summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp
index e6122ad..5940b0e 100644
--- a/noncore/unsupported/gsmtool/gsmtool.cpp
+++ b/noncore/unsupported/gsmtool/gsmtool.cpp
@@ -1,456 +1,457 @@
1#include "gsmtool.h" 1#include "gsmtool.h"
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qtabwidget.h> 6#include <qtabwidget.h>
7#include <qlistview.h> 7#include <qlistview.h>
8#include <qtextbrowser.h> 8#include <qtextbrowser.h>
9#include <qmultilineedit.h> 9#include <qmultilineedit.h>
10 10
11#include <termios.h> 11#include <termios.h>
12 12
13#include <gsmlib/gsm_me_ta.h> 13#include <gsmlib/gsm_me_ta.h>
14#include <gsmlib/gsm_unix_serial.h> 14#include <gsmlib/gsm_unix_serial.h>
15#include <gsmlib/gsm_sms.h> 15#include <gsmlib/gsm_sms.h>
16#include <gsmlib/gsm_sorted_sms_store.h> 16#include <gsmlib/gsm_sorted_sms_store.h>
17 17
18using namespace gsmlib; 18using namespace gsmlib;
19 19
20 20
21/* 21/*
22 * Constructs a GSMTool which is a child of 'parent', with the 22 * Constructs a GSMTool which is a child of 'parent', with the
23 * name 'name' and widget flags set to 'f' 23 * name 'name' and widget flags set to 'f'
24 */ 24 */
25GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) 25GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl )
26 : GSMToolBase( parent, name, fl ) 26 : GSMToolBase( parent, name, fl )
27{ 27{
28 devicelocked = 0; 28 devicelocked = 0;
29 me = NULL; 29 me = NULL;
30 sms_store = NULL; 30 sms_store = NULL;
31 setConnected(FALSE); 31 setConnected(FALSE);
32 /* FIXME: Persistent settings for device/baudrate */ 32 /* FIXME: Persistent settings for device/baudrate */
33 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); 33 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton()));
34 connect(SMSDeleteButton, SIGNAL(clicked()), this, SLOT(doSMSDeleteButton())); 34 connect(SMSDeleteButton, SIGNAL(clicked()), this, SLOT(doSMSDeleteButton()));
35 connect(SMSSendButton, SIGNAL(clicked()), this, SLOT(doSMSSendButton())); 35 connect(SMSSendButton, SIGNAL(clicked()), this, SLOT(doSMSSendButton()));
36 connect(NewSMSClearButton, SIGNAL(clicked()), this, SLOT(doNewSMSClearButton())); 36 connect(NewSMSClearButton, SIGNAL(clicked()), this, SLOT(doNewSMSClearButton()));
37 connect(NewSMSSaveButton, SIGNAL(clicked()), this, SLOT(doNewSMSSaveButton())); 37 connect(NewSMSSaveButton, SIGNAL(clicked()), this, SLOT(doNewSMSSaveButton()));
38 connect(NewSMSSendButton, SIGNAL(clicked()), this, SLOT(doNewSMSSendButton())); 38 connect(NewSMSSendButton, SIGNAL(clicked()), this, SLOT(doNewSMSSendButton()));
39 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); 39 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton()));
40 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); 40 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged()));
41 connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged())); 41 connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged()));
42 connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged())); 42 connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged()));
43 connect(SMSList, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(doSelectedSMSChanged(QListViewItem *))); 43 connect(SMSList, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(doSelectedSMSChanged(QListViewItem *)));
44 timerid = -1; // Is this not possible normally? 44 timerid = -1; // Is this not possible normally?
45} 45}
46 46
47/* 47/*
48 * Destroys the object and frees any allocated resources 48 * Destroys the object and frees any allocated resources
49 */ 49 */
50GSMTool::~GSMTool() 50GSMTool::~GSMTool()
51{ 51{
52 // no need to delete child widgets, Qt does it all for us 52 // no need to delete child widgets, Qt does it all for us
53 if (devicelocked) 53 if (devicelocked)
54 unlockDevice(); 54 unlockDevice();
55} 55}
56const speed_t GSMTool::baudrates[12] = { 56const speed_t GSMTool::baudrates[12] = {
57 B300, B600, B1200, B2400, B4800, B9600, B19200, 57 B300, B600, B1200, B2400, B4800, B9600, B19200,
58 B38400, B57600, B115200, B230400, B460800 58 B38400, B57600, B115200, B230400, B460800
59}; 59};
60 60
61int GSMTool::lockDevice( ) 61int GSMTool::lockDevice( )
62{ 62{
63 devicelocked = 1; 63 devicelocked = 1;
64 /* FIXME */ 64 /* FIXME */
65 return 0; 65 return 0;
66} 66}
67 67
68void GSMTool::unlockDevice( ) 68void GSMTool::unlockDevice( )
69{ 69{
70 devicelocked = 0; 70 devicelocked = 0;
71} 71}
72 72
73void GSMTool::setConnected( bool conn ) 73void GSMTool::setConnected( bool conn )
74{ 74{
75 TabWidget2->setTabEnabled(tab_2, conn); 75 TabWidget2->setTabEnabled(tab_2, conn);
76 TabWidget2->setTabEnabled(tab_3, conn); 76 TabWidget2->setTabEnabled(tab_3, conn);
77 TabWidget2->setTabEnabled(tab_4, conn); 77 //TabWidget2->setTabEnabled(tab_4, conn);
78 NewSMSSendButton->setEnabled(conn);
78 MfrLabel->setEnabled(conn); 79 MfrLabel->setEnabled(conn);
79 MfrText->setEnabled(conn); 80 MfrText->setEnabled(conn);
80 ModelLabel->setEnabled(conn); 81 ModelLabel->setEnabled(conn);
81 ModelText->setEnabled(conn); 82 ModelText->setEnabled(conn);
82 RevisionLabel->setEnabled(conn); 83 RevisionLabel->setEnabled(conn);
83 RevisionText->setEnabled(conn); 84 RevisionText->setEnabled(conn);
84 SerialLabel->setEnabled(conn); 85 SerialLabel->setEnabled(conn);
85 SerialText->setEnabled(conn); 86 SerialText->setEnabled(conn);
86 87
87} 88}
88void GSMTool::doTabChanged() 89void GSMTool::doTabChanged()
89{ 90{
90 int index = TabWidget2->currentPageIndex(); 91 int index = TabWidget2->currentPageIndex();
91 qDebug("tab changed to %d", index); 92 qDebug("tab changed to %d", index);
92 93
93 if (index == 1) { 94 if (index == 1) {
94 timerid = startTimer(5000); 95 timerid = startTimer(5000);
95 timerEvent(NULL); 96 timerEvent(NULL);
96 } else if (timerid != -1) { 97 } else if (timerid != -1) {
97 killTimer(timerid); 98 killTimer(timerid);
98 timerid = -1; 99 timerid = -1;
99 } 100 }
100} 101}
101 102
102void GSMTool::timerEvent( QTimerEvent * ) 103void GSMTool::timerEvent( QTimerEvent * )
103{ 104{
104 OPInfo opi; 105 OPInfo opi;
105 106
106 opi = me->getCurrentOPInfo(); 107 opi = me->getCurrentOPInfo();
107 108
108 if (opi._numericName == NOT_SET) { 109 if (opi._numericName == NOT_SET) {
109 NetStatText->setText("No network"); 110 NetStatText->setText("No network");
110 NetworkLabel->setEnabled(FALSE); 111 NetworkLabel->setEnabled(FALSE);
111 NetworkText->setEnabled(FALSE); 112 NetworkText->setEnabled(FALSE);
112 NetworkText->setText(""); 113 NetworkText->setText("");
113 SigStrText->setEnabled(FALSE); 114 SigStrText->setEnabled(FALSE);
114 SigStrText->setText(""); 115 SigStrText->setText("");
115 dB->setEnabled(FALSE); 116 dB->setEnabled(FALSE);
116 SigStrLabel->setEnabled(FALSE); 117 SigStrLabel->setEnabled(FALSE);
117 } else { 118 } else {
118 // FIXME: Add 'roaming' info from AT+CFUN 119 // FIXME: Add 'roaming' info from AT+CFUN
119 qDebug("network"); 120 qDebug("network");
120 NetStatText->setText("Registered"); 121 NetStatText->setText("Registered");
121 NetworkLabel->setEnabled(TRUE); 122 NetworkLabel->setEnabled(TRUE);
122 NetworkText->setEnabled(TRUE); 123 NetworkText->setEnabled(TRUE);
123 NetworkText->setText(opi._longName.c_str()); 124 NetworkText->setText(opi._longName.c_str());
124 SigStrText->setEnabled(TRUE); 125 SigStrText->setEnabled(TRUE);
125 126
126 qDebug("get sig str"); 127 qDebug("get sig str");
127 int csq = me->getSignalStrength(); 128 int csq = me->getSignalStrength();
128 if (csq == 0) { 129 if (csq == 0) {
129 SigStrText->setText("<= -113"); 130 SigStrText->setText("<= -113");
130 dB->setEnabled(TRUE); 131 dB->setEnabled(TRUE);
131 SigStrLabel->setEnabled(TRUE); 132 SigStrLabel->setEnabled(TRUE);
132 } else if (csq == 99) { 133 } else if (csq == 99) {
133 SigStrText->setText("Unknown"); 134 SigStrText->setText("Unknown");
134 dB->setEnabled(FALSE); 135 dB->setEnabled(FALSE);
135 SigStrLabel->setEnabled(FALSE); 136 SigStrLabel->setEnabled(FALSE);
136 } else { 137 } else {
137 char buf[6]; 138 char buf[6];
138 sprintf(buf, "%d", -113 + (2*csq)); 139 sprintf(buf, "%d", -113 + (2*csq));
139 SigStrText->setText(buf); 140 SigStrText->setText(buf);
140 dB->setEnabled(TRUE); 141 dB->setEnabled(TRUE);
141 SigStrLabel->setEnabled(TRUE); 142 SigStrLabel->setEnabled(TRUE);
142 } 143 }
143 } 144 }
144} 145}
145 146
146void GSMTool::doSMSStoreChanged() 147void GSMTool::doSMSStoreChanged()
147{ 148{
148 const char *storename = SMSStoreList->currentText().ascii(); 149 const char *storename = SMSStoreList->currentText().ascii();
149 qDebug("Store Changed to '%s'", storename); 150 qDebug("Store Changed to '%s'", storename);
150 if (!strcmp(storename, "None")) { 151 if (!strcmp(storename, "None")) {
151 sms_store = NULL; 152 sms_store = NULL;
152 } else try { 153 } else try {
153 sms_store = new SortedSMSStore(me->getSMSStore(storename)); 154 sms_store = new SortedSMSStore(me->getSMSStore(storename));
154 sms_store->setSortOrder(ByIndex); 155 sms_store->setSortOrder(ByIndex);
155 156
156 qDebug("got store of size %d", sms_store->size()); 157 qDebug("got store of size %d", sms_store->size());
157 } catch (GsmException) { 158 } catch (GsmException) {
158 sms_store = NULL; 159 sms_store = NULL;
159 qDebug("get store failed"); 160 qDebug("get store failed");
160 } 161 }
161 162
162 SMSList->setEnabled(!(sms_store == NULL)); 163 SMSList->setEnabled(!(sms_store == NULL));
163 NewSMSSaveButton->setEnabled(!(sms_store == NULL)); 164 NewSMSSaveButton->setEnabled(!(sms_store == NULL));
164 doSMSTypeChanged(); 165 doSMSTypeChanged();
165} 166}
166 167
167void GSMTool::doSMSTypeChanged() 168void GSMTool::doSMSTypeChanged()
168{ 169{
169 int direction = SMSViewType->currentItem(); 170 int direction = SMSViewType->currentItem();
170 qDebug("direction %s\n", direction?"outgoing":"incoming"); 171 qDebug("direction %s\n", direction?"outgoing":"incoming");
171 if (direction) 172 if (direction)
172 SMSSendButton->setText("Send"); 173 SMSSendButton->setText("Send");
173 else 174 else
174 SMSSendButton->setText("Reply"); 175 SMSSendButton->setText("Reply");
175 176
176 SMSList->clear(); 177 SMSList->clear();
177 doSelectedSMSChanged(NULL); 178 doSelectedSMSChanged(NULL);
178 179
179 if (sms_store == NULL) 180 if (sms_store == NULL)
180 return; 181 return;
181 for (SortedSMSStore::iterator e = sms_store->begin(); 182 for (SortedSMSStore::iterator e = sms_store->begin();
182 e != sms_store->end(); e++) { 183 e != sms_store->end(); e++) {
183 // qDebug("Message %d", i); 184 // qDebug("Message %d", i);
184 qDebug("Is%sempty", e->empty()?" ":" not "); 185 qDebug("Is%sempty", e->empty()?" ":" not ");
185 if (e->empty()) 186 if (e->empty())
186 continue; 187 continue;
187 188
188 qDebug("Status %d", e->status()); 189 qDebug("Status %d", e->status());
189 SMSMessageRef message = e->message(); 190 SMSMessageRef message = e->message();
190 qDebug("Got message."); 191 qDebug("Got message.");
191 192
192 // qDebug(message->toString().c_str()); 193 // qDebug(message->toString().c_str());
193 if (direction == message->messageType()) { 194 if (direction == message->messageType()) {
194 qDebug("yes\n"); 195 qDebug("yes\n");
195 char buf[3]; 196 char buf[3];
196 snprintf(buf, 3, "%d", e->index()); 197 snprintf(buf, 3, "%d", e->index());
197 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf); 198 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf);
198 } 199 }
199 } 200 }
200} 201}
201 202
202void GSMTool::doSelectedSMSChanged(QListViewItem *item) 203void GSMTool::doSelectedSMSChanged(QListViewItem *item)
203{ 204{
204 qDebug("message changed\n"); 205 qDebug("message changed\n");
205 206
206 if (!item || sms_store == NULL) { 207 if (!item || sms_store == NULL) {
207 SMSText->setText(""); 208 SMSText->setText("");
208 SMSText->setEnabled(FALSE); 209 SMSText->setEnabled(FALSE);
209 SMSDeleteButton->setEnabled(FALSE); 210 SMSDeleteButton->setEnabled(FALSE);
210 SMSSendButton->setEnabled(FALSE); 211 SMSSendButton->setEnabled(FALSE);
211 return; 212 return;
212 } 213 }
213 /* ARGH. This sucks. Surely there's an app-private pointer in the 214 /* ARGH. This sucks. Surely there's an app-private pointer in the
214 QListViewItem that I've failed to notice? 215 QListViewItem that I've failed to notice?
215 216
216 SMSMessageRef message = *(SMSMessageRef*)item->private; 217 SMSMessageRef message = *(SMSMessageRef*)item->private;
217 */ 218 */
218 qDebug("item %p\n", item); 219 qDebug("item %p\n", item);
219 220
220 qDebug("text(2) is %s\n", item->text(2).ascii()); 221 qDebug("text(2) is %s\n", item->text(2).ascii());
221 int index = atoi(item->text(2).ascii()); 222 int index = atoi(item->text(2).ascii());
222 qDebug("index %d\n", index); 223 qDebug("index %d\n", index);
223 SMSMessageRef message = sms_store->find(index)->message(); 224 SMSMessageRef message = sms_store->find(index)->message();
224 225
225 SMSText->setText(message->userData().c_str()); 226 SMSText->setText(message->userData().c_str());
226 SMSText->setEnabled(TRUE); 227 SMSText->setEnabled(TRUE);
227 SMSDeleteButton->setEnabled(TRUE); 228 SMSDeleteButton->setEnabled(TRUE);
228 SMSSendButton->setEnabled(TRUE); 229 SMSSendButton->setEnabled(TRUE);
229 230
230} 231}
231 232
232void GSMTool::doSMSSendButton() 233void GSMTool::doSMSSendButton()
233{ 234{
234 qDebug("SMSSendButton"); 235 qDebug("SMSSendButton");
235 236
236 QListViewItem *item = SMSList->currentItem(); 237 QListViewItem *item = SMSList->currentItem();
237 if (!item) 238 if (!item)
238 return; 239 return;
239 240
240 int index = atoi(item->text(2).ascii()); 241 int index = atoi(item->text(2).ascii());
241 qDebug("index %d\n", index); 242 qDebug("index %d\n", index);
242 243
243 int direction = SMSViewType->currentItem(); 244 int direction = SMSViewType->currentItem();
244 qDebug("direction %s\n", direction?"outgoing":"incoming"); 245 qDebug("direction %s\n", direction?"outgoing":"incoming");
245 246
246 SMSMessageRef message = sms_store->find(index)->message(); 247 SMSMessageRef message = sms_store->find(index)->message();
247 248
248 if (direction) 249 if (direction)
249 NewSMSText->setText(message->userData().c_str()); 250 NewSMSText->setText(message->userData().c_str());
250 else 251 else
251 NewSMSText->setText(""); 252 NewSMSText->setText("");
252 NewSMSToBox->insertItem(message->address()._number.c_str(), 0); 253 NewSMSToBox->insertItem(message->address()._number.c_str(), 0);
253 TabWidget2->setCurrentPage(3); 254 TabWidget2->setCurrentPage(3);
254 255
255} 256}
256 257
257void GSMTool::doNewSMSClearButton() 258void GSMTool::doNewSMSClearButton()
258{ 259{
259 NewSMSText->setText(""); 260 NewSMSText->setText("");
260} 261}
261 262
262void GSMTool::doNewSMSSaveButton() 263void GSMTool::doNewSMSSaveButton()
263{ 264{
264 qDebug("NewSMSSaveButton"); 265 qDebug("NewSMSSaveButton");
265 const char *msgtext = strdup(NewSMSText->text().local8Bit()); 266 const char *msgtext = strdup(NewSMSText->text().local8Bit());
266 const char *dest = NewSMSToBox->currentText().ascii(); 267 const char *dest = NewSMSToBox->currentText().ascii();
267 268
268 NewSMSStatusLabel->setText("Sending..."); 269 NewSMSStatusLabel->setText("Sending...");
269 me->setMessageService(1); 270 me->setMessageService(1);
270 271
271 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest); 272 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest);
272 273
273 SMSMessageRef m = new SMSSubmitMessage (msgtext, dest); 274 SMSMessageRef m = new SMSSubmitMessage (msgtext, dest);
274 sms_store->insert(m); 275 sms_store->insert(m);
275 free((void *)msgtext); 276 free((void *)msgtext);
276 277
277} 278}
278void GSMTool::doNewSMSSendButton() 279void GSMTool::doNewSMSSendButton()
279{ 280{
280 const char *msgtext = strdup(NewSMSText->text().local8Bit()); 281 const char *msgtext = strdup(NewSMSText->text().local8Bit());
281 const char *dest = NewSMSToBox->currentText().ascii(); 282 const char *dest = NewSMSToBox->currentText().ascii();
282 283
283 NewSMSStatusLabel->setText("Sending..."); 284 NewSMSStatusLabel->setText("Sending...");
284 me->setMessageService(1); 285 me->setMessageService(1);
285 286
286 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest); 287 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest);
287 288
288 SMSSubmitMessage m(msgtext, dest); 289 SMSSubmitMessage m(msgtext, dest);
289 try { 290 try {
290 m.setAt(new GsmAt(*me)); 291 m.setAt(new GsmAt(*me));
291 m.send(); 292 m.send();
292 293
293 NewSMSStatusLabel->setText("Message sent."); 294 NewSMSStatusLabel->setText("Message sent.");
294 } catch (GsmException &ge) { 295 } catch (GsmException &ge) {
295 NewSMSStatusLabel->setText("Failed."); 296 NewSMSStatusLabel->setText("Failed.");
296 qDebug(ge.what()); 297 qDebug(ge.what());
297 } 298 }
298 free((void *)msgtext); 299 free((void *)msgtext);
299 300
300 301
301} 302}
302 303
303 304
304void GSMTool::doSMSDeleteButton() 305void GSMTool::doSMSDeleteButton()
305{ 306{
306 QListViewItem *item = SMSList->currentItem(); 307 QListViewItem *item = SMSList->currentItem();
307 if (!item) 308 if (!item)
308 return; 309 return;
309 310
310 int index = atoi(item->text(2).ascii()); 311 int index = atoi(item->text(2).ascii());
311 qDebug("delete SMS with index %d\n", index); 312 qDebug("delete SMS with index %d\n", index);
312 313
313 314
314 315
315 SortedSMSStore::iterator e = sms_store->find(index); 316 SortedSMSStore::iterator e = sms_store->find(index);
316 317
317 if (e != sms_store->end()) { 318 if (e != sms_store->end()) {
318 qDebug("message is %s\n", e->message()->userData().c_str()); 319 qDebug("message is %s\n", e->message()->userData().c_str());
319 sms_store->erase(e); 320 sms_store->erase(e);
320 321
321 } 322 }
322 doSMSTypeChanged(); 323 doSMSTypeChanged();
323} 324}
324 325
325void GSMTool::doScanButton() 326void GSMTool::doScanButton()
326{ 327{
327 qDebug("ScanButton"); 328 qDebug("ScanButton");
328 329
329 NetworkList->setEnabled(FALSE); 330 NetworkList->setEnabled(FALSE);
330 AvailNetsLabel->setEnabled(FALSE); 331 AvailNetsLabel->setEnabled(FALSE);
331 NetworkList->clear(); 332 NetworkList->clear();
332 new QListViewItem(NetworkList, "Scanning..."); 333 new QListViewItem(NetworkList, "Scanning...");
333 334
334 vector<OPInfo> opis; 335 vector<OPInfo> opis;
335 336
336 try { 337 try {
337 opis = me->getAvailableOPInfo(); 338 opis = me->getAvailableOPInfo();
338 } catch (GsmException) { 339 } catch (GsmException) {
339 NetworkList->clear(); 340 NetworkList->clear();
340 new QListViewItem(NetworkList, "Scan failed..."); 341 new QListViewItem(NetworkList, "Scan failed...");
341 return; 342 return;
342 } 343 }
343 344
344 NetworkList->clear(); 345 NetworkList->clear();
345 for (vector<OPInfo>::iterator i = opis.begin(); i != opis.end(); ++i) { 346 for (vector<OPInfo>::iterator i = opis.begin(); i != opis.end(); ++i) {
346 char *statustext; 347 char *statustext;
347 switch (i->_status) { 348 switch (i->_status) {
348 349
349 case UnknownOPStatus: 350 case UnknownOPStatus:
350 statustext = "unknown"; 351 statustext = "unknown";
351 break; 352 break;
352 353
353 case CurrentOPStatus: 354 case CurrentOPStatus:
354 statustext = "current"; 355 statustext = "current";
355 break; 356 break;
356 357
357 case AvailableOPStatus: 358 case AvailableOPStatus:
358 statustext = "available"; 359 statustext = "available";
359 break; 360 break;
360 361
361 case ForbiddenOPStatus: 362 case ForbiddenOPStatus:
362 statustext = "forbidden"; 363 statustext = "forbidden";
363 break; 364 break;
364 365
365 default: 366 default:
366 statustext = "(ERROR)"; 367 statustext = "(ERROR)";
367 } 368 }
368 char num[7]; 369 char num[7];
369 snprintf(num, 6, "%d", i->_numericName); 370 snprintf(num, 6, "%d", i->_numericName);
370 new QListViewItem(NetworkList, i->_longName.c_str(), statustext, num, i->_shortName.c_str()); 371 new QListViewItem(NetworkList, i->_longName.c_str(), statustext, num, i->_shortName.c_str());
371 } 372 }
372 NetworkList->setEnabled(TRUE); 373 NetworkList->setEnabled(TRUE);
373 AvailNetsLabel->setEnabled(TRUE); 374 AvailNetsLabel->setEnabled(TRUE);
374} 375}
375/* 376/*
376 * A simple slot... not very interesting. 377 * A simple slot... not very interesting.
377 */ 378 */
378void GSMTool::doConnectButton() 379void GSMTool::doConnectButton()
379{ 380{
380 gsmlib::Port *port; 381 gsmlib::Port *port;
381 382
382 speed_t rate; 383 speed_t rate;
383 devicename = strdup(DeviceName->currentText().local8Bit().data()); 384 devicename = strdup(DeviceName->currentText().local8Bit().data());
384 rate = baudrates[BaudRate->currentItem()]; 385 rate = baudrates[BaudRate->currentItem()];
385 386
386 qDebug("Connect Button Pressed"); 387 qDebug("Connect Button Pressed");
387 MfrText->setText("Opening..."); 388 MfrText->setText("Opening...");
388 ModelText->setText(""); 389 ModelText->setText("");
389 RevisionText->setText(""); 390 RevisionText->setText("");
390 SerialText->setText(""); 391 SerialText->setText("");
391 392
392 setConnected(FALSE); 393 setConnected(FALSE);
393 if (me) { 394 if (me) {
394 me = NULL; 395 me = NULL;
395 } 396 }
396 397
397 if (lockDevice()) { 398 if (lockDevice()) {
398 qDebug("lockDevice() failed\n"); 399 qDebug("lockDevice() failed\n");
399 MfrText->setText("Lock port failed"); 400 MfrText->setText("Lock port failed");
400 }; 401 };
401 402
402 qDebug("Device name is %s\n", devicename); 403 qDebug("Device name is %s\n", devicename);
403 404
404 try { 405 try {
405 port = new UnixSerialPort(devicename, rate, DEFAULT_INIT_STRING, 0); 406 port = new UnixSerialPort(devicename, rate, DEFAULT_INIT_STRING, 0);
406 } catch (GsmException) { 407 } catch (GsmException) {
407 qDebug("port failed"); 408 qDebug("port failed");
408 MfrText->setText("Open port failed"); 409 MfrText->setText("Open port failed");
409 return; 410 return;
410 } 411 }
411 MfrText->setText("Initialising..."); 412 MfrText->setText("Initialising...");
412 qDebug("got port"); 413 qDebug("got port");
413 try { 414 try {
414 me = new MeTa(port); 415 me = new MeTa(port);
415 } catch (GsmException) { 416 } catch (GsmException) {
416 qDebug("meta failed"); 417 qDebug("meta failed");
417 MfrText->setText("Initialise GSM unit failed"); 418 MfrText->setText("Initialise GSM unit failed");
418 me = NULL; 419 me = NULL;
419 unlockDevice(); 420 unlockDevice();
420 return; 421 return;
421 } 422 }
422 423
423 qDebug("Opened"); 424 qDebug("Opened");
424 425
425 MEInfo ifo; 426 MEInfo ifo;
426 427
427 MfrText->setText("Querying..."); 428 MfrText->setText("Querying...");
428 429
429 try { 430 try {
430 ifo = me->getMEInfo(); 431 ifo = me->getMEInfo();
431 } catch (GsmException) { 432 } catch (GsmException) {
432 qDebug("getMEInfo failed"); 433 qDebug("getMEInfo failed");
433 MfrText->setText("Query GSM unit failed"); 434 MfrText->setText("Query GSM unit failed");
434 me = NULL; 435 me = NULL;
435 unlockDevice(); 436 unlockDevice();
436 return; 437 return;
437 } 438 }
438 439
439 MfrText->setText(ifo._manufacturer.c_str()); 440 MfrText->setText(ifo._manufacturer.c_str());
440 ModelText->setText(ifo._model.c_str()); 441 ModelText->setText(ifo._model.c_str());
441 RevisionText->setText(ifo._revision.c_str()); 442 RevisionText->setText(ifo._revision.c_str());
442 SerialText->setText(ifo._serialNumber.c_str()); 443 SerialText->setText(ifo._serialNumber.c_str());
443 setConnected(TRUE); 444 setConnected(TRUE);
444 445
445 SMSStoreList->clear(); 446 SMSStoreList->clear();
446 SMSStoreList->insertItem("None"); 447 SMSStoreList->insertItem("None");
447 448
448 vector<string> storenames = me->getSMSStoreNames(); 449 vector<string> storenames = me->getSMSStoreNames();
449 450
450 for (vector<string>::iterator i = storenames.begin(); i != storenames.end(); ++i) { 451 for (vector<string>::iterator i = storenames.begin(); i != storenames.end(); ++i) {
451 SMSStoreList->insertItem(i->c_str()); 452 SMSStoreList->insertItem(i->c_str());
452 } 453 }
453 SMSList->clear(); 454 SMSList->clear();
454 SMSText->setText(""); 455 SMSText->setText("");
455 sms_store = NULL; 456 sms_store = NULL;
456} 457}