summaryrefslogtreecommitdiff
path: root/noncore/unsupported/gsmtool
authordwmw2 <dwmw2>2002-04-04 10:23:47 (UTC)
committer dwmw2 <dwmw2>2002-04-04 10:23:47 (UTC)
commit0ffdfb93cd33ae975822701e16421990e416c218 (patch) (unidiff)
tree0682d5e14c53c7fc9d0171160a92161e249de473 /noncore/unsupported/gsmtool
parent431ff3f7fd9996236c6d82a3644b3915bd4c7b38 (diff)
downloadopie-0ffdfb93cd33ae975822701e16421990e416c218.zip
opie-0ffdfb93cd33ae975822701e16421990e416c218.tar.gz
opie-0ffdfb93cd33ae975822701e16421990e416c218.tar.bz2
Wheee. Now shows SMS messages
Diffstat (limited to 'noncore/unsupported/gsmtool') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.cpp51
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.h1
-rw-r--r--noncore/unsupported/gsmtool/gsmtoolbase.ui44
3 files changed, 79 insertions, 17 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);
diff --git a/noncore/unsupported/gsmtool/gsmtool.h b/noncore/unsupported/gsmtool/gsmtool.h
index 49387d9..b8d9a86 100644
--- a/noncore/unsupported/gsmtool/gsmtool.h
+++ b/noncore/unsupported/gsmtool/gsmtool.h
@@ -20,12 +20,13 @@ protected:
20private slots: 20private slots:
21 void doConnectButton(); 21 void doConnectButton();
22 void doScanButton(); 22 void doScanButton();
23 void doTabChanged(); 23 void doTabChanged();
24 void doSMSStoreChanged(); 24 void doSMSStoreChanged();
25 void doSMSTypeChanged(); 25 void doSMSTypeChanged();
26 void doSelectedSMSChanged(QListViewItem *);
26 27
27private: 28private:
28 static const speed_t baudrates[]; 29 static const speed_t baudrates[];
29 int devicelocked; 30 int devicelocked;
30 int timerid; 31 int timerid;
31 32
diff --git a/noncore/unsupported/gsmtool/gsmtoolbase.ui b/noncore/unsupported/gsmtool/gsmtoolbase.ui
index 340f26c..69480cd 100644
--- a/noncore/unsupported/gsmtool/gsmtoolbase.ui
+++ b/noncore/unsupported/gsmtool/gsmtoolbase.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>309</width> 14 <width>371</width>
15 <height>390</height> 15 <height>390</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>GSM Tool</string> 20 <string>GSM Tool</string>
@@ -663,12 +663,16 @@
663 <name>sizePolicy</name> 663 <name>sizePolicy</name>
664 <sizepolicy> 664 <sizepolicy>
665 <hsizetype>7</hsizetype> 665 <hsizetype>7</hsizetype>
666 <vsizetype>7</vsizetype> 666 <vsizetype>7</vsizetype>
667 </sizepolicy> 667 </sizepolicy>
668 </property> 668 </property>
669 <property stdset="1">
670 <name>allColumnsShowFocus</name>
671 <bool>true</bool>
672 </property>
669 </widget> 673 </widget>
670 <widget> 674 <widget>
671 <class>QLayoutWidget</class> 675 <class>QLayoutWidget</class>
672 <property stdset="1"> 676 <property stdset="1">
673 <name>name</name> 677 <name>name</name>
674 <cstring>Layout11</cstring> 678 <cstring>Layout11</cstring>
@@ -736,22 +740,22 @@
736 <cstring>tab</cstring> 740 <cstring>tab</cstring>
737 </property> 741 </property>
738 <attribute> 742 <attribute>
739 <name>title</name> 743 <name>title</name>
740 <string>SMS</string> 744 <string>SMS</string>
741 </attribute> 745 </attribute>
742 <vbox> 746 <grid>
743 <property stdset="1"> 747 <property stdset="1">
744 <name>margin</name> 748 <name>margin</name>
745 <number>11</number> 749 <number>11</number>
746 </property> 750 </property>
747 <property stdset="1"> 751 <property stdset="1">
748 <name>spacing</name> 752 <name>spacing</name>
749 <number>6</number> 753 <number>6</number>
750 </property> 754 </property>
751 <widget> 755 <widget row="0" column="0" >
752 <class>QLayoutWidget</class> 756 <class>QLayoutWidget</class>
753 <property stdset="1"> 757 <property stdset="1">
754 <name>name</name> 758 <name>name</name>
755 <cstring>Layout6</cstring> 759 <cstring>Layout6</cstring>
756 </property> 760 </property>
757 <hbox> 761 <hbox>
@@ -820,18 +824,18 @@
820 <name>name</name> 824 <name>name</name>
821 <cstring>SMSViewType</cstring> 825 <cstring>SMSViewType</cstring>
822 </property> 826 </property>
823 </widget> 827 </widget>
824 </hbox> 828 </hbox>
825 </widget> 829 </widget>
826 <widget> 830 <widget row="1" column="0" >
827 <class>QListView</class> 831 <class>QListView</class>
828 <column> 832 <column>
829 <property> 833 <property>
830 <name>text</name> 834 <name>text</name>
831 <string>Date</string> 835 <string>Number</string>
832 </property> 836 </property>
833 <property> 837 <property>
834 <name>clickable</name> 838 <name>clickable</name>
835 <bool>true</bool> 839 <bool>true</bool>
836 </property> 840 </property>
837 <property> 841 <property>
@@ -839,13 +843,13 @@
839 <bool>true</bool> 843 <bool>true</bool>
840 </property> 844 </property>
841 </column> 845 </column>
842 <column> 846 <column>
843 <property> 847 <property>
844 <name>text</name> 848 <name>text</name>
845 <string>Number</string> 849 <string>Date</string>
846 </property> 850 </property>
847 <property> 851 <property>
848 <name>clickable</name> 852 <name>clickable</name>
849 <bool>true</bool> 853 <bool>true</bool>
850 </property> 854 </property>
851 <property> 855 <property>
@@ -854,14 +858,22 @@
854 </property> 858 </property>
855 </column> 859 </column>
856 <property stdset="1"> 860 <property stdset="1">
857 <name>name</name> 861 <name>name</name>
858 <cstring>SMSList</cstring> 862 <cstring>SMSList</cstring>
859 </property> 863 </property>
864 <property stdset="1">
865 <name>enabled</name>
866 <bool>false</bool>
867 </property>
868 <property stdset="1">
869 <name>allColumnsShowFocus</name>
870 <bool>true</bool>
871 </property>
860 </widget> 872 </widget>
861 <widget> 873 <widget row="2" column="0" >
862 <class>QLayoutWidget</class> 874 <class>QLayoutWidget</class>
863 <property stdset="1"> 875 <property stdset="1">
864 <name>name</name> 876 <name>name</name>
865 <cstring>Layout15</cstring> 877 <cstring>Layout15</cstring>
866 </property> 878 </property>
867 <property> 879 <property>
@@ -908,19 +920,31 @@
908 <name>text</name> 920 <name>text</name>
909 <string>New</string> 921 <string>New</string>
910 </property> 922 </property>
911 </widget> 923 </widget>
912 </hbox> 924 </hbox>
913 </widget> 925 </widget>
914 <widget> 926 <widget row="3" column="0" >
915 <class>QTextBrowser</class> 927 <class>QMultiLineEdit</class>
916 <property stdset="1"> 928 <property stdset="1">
917 <name>name</name> 929 <name>name</name>
918 <cstring>SMSText</cstring> 930 <cstring>SMSText</cstring>
919 </property> 931 </property>
932 <property stdset="1">
933 <name>enabled</name>
934 <bool>false</bool>
935 </property>
936 <property stdset="1">
937 <name>wordWrap</name>
938 <enum>WidgetWidth</enum>
939 </property>
940 <property stdset="1">
941 <name>readOnly</name>
942 <bool>true</bool>
943 </property>
920 </widget> 944 </widget>
921 </vbox> 945 </grid>
922 </widget> 946 </widget>
923 </widget> 947 </widget>
924 </vbox> 948 </vbox>
925</widget> 949</widget>
926</UI> 950</UI>