Diffstat (limited to 'noncore/unsupported/gsmtool/gsmtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtool.cpp | 63 |
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 | |||
@@ -2,17 +2,19 @@ | |||
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 | 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 | ||
14 | using namespace gsmlib; | 16 | using namespace gsmlib; |
15 | 17 | ||
16 | 18 | ||
17 | /* | 19 | /* |
18 | * Constructs a GSMTool which is a child of 'parent', with the | 20 | * Constructs a GSMTool which is a child of 'parent', with the |
@@ -20,17 +22,21 @@ using namespace gsmlib; | |||
20 | */ | 22 | */ |
21 | GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) | 23 | GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) |
22 | : GSMToolBase( parent, name, fl ) | 24 | : GSMToolBase( parent, name, 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 | ||
34 | /* | 40 | /* |
35 | * Destroys the object and frees any allocated resources | 41 | * Destroys the object and frees any allocated resources |
36 | */ | 42 | */ |
@@ -126,12 +132,55 @@ void GSMTool::timerEvent( QTimerEvent * ) | |||
126 | dB->setEnabled(TRUE); | 132 | dB->setEnabled(TRUE); |
127 | SigStrLabel->setEnabled(TRUE); | 133 | SigStrLabel->setEnabled(TRUE); |
128 | } | 134 | } |
129 | } | 135 | } |
130 | } | 136 | } |
131 | 137 | ||
138 | void 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 | |||
153 | void 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 | |||
132 | void GSMTool::doScanButton() | 181 | void GSMTool::doScanButton() |
133 | { | 182 | { |
134 | qDebug("ScanButton"); | 183 | qDebug("ScanButton"); |
135 | 184 | ||
136 | NetworkList->setEnabled(FALSE); | 185 | NetworkList->setEnabled(FALSE); |
137 | AvailNetsLabel->setEnabled(FALSE); | 186 | AvailNetsLabel->setEnabled(FALSE); |
@@ -245,7 +294,19 @@ void GSMTool::doConnectButton() | |||
245 | 294 | ||
246 | MfrText->setText(ifo._manufacturer.c_str()); | 295 | MfrText->setText(ifo._manufacturer.c_str()); |
247 | ModelText->setText(ifo._model.c_str()); | 296 | ModelText->setText(ifo._model.c_str()); |
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 | } |