summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/modeminfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/modeminfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.cpp65
1 files changed, 42 insertions, 23 deletions
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp
index dbb26db..df0bf9b 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.cpp
+++ b/noncore/settings/networksettings/ppp/modeminfo.cpp
@@ -21,22 +21,26 @@
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <unistd.h> 27#include "modeminfo.h"
28#include "modem.h"
29
30/* OPIE */
31#include <qpe/qpeapplication.h>
32
33/* QT */
28#include <qregexp.h> 34#include <qregexp.h>
29#include <qlayout.h> 35#include <qlayout.h>
30// #include <kwin.h>
31// #include <kmessagebox.h>
32// #include <kapplication.h>
33#include <qmessagebox.h> 36#include <qmessagebox.h>
34#include <qapplication.h> 37#include <qapplication.h>
35#include "modeminfo.h" 38
36#include "modem.h" 39/* STD */
40#include <unistd.h>
37 41
38ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) 42ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
39 : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), 43 : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder),
40 _modem(mo) 44 _modem(mo)
41{ 45{
42 setCaption(QObject::tr("ATI Query")); 46 setCaption(QObject::tr("ATI Query"));
@@ -90,60 +94,67 @@ ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
90 timeout_timer->start(15000,TRUE); // 15 secs single shot 94 timeout_timer->start(15000,TRUE); // 15 secs single shot
91 QTimer::singleShot(500, this, SLOT(init())); 95 QTimer::singleShot(500, this, SLOT(init()));
92 96
93} 97}
94 98
95 99
96void ModemTransfer::ati_done() { 100void ModemTransfer::ati_done()
101{
97 scripttimer->stop(); 102 scripttimer->stop();
98 timeout_timer->stop(); 103 timeout_timer->stop();
99 _modem->closetty(); 104 _modem->closetty();
100 _modem->unlockdevice(); 105 _modem->unlockdevice();
101 hide(); 106 hide();
102 107
103 // open the result window 108 // open the result window
104 ModemInfo *mi = new ModemInfo(this); 109 ModemInfo *mi = new ModemInfo(this);
105 for(int i = 0; i < NUM_OF_ATI; i++) 110 for(int i = 0; i < NUM_OF_ATI; i++)
106 mi->setAtiString(i, ati_query_strings[i]); 111 mi->setAtiString(i, ati_query_strings[i]);
107 mi->showMaximized(); 112
108 mi->exec(); 113 QPEApplication::execDialog( mi );
109 delete mi; 114 delete mi;
110 115
111 accept(); 116 accept();
112} 117}
113 118
114 119
115void ModemTransfer::time_out_slot() { 120void ModemTransfer::time_out_slot()
121{
116 timeout_timer->stop(); 122 timeout_timer->stop();
117 scripttimer->stop(); 123 scripttimer->stop();
118 124
119 QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); 125 QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out."));
120 reject(); 126 reject();
121} 127}
122 128
123 129
124void ModemTransfer::init() { 130void ModemTransfer::init()
131{
125 132
126 qApp->processEvents(); 133 qApp->processEvents();
127 134
128 int lock = _modem->lockdevice(); 135 int lock = _modem->lockdevice();
129 if (lock == 1) { 136 if (lock == 1)
137 {
130 138
131 statusBar->setText(QObject::tr("Modem device is locked.")); 139 statusBar->setText(QObject::tr("Modem device is locked."));
132 return; 140 return;
133 } 141 }
134 142
135 if (lock == -1) { 143 if (lock == -1)
144 {
136 145
137 statusBar->setText(QObject::tr("Unable to create modem lock file.")); 146 statusBar->setText(QObject::tr("Unable to create modem lock file."));
138 return; 147 return;
139 } 148 }
140 149
141 150
142 if(_modem->opentty()) { 151 if(_modem->opentty())
143 if(_modem->hangup()) { 152 {
153 if(_modem->hangup())
154 {
144 usleep(100000); // wait 0.1 secs 155 usleep(100000); // wait 0.1 secs
145 _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... 156 _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ...
146 157
147 statusBar->setText(QObject::tr("Modem Ready")); 158 statusBar->setText(QObject::tr("Modem Ready"));
148 qApp->processEvents(); 159 qApp->processEvents();
149 usleep(100000); // wait 0.1 secs 160 usleep(100000); // wait 0.1 secs
@@ -162,17 +173,19 @@ void ModemTransfer::init() {
162 statusBar->setText(_modem->modemMessage()); 173 statusBar->setText(_modem->modemMessage());
163 step = 99; // wait until cancel is pressed 174 step = 99; // wait until cancel is pressed
164 _modem->unlockdevice(); 175 _modem->unlockdevice();
165} 176}
166 177
167 178
168void ModemTransfer::do_script() { 179void ModemTransfer::do_script()
180{
169 QString msg; 181 QString msg;
170 QString query; 182 QString query;
171 183
172 switch(step) { 184 switch(step)
185 {
173 case 0: 186 case 0:
174 readtty(); 187 readtty();
175 statusBar->setText("ATI..."); 188 statusBar->setText("ATI...");
176 progressBar->setProgress( progressBar->progress() + 1); 189 progressBar->setProgress( progressBar->progress() + 1);
177 _modem->writeLine("ATI\n"); 190 _modem->writeLine("ATI\n");
178 break; 191 break;
@@ -196,18 +209,20 @@ void ModemTransfer::do_script() {
196 readtty(); 209 readtty();
197 ati_done(); 210 ati_done();
198 } 211 }
199 step++; 212 step++;
200} 213}
201 214
202void ModemTransfer::readChar(unsigned char c) { 215void ModemTransfer::readChar(unsigned char c)
216{
203 if(readbuffer.length() < 255) 217 if(readbuffer.length() < 255)
204 readbuffer += c; 218 readbuffer += c;
205} 219}
206 220
207void ModemTransfer::readtty() { 221void ModemTransfer::readtty()
222{
208 223
209 if (step == 0) 224 if (step == 0)
210 return; 225 return;
211 226
212 readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r 227 readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r
213 readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white 228 readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white
@@ -217,13 +232,14 @@ void ModemTransfer::readtty() {
217 ati_query_strings[step-1] = readbuffer.copy(); 232 ati_query_strings[step-1] = readbuffer.copy();
218 233
219 readbuffer = ""; 234 readbuffer = "";
220} 235}
221 236
222 237
223void ModemTransfer::cancelbutton() { 238void ModemTransfer::cancelbutton()
239{
224 scripttimer->stop(); 240 scripttimer->stop();
225 _modem->stop(); 241 _modem->stop();
226 timeout_timer->stop(); 242 timeout_timer->stop();
227 243
228 statusBar->setText(QObject::tr("One moment please...")); 244 statusBar->setText(QObject::tr("One moment please..."));
229 qApp->processEvents(); 245 qApp->processEvents();
@@ -233,13 +249,14 @@ void ModemTransfer::cancelbutton() {
233 _modem->closetty(); 249 _modem->closetty();
234 _modem->unlockdevice(); 250 _modem->unlockdevice();
235 reject(); 251 reject();
236} 252}
237 253
238 254
239void ModemTransfer::closeEvent( QCloseEvent *e ) { 255void ModemTransfer::closeEvent( QCloseEvent *e )
256{
240 cancelbutton(); 257 cancelbutton();
241 e->accept(); 258 e->accept();
242} 259}
243 260
244 261
245ModemInfo::ModemInfo(QWidget *parent, const char* name) 262ModemInfo::ModemInfo(QWidget *parent, const char* name)
@@ -251,13 +268,14 @@ ModemInfo::ModemInfo(QWidget *parent, const char* name)
251 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 268 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
252 269
253 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 270 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
254 271
255 QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); 272 QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5);
256 tl->addLayout(l1, 1); 273 tl->addLayout(l1, 1);
257 for(int i = 0 ; i < NUM_OF_ATI ; i++) { 274 for(int i = 0 ; i < NUM_OF_ATI ; i++)
275 {
258 276
259 label_text = ""; 277 label_text = "";
260 if ( i == 0) 278 if ( i == 0)
261 label_text.sprintf("ATI :"); 279 label_text.sprintf("ATI :");
262 else 280 else
263 label_text.sprintf("ATI %d:", i ); 281 label_text.sprintf("ATI %d:", i );
@@ -283,12 +301,13 @@ ModemInfo::ModemInfo(QWidget *parent, const char* name)
283 l2->addWidget(ok); 301 l2->addWidget(ok);
284 302
285 setMinimumSize(sizeHint()); 303 setMinimumSize(sizeHint());
286} 304}
287 305
288 306
289void ModemInfo::setAtiString(int i, QString s) { 307void ModemInfo::setAtiString(int i, QString s)
308{
290 if(i < NUM_OF_ATI) 309 if(i < NUM_OF_ATI)
291 ati_label_result[i]->setText(s); 310 ati_label_result[i]->setText(s);
292} 311}
293 312
294//#include "modeminfo.moc" 313//#include "modeminfo.moc"