author | tille <tille> | 2003-06-02 14:25:18 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-02 14:25:18 (UTC) |
commit | c1e61c513803b05eea14de18604ef05d2f73d5a7 (patch) (unidiff) | |
tree | 9b4abc263eda4a6d0e9610bc22074f0d787c28e5 | |
parent | c74e5cd0fc051750c3d88cba0178f62b8ce3b5bb (diff) | |
download | opie-c1e61c513803b05eea14de18604ef05d2f73d5a7.zip opie-c1e61c513803b05eea14de18604ef05d2f73d5a7.tar.gz opie-c1e61c513803b05eea14de18604ef05d2f73d5a7.tar.bz2 |
save pppd arguments
-rw-r--r-- | noncore/settings/networksettings/ppp/TODO | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdargs.cpp | 31 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdargs.h | 2 |
4 files changed, 11 insertions, 28 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO index 9425628..529d236 100644 --- a/noncore/settings/networksettings/ppp/TODO +++ b/noncore/settings/networksettings/ppp/TODO | |||
@@ -1,8 +1,7 @@ | |||
1 | - add possibility to input username and password ;) | 1 | - add possibility to input username and password ;) |
2 | - impl. PPPData::copyaccount & PPPData::deleteAccount | 2 | - impl. PPPData::copyaccount & PPPData::deleteAccount |
3 | - update modem attribute inputs when modem has changed | 3 | - update modem attribute inputs when modem has changed |
4 | - fix layout of edit account | 4 | - fix layout of edit account, i.e. get it shown maximised |
5 | - save pppd arguments in edit account | ||
6 | - popup configure modem with the correct account prselected | 5 | - popup configure modem with the correct account prselected |
7 | not quite shure why it does not work... IMHO it should work | 6 | not quite shure why it does not work... IMHO it should work |
8 | - remove interfaces | 7 | - remove interfaces |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 10bc25c..45d6e4f 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -1,1178 +1,1177 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * | 7 | * |
8 | * based on EzPPP: | 8 | * based on EzPPP: |
9 | * Copyright (C) 1997 Jay Painter | 9 | * Copyright (C) 1997 Jay Painter |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <termios.h> | 27 | #include <termios.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qbuttongroup.h> | 33 | #include <qbuttongroup.h> |
34 | #include <qvgroupbox.h> | 34 | #include <qvgroupbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qdialog.h> | 36 | #include <qdialog.h> |
37 | 37 | ||
38 | #include "edit.h" | 38 | #include "edit.h" |
39 | #include "pppdata.h" | 39 | #include "pppdata.h" |
40 | #include "iplined.h" | 40 | #include "iplined.h" |
41 | #include "auth.h" | 41 | #include "auth.h" |
42 | 42 | ||
43 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 43 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
44 | , const char *name ) | 44 | , const char *name ) |
45 | : QWidget(parent, name), _pppdata(pd) | 45 | : QWidget(parent, name), _pppdata(pd) |
46 | { | 46 | { |
47 | const int GRIDROWS = 6; | 47 | const int GRIDROWS = 6; |
48 | 48 | ||
49 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); | 49 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint()); |
50 | 50 | ||
51 | connect_label = new QLabel(tr("Connection name:"), this); | 51 | connect_label = new QLabel(tr("Connection name:"), this); |
52 | tl->addWidget(connect_label, 0, 0); | 52 | tl->addWidget(connect_label, 0, 0); |
53 | 53 | ||
54 | connectname_l = new QLineEdit(this); | 54 | connectname_l = new QLineEdit(this); |
55 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 55 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
56 | tl->addWidget(connectname_l, 0, 1); | 56 | tl->addWidget(connectname_l, 0, 1); |
57 | QString tmp = tr("Type in a unique name for this connection"); | 57 | QString tmp = tr("Type in a unique name for this connection"); |
58 | 58 | ||
59 | QWhatsThis::add(connect_label,tmp); | 59 | QWhatsThis::add(connect_label,tmp); |
60 | QWhatsThis::add(connectname_l,tmp); | 60 | QWhatsThis::add(connectname_l,tmp); |
61 | 61 | ||
62 | 62 | ||
63 | number_label = new QLabel(tr("Phone number:"), this); | 63 | number_label = new QLabel(tr("Phone number:"), this); |
64 | number_label->setAlignment(AlignTop|AlignLeft); | 64 | number_label->setAlignment(AlignTop|AlignLeft); |
65 | tl->addWidget(number_label, 1, 0); | 65 | tl->addWidget(number_label, 1, 0); |
66 | 66 | ||
67 | QHBoxLayout *lpn = new QHBoxLayout(5); | 67 | QHBoxLayout *lpn = new QHBoxLayout(5); |
68 | tl->addLayout(lpn, 1, 1); | 68 | tl->addLayout(lpn, 1, 1); |
69 | numbers = new QListBox(this); | 69 | numbers = new QListBox(this); |
70 | // numbers->setMinimumSize(120, 70); | 70 | // numbers->setMinimumSize(120, 70); |
71 | lpn->addWidget(numbers); | 71 | lpn->addWidget(numbers); |
72 | QVBoxLayout *lpn1 = new QVBoxLayout; | 72 | QVBoxLayout *lpn1 = new QVBoxLayout; |
73 | lpn->addLayout(lpn1); | 73 | lpn->addLayout(lpn1); |
74 | add = new QPushButton(tr("&Add..."), this); | 74 | add = new QPushButton(tr("&Add..."), this); |
75 | del = new QPushButton(tr("&Remove"), this); | 75 | del = new QPushButton(tr("&Remove"), this); |
76 | 76 | ||
77 | up = new QPushButton(this); | 77 | up = new QPushButton(this); |
78 | //FIXME: QPixmap pm = BarIcon("up"); | 78 | //FIXME: QPixmap pm = BarIcon("up"); |
79 | // up->setPixmap(pm); | 79 | // up->setPixmap(pm); |
80 | down = new QPushButton(this); | 80 | down = new QPushButton(this); |
81 | //FIXME: pm = BarIcon("down"); | 81 | //FIXME: pm = BarIcon("down"); |
82 | // down->setPixmap(pm); | 82 | // down->setPixmap(pm); |
83 | lpn1->addWidget(add); | 83 | lpn1->addWidget(add); |
84 | lpn1->addWidget(del); | 84 | lpn1->addWidget(del); |
85 | lpn1->addStretch(1); | 85 | lpn1->addStretch(1); |
86 | lpn1->addWidget(up); | 86 | lpn1->addWidget(up); |
87 | lpn1->addWidget(down); | 87 | lpn1->addWidget(down); |
88 | connect(add, SIGNAL(clicked()), | 88 | connect(add, SIGNAL(clicked()), |
89 | this, SLOT(addNumber())); | 89 | this, SLOT(addNumber())); |
90 | connect(del, SIGNAL(clicked()), | 90 | connect(del, SIGNAL(clicked()), |
91 | this, SLOT(delNumber())); | 91 | this, SLOT(delNumber())); |
92 | connect(up, SIGNAL(clicked()), | 92 | connect(up, SIGNAL(clicked()), |
93 | this, SLOT(upNumber())); | 93 | this, SLOT(upNumber())); |
94 | connect(down, SIGNAL(clicked()), | 94 | connect(down, SIGNAL(clicked()), |
95 | this, SLOT(downNumber())); | 95 | this, SLOT(downNumber())); |
96 | connect(numbers, SIGNAL(highlighted(int)), | 96 | connect(numbers, SIGNAL(highlighted(int)), |
97 | this, SLOT(selectionChanged(int))); | 97 | this, SLOT(selectionChanged(int))); |
98 | numbersChanged(); | 98 | numbersChanged(); |
99 | 99 | ||
100 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" | 100 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" |
101 | "can supply multiple numbers here, simply\n" | 101 | "can supply multiple numbers here, simply\n" |
102 | "click on \"Add\". You can arrange the\n" | 102 | "click on \"Add\". You can arrange the\n" |
103 | "order the numbers are tried by using the\n" | 103 | "order the numbers are tried by using the\n" |
104 | "arrow buttons.\n\n" | 104 | "arrow buttons.\n\n" |
105 | "When a number is busy or fails, <i>kppp</i> will \n" | 105 | "When a number is busy or fails, <i>kppp</i> will \n" |
106 | "try the next number and so on"); | 106 | "try the next number and so on"); |
107 | 107 | ||
108 | QWhatsThis::add(number_label,tmp); | 108 | QWhatsThis::add(number_label,tmp); |
109 | QWhatsThis::add(numbers,tmp); | 109 | QWhatsThis::add(numbers,tmp); |
110 | 110 | ||
111 | auth_l = new QLabel(tr("Authentication:"), this); | 111 | auth_l = new QLabel(tr("Authentication:"), this); |
112 | tl->addWidget(auth_l, 3, 0); | 112 | tl->addWidget(auth_l, 3, 0); |
113 | 113 | ||
114 | auth = new QComboBox(this); | 114 | auth = new QComboBox(this); |
115 | auth->insertItem(tr("Script-based")); | 115 | auth->insertItem(tr("Script-based")); |
116 | auth->insertItem(tr("PAP")); | 116 | auth->insertItem(tr("PAP")); |
117 | auth->insertItem(tr("Terminal-based")); | 117 | auth->insertItem(tr("Terminal-based")); |
118 | auth->insertItem(tr("CHAP")); | 118 | auth->insertItem(tr("CHAP")); |
119 | auth->insertItem(tr("PAP/CHAP")); | 119 | auth->insertItem(tr("PAP/CHAP")); |
120 | tl->addWidget(auth, 3, 1); | 120 | tl->addWidget(auth, 3, 1); |
121 | tmp = tr("<p>Specifies the method used to identify yourself to\n" | 121 | tmp = tr("<p>Specifies the method used to identify yourself to\n" |
122 | "the PPP server. Most universities still use\n" | 122 | "the PPP server. Most universities still use\n" |
123 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" | 123 | "<b>Terminal</b>- or <b>Script</b>-based authentication,\n" |
124 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" | 124 | "while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n" |
125 | "unsure, contact your ISP.\n" | 125 | "unsure, contact your ISP.\n" |
126 | "\n" | 126 | "\n" |
127 | "If you can choose between PAP and CHAP,\n" | 127 | "If you can choose between PAP and CHAP,\n" |
128 | "choose CHAP, because it's much safer. If you don't know\n" | 128 | "choose CHAP, because it's much safer. If you don't know\n" |
129 | "whether PAP or CHAP is right, choose PAP/CHAP."); | 129 | "whether PAP or CHAP is right, choose PAP/CHAP."); |
130 | 130 | ||
131 | QWhatsThis::add(auth_l,tmp); | 131 | QWhatsThis::add(auth_l,tmp); |
132 | QWhatsThis::add(auth,tmp); | 132 | QWhatsThis::add(auth,tmp); |
133 | 133 | ||
134 | store_password = new QCheckBox(tr("Store password"), this); | 134 | store_password = new QCheckBox(tr("Store password"), this); |
135 | store_password->setChecked(true); | 135 | store_password->setChecked(true); |
136 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); | 136 | tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight); |
137 | QWhatsThis::add(store_password, | 137 | QWhatsThis::add(store_password, |
138 | tr("<p>When this is turned on, your ISP password\n" | 138 | tr("<p>When this is turned on, your ISP password\n" |
139 | "will be saved in <i>kppp</i>'s config file, so\n" | 139 | "will be saved in <i>kppp</i>'s config file, so\n" |
140 | "you do not need to type it in every time.\n" | 140 | "you do not need to type it in every time.\n" |
141 | "\n" | 141 | "\n" |
142 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" | 142 | "<b><font color=\"red\">Warning:</font> your password will be stored as\n" |
143 | "plain text in the config file, which is\n" | 143 | "plain text in the config file, which is\n" |
144 | "readable only to you. Make sure nobody\n" | 144 | "readable only to you. Make sure nobody\n" |
145 | "gains access to this file!")); | 145 | "gains access to this file!")); |
146 | 146 | ||
147 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | 147 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); |
148 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 148 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
149 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 149 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
150 | 150 | ||
151 | // Set defaults if editing an existing connection | 151 | // Set defaults if editing an existing connection |
152 | if(!isnewaccount) { | 152 | if(!isnewaccount) { |
153 | connectname_l->setText(_pppdata->accname()); | 153 | connectname_l->setText(_pppdata->accname()); |
154 | 154 | ||
155 | // insert the phone numbers into the listbox | 155 | // insert the phone numbers into the listbox |
156 | QString n = _pppdata->phonenumber(); | 156 | QString n = _pppdata->phonenumber(); |
157 | QString tmp = ""; | 157 | QString tmp = ""; |
158 | uint idx = 0; | 158 | uint idx = 0; |
159 | while(idx != n.length()) { | 159 | while(idx != n.length()) { |
160 | if(n[idx] == ':') { | 160 | if(n[idx] == ':') { |
161 | if(tmp.length() > 0) | 161 | if(tmp.length() > 0) |
162 | numbers->insertItem(tmp); | 162 | numbers->insertItem(tmp); |
163 | tmp = ""; | 163 | tmp = ""; |
164 | } else | 164 | } else |
165 | tmp += n[idx]; | 165 | tmp += n[idx]; |
166 | idx++; | 166 | idx++; |
167 | } | 167 | } |
168 | if(tmp.length() > 0) | 168 | if(tmp.length() > 0) |
169 | numbers->insertItem(tmp); | 169 | numbers->insertItem(tmp); |
170 | 170 | ||
171 | auth->setCurrentItem(_pppdata->authMethod()); | 171 | auth->setCurrentItem(_pppdata->authMethod()); |
172 | store_password->setChecked(_pppdata->storePassword()); | 172 | store_password->setChecked(_pppdata->storePassword()); |
173 | } else { | 173 | } else { |
174 | // select PAP/CHAP as default | 174 | // select PAP/CHAP as default |
175 | auth->setCurrentItem(AUTH_PAPCHAP); | 175 | auth->setCurrentItem(AUTH_PAPCHAP); |
176 | } | 176 | } |
177 | 177 | ||
178 | numbersChanged(); | 178 | numbersChanged(); |
179 | tl->activate(); | 179 | tl->activate(); |
180 | } | 180 | } |
181 | 181 | ||
182 | |||
183 | bool DialWidget::save() { | 182 | bool DialWidget::save() { |
184 | //first check to make sure that the account name is unique! | 183 | //first check to make sure that the account name is unique! |
185 | if(connectname_l->text().isEmpty() || | 184 | if(connectname_l->text().isEmpty() || |
186 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 185 | !_pppdata->isUniqueAccname(connectname_l->text())) { |
187 | return false; | 186 | return false; |
188 | } else { | 187 | } else { |
189 | _pppdata->setAccname(connectname_l->text()); | 188 | _pppdata->setAccname(connectname_l->text()); |
190 | 189 | ||
191 | QString number = ""; | 190 | QString number = ""; |
192 | for(uint i = 0; i < numbers->count(); i++) { | 191 | for(uint i = 0; i < numbers->count(); i++) { |
193 | if(i != 0) | 192 | if(i != 0) |
194 | number += ":"; | 193 | number += ":"; |
195 | number += numbers->text(i); | 194 | number += numbers->text(i); |
196 | } | 195 | } |
197 | 196 | ||
198 | _pppdata->setPhonenumber(number); | 197 | _pppdata->setPhonenumber(number); |
199 | _pppdata->setAuthMethod(auth->currentItem()); | 198 | _pppdata->setAuthMethod(auth->currentItem()); |
200 | _pppdata->setStorePassword(store_password->isChecked()); | 199 | _pppdata->setStorePassword(store_password->isChecked()); |
201 | return true; | 200 | return true; |
202 | } | 201 | } |
203 | } | 202 | } |
204 | 203 | ||
205 | 204 | ||
206 | void DialWidget::numbersChanged() { | 205 | void DialWidget::numbersChanged() { |
207 | int sel = numbers->currentItem(); | 206 | int sel = numbers->currentItem(); |
208 | 207 | ||
209 | del->setEnabled(sel != -1); | 208 | del->setEnabled(sel != -1); |
210 | up->setEnabled(sel != -1 && sel != 0); | 209 | up->setEnabled(sel != -1 && sel != 0); |
211 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 210 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
212 | } | 211 | } |
213 | 212 | ||
214 | 213 | ||
215 | void DialWidget::selectionChanged(int) { | 214 | void DialWidget::selectionChanged(int) { |
216 | numbersChanged(); | 215 | numbersChanged(); |
217 | } | 216 | } |
218 | 217 | ||
219 | 218 | ||
220 | void DialWidget::addNumber() { | 219 | void DialWidget::addNumber() { |
221 | PhoneNumberDialog dlg(this); | 220 | PhoneNumberDialog dlg(this); |
222 | if(dlg.exec()) { | 221 | if(dlg.exec()) { |
223 | numbers->insertItem(dlg.phoneNumber()); | 222 | numbers->insertItem(dlg.phoneNumber()); |
224 | numbersChanged(); | 223 | numbersChanged(); |
225 | } | 224 | } |
226 | } | 225 | } |
227 | 226 | ||
228 | 227 | ||
229 | void DialWidget::delNumber() { | 228 | void DialWidget::delNumber() { |
230 | if(numbers->currentItem() != -1) { | 229 | if(numbers->currentItem() != -1) { |
231 | numbers->removeItem(numbers->currentItem()); | 230 | numbers->removeItem(numbers->currentItem()); |
232 | numbersChanged(); | 231 | numbersChanged(); |
233 | } | 232 | } |
234 | } | 233 | } |
235 | 234 | ||
236 | 235 | ||
237 | void DialWidget::upNumber() { | 236 | void DialWidget::upNumber() { |
238 | int idx = numbers->currentItem(); | 237 | int idx = numbers->currentItem(); |
239 | if(idx != -1) { | 238 | if(idx != -1) { |
240 | QString item = numbers->text(idx); | 239 | QString item = numbers->text(idx); |
241 | numbers->removeItem(idx); | 240 | numbers->removeItem(idx); |
242 | numbers->insertItem(item, idx-1); | 241 | numbers->insertItem(item, idx-1); |
243 | numbers->setCurrentItem(idx-1); | 242 | numbers->setCurrentItem(idx-1); |
244 | numbersChanged(); | 243 | numbersChanged(); |
245 | } | 244 | } |
246 | } | 245 | } |
247 | 246 | ||
248 | 247 | ||
249 | void DialWidget::downNumber() { | 248 | void DialWidget::downNumber() { |
250 | int idx = numbers->currentItem(); | 249 | int idx = numbers->currentItem(); |
251 | if(idx != -1) { | 250 | if(idx != -1) { |
252 | QString item = numbers->text(idx); | 251 | QString item = numbers->text(idx); |
253 | numbers->removeItem(idx); | 252 | numbers->removeItem(idx); |
254 | numbers->insertItem(item, idx+1); | 253 | numbers->insertItem(item, idx+1); |
255 | numbers->setCurrentItem(idx+1); | 254 | numbers->setCurrentItem(idx+1); |
256 | numbersChanged(); | 255 | numbersChanged(); |
257 | } | 256 | } |
258 | } | 257 | } |
259 | 258 | ||
260 | 259 | ||
261 | void DialWidget::pppdargsbutton() { | 260 | void DialWidget::pppdargsbutton() { |
262 | PPPdArguments pa(_pppdata, this); | 261 | PPPdArguments pa(_pppdata, this); |
263 | pa.exec(); | 262 | pa.exec(); |
264 | } | 263 | } |
265 | 264 | ||
266 | 265 | ||
267 | 266 | ||
268 | ///////////////////////////////////////////////////////////////////////////// | 267 | ///////////////////////////////////////////////////////////////////////////// |
269 | // ExecWidget | 268 | // ExecWidget |
270 | ///////////////////////////////////////////////////////////////////////////// | 269 | ///////////////////////////////////////////////////////////////////////////// |
271 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : | 270 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
272 | QWidget(parent, name), _pppdata(pd) | 271 | QWidget(parent, name), _pppdata(pd) |
273 | { | 272 | { |
274 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 273 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
275 | 274 | ||
276 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); | 275 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); |
277 | 276 | ||
278 | tl->addWidget(l); | 277 | tl->addWidget(l); |
279 | tl->addStretch(1); | 278 | tl->addStretch(1); |
280 | 279 | ||
281 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | 280 | QGridLayout *l1 = new QGridLayout(4, 2, 10); |
282 | tl->addLayout(l1); | 281 | tl->addLayout(l1); |
283 | l1->setColStretch(0, 0); | 282 | l1->setColStretch(0, 0); |
284 | l1->setColStretch(1, 1); | 283 | l1->setColStretch(1, 1); |
285 | 284 | ||
286 | before_connect_l = new QLabel(tr("Before connect:"), this); | 285 | before_connect_l = new QLabel(tr("Before connect:"), this); |
287 | before_connect_l->setAlignment(AlignVCenter); | 286 | before_connect_l->setAlignment(AlignVCenter); |
288 | l1->addWidget(before_connect_l, 0, 0); | 287 | l1->addWidget(before_connect_l, 0, 0); |
289 | before_connect = new QLineEdit(this); | 288 | before_connect = new QLineEdit(this); |
290 | // before_connect->setMaxLength(COMMAND_SIZE); | 289 | // before_connect->setMaxLength(COMMAND_SIZE); |
291 | l1->addWidget(before_connect, 0, 1); | 290 | l1->addWidget(before_connect, 0, 1); |
292 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 291 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
293 | "is established. It is called immediately before\n" | 292 | "is established. It is called immediately before\n" |
294 | "dialing has begun.\n\n" | 293 | "dialing has begun.\n\n" |
295 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | 294 | "This might be useful, e.g. to stop HylaFAX blocking the\n" |
296 | "modem."); | 295 | "modem."); |
297 | 296 | ||
298 | QWhatsThis::add(before_connect_l,tmp); | 297 | QWhatsThis::add(before_connect_l,tmp); |
299 | QWhatsThis::add(before_connect,tmp); | 298 | QWhatsThis::add(before_connect,tmp); |
300 | 299 | ||
301 | command_label = new QLabel(tr("Upon connect:"), this); | 300 | command_label = new QLabel(tr("Upon connect:"), this); |
302 | command_label->setAlignment(AlignVCenter); | 301 | command_label->setAlignment(AlignVCenter); |
303 | l1->addWidget(command_label, 1, 0); | 302 | l1->addWidget(command_label, 1, 0); |
304 | command = new QLineEdit(this); | 303 | command = new QLineEdit(this); |
305 | // command->setMaxLength(COMMAND_SIZE); | 304 | // command->setMaxLength(COMMAND_SIZE); |
306 | l1->addWidget(command, 1, 1); | 305 | l1->addWidget(command, 1, 1); |
307 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 306 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
308 | "is established. When your program is called, all\n" | 307 | "is established. When your program is called, all\n" |
309 | "preparations for an Internet connection are finished.\n" | 308 | "preparations for an Internet connection are finished.\n" |
310 | "\n" | 309 | "\n" |
311 | "Very useful for fetching mail and news"); | 310 | "Very useful for fetching mail and news"); |
312 | 311 | ||
313 | QWhatsThis::add(command_label,tmp); | 312 | QWhatsThis::add(command_label,tmp); |
314 | QWhatsThis::add(command,tmp); | 313 | QWhatsThis::add(command,tmp); |
315 | 314 | ||
316 | predisconnect_label = new QLabel(tr("Before disconnect:"), | 315 | predisconnect_label = new QLabel(tr("Before disconnect:"), |
317 | this); | 316 | this); |
318 | predisconnect_label->setAlignment(AlignVCenter); | 317 | predisconnect_label->setAlignment(AlignVCenter); |
319 | l1->addWidget(predisconnect_label, 2, 0); | 318 | l1->addWidget(predisconnect_label, 2, 0); |
320 | predisconnect = new QLineEdit(this); | 319 | predisconnect = new QLineEdit(this); |
321 | // predisconnect->setMaxLength(COMMAND_SIZE); | 320 | // predisconnect->setMaxLength(COMMAND_SIZE); |
322 | l1->addWidget(predisconnect, 2, 1); | 321 | l1->addWidget(predisconnect, 2, 1); |
323 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 322 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
324 | "is closed. The connection will stay open until\n" | 323 | "is closed. The connection will stay open until\n" |
325 | "the program exits."); | 324 | "the program exits."); |
326 | 325 | ||
327 | QWhatsThis::add(predisconnect_label,tmp); | 326 | QWhatsThis::add(predisconnect_label,tmp); |
328 | QWhatsThis::add(predisconnect,tmp); | 327 | QWhatsThis::add(predisconnect,tmp); |
329 | 328 | ||
330 | discommand_label = new QLabel(tr("Upon disconnect:"), | 329 | discommand_label = new QLabel(tr("Upon disconnect:"), |
331 | this); | 330 | this); |
332 | discommand_label->setAlignment(AlignVCenter); | 331 | discommand_label->setAlignment(AlignVCenter); |
333 | l1->addWidget(discommand_label, 3, 0); | 332 | l1->addWidget(discommand_label, 3, 0); |
334 | 333 | ||
335 | discommand = new QLineEdit(this); | 334 | discommand = new QLineEdit(this); |
336 | // discommand->setMaxLength(COMMAND_SIZE); | 335 | // discommand->setMaxLength(COMMAND_SIZE); |
337 | l1->addWidget(discommand, 3, 1); | 336 | l1->addWidget(discommand, 3, 1); |
338 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 337 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
339 | "has been closed."); | 338 | "has been closed."); |
340 | 339 | ||
341 | QWhatsThis::add(discommand_label,tmp); | 340 | QWhatsThis::add(discommand_label,tmp); |
342 | QWhatsThis::add(discommand,tmp); | 341 | QWhatsThis::add(discommand,tmp); |
343 | 342 | ||
344 | // extra space between entries | 343 | // extra space between entries |
345 | l1->addRowSpacing(1, 5); | 344 | l1->addRowSpacing(1, 5); |
346 | l1->addRowSpacing(3, 5); | 345 | l1->addRowSpacing(3, 5); |
347 | 346 | ||
348 | tl->addStretch(1); | 347 | tl->addStretch(1); |
349 | tl->activate(); | 348 | tl->activate(); |
350 | 349 | ||
351 | // Set defaults if editing an existing connection | 350 | // Set defaults if editing an existing connection |
352 | if(!isnewaccount) { | 351 | if(!isnewaccount) { |
353 | before_connect->setText(_pppdata->command_before_connect()); | 352 | before_connect->setText(_pppdata->command_before_connect()); |
354 | command->setText(_pppdata->command_on_connect()); | 353 | command->setText(_pppdata->command_on_connect()); |
355 | discommand->setText(_pppdata->command_on_disconnect()); | 354 | discommand->setText(_pppdata->command_on_disconnect()); |
356 | predisconnect->setText(_pppdata->command_before_disconnect()); | 355 | predisconnect->setText(_pppdata->command_before_disconnect()); |
357 | } | 356 | } |
358 | } | 357 | } |
359 | 358 | ||
360 | 359 | ||
361 | bool ExecWidget::save() { | 360 | bool ExecWidget::save() { |
362 | _pppdata->setCommand_before_connect(before_connect->text()); | 361 | _pppdata->setCommand_before_connect(before_connect->text()); |
363 | _pppdata->setCommand_on_connect(command->text()); | 362 | _pppdata->setCommand_on_connect(command->text()); |
364 | _pppdata->setCommand_before_disconnect(predisconnect->text()); | 363 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
365 | _pppdata->setCommand_on_disconnect(discommand->text()); | 364 | _pppdata->setCommand_on_disconnect(discommand->text()); |
366 | return true; | 365 | return true; |
367 | } | 366 | } |
368 | 367 | ||
369 | 368 | ||
370 | 369 | ||
371 | ///////////////////////////////////////////////////////////////////////////// | 370 | ///////////////////////////////////////////////////////////////////////////// |
372 | // | 371 | // |
373 | // IPWidget | 372 | // IPWidget |
374 | // | 373 | // |
375 | ///////////////////////////////////////////////////////////////////////////// | 374 | ///////////////////////////////////////////////////////////////////////////// |
376 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 375 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
377 | : QWidget(parent, name), _pppdata(pd) | 376 | : QWidget(parent, name), _pppdata(pd) |
378 | { | 377 | { |
379 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 378 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
380 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 379 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
381 | 380 | ||
382 | box = new QVGroupBox(tr("Configuration"), this); | 381 | box = new QVGroupBox(tr("Configuration"), this); |
383 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 382 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
384 | 383 | ||
385 | rb = new QButtonGroup(this); | 384 | rb = new QButtonGroup(this); |
386 | rb->hide(); | 385 | rb->hide(); |
387 | connect(rb, SIGNAL(clicked(int)), | 386 | connect(rb, SIGNAL(clicked(int)), |
388 | SLOT(hitIPSelect(int))); | 387 | SLOT(hitIPSelect(int))); |
389 | 388 | ||
390 | dynamicadd_rb = new QRadioButton(box); | 389 | dynamicadd_rb = new QRadioButton(box); |
391 | dynamicadd_rb->setText(tr("Dynamic IP address")); | 390 | dynamicadd_rb->setText(tr("Dynamic IP address")); |
392 | QWhatsThis::add(dynamicadd_rb, | 391 | QWhatsThis::add(dynamicadd_rb, |
393 | tr("Select this option when your computer gets an\n" | 392 | tr("Select this option when your computer gets an\n" |
394 | "internet address (IP) every time a\n" | 393 | "internet address (IP) every time a\n" |
395 | "connection is made.\n" | 394 | "connection is made.\n" |
396 | "\n" | 395 | "\n" |
397 | "Almost every Internet Service Provider uses\n" | 396 | "Almost every Internet Service Provider uses\n" |
398 | "this method, so this should be turned on.")); | 397 | "this method, so this should be turned on.")); |
399 | 398 | ||
400 | staticadd_rb = new QRadioButton(box); | 399 | staticadd_rb = new QRadioButton(box); |
401 | staticadd_rb->setText(tr("Static IP address")); | 400 | staticadd_rb->setText(tr("Static IP address")); |
402 | rb->insert(dynamicadd_rb, 0); | 401 | rb->insert(dynamicadd_rb, 0); |
403 | rb->insert(staticadd_rb, 1); | 402 | rb->insert(staticadd_rb, 1); |
404 | QWhatsThis::add(staticadd_rb, | 403 | QWhatsThis::add(staticadd_rb, |
405 | tr("Select this option when your computer has a\n" | 404 | tr("Select this option when your computer has a\n" |
406 | "fixed internet address (IP). Most computers\n" | 405 | "fixed internet address (IP). Most computers\n" |
407 | "don't have this, so you should probably select\n" | 406 | "don't have this, so you should probably select\n" |
408 | "dynamic IP addressing unless you know what you\n" | 407 | "dynamic IP addressing unless you know what you\n" |
409 | "are doing.")); | 408 | "are doing.")); |
410 | 409 | ||
411 | QWidget *ipWidget = new QWidget(box); | 410 | QWidget *ipWidget = new QWidget(box); |
412 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | 411 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); |
413 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | 412 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); |
414 | 413 | ||
415 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); | 414 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); |
416 | QString tmp = tr("If your computer has a permanent internet\n" | 415 | QString tmp = tr("If your computer has a permanent internet\n" |
417 | "address, you must supply your IP address here."); | 416 | "address, you must supply your IP address here."); |
418 | ipLayout->addWidget(ipaddress_label, 0, 0); | 417 | ipLayout->addWidget(ipaddress_label, 0, 0); |
419 | 418 | ||
420 | ipaddress_l = new IPLineEdit(ipWidget); | 419 | ipaddress_l = new IPLineEdit(ipWidget); |
421 | ipLayout->addWidget(ipaddress_l, 0, 1); | 420 | ipLayout->addWidget(ipaddress_l, 0, 1); |
422 | 421 | ||
423 | QWhatsThis::add(ipaddress_label,tmp); | 422 | QWhatsThis::add(ipaddress_label,tmp); |
424 | QWhatsThis::add(ipaddress_l,tmp); | 423 | QWhatsThis::add(ipaddress_l,tmp); |
425 | 424 | ||
426 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); | 425 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); |
427 | tmp = tr("<p>If your computer has a static Internet address,\n" | 426 | tmp = tr("<p>If your computer has a static Internet address,\n" |
428 | "you must supply a network mask here. In almost\n" | 427 | "you must supply a network mask here. In almost\n" |
429 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | 428 | "all cases this netmask will be <b>255.255.255.0</b>,\n" |
430 | "but your mileage may vary.\n" | 429 | "but your mileage may vary.\n" |
431 | "\n" | 430 | "\n" |
432 | "If unsure, contact your Internet Service Provider"); | 431 | "If unsure, contact your Internet Service Provider"); |
433 | ipLayout->addWidget(sub_label, 1, 0); | 432 | ipLayout->addWidget(sub_label, 1, 0); |
434 | 433 | ||
435 | subnetmask_l = new IPLineEdit(ipWidget); | 434 | subnetmask_l = new IPLineEdit(ipWidget); |
436 | ipLayout->addWidget(subnetmask_l, 1, 1); | 435 | ipLayout->addWidget(subnetmask_l, 1, 1); |
437 | 436 | ||
438 | QWhatsThis::add(sub_label,tmp); | 437 | QWhatsThis::add(sub_label,tmp); |
439 | QWhatsThis::add(subnetmask_l,tmp); | 438 | QWhatsThis::add(subnetmask_l,tmp); |
440 | 439 | ||
441 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); | 440 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); |
442 | autoname->setChecked(_pppdata->autoname()); | 441 | autoname->setChecked(_pppdata->autoname()); |
443 | connect(autoname,SIGNAL(toggled(bool)), | 442 | connect(autoname,SIGNAL(toggled(bool)), |
444 | this,SLOT(autoname_t(bool))); | 443 | this,SLOT(autoname_t(bool))); |
445 | 444 | ||
446 | QWhatsThis::add(autoname, | 445 | QWhatsThis::add(autoname, |
447 | tr("<p>Whenever you connect, this reconfigures\n" | 446 | tr("<p>Whenever you connect, this reconfigures\n" |
448 | "your hostname to match the IP address you\n" | 447 | "your hostname to match the IP address you\n" |
449 | "got from the PPP server. This may be useful\n" | 448 | "got from the PPP server. This may be useful\n" |
450 | "if you need to use a protocol which depends\n" | 449 | "if you need to use a protocol which depends\n" |
451 | "on this information, but it can also cause several\n" | 450 | "on this information, but it can also cause several\n" |
452 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 451 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
453 | "\n" | 452 | "\n" |
454 | "Don't enable this unless you really need it.")); | 453 | "Don't enable this unless you really need it.")); |
455 | 454 | ||
456 | topLayout->addWidget(box); | 455 | topLayout->addWidget(box); |
457 | topLayout->addWidget(autoname); | 456 | topLayout->addWidget(autoname); |
458 | topLayout->addStretch(); | 457 | topLayout->addStretch(); |
459 | 458 | ||
460 | //load info from gpppdata | 459 | //load info from gpppdata |
461 | if(!isnewaccount) { | 460 | if(!isnewaccount) { |
462 | if(_pppdata->ipaddr() == "0.0.0.0" && | 461 | if(_pppdata->ipaddr() == "0.0.0.0" && |
463 | _pppdata->subnetmask() == "0.0.0.0") { | 462 | _pppdata->subnetmask() == "0.0.0.0") { |
464 | dynamicadd_rb->setChecked(true); | 463 | dynamicadd_rb->setChecked(true); |
465 | hitIPSelect(0); | 464 | hitIPSelect(0); |
466 | autoname->setChecked(_pppdata->autoname()); | 465 | autoname->setChecked(_pppdata->autoname()); |
467 | } | 466 | } |
468 | else { | 467 | else { |
469 | ipaddress_l->setText(_pppdata->ipaddr()); | 468 | ipaddress_l->setText(_pppdata->ipaddr()); |
470 | subnetmask_l->setText(_pppdata->subnetmask()); | 469 | subnetmask_l->setText(_pppdata->subnetmask()); |
471 | staticadd_rb->setChecked(true); | 470 | staticadd_rb->setChecked(true); |
472 | autoname->setChecked(false); | 471 | autoname->setChecked(false); |
473 | } | 472 | } |
474 | } | 473 | } |
475 | else { | 474 | else { |
476 | dynamicadd_rb->setChecked(true); | 475 | dynamicadd_rb->setChecked(true); |
477 | hitIPSelect(0); | 476 | hitIPSelect(0); |
478 | } | 477 | } |
479 | 478 | ||
480 | } | 479 | } |
481 | 480 | ||
482 | void IPWidget::autoname_t(bool on) { | 481 | void IPWidget::autoname_t(bool on) { |
483 | static bool was_warned = false; | 482 | static bool was_warned = false; |
484 | 483 | ||
485 | // big-fat warning when selecting the auto configure hostname option | 484 | // big-fat warning when selecting the auto configure hostname option |
486 | if(on && !was_warned) { | 485 | if(on && !was_warned) { |
487 | QMessageBox::information(this, | 486 | QMessageBox::information(this, |
488 | tr("Selecting this option might cause some weird " | 487 | tr("Selecting this option might cause some weird " |
489 | "problems with the X-server and applications " | 488 | "problems with the X-server and applications " |
490 | "while kppp is connected. Don't use it until " | 489 | "while kppp is connected. Don't use it until " |
491 | "you know what you are doing!\n" | 490 | "you know what you are doing!\n" |
492 | "For more information take a look at the " | 491 | "For more information take a look at the " |
493 | "handbook (or help) in the section \"Frequently " | 492 | "handbook (or help) in the section \"Frequently " |
494 | "asked questions\"."), | 493 | "asked questions\"."), |
495 | tr("Warning")); | 494 | tr("Warning")); |
496 | was_warned = true; | 495 | was_warned = true; |
497 | } | 496 | } |
498 | } | 497 | } |
499 | 498 | ||
500 | 499 | ||
501 | void IPWidget::save() { | 500 | void IPWidget::save() { |
502 | if(dynamicadd_rb->isChecked()) { | 501 | if(dynamicadd_rb->isChecked()) { |
503 | _pppdata->setIpaddr("0.0.0.0"); | 502 | _pppdata->setIpaddr("0.0.0.0"); |
504 | _pppdata->setSubnetmask("0.0.0.0"); | 503 | _pppdata->setSubnetmask("0.0.0.0"); |
505 | } else { | 504 | } else { |
506 | _pppdata->setIpaddr(ipaddress_l->text()); | 505 | _pppdata->setIpaddr(ipaddress_l->text()); |
507 | _pppdata->setSubnetmask(subnetmask_l->text()); | 506 | _pppdata->setSubnetmask(subnetmask_l->text()); |
508 | } | 507 | } |
509 | _pppdata->setAutoname(autoname->isChecked()); | 508 | _pppdata->setAutoname(autoname->isChecked()); |
510 | } | 509 | } |
511 | 510 | ||
512 | 511 | ||
513 | void IPWidget::hitIPSelect( int i ) { | 512 | void IPWidget::hitIPSelect( int i ) { |
514 | if(i == 0) { | 513 | if(i == 0) { |
515 | ipaddress_label->setEnabled(false); | 514 | ipaddress_label->setEnabled(false); |
516 | sub_label->setEnabled(false); | 515 | sub_label->setEnabled(false); |
517 | ipaddress_l->setEnabled(false); | 516 | ipaddress_l->setEnabled(false); |
518 | subnetmask_l->setEnabled(false); | 517 | subnetmask_l->setEnabled(false); |
519 | } | 518 | } |
520 | else { | 519 | else { |
521 | ipaddress_label->setEnabled(true); | 520 | ipaddress_label->setEnabled(true); |
522 | sub_label->setEnabled(true); | 521 | sub_label->setEnabled(true); |
523 | ipaddress_l->setEnabled(true); | 522 | ipaddress_l->setEnabled(true); |
524 | subnetmask_l->setEnabled(true); | 523 | subnetmask_l->setEnabled(true); |
525 | } | 524 | } |
526 | } | 525 | } |
527 | 526 | ||
528 | 527 | ||
529 | 528 | ||
530 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 529 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
531 | : QWidget(parent, name), _pppdata(pd) | 530 | : QWidget(parent, name), _pppdata(pd) |
532 | { | 531 | { |
533 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); | 532 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); |
534 | 533 | ||
535 | dnsdomain_label = new QLabel(tr("Domain name:"), this); | 534 | dnsdomain_label = new QLabel(tr("Domain name:"), this); |
536 | tl->addWidget(dnsdomain_label, 0, 0); | 535 | tl->addWidget(dnsdomain_label, 0, 0); |
537 | 536 | ||
538 | dnsdomain = new QLineEdit(this); | 537 | dnsdomain = new QLineEdit(this); |
539 | 538 | ||
540 | tl->addWidget(dnsdomain, 0, 1); | 539 | tl->addWidget(dnsdomain, 0, 1); |
541 | QString tmp = tr("If you enter a domain name here, this domain\n" | 540 | QString tmp = tr("If you enter a domain name here, this domain\n" |
542 | "name is used for your computer while you are\n" | 541 | "name is used for your computer while you are\n" |
543 | "connected. When the connection is closed, the\n" | 542 | "connected. When the connection is closed, the\n" |
544 | "original domain name of your computer is\n" | 543 | "original domain name of your computer is\n" |
545 | "restored.\n" | 544 | "restored.\n" |
546 | "\n" | 545 | "\n" |
547 | "If you leave this field blank, no changes are\n" | 546 | "If you leave this field blank, no changes are\n" |
548 | "made to the domain name."); | 547 | "made to the domain name."); |
549 | 548 | ||
550 | QWhatsThis::add(dnsdomain_label,tmp); | 549 | QWhatsThis::add(dnsdomain_label,tmp); |
551 | QWhatsThis::add(dnsdomain,tmp); | 550 | QWhatsThis::add(dnsdomain,tmp); |
552 | 551 | ||
553 | conf_label = new QLabel(tr("Configuration:"), this); | 552 | conf_label = new QLabel(tr("Configuration:"), this); |
554 | tl->addWidget(conf_label, 1, 0); | 553 | tl->addWidget(conf_label, 1, 0); |
555 | 554 | ||
556 | bg = new QButtonGroup("Group", this); | 555 | bg = new QButtonGroup("Group", this); |
557 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 556 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
558 | bg->hide(); | 557 | bg->hide(); |
559 | 558 | ||
560 | autodns = new QRadioButton(tr("Automatic"), this); | 559 | autodns = new QRadioButton(tr("Automatic"), this); |
561 | bg->insert(autodns, 0); | 560 | bg->insert(autodns, 0); |
562 | tl->addWidget(autodns, 1, 1); | 561 | tl->addWidget(autodns, 1, 1); |
563 | if(!_pppdata->pppdVersionMin(2, 3, 7)) | 562 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
564 | autodns->setEnabled(false); | 563 | autodns->setEnabled(false); |
565 | 564 | ||
566 | mandns = new QRadioButton(tr("Manual"), this); | 565 | mandns = new QRadioButton(tr("Manual"), this); |
567 | bg->insert(mandns, 1); | 566 | bg->insert(mandns, 1); |
568 | tl->addWidget(mandns, 2, 1); | 567 | tl->addWidget(mandns, 2, 1); |
569 | 568 | ||
570 | dns_label = new QLabel(tr("DNS IP address:"), this); | 569 | dns_label = new QLabel(tr("DNS IP address:"), this); |
571 | tl->addWidget(dns_label, 3, 0); | 570 | tl->addWidget(dns_label, 3, 0); |
572 | 571 | ||
573 | QHBoxLayout *l2 = new QHBoxLayout; | 572 | QHBoxLayout *l2 = new QHBoxLayout; |
574 | tl->addLayout(l2, 3, 1); | 573 | tl->addLayout(l2, 3, 1); |
575 | dnsipaddr = new IPLineEdit(this); | 574 | dnsipaddr = new IPLineEdit(this); |
576 | connect(dnsipaddr, SIGNAL(returnPressed()), | 575 | connect(dnsipaddr, SIGNAL(returnPressed()), |
577 | SLOT(adddns())); | 576 | SLOT(adddns())); |
578 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | 577 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), |
579 | SLOT(DNS_Edit_Changed(const QString &))); | 578 | SLOT(DNS_Edit_Changed(const QString &))); |
580 | l2->addWidget(dnsipaddr, 1); | 579 | l2->addWidget(dnsipaddr, 1); |
581 | l2->addStretch(1); | 580 | l2->addStretch(1); |
582 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" | 581 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" |
583 | "used while you are connected. When the\n" | 582 | "used while you are connected. When the\n" |
584 | "connection is closed, this DNS entry will be\n" | 583 | "connection is closed, this DNS entry will be\n" |
585 | "removed again.\n" | 584 | "removed again.\n" |
586 | "\n" | 585 | "\n" |
587 | "To add a DNS server, type in the IP address of\n" | 586 | "To add a DNS server, type in the IP address of\n" |
588 | "the DNS server here and click on <b>Add</b>"); | 587 | "the DNS server here and click on <b>Add</b>"); |
589 | 588 | ||
590 | QWhatsThis::add(dns_label, tmp); | 589 | QWhatsThis::add(dns_label, tmp); |
591 | QWhatsThis::add(dnsipaddr, tmp); | 590 | QWhatsThis::add(dnsipaddr, tmp); |
592 | 591 | ||
593 | QHBoxLayout *l1 = new QHBoxLayout; | 592 | QHBoxLayout *l1 = new QHBoxLayout; |
594 | tl->addLayout(l1, 4, 1); | 593 | tl->addLayout(l1, 4, 1); |
595 | add = new QPushButton(tr("Add"), this); | 594 | add = new QPushButton(tr("Add"), this); |
596 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 595 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
597 | l1->addWidget(add); | 596 | l1->addWidget(add); |
598 | // l1->addStretch(1); | 597 | // l1->addStretch(1); |
599 | QWhatsThis::add(add, | 598 | QWhatsThis::add(add, |
600 | tr("Click this button to add the DNS server\n" | 599 | tr("Click this button to add the DNS server\n" |
601 | "specified in the field above. The entry\n" | 600 | "specified in the field above. The entry\n" |
602 | "will then be added to the list below")); | 601 | "will then be added to the list below")); |
603 | 602 | ||
604 | remove = new QPushButton(tr("Remove"), this); | 603 | remove = new QPushButton(tr("Remove"), this); |
605 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 604 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
606 | l1->addWidget(remove); | 605 | l1->addWidget(remove); |
607 | QWhatsThis::add(remove, | 606 | QWhatsThis::add(remove, |
608 | tr("Click this button to remove the selected DNS\n" | 607 | tr("Click this button to remove the selected DNS\n" |
609 | "server entry from the list below")); | 608 | "server entry from the list below")); |
610 | 609 | ||
611 | servers_label = new QLabel(tr("DNS address list:"), this); | 610 | servers_label = new QLabel(tr("DNS address list:"), this); |
612 | servers_label->setAlignment(AlignTop|AlignLeft); | 611 | servers_label->setAlignment(AlignTop|AlignLeft); |
613 | tl->addWidget(servers_label, 5, 0); | 612 | tl->addWidget(servers_label, 5, 0); |
614 | 613 | ||
615 | dnsservers = new QListBox(this); | 614 | dnsservers = new QListBox(this); |
616 | dnsservers->setMinimumSize(150, 80); | 615 | dnsservers->setMinimumSize(150, 80); |
617 | connect(dnsservers, SIGNAL(highlighted(int)), | 616 | connect(dnsservers, SIGNAL(highlighted(int)), |
618 | SLOT(DNS_Entry_Selected(int))); | 617 | SLOT(DNS_Entry_Selected(int))); |
619 | tl->addWidget(dnsservers, 5, 1); | 618 | tl->addWidget(dnsservers, 5, 1); |
620 | tmp = tr("<p>This shows all defined DNS servers to use\n" | 619 | tmp = tr("<p>This shows all defined DNS servers to use\n" |
621 | "while you are connected. Use the <b>Add</b> and\n" | 620 | "while you are connected. Use the <b>Add</b> and\n" |
622 | "<b>Remove</b> buttons to modify the list"); | 621 | "<b>Remove</b> buttons to modify the list"); |
623 | 622 | ||
624 | QWhatsThis::add(servers_label,tmp); | 623 | QWhatsThis::add(servers_label,tmp); |
625 | QWhatsThis::add(dnsservers,tmp); | 624 | QWhatsThis::add(dnsservers,tmp); |
626 | 625 | ||
627 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); | 626 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); |
628 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); | 627 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); |
629 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); | 628 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
630 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 629 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
631 | QWhatsThis::add(exdnsdisabled_toggle, | 630 | QWhatsThis::add(exdnsdisabled_toggle, |
632 | tr("<p>When this option is selected, all DNS\n" | 631 | tr("<p>When this option is selected, all DNS\n" |
633 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 632 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
634 | "temporary disabled while the dialup connection\n" | 633 | "temporary disabled while the dialup connection\n" |
635 | "is established. After the connection is\n" | 634 | "is established. After the connection is\n" |
636 | "closed, the servers will be re-enabled\n" | 635 | "closed, the servers will be re-enabled\n" |
637 | "\n" | 636 | "\n" |
638 | "Typically, there is no reason to use this\n" | 637 | "Typically, there is no reason to use this\n" |
639 | "option, but it may become useful under \n" | 638 | "option, but it may become useful under \n" |
640 | "some circumstances.")); | 639 | "some circumstances.")); |
641 | 640 | ||
642 | 641 | ||
643 | // restore data if editing | 642 | // restore data if editing |
644 | if(!isnewaccount) { | 643 | if(!isnewaccount) { |
645 | dnsservers->insertStringList(_pppdata->dns()); | 644 | dnsservers->insertStringList(_pppdata->dns()); |
646 | dnsdomain->setText(_pppdata->domain()); | 645 | dnsdomain->setText(_pppdata->domain()); |
647 | } | 646 | } |
648 | 647 | ||
649 | int mode = _pppdata->autoDNS() ? 0 : 1; | 648 | int mode = _pppdata->autoDNS() ? 0 : 1; |
650 | bg->setButton(mode); | 649 | bg->setButton(mode); |
651 | DNS_Mode_Selected(mode); | 650 | DNS_Mode_Selected(mode); |
652 | 651 | ||
653 | tl->activate(); | 652 | tl->activate(); |
654 | } | 653 | } |
655 | 654 | ||
656 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 655 | void DNSWidget::DNS_Edit_Changed(const QString &text) { |
657 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
658 | add->setEnabled(text.find(r) != -1); | 657 | add->setEnabled(text.find(r) != -1); |
659 | } | 658 | } |
660 | 659 | ||
661 | void DNSWidget::DNS_Entry_Selected(int) { | 660 | void DNSWidget::DNS_Entry_Selected(int) { |
662 | remove->setEnabled(true); | 661 | remove->setEnabled(true); |
663 | } | 662 | } |
664 | 663 | ||
665 | void DNSWidget::DNS_Mode_Selected(int mode) { | 664 | void DNSWidget::DNS_Mode_Selected(int mode) { |
666 | bool on = (mode == 1); | 665 | bool on = (mode == 1); |
667 | dns_label->setEnabled(on); | 666 | dns_label->setEnabled(on); |
668 | servers_label->setEnabled(on); | 667 | servers_label->setEnabled(on); |
669 | dnsipaddr->setText(""); | 668 | dnsipaddr->setText(""); |
670 | dnsipaddr->setEnabled(on); | 669 | dnsipaddr->setEnabled(on); |
671 | add->setEnabled(false); | 670 | add->setEnabled(false); |
672 | remove->setEnabled(dnsservers->count()>0 && on); | 671 | remove->setEnabled(dnsservers->count()>0 && on); |
673 | dnsservers->clearSelection(); | 672 | dnsservers->clearSelection(); |
674 | dnsservers->setEnabled(on); | 673 | dnsservers->setEnabled(on); |
675 | dnsservers->triggerUpdate(false); | 674 | dnsservers->triggerUpdate(false); |
676 | } | 675 | } |
677 | 676 | ||
678 | void DNSWidget::save() { | 677 | void DNSWidget::save() { |
679 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 678 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
680 | QStringList serverlist; | 679 | QStringList serverlist; |
681 | for(uint i=0; i < dnsservers->count(); i++) | 680 | for(uint i=0; i < dnsservers->count(); i++) |
682 | serverlist.append(dnsservers->text(i)); | 681 | serverlist.append(dnsservers->text(i)); |
683 | _pppdata->setDns(serverlist); | 682 | _pppdata->setDns(serverlist); |
684 | 683 | ||
685 | // strip leading dot | 684 | // strip leading dot |
686 | QString s(dnsdomain->text()); | 685 | QString s(dnsdomain->text()); |
687 | if(s.left(1) == ".") | 686 | if(s.left(1) == ".") |
688 | _pppdata->setDomain(s.mid(1)); | 687 | _pppdata->setDomain(s.mid(1)); |
689 | else | 688 | else |
690 | _pppdata->setDomain(dnsdomain->text()); | 689 | _pppdata->setDomain(dnsdomain->text()); |
691 | 690 | ||
692 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 691 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
693 | } | 692 | } |
694 | 693 | ||
695 | 694 | ||
696 | void DNSWidget::adddns() { | 695 | void DNSWidget::adddns() { |
697 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 696 | if(dnsservers->count() < MAX_DNS_ENTRIES) { |
698 | dnsservers->insertItem(dnsipaddr->text()); | 697 | dnsservers->insertItem(dnsipaddr->text()); |
699 | dnsipaddr->setText(""); | 698 | dnsipaddr->setText(""); |
700 | } | 699 | } |
701 | } | 700 | } |
702 | 701 | ||
703 | 702 | ||
704 | void DNSWidget::removedns() { | 703 | void DNSWidget::removedns() { |
705 | int i; | 704 | int i; |
706 | i = dnsservers->currentItem(); | 705 | i = dnsservers->currentItem(); |
707 | if(i != -1) | 706 | if(i != -1) |
708 | dnsservers->removeItem(i); | 707 | dnsservers->removeItem(i); |
709 | remove->setEnabled(dnsservers->count()>0); | 708 | remove->setEnabled(dnsservers->count()>0); |
710 | } | 709 | } |
711 | 710 | ||
712 | 711 | ||
713 | // | 712 | // |
714 | // GatewayWidget | 713 | // GatewayWidget |
715 | // | 714 | // |
716 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 715 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
717 | : QWidget(parent, name), _pppdata(pd) | 716 | : QWidget(parent, name), _pppdata(pd) |
718 | { | 717 | { |
719 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 718 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
720 | topLayout->setSpacing( 2 ); | 719 | topLayout->setSpacing( 2 ); |
721 | topLayout->setMargin( 0 ); | 720 | topLayout->setMargin( 0 ); |
722 | 721 | ||
723 | box = new QVGroupBox(tr("Configuration"), this); | 722 | box = new QVGroupBox(tr("Configuration"), this); |
724 | 723 | ||
725 | rb = new QButtonGroup(this); | 724 | rb = new QButtonGroup(this); |
726 | rb->hide(); | 725 | rb->hide(); |
727 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 726 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
728 | 727 | ||
729 | defaultgateway = new QRadioButton(box); | 728 | defaultgateway = new QRadioButton(box); |
730 | defaultgateway->setText(tr("Default gateway")); | 729 | defaultgateway->setText(tr("Default gateway")); |
731 | rb->insert(defaultgateway, 0); | 730 | rb->insert(defaultgateway, 0); |
732 | QWhatsThis::add(defaultgateway, | 731 | QWhatsThis::add(defaultgateway, |
733 | tr("This makes the PPP peer computer (the computer\n" | 732 | tr("This makes the PPP peer computer (the computer\n" |
734 | "you are connected to with your modem) to act as\n" | 733 | "you are connected to with your modem) to act as\n" |
735 | "a gateway. Your computer will send all packets not\n" | 734 | "a gateway. Your computer will send all packets not\n" |
736 | "going to a computer inside your local net to this\n" | 735 | "going to a computer inside your local net to this\n" |
737 | "computer, which will route these packets.\n" | 736 | "computer, which will route these packets.\n" |
738 | "\n" | 737 | "\n" |
739 | "This is the default for most ISPs, so you should\n" | 738 | "This is the default for most ISPs, so you should\n" |
740 | "probably leave this option on.")); | 739 | "probably leave this option on.")); |
741 | 740 | ||
742 | 741 | ||
743 | staticgateway = new QRadioButton(box); | 742 | staticgateway = new QRadioButton(box); |
744 | staticgateway->setText(tr("Static gateway")); | 743 | staticgateway->setText(tr("Static gateway")); |
745 | rb->insert(staticgateway, 1); | 744 | rb->insert(staticgateway, 1); |
746 | QWhatsThis::add(staticgateway, | 745 | QWhatsThis::add(staticgateway, |
747 | tr("<p>Allows you to specify which computer you want\n" | 746 | tr("<p>Allows you to specify which computer you want\n" |
748 | "to use as gateway (see <i>Default Gateway</i> above)")); | 747 | "to use as gateway (see <i>Default Gateway</i> above)")); |
749 | 748 | ||
750 | QHBox *gateBox = new QHBox(box); | 749 | QHBox *gateBox = new QHBox(box); |
751 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); | 750 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); |
752 | gatewayaddr = new IPLineEdit(gateBox); | 751 | gatewayaddr = new IPLineEdit(gateBox); |
753 | 752 | ||
754 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), | 753 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), |
755 | this); | 754 | this); |
756 | QWhatsThis::add(defaultroute, | 755 | QWhatsThis::add(defaultroute, |
757 | tr("If this option is enabled, all packets not\n" | 756 | tr("If this option is enabled, all packets not\n" |
758 | "going to the local net are routed through\n" | 757 | "going to the local net are routed through\n" |
759 | "the PPP connection.\n" | 758 | "the PPP connection.\n" |
760 | "\n" | 759 | "\n" |
761 | "Normally, you should turn this on")); | 760 | "Normally, you should turn this on")); |
762 | 761 | ||
763 | topLayout->addWidget(box); | 762 | topLayout->addWidget(box); |
764 | topLayout->addWidget(defaultroute); | 763 | topLayout->addWidget(defaultroute); |
765 | topLayout->addStretch(); | 764 | topLayout->addStretch(); |
766 | 765 | ||
767 | //load info from gpppdata | 766 | //load info from gpppdata |
768 | if(!isnewaccount) { | 767 | if(!isnewaccount) { |
769 | if(_pppdata->gateway() == "0.0.0.0") { | 768 | if(_pppdata->gateway() == "0.0.0.0") { |
770 | defaultgateway->setChecked(true); | 769 | defaultgateway->setChecked(true); |
771 | hitGatewaySelect(0); | 770 | hitGatewaySelect(0); |
772 | } | 771 | } |
773 | else { | 772 | else { |
774 | gatewayaddr->setText(_pppdata->gateway()); | 773 | gatewayaddr->setText(_pppdata->gateway()); |
775 | staticgateway->setChecked(true); | 774 | staticgateway->setChecked(true); |
776 | } | 775 | } |
777 | defaultroute->setChecked(_pppdata->defaultroute()); | 776 | defaultroute->setChecked(_pppdata->defaultroute()); |
778 | } | 777 | } |
779 | else { | 778 | else { |
780 | defaultgateway->setChecked(true); | 779 | defaultgateway->setChecked(true); |
781 | hitGatewaySelect(0); | 780 | hitGatewaySelect(0); |
782 | defaultroute->setChecked(true); | 781 | defaultroute->setChecked(true); |
783 | } | 782 | } |
784 | } | 783 | } |
785 | 784 | ||
786 | void GatewayWidget::save() { | 785 | void GatewayWidget::save() { |
787 | _pppdata->setGateway(gatewayaddr->text()); | 786 | _pppdata->setGateway(gatewayaddr->text()); |
788 | _pppdata->setDefaultroute(defaultroute->isChecked()); | 787 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
789 | } | 788 | } |
790 | 789 | ||
791 | 790 | ||
792 | void GatewayWidget::hitGatewaySelect( int i ) { | 791 | void GatewayWidget::hitGatewaySelect( int i ) { |
793 | if(i == 0) { | 792 | if(i == 0) { |
794 | gatewayaddr->setText("0.0.0.0"); | 793 | gatewayaddr->setText("0.0.0.0"); |
795 | gatewayaddr->setEnabled(false); | 794 | gatewayaddr->setEnabled(false); |
796 | gate_label->setEnabled(false); | 795 | gate_label->setEnabled(false); |
797 | } | 796 | } |
798 | else { | 797 | else { |
799 | gatewayaddr->setEnabled(true); | 798 | gatewayaddr->setEnabled(true); |
800 | gatewayaddr->setText(""); | 799 | gatewayaddr->setText(""); |
801 | gate_label->setEnabled(true); | 800 | gate_label->setEnabled(true); |
802 | } | 801 | } |
803 | } | 802 | } |
804 | 803 | ||
805 | 804 | ||
806 | 805 | ||
807 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 806 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
808 | : QWidget(parent, name),_pppdata(pd) | 807 | : QWidget(parent, name),_pppdata(pd) |
809 | { | 808 | { |
810 | 809 | ||
811 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 810 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
812 | se = new ScriptEdit(this); | 811 | se = new ScriptEdit(this); |
813 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 812 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
814 | tl->addWidget(se); | 813 | tl->addWidget(se); |
815 | 814 | ||
816 | // insert equal-sized buttons | 815 | // insert equal-sized buttons |
817 | QHBoxLayout *hl = new QHBoxLayout( this ); | 816 | QHBoxLayout *hl = new QHBoxLayout( this ); |
818 | tl->addLayout( hl ); | 817 | tl->addLayout( hl ); |
819 | add = new QPushButton( tr("Add"), this ); | 818 | add = new QPushButton( tr("Add"), this ); |
820 | hl->addWidget( add ); | 819 | hl->addWidget( add ); |
821 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | 820 | connect(add, SIGNAL(clicked()), SLOT(addButton())); |
822 | insert = new QPushButton( tr("Insert"), this ); | 821 | insert = new QPushButton( tr("Insert"), this ); |
823 | hl->addWidget( insert ); | 822 | hl->addWidget( insert ); |
824 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | 823 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); |
825 | remove = new QPushButton( tr("Remove"), this ); | 824 | remove = new QPushButton( tr("Remove"), this ); |
826 | hl->addWidget( remove ); | 825 | hl->addWidget( remove ); |
827 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | 826 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); |
828 | 827 | ||
829 | QHBoxLayout *l12 = new QHBoxLayout(0); | 828 | QHBoxLayout *l12 = new QHBoxLayout(0); |
830 | tl->addLayout(l12); | 829 | tl->addLayout(l12); |
831 | stl = new QListBox(this); | 830 | stl = new QListBox(this); |
832 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); | 831 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); |
833 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | 832 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); |
834 | // stl->setMinimumSize(QSize(70, 140)); | 833 | // stl->setMinimumSize(QSize(70, 140)); |
835 | 834 | ||
836 | sl = new QListBox(this); | 835 | sl = new QListBox(this); |
837 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); | 836 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); |
838 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 837 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
839 | // sl->setMinimumSize(QSize(150, 140)); | 838 | // sl->setMinimumSize(QSize(150, 140)); |
840 | 839 | ||
841 | slb = new QScrollBar(this); | 840 | slb = new QScrollBar(this); |
842 | // slb->setFixedWidth(slb->sizeHint().width()); | 841 | // slb->setFixedWidth(slb->sizeHint().width()); |
843 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 842 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
844 | 843 | ||
845 | l12->addWidget(stl, 1); | 844 | l12->addWidget(stl, 1); |
846 | l12->addWidget(sl, 3); | 845 | l12->addWidget(sl, 3); |
847 | l12->addWidget(slb, 0); | 846 | l12->addWidget(slb, 0); |
848 | 847 | ||
849 | //load data from gpppdata | 848 | //load data from gpppdata |
850 | if(!isnewaccount) { | 849 | if(!isnewaccount) { |
851 | QStringList &comlist = _pppdata->scriptType(); | 850 | QStringList &comlist = _pppdata->scriptType(); |
852 | QStringList &arglist = _pppdata->script(); | 851 | QStringList &arglist = _pppdata->script(); |
853 | QStringList::Iterator itcom = comlist.begin(); | 852 | QStringList::Iterator itcom = comlist.begin(); |
854 | QStringList::Iterator itarg = arglist.begin(); | 853 | QStringList::Iterator itarg = arglist.begin(); |
855 | 854 | ||
856 | for ( ; | 855 | for ( ; |
857 | itcom != comlist.end() && itarg != arglist.end(); | 856 | itcom != comlist.end() && itarg != arglist.end(); |
858 | ++itcom, ++itarg ) | 857 | ++itcom, ++itarg ) |
859 | { | 858 | { |
860 | stl->insertItem(*itcom); | 859 | stl->insertItem(*itcom); |
861 | sl->insertItem(*itarg); | 860 | sl->insertItem(*itarg); |
862 | } | 861 | } |
863 | } | 862 | } |
864 | 863 | ||
865 | insert->setEnabled(false); | 864 | insert->setEnabled(false); |
866 | remove->setEnabled(false); | 865 | remove->setEnabled(false); |
867 | adjustScrollBar(); | 866 | adjustScrollBar(); |
868 | tl->activate(); | 867 | tl->activate(); |
869 | } | 868 | } |
870 | 869 | ||
871 | bool ScriptWidget::check() { | 870 | bool ScriptWidget::check() { |
872 | uint lstart = 0; | 871 | uint lstart = 0; |
873 | uint lend = 0; | 872 | uint lend = 0; |
874 | uint errcnt = 0; | 873 | uint errcnt = 0; |
875 | 874 | ||
876 | if(sl->count() > 0) { | 875 | if(sl->count() > 0) { |
877 | for( uint i=0; i <= sl->count()-1; i++) { | 876 | for( uint i=0; i <= sl->count()-1; i++) { |
878 | if(stl->text(i) == "LoopStart") { | 877 | if(stl->text(i) == "LoopStart") { |
879 | lstart++; | 878 | lstart++; |
880 | } | 879 | } |
881 | if (stl->text(i) == "LoopEnd") { | 880 | if (stl->text(i) == "LoopEnd") { |
882 | lend++; | 881 | lend++; |
883 | } | 882 | } |
884 | if ( lend > lstart ) errcnt++; | 883 | if ( lend > lstart ) errcnt++; |
885 | } | 884 | } |
886 | return ( (errcnt == 0 ) && (lstart == lend) ); | 885 | return ( (errcnt == 0 ) && (lstart == lend) ); |
887 | } | 886 | } |
888 | return true; | 887 | return true; |
889 | } | 888 | } |
890 | 889 | ||
891 | 890 | ||
892 | void ScriptWidget::save() { | 891 | void ScriptWidget::save() { |
893 | QStringList typelist, arglist; | 892 | QStringList typelist, arglist; |
894 | for(uint i=0; i < sl->count(); i++) { | 893 | for(uint i=0; i < sl->count(); i++) { |
895 | typelist.append(stl->text(i)); | 894 | typelist.append(stl->text(i)); |
896 | arglist.append(sl->text(i)); | 895 | arglist.append(sl->text(i)); |
897 | } | 896 | } |
898 | _pppdata->setScriptType(typelist); | 897 | _pppdata->setScriptType(typelist); |
899 | _pppdata->setScript(arglist); | 898 | _pppdata->setScript(arglist); |
900 | } | 899 | } |
901 | 900 | ||
902 | 901 | ||
903 | 902 | ||
904 | void ScriptWidget::adjustScrollBar() { | 903 | void ScriptWidget::adjustScrollBar() { |
905 | if((int)sl->count() <= sl->numItemsVisible()) | 904 | if((int)sl->count() <= sl->numItemsVisible()) |
906 | slb->setRange(0, 0); | 905 | slb->setRange(0, 0); |
907 | else | 906 | else |
908 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 907 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
909 | } | 908 | } |
910 | 909 | ||
911 | 910 | ||
912 | void ScriptWidget::scrolling(int i) { | 911 | void ScriptWidget::scrolling(int i) { |
913 | sl->setTopItem(i); | 912 | sl->setTopItem(i); |
914 | stl->setTopItem(i); | 913 | stl->setTopItem(i); |
915 | } | 914 | } |
916 | 915 | ||
917 | 916 | ||
918 | void ScriptWidget::slhighlighted(int i) { | 917 | void ScriptWidget::slhighlighted(int i) { |
919 | insert->setEnabled(true); | 918 | insert->setEnabled(true); |
920 | remove->setEnabled(true); | 919 | remove->setEnabled(true); |
921 | stl->setCurrentItem(i); | 920 | stl->setCurrentItem(i); |
922 | } | 921 | } |
923 | 922 | ||
924 | 923 | ||
925 | void ScriptWidget::stlhighlighted(int i) { | 924 | void ScriptWidget::stlhighlighted(int i) { |
926 | insert->setEnabled(true); | 925 | insert->setEnabled(true); |
927 | remove->setEnabled(true); | 926 | remove->setEnabled(true); |
928 | sl->setCurrentItem(i); | 927 | sl->setCurrentItem(i); |
929 | } | 928 | } |
930 | 929 | ||
931 | 930 | ||
932 | void ScriptWidget::addButton() { | 931 | void ScriptWidget::addButton() { |
933 | //don't allow more than the maximum script entries | 932 | //don't allow more than the maximum script entries |
934 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 933 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
935 | return; | 934 | return; |
936 | 935 | ||
937 | switch(se->type()) { | 936 | switch(se->type()) { |
938 | case ScriptEdit::Expect: | 937 | case ScriptEdit::Expect: |
939 | stl->insertItem("Expect"); | 938 | stl->insertItem("Expect"); |
940 | sl->insertItem(se->text()); | 939 | sl->insertItem(se->text()); |
941 | break; | 940 | break; |
942 | 941 | ||
943 | case ScriptEdit::Send: | 942 | case ScriptEdit::Send: |
944 | stl->insertItem("Send"); | 943 | stl->insertItem("Send"); |
945 | sl->insertItem(se->text()); | 944 | sl->insertItem(se->text()); |
946 | break; | 945 | break; |
947 | 946 | ||
948 | case ScriptEdit::SendNoEcho: | 947 | case ScriptEdit::SendNoEcho: |
949 | stl->insertItem("SendNoEcho"); | 948 | stl->insertItem("SendNoEcho"); |
950 | sl->insertItem(se->text()); | 949 | sl->insertItem(se->text()); |
951 | break; | 950 | break; |
952 | 951 | ||
953 | case ScriptEdit::Pause: | 952 | case ScriptEdit::Pause: |
954 | stl->insertItem("Pause"); | 953 | stl->insertItem("Pause"); |
955 | sl->insertItem(se->text()); | 954 | sl->insertItem(se->text()); |
956 | break; | 955 | break; |
957 | 956 | ||
958 | case ScriptEdit::Hangup: | 957 | case ScriptEdit::Hangup: |
959 | stl->insertItem("Hangup"); | 958 | stl->insertItem("Hangup"); |
960 | sl->insertItem(""); | 959 | sl->insertItem(""); |
961 | break; | 960 | break; |
962 | 961 | ||
963 | case ScriptEdit::Answer: | 962 | case ScriptEdit::Answer: |
964 | stl->insertItem("Answer"); | 963 | stl->insertItem("Answer"); |
965 | sl->insertItem(""); | 964 | sl->insertItem(""); |
966 | break; | 965 | break; |
967 | 966 | ||
968 | case ScriptEdit::Timeout: | 967 | case ScriptEdit::Timeout: |
969 | stl->insertItem("Timeout"); | 968 | stl->insertItem("Timeout"); |
970 | sl->insertItem(se->text()); | 969 | sl->insertItem(se->text()); |
971 | break; | 970 | break; |
972 | 971 | ||
973 | case ScriptEdit::Password: | 972 | case ScriptEdit::Password: |
974 | stl->insertItem("Password"); | 973 | stl->insertItem("Password"); |
975 | sl->insertItem(se->text()); | 974 | sl->insertItem(se->text()); |
976 | break; | 975 | break; |
977 | 976 | ||
978 | case ScriptEdit::ID: | 977 | case ScriptEdit::ID: |
979 | stl->insertItem("ID"); | 978 | stl->insertItem("ID"); |
980 | sl->insertItem(se->text()); | 979 | sl->insertItem(se->text()); |
981 | break; | 980 | break; |
982 | 981 | ||
983 | case ScriptEdit::Prompt: | 982 | case ScriptEdit::Prompt: |
984 | stl->insertItem("Prompt"); | 983 | stl->insertItem("Prompt"); |
985 | sl->insertItem(se->text()); | 984 | sl->insertItem(se->text()); |
986 | break; | 985 | break; |
987 | 986 | ||
988 | case ScriptEdit::PWPrompt: | 987 | case ScriptEdit::PWPrompt: |
989 | stl->insertItem("PWPrompt"); | 988 | stl->insertItem("PWPrompt"); |
990 | sl->insertItem(se->text()); | 989 | sl->insertItem(se->text()); |
991 | break; | 990 | break; |
992 | 991 | ||
993 | case ScriptEdit::LoopStart: | 992 | case ScriptEdit::LoopStart: |
994 | stl->insertItem("LoopStart"); | 993 | stl->insertItem("LoopStart"); |
995 | sl->insertItem(se->text()); | 994 | sl->insertItem(se->text()); |
996 | break; | 995 | break; |
997 | 996 | ||
998 | case ScriptEdit::LoopEnd: | 997 | case ScriptEdit::LoopEnd: |
999 | stl->insertItem("LoopEnd"); | 998 | stl->insertItem("LoopEnd"); |
1000 | sl->insertItem(se->text()); | 999 | sl->insertItem(se->text()); |
1001 | break; | 1000 | break; |
1002 | 1001 | ||
1003 | case ScriptEdit::Scan: | 1002 | case ScriptEdit::Scan: |
1004 | stl->insertItem("Scan"); | 1003 | stl->insertItem("Scan"); |
1005 | sl->insertItem(se->text()); | 1004 | sl->insertItem(se->text()); |
1006 | break; | 1005 | break; |
1007 | 1006 | ||
1008 | case ScriptEdit::Save: | 1007 | case ScriptEdit::Save: |
1009 | stl->insertItem("Save"); | 1008 | stl->insertItem("Save"); |
1010 | sl->insertItem(se->text()); | 1009 | sl->insertItem(se->text()); |
1011 | break; | 1010 | break; |
1012 | 1011 | ||
1013 | default: | 1012 | default: |
1014 | break; | 1013 | break; |
1015 | } | 1014 | } |
1016 | 1015 | ||
1017 | //get the scrollbar adjusted, and scroll the list so we can see what | 1016 | //get the scrollbar adjusted, and scroll the list so we can see what |
1018 | //we're adding to | 1017 | //we're adding to |
1019 | adjustScrollBar(); | 1018 | adjustScrollBar(); |
1020 | slb->setValue(slb->maxValue()); | 1019 | slb->setValue(slb->maxValue()); |
1021 | 1020 | ||
1022 | //clear the text in the entry box | 1021 | //clear the text in the entry box |
1023 | se->setText(""); | 1022 | se->setText(""); |
1024 | } | 1023 | } |
1025 | 1024 | ||
1026 | 1025 | ||
1027 | void ScriptWidget::insertButton() { | 1026 | void ScriptWidget::insertButton() { |
1028 | //exit if there is no highlighted item, or we've reached the | 1027 | //exit if there is no highlighted item, or we've reached the |
1029 | //maximum entries in the script list | 1028 | //maximum entries in the script list |
1030 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 1029 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
1031 | return; | 1030 | return; |
1032 | 1031 | ||
1033 | switch(se->type()) { | 1032 | switch(se->type()) { |
1034 | case ScriptEdit::Expect: | 1033 | case ScriptEdit::Expect: |
1035 | stl->insertItem("Expect", stl->currentItem()); | 1034 | stl->insertItem("Expect", stl->currentItem()); |
1036 | sl->insertItem(se->text(), sl->currentItem()); | 1035 | sl->insertItem(se->text(), sl->currentItem()); |
1037 | break; | 1036 | break; |
1038 | 1037 | ||
1039 | case ScriptEdit::Send: | 1038 | case ScriptEdit::Send: |
1040 | stl->insertItem("Send", stl->currentItem()); | 1039 | stl->insertItem("Send", stl->currentItem()); |
1041 | sl->insertItem(se->text(), sl->currentItem()); | 1040 | sl->insertItem(se->text(), sl->currentItem()); |
1042 | break; | 1041 | break; |
1043 | 1042 | ||
1044 | case ScriptEdit::SendNoEcho: | 1043 | case ScriptEdit::SendNoEcho: |
1045 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1044 | stl->insertItem("SendNoEcho", stl->currentItem()); |
1046 | sl->insertItem(se->text(), sl->currentItem()); | 1045 | sl->insertItem(se->text(), sl->currentItem()); |
1047 | break; | 1046 | break; |
1048 | 1047 | ||
1049 | case ScriptEdit::Pause: | 1048 | case ScriptEdit::Pause: |
1050 | stl->insertItem("Pause", stl->currentItem()); | 1049 | stl->insertItem("Pause", stl->currentItem()); |
1051 | sl->insertItem(se->text(), sl->currentItem()); | 1050 | sl->insertItem(se->text(), sl->currentItem()); |
1052 | break; | 1051 | break; |
1053 | 1052 | ||
1054 | case ScriptEdit::Hangup: | 1053 | case ScriptEdit::Hangup: |
1055 | stl->insertItem("Hangup", stl->currentItem()); | 1054 | stl->insertItem("Hangup", stl->currentItem()); |
1056 | sl->insertItem("", sl->currentItem()); | 1055 | sl->insertItem("", sl->currentItem()); |
1057 | break; | 1056 | break; |
1058 | 1057 | ||
1059 | case ScriptEdit::Answer: | 1058 | case ScriptEdit::Answer: |
1060 | stl->insertItem("Answer", stl->currentItem()); | 1059 | stl->insertItem("Answer", stl->currentItem()); |
1061 | sl->insertItem("", sl->currentItem()); | 1060 | sl->insertItem("", sl->currentItem()); |
1062 | break; | 1061 | break; |
1063 | 1062 | ||
1064 | case ScriptEdit::Timeout: | 1063 | case ScriptEdit::Timeout: |
1065 | stl->insertItem("Timeout", stl->currentItem()); | 1064 | stl->insertItem("Timeout", stl->currentItem()); |
1066 | sl->insertItem(se->text(), sl->currentItem()); | 1065 | sl->insertItem(se->text(), sl->currentItem()); |
1067 | break; | 1066 | break; |
1068 | 1067 | ||
1069 | case ScriptEdit::Password: | 1068 | case ScriptEdit::Password: |
1070 | stl->insertItem("Password", stl->currentItem()); | 1069 | stl->insertItem("Password", stl->currentItem()); |
1071 | sl->insertItem(se->text(), sl->currentItem()); | 1070 | sl->insertItem(se->text(), sl->currentItem()); |
1072 | break; | 1071 | break; |
1073 | 1072 | ||
1074 | case ScriptEdit::ID: | 1073 | case ScriptEdit::ID: |
1075 | stl->insertItem("ID", stl->currentItem()); | 1074 | stl->insertItem("ID", stl->currentItem()); |
1076 | sl->insertItem(se->text(), sl->currentItem()); | 1075 | sl->insertItem(se->text(), sl->currentItem()); |
1077 | break; | 1076 | break; |
1078 | 1077 | ||
1079 | case ScriptEdit::Prompt: | 1078 | case ScriptEdit::Prompt: |
1080 | stl->insertItem("Prompt", stl->currentItem()); | 1079 | stl->insertItem("Prompt", stl->currentItem()); |
1081 | sl->insertItem(se->text(), sl->currentItem()); | 1080 | sl->insertItem(se->text(), sl->currentItem()); |
1082 | break; | 1081 | break; |
1083 | 1082 | ||
1084 | case ScriptEdit::PWPrompt: | 1083 | case ScriptEdit::PWPrompt: |
1085 | stl->insertItem("PWPrompt", stl->currentItem()); | 1084 | stl->insertItem("PWPrompt", stl->currentItem()); |
1086 | sl->insertItem(se->text(), sl->currentItem()); | 1085 | sl->insertItem(se->text(), sl->currentItem()); |
1087 | break; | 1086 | break; |
1088 | 1087 | ||
1089 | case ScriptEdit::LoopStart: | 1088 | case ScriptEdit::LoopStart: |
1090 | stl->insertItem("LoopStart", stl->currentItem()); | 1089 | stl->insertItem("LoopStart", stl->currentItem()); |
1091 | sl->insertItem(se->text(), sl->currentItem()); | 1090 | sl->insertItem(se->text(), sl->currentItem()); |
1092 | break; | 1091 | break; |
1093 | 1092 | ||
1094 | case ScriptEdit::LoopEnd: | 1093 | case ScriptEdit::LoopEnd: |
1095 | stl->insertItem("LoopEnd", stl->currentItem()); | 1094 | stl->insertItem("LoopEnd", stl->currentItem()); |
1096 | sl->insertItem(se->text(), sl->currentItem()); | 1095 | sl->insertItem(se->text(), sl->currentItem()); |
1097 | break; | 1096 | break; |
1098 | 1097 | ||
1099 | case ScriptEdit::Scan: | 1098 | case ScriptEdit::Scan: |
1100 | stl->insertItem("Scan", stl->currentItem()); | 1099 | stl->insertItem("Scan", stl->currentItem()); |
1101 | sl->insertItem(se->text(), sl->currentItem()); | 1100 | sl->insertItem(se->text(), sl->currentItem()); |
1102 | break; | 1101 | break; |
1103 | 1102 | ||
1104 | case ScriptEdit::Save: | 1103 | case ScriptEdit::Save: |
1105 | stl->insertItem("Save", stl->currentItem()); | 1104 | stl->insertItem("Save", stl->currentItem()); |
1106 | sl->insertItem(se->text(), sl->currentItem()); | 1105 | sl->insertItem(se->text(), sl->currentItem()); |
1107 | break; | 1106 | break; |
1108 | 1107 | ||
1109 | default: | 1108 | default: |
1110 | break; | 1109 | break; |
1111 | } | 1110 | } |
1112 | adjustScrollBar(); | 1111 | adjustScrollBar(); |
1113 | se->setText(""); | 1112 | se->setText(""); |
1114 | } | 1113 | } |
1115 | 1114 | ||
1116 | 1115 | ||
1117 | void ScriptWidget::removeButton() { | 1116 | void ScriptWidget::removeButton() { |
1118 | if(sl->currentItem() >= 0) { | 1117 | if(sl->currentItem() >= 0) { |
1119 | int stlc = stl->currentItem(); | 1118 | int stlc = stl->currentItem(); |
1120 | sl->removeItem(sl->currentItem()); | 1119 | sl->removeItem(sl->currentItem()); |
1121 | stl->removeItem(stlc); | 1120 | stl->removeItem(stlc); |
1122 | adjustScrollBar(); | 1121 | adjustScrollBar(); |
1123 | insert->setEnabled(sl->currentItem() != -1); | 1122 | insert->setEnabled(sl->currentItem() != -1); |
1124 | remove->setEnabled(sl->currentItem() != -1); | 1123 | remove->setEnabled(sl->currentItem() != -1); |
1125 | } | 1124 | } |
1126 | } | 1125 | } |
1127 | 1126 | ||
1128 | 1127 | ||
1129 | 1128 | ||
1130 | ///////////////////////////////////////////////////////////////////////////// | 1129 | ///////////////////////////////////////////////////////////////////////////// |
1131 | // | 1130 | // |
1132 | // Used to specify a new phone number | 1131 | // Used to specify a new phone number |
1133 | // | 1132 | // |
1134 | ///////////////////////////////////////////////////////////////////////////// | 1133 | ///////////////////////////////////////////////////////////////////////////// |
1135 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1134 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1136 | : QDialog(parent,"PhoneNumberDialog",true) | 1135 | : QDialog(parent,"PhoneNumberDialog",true) |
1137 | { | 1136 | { |
1138 | setCaption( tr("Add Phone Number") ); | 1137 | setCaption( tr("Add Phone Number") ); |
1139 | 1138 | ||
1140 | 1139 | ||
1141 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1140 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1142 | layout->setSpacing( 3 ); | 1141 | layout->setSpacing( 3 ); |
1143 | layout->setMargin( 3 ); | 1142 | layout->setMargin( 3 ); |
1144 | 1143 | ||
1145 | // QHBox *hbox = new QHBox(this); | 1144 | // QHBox *hbox = new QHBox(this); |
1146 | // setMainWidget(hbox); | 1145 | // setMainWidget(hbox); |
1147 | 1146 | ||
1148 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1147 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1149 | 1148 | ||
1150 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1149 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1151 | layout->addWidget( label ); | 1150 | layout->addWidget( label ); |
1152 | 1151 | ||
1153 | le = new QLineEdit(this, "lineEdit"); | 1152 | le = new QLineEdit(this, "lineEdit"); |
1154 | layout->addWidget( le ); | 1153 | layout->addWidget( le ); |
1155 | 1154 | ||
1156 | connect(le, SIGNAL(textChanged(const QString &)), | 1155 | connect(le, SIGNAL(textChanged(const QString &)), |
1157 | this, SLOT(textChanged(const QString &))); | 1156 | this, SLOT(textChanged(const QString &))); |
1158 | 1157 | ||
1159 | le->setFocus(); | 1158 | le->setFocus(); |
1160 | textChanged(""); | 1159 | textChanged(""); |
1161 | 1160 | ||
1162 | 1161 | ||
1163 | } | 1162 | } |
1164 | 1163 | ||
1165 | 1164 | ||
1166 | QString PhoneNumberDialog::phoneNumber() { | 1165 | QString PhoneNumberDialog::phoneNumber() { |
1167 | QString s = le->text(); | 1166 | QString s = le->text(); |
1168 | 1167 | ||
1169 | return s; | 1168 | return s; |
1170 | } | 1169 | } |
1171 | 1170 | ||
1172 | 1171 | ||
1173 | void PhoneNumberDialog::textChanged(const QString &s) { | 1172 | void PhoneNumberDialog::textChanged(const QString &s) { |
1174 | // enableButtonOK(s.length() > 0); | 1173 | // enableButtonOK(s.length() > 0); |
1175 | } | 1174 | } |
1176 | 1175 | ||
1177 | 1176 | ||
1178 | //#include "edit.moc" | 1177 | //#include "edit.moc" |
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp index d1143cf..66a4d82 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.cpp +++ b/noncore/settings/networksettings/ppp/pppdargs.cpp | |||
@@ -1,166 +1,151 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * | 12 | * |
13 | * This library is free software; you can redistribute it and/or | 13 | * This library is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU Library General Public | 14 | * modify it under the terms of the GNU Library General Public |
15 | * License as published by the Free Software Foundation; either | 15 | * License as published by the Free Software Foundation; either |
16 | * version 2 of the License, or (at your option) any later version. | 16 | * version 2 of the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This library is distributed in the hope that it will be useful, | 18 | * This library is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * Library General Public License for more details. | 21 | * Library General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU Library General Public | 23 | * You should have received a copy of the GNU Library General Public |
24 | * License along with this program; if not, write to the Free | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | //#include <kwin.h> | ||
31 | #include <qapplication.h> | 30 | #include <qapplication.h> |
32 | #include "pppdargs.h" | 31 | #include "pppdargs.h" |
33 | #include "pppdata.h" | 32 | #include "pppdata.h" |
34 | //#include <klocale.h> | 33 | |
35 | #define i18n QObject::tr | ||
36 | 34 | ||
37 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) | 35 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) |
38 | : QDialog(parent, name, TRUE), _pppdata(pd) | 36 | : QDialog(parent, name, TRUE), _pppdata(pd) |
39 | { | 37 | { |
40 | setCaption(i18n("Customize pppd Arguments")); | 38 | setCaption(tr("Customize pppd Arguments")); |
41 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 39 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
42 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); | 40 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); |
43 | QHBoxLayout *tl = new QHBoxLayout(10); | 41 | QHBoxLayout *tl = new QHBoxLayout(10); |
44 | l->addLayout(tl); | 42 | l->addLayout(tl); |
45 | QVBoxLayout *l1 = new QVBoxLayout(); | 43 | QVBoxLayout *l1 = new QVBoxLayout(); |
46 | QVBoxLayout *l2 = new QVBoxLayout(); | 44 | QVBoxLayout *l2 = new QVBoxLayout(); |
47 | tl->addLayout(l1, 1); | 45 | tl->addLayout(l1, 1); |
48 | tl->addLayout(l2, 0); | 46 | tl->addLayout(l2, 0); |
49 | 47 | ||
50 | QHBoxLayout *l11 = new QHBoxLayout(10); | 48 | QHBoxLayout *l11 = new QHBoxLayout(10); |
51 | l1->addLayout(l11); | 49 | l1->addLayout(l11); |
52 | 50 | ||
53 | argument_label = new QLabel(i18n("Argument:"), this); | 51 | argument_label = new QLabel(tr("Argument:"), this); |
54 | l11->addWidget(argument_label); | 52 | l11->addWidget(argument_label); |
55 | 53 | ||
56 | argument = new QLineEdit(this); | 54 | argument = new QLineEdit(this); |
57 | connect(argument, SIGNAL(returnPressed()), | 55 | connect(argument, SIGNAL(returnPressed()), |
58 | SLOT(addbutton())); | 56 | SLOT(addbutton())); |
59 | l11->addWidget(argument); | 57 | l11->addWidget(argument); |
60 | connect(argument, SIGNAL(textChanged(const QString &)), | 58 | connect(argument, SIGNAL(textChanged(const QString &)), |
61 | this, SLOT(textChanged(const QString &))); | 59 | this, SLOT(textChanged(const QString &))); |
62 | 60 | ||
63 | arguments = new QListBox(this); | 61 | arguments = new QListBox(this); |
64 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); | 62 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); |
65 | connect(arguments, SIGNAL(highlighted(int)), | 63 | connect(arguments, SIGNAL(highlighted(int)), |
66 | this, SLOT(itemSelected(int))); | 64 | this, SLOT(itemSelected(int))); |
67 | l1->addWidget(arguments, 1); | 65 | l1->addWidget(arguments, 1); |
68 | 66 | ||
69 | add = new QPushButton(i18n("Add"), this); | 67 | add = new QPushButton(tr("Add"), this); |
70 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); | 68 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); |
71 | l2->addWidget(add); | 69 | l2->addWidget(add); |
72 | l2->addStretch(1); | 70 | l2->addStretch(1); |
73 | 71 | ||
74 | remove = new QPushButton(i18n("Remove"), this); | 72 | remove = new QPushButton(tr("Remove"), this); |
75 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); | 73 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); |
76 | l2->addWidget(remove); | 74 | l2->addWidget(remove); |
77 | 75 | ||
78 | defaults = new QPushButton(i18n("Defaults"), this); | 76 | defaults = new QPushButton(tr("Defaults"), this); |
79 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); | 77 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); |
80 | l2->addWidget(defaults); | 78 | l2->addWidget(defaults); |
81 | 79 | ||
82 | l->addSpacing(5); | 80 | l->addSpacing(5); |
83 | 81 | ||
84 | // QButtonGroup *bbox = new QButtonGroup(this); | ||
85 | // // bbox->addStretch(1); | ||
86 | // closebtn = new QPushButton( bbox, i18n("OK")); | ||
87 | // bbox->insert(closebtn); | ||
88 | // connect(closebtn, SIGNAL(clicked()), SLOT(closebutton())); | ||
89 | // QPushButton *cancel = new QPushButton( bbox, i18n("Cancel")); | ||
90 | // bbox->insert(cancel); | ||
91 | // connect(cancel, SIGNAL(clicked()), | ||
92 | // this, SLOT(reject())); | ||
93 | // bbox->layout(); | ||
94 | // l->addWidget(bbox); | ||
95 | |||
96 | // setFixedSize(sizeHint()); | ||
97 | 82 | ||
98 | //load info from gpppdata | 83 | //load info from gpppdata |
99 | init(); | 84 | init(); |
100 | 85 | ||
101 | add->setEnabled(false); | 86 | add->setEnabled(false); |
102 | remove->setEnabled(false); | 87 | remove->setEnabled(false); |
103 | argument->setFocus(); | 88 | argument->setFocus(); |
104 | } | 89 | } |
105 | 90 | ||
106 | 91 | ||
107 | void PPPdArguments::addbutton() { | 92 | void PPPdArguments::addbutton() { |
108 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { | 93 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { |
109 | arguments->insertItem(argument->text()); | 94 | arguments->insertItem(argument->text()); |
110 | argument->setText(""); | 95 | argument->setText(""); |
111 | } | 96 | } |
112 | } | 97 | } |
113 | 98 | ||
114 | 99 | ||
115 | void PPPdArguments::removebutton() { | 100 | void PPPdArguments::removebutton() { |
116 | if(arguments->currentItem() >= 0) | 101 | if(arguments->currentItem() >= 0) |
117 | arguments->removeItem(arguments->currentItem()); | 102 | arguments->removeItem(arguments->currentItem()); |
118 | } | 103 | } |
119 | 104 | ||
120 | 105 | ||
121 | void PPPdArguments::defaultsbutton() { | 106 | void PPPdArguments::defaultsbutton() { |
122 | // all of this is a hack | 107 | // all of this is a hack |
123 | // save current list | 108 | // save current list |
124 | QStringList arglist(_pppdata->pppdArgument()); | 109 | QStringList arglist(_pppdata->pppdArgument()); |
125 | 110 | ||
126 | // get defaults | 111 | // get defaults |
127 | _pppdata->setpppdArgumentDefaults(); | 112 | _pppdata->setpppdArgumentDefaults(); |
128 | init(); | 113 | init(); |
129 | 114 | ||
130 | // restore old list | 115 | // restore old list |
131 | _pppdata->setpppdArgument(arglist); | 116 | _pppdata->setpppdArgument(arglist); |
132 | } | 117 | } |
133 | 118 | ||
134 | 119 | ||
135 | void PPPdArguments::closebutton() { | 120 | void PPPdArguments::accept() { |
136 | QStringList arglist; | 121 | QStringList arglist; |
137 | for(uint i=0; i < arguments->count(); i++) | 122 | for(uint i=0; i < arguments->count(); i++) |
138 | arglist.append(arguments->text(i)); | 123 | arglist.append(arguments->text(i)); |
139 | _pppdata->setpppdArgument(arglist); | 124 | _pppdata->setpppdArgument(arglist); |
140 | 125 | ||
141 | done(0); | 126 | QDialog::accept(); |
142 | } | 127 | } |
143 | 128 | ||
144 | 129 | ||
145 | void PPPdArguments::init() { | 130 | void PPPdArguments::init() { |
146 | while(arguments->count()) | 131 | while(arguments->count()) |
147 | arguments->removeItem(0); | 132 | arguments->removeItem(0); |
148 | 133 | ||
149 | QStringList &arglist = _pppdata->pppdArgument(); | 134 | QStringList &arglist = _pppdata->pppdArgument(); |
150 | for ( QStringList::Iterator it = arglist.begin(); | 135 | for ( QStringList::Iterator it = arglist.begin(); |
151 | it != arglist.end(); | 136 | it != arglist.end(); |
152 | ++it ) | 137 | ++it ) |
153 | arguments->insertItem(*it); | 138 | arguments->insertItem(*it); |
154 | } | 139 | } |
155 | 140 | ||
156 | 141 | ||
157 | void PPPdArguments::textChanged(const QString &s) { | 142 | void PPPdArguments::textChanged(const QString &s) { |
158 | add->setEnabled(s.length() > 0); | 143 | add->setEnabled(s.length() > 0); |
159 | } | 144 | } |
160 | 145 | ||
161 | 146 | ||
162 | void PPPdArguments::itemSelected(int idx) { | 147 | void PPPdArguments::itemSelected(int idx) { |
163 | remove->setEnabled(idx != -1); | 148 | remove->setEnabled(idx != -1); |
164 | } | 149 | } |
165 | 150 | ||
166 | 151 | ||
diff --git a/noncore/settings/networksettings/ppp/pppdargs.h b/noncore/settings/networksettings/ppp/pppdargs.h index 75f0c9d..065b03c 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.h +++ b/noncore/settings/networksettings/ppp/pppdargs.h | |||
@@ -1,78 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * | 12 | * |
13 | * This library is free software; you can redistribute it and/or | 13 | * This library is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU Library General Public | 14 | * modify it under the terms of the GNU Library General Public |
15 | * License as published by the Free Software Foundation; either | 15 | * License as published by the Free Software Foundation; either |
16 | * version 2 of the License, or (at your option) any later version. | 16 | * version 2 of the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This library is distributed in the hope that it will be useful, | 18 | * This library is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * Library General Public License for more details. | 21 | * Library General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU Library General Public | 23 | * You should have received a copy of the GNU Library General Public |
24 | * License along with this program; if not, write to the Free | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef _PPPDARGS_H_ | 28 | #ifndef _PPPDARGS_H_ |
29 | #define _PPPDARGS_H_ | 29 | #define _PPPDARGS_H_ |
30 | 30 | ||
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qlistbox.h> | 34 | #include <qlistbox.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | class PPPData; | 36 | class PPPData; |
37 | 37 | ||
38 | class PPPdArguments : public QDialog { | 38 | class PPPdArguments : public QDialog { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | PPPdArguments(PPPData*,QWidget *parent=0, const char *name=0); | 41 | PPPdArguments(PPPData*,QWidget *parent=0, const char *name=0); |
42 | ~PPPdArguments() {} | 42 | ~PPPdArguments() {} |
43 | 43 | ||
44 | private slots: | 44 | private slots: |
45 | void addbutton(); | 45 | void addbutton(); |
46 | void removebutton(); | 46 | void removebutton(); |
47 | void defaultsbutton(); | 47 | void defaultsbutton(); |
48 | void closebutton(); | 48 | virtual void accept(); |
49 | void textChanged(const QString &); | 49 | void textChanged(const QString &); |
50 | void itemSelected(int); | 50 | void itemSelected(int); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | void init(); | 53 | void init(); |
54 | 54 | ||
55 | QLabel *argument_label; | 55 | QLabel *argument_label; |
56 | 56 | ||
57 | QLineEdit *argument; | 57 | QLineEdit *argument; |
58 | 58 | ||
59 | QPushButton *add; | 59 | QPushButton *add; |
60 | QPushButton *remove; | 60 | QPushButton *remove; |
61 | QPushButton *defaults; | 61 | QPushButton *defaults; |
62 | 62 | ||
63 | QListBox *arguments; | 63 | QListBox *arguments; |
64 | 64 | ||
65 | QPushButton *closebtn; | 65 | QPushButton *closebtn; |
66 | PPPData *_pppdata; | 66 | PPPData *_pppdata; |
67 | }; | 67 | }; |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | 70 | ||
71 | 71 | ||
72 | 72 | ||
73 | 73 | ||
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | 78 | ||