Diffstat (limited to 'noncore/settings/networksettings/ppp/modeminfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/modeminfo.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp index 0bec186..dbb26db 100644 --- a/noncore/settings/networksettings/ppp/modeminfo.cpp +++ b/noncore/settings/networksettings/ppp/modeminfo.cpp | |||
@@ -13,83 +13,81 @@ | |||
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This library is distributed in the hope that it will be useful, | 17 | * This library is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <qregexp.h> | 28 | #include <qregexp.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | // #include <kwin.h> | 30 | // #include <kwin.h> |
31 | // #include <kmessagebox.h> | 31 | // #include <kmessagebox.h> |
32 | // #include <kapplication.h> | 32 | // #include <kapplication.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include "modeminfo.h" | 35 | #include "modeminfo.h" |
36 | #include "modem.h" | 36 | #include "modem.h" |
37 | //#include <klocale.h> | ||
38 | #define i18n QObject::tr | ||
39 | 37 | ||
40 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) | 38 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) |
41 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), | 39 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), |
42 | _modem(mo) | 40 | _modem(mo) |
43 | { | 41 | { |
44 | setCaption(i18n("ATI Query")); | 42 | setCaption(QObject::tr("ATI Query")); |
45 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 43 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
46 | 44 | ||
47 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 45 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
48 | 46 | ||
49 | progressBar = new QProgressBar(this, "bar"); | 47 | progressBar = new QProgressBar(this, "bar"); |
50 | progressBar->setTotalSteps(8); | 48 | progressBar->setTotalSteps(8); |
51 | 49 | ||
52 | statusBar = new QLabel(this,"sBar"); | 50 | statusBar = new QLabel(this,"sBar"); |
53 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 51 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
54 | statusBar->setAlignment(AlignCenter); | 52 | statusBar->setAlignment(AlignCenter); |
55 | 53 | ||
56 | // This is a rather complicated case. Since we do not know which | 54 | // This is a rather complicated case. Since we do not know which |
57 | // message is the widest in the national language, we'd to | 55 | // message is the widest in the national language, we'd to |
58 | // search all these messages. This is a little overkill, so I take | 56 | // search all these messages. This is a little overkill, so I take |
59 | // the longest english message, translate it and give it additional | 57 | // the longest english message, translate it and give it additional |
60 | // 20 percent space. Hope this is enough. | 58 | // 20 percent space. Hope this is enough. |
61 | statusBar->setText(i18n("Unable to create modem lock file.")); | 59 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
62 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); | 60 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); |
63 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); | 61 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); |
64 | 62 | ||
65 | // set original text | 63 | // set original text |
66 | statusBar->setText(i18n("Looking for modem...")); | 64 | statusBar->setText(QObject::tr("Looking for modem...")); |
67 | progressBar->setFixedHeight(statusBar->minimumSize().height()); | 65 | progressBar->setFixedHeight(statusBar->minimumSize().height()); |
68 | tl->addWidget(progressBar); | 66 | tl->addWidget(progressBar); |
69 | tl->addWidget(statusBar); | 67 | tl->addWidget(statusBar); |
70 | 68 | ||
71 | cancel = new QPushButton(i18n("Cancel"), this); | 69 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
72 | cancel->setFocus(); | 70 | cancel->setFocus(); |
73 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 71 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
74 | 72 | ||
75 | QHBoxLayout *l1 = new QHBoxLayout; | 73 | QHBoxLayout *l1 = new QHBoxLayout; |
76 | tl->addLayout(l1); | 74 | tl->addLayout(l1); |
77 | l1->addStretch(1); | 75 | l1->addStretch(1); |
78 | l1->addWidget(cancel); | 76 | l1->addWidget(cancel); |
79 | 77 | ||
80 | setFixedSize(sizeHint()); | 78 | setFixedSize(sizeHint()); |
81 | 79 | ||
82 | step = 0; | 80 | step = 0; |
83 | 81 | ||
84 | //////////////////////////////////////////////// | 82 | //////////////////////////////////////////////// |
85 | 83 | ||
86 | timeout_timer = new QTimer(this); | 84 | timeout_timer = new QTimer(this); |
87 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); | 85 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); |
88 | 86 | ||
89 | scripttimer = new QTimer(this); | 87 | scripttimer = new QTimer(this); |
90 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); | 88 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); |
91 | 89 | ||
92 | timeout_timer->start(15000,TRUE); // 15 secs single shot | 90 | timeout_timer->start(15000,TRUE); // 15 secs single shot |
93 | QTimer::singleShot(500, this, SLOT(init())); | 91 | QTimer::singleShot(500, this, SLOT(init())); |
94 | 92 | ||
95 | } | 93 | } |
@@ -97,77 +95,77 @@ ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) | |||
97 | 95 | ||
98 | void ModemTransfer::ati_done() { | 96 | void ModemTransfer::ati_done() { |
99 | scripttimer->stop(); | 97 | scripttimer->stop(); |
100 | timeout_timer->stop(); | 98 | timeout_timer->stop(); |
101 | _modem->closetty(); | 99 | _modem->closetty(); |
102 | _modem->unlockdevice(); | 100 | _modem->unlockdevice(); |
103 | hide(); | 101 | hide(); |
104 | 102 | ||
105 | // open the result window | 103 | // open the result window |
106 | ModemInfo *mi = new ModemInfo(this); | 104 | ModemInfo *mi = new ModemInfo(this); |
107 | for(int i = 0; i < NUM_OF_ATI; i++) | 105 | for(int i = 0; i < NUM_OF_ATI; i++) |
108 | mi->setAtiString(i, ati_query_strings[i]); | 106 | mi->setAtiString(i, ati_query_strings[i]); |
109 | mi->showMaximized(); | 107 | mi->showMaximized(); |
110 | mi->exec(); | 108 | mi->exec(); |
111 | delete mi; | 109 | delete mi; |
112 | 110 | ||
113 | accept(); | 111 | accept(); |
114 | } | 112 | } |
115 | 113 | ||
116 | 114 | ||
117 | void ModemTransfer::time_out_slot() { | 115 | void ModemTransfer::time_out_slot() { |
118 | timeout_timer->stop(); | 116 | timeout_timer->stop(); |
119 | scripttimer->stop(); | 117 | scripttimer->stop(); |
120 | 118 | ||
121 | QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); | 119 | QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); |
122 | reject(); | 120 | reject(); |
123 | } | 121 | } |
124 | 122 | ||
125 | 123 | ||
126 | void ModemTransfer::init() { | 124 | void ModemTransfer::init() { |
127 | 125 | ||
128 | qApp->processEvents(); | 126 | qApp->processEvents(); |
129 | 127 | ||
130 | int lock = _modem->lockdevice(); | 128 | int lock = _modem->lockdevice(); |
131 | if (lock == 1) { | 129 | if (lock == 1) { |
132 | 130 | ||
133 | statusBar->setText(i18n("Modem device is locked.")); | 131 | statusBar->setText(QObject::tr("Modem device is locked.")); |
134 | return; | 132 | return; |
135 | } | 133 | } |
136 | 134 | ||
137 | if (lock == -1) { | 135 | if (lock == -1) { |
138 | 136 | ||
139 | statusBar->setText(i18n("Unable to create modem lock file.")); | 137 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | 140 | ||
143 | 141 | ||
144 | if(_modem->opentty()) { | 142 | if(_modem->opentty()) { |
145 | if(_modem->hangup()) { | 143 | if(_modem->hangup()) { |
146 | usleep(100000); // wait 0.1 secs | 144 | usleep(100000); // wait 0.1 secs |
147 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | 145 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... |
148 | 146 | ||
149 | statusBar->setText(i18n("Modem Ready")); | 147 | statusBar->setText(QObject::tr("Modem Ready")); |
150 | qApp->processEvents(); | 148 | qApp->processEvents(); |
151 | usleep(100000); // wait 0.1 secs | 149 | usleep(100000); // wait 0.1 secs |
152 | qApp->processEvents(); | 150 | qApp->processEvents(); |
153 | scripttimer->start(1000); // this one does the ati query | 151 | scripttimer->start(1000); // this one does the ati query |
154 | 152 | ||
155 | // clear modem buffer | 153 | // clear modem buffer |
156 | _modem->flush(); | 154 | _modem->flush(); |
157 | 155 | ||
158 | _modem->notify(this, SLOT(readChar(unsigned char))); | 156 | _modem->notify(this, SLOT(readChar(unsigned char))); |
159 | return; | 157 | return; |
160 | } | 158 | } |
161 | } | 159 | } |
162 | 160 | ||
163 | // opentty() or hangup() failed | 161 | // opentty() or hangup() failed |
164 | statusBar->setText(_modem->modemMessage()); | 162 | statusBar->setText(_modem->modemMessage()); |
165 | step = 99; // wait until cancel is pressed | 163 | step = 99; // wait until cancel is pressed |
166 | _modem->unlockdevice(); | 164 | _modem->unlockdevice(); |
167 | } | 165 | } |
168 | 166 | ||
169 | 167 | ||
170 | void ModemTransfer::do_script() { | 168 | void ModemTransfer::do_script() { |
171 | QString msg; | 169 | QString msg; |
172 | QString query; | 170 | QString query; |
173 | 171 | ||
@@ -206,91 +204,91 @@ void ModemTransfer::readChar(unsigned char c) { | |||
206 | readbuffer += c; | 204 | readbuffer += c; |
207 | } | 205 | } |
208 | 206 | ||
209 | void ModemTransfer::readtty() { | 207 | void ModemTransfer::readtty() { |
210 | 208 | ||
211 | if (step == 0) | 209 | if (step == 0) |
212 | return; | 210 | return; |
213 | 211 | ||
214 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r | 212 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r |
215 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white | 213 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white |
216 | // space | 214 | // space |
217 | 215 | ||
218 | if(step <= NUM_OF_ATI) | 216 | if(step <= NUM_OF_ATI) |
219 | ati_query_strings[step-1] = readbuffer.copy(); | 217 | ati_query_strings[step-1] = readbuffer.copy(); |
220 | 218 | ||
221 | readbuffer = ""; | 219 | readbuffer = ""; |
222 | } | 220 | } |
223 | 221 | ||
224 | 222 | ||
225 | void ModemTransfer::cancelbutton() { | 223 | void ModemTransfer::cancelbutton() { |
226 | scripttimer->stop(); | 224 | scripttimer->stop(); |
227 | _modem->stop(); | 225 | _modem->stop(); |
228 | timeout_timer->stop(); | 226 | timeout_timer->stop(); |
229 | 227 | ||
230 | statusBar->setText(i18n("One moment please...")); | 228 | statusBar->setText(QObject::tr("One moment please...")); |
231 | qApp->processEvents(); | 229 | qApp->processEvents(); |
232 | 230 | ||
233 | _modem->hangup(); | 231 | _modem->hangup(); |
234 | 232 | ||
235 | _modem->closetty(); | 233 | _modem->closetty(); |
236 | _modem->unlockdevice(); | 234 | _modem->unlockdevice(); |
237 | reject(); | 235 | reject(); |
238 | } | 236 | } |
239 | 237 | ||
240 | 238 | ||
241 | void ModemTransfer::closeEvent( QCloseEvent *e ) { | 239 | void ModemTransfer::closeEvent( QCloseEvent *e ) { |
242 | cancelbutton(); | 240 | cancelbutton(); |
243 | e->accept(); | 241 | e->accept(); |
244 | } | 242 | } |
245 | 243 | ||
246 | 244 | ||
247 | ModemInfo::ModemInfo(QWidget *parent, const char* name) | 245 | ModemInfo::ModemInfo(QWidget *parent, const char* name) |
248 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) | 246 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) |
249 | { | 247 | { |
250 | QString label_text; | 248 | QString label_text; |
251 | 249 | ||
252 | setCaption(i18n("Modem Query Results")); | 250 | setCaption(QObject::tr("Modem Query Results")); |
253 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 251 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
254 | 252 | ||
255 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 253 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
256 | 254 | ||
257 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); | 255 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); |
258 | tl->addLayout(l1, 1); | 256 | tl->addLayout(l1, 1); |
259 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { | 257 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { |
260 | 258 | ||
261 | label_text = ""; | 259 | label_text = ""; |
262 | if ( i == 0) | 260 | if ( i == 0) |
263 | label_text.sprintf("ATI :"); | 261 | label_text.sprintf("ATI :"); |
264 | else | 262 | else |
265 | label_text.sprintf("ATI %d:", i ); | 263 | label_text.sprintf("ATI %d:", i ); |
266 | 264 | ||
267 | ati_label[i] = new QLabel(label_text, this); | 265 | ati_label[i] = new QLabel(label_text, this); |
268 | l1->addWidget(ati_label[i], i, 0); | 266 | l1->addWidget(ati_label[i], i, 0); |
269 | 267 | ||
270 | ati_label_result[i] = new QLineEdit(this); | 268 | ati_label_result[i] = new QLineEdit(this); |
271 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); | 269 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); |
272 | l1->addWidget(ati_label_result[i], i, 1); | 270 | l1->addWidget(ati_label_result[i], i, 1); |
273 | } | 271 | } |
274 | //tl->addSpacing(1); | 272 | //tl->addSpacing(1); |
275 | 273 | ||
276 | QHBoxLayout *l2 = new QHBoxLayout; | 274 | QHBoxLayout *l2 = new QHBoxLayout; |
277 | QPushButton *ok = new QPushButton(i18n("Close"), this); | 275 | QPushButton *ok = new QPushButton(QObject::tr("Close"), this); |
278 | ok->setDefault(TRUE); | 276 | ok->setDefault(TRUE); |
279 | ok->setFocus(); | 277 | ok->setFocus(); |
280 | 278 | ||
281 | tl->addLayout(l2); | 279 | tl->addLayout(l2); |
282 | l2->addStretch(1); | 280 | l2->addStretch(1); |
283 | 281 | ||
284 | connect(ok, SIGNAL(clicked()), SLOT(accept())); | 282 | connect(ok, SIGNAL(clicked()), SLOT(accept())); |
285 | l2->addWidget(ok); | 283 | l2->addWidget(ok); |
286 | 284 | ||
287 | setMinimumSize(sizeHint()); | 285 | setMinimumSize(sizeHint()); |
288 | } | 286 | } |
289 | 287 | ||
290 | 288 | ||
291 | void ModemInfo::setAtiString(int i, QString s) { | 289 | void ModemInfo::setAtiString(int i, QString s) { |
292 | if(i < NUM_OF_ATI) | 290 | if(i < NUM_OF_ATI) |
293 | ati_label_result[i]->setText(s); | 291 | ati_label_result[i]->setText(s); |
294 | } | 292 | } |
295 | 293 | ||
296 | //#include "modeminfo.moc" | 294 | //#include "modeminfo.moc" |