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

pppdata.h

Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  *
00003  *            kPPP: A pppd front end for the KDE project
00004  *
00005  * $Id: pppdata.h,v 1.10 2004/10/14 01:44:27 zecke Exp $
00006  *
00007  *            Copyright (C) 1997 Bernd Johannes Wuebben
00008  *                   wuebben@math.cornell.edu
00009  *
00010  * based on EzPPP:
00011  * Copyright (C) 1997  Jay Painter
00012  *
00013  * This program is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Library General Public
00015  * License as published by the Free Software Foundation; either
00016  * version 2 of the License, or (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * Library General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Library General Public
00024  * License along with this program; if not, write to the Free
00025  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00026  */
00027 
00028 #ifndef _PPPDATA_H_
00029 #define _PPPDATA_H_
00030 
00031 #include <unistd.h>
00032 #include <sys/types.h>
00033 
00034 #include <qcolor.h>
00035 #include <qmap.h>
00036 #include <qstring.h>
00037 #include <qstringlist.h>
00038 
00039 #include "kpppconfig.h"
00040 
00041 class Config;
00042 
00043 // string lengths
00044 
00045 #define PATH_SIZE 120
00046 #define MODEMSTR_SIZE 80
00047 #define ACCNAME_SIZE 50
00048 #define PHONENUMBER_SIZE 60
00049 #define COMMAND_SIZE 255
00050 #define IPADDR_SIZE 15
00051 #define DOMAIN_SIZE 50
00052 #define TIMEOUT_SIZE 60
00053 
00054 //
00055 // keys for config file
00056 //
00057 
00058 // groups
00059 #define GENERAL_GRP        "PPP_General"
00060 #define MODEM_GRP          "PPP_Modem"
00061 #define ACCOUNT_GRP        "PPP_Account"
00062 #define ACCLIST_GRP        "PPP_Accounts_List"
00063 //#define GRAPH_GRP          "Graph"
00064 //#define WINPOS_GRP         "WindowPosition"
00065 
00066 // general
00067 #define ACCOUNT_LIST       "AccountList"
00068 #define DEVICE_LIST        "DeviceList"
00069 #define DEFAULTACCOUNT_KEY "DefaultAccount"
00070 #define PPPDVERSION_KEY    "pppdVersion"
00071 #define PPPDTIMEOUT_KEY    "pppdTimeout"
00072 #define SHOWCLOCK_KEY      "ShowClock"
00073 #define SHOWLOGWIN_KEY     "ShowLogWindow"
00074 #define AUTOREDIAL_KEY     "AutomaticRedial"
00075 #define DISCONNECT_KEY     "DisconnectOnXServerExit"
00076 #define QUITONDISCONNECT_KEY "QuitOnDisconnect"
00077 #define NUMACCOUNTS_KEY    "HighcountAccounts"
00078 #define NUMDEVICES_KEY    "HighcountDevices"
00079 #define ID_KEY             "ID"
00080 
00081 // modem
00082 #define MODEMNAME_KEY      "Modem_Name"
00083 #define MODEMDEV_KEY       "Device"
00084 #define LOCKFILE_KEY       "UseLockFile"
00085 #define FLOWCONTROL_KEY    "FlowControl"
00086 #define SPEED_KEY          "Speed"
00087 #define TIMEOUT_KEY        "Timeout"
00088 #define TONEDURATION_KEY   "ToneDuration"
00089 #define BUSYWAIT_KEY       "BusyWait"
00090 #define INITSTR_KEY        "InitString"
00091 #define INITRESP_KEY       "InitResponse"
00092 #define PREINITDELAY_KEY   "PreInitDelay"
00093 #define INITDELAY_KEY      "InitDelay"
00094 #define NODTDETECT_KEY     "NoDialToneDetection"
00095 #define DIALTONEWAIT_KEY   "WaitForDialTone"
00096 #define DIALSTR_KEY        "DialString"
00097 #define CONNECTRESP_KEY    "ConnectResponse"
00098 #define BUSYRESP_KEY       "BusyResponse"
00099 #define NOCARRIERRESP_KEY  "NoCarrierResponse"
00100 #define NODIALTONERESP_KEY "NoDialToneResp"
00101 #define HANGUPSTR_KEY      "HangupString"
00102 #define HANGUPRESP_KEY     "HangUpResponse"
00103 #define ANSWERSTR_KEY      "AnswerString"
00104 #define RINGRESP_KEY       "RingResponse"
00105 #define ANSWERRESP_KEY     "AnswerResponse"
00106 #define ENTER_KEY          "Enter"
00107 #define ESCAPESTR_KEY      "EscapeString"
00108 #define ESCAPERESP_KEY     "EscapeResponse"
00109 #define ESCAPEGUARDTIME_KEY "EscapeGuardTime"
00110 #define USECDLINE_KEY      "UseCDLine"
00111 #define VOLUME_HIGH        "VolumeHigh"
00112 #define VOLUME_MEDIUM      "VolumeMedium"
00113 #define VOLUME_OFF         "VolumeOff"
00114 #define VOLUME_KEY         "Volume"
00115 
00116 // account
00117 #define NAME_KEY           "Name"
00118 #define PHONENUMBER_KEY    "Phonenumber"
00119 #define DIAL_PREFIX_KEY    "DialPrefix"
00120 #define AUTH_KEY           "Authentication"
00121 #define STORED_PASSWORD_KEY "Password"
00122 #define STORED_USERNAME_KEY "Username"
00123 #define STORE_PASSWORD_KEY "StorePassword"
00124 #define BEFORE_CONNECT_KEY  "BeforeConnect"
00125 #define COMMAND_KEY        "Command"
00126 #define DISCONNECT_COMMAND_KEY "DisconnectCommand"
00127 #define BEFORE_DISCONNECT_KEY  "BeforeDisconnect"
00128 #define IPADDR_KEY         "IPAddr"
00129 #define SUBNETMASK_KEY     "SubnetMask"
00130 #define ACCTENABLED_KEY    "AccountingEnabled"
00131 #define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
00132 #define ACCTFILE_KEY       "AccountingFile"
00133 #define AUTONAME_KEY       "AutoName"
00134 #define GATEWAY_KEY        "Gateway"
00135 #define DEFAULTROUTE_KEY   "DefaultRoute"
00136 #define DOMAIN_KEY         "Domain"
00137 #define DNS_KEY            "DNS"
00138 #define AUTODNS_KEY        "AutoDNS"
00139 #define EXDNSDISABLED_KEY  "ExDNSDisabled"
00140 #define SCRIPTCOM_KEY      "ScriptCommands"
00141 #define SCRIPTARG_KEY      "ScriptArguments"
00142 #define PPPDARG_KEY        "pppdArguments"
00143 #define PPP_DEBUG_OPTION   "PPPDebug"
00144 #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
00145 #define DOCKING_KEY        "DockIntoPanel"
00146 #define TOTALCOSTS_KEY     "TotalCosts"
00147 #define TOTALBYTES_KEY     "TotalBytes"
00148 
00149 // pppd errors
00150 #define E_IF_TIMEOUT       1
00151 #define E_PPPD_DIED        2
00152 
00153 // account list
00154 #define ACCOUNTS_COUNT     "Accounts_Count"
00155 #define ACOUNTS_DEV        "Accounts_Modem"
00156 #define ACOUNTS_ACC        "Accounts_Account"
00157 
00158 #define DEVICESNAMES_LIST  "DevicesNames_List"
00159 #define DEVICES_LIST       "Devices_List"
00160 #define DEVICES_LIST_SEP   ','
00161 
00162 class PPPData {
00163 public:
00164     PPPData();
00165     ~PPPData() {};
00166 
00167     enum { NumInitStrings = 2 };
00168     enum LineTermination {
00169         EndCR,
00170         EndLF,
00171         EndCRLF
00172     };
00173 
00174     enum FlowControl {
00175         FlowHardware,
00176         FlowSoftware,
00177         FlowNone
00178     };
00179 
00180     // general functions
00181     void save();
00182     void cancel();
00183 
00184     QStringList getAccountList();
00185 
00186     static QMap<QString,QString> getConfiguredInterfaces();
00187     static void setConfiguredInterfaces( QMap<QString,QString> );
00188 
00189     // function to read/write date to configuration file
00190     static Config config();
00191     QString readConfig(const QString &, const QString &, const QString &);
00192     int readNumConfig(const QString &, const QString &, int);
00193     bool readListConfig(const QString &, const QString &,
00194                       QStringList &, char sep = ',');
00195     void writeConfig(const QString &, const QString &, const QString &);
00196     void writeConfig(const QString &, const QString &, int);
00197     void writeListConfig(const QString &, const QString &,
00198                        QStringList &, char sep = ',');
00199 
00200     // return the current account group
00201     QString currentGroup() { return cgroup; }
00202     QString modemGroup();
00203 
00204   // functions to set/get general kppp info
00205   QString password();
00206   void setPassword(const QString &);
00207 
00208 //  int currentAccountID() { return caccount; };
00209   const QString defaultAccount();
00210   void setDefaultAccount(const QString &);
00211 
00212   void set_xserver_exit_disconnect(bool set);
00213   bool get_xserver_exit_disconnect();
00214 
00215   void setPPPDebug(bool set);
00216   bool getPPPDebug();
00217 
00218   void set_quit_on_disconnect(bool);
00219   bool quit_on_disconnect();
00220 
00221   void set_show_clock_on_caption(bool set);
00222   bool get_show_clock_on_caption();
00223 
00224   void set_show_log_window(bool set);
00225   bool get_show_log_window();
00226 
00227   void set_automatic_redial(bool set);
00228   bool automatic_redial();
00229 
00230 //   void set_iconify_on_connect(bool set);
00231 //   bool get_iconify_on_connect();
00232 
00233 //   void set_dock_into_panel(bool set);
00234 //   bool get_dock_into_panel();
00235 
00236   enum LineTermination enter();
00237   void setEnter(enum LineTermination);
00238 
00239   QString pppdVersion();
00240   bool pppdVersionMin(int ver, int mod, int patch);
00241 
00242   int pppdTimeout();
00243   void setpppdTimeout(int);
00244 
00245   int busyWait();
00246   void setbusyWait(int);
00247 
00248   bool modemLockFile();
00249   void setModemLockFile(bool set);
00250 
00251   int modemEscapeGuardTime();
00252   void setModemEscapeGuardTime(int i);
00253 
00254   void setModemEscapeStr(const QString &);
00255   const QString modemEscapeStr();
00256 
00257   void setModemEscapeResp(const QString &);
00258   const QString modemEscapeResp();
00259 
00260 //  const QString modemName();
00261 //  bool setModemName(const QString &);
00262 //  bool changeModemName(const QString &);
00263 
00264    const QString modemDevice();
00265    bool setModemDevice(const QString &);
00266 
00267   enum FlowControl flowcontrol();
00268   void setFlowcontrol(enum FlowControl);
00269 
00270   int modemTimeout();
00271   void setModemTimeout(int);
00272 
00273   int modemToneDuration();
00274   void setModemToneDuration(int);
00275 
00276   QString volumeInitString();
00277   int volume();
00278   void setVolume(int);
00279 
00280   int waitForDialTone();
00281   void setWaitForDialTone(int i);
00282 
00283   // modem command strings/responses
00284   const QString modemInitStr(int i);
00285   void setModemInitStr(int i, const QString &);
00286 
00287   const QString modemInitResp();
00288   void setModemInitResp(const QString &);
00289 
00290   int modemPreInitDelay();
00291   void setModemPreInitDelay(int);
00292 
00293   int modemInitDelay();
00294   void setModemInitDelay(int);
00295 
00296   QString modemNoDialToneDetectionStr();
00297   void setModemNoDialToneDetectionStr(const QString &);
00298 
00299   const QString modemDialStr();
00300   void setModemDialStr(const QString &);
00301 
00302   const QString modemConnectResp();
00303   void setModemConnectResp(const QString &);
00304 
00305   const QString modemBusyResp();
00306   void setModemBusyResp(const QString &);
00307 
00308   const QString modemNoCarrierResp();
00309   void setModemNoCarrierResp(const QString &);
00310 
00311   const QString modemNoDialtoneResp();
00312   void setModemNoDialtoneResp(const QString &);
00313 
00314   const QString modemHangupStr();
00315   void setModemHangupStr(const QString &);
00316 
00317   const QString modemHangupResp();
00318   void setModemHangupResp(const QString &);
00319 
00320   const QString modemAnswerStr();
00321   void setModemAnswerStr(const QString &);
00322 
00323   const QString modemRingResp();
00324   void setModemRingResp(const QString &);
00325 
00326   const QString modemAnswerResp();
00327   void setModemAnswerResp(const QString &);
00328 
00329   QString volumeOff();
00330   void setVolumeOff(const QString &);
00331 
00332   QString volumeMedium();
00333   void setVolumeMedium(const QString &);
00334 
00335   QString volumeHigh();
00336   void setVolumeHigh(const QString &);
00337 
00338   // functions to set/get account information
00339   int count() const;
00340   bool setAccount(const QString &);
00341 //  bool setAccountbyIndex(int);
00342 
00343   bool isUniqueAccname(const QString &);
00344   bool isUniqueDevname(const QString &);
00345 
00346   bool deleteAccount();
00347   bool deleteAccount(const QString &);
00348   int newaccount();
00349   int copyaccount(const QString&);
00350 
00351   const QString accname();
00352   void setAccname(const QString &);
00353 
00354   QStringList &phonenumbers();
00355   const QString phonenumber();
00356   void setPhonenumber(const QString &);
00357 
00358   const QString dialPrefix();
00359   void setDialPrefix(const QString &);
00360 
00361   int authMethod();
00362   void setAuthMethod(int);
00363 
00364   const QString storedUsername();
00365   void setStoredUsername(const QString &);
00366 
00367   const QString storedPassword();
00368   void setStoredPassword(const QString &);
00369 
00370   bool storePassword();
00371   void setStorePassword(bool);
00372 
00373   const QString speed();
00374   void setSpeed(const QString &);
00375 
00376   const QString command_before_connect();
00377   void setCommand_before_connect(const QString &);
00378 
00379   const QString command_on_connect();
00380   void setCommand_on_connect(const QString &);
00381 
00382   const QString command_on_disconnect();
00383   void setCommand_on_disconnect(const QString &);
00384 
00385   const QString command_before_disconnect();
00386   void setCommand_before_disconnect(const QString &);
00387 
00388   const QString ipaddr();
00389   void setIpaddr(const QString &);
00390 
00391   const QString subnetmask();
00392   void setSubnetmask(const QString &);
00393 
00394   bool AcctEnabled();
00395   void setAcctEnabled(bool set);
00396 
00397 //   int VolAcctEnabled();
00398 //   void setVolAcctEnabled(int set);
00399 
00400   bool autoDNS();
00401   void setAutoDNS(bool set);
00402 
00403   bool exDNSDisabled();
00404   void setExDNSDisabled(bool set);
00405 
00406   bool autoname();
00407   void setAutoname(bool set);
00408 
00409   const QString gateway();
00410   void setGateway(const QString &);
00411 
00412   bool defaultroute();
00413   void setDefaultroute(bool set);
00414 
00415   QStringList &dns();
00416   void setDns(QStringList &);
00417 
00418   const QString domain();
00419   void setDomain(const QString &);
00420 
00421   QStringList &scriptType();
00422   void setScriptType(QStringList &);
00423 
00424   QStringList &script();
00425   void setScript(QStringList &);
00426 
00427   QStringList &pppdArgument();
00428   void setpppdArgumentDefaults();
00429   void setpppdArgument(QStringList &);
00430 
00431   //functions to change/set the child pppd process info
00432   bool pppdRunning() const;
00433   void setpppdRunning(bool set);
00434 
00435   int pppdError() const;
00436   void setpppdError(int err);
00437 
00438   QStringList getDevicesList();
00439 
00440   static QString encodeWord(const QString &s);
00441 
00442   const QString devname();
00443   void setDevname(const QString &);
00444   bool setDevice(const QString& );
00445   bool deleteDevice();
00446   bool deleteDevice(const QString &);
00447   int newdevice();
00448   int copydevice(const QString&);
00449   QStringList getDevicesNamesList();
00450 
00451 private:
00452 
00453     //static PPPData *_data;
00454 //    int modemDeviceGroup;
00455     QString passwd;
00456     QString _modemName;
00457     int highcount;                         // index of highest account
00458     int highcountdev;                      // index of highest device
00459 //    int caccount;                          // index of the current account
00460     QString cgroup;                        // name of current config group
00461     pid_t suidprocessid;                   // process ID of setuid child
00462     bool pppdisrunning;                    // pppd process
00463     // daemon
00464     int pppderror;                         // error encounterd running pppd
00465     int pppdVer, pppdMod, pppdPatch;       // pppd version
00466 
00467 
00468     QStringList phonelist;
00469     QStringList accountList;
00470     QStringList deviceList;
00471     QMap<QString,QString> stringEntries;
00472     QMap<QString,int> intEntries;
00473     QMap<QString,QStringList> listEntries;
00474     QMap<QString,QChar> sepEntries;
00475 
00476 };
00477 
00478 #endif

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