author | dwmw2 <dwmw2> | 2002-04-04 14:08:17 (UTC) |
---|---|---|
committer | dwmw2 <dwmw2> | 2002-04-04 14:08:17 (UTC) |
commit | d3ef7996a0c857451395fcdd2eed63399100586a (patch) (unidiff) | |
tree | 054563aae8769f9bf584fab3beee2c63f880c869 | |
parent | 351f962d07ad32ab3cc3442f85b9fd20fe621b4c (diff) | |
download | opie-d3ef7996a0c857451395fcdd2eed63399100586a.zip opie-d3ef7996a0c857451395fcdd2eed63399100586a.tar.gz opie-d3ef7996a0c857451395fcdd2eed63399100586a.tar.bz2 |
SMS sending
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtool.cpp | 129 | ||||
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtool.h | 9 | ||||
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtoolbase.ui | 237 |
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 | |||
@@ -33,2 +33,7 @@ GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) | |||
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())); |
@@ -71,2 +76,3 @@ void GSMTool::setConnected( bool 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); |
@@ -146,3 +152,4 @@ void GSMTool::doSMSStoreChanged() | |||
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 | ||
@@ -155,2 +162,3 @@ void GSMTool::doSMSStoreChanged() | |||
155 | SMSList->setEnabled(!(sms_store == NULL)); | 162 | SMSList->setEnabled(!(sms_store == NULL)); |
163 | NewSMSSaveButton->setEnabled(!(sms_store == NULL)); | ||
156 | doSMSTypeChanged(); | 164 | doSMSTypeChanged(); |
@@ -162,2 +170,6 @@ void GSMTool::doSMSTypeChanged() | |||
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 | ||
@@ -168,10 +180,11 @@ void GSMTool::doSMSTypeChanged() | |||
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."); |
@@ -182,3 +195,3 @@ void GSMTool::doSMSTypeChanged() | |||
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); |
@@ -209,3 +222,3 @@ void GSMTool::doSelectedSMSChanged(QListViewItem *item) | |||
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 | ||
@@ -217,2 +230,100 @@ void GSMTool::doSelectedSMSChanged(QListViewItem *item) | |||
217 | } | 230 | } |
231 | |||
232 | void 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 | |||
257 | void GSMTool::doNewSMSClearButton() | ||
258 | { | ||
259 | NewSMSText->setText(""); | ||
260 | } | ||
261 | |||
262 | void 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 | } | ||
278 | void 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 | |||
308 | void 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 | |||
218 | void GSMTool::doScanButton() | 329 | void GSMTool::doScanButton() |
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 | |||
@@ -7,2 +7,3 @@ | |||
7 | #include <gsmlib/gsm_me_ta.h> | 7 | #include <gsmlib/gsm_me_ta.h> |
8 | #include <gsmlib/gsm_sorted_sms_store.h> | ||
8 | 9 | ||
@@ -26,3 +27,7 @@ private slots: | |||
26 | void doSelectedSMSChanged(QListViewItem *); | 27 | void doSelectedSMSChanged(QListViewItem *); |
27 | 28 | void doSMSSendButton(); | |
29 | void doSMSDeleteButton(); | ||
30 | void doNewSMSClearButton(); | ||
31 | void doNewSMSSaveButton(); | ||
32 | void doNewSMSSendButton(); | ||
28 | private: | 33 | private: |
@@ -33,3 +38,3 @@ private: | |||
33 | gsmlib::MeTa *me; | 38 | gsmlib::MeTa *me; |
34 | gsmlib::SMSStoreRef sms_store; | 39 | gsmlib::SortedSMSStoreRef sms_store; |
35 | 40 | ||
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 | |||
@@ -13,3 +13,3 @@ | |||
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>371</width> | 14 | <width>404</width> |
15 | <height>390</height> | 15 | <height>390</height> |
@@ -27,3 +27,3 @@ | |||
27 | </property> | 27 | </property> |
28 | <vbox> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
@@ -36,3 +36,3 @@ | |||
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget row="0" column="0" > |
38 | <class>QTabWidget</class> | 38 | <class>QTabWidget</class> |
@@ -121,2 +121,6 @@ | |||
121 | </property> | 121 | </property> |
122 | <property stdset="1"> | ||
123 | <name>duplicatesEnabled</name> | ||
124 | <bool>false</bool> | ||
125 | </property> | ||
122 | </widget> | 126 | </widget> |
@@ -748,3 +752,3 @@ | |||
748 | <name>margin</name> | 752 | <name>margin</name> |
749 | <number>-1</number> | 753 | <number>2</number> |
750 | </property> | 754 | </property> |
@@ -752,5 +756,5 @@ | |||
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> |
@@ -832,3 +836,3 @@ | |||
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> |
@@ -875,56 +879,127 @@ | |||
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> |
@@ -932,3 +1007,3 @@ | |||
932 | <name>name</name> | 1007 | <name>name</name> |
933 | <cstring>SMSText</cstring> | 1008 | <cstring>NewSMSText</cstring> |
934 | </property> | 1009 | </property> |
@@ -936,3 +1011,3 @@ | |||
936 | <name>enabled</name> | 1011 | <name>enabled</name> |
937 | <bool>false</bool> | 1012 | <bool>true</bool> |
938 | </property> | 1013 | </property> |
@@ -948,3 +1023,51 @@ | |||
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> |
@@ -954,3 +1077,3 @@ | |||
954 | </widget> | 1077 | </widget> |
955 | </vbox> | 1078 | </grid> |
956 | </widget> | 1079 | </widget> |