Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

modem.h

Go to the documentation of this file.
00001 /*
00002  *              kPPP: A pppd Front End for the KDE project
00003  *
00004  * $Id: modem.h,v 1.5 2003/08/09 17:14:55 kergoth Exp $
00005  *
00006  *              Copyright (C) 1997 Bernd Johannes Wuebben
00007  *                      wuebben@math.cornell.edu
00008  *
00009  * This file was added by Harri Porten <porten@tu-harburg.de>
00010  *
00011  *
00012  * This program is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Library General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2 of the License, or (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Library General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Library General Public
00023  * License along with this program; if not, write to the Free
00024  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  */
00026 
00027 #ifndef _MODEM_H_
00028 #define _MODEM_H_
00029 
00030 #include <qdir.h>
00031 
00032 #include <sys/types.h>
00033 #include <termios.h>
00034 #include <unistd.h>
00035 
00036 #include <qsocketnotifier.h>
00037 
00038 class PPPData;
00039 
00040 void    alarm_handler(int);
00041 const char *pppdPath();
00042 
00043 class Modem : public QObject {
00044   Q_OBJECT
00045 public:
00046   Modem(PPPData*);
00047   ~Modem();
00048 
00049   const QString getDevice() {return device;};
00050   void setDevice(const QString dev) {device = dev;};
00051 
00052   void save();
00053 
00054   bool opentty();
00055   bool closetty();
00056   bool hangup();
00057   bool writeChar(unsigned char);
00058   bool writeLine(const char *);
00059   bool dataMode() const { return data_mode; }
00060   void setDataMode(bool set) { data_mode = set; }
00061   const QString modemMessage();
00062   speed_t modemspeed();
00063   static QString parseModemSpeed(const QString &);
00064   void notify(const QObject *, const char *);
00065   void stop();
00066   void flush();
00067 
00068   int     lockdevice();
00069   void    unlockdevice();
00070 
00071   bool setSecret(int,const char*,const char*);
00072   bool removeSecret(int);
00073   void killPPPDaemon();
00074   int  pppdExitStatus();
00075   bool execPPPDaemon(const QString & arguments);
00076   int  openResolv(int flags);
00077   bool setHostname(const QString & name);
00078 
00079   QString pppDevice()const;
00080     void setPPPDevice( const QString& );
00081     pid_t pppPID()const;
00082     void setPPPDPid( pid_t );
00083 
00084 public:
00085   enum Auth { PAP = 1, CHAP };
00086   //  static Modem *modem;
00087   int lastStatus;
00088 
00089 signals:
00090   void charWaiting(unsigned char);
00091 
00092 private slots:
00093   void startNotifier();
00094   void stopNotifier();
00095   void readtty(int);
00096   void slotModemDebug(int);
00097 
00098 private:
00099   enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
00100   enum { Original=0x100, New=0x200, Old=0x400 } Version;
00101 
00102   const char* authFile(Auth method, int version = Original );
00103   bool createAuthFile(Auth method,const char *username,const char *password);
00104   bool removeAuthFile(Auth method);
00105   bool execpppd(const char *arguments);
00106   bool killpppd();
00107   void parseargs(char* buf, char** args);
00108   void escape_to_command_mode();
00109   int openLockfile(QString,int);
00110 
00111 private:
00112   QString device;
00113   QString lockfile;
00114   int modemfd;
00115   int pppdPid;
00116   int _pppdExitStatus;
00117   QSocketNotifier *sn;
00118     QSocketNotifier *m_modemDebug;
00119   bool data_mode;
00120   QString errmsg;
00121   struct termios initial_tty;
00122   struct termios tty;
00123   bool modem_is_locked;
00124   PPPData *_pppdata;
00125     int m_pppdLOG[2];
00126     QString m_pppdDev;
00127 };
00128 
00129 #endif
00130 
00131 

Generated on Sat Nov 5 16:17:50 2005 for OPIE by  doxygen 1.4.2