wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvmodem.h
blob6bb3ee22b7c959d11bccb1091e496c7550096fe2
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * Copyright (C) 1999 Red Hat, Inc.
7 * Definition of the WvModemBase and WvModem classes. Inherit from WvFile,
8 * but do various important details related to modems, like setting baud
9 * rates and dropping DTR and the like.
13 #ifndef __WVMODEM_H
14 #define __WVMODEM_H
16 #include "wvlockdev.h"
17 #include "wvfile.h"
18 #include "wvlog.h"
19 #include <termios.h>
21 #ifndef IUCLC
22 #define IUCLC 0
23 #endif
25 #ifndef OLCUC
26 #define OLCUC 0
27 #endif
29 #ifndef XCASE
30 #define XCASE 0
31 #endif
33 /**
34 * WvModemBase provides the methods used to control a modem, but
35 * without real implementation for most of them, so that they can
36 * be used in contexts where modem control is undesirable without
37 * reimplementing calling code for such uses.
39 class WvModemBase : public WvFile
41 protected:
42 struct termios t;
43 int baud;
45 WvModemBase() { }
47 int get_real_speed();
49 public:
50 bool die_fast;
52 WvModemBase(int _fd);
53 virtual ~WvModemBase();
55 /** do-nothing method that is not needed in WvModemBase */
56 virtual void close();
58 /** do-nothing method that is not needed in WvModemBase */
59 virtual bool carrier();
61 /** do-nothing method that is not needed in WvModemBase */
62 virtual int speed(int _baud);
64 /** this one really is needed */
65 int getspeed()
66 { return baud; }
68 /** may need to hangup for redial reasons */
69 virtual void hangup();
71 public:
72 const char *wstype() const { return "WvModemBase"; }
76 /**
77 * WvModem implements a named modem that really needs to be opened,
78 * closed, and manipulated in lots of ways
80 class WvModem : public WvModemBase
82 private:
83 WvLockDev lock;
84 WvLog log;
85 bool have_old_t;
86 struct termios old_t;
87 bool closing;
88 bool no_reset;
90 /**
91 * Setup all of the terminal characteristics, and leave the modem in CLOCAL
92 * mode to make sure that we can communicate easily with the modem later.
94 void setup_modem(bool rtscts);
96 /** Check the status of the modem */
97 int getstatus();
99 public:
100 WvModem(WvStringParm filename, int _baud, bool rtscts = true,
101 bool _no_reset = false);
102 virtual ~WvModem();
104 /** Close the connection to the modem */
105 virtual void close();
107 /** Is there a carrier present? */
108 virtual bool carrier();
111 * _baud is the desired speed, that you wish the modem to communicate with,
112 * and this method returns the actual speed that the modem managed to achieve.
114 virtual int speed(int _baud);
116 public:
117 const char *wstype() const { return "WvModem"; }
120 #endif