summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.cpp129
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.h9
-rw-r--r--noncore/unsupported/gsmtool/gsmtoolbase.ui237
3 files changed, 307 insertions, 68 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp
index 8273461..6fea596 100644
--- a/noncore/unsupported/gsmtool/gsmtool.cpp
+++ b/noncore/unsupported/gsmtool/gsmtool.cpp
@@ -32,4 +32,9 @@ GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl )
32 /* FIXME: Persistent settings for device/baudrate */ 32 /* FIXME: Persistent settings for device/baudrate */
33 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); 33 connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton()));
34 connect(SMSDeleteButton, SIGNAL(clicked()), this, SLOT(doSMSDeleteButton()));
35 connect(SMSSendButton, SIGNAL(clicked()), this, SLOT(doSMSSendButton()));
36 connect(NewSMSClearButton, SIGNAL(clicked()), this, SLOT(doNewSMSClearButton()));
37 connect(NewSMSSaveButton, SIGNAL(clicked()), this, SLOT(doNewSMSSaveButton()));
38 connect(NewSMSSendButton, SIGNAL(clicked()), this, SLOT(doNewSMSSendButton()));
34 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); 39 connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton()));
35 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); 40 connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged()));
@@ -70,4 +75,5 @@ void GSMTool::setConnected( bool conn )
70 TabWidget2->setTabEnabled(tab_2, conn); 75 TabWidget2->setTabEnabled(tab_2, conn);
71 TabWidget2->setTabEnabled(tab_3, conn); 76 TabWidget2->setTabEnabled(tab_3, conn);
77 TabWidget2->setTabEnabled(tab_4, conn);
72 MfrLabel->setEnabled(conn); 78 MfrLabel->setEnabled(conn);
73 MfrText->setEnabled(conn); 79 MfrText->setEnabled(conn);
@@ -145,5 +151,6 @@ void GSMTool::doSMSStoreChanged()
145 sms_store = NULL; 151 sms_store = NULL;
146 } else try { 152 } else try {
147 sms_store = me->getSMSStore(storename); 153 sms_store = new SortedSMSStore(me->getSMSStore(storename));
154 sms_store->setSortOrder(ByIndex);
148 155
149 qDebug("got store of size %d", sms_store->size()); 156 qDebug("got store of size %d", sms_store->size());
@@ -154,4 +161,5 @@ void GSMTool::doSMSStoreChanged()
154 161
155 SMSList->setEnabled(!(sms_store == NULL)); 162 SMSList->setEnabled(!(sms_store == NULL));
163 NewSMSSaveButton->setEnabled(!(sms_store == NULL));
156 doSMSTypeChanged(); 164 doSMSTypeChanged();
157} 165}
@@ -161,4 +169,8 @@ void GSMTool::doSMSTypeChanged()
161 int direction = SMSViewType->currentItem(); 169 int direction = SMSViewType->currentItem();
162 qDebug("direction %s\n", direction?"outgoing":"incoming"); 170 qDebug("direction %s\n", direction?"outgoing":"incoming");
171 if (direction)
172 SMSSendButton->setText("Send");
173 else
174 SMSSendButton->setText("Reply");
163 175
164 SMSList->clear(); 176 SMSList->clear();
@@ -167,12 +179,13 @@ void GSMTool::doSMSTypeChanged()
167 if (sms_store == NULL) 179 if (sms_store == NULL)
168 return; 180 return;
169 for (int i = 0; i < sms_store->size(); i++) { 181 for (SortedSMSStore::iterator e = sms_store->begin();
170 qDebug("Message %d", i); 182 e != sms_store->end(); e++) {
171 qDebug("Is%sempty", sms_store()[i].empty()?" ":" not "); 183 // qDebug("Message %d", i);
172 if (sms_store()[i].empty()) 184 qDebug("Is%sempty", e->empty()?" ":" not ");
185 if (e->empty())
173 continue; 186 continue;
174 187
175 qDebug("Status %d", sms_store()[i].status()); 188 qDebug("Status %d", e->status());
176 SMSMessageRef message = sms_store()[i].message(); 189 SMSMessageRef message = e->message();
177 qDebug("Got message."); 190 qDebug("Got message.");
178 191
@@ -181,5 +194,5 @@ void GSMTool::doSMSTypeChanged()
181 qDebug("yes\n"); 194 qDebug("yes\n");
182 char buf[3]; 195 char buf[3];
183 snprintf(buf, 3, "%d", i); 196 snprintf(buf, 3, "%d", e->index());
184 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf); 197 new QListViewItem(SMSList, message->address()._number.c_str(), message->serviceCentreTimestamp().toString().c_str(), buf);
185 } 198 }
@@ -208,5 +221,5 @@ void GSMTool::doSelectedSMSChanged(QListViewItem *item)
208 int index = atoi(item->text(2).ascii()); 221 int index = atoi(item->text(2).ascii());
209 qDebug("index %d\n", index); 222 qDebug("index %d\n", index);
210 SMSMessageRef message = sms_store()[index].message(); 223 SMSMessageRef message = sms_store->find(index)->message();
211 224
212 SMSText->setText(message->userData().c_str()); 225 SMSText->setText(message->userData().c_str());
@@ -216,4 +229,102 @@ void GSMTool::doSelectedSMSChanged(QListViewItem *item)
216 229
217} 230}
231
232void GSMTool::doSMSSendButton()
233{
234 qDebug("SMSSendButton");
235
236 QListViewItem *item = SMSList->currentItem();
237 if (!item)
238 return;
239
240 int index = atoi(item->text(2).ascii());
241 qDebug("index %d\n", index);
242
243 int direction = SMSViewType->currentItem();
244 qDebug("direction %s\n", direction?"outgoing":"incoming");
245
246 SMSMessageRef message = sms_store->find(index)->message();
247
248 if (direction)
249 NewSMSText->setText(message->userData().c_str());
250 else
251 NewSMSText->setText("");
252 NewSMSToBox->insertItem(message->address()._number.c_str(), 0);
253 TabWidget2->setCurrentPage(3);
254
255}
256
257void GSMTool::doNewSMSClearButton()
258{
259 NewSMSText->setText("");
260}
261
262void GSMTool::doNewSMSSaveButton()
263{
264 qDebug("NewSMSSaveButton");
265 const char *msgtext = strdup(NewSMSText->text().local8Bit());
266 const char *dest = NewSMSToBox->currentText().ascii();
267
268 NewSMSStatusLabel->setText("Sending...");
269 me->setMessageService(1);
270
271 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest);
272
273 SMSMessageRef m = new SMSSubmitMessage (msgtext, dest);
274 sms_store->insert(m);
275 free((void *)msgtext);
276
277}
278void GSMTool::doNewSMSSendButton()
279{
280 const char *msgtext = strdup(NewSMSText->text().local8Bit());
281 const char *dest = NewSMSToBox->currentText().ascii();
282
283 NewSMSStatusLabel->setText("Sending...");
284 me->setMessageService(1);
285
286 qDebug("NewSMSSendButton: '%s' to '%s'", msgtext, dest);
287
288 SMSSubmitMessage m(msgtext, dest);
289 try {
290 Ref<SMSMessage> ackPDU;
291 m.setAt(new GsmAt(*me));
292 m.send(ackPDU);
293
294 // print acknowledgement if available
295 if (! ackPDU.isnull())
296 cout << ackPDU->toString();
297 NewSMSStatusLabel->setText("Message sent.");
298 } catch (GsmException &ge) {
299 NewSMSStatusLabel->setText("Failed.");
300 qDebug(ge.what());
301 }
302 free((void *)msgtext);
303
304
305}
306
307
308void GSMTool::doSMSDeleteButton()
309{
310 QListViewItem *item = SMSList->currentItem();
311 if (!item)
312 return;
313
314 int index = atoi(item->text(2).ascii());
315 qDebug("delete SMS with index %d\n", index);
316
317
318
319 SortedSMSStore::iterator e = sms_store->find(index);
320
321 if (e != sms_store->end()) {
322 qDebug("message is %s\n", e->message()->userData().c_str());
323 sms_store->erase(e);
324
325 }
326 doSMSTypeChanged();
327}
328
218void GSMTool::doScanButton() 329void GSMTool::doScanButton()
219{ 330{
diff --git a/noncore/unsupported/gsmtool/gsmtool.h b/noncore/unsupported/gsmtool/gsmtool.h
index b8d9a86..b38ff88 100644
--- a/noncore/unsupported/gsmtool/gsmtool.h
+++ b/noncore/unsupported/gsmtool/gsmtool.h
@@ -6,4 +6,5 @@
6 6
7#include <gsmlib/gsm_me_ta.h> 7#include <gsmlib/gsm_me_ta.h>
8#include <gsmlib/gsm_sorted_sms_store.h>
8 9
9class GSMTool : public GSMToolBase 10class GSMTool : public GSMToolBase
@@ -25,5 +26,9 @@ private slots:
25 void doSMSTypeChanged(); 26 void doSMSTypeChanged();
26 void doSelectedSMSChanged(QListViewItem *); 27 void doSelectedSMSChanged(QListViewItem *);
27 28 void doSMSSendButton();
29 void doSMSDeleteButton();
30 void doNewSMSClearButton();
31 void doNewSMSSaveButton();
32 void doNewSMSSendButton();
28private: 33private:
29 static const speed_t baudrates[]; 34 static const speed_t baudrates[];
@@ -32,5 +37,5 @@ private:
32 37
33 gsmlib::MeTa *me; 38 gsmlib::MeTa *me;
34 gsmlib::SMSStoreRef sms_store; 39 gsmlib::SortedSMSStoreRef sms_store;
35 40
36 char *devicename; 41 char *devicename;
diff --git a/noncore/unsupported/gsmtool/gsmtoolbase.ui b/noncore/unsupported/gsmtool/gsmtoolbase.ui
index 2cca852..65e75ec 100644
--- a/noncore/unsupported/gsmtool/gsmtoolbase.ui
+++ b/noncore/unsupported/gsmtool/gsmtoolbase.ui
@@ -12,5 +12,5 @@
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>371</width> 14 <width>404</width>
15 <height>390</height> 15 <height>390</height>
16 </rect> 16 </rect>
@@ -26,5 +26,5 @@
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <grid>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
@@ -35,5 +35,5 @@
35 <number>1</number> 35 <number>1</number>
36 </property> 36 </property>
37 <widget> 37 <widget row="0" column="0" >
38 <class>QTabWidget</class> 38 <class>QTabWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
@@ -120,4 +120,8 @@
120 <number>0</number> 120 <number>0</number>
121 </property> 121 </property>
122 <property stdset="1">
123 <name>duplicatesEnabled</name>
124 <bool>false</bool>
125 </property>
122 </widget> 126 </widget>
123 <widget> 127 <widget>
@@ -747,11 +751,11 @@
747 <property stdset="1"> 751 <property stdset="1">
748 <name>margin</name> 752 <name>margin</name>
749 <number>-1</number> 753 <number>2</number>
750 </property> 754 </property>
751 <property stdset="1"> 755 <property stdset="1">
752 <name>spacing</name> 756 <name>spacing</name>
753 <number>-1</number> 757 <number>1</number>
754 </property> 758 </property>
755 <widget row="0" column="0" > 759 <widget row="0" column="0" rowspan="1" colspan="3" >
756 <class>QLayoutWidget</class> 760 <class>QLayoutWidget</class>
757 <property stdset="1"> 761 <property stdset="1">
@@ -831,5 +835,5 @@
831 </hbox> 835 </hbox>
832 </widget> 836 </widget>
833 <widget row="1" column="0" > 837 <widget row="1" column="0" rowspan="1" colspan="3" >
834 <class>QListView</class> 838 <class>QListView</class>
835 <column> 839 <column>
@@ -874,66 +878,137 @@
874 </property> 878 </property>
875 </widget> 879 </widget>
880 <widget row="3" column="0" rowspan="1" colspan="3" >
881 <class>QMultiLineEdit</class>
882 <property stdset="1">
883 <name>name</name>
884 <cstring>SMSText</cstring>
885 </property>
886 <property stdset="1">
887 <name>enabled</name>
888 <bool>false</bool>
889 </property>
890 <property stdset="1">
891 <name>hMargin</name>
892 <number>1</number>
893 </property>
894 <property stdset="1">
895 <name>wordWrap</name>
896 <enum>WidgetWidth</enum>
897 </property>
898 <property stdset="1">
899 <name>readOnly</name>
900 <bool>true</bool>
901 </property>
902 </widget>
876 <widget row="2" column="0" > 903 <widget row="2" column="0" >
877 <class>QLayoutWidget</class> 904 <class>QPushButton</class>
905 <property stdset="1">
906 <name>name</name>
907 <cstring>SMSDeleteButton</cstring>
908 </property>
909 <property stdset="1">
910 <name>text</name>
911 <string>Delete</string>
912 </property>
913 </widget>
914 <widget row="2" column="2" >
915 <class>QPushButton</class>
878 <property stdset="1"> 916 <property stdset="1">
879 <name>name</name> 917 <name>name</name>
880 <cstring>Layout15</cstring> 918 <cstring>SMSSendButton</cstring>
919 </property>
920 <property stdset="1">
921 <name>text</name>
922 <string>Send</string>
881 </property> 923 </property>
924 </widget>
925 <spacer row="2" column="1" >
882 <property> 926 <property>
883 <name>layoutMargin</name> 927 <name>name</name>
928 <cstring>Spacer6_2</cstring>
929 </property>
930 <property stdset="1">
931 <name>orientation</name>
932 <enum>Horizontal</enum>
933 </property>
934 <property stdset="1">
935 <name>sizeType</name>
936 <enum>Expanding</enum>
937 </property>
938 <property>
939 <name>sizeHint</name>
940 <size>
941 <width>20</width>
942 <height>20</height>
943 </size>
944 </property>
945 </spacer>
946 </grid>
947 </widget>
948 <widget>
949 <class>QWidget</class>
950 <property stdset="1">
951 <name>name</name>
952 <cstring>tab</cstring>
953 </property>
954 <attribute>
955 <name>title</name>
956 <string>New</string>
957 </attribute>
958 <grid>
959 <property stdset="1">
960 <name>margin</name>
961 <number>2</number>
962 </property>
963 <property stdset="1">
964 <name>spacing</name>
965 <number>1</number>
966 </property>
967 <widget row="0" column="0" rowspan="1" colspan="3" >
968 <class>QLabel</class>
969 <property stdset="1">
970 <name>name</name>
971 <cstring>NewSMSMessageLabel</cstring>
972 </property>
973 <property stdset="1">
974 <name>text</name>
975 <string>Message:</string>
884 </property> 976 </property>
885 <hbox>
886 <property stdset="1">
887 <name>margin</name>
888 <number>0</number>
889 </property>
890 <property stdset="1">
891 <name>spacing</name>
892 <number>1</number>
893 </property>
894 <widget>
895 <class>QPushButton</class>
896 <property stdset="1">
897 <name>name</name>
898 <cstring>SMSDeleteButton</cstring>
899 </property>
900 <property stdset="1">
901 <name>text</name>
902 <string>Delete</string>
903 </property>
904 </widget>
905 <widget>
906 <class>QPushButton</class>
907 <property stdset="1">
908 <name>name</name>
909 <cstring>SMSSendButton</cstring>
910 </property>
911 <property stdset="1">
912 <name>text</name>
913 <string>Send</string>
914 </property>
915 </widget>
916 <widget>
917 <class>QPushButton</class>
918 <property stdset="1">
919 <name>name</name>
920 <cstring>SMSNewButton</cstring>
921 </property>
922 <property stdset="1">
923 <name>text</name>
924 <string>New</string>
925 </property>
926 </widget>
927 </hbox>
928 </widget> 977 </widget>
929 <widget row="3" column="0" > 978 <widget row="3" column="0" >
979 <class>QLabel</class>
980 <property stdset="1">
981 <name>name</name>
982 <cstring>NewSMSToLabel</cstring>
983 </property>
984 <property stdset="1">
985 <name>text</name>
986 <string>To:</string>
987 </property>
988 </widget>
989 <widget row="3" column="1" rowspan="1" colspan="4" >
990 <class>QComboBox</class>
991 <property stdset="1">
992 <name>name</name>
993 <cstring>NewSMSToBox</cstring>
994 </property>
995 <property stdset="1">
996 <name>editable</name>
997 <bool>true</bool>
998 </property>
999 <property stdset="1">
1000 <name>duplicatesEnabled</name>
1001 <bool>false</bool>
1002 </property>
1003 </widget>
1004 <widget row="1" column="0" rowspan="1" colspan="5" >
930 <class>QMultiLineEdit</class> 1005 <class>QMultiLineEdit</class>
931 <property stdset="1"> 1006 <property stdset="1">
932 <name>name</name> 1007 <name>name</name>
933 <cstring>SMSText</cstring> 1008 <cstring>NewSMSText</cstring>
934 </property> 1009 </property>
935 <property stdset="1"> 1010 <property stdset="1">
936 <name>enabled</name> 1011 <name>enabled</name>
937 <bool>false</bool> 1012 <bool>true</bool>
938 </property> 1013 </property>
939 <property stdset="1"> 1014 <property stdset="1">
@@ -947,5 +1022,53 @@
947 <property stdset="1"> 1022 <property stdset="1">
948 <name>readOnly</name> 1023 <name>readOnly</name>
949 <bool>true</bool> 1024 <bool>false</bool>
1025 </property>
1026 </widget>
1027 <widget row="4" column="4" >
1028 <class>QPushButton</class>
1029 <property stdset="1">
1030 <name>name</name>
1031 <cstring>NewSMSSendButton</cstring>
1032 </property>
1033 <property stdset="1">
1034 <name>text</name>
1035 <string>Send</string>
1036 </property>
1037 </widget>
1038 <widget row="0" column="3" rowspan="1" colspan="2" >
1039 <class>QLabel</class>
1040 <property stdset="1">
1041 <name>name</name>
1042 <cstring>NewSMSStatusLabel</cstring>
1043 </property>
1044 <property stdset="1">
1045 <name>text</name>
1046 <string></string>
1047 </property>
1048 </widget>
1049 <widget row="4" column="2" rowspan="1" colspan="2" >
1050 <class>QPushButton</class>
1051 <property stdset="1">
1052 <name>name</name>
1053 <cstring>NewSMSSaveButton</cstring>
1054 </property>
1055 <property stdset="1">
1056 <name>enabled</name>
1057 <bool>false</bool>
1058 </property>
1059 <property stdset="1">
1060 <name>text</name>
1061 <string>Save</string>
1062 </property>
1063 </widget>
1064 <widget row="4" column="0" rowspan="1" colspan="2" >
1065 <class>QPushButton</class>
1066 <property stdset="1">
1067 <name>name</name>
1068 <cstring>NewSMSClearButton</cstring>
1069 </property>
1070 <property stdset="1">
1071 <name>text</name>
1072 <string>Clear</string>
950 </property> 1073 </property>
951 </widget> 1074 </widget>
@@ -953,5 +1076,5 @@
953 </widget> 1076 </widget>
954 </widget> 1077 </widget>
955 </vbox> 1078 </grid>
956</widget> 1079</widget>
957</UI> 1080</UI>