summaryrefslogtreecommitdiff
authortille <tille>2003-05-25 14:25:23 (UTC)
committer tille <tille>2003-05-25 14:25:23 (UTC)
commit61c6231cdcde59f8a3ecff31b9fab37f7e9d8852 (patch) (unidiff)
tree4724031209e2263c872ad6160ea61a793f09ed1e
parentefa6dfa3428746451dd5a9b5e1ba57806ae96dba (diff)
downloadopie-61c6231cdcde59f8a3ecff31b9fab37f7e9d8852.zip
opie-61c6231cdcde59f8a3ecff31b9fab37f7e9d8852.tar.gz
opie-61c6231cdcde59f8a3ecff31b9fab37f7e9d8852.tar.bz2
save device specific settings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp110
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro4
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp27
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h4
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp54
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h16
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp24
7 files changed, 130 insertions, 109 deletions
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index ad89005..20d705d 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -264,57 +264,57 @@ void ConWindow::stopClock() {
264void ConWindow::timeclick() { 264void ConWindow::timeclick() {
265 QString tooltip = i18n("Connection: %1\n" 265// QString tooltip = i18n("Connection: %1\n"
266 "Connected at: %2\n" 266 // "Connected at: %2\n"
267 "Time connected: %3") 267 // "Time connected: %3")
268 .arg(PPPData::data()->accname()).arg(info2->text()) 268 // .arg(PPPData::data()->accname()).arg(info2->text())
269 .arg(time_string2); 269 // .arg(time_string2);
270 270
271 if(accountingEnabled) 271// if(accountingEnabled)
272 tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") 272// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
273 .arg(session_bill->text()).arg(total_bill->text()); 273 // .arg(session_bill->text()).arg(total_bill->text());
274 // volume accounting 274// // volume accounting
275 if(volumeAccountingEnabled) { 275// if(volumeAccountingEnabled) {
276 276
277 volinfo->setEnabled(TRUE); 277// volinfo->setEnabled(TRUE);
278 int bytes = PPPData::data()->totalBytes(); 278// int bytes = PPPData::data()->totalBytes();
279 volinfo->setText(prettyPrintVolume(bytes)); 279// volinfo->setText(prettyPrintVolume(bytes));
280 } 280// }
281 281
282 seconds++; 282// seconds++;
283 283
284 if(seconds >= 60 ) { 284// if(seconds >= 60 ) {
285 minutes ++; 285// minutes ++;
286 seconds = 0; 286// seconds = 0;
287 } 287// }
288 288
289 if (minutes >= 60){ 289// if (minutes >= 60){
290 minutes = 0; 290// minutes = 0;
291 hours ++; 291// hours ++;
292 } 292// }
293 293
294 if( hours >= 24){ 294// if( hours >= 24){
295 days ++; 295// days ++;
296 hours = 0; 296// hours = 0;
297 } 297// }
298 298
299 time_string.sprintf("%02d:%02d",hours,minutes); 299// time_string.sprintf("%02d:%02d",hours,minutes);
300 time_string2 = ""; 300// time_string2 = "";
301 if (days) 301// if (days)
302 time_string2.sprintf("%d d %02d:%02d:%02d", 302// time_string2.sprintf("%d d %02d:%02d:%02d",
303 days,hours,minutes,seconds); 303 // days,hours,minutes,seconds);
304 304
305 else 305// else
306 time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); 306// time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
307 307
308 caption_string = PPPData::data()->accname(); 308// caption_string = PPPData::data()->accname();
309 caption_string += " "; 309// caption_string += " ";
310 caption_string += time_string; 310// caption_string += time_string;
311 311
312 312
313 timelabel2->setText(time_string2); 313// timelabel2->setText(time_string2);
314 314
315 if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){ 315// if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){
316 // we update the Caption only once per minute not every second 316// // we update the Caption only once per minute not every second
317 // otherwise I get a flickering icon 317// // otherwise I get a flickering icon
318 this->setCaption(caption_string); 318// this->setCaption(caption_string);
319 } 319// }
320 320
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index e3c58d6..ac438dd 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -7,5 +7,5 @@ DESTDIR = $(OPIEDIR)/plugins/networksettings
7 HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h 7 HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h
8# knuminput.h knumvalidator.h 8#
9 SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp 9 SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp
10#knuminput.cpp knumvalidator.cpp 10#
11 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ 11 INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index c0f1fef..e2521a6 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -7,2 +7,4 @@
7#include "general.h" 7#include "general.h"
8#include "interface.h"
9#include "modem.h"
8#include "pppconfig.h" 10#include "pppconfig.h"
@@ -10,5 +12,5 @@
10#include "runtests.h" 12#include "runtests.h"
11#include "modem.h"
12 13
13PPPConfigWidget::PPPConfigWidget( QWidget *parent, const char *name, 14PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent,
15 const char *name,
14 bool modal, WFlags fl ) 16 bool modal, WFlags fl )
@@ -17,11 +19,14 @@ PPPConfigWidget::PPPConfigWidget( QWidget *parent, const char *name,
17 setCaption(tr("Configure Modem")); 19 setCaption(tr("Configure Modem"));
18 int result = runTests(); 20 int result = runTests();
19 if(result == TEST_CRITICAL){ 21 if(result == TEST_CRITICAL){
20 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); 22 QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
21 return; 23 return;
22 } 24 }
23
24// setFixedSize(sizeHint());
25 25
26 (void)new Modem; 26 interface = iface;
27 if (!PPPData::data()->setModemDevice( interface->getInterfaceName() ))
28 PPPData::data()->setModemDevice("/dev/modem");
29 if (!PPPData::data()->setAccount( interface->getHardwareName() ))
30 PPPData::data()->setAccount( 0 );
31 (void)new Modem;
27 32
@@ -52,2 +57,4 @@ void PPPConfigWidget::accept()
52{ 57{
58 interface->setInterfaceName( PPPData::data()->modemDevice() );
59 interface->setHardwareName( PPPData::data()->accname() );
53 PPPData::data()->save(); 60 PPPData::data()->save();
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h
index ec64878..b324b6d 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.h
+++ b/noncore/settings/networksettings/ppp/pppconfig.h
@@ -6,2 +6,3 @@
6class QTabWidget; 6class QTabWidget;
7class Interface;
7class AccountWidget; 8class AccountWidget;
@@ -15,3 +16,3 @@ public:
15 16
16 PPPConfigWidget( QWidget *parent=0, const char *name=0, 17 PPPConfigWidget( Interface*, QWidget *parent=0, const char *name=0,
17 bool modal = false, WFlags fl = 0 ); 18 bool modal = false, WFlags fl = 0 );
@@ -25,2 +26,3 @@ protected slots:
25 private: 26 private:
27 Interface *interface;
26 QTabWidget *tabWindow; 28 QTabWidget *tabWindow;
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index bb1c8ed..109e3b7 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -62,3 +62,4 @@ PPPData::PPPData()
62 pppdisrunning(false), 62 pppdisrunning(false),
63 pppderror(0) 63 pppderror(0),
64 modemDeviceGroup(-1)
64{ 65{
@@ -329,4 +330,12 @@ const QString PPPData::modemDevice() {
329 330
330void PPPData::setModemDevice(const QString &n) { 331bool PPPData::setModemDevice(const QString &n) {
331 writeConfig(modemGroup(), MODEMDEV_KEY, n); 332 //FIXME: change modem group
333 bool ret = false;
334 for (int i = 0; devices[i]; i++)
335 if (devices[i] == n){
336 modemDeviceGroup = i;
337 writeConfig(modemGroup(), MODEMDEV_KEY, n);
338 ret = true;
339 }
340 return ret;
332} 341}
@@ -1095,29 +1104,29 @@ void PPPData::setScript(QStringList &list) {
1095 1104
1096const QString PPPData::accountingFile() { 1105// const QString PPPData::accountingFile() {
1097 return readConfig(cgroup, ACCTFILE_KEY); 1106// return readConfig(cgroup, ACCTFILE_KEY);
1098} 1107// }
1099 1108
1100 1109
1101void PPPData::setAccountingFile(const QString &n) { 1110// void PPPData::setAccountingFile(const QString &n) {
1102 writeConfig(cgroup, ACCTFILE_KEY, n); 1111// writeConfig(cgroup, ACCTFILE_KEY, n);
1103} 1112// }
1104 1113
1105 1114
1106const QString PPPData::totalCosts() { 1115// const QString PPPData::totalCosts() {
1107 return readConfig(cgroup, TOTALCOSTS_KEY); 1116// return readConfig(cgroup, TOTALCOSTS_KEY);
1108} 1117// }
1109 1118
1110 1119
1111void PPPData::setTotalCosts(const QString &n) { 1120// void PPPData::setTotalCosts(const QString &n) {
1112 writeConfig(cgroup, TOTALCOSTS_KEY, n); 1121// writeConfig(cgroup, TOTALCOSTS_KEY, n);
1113} 1122// }
1114 1123
1115 1124
1116int PPPData::totalBytes() { 1125// int PPPData::totalBytes() {
1117 return readNumConfig(cgroup, TOTALBYTES_KEY, 0); 1126// return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
1118} 1127// }
1119 1128
1120void PPPData::setTotalBytes(int n) { 1129// void PPPData::setTotalBytes(int n) {
1121 writeConfig(cgroup, TOTALBYTES_KEY, n); 1130// writeConfig(cgroup, TOTALBYTES_KEY, n);
1122} 1131// }
1123 1132
@@ -1213,3 +1222,4 @@ QString PPPData::modemGroup()
1213{ 1222{
1214 return MODEM_GRP; 1223 if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup);
1224 return QString("MODEM_GRP_%1").arg(modemDeviceGroup);
1215} 1225}
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index c4d7bc3..41dfbd8 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -243,3 +243,3 @@ public:
243 const QString modemDevice(); 243 const QString modemDevice();
244 void setModemDevice(const QString &); 244 bool setModemDevice(const QString &);
245 245
@@ -421,10 +421,10 @@ public:
421 // functions to set/query the accounting info 421 // functions to set/query the accounting info
422 const QString accountingFile(); 422// const QString accountingFile();
423 void setAccountingFile(const QString &); 423// void setAccountingFile(const QString &);
424 424
425 const QString totalCosts(); 425// const QString totalCosts();
426 void setTotalCosts(const QString &); 426// void setTotalCosts(const QString &);
427 427
428 int totalBytes(); 428// int totalBytes();
429 void setTotalBytes(int); 429// void setTotalBytes(int);
430 430
@@ -452,3 +452,3 @@ private:
452 static PPPData *_data; 452 static PPPData *_data;
453 453 int modemDeviceGroup;
454 QString passwd; 454 QString passwd;
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index fb2f3e5..3a97535 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -58,3 +58,4 @@ QWidget *PPPModule::configure(Interface *i){
58 qDebug("return ModemWidget"); 58 qDebug("return ModemWidget");
59 PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false, 59 PPPConfigWidget *pppconfig = new PPPConfigWidget( i, 0, "PPPConfig",
60 false,
60 Qt::WDestructiveClose ); 61 Qt::WDestructiveClose );
@@ -71,3 +72,3 @@ QWidget *PPPModule::information(Interface *i){
71 qDebug("return PPPModule::information"); 72 qDebug("return PPPModule::information");
72 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i); 73 InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i);
73 return information; 74 return information;
@@ -96,14 +97,15 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){
96 97
97 PPPConfigWidget imp(0, "PPPConfigImp", true); 98 Interface *iface;
99 iface = new Interface();
100 PPPConfigWidget imp(iface, 0, "PPPConfigImp", true);
98 imp.showMaximized(); 101 imp.showMaximized();
99 if(imp.exec() == QDialog::Accepted ){ 102 if(imp.exec() == QDialog::Accepted ){
100 qDebug("ACCEPTED"); 103 iface->setModuleOwner( this );
101 PPPData::data()->save(); 104 list.append( iface );
102 Interface *iface; 105 return iface;
103 iface = new Interface( 0, PPPData::data()->modemDevice() ); 106 }else {
104 iface->setHardwareName( PPPData::data()->accname() ); 107 delete iface;
105 list.append( iface ); 108 iface = NULL;
106 return iface;
107 } 109 }
108 return NULL; 110 return iface;
109} 111}