summaryrefslogtreecommitdiff
path: root/noncore/unsupported/gsmtool/gsmtool.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/gsmtool/gsmtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.cpp63
1 files changed, 62 insertions, 1 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp
index 38baf45..c3f9482 100644
--- a/noncore/unsupported/gsmtool/gsmtool.cpp
+++ b/noncore/unsupported/gsmtool/gsmtool.cpp
@@ -5,11 +5,13 @@
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 8#include <qtextbrowser.h>
9#include <termios.h> 9#include <termios.h>
10 10
11#include <gsmlib/gsm_me_ta.h> 11#include <gsmlib/gsm_me_ta.h>
12#include <gsmlib/gsm_unix_serial.h> 12#include <gsmlib/gsm_unix_serial.h>
13#include <gsmlib/gsm_sms.h>
14#include <gsmlib/gsm_sorted_sms_store.h>
13 15
14using namespace gsmlib; 16using namespace gsmlib;
15 17
@@ -23,11 +25,15 @@ GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl )
23{ 25{
24 devicelocked = 0; 26 devicelocked = 0;
25 me = NULL; 27 me = NULL;
28 sms_store = NULL;
26 setConnected(FALSE); 29 setConnected(FALSE);
27 /* FIXME: Persistent settings for device/baudrate */ 30 /* FIXME: Persistent settings for device/baudrate */
28 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); 31 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton()));
29 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); 32 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton()));
30 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); 33 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged()));
34 connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged()));
35 connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged()));
36
31 timerid = -1; // Is this not possible normally? 37 timerid = -1; // Is this not possible normally?
32} 38}
33 39
@@ -129,6 +135,49 @@ void GSMTool::timerEvent( QTimerEvent * )
129 } 135 }
130} 136}
131 137
138void GSMTool::doSMSStoreChanged()
139{
140 const char *storename = SMSStoreList->currentText().ascii();
141 qDebug("Store Changed to '%s'", storename);
142 try {
143 sms_store = me->getSMSStore(storename);
144
145 qDebug("got store of size %d", sms_store->size());
146 } catch (GsmException) {
147 sms_store = NULL;
148 qDebug("get store failed");
149 }
150 doSMSTypeChanged();
151}
152
153void GSMTool::doSMSTypeChanged()
154{
155 int direction = SMSViewType->currentItem();
156 qDebug("direction %s\n", direction?"outgoing":"incoming");
157
158 SMSList->clear();
159 if (sms_store == NULL)
160 return;
161 for (int i = 0; i < sms_store->size(); i++) {
162 qDebug("Message %d", i);
163 qDebug("Is%sempty", sms_store()[i].empty()?" ":" not ");
164 if (sms_store()[i].empty())
165 continue;
166
167 qDebug("Status %d", sms_store()[i].status());
168 SMSMessageRef message = sms_store()[i].message();
169 qDebug("Got message.");
170
171#if 0 // WTF does this die? Did I mention that gsmlib needs rewriting in a sane language?
172 qDebug(message->toString().c_str());
173 if (direction == message->messageType()) {
174 qDebug("yes\n");
175 new QListViewItem(SMSList, "xx", message->address()._number.c_str());
176 } else qDebug("no. dir %d, type %d\n", direction, message->messageType());
177#endif
178 }
179}
180
132void GSMTool::doScanButton() 181void GSMTool::doScanButton()
133{ 182{
134 qDebug("ScanButton"); 183 qDebug("ScanButton");
@@ -248,4 +297,16 @@ void GSMTool::doConnectButton()
248 RevisionText->setText(ifo._revision.c_str()); 297 RevisionText->setText(ifo._revision.c_str());
249 SerialText->setText(ifo._serialNumber.c_str()); 298 SerialText->setText(ifo._serialNumber.c_str());
250 setConnected(TRUE); 299 setConnected(TRUE);
300
301 SMSStoreList->clear();
302 SMSStoreList->insertItem("None");
303
304 vector<string> storenames = me->getSMSStoreNames();
305
306 for (vector<string>::iterator i = storenames.begin(); i != storenames.end(); ++i) {
307 SMSStoreList->insertItem(i->c_str());
308 }
309 SMSList->clear();
310 SMSText->setText("");
311 sms_store = NULL;
251} 312}