summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/interfaceppp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/interfaceppp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.cpp70
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,9 +1,11 @@
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"
7#include "modem.h" 9#include "modem.h"
8#include "pppdata.h" 10#include "pppdata.h"
9 11
@@ -12,65 +14,80 @@ InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status)
12 _modemPtr(0), 14 _modemPtr(0),
13 _dataPtr(0) 15 _dataPtr(0)
14{ 16{
15 qDebug("InterfacePPP::InterfacePPP("); 17 qDebug("InterfacePPP::InterfacePPP(");
16} 18}
17 19
18PPPData* InterfacePPP::data() 20PPPData* 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
29Modem* InterfacePPP::modem() 31Modem* InterfacePPP::modem()const
30{ 32{
31 if (!_modemPtr){ 33 if (!_modemPtr){
32 qDebug("creating new modem obj"); 34 qDebug("creating new modem obj");
33 _modemPtr = new Modem( data() ); 35 _modemPtr = new Modem( data() );
34 } 36 }
35 return _modemPtr; 37 return _modemPtr;
36} 38}
37 39
38bool InterfacePPP::refresh() 40bool 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
46void InterfacePPP::start() 54void 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;
65 } 82 }
66//#if 0 83//#if 0
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());
74 QMessageBox::warning(0, tr("Error"), string); 91 QMessageBox::warning(0, tr("Error"), string);
75 return; 92 return;
76 93
@@ -78,13 +95,13 @@ void InterfacePPP::start()
78//#endif 95//#endif
79 96
80 QFileInfo info2(data()->modemDevice()); 97 QFileInfo info2(data()->modemDevice());
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 "
88 "the modem tab of " 105 "the modem tab of "
89 "the setup dialog.</qt>").arg(data()->modemDevice()); 106 "the setup dialog.</qt>").arg(data()->modemDevice());
90 QMessageBox::warning(0, tr("Error"), string); 107 QMessageBox::warning(0, tr("Error"), string);
@@ -95,30 +112,30 @@ void InterfacePPP::start()
95 // supplied 112 // supplied
96 if(data()->authMethod() == AUTH_PAP || 113 if(data()->authMethod() == AUTH_PAP ||
97 data()->authMethod() == AUTH_CHAP || 114 data()->authMethod() == AUTH_CHAP ||
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(),
105 PPPData::encodeWord(data()->storedUsername()), 122 PPPData::encodeWord(data()->storedUsername()),
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;
113 } 130 }
114 } 131 }
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 }
122 139
123 // SEGFAULTS: 140 // SEGFAULTS:
124// setStatus( true ); 141// setStatus( true );
@@ -129,14 +146,29 @@ void InterfacePPP::start()
129 qDebug("InterfacePPP::start END"); 146 qDebug("InterfacePPP::start END");
130} 147}
131 148
132void InterfacePPP::stop() 149void 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
138void InterfacePPP::save() 160void InterfacePPP::save()
139{ 161{
140 data()->save(); 162 data()->save();
141 emit updateInterface((Interface*) this); 163 emit updateInterface((Interface*) this);
142} 164}
165QString InterfacePPP::pppDev()const {
166 return modem()->pppDevice();
167}
168pid_t InterfacePPP::pppPID()const{
169 return modem()->pppPID();
170}
171void InterfacePPP::setPPPDpid( pid_t pid) {
172 setStatus( true );
173 modem()->setPPPDPid( pid );
174}