Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (ignore whitespace changes)
9 files changed, 160 insertions, 30 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO index 2410880..1136c2d 100644 --- a/noncore/settings/networksettings/ppp/TODO +++ b/noncore/settings/networksettings/ppp/TODO | |||
@@ -1,3 +1,4 @@ | |||
1 | - add possibility to input username and password ;) | ||
1 | - impl. PPPData::copyaccount & PPPData::deleteAccount | 2 | - impl. PPPData::copyaccount & PPPData::deleteAccount |
2 | - update modem attribute inputs when modem has changed | 3 | - update modem attribute inputs when modem has changed |
3 | - fix layout of edit account | 4 | - fix layout of edit account |
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 2615b60..89d9930 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -110,10 +110,10 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam | |||
110 | messg->setAlignment(AlignCenter); | 110 | messg->setAlignment(AlignCenter); |
111 | messg->setText(i18n("Unable to create modem lock file.")); | 111 | messg->setText(i18n("Unable to create modem lock file.")); |
112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
113 | int messw = (messg->sizeHint().width() * 12) / 10; | 113 | // int messw = (messg->sizeHint().width() * 12) / 10; |
114 | messw = QMAX(messw,280); | 114 | // messw = QMAX(messw,280); |
115 | messg->setMinimumWidth(messw); | 115 | // messg->setMinimumWidth(messw); |
116 | messg->setText(i18n("Looking for modem...")); | 116 | messg->setText(i18n("Offline")); |
117 | l0->addSpacing(10); | 117 | l0->addSpacing(10); |
118 | l0->addWidget(messg); | 118 | l0->addWidget(messg); |
119 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
@@ -130,15 +130,15 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam | |||
130 | cancel->setFocus(); | 130 | cancel->setFocus(); |
131 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 131 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
132 | 132 | ||
133 | int maxw = QMAX(cancel->sizeHint().width(), | 133 | // int maxw = QMAX(cancel->sizeHint().width(), |
134 | debug->sizeHint().width()); | 134 | // debug->sizeHint().width()); |
135 | maxw = QMAX(maxw,65); | 135 | // maxw = QMAX(maxw,65); |
136 | debug->setFixedWidth(maxw); | 136 | // debug->setFixedWidth(maxw); |
137 | cancel->setFixedWidth(maxw); | 137 | // cancel->setFixedWidth(maxw); |
138 | l1->addWidget(debug); | 138 | l1->addWidget(debug); |
139 | l1->addWidget(cancel); | 139 | l1->addWidget(cancel); |
140 | 140 | ||
141 | setFixedSize(sizeHint()); | 141 | // setFixedSize(sizeHint()); |
142 | 142 | ||
143 | pausetimer = new QTimer(this); | 143 | pausetimer = new QTimer(this); |
144 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); | 144 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); |
@@ -989,11 +989,10 @@ void ConnectWidget::cancelbutton() { | |||
989 | _ifaceppp->modem()->killPPPDaemon(); | 989 | _ifaceppp->modem()->killPPPDaemon(); |
990 | _ifaceppp->modem()->hangup(); | 990 | _ifaceppp->modem()->hangup(); |
991 | 991 | ||
992 | this->hide(); | 992 | |
993 | messg->setText(""); | ||
994 | // p_kppp->quit_b->setFocus(); | 993 | // p_kppp->quit_b->setFocus(); |
995 | // p_kppp->show(); | 994 | // p_kppp->show(); |
996 | emit stopAccounting();// just to be sure | 995 | // emit stopAccounting();// just to be sure |
997 | // p_kppp->con_win->stopClock(); | 996 | // p_kppp->con_win->stopClock(); |
998 | _ifaceppp->modem()->closetty(); | 997 | _ifaceppp->modem()->closetty(); |
999 | _ifaceppp->modem()->unlockdevice(); | 998 | _ifaceppp->modem()->unlockdevice(); |
@@ -1004,8 +1003,7 @@ void ConnectWidget::cancelbutton() { | |||
1004 | } | 1003 | } |
1005 | prompt->setConsumed(); | 1004 | prompt->setConsumed(); |
1006 | 1005 | ||
1007 | // if(p_kppp->quitOnDisconnect()) | 1006 | messg->setText(tr("offline")); |
1008 | // qApp->exit(0); | ||
1009 | } | 1007 | } |
1010 | 1008 | ||
1011 | 1009 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index a58858c..3cf1167 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -6,6 +6,9 @@ | |||
6 | //#include <qgroupbox.h> | 6 | //#include <qgroupbox.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | 8 | ||
9 | #include "connect.h" | ||
10 | #include "conwindow.h" | ||
11 | |||
9 | #ifdef QWS | 12 | #ifdef QWS |
10 | #else | 13 | #else |
11 | #define showMaximized show | 14 | #define showMaximized show |
@@ -18,6 +21,11 @@ | |||
18 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | 21 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) |
19 | :InterfaceInformationImp(parent, name, i, f) | 22 | :InterfaceInformationImp(parent, name, i, f) |
20 | { | 23 | { |
24 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP"); | ||
25 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); | ||
26 | // InterfaceInformationLayout->addMultiCellWidget( con, 7, 7, 0, 1 ); | ||
27 | InterfaceInformationLayout->addWidget( con, 7, 0 ); | ||
28 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); | ||
21 | } | 29 | } |
22 | 30 | ||
23 | 31 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.h b/noncore/settings/networksettings/ppp/interfaceinformationppp.h index 8c6fc0b..68b58ea 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.h +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.h | |||
@@ -2,10 +2,12 @@ | |||
2 | #define INTERFACEINFORMATIONPPP_H | 2 | #define INTERFACEINFORMATIONPPP_H |
3 | 3 | ||
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | //#include "interface.h" | 5 | |
6 | 6 | ||
7 | class QWidget; | 7 | class QWidget; |
8 | class Interface; | 8 | class Interface; |
9 | class ConnectWidget; | ||
10 | class ConnectWindow; | ||
9 | 11 | ||
10 | class InterfaceInformationPPP : public InterfaceInformationImp { | 12 | class InterfaceInformationPPP : public InterfaceInformationImp { |
11 | 13 | ||
@@ -16,6 +18,9 @@ public: | |||
16 | InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | 18 | InterfaceInformationPPP(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); |
17 | ~InterfaceInformationPPP(){}; | 19 | ~InterfaceInformationPPP(){}; |
18 | 20 | ||
21 | private: | ||
22 | ConnectWidget *con; | ||
23 | ConnectWindow *con_win; | ||
19 | 24 | ||
20 | }; | 25 | }; |
21 | 26 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index d9ee3ff..dc24824 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,43 +1,136 @@ | |||
1 | |||
2 | #include <qmessagebox.h> | ||
3 | #define i18n QObject::tr | ||
4 | |||
5 | #include "auth.h" | ||
1 | #include "interfaceppp.h" | 6 | #include "interfaceppp.h" |
2 | #include "modem.h" | 7 | #include "modem.h" |
3 | #include "pppdata.h" | 8 | #include "pppdata.h" |
4 | 9 | ||
5 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | 10 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) |
6 | : Interface(parent, name, status), | 11 | : Interface(parent, name, status), |
7 | _modem(0), | 12 | _modemPtr(0), |
8 | _pppdata(0) | 13 | _dataPtr(0) |
9 | { | 14 | { |
10 | qDebug("InterfacePPP::InterfacePPP("); | 15 | qDebug("InterfacePPP::InterfacePPP("); |
11 | } | 16 | } |
12 | 17 | ||
13 | PPPData* InterfacePPP::data() | 18 | PPPData* InterfacePPP::data() |
14 | { | 19 | { |
15 | if (!_pppdata){ | 20 | if (!_dataPtr){ |
16 | _pppdata = new PPPData(); | 21 | qDebug("creating new Data obj"); |
17 | _pppdata->setModemDevice( getInterfaceName() ); | 22 | _dataPtr = new PPPData(); |
18 | _pppdata->setAccount( getHardwareName() ); | 23 | _dataPtr->setModemDevice( getInterfaceName() ); |
24 | _dataPtr->setAccount( getHardwareName() ); | ||
19 | } | 25 | } |
20 | return _pppdata; | 26 | return _dataPtr; |
21 | } | 27 | } |
22 | 28 | ||
23 | Modem* InterfacePPP::modem() | 29 | Modem* InterfacePPP::modem() |
24 | { | 30 | { |
25 | if (!_modem){ | 31 | if (!_modemPtr){ |
26 | _modem = new Modem( data() ); | 32 | qDebug("creating new modem obj"); |
33 | _modemPtr = new Modem( data() ); | ||
27 | } | 34 | } |
28 | return _modem; | 35 | return _modemPtr; |
29 | } | 36 | } |
30 | 37 | ||
31 | bool InterfacePPP::refresh() | 38 | bool InterfacePPP::refresh() |
32 | { | 39 | { |
33 | qDebug("InterfacePPP::refresh()"); | 40 | qDebug("InterfacePPP::refresh()"); |
41 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); | ||
34 | return false; | 42 | return false; |
35 | } | 43 | } |
36 | 44 | ||
37 | void InterfacePPP::start() | 45 | void InterfacePPP::start() |
38 | { | 46 | { |
39 | qDebug("InterfacePPP::start"); | 47 | qDebug("InterfacePPP::start"); |
48 | if (data()->storedPassword() != "" ){ | ||
49 | data()->setPassword(data()->storedPassword()); | ||
50 | }else{ | ||
51 | //FIXME: | ||
52 | qDebug("using dummy password"); | ||
53 | data()->setPassword( "dummy" ); | ||
54 | } | ||
55 | |||
56 | |||
57 | QFileInfo info(pppdPath()); | ||
58 | |||
59 | if(!info.exists()){ | ||
60 | QMessageBox::warning(0, tr("Error"), | ||
61 | i18n("<qt>Cannot find the PPP daemon!<br>" | ||
62 | "Make sure that pppd is installed and " | ||
63 | "that you have entered the correct path.</qt>")); | ||
64 | return; | ||
65 | } | ||
66 | //#if 0 | ||
67 | if(!info.isExecutable()){ | ||
68 | |||
69 | QString string; | ||
70 | string = i18n( "<qt>Cannot execute:<br> %1<br>" | ||
71 | "Please make sure that you have given " | ||
72 | "setuid permission and that " | ||
73 | "pppd is executable.<br>").arg(pppdPath()); | ||
74 | QMessageBox::warning(0, tr("Error"), string); | ||
75 | return; | ||
76 | |||
77 | } | ||
78 | //#endif | ||
79 | |||
80 | QFileInfo info2(data()->modemDevice()); | ||
81 | |||
82 | if(!info2.exists()){ | ||
83 | QString string; | ||
84 | string = i18n( "<qt>Cannot find:<br> %1<br>" | ||
85 | "Please make sure you have setup " | ||
86 | "your modem device properly " | ||
87 | "and/or adjust the location of the modem device on " | ||
88 | "the modem tab of " | ||
89 | "the setup dialog.</qt>").arg(data()->modemDevice()); | ||
90 | QMessageBox::warning(0, tr("Error"), string); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | // if this is a PAP or CHAP account, ensure that username is | ||
95 | // supplied | ||
96 | if(data()->authMethod() == AUTH_PAP || | ||
97 | data()->authMethod() == AUTH_CHAP || | ||
98 | data()->authMethod() == AUTH_PAPCHAP ) { | ||
99 | if(false){ //ID_Edit->text().isEmpty()) { | ||
100 | QMessageBox::warning(0,tr("Error"), | ||
101 | i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); | ||
102 | // FIXME: return; | ||
103 | } else { | ||
104 | if(!modem()->setSecret(data()->authMethod(), | ||
105 | PPPData::encodeWord(data()->storedUsername()), | ||
106 | PPPData::encodeWord(data()->password())) | ||
107 | ) { | ||
108 | QString s; | ||
109 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" | ||
110 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | ||
111 | QMessageBox::warning(0, tr("Error"), s); | ||
112 | return; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if (data()->phonenumber().isEmpty()) { | ||
118 | QString s = i18n("You must specify a telephone number!"); | ||
119 | QMessageBox::warning(0, tr("Error"), s); | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | // this->hide(); | ||
124 | |||
125 | QString tit = i18n("Connecting to: %1").arg(data()->accname()); | ||
126 | // con->setCaption(tit); | ||
127 | |||
128 | // con->show(); | ||
129 | |||
130 | |||
131 | emit begin_connect(); | ||
40 | 132 | ||
133 | qDebug("InterfacePPP::start END"); | ||
41 | } | 134 | } |
42 | 135 | ||
43 | void InterfacePPP::stop() | 136 | void InterfacePPP::stop() |
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h index b7477c9..06a4dbf 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.h +++ b/noncore/settings/networksettings/ppp/interfaceppp.h | |||
@@ -16,14 +16,17 @@ public: | |||
16 | PPPData* data(); | 16 | PPPData* data(); |
17 | Modem* modem(); | 17 | Modem* modem(); |
18 | 18 | ||
19 | signals: | ||
20 | void begin_connect(); | ||
21 | |||
19 | public slots: | 22 | public slots: |
20 | virtual bool refresh(); | 23 | virtual bool refresh(); |
21 | virtual void start(); | 24 | virtual void start(); |
22 | virtual void stop(); | 25 | virtual void stop(); |
23 | 26 | ||
24 | private: | 27 | private: |
25 | Modem *_modem; | 28 | Modem *_modemPtr; |
26 | PPPData *_pppdata; | 29 | PPPData *_dataPtr; |
27 | }; | 30 | }; |
28 | 31 | ||
29 | 32 | ||
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h index b958862..e0f5237 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.h +++ b/noncore/settings/networksettings/ppp/kpppwidget.h | |||
@@ -29,9 +29,9 @@ | |||
29 | 29 | ||
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | 31 | ||
32 | #include "conwindow.h" | ||
33 | #include "accounts.h" | 32 | #include "accounts.h" |
34 | #include "connect.h" | 33 | #include "connect.h" |
34 | #include "conwindow.h" | ||
35 | 35 | ||
36 | class QPushButton; | 36 | class QPushButton; |
37 | class Interface; | 37 | class Interface; |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 59d68c9..7a6524f 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -130,7 +130,7 @@ void PPPData::cancel() { | |||
130 | QString PPPData::readConfig(const QString &group, const QString &key, | 130 | QString PPPData::readConfig(const QString &group, const QString &key, |
131 | const QString &defvalue = "") | 131 | const QString &defvalue = "") |
132 | { | 132 | { |
133 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 133 | qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
134 | QString idx = SEP.arg(group).arg(key); | 134 | QString idx = SEP.arg(group).arg(key); |
135 | if (stringEntries.find(idx) != stringEntries.end()) | 135 | if (stringEntries.find(idx) != stringEntries.end()) |
136 | return stringEntries[idx]; | 136 | return stringEntries[idx]; |
@@ -347,6 +347,7 @@ const QString PPPData::modemDevice() { | |||
347 | 347 | ||
348 | 348 | ||
349 | bool PPPData::setModemDevice(const QString &n) { | 349 | bool PPPData::setModemDevice(const QString &n) { |
350 | qDebug("Setting modem dev to >%s<", n.latin1()); | ||
350 | bool ret = false; | 351 | bool ret = false; |
351 | for (int i = 0; devices[i]; i++) | 352 | for (int i = 0; devices[i]; i++) |
352 | if (devices[i] == n){ | 353 | if (devices[i] == n){ |
@@ -354,6 +355,7 @@ bool PPPData::setModemDevice(const QString &n) { | |||
354 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | 355 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
355 | ret = true; | 356 | ret = true; |
356 | } | 357 | } |
358 | qDebug(ret?"SUCCESS":"FAILURE"); | ||
357 | return ret; | 359 | return ret; |
358 | } | 360 | } |
359 | 361 | ||
@@ -712,13 +714,16 @@ int PPPData::count() const { | |||
712 | 714 | ||
713 | 715 | ||
714 | bool PPPData::setAccount(const QString &aname) { | 716 | bool PPPData::setAccount(const QString &aname) { |
717 | qDebug("setting account to >%s<", aname.latin1()); | ||
715 | for(int i = 0; i <= highcount; i++) { | 718 | for(int i = 0; i <= highcount; i++) { |
716 | setAccountbyIndex(i); | 719 | setAccountbyIndex(i); |
717 | if(accname() == aname) { | 720 | if(accname() == aname) { |
718 | caccount = i; | 721 | caccount = i; |
722 | qDebug("SUCCESS"); | ||
719 | return true; | 723 | return true; |
720 | } | 724 | } |
721 | } | 725 | } |
726 | qDebug("FAILURE"); | ||
722 | return false; | 727 | return false; |
723 | } | 728 | } |
724 | 729 | ||
@@ -910,6 +915,9 @@ void PPPData::setStoredUsername(const QString &b) { | |||
910 | 915 | ||
911 | 916 | ||
912 | const QString PPPData::storedPassword() { | 917 | const QString PPPData::storedPassword() { |
918 | qDebug("getting stored pw"); | ||
919 | qDebug("g %s", cgroup.latin1() ); | ||
920 | qDebug("k %s", STORED_PASSWORD_KEY); | ||
913 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 921 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
914 | } | 922 | } |
915 | 923 | ||
@@ -1274,3 +1282,14 @@ void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | |||
1274 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1282 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1275 | 1283 | ||
1276 | } | 1284 | } |
1285 | |||
1286 | /** | ||
1287 | * pppd's getword() function knows about escape characters. | ||
1288 | * If we write the username and password to the secrets file | ||
1289 | * we'll therefore have to escape back slashes. | ||
1290 | */ | ||
1291 | QString PPPData::encodeWord(const QString &s) { | ||
1292 | QString r = s; | ||
1293 | r.replace(QRegExp("\\"), "\\\\"); | ||
1294 | return r; | ||
1295 | } | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index af960c6..c9cd482 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -409,6 +409,9 @@ public: | |||
409 | int pppdError() const; | 409 | int pppdError() const; |
410 | void setpppdError(int err); | 410 | void setpppdError(int err); |
411 | 411 | ||
412 | |||
413 | static QString encodeWord(const QString &s); | ||
414 | |||
412 | private: | 415 | private: |
413 | 416 | ||
414 | //static PPPData *_data; | 417 | //static PPPData *_data; |