Diffstat (limited to 'noncore/settings/networksettings/ppp/interfaceppp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/interfaceppp.cpp | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index 9ec30bc..f443f3c 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,6 +1,8 @@ | |||
1 | 1 | ||
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #define i18n QObject::tr | 3 | #include <qlayout.h> |
4 | #include <qlineedit.h> | ||
5 | #include <qlabel.h> | ||
4 | 6 | ||
5 | #include "auth.h" | 7 | #include "auth.h" |
6 | #include "interfaceppp.h" | 8 | #include "interfaceppp.h" |
@@ -15,18 +17,18 @@ InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | |||
15 | qDebug("InterfacePPP::InterfacePPP("); | 17 | qDebug("InterfacePPP::InterfacePPP("); |
16 | } | 18 | } |
17 | 19 | ||
18 | PPPData* InterfacePPP::data() | 20 | PPPData* InterfacePPP::data()const |
19 | { | 21 | { |
20 | if (!_dataPtr){ | 22 | if (!_dataPtr){ |
21 | qDebug("creating new Data obj"); | 23 | qDebug("creating new Data obj"); |
22 | _dataPtr = new PPPData(); | 24 | _dataPtr = new PPPData(); |
23 | _dataPtr->setModemDevice( getInterfaceName() ); | 25 | _dataPtr->setDevice( getInterfaceName() ); |
24 | _dataPtr->setAccount( getHardwareName() ); | 26 | _dataPtr->setAccount( getHardwareName() ); |
25 | } | 27 | } |
26 | return _dataPtr; | 28 | return _dataPtr; |
27 | } | 29 | } |
28 | 30 | ||
29 | Modem* InterfacePPP::modem() | 31 | Modem* InterfacePPP::modem()const |
30 | { | 32 | { |
31 | if (!_modemPtr){ | 33 | if (!_modemPtr){ |
32 | qDebug("creating new modem obj"); | 34 | qDebug("creating new modem obj"); |
@@ -38,27 +40,42 @@ Modem* InterfacePPP::modem() | |||
38 | bool InterfacePPP::refresh() | 40 | bool InterfacePPP::refresh() |
39 | { | 41 | { |
40 | qDebug("InterfacePPP::refresh()"); | 42 | qDebug("InterfacePPP::refresh()"); |
41 | updateInterface(this); | 43 | QString old = getInterfaceName(); |
42 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); | 44 | setInterfaceName( modem()->pppDevice() ); |
43 | return false; | 45 | |
46 | (void)Interface::refresh(); | ||
47 | |||
48 | setInterfaceName( old ); | ||
49 | emit updateInterface(this); | ||
50 | |||
51 | return true; | ||
44 | } | 52 | } |
45 | 53 | ||
46 | void InterfacePPP::start() | 54 | void InterfacePPP::start() |
47 | { | 55 | { |
48 | qDebug("InterfacePPP::start"); | 56 | qDebug("InterfacePPP::start"); |
49 | // should work... | ||
50 | // if (data()->password().isEmpty() ){ | ||
51 | // //FIXME: ask for password | ||
52 | // qDebug("using dummy password"); | ||
53 | // QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)"); | ||
54 | // } | ||
55 | 57 | ||
58 | if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { | ||
59 | |||
60 | QDialog mb( 0, "Dialog", true ); | ||
61 | mb.setCaption( tr( "No password" ) ); | ||
62 | QVBoxLayout layout( &mb ); | ||
63 | QLabel text ( &mb ); | ||
64 | text.setText( tr("Username defined but no password\n Please enter a password") ); | ||
65 | QLineEdit lineedit( &mb ); | ||
66 | lineedit.setEchoMode( QLineEdit::Password ); | ||
67 | layout.addWidget( &text ); | ||
68 | layout.addWidget( &lineedit ); | ||
69 | if ( mb.exec() == QDialog::Accepted ) { | ||
70 | data()->setPassword( lineedit.text() ); | ||
71 | } | ||
72 | } | ||
56 | 73 | ||
57 | QFileInfo info(pppdPath()); | 74 | QFileInfo info(pppdPath()); |
58 | 75 | ||
59 | if(!info.exists()){ | 76 | if(!info.exists()){ |
60 | QMessageBox::warning(0, tr("Error"), | 77 | QMessageBox::warning(0, tr("Error"), |
61 | i18n("<qt>Cannot find the PPP daemon!<br>" | 78 | QObject::tr("<qt>Cannot find the PPP daemon!<br>" |
62 | "Make sure that pppd is installed and " | 79 | "Make sure that pppd is installed and " |
63 | "that you have entered the correct path.</qt>")); | 80 | "that you have entered the correct path.</qt>")); |
64 | return; | 81 | return; |
@@ -67,7 +84,7 @@ void InterfacePPP::start() | |||
67 | if(!info.isExecutable()){ | 84 | if(!info.isExecutable()){ |
68 | 85 | ||
69 | QString string; | 86 | QString string; |
70 | string = i18n( "<qt>Cannot execute:<br> %1<br>" | 87 | string = QObject::tr( "<qt>Cannot execute:<br> %1<br>" |
71 | "Please make sure that you have given " | 88 | "Please make sure that you have given " |
72 | "setuid permission and that " | 89 | "setuid permission and that " |
73 | "pppd is executable.<br>").arg(pppdPath()); | 90 | "pppd is executable.<br>").arg(pppdPath()); |
@@ -81,7 +98,7 @@ void InterfacePPP::start() | |||
81 | 98 | ||
82 | if(!info2.exists()){ | 99 | if(!info2.exists()){ |
83 | QString string; | 100 | QString string; |
84 | string = i18n( "<qt>Cannot find:<br> %1<br>" | 101 | string = QObject::tr( "<qt>Cannot find:<br> %1<br>" |
85 | "Please make sure you have setup " | 102 | "Please make sure you have setup " |
86 | "your modem device properly " | 103 | "your modem device properly " |
87 | "and/or adjust the location of the modem device on " | 104 | "and/or adjust the location of the modem device on " |
@@ -98,7 +115,7 @@ void InterfacePPP::start() | |||
98 | data()->authMethod() == AUTH_PAPCHAP ) { | 115 | data()->authMethod() == AUTH_PAPCHAP ) { |
99 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { | 116 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { |
100 | QMessageBox::warning(0,tr("Error"), | 117 | 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>")); | 118 | QObject::tr("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); |
102 | // FIXME: return; | 119 | // FIXME: return; |
103 | } else { | 120 | } else { |
104 | if(!modem()->setSecret(data()->authMethod(), | 121 | if(!modem()->setSecret(data()->authMethod(), |
@@ -106,7 +123,7 @@ void InterfacePPP::start() | |||
106 | PPPData::encodeWord(data()->password())) | 123 | PPPData::encodeWord(data()->password())) |
107 | ) { | 124 | ) { |
108 | QString s; | 125 | QString s; |
109 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" | 126 | s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>" |
110 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | 127 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); |
111 | QMessageBox::warning(0, tr("Error"), s); | 128 | QMessageBox::warning(0, tr("Error"), s); |
112 | return; | 129 | return; |
@@ -115,7 +132,7 @@ void InterfacePPP::start() | |||
115 | } | 132 | } |
116 | 133 | ||
117 | if (data()->phonenumber().isEmpty()) { | 134 | if (data()->phonenumber().isEmpty()) { |
118 | QString s = i18n("You must specify a telephone number!"); | 135 | QString s = QObject::tr("You must specify a telephone number!"); |
119 | QMessageBox::warning(0, tr("Error"), s); | 136 | QMessageBox::warning(0, tr("Error"), s); |
120 | return; | 137 | return; |
121 | } | 138 | } |
@@ -132,6 +149,11 @@ void InterfacePPP::start() | |||
132 | void InterfacePPP::stop() | 149 | void InterfacePPP::stop() |
133 | { | 150 | { |
134 | qDebug("InterfacePPP::stop"); | 151 | qDebug("InterfacePPP::stop"); |
152 | // emit hangup_now(); | ||
153 | status = false; // not connected | ||
154 | setStatus( false ); | ||
155 | emit hangup_now(); | ||
156 | refresh(); | ||
135 | 157 | ||
136 | } | 158 | } |
137 | 159 | ||
@@ -140,3 +162,13 @@ void InterfacePPP::save() | |||
140 | data()->save(); | 162 | data()->save(); |
141 | emit updateInterface((Interface*) this); | 163 | emit updateInterface((Interface*) this); |
142 | } | 164 | } |
165 | QString InterfacePPP::pppDev()const { | ||
166 | return modem()->pppDevice(); | ||
167 | } | ||
168 | pid_t InterfacePPP::pppPID()const{ | ||
169 | return modem()->pppPID(); | ||
170 | } | ||
171 | void InterfacePPP::setPPPDpid( pid_t pid) { | ||
172 | setStatus( true ); | ||
173 | modem()->setPPPDPid( pid ); | ||
174 | } | ||