summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/sms/services/kopete_unix_serial.h
blob: fd8ed74c0776301fbb79e993d2d1c4ce1c1e198e (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
63
64
65
66
67
68
69
70
71
// *************************************************************************
// * Taken from the GSM TA/ME library
// *
// * File:    gsm_unix_port.h
// *
// * Purpose: UNIX serial port implementation with extras
// *
// * Original Author:  Peter Hofmann ([email protected])
// * Modified by: Justin Huff ([email protected])
// *
// * Created: 4.5.1999
// *************************************************************************

#ifndef GSM_UNIX_SERIAL_KOPETE_H
#define GSM_UNIX_SERIAL_KOPETE_H

#include "config.h"
#ifdef INCLUDE_SMSGSM

#include <string>
#include <gsmlib/gsm_error.h>
#include <gsmlib/gsm_port.h>
#include <gsmlib/gsm_util.h>
#include <sys/types.h>
#include <termios.h>

#include <tqobject.h>

class TQSocketNotifier;
namespace gsmlib
{

class KopeteUnixSerialPort : public TQObject, public Port
{
	TQ_OBJECT
	

protected:
	int _fd;                    // file descriptor for device
	int _oldChar;               // character set by putBack() (-1 == none)
	long int _timeoutVal;       // timeout for getLine/readByte

	TQSocketNotifier* _readNotifier;

	// throw GsmException include UNIX errno
	void throwModemException(std::string message) throw(GsmException);

public:
	// create Port given the UNIX device name
	KopeteUnixSerialPort(std::string device, speed_t lineSpeed = DEFAULT_BAUD_RATE,
				   std::string initString = DEFAULT_INIT_STRING,
				   bool swHandshake = false)
	  throw(GsmException);
	virtual ~KopeteUnixSerialPort();

	// inherited from Port
	void putBack(unsigned char c);
	int readByte() throw(GsmException);
	std::string getLine() throw(GsmException);
	void putLine(std::string line,
						 bool carriageReturn = true) throw(GsmException);
	bool wait(GsmTime timeout) throw(GsmException);
	void setTimeOut(unsigned int timeout);

signals:
	void activated();
};

}
#endif
#endif // GSM_UNIX_SERIAL_KOPETE_H