summaryrefslogtreecommitdiffstats
path: root/kppp/pppdata.h
blob: 9e94596256dcf34a9980953260ae14a5500f9858 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
/*
 *
 *            kPPP: A pppd front end for the KDE project
 *
 * $Id$
 *
 *            Copyright (C) 1997 Bernd Johannes Wuebben
 *                   wuebben@math.cornell.edu
 *
 * based on EzPPP:
 * Copyright (C) 1997  Jay Painter
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef _PPPDATA_H_
#define _PPPDATA_H_

#include <unistd.h>
#include <sys/types.h>

#include <tqstring.h>
#include <tqstringlist.h>
#include <tqcolor.h>

#include "kpppconfig.h"

class TDEConfig;

// string lengths

#define PATH_SIZE 120
#define MODEMSTR_SIZE 80
#define ACCNAME_SIZE 50
#define PHONENUMBER_SIZE 60
#define COMMAND_SIZE 255
#define IPADDR_SIZE 15
#define DOMAIN_SIZE 50
#define TIMEOUT_SIZE 60

//
// keys for config file
//

// groups
#define GENERAL_GRP        "General"
#define MODEM_GRP          "Modem"
#define ACCOUNT_GRP        "Account"
#define GRAPH_GRP          "Graph"
#define WINPOS_GRP         "WindowPosition"

// general
#define DEFAULTACCOUNT_KEY "DefaultAccount"
#define DEFAULTMODEM_KEY   "DefaultModem"
#define PPPDVERSION_KEY    "pppdVersion"
#define PPPDTIMEOUT_KEY    "pppdTimeout"
#define SHOWCLOCK_KEY      "ShowClock"
#define SHOWLOGWIN_KEY     "ShowLogWindow"
#define AUTOREDIAL_KEY     "AutomaticRedial"
#define DISCONNECT_KEY     "DisconnectOnXServerExit"
#define QUITONDISCONNECT_KEY "QuitOnDisconnect"
#define NUMACCOUNTS_KEY    "NumberOfAccounts"
#define NUMMODEMS_KEY      "NumberOfModems"
#define REDIALONNOCARR_KEY "RedialOnNoCarrier"
#define ID_KEY		   "ID"

// modem
#define MOD_NAME_KEY       "Name"
#define MODEMDEV_KEY       "Device"
#define LOCKFILE_KEY       "UseLockFile"
#define FLOWCONTROL_KEY    "FlowControl"
#define SPEED_KEY          "Speed"
#define TIMEOUT_KEY        "Timeout"
#define TONEDURATION_KEY   "ToneDuration"
#define BUSYWAIT_KEY       "BusyWait"
#define INITSTR_KEY        "InitString"
#define INITRESP_KEY       "InitResponse"
#define PREINITDELAY_KEY   "PreInitDelay"
#define INITDELAY_KEY      "InitDelay"
#define NODTDETECT_KEY     "NoDialToneDetection"
#define DIALTONEWAIT_KEY   "WaitForDialTone"
#define DIALSTR_KEY        "DialString"
#define CONNECTRESP_KEY    "ConnectResponse"
#define BUSYRESP_KEY       "BusyResponse"
#define NOCARRIERRESP_KEY  "NoCarrierResponse"
#define NODIALTONERESP_KEY "NoDialToneResp"
#define HANGUPSTR_KEY      "HangupString"
#define HANGUPRESP_KEY     "HangUpResponse"
#define DLPRESP_KEY        "DLPResponse"
#define ANSWERSTR_KEY      "AnswerString"
#define RINGRESP_KEY       "RingResponse"
#define ANSWERRESP_KEY     "AnswerResponse"
#define ENTER_KEY          "Enter"
#define ESCAPESTR_KEY      "EscapeString"
#define ESCAPERESP_KEY     "EscapeResponse"
#define ESCAPEGUARDTIME_KEY "EscapeGuardTime"
#define USECDLINE_KEY      "UseCDLine"
#define VOLUME_HIGH        "VolumeHigh"
#define VOLUME_MEDIUM      "VolumeMedium"
#define VOLUME_OFF         "VolumeOff"
#define VOLUME_KEY         "Volume"

// account
#define ACC_NAME_KEY       "Name"
#define PHONENUMBER_KEY    "Phonenumber"
#define DIAL_PREFIX_KEY    "DialPrefix"
#define AUTH_KEY           "Authentication"
#define STORED_PASSWORD_KEY "Password"
#define STORED_USERNAME_KEY "Username"
#define STORE_PASSWORD_KEY "StorePassword"
#define CALLBACK_TYPE_KEY  "CallbackType"
#define CALLBACK_PHONE_KEY "CallbackPhone"
#define BEFORE_CONNECT_KEY  "BeforeConnect"
#define COMMAND_KEY        "Command"
#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
#define BEFORE_DISCONNECT_KEY  "BeforeDisconnect"
#define IPADDR_KEY         "IPAddr"
#define SUBNETMASK_KEY     "SubnetMask"
#define ACCTENABLED_KEY    "AccountingEnabled"
#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
#define ACCTFILE_KEY       "AccountingFile"
#define AUTONAME_KEY       "AutoName"
#define GATEWAY_KEY        "Gateway"
#define DEFAULTROUTE_KEY   "DefaultRoute"
#define DOMAIN_KEY         "Domain"
#define DNS_KEY            "DNS"
#define AUTODNS_KEY        "AutoDNS"
#define EXDNSDISABLED_KEY  "ExDNSDisabled"
#define SCRIPTCOM_KEY      "ScriptCommands"
#define SCRIPTARG_KEY      "ScriptArguments"
#define PPPDARG_KEY        "pppdArguments"
#define PPP_DEBUG_OPTION   "PPPDebug"
#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
#define DOCKING_KEY        "DockIntoPanel"
#define TOTALCOSTS_KEY     "TotalCosts"
#define TOTALBYTES_KEY     "TotalBytes"

// graph colors
#define GENABLED           "Enabled"
#define GCOLOR_BG          "Background"
#define GCOLOR_TEXT        "Text"
#define GCOLOR_IN          "InBytes"
#define GCOLOR_OUT         "OutBytes"

// pppd errors
#define E_IF_TIMEOUT       1
#define E_PPPD_DIED        2
#define E_CBCP_WAIT       14

// window position
#define WINPOS_CONWIN_X    "WindowPositionConWinX"
#define WINPOS_CONWIN_Y    "WindowPositionConWinY"
#define WINPOS_STATWIN_X   "WindowPositionStatWinX"
#define WINPOS_STATWIN_Y   "WindowPositionStatWinY"

class PPPData {
public:
  PPPData();
  ~PPPData() {};

  enum { NumInitStrings = 2 };

  // general functions
  bool open();
  void save();
  void cancel();
  int  access() const;       // read/write access

  // function to read/write date to configuration file
  TQString readConfig(const TQString &, const TQString &, const TQString &);
  int readNumConfig(const TQString &, const TQString &, int);
  bool readListConfig(const TQString &, const TQString &,
                      TQStringList &, char sep = ',');
  void writeConfig(const TQString &, const TQString &, const TQString &);
  void writeConfig(const TQString &, const TQString &, int);
  void writeListConfig(const TQString &, const TQString &,
                       TQStringList &, char sep = ',');

  // return the current account group
  TQString currentAccountGroup() { return caccountgroup; }
  // return the current modem group
  TQString currentModemGroup() { return cmodemgroup; }

  // functions to set/get general kppp info
  TQString password() const;
  void setPassword(const TQString &);

  const TQString defaultAccount();
  void setDefaultAccount(const TQString &);

	const TQString defaultModem();
  void setDefaultModem(const TQString &);

  void set_xserver_exit_disconnect(bool set);
  bool get_xserver_exit_disconnect();

  void set_redial_on_nocarrier(bool set);
  bool get_redial_on_nocarrier();

  void setPPPDebug(bool set);
  bool getPPPDebug();

  void set_quit_on_disconnect(bool);
  bool quit_on_disconnect();

  void set_show_clock_on_caption(bool set);
  bool get_show_clock_on_caption();

  void set_show_log_window(bool set);
  bool get_show_log_window();

  void set_automatic_redial(bool set);
  bool automatic_redial();

  void set_iconify_on_connect(bool set);
  bool get_iconify_on_connect();

  void set_dock_into_panel(bool set);
  bool get_dock_into_panel();

  const TQString enter();
  void setEnter(const TQString &);

  TQString pppdVersion();
  bool pppdVersionMin(int ver, int mod, int patch);

  int pppdTimeout();
  void setpppdTimeout(int);

	// functions to set/get account information
  int modemCount() const;
  bool setModem(const TQString &);
  bool setModemByIndex(int);

  bool isUniqueModname(const TQString &);

  bool deleteModem();
  bool deleteModem(const TQString &);
  int newmodem();
  int copymodem(int i);

  const TQString modname();
  void setModname(const TQString &);


  int busyWait();
  void setbusyWait(int);

  bool modemLockFile();
  void setModemLockFile(bool set);

  int modemEscapeGuardTime();
  void setModemEscapeGuardTime(int i);

  void setModemEscapeStr(const TQString &);
  const TQString modemEscapeStr();

  void setModemEscapeResp(const TQString &);
  const TQString modemEscapeResp();

  const TQString modemDevice();
  void setModemDevice(const TQString &);

  TQString flowcontrol();
  void setFlowcontrol(const TQString &);

  int modemTimeout();
  void setModemTimeout(int);

  int modemToneDuration();
  void setModemToneDuration(int);

  TQString volumeInitString();
  int volume();
  void setVolume(int);

  int waitForDialTone();
  void setWaitForDialTone(int i);

  // modem command strings/responses
  const TQString modemInitStr(int i);
  void setModemInitStr(int i, const TQString &);

  const TQString modemInitResp();
  void setModemInitResp(const TQString &);

  int modemPreInitDelay();
  void setModemPreInitDelay(int);

  int modemInitDelay();
  void setModemInitDelay(int);

  TQString modemNoDialToneDetectionStr();
  void setModemNoDialToneDetectionStr(const TQString &);

  const TQString modemDialStr();
  void setModemDialStr(const TQString &);

  const TQString modemConnectResp();
  void setModemConnectResp(const TQString &);

  const TQString modemBusyResp();
  void setModemBusyResp(const TQString &);

  const TQString modemNoCarrierResp();
  void setModemNoCarrierResp(const TQString &);

  const TQString modemNoDialtoneResp();
  void setModemNoDialtoneResp(const TQString &);

  const TQString modemHangupStr();
  void setModemHangupStr(const TQString &);

  const TQString modemHangupResp();
  void setModemHangupResp(const TQString &);

  TQString modemDLPResp();
  void setModemDLPResp(const TQString &);

  const TQString modemAnswerStr();
  void setModemAnswerStr(const TQString &);

  const TQString modemRingResp();
  void setModemRingResp(const TQString &);

  const TQString modemAnswerResp();
  void setModemAnswerResp(const TQString &);

  TQString volumeOff();
  void setVolumeOff(const TQString &);

  TQString volumeMedium();
  void setVolumeMedium(const TQString &);

  TQString volumeHigh();
  void setVolumeHigh(const TQString &);

#if 0
  void setUseCDLine(const int n);
  int  UseCDLine();
#endif

  // functions to set/get account information
  int accountCount() const;
  bool setAccount(const TQString &);
  bool setAccountByIndex(int);

  bool isUniqueAccname(const TQString &);

  bool deleteAccount();
  bool deleteAccount(const TQString &);
  int newaccount();
  int copyaccount(int i);

  const TQString accname();
  void setAccname(const TQString &);

  TQStringList &phonenumbers();
  const TQString phonenumber();
  void setPhonenumber(const TQString &);

  const TQString dialPrefix();
  void setDialPrefix(const TQString &);

  int authMethod();
  void setAuthMethod(int);

  const TQString storedUsername();
  void setStoredUsername(const TQString &);

  const TQString storedPassword();
  void setStoredPassword(const TQString &);

  bool storePassword();
  void setStorePassword(bool);

  int callbackType();
  void setCallbackType(int);

  TQString callbackPhone();
  void setCallbackPhone(const TQString &);

  bool waitCallback();
  void setWaitCallback(bool);

  const TQString speed();
  void setSpeed(const TQString &);

  const TQString command_before_connect();
  void setCommand_before_connect(const TQString &);

  const TQString command_on_connect();
  void setCommand_on_connect(const TQString &);

  const TQString command_on_disconnect();
  void setCommand_on_disconnect(const TQString &);

  const TQString command_before_disconnect();
  void setCommand_before_disconnect(const TQString &);

  const TQString ipaddr();
  void setIpaddr(const TQString &);

  const TQString subnetmask();
  void setSubnetmask(const TQString &);

  bool AcctEnabled();
  void setAcctEnabled(bool set);

  int VolAcctEnabled();
  void setVolAcctEnabled(int set);

  bool autoDNS();
  void setAutoDNS(bool set);

  bool exDNSDisabled();
  void setExDNSDisabled(bool set);

  bool autoname();
  void setAutoname(bool set);

  const TQString gateway();
  void setGateway(const TQString &);

  bool defaultroute();
  void setDefaultroute(bool set);

  TQStringList &dns();
  void setDns(TQStringList &);

  const TQString domain();
  void setDomain(const TQString &);

  TQStringList &scriptType();
  void setScriptType(TQStringList &);

  TQStringList &script();
  void setScript(TQStringList &);

  TQStringList &pppdArgument();
  void setpppdArgumentDefaults();
  void setpppdArgument(TQStringList &);

  //functions to change/set the child pppd process info
  bool pppdRunning() const;
  void setpppdRunning(bool set);

  int pppdError() const;
  void setpppdError(int err);

  // functions to set/query the accounting info
  const TQString accountingFile();
  void setAccountingFile(const TQString &);

  const TQString totalCosts();
  void setTotalCosts(const TQString &);

  int totalBytes();
  void  setTotalBytes(int);

  // graphing widget
  void setGraphingOptions(bool enabled,
			  TQColor bg,
			  TQColor text,
			  TQColor in,
			  TQColor out);
  void graphingOptions(bool &enabled,
		       TQColor &bg,
		       TQColor &text,
		       TQColor &in,
		       TQColor &out);
  bool graphingEnabled();

  // window positions
  void winPosConWin(int &, int &);
  void setWinPosConWin(int, int);
  void winPosStatWin(int &, int &);
  void setWinPosStatWin(int, int);

private:
  TQString passwd;
  TDEConfig* config;                       // configuration object
  int accounthighcount;                  // index of highest account
  int caccount;                          // index of the current account
	int modemhighcount;                    // index of highest modem
  int cmodem;                            // index of the current modem
  TQString cmodemgroup;                   // name of current modem group
  TQString caccountgroup;                 // name of current account group
  pid_t suidprocessid;                   // process ID of setuid child
  bool pppdisrunning;                    // pppd process
                                         // daemon
  int pppderror;                         // error encounterd running pppd
  int pppdVer, pppdMod, pppdPatch;       // pppd version
  bool waitcallback;			 // callback waiting flag

  TQStringList phonelist;
};

extern PPPData gpppdata;

#endif