Diffstat (limited to 'noncore/settings/networksettings/ppp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/accounts.cpp | 206 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.cpp | 672 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modeminfo.cpp | 383 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 147 |
4 files changed, 747 insertions, 661 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index 28d8732..b8a1925a 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -21,212 +21,238 @@ | |||
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "accounts.h" | ||
28 | #include "authwidget.h" | ||
29 | #include "pppdata.h" | ||
30 | #include "edit.h" | ||
31 | |||
32 | /* OPIE */ | ||
33 | #include <qpe/qpeapplication.h> | ||
34 | |||
35 | /* QT */ | ||
27 | #include <qdir.h> | 36 | #include <qdir.h> |
28 | #include <stdlib.h> | ||
29 | #include <qlayout.h> | 37 | #include <qlayout.h> |
30 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
31 | #include <qtabdialog.h> | 39 | #include <qtabdialog.h> |
32 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
33 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
34 | |||
35 | #include <qapplication.h> | 42 | #include <qapplication.h> |
36 | #include <qbuttongroup.h> | 43 | #include <qbuttongroup.h> |
37 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
38 | #include <qvgroupbox.h> | 45 | #include <qvgroupbox.h> |
39 | 46 | ||
40 | #include "accounts.h" | 47 | /* STD */ |
41 | #include "authwidget.h" | 48 | #include <stdlib.h> |
42 | #include "pppdata.h" | ||
43 | #include "edit.h" | ||
44 | 49 | ||
45 | void parseargs(char* buf, char** args); | 50 | void parseargs(char* buf, char** args); |
46 | 51 | ||
47 | 52 | ||
48 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) | 53 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) |
49 | : ChooserWidget( pd, parent, name, f ) | 54 | : ChooserWidget( pd, parent, name, f ) |
50 | { | 55 | { |
51 | 56 | ||
52 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); | 57 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); |
53 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" | 58 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" |
54 | "to the Internet")); | 59 | "to the Internet")); |
55 | QWhatsThis::add(copy_b, | 60 | QWhatsThis::add(copy_b, |
56 | tr("Makes a copy of the selected account. All\n" | 61 | tr("Makes a copy of the selected account. All\n" |
57 | "settings of the selected account are copied\n" | 62 | "settings of the selected account are copied\n" |
58 | "to a new account, that you can modify to fit your\n" | 63 | "to a new account, that you can modify to fit your\n" |
59 | "needs")); | 64 | "needs")); |
60 | QWhatsThis::add(delete_b, | 65 | QWhatsThis::add(delete_b, |
61 | tr("<p>Deletes the selected account\n\n" | 66 | tr("<p>Deletes the selected account\n\n" |
62 | "<font color=\"red\"><b>Use with care!</b></font>")); | 67 | "<font color=\"red\"><b>Use with care!</b></font>")); |
63 | 68 | ||
64 | 69 | ||
65 | 70 | ||
66 | copy_b->setEnabled( false ); //FIXME | 71 | copy_b->setEnabled( false ); //FIXME |
67 | // delete_b->setEnabled( false ); //FIXME | 72 | // delete_b->setEnabled( false ); //FIXME |
68 | 73 | ||
69 | listListbox->insertStringList(_pppdata->getAccountList()); | 74 | listListbox->insertStringList(_pppdata->getAccountList()); |
70 | 75 | ||
71 | for (uint i = 0; i < listListbox->count(); i++){ | 76 | for (uint i = 0; i < listListbox->count(); i++) |
72 | if ( listListbox->text(i) == _pppdata->accname() ) | 77 | { |
73 | listListbox->setCurrentItem( i ); | 78 | if ( listListbox->text(i) == _pppdata->accname() ) |
74 | } | 79 | listListbox->setCurrentItem( i ); |
80 | } | ||
75 | } | 81 | } |
76 | 82 | ||
77 | 83 | ||
78 | 84 | ||
79 | void AccountWidget::slotListBoxSelect(int idx) { | 85 | void AccountWidget::slotListBoxSelect(int idx) |
86 | { | ||
80 | bool ok = _pppdata->setAccount( listListbox->text(idx) ); | 87 | bool ok = _pppdata->setAccount( listListbox->text(idx) ); |
81 | ok = (bool)(idx != -1); | 88 | ok = (bool)(idx != -1); |
82 | delete_b->setEnabled(ok); | 89 | delete_b->setEnabled(ok); |
83 | edit_b->setEnabled(ok); | 90 | edit_b->setEnabled(ok); |
84 | //FIXME copy_b->setEnabled(ok); | 91 | //FIXME copy_b->setEnabled(ok); |
85 | } | 92 | } |
86 | 93 | ||
87 | void AccountWidget::edit() { | 94 | void AccountWidget::edit() |
88 | _pppdata->setAccount(listListbox->text(listListbox->currentItem())); | 95 | { |
96 | _pppdata->setAccount(listListbox->text(listListbox->currentItem())); | ||
89 | 97 | ||
90 | int result = doTab(); | 98 | int result = doTab(); |
91 | 99 | ||
92 | if(result == QDialog::Accepted) { | 100 | if(result == QDialog::Accepted) |
93 | listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); | 101 | { |
94 | // emit resetaccounts(); | 102 | listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); |
95 | _pppdata->save(); | 103 | // emit resetaccounts(); |
96 | } | 104 | _pppdata->save(); |
105 | } | ||
97 | } | 106 | } |
98 | 107 | ||
99 | 108 | ||
100 | void AccountWidget::create() { | 109 | void AccountWidget::create() |
110 | { | ||
101 | 111 | ||
102 | // if(listListbox->count() == MAX_ACCOUNTS) { | 112 | // if(listListbox->count() == MAX_ACCOUNTS) { |
103 | // QMessageBox::information(this, "sorry", | 113 | // QMessageBox::information(this, "sorry", |
104 | // tr("Maximum number of accounts reached.")); | 114 | // tr("Maximum number of accounts reached.")); |
105 | // return; | 115 | // return; |
106 | // } | 116 | // } |
107 | 117 | ||
108 | int result; | 118 | int result; |
109 | if (_pppdata->newaccount() == -1){ | 119 | if (_pppdata->newaccount() == -1) |
120 | { | ||
110 | qDebug("_pppdata->newaccount() == -1"); | 121 | qDebug("_pppdata->newaccount() == -1"); |
111 | return; | 122 | return; |
112 | } | 123 | } |
113 | result = doTab(); | 124 | result = doTab(); |
114 | 125 | ||
115 | if(result == QDialog::Accepted) { | 126 | if(result == QDialog::Accepted) |
127 | { | ||
116 | listListbox->insertItem(_pppdata->accname()); | 128 | listListbox->insertItem(_pppdata->accname()); |
117 | listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); | 129 | listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); |
118 | 130 | ||
119 | _pppdata->save(); | 131 | _pppdata->save(); |
120 | } else | 132 | } |
133 | else | ||
121 | _pppdata->deleteAccount(); | 134 | _pppdata->deleteAccount(); |
122 | } | 135 | } |
123 | 136 | ||
124 | 137 | ||
125 | void AccountWidget::copy() { | 138 | void AccountWidget::copy() |
126 | // if(listListbox->count() == MAX_ACCOUNTS) { | 139 | { |
127 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | 140 | // if(listListbox->count() == MAX_ACCOUNTS) { |
128 | // return; | 141 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); |
129 | // } | 142 | // return; |
130 | 143 | // } | |
131 | if(listListbox->currentItem()<0) { | 144 | |
132 | QMessageBox::information(this, "sorry", tr("No account selected.")); | 145 | if(listListbox->currentItem()<0) |
133 | return; | 146 | { |
134 | } | 147 | QMessageBox::information(this, "sorry", tr("No account selected.")); |
148 | return; | ||
149 | } | ||
135 | 150 | ||
136 | _pppdata->copyaccount(listListbox->currentText()); | 151 | _pppdata->copyaccount(listListbox->currentText()); |
137 | 152 | ||
138 | listListbox->insertItem(_pppdata->accname()); | 153 | listListbox->insertItem(_pppdata->accname()); |
139 | // emit resetaccounts(); | 154 | // emit resetaccounts(); |
140 | _pppdata->save(); | 155 | _pppdata->save(); |
141 | } | 156 | } |
142 | 157 | ||
143 | 158 | ||
144 | void AccountWidget::remove() { | 159 | void AccountWidget::remove() |
160 | { | ||
145 | 161 | ||
146 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") | 162 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") |
147 | .arg(listListbox->text(listListbox->currentItem())); | 163 | .arg(listListbox->text(listListbox->currentItem())); |
148 | 164 | ||
149 | if(QMessageBox::warning(this,tr("Confirm"),s, | 165 | if(QMessageBox::warning(this,tr("Confirm"),s, |
150 | QMessageBox::Yes,QMessageBox::No | 166 | QMessageBox::Yes,QMessageBox::No |
151 | ) != QMessageBox::Yes) | 167 | ) != QMessageBox::Yes) |
152 | return; | 168 | return; |
153 | 169 | ||
154 | if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) | 170 | if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) |
155 | listListbox->removeItem(listListbox->currentItem()); | 171 | listListbox->removeItem(listListbox->currentItem()); |
156 | 172 | ||
157 | 173 | ||
158 | // emit resetaccounts(); | 174 | // emit resetaccounts(); |
159 | // _pppdata->save(); | 175 | // _pppdata->save(); |
160 | 176 | ||
161 | 177 | ||
162 | slotListBoxSelect(listListbox->currentItem()); | 178 | slotListBoxSelect(listListbox->currentItem()); |
163 | 179 | ||
164 | } | 180 | } |
165 | 181 | ||
166 | 182 | ||
167 | int AccountWidget::doTab(){ | 183 | int AccountWidget::doTab() |
184 | { | ||
168 | QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); | 185 | QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); |
169 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 186 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
170 | layout->setSpacing( 0 ); | 187 | layout->setSpacing( 0 ); |
171 | layout->setMargin( 1 ); | 188 | layout->setMargin( 1 ); |
172 | 189 | ||
173 | QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); | 190 | QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); |
174 | layout->addWidget( tabWindow ); | 191 | layout->addWidget( tabWindow ); |
175 | 192 | ||
176 | bool isnewaccount; | 193 | bool isnewaccount; |
177 | 194 | ||
178 | if(_pppdata->accname().isEmpty()) { | 195 | if(_pppdata->accname().isEmpty()) |
196 | { | ||
179 | dlg->setCaption(tr("New Account")); | 197 | dlg->setCaption(tr("New Account")); |
180 | isnewaccount = true; | 198 | isnewaccount = true; |
181 | } else { | 199 | } |
200 | else | ||
201 | { | ||
182 | QString tit = tr("Edit Account: "); | 202 | QString tit = tr("Edit Account: "); |
183 | tit += _pppdata->accname(); | 203 | tit += _pppdata->accname(); |
184 | dlg->setCaption(tit); | 204 | dlg->setCaption(tit); |
185 | isnewaccount = false; | 205 | isnewaccount = false; |
186 | } | 206 | } |
187 | 207 | ||
188 | // // DIAL WIDGET | 208 | // // DIAL WIDGET |
189 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); | 209 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); |
190 | tabWindow->addTab( dial_w, tr("Dial") ); | 210 | tabWindow->addTab( dial_w, tr("Dial") ); |
191 | 211 | ||
192 | // // AUTH WIDGET | 212 | // // AUTH WIDGET |
193 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); | 213 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); |
194 | tabWindow->addTab( auth_w, tr("Authentication") ); | 214 | tabWindow->addTab( auth_w, tr("Authentication") ); |
195 | 215 | ||
196 | // // IP WIDGET | 216 | // // IP WIDGET |
197 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); | 217 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); |
198 | tabWindow->addTab( ip_w, tr("IP") ); | 218 | tabWindow->addTab( ip_w, tr("IP") ); |
199 | 219 | ||
200 | // // GATEWAY WIDGET | 220 | // // GATEWAY WIDGET |
201 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); | 221 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); |
202 | tabWindow->addTab( gateway_w, tr("Gateway") ); | 222 | tabWindow->addTab( gateway_w, tr("Gateway") ); |
203 | 223 | ||
204 | // // DNS WIDGET | 224 | // // DNS WIDGET |
205 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); | 225 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); |
206 | tabWindow->addTab( dns_w, tr("DNS") ); | 226 | tabWindow->addTab( dns_w, tr("DNS") ); |
207 | 227 | ||
208 | // // EXECUTE WIDGET | 228 | // // EXECUTE WIDGET |
209 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); | 229 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); |
210 | tabWindow->addTab( exec_w, tr("Execute") ); | 230 | tabWindow->addTab( exec_w, tr("Execute") ); |
211 | 231 | ||
212 | int result = 0; | 232 | int result = 0; |
213 | bool ok = false; | 233 | bool ok = false; |
214 | 234 | ||
215 | while (!ok){ | 235 | while (!ok) |
216 | dlg->showMaximized(); | 236 | { |
217 | result = dlg->exec(); | 237 | result = QPEApplication::execDialog( dlg ); |
218 | ok = true; | 238 | ok = true; |
219 | 239 | ||
220 | if(result == QDialog::Accepted) { | 240 | if(result == QDialog::Accepted) |
221 | if (!auth_w->check()){ | 241 | { |
242 | if (!auth_w->check()) | ||
243 | { | ||
222 | ok = false; | 244 | ok = false; |
223 | } else if(!dial_w->save()) { | 245 | } |
246 | else if(!dial_w->save()) | ||
247 | { | ||
224 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); | 248 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); |
225 | ok = false; | 249 | ok = false; |
226 | }else{ | 250 | } |
251 | else | ||
252 | { | ||
227 | ip_w->save(); | 253 | ip_w->save(); |
228 | dns_w->save(); | 254 | dns_w->save(); |
229 | gateway_w->save(); | 255 | gateway_w->save(); |
230 | auth_w->save(); | 256 | auth_w->save(); |
231 | exec_w->save(); | 257 | exec_w->save(); |
232 | } | 258 | } |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 5540946..ff1b11b 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -21,246 +21,250 @@ | |||
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <termios.h> | 27 | #include "general.h" |
28 | #include <string.h> | 28 | #include "interfaceppp.h" |
29 | #include "modeminfo.h" | ||
30 | #include "modemcmds.h" | ||
31 | #include "pppdata.h" | ||
29 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <qpe/config.h> | ||
35 | #include <qpe/qpeapplication.h> | ||
36 | |||
37 | /* QT */ | ||
30 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
31 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
32 | #include <qlabel.h> | 40 | #include <qlabel.h> |
33 | #include <qlayout.h> | 41 | #include <qlayout.h> |
34 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
35 | #include <qslider.h> | 43 | #include <qslider.h> |
36 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
37 | #include <qwhatsthis.h> | 45 | #include <qwhatsthis.h> |
38 | #include <qpe/config.h> | ||
39 | // #include <qgroupbox.h> | ||
40 | 46 | ||
47 | /* STD */ | ||
48 | #include <termios.h> | ||
49 | #include <string.h> | ||
41 | 50 | ||
42 | #include "general.h" | ||
43 | #include "interfaceppp.h" | ||
44 | //#include "miniterm.h" | ||
45 | #include "modeminfo.h" | ||
46 | #include "modemcmds.h" | ||
47 | //#include "devices.h" | ||
48 | #include "pppdata.h" | ||
49 | //#include <klocale.h> | ||
50 | 51 | ||
52 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) | ||
53 | : QWidget(parent, name), _pppdata(pd) | ||
54 | { | ||
55 | int k; | ||
56 | |||
57 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | ||
51 | 58 | ||
59 | QLabel *label1; | ||
52 | 60 | ||
61 | label1 = new QLabel(tr("Modem &name:"), this); | ||
62 | tl->addWidget(label1, 0, 0); | ||
53 | 63 | ||
54 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) | 64 | modemname = new QLineEdit(this, "modemName"); |
55 | : QWidget(parent, name), _pppdata(pd) | 65 | modemname->setText( _pppdata->devname() ); |
56 | { | 66 | label1->setBuddy(modemname); |
57 | int k; | 67 | tl->addWidget(modemname, 0, 1); |
58 | 68 | ||
59 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | 69 | label1 = new QLabel(tr("Modem de&vice:"), this); |
60 | 70 | tl->addWidget(label1, 1, 0); | |
61 | QLabel *label1; | 71 | |
62 | 72 | modemdevice = new QComboBox(false, this); | |
63 | label1 = new QLabel(tr("Modem &name:"), this); | 73 | modemdevice->setEditable( true ); |
64 | tl->addWidget(label1, 0, 0); | 74 | modemdevice->setDuplicatesEnabled ( false ); |
65 | 75 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); | |
66 | modemname = new QLineEdit(this, "modemName"); | 76 | label1->setBuddy(modemdevice); |
67 | modemname->setText( _pppdata->devname() ); | 77 | |
68 | label1->setBuddy(modemname); | 78 | Config cfg("NetworkSetupPPP"); |
69 | tl->addWidget(modemname, 0, 1); | 79 | cfg.setGroup("Devices_General"); |
70 | 80 | QStringList devs = cfg.readListEntry("devices",','); | |
71 | label1 = new QLabel(tr("Modem de&vice:"), this); | 81 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; |
72 | tl->addWidget(label1, 1, 0); | 82 | modemdevice->insertStringList( devs ); |
73 | 83 | tl->addWidget(modemdevice, 1, 1); | |
74 | modemdevice = new QComboBox(false, this); | 84 | |
75 | modemdevice->setEditable( true ); | 85 | // connect(modemdevice, SIGNAL(activated(int)), |
76 | modemdevice->setDuplicatesEnabled ( false ); | 86 | // SLOT(setmodemdc(int))); |
77 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); | 87 | // connect(modemdevice, SIGNAL(textChanged( const QString & ) ), |
78 | label1->setBuddy(modemdevice); | 88 | // SLOT( setmodemdc( const QString &) ) ); |
79 | 89 | ||
80 | Config cfg("NetworkSetupPPP"); | 90 | QString tmp = tr("This specifies the serial port your modem is attached \n" |
81 | cfg.setGroup("Devices_General"); | 91 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" |
82 | QStringList devs = cfg.readListEntry("devices",','); | 92 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" |
83 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; | 93 | "\n" |
84 | modemdevice->insertStringList( devs ); | 94 | "If you have an internal ISDN card with AT command\n" |
85 | tl->addWidget(modemdevice, 1, 1); | 95 | "emulation (most cards under Linux support this), you\n" |
86 | 96 | "should select one of the /dev/ttyIx devices."); | |
87 | // connect(modemdevice, SIGNAL(activated(int)), | 97 | |
88 | // SLOT(setmodemdc(int))); | 98 | QWhatsThis::add(label1,tmp); |
89 | // connect(modemdevice, SIGNAL(textChanged( const QString & ) ), | 99 | QWhatsThis::add(modemdevice,tmp); |
90 | // SLOT( setmodemdc( const QString &) ) ); | 100 | |
91 | 101 | ||
92 | QString tmp = tr("This specifies the serial port your modem is attached \n" | 102 | label1 = new QLabel(tr("&Flow control:"), this); |
93 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" | 103 | tl->addWidget(label1, 2, 0); |
94 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" | 104 | |
95 | "\n" | 105 | flowcontrol = new QComboBox(false, this); |
96 | "If you have an internal ISDN card with AT command\n" | 106 | label1->setBuddy(flowcontrol); |
97 | "emulation (most cards under Linux support this), you\n" | 107 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); |
98 | "should select one of the /dev/ttyIx devices."); | 108 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); |
99 | 109 | flowcontrol->insertItem(tr("None")); | |
100 | QWhatsThis::add(label1,tmp); | 110 | tl->addWidget(flowcontrol, 2, 1); |
101 | QWhatsThis::add(modemdevice,tmp); | 111 | // connect(flowcontrol, SIGNAL(activated(int)), |
102 | 112 | // SLOT(setflowcontrol(int))); | |
103 | 113 | ||
104 | label1 = new QLabel(tr("&Flow control:"), this); | 114 | tmp = tr("<p>Specifies how the serial port and modem\n" |
105 | tl->addWidget(label1, 2, 0); | 115 | "communicate. You should not change this unless\n" |
106 | 116 | "you know what you are doing.\n" | |
107 | flowcontrol = new QComboBox(false, this); | 117 | "\n" |
108 | label1->setBuddy(flowcontrol); | 118 | "<b>Default</b>: CRTSCTS"); |
109 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); | 119 | |
110 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); | 120 | QWhatsThis::add(label1,tmp); |
111 | flowcontrol->insertItem(tr("None")); | 121 | QWhatsThis::add(flowcontrol,tmp); |
112 | tl->addWidget(flowcontrol, 2, 1); | 122 | |
113 | // connect(flowcontrol, SIGNAL(activated(int)), | 123 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); |
114 | // SLOT(setflowcontrol(int))); | 124 | tl->addWidget(labelenter, 3, 0); |
115 | 125 | ||
116 | tmp = tr("<p>Specifies how the serial port and modem\n" | 126 | enter = new QComboBox(false, this); |
117 | "communicate. You should not change this unless\n" | 127 | labelenter->setBuddy(enter); |
118 | "you know what you are doing.\n" | 128 | enter->insertItem("CR"); |
119 | "\n" | 129 | enter->insertItem("LF"); |
120 | "<b>Default</b>: CRTSCTS"); | 130 | enter->insertItem("CR/LF"); |
121 | 131 | tl->addWidget(enter, 3, 1); | |
122 | QWhatsThis::add(label1,tmp); | 132 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
123 | QWhatsThis::add(flowcontrol,tmp); | 133 | tmp = tr("<p>Specifies how AT commands are sent to your\n" |
124 | 134 | "modem. Most modems will work fine with the\n" | |
125 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); | 135 | "default <i>CR/LF</i>. If your modem does not react\n" |
126 | tl->addWidget(labelenter, 3, 0); | 136 | "to the init string, you should try different\n" |
127 | 137 | "settings here\n" | |
128 | enter = new QComboBox(false, this); | 138 | "\n" |
129 | labelenter->setBuddy(enter); | 139 | "<b>Default</b>: CR/LF"); |
130 | enter->insertItem("CR"); | 140 | |
131 | enter->insertItem("LF"); | 141 | QWhatsThis::add(labelenter,tmp); |
132 | enter->insertItem("CR/LF"); | 142 | QWhatsThis::add(enter, tmp); |
133 | tl->addWidget(enter, 3, 1); | 143 | |
134 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 144 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); |
135 | tmp = tr("<p>Specifies how AT commands are sent to your\n" | 145 | tl->addWidget(baud_label, 4, 0); |
136 | "modem. Most modems will work fine with the\n" | 146 | baud_c = new QComboBox(this); |
137 | "default <i>CR/LF</i>. If your modem does not react\n" | 147 | baud_label->setBuddy(baud_c); |
138 | "to the init string, you should try different\n" | 148 | |
139 | "settings here\n" | 149 | static const char *baudrates[] = |
140 | "\n" | 150 | { |
141 | "<b>Default</b>: CR/LF"); | ||
142 | |||
143 | QWhatsThis::add(labelenter,tmp); | ||
144 | QWhatsThis::add(enter, tmp); | ||
145 | |||
146 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); | ||
147 | tl->addWidget(baud_label, 4, 0); | ||
148 | baud_c = new QComboBox(this); | ||
149 | baud_label->setBuddy(baud_c); | ||
150 | |||
151 | static const char *baudrates[] = { | ||
152 | 151 | ||
153 | #ifdef B460800 | 152 | #ifdef B460800 |
154 | "460800", | 153 | "460800", |
155 | #endif | 154 | #endif |
156 | 155 | ||
157 | #ifdef B230400 | 156 | #ifdef B230400 |
158 | "230400", | 157 | "230400", |
159 | #endif | 158 | #endif |
160 | 159 | ||
161 | #ifdef B115200 | 160 | #ifdef B115200 |
162 | "115200", | 161 | "115200", |
163 | #endif | 162 | #endif |
164 | 163 | ||
165 | #ifdef B57600 | 164 | #ifdef B57600 |
166 | "57600", | 165 | "57600", |
167 | #endif | 166 | #endif |
168 | 167 | ||
169 | "38400", | 168 | "38400", |
170 | "19200", | 169 | "19200", |
171 | "9600", | 170 | "9600", |
172 | "2400", | 171 | "2400", |
173 | 0}; | 172 | 0 |
174 | 173 | }; | |
175 | for(k = 0; baudrates[k]; k++) | 174 | |
176 | baud_c->insertItem(baudrates[k]); | 175 | for(k = 0; baudrates[k]; k++) |
177 | 176 | baud_c->insertItem(baudrates[k]); | |
178 | baud_c->setCurrentItem(3); | 177 | |
179 | // connect(baud_c, SIGNAL(activated(int)), | 178 | baud_c->setCurrentItem(3); |
180 | // this, SLOT(speed_selection(int))); | 179 | // connect(baud_c, SIGNAL(activated(int)), |
181 | tl->addWidget(baud_c, 4, 1); | 180 | // this, SLOT(speed_selection(int))); |
182 | 181 | tl->addWidget(baud_c, 4, 1); | |
183 | tmp = tr("Specifies the speed your modem and the serial\n" | 182 | |
184 | "port talk to each other. You should begin with\n" | 183 | tmp = tr("Specifies the speed your modem and the serial\n" |
185 | "the default of 38400 bits/sec. If everything\n" | 184 | "port talk to each other. You should begin with\n" |
186 | "works you can try to increase this value, but to\n" | 185 | "the default of 38400 bits/sec. If everything\n" |
187 | "no more than 115200 bits/sec (unless you know\n" | 186 | "works you can try to increase this value, but to\n" |
188 | "that your serial port supports higher speeds)."); | 187 | "no more than 115200 bits/sec (unless you know\n" |
189 | 188 | "that your serial port supports higher speeds)."); | |
190 | QWhatsThis::add(baud_label,tmp); | 189 | |
191 | QWhatsThis::add(baud_c,tmp); | 190 | QWhatsThis::add(baud_label,tmp); |
192 | 191 | QWhatsThis::add(baud_c,tmp); | |
193 | for(int i=0; i <= enter->count()-1; i++) { | 192 | |
194 | if(_pppdata->enter() == enter->text(i)) | 193 | for(int i=0; i <= enter->count()-1; i++) |
195 | enter->setCurrentItem(i); | 194 | { |
196 | } | 195 | if(_pppdata->enter() == enter->text(i)) |
197 | 196 | enter->setCurrentItem(i); | |
198 | tl->addRowSpacing(5, 10); | 197 | } |
199 | 198 | ||
200 | //Modem Lock File | 199 | tl->addRowSpacing(5, 10); |
201 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); | 200 | |
202 | 201 | //Modem Lock File | |
203 | modemlockfile->setChecked(_pppdata->modemLockFile()); | 202 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); |
204 | // connect(modemlockfile, SIGNAL(toggled(bool)), | 203 | |
205 | // SLOT(modemlockfilechanged(bool))); | 204 | modemlockfile->setChecked(_pppdata->modemLockFile()); |
206 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); | 205 | // connect(modemlockfile, SIGNAL(toggled(bool)), |
207 | // l12->addStretch(1); | 206 | // SLOT(modemlockfilechanged(bool))); |
208 | QWhatsThis::add(modemlockfile, | 207 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); |
209 | tr("<p>To prevent other programs from accessing the\n" | 208 | // l12->addStretch(1); |
210 | "modem while a connection is established, a\n" | 209 | QWhatsThis::add(modemlockfile, |
211 | "file can be created to indicate that the modem\n" | 210 | tr("<p>To prevent other programs from accessing the\n" |
212 | "is in use. On Linux an example file would be\n" | 211 | "modem while a connection is established, a\n" |
213 | "<tt>/var/lock/LCK..ttyS1</tt>\n" | 212 | "file can be created to indicate that the modem\n" |
214 | "Here you can select whether this locking will\n" | 213 | "is in use. On Linux an example file would be\n" |
215 | "be done.\n" | 214 | "<tt>/var/lock/LCK..ttyS1</tt>\n" |
216 | "\n" | 215 | "Here you can select whether this locking will\n" |
217 | "<b>Default</b>: On")); | 216 | "be done.\n" |
218 | 217 | "\n" | |
219 | // Modem Timeout Line Edit Box | 218 | "<b>Default</b>: On")); |
220 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); | 219 | |
221 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); | 220 | // Modem Timeout Line Edit Box |
222 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); | 221 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); |
223 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); | 222 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); |
224 | // modemtimeout->setLabel(tr("Modem &timeout:")); | 223 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); |
225 | // modemtimeout->setRange(1, 120, 1); | 224 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); |
226 | modemtimeout->setSuffix(tr(" sec")); | 225 | // modemtimeout->setLabel(tr("Modem &timeout:")); |
227 | modemtimeout->setValue( _pppdata->modemTimeout() ); | 226 | // modemtimeout->setRange(1, 120, 1); |
228 | // connect(modemtimeout, SIGNAL(valueChanged(int)), | 227 | modemtimeout->setSuffix(tr(" sec")); |
229 | // SLOT(modemtimeoutchanged(int))); | 228 | modemtimeout->setValue( _pppdata->modemTimeout() ); |
230 | timeoutLayout->addWidget(timeoutlabel); | 229 | // connect(modemtimeout, SIGNAL(valueChanged(int)), |
231 | timeoutLayout->addWidget(modemtimeout); | 230 | // SLOT(modemtimeoutchanged(int))); |
232 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); | 231 | timeoutLayout->addWidget(timeoutlabel); |
233 | 232 | timeoutLayout->addWidget(modemtimeout); | |
234 | QWhatsThis::add(modemtimeout, | 233 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); |
235 | tr("This specifies how long <i>kppp</i> waits for a\n" | 234 | |
236 | "<i>CONNECT</i> response from your modem. The\n" | 235 | QWhatsThis::add(modemtimeout, |
237 | "recommended value is 30 seconds.")); | 236 | tr("This specifies how long <i>kppp</i> waits for a\n" |
238 | 237 | "<i>CONNECT</i> response from your modem. The\n" | |
239 | //set stuff from gpppdata | 238 | "recommended value is 30 seconds.")); |
240 | for(int i=0; i <= enter->count()-1; i++) { | 239 | |
241 | if(_pppdata->enter() == enter->text(i)) | 240 | //set stuff from gpppdata |
242 | enter->setCurrentItem(i); | 241 | for(int i=0; i <= enter->count()-1; i++) |
243 | } | 242 | { |
244 | 243 | if(_pppdata->enter() == enter->text(i)) | |
245 | for(int i=0; i <= modemdevice->count()-1; i++) { | 244 | enter->setCurrentItem(i); |
246 | if(_pppdata->modemDevice() == modemdevice->text(i)) | 245 | } |
247 | modemdevice->setCurrentItem(i); | 246 | |
248 | } | 247 | for(int i=0; i <= modemdevice->count()-1; i++) |
249 | 248 | { | |
250 | for(int i=0; i <= flowcontrol->count()-1; i++) { | 249 | if(_pppdata->modemDevice() == modemdevice->text(i)) |
251 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) | 250 | modemdevice->setCurrentItem(i); |
252 | flowcontrol->setCurrentItem(i); | 251 | } |
253 | } | 252 | |
254 | 253 | for(int i=0; i <= flowcontrol->count()-1; i++) | |
255 | //set the modem speed | 254 | { |
256 | for(int i=0; i < baud_c->count(); i++) | 255 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) |
257 | if(baud_c->text(i) == _pppdata->speed()) | 256 | flowcontrol->setCurrentItem(i); |
258 | baud_c->setCurrentItem(i); | 257 | } |
259 | 258 | ||
260 | tl->setRowStretch(1, 1); | 259 | //set the modem speed |
260 | for(int i=0; i < baud_c->count(); i++) | ||
261 | if(baud_c->text(i) == _pppdata->speed()) | ||
262 | baud_c->setCurrentItem(i); | ||
263 | |||
264 | tl->setRowStretch(1, 1); | ||
261 | } | 265 | } |
262 | 266 | ||
263 | ModemWidget::~ModemWidget() | 267 | ModemWidget::~ModemWidget() |
264 | { | 268 | { |
265 | QStringList devs; | 269 | QStringList devs; |
266 | 270 | ||
@@ -270,15 +274,17 @@ ModemWidget::~ModemWidget() | |||
270 | s.simplifyWhiteSpace(); | 274 | s.simplifyWhiteSpace(); |
271 | if (! s.isEmpty() ) devs << s; | 275 | if (! s.isEmpty() ) devs << s; |
272 | } | 276 | } |
273 | 277 | ||
274 | 278 | ||
275 | QString edited = modemdevice->currentText(); | 279 | QString edited = modemdevice->currentText(); |
276 | if ( !( edited ).isEmpty() ) { | 280 | if ( !( edited ).isEmpty() ) |
281 | { | ||
277 | edited.simplifyWhiteSpace(); | 282 | edited.simplifyWhiteSpace(); |
278 | if ( devs.contains( edited ) == 0 ) { | 283 | if ( devs.contains( edited ) == 0 ) |
284 | { | ||
279 | devs << edited; | 285 | devs << edited; |
280 | } | 286 | } |
281 | _pppdata->setModemDevice( edited ); | 287 | _pppdata->setModemDevice( edited ); |
282 | } | 288 | } |
283 | 289 | ||
284 | 290 | ||
@@ -323,13 +329,13 @@ ModemWidget::~ModemWidget() | |||
323 | 329 | ||
324 | 330 | ||
325 | bool ModemWidget::save() | 331 | bool ModemWidget::save() |
326 | { | 332 | { |
327 | //first check to make sure that the device name is unique! | 333 | //first check to make sure that the device name is unique! |
328 | if(modemname->text().isEmpty() || | 334 | if(modemname->text().isEmpty() || |
329 | !_pppdata->isUniqueDevname(modemname->text())) | 335 | !_pppdata->isUniqueDevname(modemname->text())) |
330 | return false; | 336 | return false; |
331 | 337 | ||
332 | qDebug("ModemWidget::save saving modem1 data"); | 338 | qDebug("ModemWidget::save saving modem1 data"); |
333 | _pppdata->setDevname( modemname->text() ); | 339 | _pppdata->setDevname( modemname->text() ); |
334 | _pppdata->setModemDevice( modemdevice->currentText() ); | 340 | _pppdata->setModemDevice( modemdevice->currentText() ); |
335 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 341 | _pppdata->setFlowcontrol(flowcontrol->currentText()); |
@@ -340,149 +346,151 @@ bool ModemWidget::save() | |||
340 | return true; | 346 | return true; |
341 | 347 | ||
342 | } | 348 | } |
343 | 349 | ||
344 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, | 350 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, |
345 | const char *name) | 351 | const char *name) |
346 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) | 352 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) |
347 | { | 353 | { |
348 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 354 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
349 | 355 | ||
350 | 356 | ||
351 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); | 357 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); |
352 | waitfordt->setChecked(_pppdata->waitForDialTone()); | 358 | waitfordt->setChecked(_pppdata->waitForDialTone()); |
353 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 359 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
354 | l1->addWidget(waitfordt); | 360 | l1->addWidget(waitfordt); |
355 | QWhatsThis::add(waitfordt, | 361 | QWhatsThis::add(waitfordt, |
356 | tr("<p>Normally the modem waits for a dial tone\n" | 362 | tr("<p>Normally the modem waits for a dial tone\n" |
357 | "from your phone line, indicating that it can\n" | 363 | "from your phone line, indicating that it can\n" |
358 | "start to dial a number. If your modem does not\n" | 364 | "start to dial a number. If your modem does not\n" |
359 | "recognize this sound, or your local phone system\n" | 365 | "recognize this sound, or your local phone system\n" |
360 | "does not emit such a tone, uncheck this option\n" | 366 | "does not emit such a tone, uncheck this option\n" |
361 | "\n" | 367 | "\n" |
362 | "<b>Default:</b>: On")); | 368 | "<b>Default:</b>: On")); |
363 | 369 | ||
364 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); | 370 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); |
365 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); | 371 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); |
366 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); | 372 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); |
367 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); | 373 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); |
368 | // busywait->setLabel(tr("B&usy wait:")); | 374 | // busywait->setLabel(tr("B&usy wait:")); |
369 | // busywait->setRange(0, 300, 5, true); | 375 | // busywait->setRange(0, 300, 5, true); |
370 | busywait->setSuffix(tr(" sec")); | 376 | busywait->setSuffix(tr(" sec")); |
371 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); | 377 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); |
372 | waitLayout->addWidget(waitLabel); | 378 | waitLayout->addWidget(waitLabel); |
373 | waitLayout->addWidget(busywait); | 379 | waitLayout->addWidget(busywait); |
374 | l1->addLayout( waitLayout ); | 380 | l1->addLayout( waitLayout ); |
375 | 381 | ||
376 | QWhatsThis::add(busywait, | 382 | QWhatsThis::add(busywait, |
377 | tr("Specifies the number of seconds to wait before\n" | 383 | tr("Specifies the number of seconds to wait before\n" |
378 | "redial if all dialed numbers are busy. This is\n" | 384 | "redial if all dialed numbers are busy. This is\n" |
379 | "necessary because some modems get stuck if the\n" | 385 | "necessary because some modems get stuck if the\n" |
380 | "same number is busy too often.\n" | 386 | "same number is busy too often.\n" |
381 | "\n" | 387 | "\n" |
382 | "The default is 0 seconds, you should not change\n" | 388 | "The default is 0 seconds, you should not change\n" |
383 | "this unless you need to.")); | 389 | "this unless you need to.")); |
384 | 390 | ||
385 | l1->addSpacing(10); | 391 | l1->addSpacing(10); |
386 | 392 | ||
387 | QHBoxLayout *hbl = new QHBoxLayout; | 393 | QHBoxLayout *hbl = new QHBoxLayout; |
388 | hbl->setSpacing(2);//KDialog::spacingHint()); | 394 | hbl->setSpacing(2);//KDialog::spacingHint()); |
389 | 395 | ||
390 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); | 396 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); |
391 | hbl->addWidget(volumeLabel); | 397 | hbl->addWidget(volumeLabel); |
392 | volume = new QSlider(0, 2, 1, _pppdata->volume(), | 398 | volume = new QSlider(0, 2, 1, _pppdata->volume(), |
393 | QSlider::Horizontal, this); | 399 | QSlider::Horizontal, this); |
394 | volumeLabel->setBuddy(volume); | 400 | volumeLabel->setBuddy(volume); |
395 | volume->setTickmarks(QSlider::Below); | 401 | volume->setTickmarks(QSlider::Below); |
396 | hbl->addWidget(volume); | 402 | hbl->addWidget(volume); |
397 | 403 | ||
398 | l1->addLayout(hbl); | 404 | l1->addLayout(hbl); |
399 | 405 | ||
400 | // connect(volume, SIGNAL(valueChanged(int)), | 406 | // connect(volume, SIGNAL(valueChanged(int)), |
401 | // this, SLOT(volumeChanged(int))); | 407 | // this, SLOT(volumeChanged(int))); |
402 | QString tmp = tr("Most modems have a speaker which makes\n" | 408 | QString tmp = tr("Most modems have a speaker which makes\n" |
403 | "a lot of noise when dialing. Here you can\n" | 409 | "a lot of noise when dialing. Here you can\n" |
404 | "either turn this completely off or select a\n" | 410 | "either turn this completely off or select a\n" |
405 | "lower volume.\n" | 411 | "lower volume.\n" |
406 | "\n" | 412 | "\n" |
407 | "If this does not work for your modem,\n" | 413 | "If this does not work for your modem,\n" |
408 | "you must modify the modem volume command."); | 414 | "you must modify the modem volume command."); |
409 | 415 | ||
410 | QWhatsThis::add(volumeLabel,tmp); | 416 | QWhatsThis::add(volumeLabel,tmp); |
411 | QWhatsThis::add(volume, tmp); | 417 | QWhatsThis::add(volume, tmp); |
412 | 418 | ||
413 | l1->addSpacing(20); | 419 | l1->addSpacing(20); |
414 | 420 | ||
415 | #if 0 | 421 | #if 0 |
416 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); | 422 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); |
417 | chkbox1->setChecked(_pppdata->UseCDLine()); | 423 | chkbox1->setChecked(_pppdata->UseCDLine()); |
418 | connect(chkbox1,SIGNAL(toggled(bool)), | 424 | connect(chkbox1,SIGNAL(toggled(bool)), |
419 | this,SLOT(use_cdline_toggled(bool))); | 425 | this,SLOT(use_cdline_toggled(bool))); |
420 | l12->addWidget(chkbox1); | 426 | l12->addWidget(chkbox1); |
421 | l12->addStretch(1); | 427 | l12->addStretch(1); |
422 | l1->addStretch(1); | 428 | l1->addStretch(1); |
423 | QWhatsThis::add(chkbox1, | 429 | QWhatsThis::add(chkbox1, |
424 | tr("This controls how <i>kppp</i> detects that the modem\n" | 430 | tr("This controls how <i>kppp</i> detects that the modem\n" |
425 | "is not responding. Unless you are having\n" | 431 | "is not responding. Unless you are having\n" |
426 | "problems with this, do not modify this setting.\n" | 432 | "problems with this, do not modify this setting.\n" |
427 | "\n" | 433 | "\n" |
428 | "<b>Default</b>: Off")); | 434 | "<b>Default</b>: Off")); |
429 | #endif | 435 | #endif |
430 | 436 | ||
431 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); | 437 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); |
432 | QWhatsThis::add(modemcmds, | 438 | QWhatsThis::add(modemcmds, |
433 | tr("Allows you to change the AT command for\n" | 439 | tr("Allows you to change the AT command for\n" |
434 | "your modem.")); | 440 | "your modem.")); |
435 | 441 | ||
436 | modeminfo_button = new QPushButton(tr("&Query Modem..."), this); | 442 | modeminfo_button = new QPushButton(tr("&Query Modem..."), this); |
437 | QWhatsThis::add(modeminfo_button, | 443 | QWhatsThis::add(modeminfo_button, |
438 | tr("Most modems support the ATI command set to\n" | 444 | tr("Most modems support the ATI command set to\n" |
439 | "find out vendor and revision of your modem.\n" | 445 | "find out vendor and revision of your modem.\n" |
440 | "\n" | 446 | "\n" |
441 | "Press this button to query your modem for\n" | 447 | "Press this button to query your modem for\n" |
442 | "this information. It can be useful to help\n" | 448 | "this information. It can be useful to help\n" |
443 | "you setup the modem")); | 449 | "you setup the modem")); |
444 | 450 | ||
445 | // terminal_button = new QPushButton(tr("&Terminal..."), this); | 451 | // terminal_button = new QPushButton(tr("&Terminal..."), this); |
446 | // QWhatsThis::add(terminal_button, | 452 | // QWhatsThis::add(terminal_button, |
447 | // tr("Opens the built-in terminal program. You\n" | 453 | // tr("Opens the built-in terminal program. You\n" |
448 | // "can use this if you want to play around\n" | 454 | // "can use this if you want to play around\n" |
449 | // "with your modem's AT command set")); | 455 | // "with your modem's AT command set")); |
450 | 456 | ||
451 | QHBoxLayout *hbox = new QHBoxLayout(); | 457 | QHBoxLayout *hbox = new QHBoxLayout(); |
452 | l1->addLayout(hbox); | 458 | l1->addLayout(hbox); |
453 | hbox->addStretch(1); | 459 | hbox->addStretch(1); |
454 | QVBoxLayout *vbox = new QVBoxLayout(); | 460 | QVBoxLayout *vbox = new QVBoxLayout(); |
455 | hbox->addLayout(vbox); | 461 | hbox->addLayout(vbox); |
456 | 462 | ||
457 | vbox->addWidget(modemcmds); | 463 | vbox->addWidget(modemcmds); |
458 | vbox->addWidget(modeminfo_button); | 464 | vbox->addWidget(modeminfo_button); |
459 | // vbox->addWidget(terminal_button); | 465 | // vbox->addWidget(terminal_button); |
460 | 466 | ||
461 | hbox->addStretch(1); | 467 | hbox->addStretch(1); |
462 | l1->addStretch(1); | 468 | l1->addStretch(1); |
463 | 469 | ||
464 | connect(modemcmds, SIGNAL(clicked()), | 470 | connect(modemcmds, SIGNAL(clicked()), |
465 | SLOT(modemcmdsbutton())); | 471 | SLOT(modemcmdsbutton())); |
466 | connect(modeminfo_button, SIGNAL(clicked()), | 472 | connect(modeminfo_button, SIGNAL(clicked()), |
467 | SLOT(query_modem())); | 473 | SLOT(query_modem())); |
468 | // connect(terminal_button, SIGNAL(clicked()), | 474 | // connect(terminal_button, SIGNAL(clicked()), |
469 | // SLOT(terminal())); | 475 | // SLOT(terminal())); |
470 | } | 476 | } |
471 | 477 | ||
472 | 478 | ||
473 | void ModemWidget2::modemcmdsbutton() { | 479 | void ModemWidget2::modemcmdsbutton() |
474 | ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); | 480 | { |
475 | mc.showMaximized(); | 481 | ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); |
476 | mc.exec(); | 482 | |
483 | QPEApplication::execDialog( &mc ); | ||
477 | } | 484 | } |
478 | 485 | ||
479 | 486 | ||
480 | void ModemWidget2::query_modem() { | 487 | void ModemWidget2::query_modem() |
481 | ModemTransfer mt(_ifaceppp->modem(), this); | 488 | { |
482 | mt.exec(); | 489 | ModemTransfer mt(_ifaceppp->modem(), this); |
490 | mt.exec(); | ||
483 | } | 491 | } |
484 | 492 | ||
485 | 493 | ||
486 | // void ModemWidget2::terminal() { | 494 | // void ModemWidget2::terminal() { |
487 | // MiniTerm terminal(NULL,NULL); | 495 | // MiniTerm terminal(NULL,NULL); |
488 | // terminal.exec(); | 496 | // terminal.exec(); |
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp index dbb26db..df0bf9b 100644 --- a/noncore/settings/networksettings/ppp/modeminfo.cpp +++ b/noncore/settings/networksettings/ppp/modeminfo.cpp | |||
@@ -21,274 +21,293 @@ | |||
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <unistd.h> | 27 | #include "modeminfo.h" |
28 | #include "modem.h" | ||
29 | |||
30 | /* OPIE */ | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | |||
33 | /* QT */ | ||
28 | #include <qregexp.h> | 34 | #include <qregexp.h> |
29 | #include <qlayout.h> | 35 | #include <qlayout.h> |
30 | // #include <kwin.h> | ||
31 | // #include <kmessagebox.h> | ||
32 | // #include <kapplication.h> | ||
33 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 37 | #include <qapplication.h> |
35 | #include "modeminfo.h" | 38 | |
36 | #include "modem.h" | 39 | /* STD */ |
40 | #include <unistd.h> | ||
37 | 41 | ||
38 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) | 42 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) |
39 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), | 43 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), |
40 | _modem(mo) | 44 | _modem(mo) |
41 | { | 45 | { |
42 | setCaption(QObject::tr("ATI Query")); | 46 | setCaption(QObject::tr("ATI Query")); |
43 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 47 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
44 | 48 | ||
45 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 49 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
46 | 50 | ||
47 | progressBar = new QProgressBar(this, "bar"); | 51 | progressBar = new QProgressBar(this, "bar"); |
48 | progressBar->setTotalSteps(8); | 52 | progressBar->setTotalSteps(8); |
49 | 53 | ||
50 | statusBar = new QLabel(this,"sBar"); | 54 | statusBar = new QLabel(this,"sBar"); |
51 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 55 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
52 | statusBar->setAlignment(AlignCenter); | 56 | statusBar->setAlignment(AlignCenter); |
53 | 57 | ||
54 | // This is a rather complicated case. Since we do not know which | 58 | // This is a rather complicated case. Since we do not know which |
55 | // message is the widest in the national language, we'd to | 59 | // message is the widest in the national language, we'd to |
56 | // search all these messages. This is a little overkill, so I take | 60 | // search all these messages. This is a little overkill, so I take |
57 | // the longest english message, translate it and give it additional | 61 | // the longest english message, translate it and give it additional |
58 | // 20 percent space. Hope this is enough. | 62 | // 20 percent space. Hope this is enough. |
59 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); | 63 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
60 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); | 64 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); |
61 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); | 65 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); |
62 | 66 | ||
63 | // set original text | 67 | // set original text |
64 | statusBar->setText(QObject::tr("Looking for modem...")); | 68 | statusBar->setText(QObject::tr("Looking for modem...")); |
65 | progressBar->setFixedHeight(statusBar->minimumSize().height()); | 69 | progressBar->setFixedHeight(statusBar->minimumSize().height()); |
66 | tl->addWidget(progressBar); | 70 | tl->addWidget(progressBar); |
67 | tl->addWidget(statusBar); | 71 | tl->addWidget(statusBar); |
68 | 72 | ||
69 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 73 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
70 | cancel->setFocus(); | 74 | cancel->setFocus(); |
71 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 75 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
72 | 76 | ||
73 | QHBoxLayout *l1 = new QHBoxLayout; | 77 | QHBoxLayout *l1 = new QHBoxLayout; |
74 | tl->addLayout(l1); | 78 | tl->addLayout(l1); |
75 | l1->addStretch(1); | 79 | l1->addStretch(1); |
76 | l1->addWidget(cancel); | 80 | l1->addWidget(cancel); |
77 | 81 | ||
78 | setFixedSize(sizeHint()); | 82 | setFixedSize(sizeHint()); |
79 | 83 | ||
80 | step = 0; | 84 | step = 0; |
81 | 85 | ||
82 | //////////////////////////////////////////////// | 86 | //////////////////////////////////////////////// |
83 | 87 | ||
84 | timeout_timer = new QTimer(this); | 88 | timeout_timer = new QTimer(this); |
85 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); | 89 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); |
86 | 90 | ||
87 | scripttimer = new QTimer(this); | 91 | scripttimer = new QTimer(this); |
88 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); | 92 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); |
89 | 93 | ||
90 | timeout_timer->start(15000,TRUE); // 15 secs single shot | 94 | timeout_timer->start(15000,TRUE); // 15 secs single shot |
91 | QTimer::singleShot(500, this, SLOT(init())); | 95 | QTimer::singleShot(500, this, SLOT(init())); |
92 | 96 | ||
93 | } | 97 | } |
94 | 98 | ||
95 | 99 | ||
96 | void ModemTransfer::ati_done() { | 100 | void ModemTransfer::ati_done() |
97 | scripttimer->stop(); | 101 | { |
98 | timeout_timer->stop(); | 102 | scripttimer->stop(); |
99 | _modem->closetty(); | 103 | timeout_timer->stop(); |
100 | _modem->unlockdevice(); | 104 | _modem->closetty(); |
101 | hide(); | 105 | _modem->unlockdevice(); |
106 | hide(); | ||
107 | |||
108 | // open the result window | ||
109 | ModemInfo *mi = new ModemInfo(this); | ||
110 | for(int i = 0; i < NUM_OF_ATI; i++) | ||
111 | mi->setAtiString(i, ati_query_strings[i]); | ||
102 | 112 | ||
103 | // open the result window | 113 | QPEApplication::execDialog( mi ); |
104 | ModemInfo *mi = new ModemInfo(this); | 114 | delete mi; |
105 | for(int i = 0; i < NUM_OF_ATI; i++) | ||
106 | mi->setAtiString(i, ati_query_strings[i]); | ||
107 | mi->showMaximized(); | ||
108 | mi->exec(); | ||
109 | delete mi; | ||
110 | 115 | ||
111 | accept(); | 116 | accept(); |
112 | } | 117 | } |
113 | 118 | ||
114 | 119 | ||
115 | void ModemTransfer::time_out_slot() { | 120 | void ModemTransfer::time_out_slot() |
116 | timeout_timer->stop(); | 121 | { |
117 | scripttimer->stop(); | 122 | timeout_timer->stop(); |
123 | scripttimer->stop(); | ||
118 | 124 | ||
119 | QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); | 125 | QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); |
120 | reject(); | 126 | reject(); |
121 | } | 127 | } |
122 | 128 | ||
123 | 129 | ||
124 | void ModemTransfer::init() { | 130 | void ModemTransfer::init() |
131 | { | ||
125 | 132 | ||
126 | qApp->processEvents(); | 133 | qApp->processEvents(); |
127 | 134 | ||
128 | int lock = _modem->lockdevice(); | 135 | int lock = _modem->lockdevice(); |
129 | if (lock == 1) { | 136 | if (lock == 1) |
137 | { | ||
130 | 138 | ||
131 | statusBar->setText(QObject::tr("Modem device is locked.")); | 139 | statusBar->setText(QObject::tr("Modem device is locked.")); |
132 | return; | 140 | return; |
133 | } | 141 | } |
134 | 142 | ||
135 | if (lock == -1) { | 143 | if (lock == -1) |
144 | { | ||
136 | 145 | ||
137 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); | 146 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
138 | return; | 147 | return; |
139 | } | 148 | } |
140 | 149 | ||
141 | 150 | ||
142 | if(_modem->opentty()) { | 151 | if(_modem->opentty()) |
143 | if(_modem->hangup()) { | 152 | { |
144 | usleep(100000); // wait 0.1 secs | 153 | if(_modem->hangup()) |
145 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | 154 | { |
155 | usleep(100000); // wait 0.1 secs | ||
156 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | ||
146 | 157 | ||
147 | statusBar->setText(QObject::tr("Modem Ready")); | 158 | statusBar->setText(QObject::tr("Modem Ready")); |
148 | qApp->processEvents(); | 159 | qApp->processEvents(); |
149 | usleep(100000); // wait 0.1 secs | 160 | usleep(100000); // wait 0.1 secs |
150 | qApp->processEvents(); | 161 | qApp->processEvents(); |
151 | scripttimer->start(1000); // this one does the ati query | 162 | scripttimer->start(1000); // this one does the ati query |
152 | 163 | ||
153 | // clear modem buffer | 164 | // clear modem buffer |
154 | _modem->flush(); | 165 | _modem->flush(); |
155 | 166 | ||
156 | _modem->notify(this, SLOT(readChar(unsigned char))); | 167 | _modem->notify(this, SLOT(readChar(unsigned char))); |
157 | return; | 168 | return; |
169 | } | ||
158 | } | 170 | } |
159 | } | ||
160 | 171 | ||
161 | // opentty() or hangup() failed | 172 | // opentty() or hangup() failed |
162 | statusBar->setText(_modem->modemMessage()); | 173 | statusBar->setText(_modem->modemMessage()); |
163 | step = 99; // wait until cancel is pressed | 174 | step = 99; // wait until cancel is pressed |
164 | _modem->unlockdevice(); | 175 | _modem->unlockdevice(); |
165 | } | 176 | } |
166 | 177 | ||
167 | 178 | ||
168 | void ModemTransfer::do_script() { | 179 | void ModemTransfer::do_script() |
169 | QString msg; | 180 | { |
170 | QString query; | 181 | QString msg; |
171 | 182 | QString query; | |
172 | switch(step) { | 183 | |
173 | case 0: | 184 | switch(step) |
174 | readtty(); | 185 | { |
175 | statusBar->setText("ATI..."); | 186 | case 0: |
176 | progressBar->setProgress( progressBar->progress() + 1); | 187 | readtty(); |
177 | _modem->writeLine("ATI\n"); | 188 | statusBar->setText("ATI..."); |
178 | break; | 189 | progressBar->setProgress( progressBar->progress() + 1); |
179 | 190 | _modem->writeLine("ATI\n"); | |
180 | case 1: | 191 | break; |
181 | case 2: | 192 | |
182 | case 3: | 193 | case 1: |
183 | case 4: | 194 | case 2: |
184 | case 5: | 195 | case 3: |
185 | case 6: | 196 | case 4: |
186 | case 7: | 197 | case 5: |
187 | readtty(); | 198 | case 6: |
188 | msg.sprintf("ATI %d ...", step); | 199 | case 7: |
189 | query.sprintf("ATI%d\n", step); | 200 | readtty(); |
190 | statusBar->setText(msg); | 201 | msg.sprintf("ATI %d ...", step); |
191 | progressBar->setProgress( progressBar->progress() + 1); | 202 | query.sprintf("ATI%d\n", step); |
192 | _modem->writeLine(query.local8Bit()); | 203 | statusBar->setText(msg); |
193 | break; | 204 | progressBar->setProgress( progressBar->progress() + 1); |
194 | 205 | _modem->writeLine(query.local8Bit()); | |
195 | default: | 206 | break; |
196 | readtty(); | 207 | |
197 | ati_done(); | 208 | default: |
198 | } | 209 | readtty(); |
199 | step++; | 210 | ati_done(); |
211 | } | ||
212 | step++; | ||
200 | } | 213 | } |
201 | 214 | ||
202 | void ModemTransfer::readChar(unsigned char c) { | 215 | void ModemTransfer::readChar(unsigned char c) |
203 | if(readbuffer.length() < 255) | 216 | { |
204 | readbuffer += c; | 217 | if(readbuffer.length() < 255) |
218 | readbuffer += c; | ||
205 | } | 219 | } |
206 | 220 | ||
207 | void ModemTransfer::readtty() { | 221 | void ModemTransfer::readtty() |
222 | { | ||
208 | 223 | ||
209 | if (step == 0) | 224 | if (step == 0) |
210 | return; | 225 | return; |
211 | 226 | ||
212 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r | 227 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r |
213 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white | 228 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white |
214 | // space | 229 | // space |
215 | 230 | ||
216 | if(step <= NUM_OF_ATI) | 231 | if(step <= NUM_OF_ATI) |
217 | ati_query_strings[step-1] = readbuffer.copy(); | 232 | ati_query_strings[step-1] = readbuffer.copy(); |
218 | 233 | ||
219 | readbuffer = ""; | 234 | readbuffer = ""; |
220 | } | 235 | } |
221 | 236 | ||
222 | 237 | ||
223 | void ModemTransfer::cancelbutton() { | 238 | void ModemTransfer::cancelbutton() |
224 | scripttimer->stop(); | 239 | { |
225 | _modem->stop(); | 240 | scripttimer->stop(); |
226 | timeout_timer->stop(); | 241 | _modem->stop(); |
242 | timeout_timer->stop(); | ||
227 | 243 | ||
228 | statusBar->setText(QObject::tr("One moment please...")); | 244 | statusBar->setText(QObject::tr("One moment please...")); |
229 | qApp->processEvents(); | 245 | qApp->processEvents(); |
230 | 246 | ||
231 | _modem->hangup(); | 247 | _modem->hangup(); |
232 | 248 | ||
233 | _modem->closetty(); | 249 | _modem->closetty(); |
234 | _modem->unlockdevice(); | 250 | _modem->unlockdevice(); |
235 | reject(); | 251 | reject(); |
236 | } | 252 | } |
237 | 253 | ||
238 | 254 | ||
239 | void ModemTransfer::closeEvent( QCloseEvent *e ) { | 255 | void ModemTransfer::closeEvent( QCloseEvent *e ) |
240 | cancelbutton(); | 256 | { |
241 | e->accept(); | 257 | cancelbutton(); |
258 | e->accept(); | ||
242 | } | 259 | } |
243 | 260 | ||
244 | 261 | ||
245 | ModemInfo::ModemInfo(QWidget *parent, const char* name) | 262 | ModemInfo::ModemInfo(QWidget *parent, const char* name) |
246 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) | 263 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) |
247 | { | 264 | { |
248 | QString label_text; | 265 | QString label_text; |
249 | 266 | ||
250 | setCaption(QObject::tr("Modem Query Results")); | 267 | setCaption(QObject::tr("Modem Query Results")); |
251 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 268 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
252 | 269 | ||
253 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 270 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
254 | 271 | ||
255 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); | 272 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); |
256 | tl->addLayout(l1, 1); | 273 | tl->addLayout(l1, 1); |
257 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { | 274 | for(int i = 0 ; i < NUM_OF_ATI ; i++) |
275 | { | ||
258 | 276 | ||
259 | label_text = ""; | 277 | label_text = ""; |
260 | if ( i == 0) | 278 | if ( i == 0) |
261 | label_text.sprintf("ATI :"); | 279 | label_text.sprintf("ATI :"); |
262 | else | 280 | else |
263 | label_text.sprintf("ATI %d:", i ); | 281 | label_text.sprintf("ATI %d:", i ); |
264 | 282 | ||
265 | ati_label[i] = new QLabel(label_text, this); | 283 | ati_label[i] = new QLabel(label_text, this); |
266 | l1->addWidget(ati_label[i], i, 0); | 284 | l1->addWidget(ati_label[i], i, 0); |
267 | 285 | ||
268 | ati_label_result[i] = new QLineEdit(this); | 286 | ati_label_result[i] = new QLineEdit(this); |
269 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); | 287 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); |
270 | l1->addWidget(ati_label_result[i], i, 1); | 288 | l1->addWidget(ati_label_result[i], i, 1); |
271 | } | 289 | } |
272 | //tl->addSpacing(1); | 290 | //tl->addSpacing(1); |
273 | 291 | ||
274 | QHBoxLayout *l2 = new QHBoxLayout; | 292 | QHBoxLayout *l2 = new QHBoxLayout; |
275 | QPushButton *ok = new QPushButton(QObject::tr("Close"), this); | 293 | QPushButton *ok = new QPushButton(QObject::tr("Close"), this); |
276 | ok->setDefault(TRUE); | 294 | ok->setDefault(TRUE); |
277 | ok->setFocus(); | 295 | ok->setFocus(); |
278 | 296 | ||
279 | tl->addLayout(l2); | 297 | tl->addLayout(l2); |
280 | l2->addStretch(1); | 298 | l2->addStretch(1); |
281 | 299 | ||
282 | connect(ok, SIGNAL(clicked()), SLOT(accept())); | 300 | connect(ok, SIGNAL(clicked()), SLOT(accept())); |
283 | l2->addWidget(ok); | 301 | l2->addWidget(ok); |
284 | 302 | ||
285 | setMinimumSize(sizeHint()); | 303 | setMinimumSize(sizeHint()); |
286 | } | 304 | } |
287 | 305 | ||
288 | 306 | ||
289 | void ModemInfo::setAtiString(int i, QString s) { | 307 | void ModemInfo::setAtiString(int i, QString s) |
290 | if(i < NUM_OF_ATI) | 308 | { |
291 | ati_label_result[i]->setText(s); | 309 | if(i < NUM_OF_ATI) |
310 | ati_label_result[i]->setText(s); | ||
292 | } | 311 | } |
293 | 312 | ||
294 | //#include "modeminfo.moc" | 313 | //#include "modeminfo.moc" |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index f7dacf6..a7caffe 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,32 +1,40 @@ | |||
1 | #include <errno.h> | ||
2 | #include <signal.h> | ||
3 | |||
4 | |||
5 | #include <qpe/config.h> | ||
6 | 1 | ||
7 | #include "modem.h" | 2 | #include "modem.h" |
8 | #include "pppconfig.h" | 3 | #include "pppconfig.h" |
9 | #include "pppmodule.h" | 4 | #include "pppmodule.h" |
10 | #include "pppdata.h" | 5 | #include "pppdata.h" |
11 | #include "interfaceinformationppp.h" | 6 | #include "interfaceinformationppp.h" |
12 | #include "interfaceppp.h" | 7 | #include "interfaceppp.h" |
13 | 8 | ||
9 | /* OPIE */ | ||
10 | #include <qpe/config.h> | ||
11 | #include <qpe/qpeapplication.h> | ||
12 | |||
13 | /* QT */ | ||
14 | |||
15 | /* STD */ | ||
16 | #include <errno.h> | ||
17 | #include <signal.h> | ||
18 | |||
14 | // don't polute global namespace | 19 | // don't polute global namespace |
15 | namespace { | 20 | namespace |
21 | { | ||
16 | /* | 22 | /* |
17 | * If network settings is qutting and we've ppp | 23 | * If network settings is qutting and we've ppp |
18 | * devices open we need to save the pid_t the PPData | 24 | * devices open we need to save the pid_t the PPData |
19 | * and the interface number | 25 | * and the interface number |
20 | */ | 26 | */ |
21 | struct Connection { | 27 | struct Connection |
28 | { | ||
22 | pid_t pid; | 29 | pid_t pid; |
23 | QString device; | 30 | QString device; |
24 | QString name; | 31 | QString name; |
25 | }; | 32 | }; |
26 | class InterfaceKeeper { | 33 | class InterfaceKeeper |
34 | { | ||
27 | public: | 35 | public: |
28 | InterfaceKeeper(); | 36 | InterfaceKeeper(); |
29 | ~InterfaceKeeper(); | 37 | ~InterfaceKeeper(); |
30 | 38 | ||
31 | void addInterface( pid_t, const QString& pppDev, const QString& name ); | 39 | void addInterface( pid_t, const QString& pppDev, const QString& name ); |
32 | QMap<QString, Connection> interfaces()const; // will check if still available | 40 | QMap<QString, Connection> interfaces()const; // will check if still available |
@@ -50,20 +58,22 @@ PPPModule::PPPModule() : Module() | |||
50 | QStringList handledInterfaceNames; | 58 | QStringList handledInterfaceNames; |
51 | 59 | ||
52 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 60 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
53 | QMap<QString,QString>::Iterator it; | 61 | QMap<QString,QString>::Iterator it; |
54 | InterfacePPP *iface; | 62 | InterfacePPP *iface; |
55 | qDebug("getting interfaces"); | 63 | qDebug("getting interfaces"); |
56 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 64 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) |
65 | { | ||
57 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); | 66 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); |
58 | iface = new InterfacePPP( 0, it.key() ); | 67 | iface = new InterfacePPP( 0, it.key() ); |
59 | iface->setHardwareName( it.data() ); | 68 | iface->setHardwareName( it.data() ); |
60 | list.append( (Interface*)iface ); | 69 | list.append( (Interface*)iface ); |
61 | 70 | ||
62 | // check if (*it) is one of the running ifaces | 71 | // check if (*it) is one of the running ifaces |
63 | if ( running.contains( it.data() ) ) { | 72 | if ( running.contains( it.data() ) ) |
73 | { | ||
64 | qDebug("iface is running %s", it.key().latin1() ); | 74 | qDebug("iface is running %s", it.key().latin1() ); |
65 | handledInterfaceNames << running[it.data()].device; | 75 | handledInterfaceNames << running[it.data()].device; |
66 | iface->setStatus( true ); | 76 | iface->setStatus( true ); |
67 | iface->setPPPDpid( running[it.data()].pid ); | 77 | iface->setPPPDpid( running[it.data()].pid ); |
68 | iface->modem()->setPPPDevice( running[it.data()].device ); | 78 | iface->modem()->setPPPDevice( running[it.data()].device ); |
69 | iface->refresh(); | 79 | iface->refresh(); |
@@ -73,20 +83,23 @@ PPPModule::PPPModule() : Module() | |||
73 | setHandledInterfaceNames( handledInterfaceNames ); | 83 | setHandledInterfaceNames( handledInterfaceNames ); |
74 | } | 84 | } |
75 | 85 | ||
76 | /** | 86 | /** |
77 | * Delete any interfaces that we own. | 87 | * Delete any interfaces that we own. |
78 | */ | 88 | */ |
79 | PPPModule::~PPPModule(){ | 89 | PPPModule::~PPPModule() |
90 | { | ||
80 | qDebug("PPPModule::~PPPModule() " ); | 91 | qDebug("PPPModule::~PPPModule() " ); |
81 | QMap<QString,QString> ifaces; | 92 | QMap<QString,QString> ifaces; |
82 | InterfaceKeeper keeper; | 93 | InterfaceKeeper keeper; |
83 | Interface *i; | 94 | Interface *i; |
84 | for ( i=list.first(); i != 0; i=list.next() ){ | 95 | for ( i=list.first(); i != 0; i=list.next() ) |
96 | { | ||
85 | /* if online save the state */ | 97 | /* if online save the state */ |
86 | if ( i->getStatus() ) { | 98 | if ( i->getStatus() ) |
99 | { | ||
87 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); | 100 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); |
88 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); | 101 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); |
89 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); | 102 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); |
90 | } | 103 | } |
91 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 104 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
92 | delete i; | 105 | delete i; |
@@ -94,154 +107,174 @@ PPPModule::~PPPModule(){ | |||
94 | PPPData::setConfiguredInterfaces( ifaces ); | 107 | PPPData::setConfiguredInterfaces( ifaces ); |
95 | } | 108 | } |
96 | 109 | ||
97 | /** | 110 | /** |
98 | * Change the current profile | 111 | * Change the current profile |
99 | */ | 112 | */ |
100 | void PPPModule::setProfile(const QString &newProfile){ | 113 | void PPPModule::setProfile(const QString &newProfile) |
101 | profile = newProfile; | 114 | { |
115 | profile = newProfile; | ||
102 | } | 116 | } |
103 | 117 | ||
104 | /** | 118 | /** |
105 | * get the icon name for this device. | 119 | * get the icon name for this device. |
106 | * @param Interface* can be used in determining the icon. | 120 | * @param Interface* can be used in determining the icon. |
107 | * @return QString the icon name (minus .png, .gif etc) | 121 | * @return QString the icon name (minus .png, .gif etc) |
108 | */ | 122 | */ |
109 | QString PPPModule::getPixmapName(Interface* ){ | 123 | QString PPPModule::getPixmapName(Interface* ) |
110 | return "ppp"; | 124 | { |
125 | return "ppp"; | ||
111 | } | 126 | } |
112 | 127 | ||
113 | /** | 128 | /** |
114 | * Check to see if the interface i is owned by this module. | 129 | * Check to see if the interface i is owned by this module. |
115 | * @param Interface* interface to check against | 130 | * @param Interface* interface to check against |
116 | * @return bool true if i is owned by this module, false otherwise. | 131 | * @return bool true if i is owned by this module, false otherwise. |
117 | */ | 132 | */ |
118 | bool PPPModule::isOwner(Interface *i){ | 133 | bool PPPModule::isOwner(Interface *i) |
134 | { | ||
119 | return list.find( i ) != -1; | 135 | return list.find( i ) != -1; |
120 | } | 136 | } |
121 | 137 | ||
122 | /** | 138 | /** |
123 | * Create, and return the WLANConfigure Module | 139 | * Create, and return the WLANConfigure Module |
124 | * @return QWidget* pointer to this modules configure. | 140 | * @return QWidget* pointer to this modules configure. |
125 | */ | 141 | */ |
126 | QWidget *PPPModule::configure(Interface *i){ | 142 | QWidget *PPPModule::configure(Interface *i) |
143 | { | ||
127 | qDebug("return ModemWidget"); | 144 | qDebug("return ModemWidget"); |
128 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 145 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
129 | 0, "PPPConfig", false, | 146 | 0, "PPPConfig", false, |
130 | (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); | 147 | (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); |
131 | return pppconfig; | 148 | return pppconfig; |
132 | } | 149 | } |
133 | 150 | ||
134 | /** | 151 | /** |
135 | * Create, and return the Information Module | 152 | * Create, and return the Information Module |
136 | * @return QWidget* pointer to this modules info. | 153 | * @return QWidget* pointer to this modules info. |
137 | */ | 154 | */ |
138 | QWidget *PPPModule::information(Interface *i){ | 155 | QWidget *PPPModule::information(Interface *i) |
139 | // We don't have any advanced pppd information widget yet :-D | 156 | { |
140 | // TODO ^ | 157 | // We don't have any advanced pppd information widget yet :-D |
158 | // TODO ^ | ||
141 | 159 | ||
142 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | 160 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
143 | } | 161 | } |
144 | 162 | ||
145 | /** | 163 | /** |
146 | * Get all active (up or down) interfaces | 164 | * Get all active (up or down) interfaces |
147 | * @return QList<Interface> A list of interfaces that exsist that havn't | 165 | * @return QList<Interface> A list of interfaces that exsist that havn't |
148 | * been called by isOwner() | 166 | * been called by isOwner() |
149 | */ | 167 | */ |
150 | QList<Interface> PPPModule::getInterfaces(){ | 168 | QList<Interface> PPPModule::getInterfaces() |
151 | // List all of the files in the peer directory | 169 | { |
170 | // List all of the files in the peer directory | ||
152 | qDebug("PPPModule::getInterfaces"); | 171 | qDebug("PPPModule::getInterfaces"); |
153 | return list; | 172 | return list; |
154 | } | 173 | } |
155 | 174 | ||
156 | /** | 175 | /** |
157 | * Attempt to add a new interface as defined by name | 176 | * Attempt to add a new interface as defined by name |
158 | * @param name the name of the type of interface that should be created given | 177 | * @param name the name of the type of interface that should be created given |
159 | * by possibleNewInterfaces(); | 178 | * by possibleNewInterfaces(); |
160 | * @return Interface* NULL if it was unable to be created. | 179 | * @return Interface* NULL if it was unable to be created. |
161 | */ | 180 | */ |
162 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 181 | Interface *PPPModule::addNewInterface(const QString &newInterface) |
163 | 182 | { | |
164 | InterfacePPP *ifaceppp; | 183 | |
165 | Interface *iface; | 184 | InterfacePPP *ifaceppp; |
166 | ifaceppp = new InterfacePPP(); | 185 | Interface *iface; |
167 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 186 | ifaceppp = new InterfacePPP(); |
168 | imp.showMaximized(); | 187 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
169 | if(imp.exec() == QDialog::Accepted ){ | 188 | |
170 | iface = (InterfacePPP*) ifaceppp; | 189 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) |
171 | iface->setModuleOwner( this ); | 190 | { |
172 | list.append( iface ); | 191 | iface = (InterfacePPP*) ifaceppp; |
173 | return iface; | 192 | iface->setModuleOwner( this ); |
174 | }else { | 193 | list.append( iface ); |
175 | delete ifaceppp; | 194 | return iface; |
176 | iface = NULL; | 195 | } |
177 | } | 196 | else |
178 | return iface; | 197 | { |
198 | delete ifaceppp; | ||
199 | iface = NULL; | ||
200 | } | ||
201 | return iface; | ||
179 | } | 202 | } |
180 | 203 | ||
181 | /** | 204 | /** |
182 | * Attempts to remove the interface, doesn't delete i | 205 | * Attempts to remove the interface, doesn't delete i |
183 | * @return bool true if successful, false otherwise. | 206 | * @return bool true if successful, false otherwise. |
184 | */ | 207 | */ |
185 | bool PPPModule::remove(Interface *i){ | 208 | bool PPPModule::remove(Interface *i) |
209 | { | ||
186 | return list.remove(i); | 210 | return list.remove(i); |
187 | } | 211 | } |
188 | 212 | ||
189 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | 213 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) |
190 | { | 214 | { |
191 | newIfaces.insert(QObject::tr("PPP") , | 215 | newIfaces.insert(QObject::tr("PPP") , |
192 | QObject::tr("generic ppp device")); | 216 | QObject::tr("generic ppp device")); |
193 | } | 217 | } |
194 | 218 | ||
195 | 219 | ||
196 | 220 | ||
197 | namespace { | 221 | namespace |
198 | InterfaceKeeper::InterfaceKeeper( ) { | 222 | { |
199 | } | 223 | InterfaceKeeper::InterfaceKeeper( ) |
200 | InterfaceKeeper::~InterfaceKeeper() { | 224 | {} |
225 | InterfaceKeeper::~InterfaceKeeper() | ||
226 | { | ||
201 | Config cfg("ppp_plugin_keeper"); | 227 | Config cfg("ppp_plugin_keeper"); |
202 | QStringList lst = cfg.groupList(); | 228 | QStringList lst = cfg.groupList(); |
203 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 229 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
230 | { | ||
204 | Connection con; | 231 | Connection con; |
205 | cfg.setGroup( (*it) ); | 232 | cfg.setGroup( (*it) ); |
206 | cfg.clearGroup(); | 233 | cfg.clearGroup(); |
207 | } | 234 | } |
208 | 235 | ||
209 | for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { | 236 | for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) |
237 | { | ||
210 | Connection con = it.data(); | 238 | Connection con = it.data(); |
211 | cfg.setGroup( con.name ); | 239 | cfg.setGroup( con.name ); |
212 | cfg.writeEntry( "pid", con.pid ); | 240 | cfg.writeEntry( "pid", con.pid ); |
213 | cfg.writeEntry( "device", con.device ); | 241 | cfg.writeEntry( "device", con.device ); |
214 | } | 242 | } |
215 | } | 243 | } |
216 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { | 244 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) |
245 | { | ||
217 | Connection con; | 246 | Connection con; |
218 | con.pid = pid; | 247 | con.pid = pid; |
219 | con.device = dev; | 248 | con.device = dev; |
220 | con.name = name; | 249 | con.name = name; |
221 | m_interfaces.insert( name, con ); | 250 | m_interfaces.insert( name, con ); |
222 | } | 251 | } |
223 | QMap<QString, Connection> InterfaceKeeper::interfaces()const { | 252 | QMap<QString, Connection> InterfaceKeeper::interfaces()const |
253 | { | ||
224 | Config cfg("ppp_plugin_keeper"); | 254 | Config cfg("ppp_plugin_keeper"); |
225 | QMap<QString, Connection> ifaces; | 255 | QMap<QString, Connection> ifaces; |
226 | QStringList lst = cfg.groupList(); | 256 | QStringList lst = cfg.groupList(); |
227 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 257 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
258 | { | ||
228 | Connection con; | 259 | Connection con; |
229 | cfg.setGroup( (*it) ); | 260 | cfg.setGroup( (*it) ); |
230 | con.name = (*it); | 261 | con.name = (*it); |
231 | con.pid = cfg.readNumEntry("pid"); | 262 | con.pid = cfg.readNumEntry("pid"); |
232 | con.device = cfg.readEntry("device"); | 263 | con.device = cfg.readEntry("device"); |
233 | qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); | 264 | qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); |
234 | 265 | ||
235 | if ( con.pid != -1 && isAvailable( con.pid ) ) | 266 | if ( con.pid != -1 && isAvailable( con.pid ) ) |
236 | ifaces.insert( con.name, con ); | 267 | ifaces.insert( con.name, con ); |
237 | } | 268 | } |
238 | return ifaces; | 269 | return ifaces; |
239 | } | 270 | } |
240 | bool InterfaceKeeper::isAvailable( pid_t p)const { | 271 | bool InterfaceKeeper::isAvailable( pid_t p)const |
241 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) { | 272 | { |
273 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) | ||
274 | { | ||
242 | qDebug("isAvailable %d", p); | 275 | qDebug("isAvailable %d", p); |
243 | return true; | 276 | return true; |
244 | } | 277 | } |
245 | 278 | ||
246 | qDebug("notAvailable %d", p); | 279 | qDebug("notAvailable %d", p); |
247 | return false; | 280 | return false; |