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.cpp51
1 files changed, 44 insertions, 7 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp
index c3f9482..8273461 100644
--- a/noncore/unsupported/gsmtool/gsmtool.cpp
+++ b/noncore/unsupported/gsmtool/gsmtool.cpp
@@ -3,12 +3,14 @@
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>
10
9#include <termios.h> 11#include <termios.h>
10 12
11#include <gsmlib/gsm_me_ta.h> 13#include <gsmlib/gsm_me_ta.h>
12#include <gsmlib/gsm_unix_serial.h> 14#include <gsmlib/gsm_unix_serial.h>
13#include <gsmlib/gsm_sms.h> 15#include <gsmlib/gsm_sms.h>
14#include <gsmlib/gsm_sorted_sms_store.h> 16#include <gsmlib/gsm_sorted_sms_store.h>
@@ -30,13 +32,13 @@ GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl )
30 /* FIXME: Persistent settings for device/baudrate */ 32 /* FIXME: Persistent settings for device/baudrate */
31 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); 33 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton()));
32 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); 34 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton()));
33 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); 35 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged()));
34 connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged())); 36 connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged()));
35 connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged())); 37 connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged()));
36 38 connect(SMSList, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(doSelectedSMSChanged(QListViewItem *)));
37 timerid = -1; // Is this not possible normally? 39 timerid = -1; // Is this not possible normally?
38} 40}
39 41
40/* 42/*
41 * Destroys the object and frees any allocated resources 43 * Destroys the object and frees any allocated resources
42 */ 44 */
@@ -136,51 +138,86 @@ void GSMTool::timerEvent( QTimerEvent * )
136} 138}
137 139
138void GSMTool::doSMSStoreChanged() 140void GSMTool::doSMSStoreChanged()
139{ 141{
140 const char *storename = SMSStoreList->currentText().ascii(); 142 const char *storename = SMSStoreList->currentText().ascii();
141 qDebug("Store Changed to '%s'", storename); 143 qDebug("Store Changed to '%s'", storename);
142 try { 144 if (!strcmp(storename, "None")) {
145 sms_store = NULL;
146 } else try {
143 sms_store = me->getSMSStore(storename); 147 sms_store = me->getSMSStore(storename);
144 148
145 qDebug("got store of size %d", sms_store->size()); 149 qDebug("got store of size %d", sms_store->size());
146 } catch (GsmException) { 150 } catch (GsmException) {
147 sms_store = NULL; 151 sms_store = NULL;
148 qDebug("get store failed"); 152 qDebug("get store failed");
149 } 153 }
154
155 SMSList->setEnabled(!(sms_store == NULL));
150 doSMSTypeChanged(); 156 doSMSTypeChanged();
151} 157}
152 158
153void GSMTool::doSMSTypeChanged() 159void GSMTool::doSMSTypeChanged()
154{ 160{
155 int direction = SMSViewType->currentItem(); 161 int direction = SMSViewType->currentItem();
156 qDebug("direction %s\n", direction?"outgoing":"incoming"); 162 qDebug("direction %s\n", direction?"outgoing":"incoming");
157 163
158 SMSList->clear(); 164 SMSList->clear();
165 doSelectedSMSChanged(NULL);
166
159 if (sms_store == NULL) 167 if (sms_store == NULL)
160 return; 168 return;
161 for (int i = 0; i < sms_store->size(); i++) { 169 for (int i = 0; i < sms_store->size(); i++) {
162 qDebug("Message %d", i); 170 qDebug("Message %d", i);
163 qDebug("Is%sempty", sms_store()[i].empty()?" ":" not "); 171 qDebug("Is%sempty", sms_store()[i].empty()?" ":" not ");
164 if (sms_store()[i].empty()) 172 if (sms_store()[i].empty())
165 continue; 173 continue;
166 174
167 qDebug("Status %d", sms_store()[i].status()); 175 qDebug("Status %d", sms_store()[i].status());
168 SMSMessageRef message = sms_store()[i].message(); 176 SMSMessageRef message = sms_store()[i].message();
169 qDebug("Got message."); 177 qDebug("Got message.");
170 178
171#if 0 // WTF does this die? Did I mention that gsmlib needs rewriting in a sane language? 179 // qDebug(message->toString().c_str());
172 qDebug(message->toString().c_str());
173 if (direction == message->messageType()) { 180 if (direction == message->messageType()) {
174 qDebug("yes\n"); 181 qDebug("yes\n");
175 new QListViewItem(SMSList, "xx", message->address()._number.c_str()); 182 char buf[3];
176 } else qDebug("no. dir %d, type %d\n", direction, message->messageType()); 183 snprintf(buf, 3, "%d", i);
177#endif 184 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf);
185 }
178 } 186 }
179} 187}
180 188
189void GSMTool::doSelectedSMSChanged(QListViewItem *item)
190{
191 qDebug("message changed\n");
192
193 if (!item || sms_store == NULL) {
194 SMSText->setText("");
195 SMSText->setEnabled(FALSE);
196 SMSDeleteButton->setEnabled(FALSE);
197 SMSSendButton->setEnabled(FALSE);
198 return;
199 }
200 /* ARGH. This sucks. Surely there's an app-private pointer in the
201 QListViewItem that I've failed to notice?
202
203 SMSMessageRef message = *(SMSMessageRef*)item->private;
204 */
205 qDebug("item %p\n", item);
206
207 qDebug("text(2) is %s\n", item->text(2).ascii());
208 int index = atoi(item->text(2).ascii());
209 qDebug("index %d\n", index);
210 SMSMessageRef message = sms_store()[index].message();
211
212 SMSText->setText(message->userData().c_str());
213 SMSText->setEnabled(TRUE);
214 SMSDeleteButton->setEnabled(TRUE);
215 SMSSendButton->setEnabled(TRUE);
216
217}
181void GSMTool::doScanButton() 218void GSMTool::doScanButton()
182{ 219{
183 qDebug("ScanButton"); 220 qDebug("ScanButton");
184 221
185 NetworkList->setEnabled(FALSE); 222 NetworkList->setEnabled(FALSE);
186 AvailNetsLabel->setEnabled(FALSE); 223 AvailNetsLabel->setEnabled(FALSE);