summaryrefslogtreecommitdiff
path: root/comm/OLD/TextService.h
blob: f238d66da9d6118af5a7d7fea80c7f0926922eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 *	The Unix Channel
 *
 *	by Michel Beaudouin-Lafon
 *
 *	Copyright 1990-1993
 *	Laboratoire de Recherche en Informatique (LRI)
 *
 *	Text services
 *
 *	$Id$
 *	$CurLog$
 */

#ifndef TextService_H_
#define TextService_H_

class UchTextService : public UchTextStream {
friend	class	UchServiceStarter;

public:
enum	status {
			isUnavailable,	// address not found in port server
			isError,	// could not init connection
			isRunning,	// connection established
			isLost		// no connection (auto-starting)
		};

protected:
	status	StatusFlag;
	UchServiceStarter*	Starter;
	bool		Closed;
	CcuString	User;
	CcuString	Service;
	CcuString	Host;
	
	void	Closing (bool);
	void	Flush ();
	status	Restart ();
	void	AutoStart (int = -1, int = -1);
virtual	void	LostServer ();
virtual	void	GotServer ();
virtual	void	AbandonRestart ();
	cmd_res	Execute (const UchTextLine&);

public:
		UchTextService (UchBaseMultiplexer&, const char*, const char* = 0);
		UchTextService ();
		~UchTextService ();
	void	Init (UchBaseMultiplexer&, const char*, const char* = 0);
	status	GetStatus ()	{ return StatusFlag; }
	int	GetRetryTime ();
	int	GetMaxRetries ();
	void	Close ();	// close after output buffer emptied
	void	CloseNow ();	// close now

};

// the simplest interface to a server.
extern	bool	TellServer (const char*, const char*, const char*);

#endif