summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.cpp6
1 files changed, 1 insertions, 5 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp
index 6fea596..e6122ad 100644
--- a/noncore/unsupported/gsmtool/gsmtool.cpp
+++ b/noncore/unsupported/gsmtool/gsmtool.cpp
@@ -98,363 +98,359 @@ void GSMTool::doTabChanged()
98 timerid = -1; 98 timerid = -1;
99 } 99 }
100} 100}
101 101
102void GSMTool::timerEvent( QTimerEvent * ) 102void GSMTool::timerEvent( QTimerEvent * )
103{ 103{
104 OPInfo opi; 104 OPInfo opi;
105 105
106 opi = me->getCurrentOPInfo(); 106 opi = me->getCurrentOPInfo();
107 107
108 if (opi._numericName == NOT_SET) { 108 if (opi._numericName == NOT_SET) {
109 NetStatText->setText("No network"); 109 NetStatText->setText("No network");
110 NetworkLabel->setEnabled(FALSE); 110 NetworkLabel->setEnabled(FALSE);
111 NetworkText->setEnabled(FALSE); 111 NetworkText->setEnabled(FALSE);
112 NetworkText->setText(""); 112 NetworkText->setText("");
113 SigStrText->setEnabled(FALSE); 113 SigStrText->setEnabled(FALSE);
114 SigStrText->setText(""); 114 SigStrText->setText("");
115 dB->setEnabled(FALSE); 115 dB->setEnabled(FALSE);
116 SigStrLabel->setEnabled(FALSE); 116 SigStrLabel->setEnabled(FALSE);
117 } else { 117 } else {
118 // FIXME: Add 'roaming' info from AT+CFUN 118 // FIXME: Add 'roaming' info from AT+CFUN
119 qDebug("network"); 119 qDebug("network");
120 NetStatText->setText("Registered"); 120 NetStatText->setText("Registered");
121 NetworkLabel->setEnabled(TRUE); 121 NetworkLabel->setEnabled(TRUE);
122 NetworkText->setEnabled(TRUE); 122 NetworkText->setEnabled(TRUE);
123 NetworkText->setText(opi._longName.c_str()); 123 NetworkText->setText(opi._longName.c_str());
124 SigStrText->setEnabled(TRUE); 124 SigStrText->setEnabled(TRUE);
125 125
126 qDebug("get sig str"); 126 qDebug("get sig str");
127 int csq = me->getSignalStrength(); 127 int csq = me->getSignalStrength();
128 if (csq == 0) { 128 if (csq == 0) {
129 SigStrText->setText("<= -113"); 129 SigStrText->setText("<= -113");
130 dB->setEnabled(TRUE); 130 dB->setEnabled(TRUE);
131 SigStrLabel->setEnabled(TRUE); 131 SigStrLabel->setEnabled(TRUE);
132 } else if (csq == 99) { 132 } else if (csq == 99) {
133 SigStrText->setText("Unknown"); 133 SigStrText->setText("Unknown");
134 dB->setEnabled(FALSE); 134 dB->setEnabled(FALSE);
135 SigStrLabel->setEnabled(FALSE); 135 SigStrLabel->setEnabled(FALSE);
136 } else { 136 } else {
137 char buf[6]; 137 char buf[6];
138 sprintf(buf, "%d", -113 + (2*csq)); 138 sprintf(buf, "%d", -113 + (2*csq));
139 SigStrText->setText(buf); 139 SigStrText->setText(buf);
140 dB->setEnabled(TRUE); 140 dB->setEnabled(TRUE);
141 SigStrLabel->setEnabled(TRUE); 141 SigStrLabel->setEnabled(TRUE);
142 } 142 }
143 } 143 }
144} 144}
145 145
146void GSMTool::doSMSStoreChanged() 146void GSMTool::doSMSStoreChanged()
147{ 147{
148 const char *storename = SMSStoreList->currentText().ascii(); 148 const char *storename = SMSStoreList->currentText().ascii();
149 qDebug("Store Changed to '%s'", storename); 149 qDebug("Store Changed to '%s'", storename);
150 if (!strcmp(storename, "None")) { 150 if (!strcmp(storename, "None")) {
151 sms_store = NULL; 151 sms_store = NULL;
152 } else try { 152 } else try {
153 sms_store = new SortedSMSStore(me->getSMSStore(storename)); 153 sms_store = new SortedSMSStore(me->getSMSStore(storename));
154 sms_store->setSortOrder(ByIndex); 154 sms_store->setSortOrder(ByIndex);
155 155
156 qDebug("got store of size %d", sms_store->size()); 156 qDebug("got store of size %d", sms_store->size());
157 } catch (GsmException) { 157 } catch (GsmException) {
158 sms_store = NULL; 158 sms_store = NULL;
159 qDebug("get store failed"); 159 qDebug("get store failed");
160 } 160 }
161 161
162 SMSList->setEnabled(!(sms_store == NULL)); 162 SMSList->setEnabled(!(sms_store == NULL));
163 NewSMSSaveButton->setEnabled(!(sms_store == NULL)); 163 NewSMSSaveButton->setEnabled(!(sms_store == NULL));
164 doSMSTypeChanged(); 164 doSMSTypeChanged();
165} 165}
166 166
167void GSMTool::doSMSTypeChanged() 167void GSMTool::doSMSTypeChanged()
168{ 168{
169 int direction = SMSViewType->currentItem(); 169 int direction = SMSViewType->currentItem();
170 qDebug("direction %s\n", direction?"outgoing":"incoming"); 170 qDebug("direction %s\n", direction?"outgoing":"incoming");
171 if (direction) 171 if (direction)
172 SMSSendButton->setText("Send"); 172 SMSSendButton->setText("Send");
173 else 173 else
174 SMSSendButton->setText("Reply"); 174 SMSSendButton->setText("Reply");
175 175
176 SMSList->clear(); 176 SMSList->clear();
177 doSelectedSMSChanged(NULL); 177 doSelectedSMSChanged(NULL);
178 178
179 if (sms_store == NULL) 179 if (sms_store == NULL)
180 return; 180 return;
181 for (SortedSMSStore::iterator e = sms_store->begin(); 181 for (SortedSMSStore::iterator e = sms_store->begin();
182 e != sms_store->end(); e++) { 182 e != sms_store->end(); e++) {
183 // qDebug("Message %d", i); 183 // qDebug("Message %d", i);
184 qDebug("Is%sempty", e->empty()?" ":" not "); 184 qDebug("Is%sempty", e->empty()?" ":" not ");
185 if (e->empty()) 185 if (e->empty())
186 continue; 186 continue;
187 187
188 qDebug("Status %d", e->status()); 188 qDebug("Status %d", e->status());
189 SMSMessageRef message = e->message(); 189 SMSMessageRef message = e->message();
190 qDebug("Got message."); 190 qDebug("Got message.");
191 191
192 // qDebug(message->toString().c_str()); 192 // qDebug(message->toString().c_str());
193 if (direction == message->messageType()) { 193 if (direction == message->messageType()) {
194 qDebug("yes\n"); 194 qDebug("yes\n");
195 char buf[3]; 195 char buf[3];
196 snprintf(buf, 3, "%d", e->index()); 196 snprintf(buf, 3, "%d", e->index());
197 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf); 197 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf);
198 } 198 }
199 } 199 }
200} 200}
201 201
202void GSMTool::doSelectedSMSChanged(QListViewItem *item) 202void GSMTool::doSelectedSMSChanged(QListViewItem *item)
203{ 203{
204 qDebug("message changed\n"); 204 qDebug("message changed\n");
205 205
206 if (!item || sms_store == NULL) { 206 if (!item || sms_store == NULL) {
207 SMSText->setText(""); 207 SMSText->setText("");
208 SMSText->setEnabled(FALSE); 208 SMSText->setEnabled(FALSE);
209 SMSDeleteButton->setEnabled(FALSE); 209 SMSDeleteButton->setEnabled(FALSE);
210 SMSSendButton->setEnabled(FALSE); 210 SMSSendButton->setEnabled(FALSE);
211 return; 211 return;
212 } 212 }
213 /* ARGH. This sucks. Surely there's an app-private pointer in the 213 /* ARGH. This sucks. Surely there's an app-private pointer in the
214 QListViewItem that I've failed to notice? 214 QListViewItem that I've failed to notice?
215 215
216 SMSMessageRef message = *(SMSMessageRef*)item->private; 216 SMSMessageRef message = *(SMSMessageRef*)item->private;
217 */ 217 */
218 qDebug("item %p\n", item); 218 qDebug("item %p\n", item);
219 219
220 qDebug("text(2) is %s\n", item->text(2).ascii()); 220 qDebug("text(2) is %s\n", item->text(2).ascii());
221 int index = atoi(item->text(2).ascii()); 221 int index = atoi(item->text(2).ascii());
222 qDebug("index %d\n", index); 222 qDebug("index %d\n", index);
223 SMSMessageRef message = sms_store->find(index)->message(); 223 SMSMessageRef message = sms_store->find(index)->message();
224 224
225 SMSText->setText(message->userData().c_str()); 225 SMSText->setText(message->userData().c_str());
226 SMSText->setEnabled(TRUE); 226 SMSText->setEnabled(TRUE);
227 SMSDeleteButton->setEnabled(TRUE); 227 SMSDeleteButton->setEnabled(TRUE);
228 SMSSendButton->setEnabled(TRUE); 228 SMSSendButton->setEnabled(TRUE);
229 229
230} 230}
231 231
232void GSMTool::doSMSSendButton() 232void GSMTool::doSMSSendButton()
233{ 233{
234 qDebug("SMSSendButton"); 234 qDebug("SMSSendButton");
235 235
236 QListViewItem *item = SMSList->currentItem(); 236 QListViewItem *item = SMSList->currentItem();
237 if (!item) 237 if (!item)
238 return; 238 return;
239 239
240 int index = atoi(item->text(2).ascii()); 240 int index = atoi(item->text(2).ascii());
241 qDebug("index %d\n", index); 241 qDebug("index %d\n", index);
242 242
243 int direction = SMSViewType->currentItem(); 243 int direction = SMSViewType->currentItem();
244 qDebug("direction %s\n", direction?"outgoing":"incoming"); 244 qDebug("direction %s\n", direction?"outgoing":"incoming");
245 245
246 SMSMessageRef message = sms_store->find(index)->message(); 246 SMSMessageRef message = sms_store->find(index)->message();
247 247
248 if (direction) 248 if (direction)
249 NewSMSText->setText(message->userData().c_str()); 249 NewSMSText->setText(message->userData().c_str());
250 else 250 else
251 NewSMSText->setText(""); 251 NewSMSText->setText("");
252 NewSMSToBox->insertItem(message->address()._number.c_str(), 0); 252 NewSMSToBox->insertItem(message->address()._number.c_str(), 0);
253 TabWidget2->setCurrentPage(3); 253 TabWidget2->setCurrentPage(3);
254 254
255} 255}
256 256
257void GSMTool::doNewSMSClearButton() 257void GSMTool::doNewSMSClearButton()
258{ 258{
259 NewSMSText->setText(""); 259 NewSMSText->setText("");
260} 260}
261 261
262void GSMTool::doNewSMSSaveButton() 262void GSMTool::doNewSMSSaveButton()
263{ 263{
264 qDebug("NewSMSSaveButton"); 264 qDebug("NewSMSSaveButton");
265 const char *msgtext = strdup(NewSMSText->text().local8Bit()); 265 const char *msgtext = strdup(NewSMSText->text().local8Bit());
266 const char *dest = NewSMSToBox->currentText().ascii(); 266 const char *dest = NewSMSToBox->currentText().ascii();
267 267
268 NewSMSStatusLabel->setText("Sending..."); 268 NewSMSStatusLabel->setText("Sending...");
269 me->setMessageService(1); 269 me->setMessageService(1);
270 270
271 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest); 271 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest);
272 272
273 SMSMessageRef m = new SMSSubmitMessage (msgtext, dest); 273 SMSMessageRef m = new SMSSubmitMessage (msgtext, dest);
274 sms_store->insert(m); 274 sms_store->insert(m);
275 free((void *)msgtext); 275 free((void *)msgtext);
276 276
277} 277}
278void GSMTool::doNewSMSSendButton() 278void GSMTool::doNewSMSSendButton()
279{ 279{
280 const char *msgtext = strdup(NewSMSText->text().local8Bit()); 280 const char *msgtext = strdup(NewSMSText->text().local8Bit());
281 const char *dest = NewSMSToBox->currentText().ascii(); 281 const char *dest = NewSMSToBox->currentText().ascii();
282 282
283 NewSMSStatusLabel->setText("Sending..."); 283 NewSMSStatusLabel->setText("Sending...");
284 me->setMessageService(1); 284 me->setMessageService(1);
285 285
286 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest); 286 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest);
287 287
288 SMSSubmitMessage m(msgtext, dest); 288 SMSSubmitMessage m(msgtext, dest);
289 try { 289 try {
290 Ref<SMSMessage> ackPDU;
291 m.setAt(new GsmAt(*me)); 290 m.setAt(new GsmAt(*me));
292 m.send(ackPDU); 291 m.send();
293 292
294 // print acknowledgement if available
295 if (! ackPDU.isnull())
296 cout << ackPDU->toString();
297 NewSMSStatusLabel->setText("Message sent."); 293 NewSMSStatusLabel->setText("Message sent.");
298 } catch (GsmException &ge) { 294 } catch (GsmException &ge) {
299 NewSMSStatusLabel->setText("Failed."); 295 NewSMSStatusLabel->setText("Failed.");
300 qDebug(ge.what()); 296 qDebug(ge.what());
301 } 297 }
302 free((void *)msgtext); 298 free((void *)msgtext);
303 299
304 300
305} 301}
306 302
307 303
308void GSMTool::doSMSDeleteButton() 304void GSMTool::doSMSDeleteButton()
309{ 305{
310 QListViewItem *item = SMSList->currentItem(); 306 QListViewItem *item = SMSList->currentItem();
311 if (!item) 307 if (!item)
312 return; 308 return;
313 309
314 int index = atoi(item->text(2).ascii()); 310 int index = atoi(item->text(2).ascii());
315 qDebug("delete SMS with index %d\n", index); 311 qDebug("delete SMS with index %d\n", index);
316 312
317 313
318 314
319 SortedSMSStore::iterator e = sms_store->find(index); 315 SortedSMSStore::iterator e = sms_store->find(index);
320 316
321 if (e != sms_store->end()) { 317 if (e != sms_store->end()) {
322 qDebug("message is %s\n", e->message()->userData().c_str()); 318 qDebug("message is %s\n", e->message()->userData().c_str());
323 sms_store->erase(e); 319 sms_store->erase(e);
324 320
325 } 321 }
326 doSMSTypeChanged(); 322 doSMSTypeChanged();
327} 323}
328 324
329void GSMTool::doScanButton() 325void GSMTool::doScanButton()
330{ 326{
331 qDebug("ScanButton"); 327 qDebug("ScanButton");
332 328
333 NetworkList->setEnabled(FALSE); 329 NetworkList->setEnabled(FALSE);
334 AvailNetsLabel->setEnabled(FALSE); 330 AvailNetsLabel->setEnabled(FALSE);
335 NetworkList->clear(); 331 NetworkList->clear();
336 new QListViewItem(NetworkList, "Scanning..."); 332 new QListViewItem(NetworkList, "Scanning...");
337 333
338 vector<OPInfo> opis; 334 vector<OPInfo> opis;
339 335
340 try { 336 try {
341 opis = me->getAvailableOPInfo(); 337 opis = me->getAvailableOPInfo();
342 } catch (GsmException) { 338 } catch (GsmException) {
343 NetworkList->clear(); 339 NetworkList->clear();
344 new QListViewItem(NetworkList, "Scan failed..."); 340 new QListViewItem(NetworkList, "Scan failed...");
345 return; 341 return;
346 } 342 }
347 343
348 NetworkList->clear(); 344 NetworkList->clear();
349 for (vector<OPInfo>::iterator i = opis.begin(); i != opis.end(); ++i) { 345 for (vector<OPInfo>::iterator i = opis.begin(); i != opis.end(); ++i) {
350 char *statustext; 346 char *statustext;
351 switch (i->_status) { 347 switch (i->_status) {
352 348
353 case UnknownOPStatus: 349 case UnknownOPStatus:
354 statustext = "unknown"; 350 statustext = "unknown";
355 break; 351 break;
356 352
357 case CurrentOPStatus: 353 case CurrentOPStatus:
358 statustext = "current"; 354 statustext = "current";
359 break; 355 break;
360 356
361 case AvailableOPStatus: 357 case AvailableOPStatus:
362 statustext = "available"; 358 statustext = "available";
363 break; 359 break;
364 360
365 case ForbiddenOPStatus: 361 case ForbiddenOPStatus:
366 statustext = "forbidden"; 362 statustext = "forbidden";
367 break; 363 break;
368 364
369 default: 365 default:
370 statustext = "(ERROR)"; 366 statustext = "(ERROR)";
371 } 367 }
372 char num[7]; 368 char num[7];
373 snprintf(num, 6, "%d", i->_numericName); 369 snprintf(num, 6, "%d", i->_numericName);
374 new QListViewItem(NetworkList, i->_longName.c_str(), statustext, num, i->_shortName.c_str()); 370 new QListViewItem(NetworkList, i->_longName.c_str(), statustext, num, i->_shortName.c_str());
375 } 371 }
376 NetworkList->setEnabled(TRUE); 372 NetworkList->setEnabled(TRUE);
377 AvailNetsLabel->setEnabled(TRUE); 373 AvailNetsLabel->setEnabled(TRUE);
378} 374}
379/* 375/*
380 * A simple slot... not very interesting. 376 * A simple slot... not very interesting.
381 */ 377 */
382void GSMTool::doConnectButton() 378void GSMTool::doConnectButton()
383{ 379{
384 gsmlib::Port *port; 380 gsmlib::Port *port;
385 381
386 speed_t rate; 382 speed_t rate;
387 devicename = strdup(DeviceName->currentText().local8Bit().data()); 383 devicename = strdup(DeviceName->currentText().local8Bit().data());
388 rate = baudrates[BaudRate->currentItem()]; 384 rate = baudrates[BaudRate->currentItem()];
389 385
390 qDebug("Connect Button Pressed"); 386 qDebug("Connect Button Pressed");
391 MfrText->setText("Opening..."); 387 MfrText->setText("Opening...");
392 ModelText->setText(""); 388 ModelText->setText("");
393 RevisionText->setText(""); 389 RevisionText->setText("");
394 SerialText->setText(""); 390 SerialText->setText("");
395 391
396 setConnected(FALSE); 392 setConnected(FALSE);
397 if (me) { 393 if (me) {
398 me = NULL; 394 me = NULL;
399 } 395 }
400 396
401 if (lockDevice()) { 397 if (lockDevice()) {
402 qDebug("lockDevice() failed\n"); 398 qDebug("lockDevice() failed\n");
403 MfrText->setText("Lock port failed"); 399 MfrText->setText("Lock port failed");
404 }; 400 };
405 401
406 qDebug("Device name is %s\n", devicename); 402 qDebug("Device name is %s\n", devicename);
407 403
408 try { 404 try {
409 port = new UnixSerialPort(devicename, rate, DEFAULT_INIT_STRING, 0); 405 port = new UnixSerialPort(devicename, rate, DEFAULT_INIT_STRING, 0);
410 } catch (GsmException) { 406 } catch (GsmException) {
411 qDebug("port failed"); 407 qDebug("port failed");
412 MfrText->setText("Open port failed"); 408 MfrText->setText("Open port failed");
413 return; 409 return;
414 } 410 }
415 MfrText->setText("Initialising..."); 411 MfrText->setText("Initialising...");
416 qDebug("got port"); 412 qDebug("got port");
417 try { 413 try {
418 me = new MeTa(port); 414 me = new MeTa(port);
419 } catch (GsmException) { 415 } catch (GsmException) {
420 qDebug("meta failed"); 416 qDebug("meta failed");
421 MfrText->setText("Initialise GSM unit failed"); 417 MfrText->setText("Initialise GSM unit failed");
422 me = NULL; 418 me = NULL;
423 unlockDevice(); 419 unlockDevice();
424 return; 420 return;
425 } 421 }
426 422
427 qDebug("Opened"); 423 qDebug("Opened");
428 424
429 MEInfo ifo; 425 MEInfo ifo;
430 426
431 MfrText->setText("Querying..."); 427 MfrText->setText("Querying...");
432 428
433 try { 429 try {
434 ifo = me->getMEInfo(); 430 ifo = me->getMEInfo();
435 } catch (GsmException) { 431 } catch (GsmException) {
436 qDebug("getMEInfo failed"); 432 qDebug("getMEInfo failed");
437 MfrText->setText("Query GSM unit failed"); 433 MfrText->setText("Query GSM unit failed");
438 me = NULL; 434 me = NULL;
439 unlockDevice(); 435 unlockDevice();
440 return; 436 return;
441 } 437 }
442 438
443 MfrText->setText(ifo._manufacturer.c_str()); 439 MfrText->setText(ifo._manufacturer.c_str());
444 ModelText->setText(ifo._model.c_str()); 440 ModelText->setText(ifo._model.c_str());
445 RevisionText->setText(ifo._revision.c_str()); 441 RevisionText->setText(ifo._revision.c_str());
446 SerialText->setText(ifo._serialNumber.c_str()); 442 SerialText->setText(ifo._serialNumber.c_str());
447 setConnected(TRUE); 443 setConnected(TRUE);
448 444
449 SMSStoreList->clear(); 445 SMSStoreList->clear();
450 SMSStoreList->insertItem("None"); 446 SMSStoreList->insertItem("None");
451 447
452 vector<string> storenames = me->getSMSStoreNames(); 448 vector<string> storenames = me->getSMSStoreNames();
453 449
454 for (vector<string>::iterator i = storenames.begin(); i != storenames.end(); ++i) { 450 for (vector<string>::iterator i = storenames.begin(); i != storenames.end(); ++i) {
455 SMSStoreList->insertItem(i->c_str()); 451 SMSStoreList->insertItem(i->c_str());
456 } 452 }
457 SMSList->clear(); 453 SMSList->clear();
458 SMSText->setText(""); 454 SMSText->setText("");
459 sms_store = NULL; 455 sms_store = NULL;
460} 456}