-rw-r--r-- | noncore/unsupported/gsmtool/gsmtool.cpp | 63 | ||||
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtool.h | 4 | ||||
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtoolbase.ui | 149 |
3 files changed, 156 insertions, 60 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.cpp b/noncore/unsupported/gsmtool/gsmtool.cpp index 38baf45..c3f9482 100644 --- a/noncore/unsupported/gsmtool/gsmtool.cpp +++ b/noncore/unsupported/gsmtool/gsmtool.cpp | |||
@@ -1,38 +1,44 @@ | |||
1 | #include "gsmtool.h" | 1 | #include "gsmtool.h" |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
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 | 8 | #include <qtextbrowser.h> | |
9 | #include <termios.h> | 9 | #include <termios.h> |
10 | 10 | ||
11 | #include <gsmlib/gsm_me_ta.h> | 11 | #include <gsmlib/gsm_me_ta.h> |
12 | #include <gsmlib/gsm_unix_serial.h> | 12 | #include <gsmlib/gsm_unix_serial.h> |
13 | #include <gsmlib/gsm_sms.h> | ||
14 | #include <gsmlib/gsm_sorted_sms_store.h> | ||
13 | 15 | ||
14 | using namespace gsmlib; | 16 | using namespace gsmlib; |
15 | 17 | ||
16 | 18 | ||
17 | /* | 19 | /* |
18 | * Constructs a GSMTool which is a child of 'parent', with the | 20 | * Constructs a GSMTool which is a child of 'parent', with the |
19 | * name 'name' and widget flags set to 'f' | 21 | * name 'name' and widget flags set to 'f' |
20 | */ | 22 | */ |
21 | GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) | 23 | GSMTool::GSMTool( QWidget* parent, const char* name, WFlags fl ) |
22 | : GSMToolBase( parent, name, fl ) | 24 | : GSMToolBase( parent, name, fl ) |
23 | { | 25 | { |
24 | devicelocked = 0; | 26 | devicelocked = 0; |
25 | me = NULL; | 27 | me = NULL; |
28 | sms_store = NULL; | ||
26 | setConnected(FALSE); | 29 | setConnected(FALSE); |
27 | /* FIXME: Persistent settings for device/baudrate */ | 30 | /* FIXME: Persistent settings for device/baudrate */ |
28 | connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); | 31 | connect(ConnectButton, SIGNAL(clicked()), this, SLOT(doConnectButton())); |
29 | connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); | 32 | connect(ScanButton, SIGNAL(clicked()), this, SLOT(doScanButton())); |
30 | connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); | 33 | connect(TabWidget2, SIGNAL(currentChanged(QWidget *)), this, SLOT(doTabChanged())); |
34 | connect(SMSStoreList, SIGNAL(activated(int)), this, SLOT(doSMSStoreChanged())); | ||
35 | connect(SMSViewType, SIGNAL(activated(int)), this, SLOT(doSMSTypeChanged())); | ||
36 | |||
31 | timerid = -1; // Is this not possible normally? | 37 | timerid = -1; // Is this not possible normally? |
32 | } | 38 | } |
33 | 39 | ||
34 | /* | 40 | /* |
35 | * Destroys the object and frees any allocated resources | 41 | * Destroys the object and frees any allocated resources |
36 | */ | 42 | */ |
37 | GSMTool::~GSMTool() | 43 | GSMTool::~GSMTool() |
38 | { | 44 | { |
@@ -124,16 +130,59 @@ void GSMTool::timerEvent( QTimerEvent * ) | |||
124 | sprintf(buf, "%d", -113 + (2*csq)); | 130 | sprintf(buf, "%d", -113 + (2*csq)); |
125 | SigStrText->setText(buf); | 131 | SigStrText->setText(buf); |
126 | dB->setEnabled(TRUE); | 132 | dB->setEnabled(TRUE); |
127 | SigStrLabel->setEnabled(TRUE); | 133 | SigStrLabel->setEnabled(TRUE); |
128 | } | 134 | } |
129 | } | 135 | } |
130 | } | 136 | } |
131 | 137 | ||
138 | void GSMTool::doSMSStoreChanged() | ||
139 | { | ||
140 | const char *storename = SMSStoreList->currentText().ascii(); | ||
141 | qDebug("Store Changed to '%s'", storename); | ||
142 | try { | ||
143 | sms_store = me->getSMSStore(storename); | ||
144 | |||
145 | qDebug("got store of size %d", sms_store->size()); | ||
146 | } catch (GsmException) { | ||
147 | sms_store = NULL; | ||
148 | qDebug("get store failed"); | ||
149 | } | ||
150 | doSMSTypeChanged(); | ||
151 | } | ||
152 | |||
153 | void GSMTool::doSMSTypeChanged() | ||
154 | { | ||
155 | int direction = SMSViewType->currentItem(); | ||
156 | qDebug("direction %s\n", direction?"outgoing":"incoming"); | ||
157 | |||
158 | SMSList->clear(); | ||
159 | if (sms_store == NULL) | ||
160 | return; | ||
161 | for (int i = 0; i < sms_store->size(); i++) { | ||
162 | qDebug("Message %d", i); | ||
163 | qDebug("Is%sempty", sms_store()[i].empty()?" ":" not "); | ||
164 | if (sms_store()[i].empty()) | ||
165 | continue; | ||
166 | |||
167 | qDebug("Status %d", sms_store()[i].status()); | ||
168 | SMSMessageRef message = sms_store()[i].message(); | ||
169 | qDebug("Got message."); | ||
170 | |||
171 | #if 0 // WTF does this die? Did I mention that gsmlib needs rewriting in a sane language? | ||
172 | qDebug(message->toString().c_str()); | ||
173 | if (direction == message->messageType()) { | ||
174 | qDebug("yes\n"); | ||
175 | new QListViewItem(SMSList, "xx", message->address()._number.c_str()); | ||
176 | } else qDebug("no. dir %d, type %d\n", direction, message->messageType()); | ||
177 | #endif | ||
178 | } | ||
179 | } | ||
180 | |||
132 | void GSMTool::doScanButton() | 181 | void GSMTool::doScanButton() |
133 | { | 182 | { |
134 | qDebug("ScanButton"); | 183 | qDebug("ScanButton"); |
135 | 184 | ||
136 | NetworkList->setEnabled(FALSE); | 185 | NetworkList->setEnabled(FALSE); |
137 | AvailNetsLabel->setEnabled(FALSE); | 186 | AvailNetsLabel->setEnabled(FALSE); |
138 | NetworkList->clear(); | 187 | NetworkList->clear(); |
139 | new QListViewItem(NetworkList, "Scanning..."); | 188 | new QListViewItem(NetworkList, "Scanning..."); |
@@ -243,9 +292,21 @@ void GSMTool::doConnectButton() | |||
243 | return; | 292 | return; |
244 | } | 293 | } |
245 | 294 | ||
246 | MfrText->setText(ifo._manufacturer.c_str()); | 295 | MfrText->setText(ifo._manufacturer.c_str()); |
247 | ModelText->setText(ifo._model.c_str()); | 296 | ModelText->setText(ifo._model.c_str()); |
248 | RevisionText->setText(ifo._revision.c_str()); | 297 | RevisionText->setText(ifo._revision.c_str()); |
249 | SerialText->setText(ifo._serialNumber.c_str()); | 298 | SerialText->setText(ifo._serialNumber.c_str()); |
250 | setConnected(TRUE); | 299 | setConnected(TRUE); |
300 | |||
301 | SMSStoreList->clear(); | ||
302 | SMSStoreList->insertItem("None"); | ||
303 | |||
304 | vector<string> storenames = me->getSMSStoreNames(); | ||
305 | |||
306 | for (vector<string>::iterator i = storenames.begin(); i != storenames.end(); ++i) { | ||
307 | SMSStoreList->insertItem(i->c_str()); | ||
308 | } | ||
309 | SMSList->clear(); | ||
310 | SMSText->setText(""); | ||
311 | sms_store = NULL; | ||
251 | } | 312 | } |
diff --git a/noncore/unsupported/gsmtool/gsmtool.h b/noncore/unsupported/gsmtool/gsmtool.h index 1625cb1..49387d9 100644 --- a/noncore/unsupported/gsmtool/gsmtool.h +++ b/noncore/unsupported/gsmtool/gsmtool.h | |||
@@ -16,22 +16,26 @@ public: | |||
16 | 16 | ||
17 | protected: | 17 | protected: |
18 | void timerEvent(QTimerEvent *te ); | 18 | void timerEvent(QTimerEvent *te ); |
19 | 19 | ||
20 | private slots: | 20 | private slots: |
21 | void doConnectButton(); | 21 | void doConnectButton(); |
22 | void doScanButton(); | 22 | void doScanButton(); |
23 | void doTabChanged(); | 23 | void doTabChanged(); |
24 | void doSMSStoreChanged(); | ||
25 | void doSMSTypeChanged(); | ||
26 | |||
24 | private: | 27 | private: |
25 | static const speed_t baudrates[]; | 28 | static const speed_t baudrates[]; |
26 | int devicelocked; | 29 | int devicelocked; |
27 | int timerid; | 30 | int timerid; |
28 | 31 | ||
29 | gsmlib::MeTa *me; | 32 | gsmlib::MeTa *me; |
33 | gsmlib::SMSStoreRef sms_store; | ||
30 | 34 | ||
31 | char *devicename; | 35 | char *devicename; |
32 | speed_t baudrate; | 36 | speed_t baudrate; |
33 | 37 | ||
34 | int lockDevice( ); | 38 | int lockDevice( ); |
35 | void unlockDevice( ); | 39 | void unlockDevice( ); |
36 | 40 | ||
37 | void setConnected( bool conn ); | 41 | void setConnected( bool conn ); |
diff --git a/noncore/unsupported/gsmtool/gsmtoolbase.ui b/noncore/unsupported/gsmtool/gsmtoolbase.ui index 72c943a..340f26c 100644 --- a/noncore/unsupported/gsmtool/gsmtoolbase.ui +++ b/noncore/unsupported/gsmtool/gsmtoolbase.ui | |||
@@ -6,18 +6,18 @@ | |||
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>GSM Tool</cstring> | 7 | <cstring>GSM Tool</cstring> |
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>388</width> | 14 | <width>309</width> |
15 | <height>502</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> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
@@ -734,66 +734,101 @@ | |||
734 | <property stdset="1"> | 734 | <property stdset="1"> |
735 | <name>name</name> | 735 | <name>name</name> |
736 | <cstring>tab</cstring> | 736 | <cstring>tab</cstring> |
737 | </property> | 737 | </property> |
738 | <attribute> | 738 | <attribute> |
739 | <name>title</name> | 739 | <name>title</name> |
740 | <string>SMS</string> | 740 | <string>SMS</string> |
741 | </attribute> | 741 | </attribute> |
742 | <grid> | 742 | <vbox> |
743 | <property stdset="1"> | 743 | <property stdset="1"> |
744 | <name>margin</name> | 744 | <name>margin</name> |
745 | <number>2</number> | 745 | <number>11</number> |
746 | </property> | 746 | </property> |
747 | <property stdset="1"> | 747 | <property stdset="1"> |
748 | <name>spacing</name> | 748 | <name>spacing</name> |
749 | <number>1</number> | 749 | <number>6</number> |
750 | </property> | 750 | </property> |
751 | <widget row="0" column="1" > | 751 | <widget> |
752 | <class>QComboBox</class> | 752 | <class>QLayoutWidget</class> |
753 | <item> | ||
754 | <property> | ||
755 | <name>text</name> | ||
756 | <string>None</string> | ||
757 | </property> | ||
758 | </item> | ||
759 | <item> | ||
760 | <property> | ||
761 | <name>text</name> | ||
762 | <string>Incoming</string> | ||
763 | </property> | ||
764 | </item> | ||
765 | <item> | ||
766 | <property> | ||
767 | <name>text</name> | ||
768 | <string>Outgoing</string> | ||
769 | </property> | ||
770 | </item> | ||
771 | <property stdset="1"> | ||
772 | <name>name</name> | ||
773 | <cstring>ComboBox11</cstring> | ||
774 | </property> | ||
775 | <property stdset="1"> | ||
776 | <name>enabled</name> | ||
777 | <bool>true</bool> | ||
778 | </property> | ||
779 | </widget> | ||
780 | <widget row="0" column="0" > | ||
781 | <class>QLabel</class> | ||
782 | <property stdset="1"> | 753 | <property stdset="1"> |
783 | <name>name</name> | 754 | <name>name</name> |
784 | <cstring>TextLabel4</cstring> | 755 | <cstring>Layout6</cstring> |
785 | </property> | ||
786 | <property stdset="1"> | ||
787 | <name>text</name> | ||
788 | <string>Message Collection:</string> | ||
789 | </property> | 756 | </property> |
757 | <hbox> | ||
758 | <property stdset="1"> | ||
759 | <name>margin</name> | ||
760 | <number>0</number> | ||
761 | </property> | ||
762 | <property stdset="1"> | ||
763 | <name>spacing</name> | ||
764 | <number>6</number> | ||
765 | </property> | ||
766 | <widget> | ||
767 | <class>QLabel</class> | ||
768 | <property stdset="1"> | ||
769 | <name>name</name> | ||
770 | <cstring>SMSStoreLabel</cstring> | ||
771 | </property> | ||
772 | <property stdset="1"> | ||
773 | <name>text</name> | ||
774 | <string>Store:</string> | ||
775 | </property> | ||
776 | </widget> | ||
777 | <widget> | ||
778 | <class>QComboBox</class> | ||
779 | <item> | ||
780 | <property> | ||
781 | <name>text</name> | ||
782 | <string>None</string> | ||
783 | </property> | ||
784 | </item> | ||
785 | <property stdset="1"> | ||
786 | <name>name</name> | ||
787 | <cstring>SMSStoreList</cstring> | ||
788 | </property> | ||
789 | <property stdset="1"> | ||
790 | <name>enabled</name> | ||
791 | <bool>true</bool> | ||
792 | </property> | ||
793 | </widget> | ||
794 | <widget> | ||
795 | <class>QLabel</class> | ||
796 | <property stdset="1"> | ||
797 | <name>name</name> | ||
798 | <cstring>SMSTypeLabel</cstring> | ||
799 | </property> | ||
800 | <property stdset="1"> | ||
801 | <name>text</name> | ||
802 | <string>Type:</string> | ||
803 | </property> | ||
804 | </widget> | ||
805 | <widget> | ||
806 | <class>QComboBox</class> | ||
807 | <item> | ||
808 | <property> | ||
809 | <name>text</name> | ||
810 | <string>Incoming</string> | ||
811 | </property> | ||
812 | </item> | ||
813 | <item> | ||
814 | <property> | ||
815 | <name>text</name> | ||
816 | <string>Outgoing</string> | ||
817 | </property> | ||
818 | </item> | ||
819 | <property stdset="1"> | ||
820 | <name>name</name> | ||
821 | <cstring>SMSViewType</cstring> | ||
822 | </property> | ||
823 | </widget> | ||
824 | </hbox> | ||
790 | </widget> | 825 | </widget> |
791 | <widget row="1" column="0" rowspan="1" colspan="2" > | 826 | <widget> |
792 | <class>QListView</class> | 827 | <class>QListView</class> |
793 | <column> | 828 | <column> |
794 | <property> | 829 | <property> |
795 | <name>text</name> | 830 | <name>text</name> |
796 | <string>Date</string> | 831 | <string>Date</string> |
797 | </property> | 832 | </property> |
798 | <property> | 833 | <property> |
799 | <name>clickable</name> | 834 | <name>clickable</name> |
@@ -815,31 +850,20 @@ | |||
815 | </property> | 850 | </property> |
816 | <property> | 851 | <property> |
817 | <name>resizeable</name> | 852 | <name>resizeable</name> |
818 | <bool>true</bool> | 853 | <bool>true</bool> |
819 | </property> | 854 | </property> |
820 | </column> | 855 | </column> |
821 | <property stdset="1"> | 856 | <property stdset="1"> |
822 | <name>name</name> | 857 | <name>name</name> |
823 | <cstring>ListView3</cstring> | 858 | <cstring>SMSList</cstring> |
824 | </property> | ||
825 | </widget> | ||
826 | <widget row="3" column="0" rowspan="1" colspan="2" > | ||
827 | <class>QMultiLineEdit</class> | ||
828 | <property stdset="1"> | ||
829 | <name>name</name> | ||
830 | <cstring>MultiLineEdit3</cstring> | ||
831 | </property> | ||
832 | <property stdset="1"> | ||
833 | <name>readOnly</name> | ||
834 | <bool>true</bool> | ||
835 | </property> | 859 | </property> |
836 | </widget> | 860 | </widget> |
837 | <widget row="2" column="0" rowspan="1" colspan="2" > | 861 | <widget> |
838 | <class>QLayoutWidget</class> | 862 | <class>QLayoutWidget</class> |
839 | <property stdset="1"> | 863 | <property stdset="1"> |
840 | <name>name</name> | 864 | <name>name</name> |
841 | <cstring>Layout15</cstring> | 865 | <cstring>Layout15</cstring> |
842 | </property> | 866 | </property> |
843 | <property> | 867 | <property> |
844 | <name>layoutMargin</name> | 868 | <name>layoutMargin</name> |
845 | </property> | 869 | </property> |
@@ -851,45 +875,52 @@ | |||
851 | <property stdset="1"> | 875 | <property stdset="1"> |
852 | <name>spacing</name> | 876 | <name>spacing</name> |
853 | <number>1</number> | 877 | <number>1</number> |
854 | </property> | 878 | </property> |
855 | <widget> | 879 | <widget> |
856 | <class>QPushButton</class> | 880 | <class>QPushButton</class> |
857 | <property stdset="1"> | 881 | <property stdset="1"> |
858 | <name>name</name> | 882 | <name>name</name> |
859 | <cstring>PushButton11</cstring> | 883 | <cstring>SMSDeleteButton</cstring> |
860 | </property> | 884 | </property> |
861 | <property stdset="1"> | 885 | <property stdset="1"> |
862 | <name>text</name> | 886 | <name>text</name> |
863 | <string>Delete</string> | 887 | <string>Delete</string> |
864 | </property> | 888 | </property> |
865 | </widget> | 889 | </widget> |
866 | <widget> | 890 | <widget> |
867 | <class>QPushButton</class> | 891 | <class>QPushButton</class> |
868 | <property stdset="1"> | 892 | <property stdset="1"> |
869 | <name>name</name> | 893 | <name>name</name> |
870 | <cstring>PushButton12</cstring> | 894 | <cstring>SMSSendButton</cstring> |
871 | </property> | 895 | </property> |
872 | <property stdset="1"> | 896 | <property stdset="1"> |
873 | <name>text</name> | 897 | <name>text</name> |
874 | <string>Send</string> | 898 | <string>Send</string> |
875 | </property> | 899 | </property> |
876 | </widget> | 900 | </widget> |
877 | <widget> | 901 | <widget> |
878 | <class>QPushButton</class> | 902 | <class>QPushButton</class> |
879 | <property stdset="1"> | 903 | <property stdset="1"> |
880 | <name>name</name> | 904 | <name>name</name> |
881 | <cstring>PushButton13</cstring> | 905 | <cstring>SMSNewButton</cstring> |
882 | </property> | 906 | </property> |
883 | <property stdset="1"> | 907 | <property stdset="1"> |
884 | <name>text</name> | 908 | <name>text</name> |
885 | <string>New</string> | 909 | <string>New</string> |
886 | </property> | 910 | </property> |
887 | </widget> | 911 | </widget> |
888 | </hbox> | 912 | </hbox> |
889 | </widget> | 913 | </widget> |
890 | </grid> | 914 | <widget> |
915 | <class>QTextBrowser</class> | ||
916 | <property stdset="1"> | ||
917 | <name>name</name> | ||
918 | <cstring>SMSText</cstring> | ||
919 | </property> | ||
920 | </widget> | ||
921 | </vbox> | ||
891 | </widget> | 922 | </widget> |
892 | </widget> | 923 | </widget> |
893 | </vbox> | 924 | </vbox> |
894 | </widget> | 925 | </widget> |
895 | </UI> | 926 | </UI> |