summaryrefslogtreecommitdiff
path: root/noncore/unsupported/gsmtool/gsmtool.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/gsmtool/gsmtool.cpp') (more/less context) (show 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
@@ -6,6 +6,8 @@
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>
@@ -33,7 +35,7 @@ GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl )
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
@@ -139,7 +141,9 @@ void 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());
@@ -147,6 +151,8 @@ void GSMTool::doSMSStoreChanged()
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
@@ -156,6 +162,8 @@ void GSMTool::doSMSTypeChanged()
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++) {
@@ -168,16 +176,45 @@ void GSMTool::doSMSTypeChanged()
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");