summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-25 08:56:23 (UTC)
committer zautrix <zautrix>2004-10-25 08:56:23 (UTC)
commit62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3 (patch) (unidiff)
treec2b7a41b0c8fffdc0786b84ff86724ea8f08d6a1
parentfeff0930372dd51af24dc3b46697e70838277ea5 (diff)
downloadkdepimpi-62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3.zip
kdepimpi-62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3.tar.gz
kdepimpi-62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3.tar.bz2
gammu updates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/common.pro22
-rw-r--r--gammu/emb/common/commonE.pro14
-rw-r--r--gammu/emb/common/device/serial/ser_djg.c399
-rw-r--r--gammu/emb/common/device/serial/ser_djg.h37
-rw-r--r--gammu/emb/common/device/serial/ser_unx.c27
-rw-r--r--gammu/emb/common/device/serial/ser_w32.c9
-rw-r--r--gammu/emb/common/gsmstate.c7
-rw-r--r--gammu/emb/common/gsmstate.h30
-rw-r--r--gammu/emb/common/phone/alcatel/alcatel.c6
-rw-r--r--gammu/emb/common/phone/at/atgen.c8
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c19
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.c17
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n0650.c150
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n0650.h18
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n6110.c17
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.c15
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.c6
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3320.c6
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3650.c6
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.c142
-rw-r--r--gammu/emb/common/phone/nokia/nauto.c6
-rw-r--r--gammu/emb/common/phone/obex/obexgen.c6
-rw-r--r--gammu/emb/common/phone/pfunc.c1
-rw-r--r--gammu/emb/common/phone/symbian/mroutgen.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.c10
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.h9
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.c9
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.h9
-rw-r--r--gammu/emb/common/service/backup/backgen.h2
-rw-r--r--gammu/emb/common/service/backup/backtext.c12
-rw-r--r--gammu/emb/common/service/gsmring.h2
-rw-r--r--gammu/emb/gammu/gammu.c121
-rw-r--r--gammu/emb/gammu/smsd/s_files.c2
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.c31
34 files changed, 1065 insertions, 116 deletions
diff --git a/gammu/emb/common/common.pro b/gammu/emb/common/common.pro
index 797199b..af45382 100644
--- a/gammu/emb/common/common.pro
+++ b/gammu/emb/common/common.pro
@@ -1,188 +1,194 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Fri Jul 30 22:13:34 2004 2# Automatically generated by qmake (1.07a) Fri Jul 30 22:13:34 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = lib 5TEMPLATE = lib
6DEPENDPATH += device \ 6DEPENDPATH += device \
7 misc \ 7 misc \
8 phone \ 8 phone \
9 protocol \ 9 protocol \
10 service \ 10 service \
11 device/bluetoth \ 11 device/bluetoth \
12 device/irda \ 12 device/irda \
13 device/serial \ 13 device/serial \
14 misc/coding \ 14 misc/coding \
15 phone/alcatel \ 15 phone/alcatel \
16 phone/at \ 16 phone/at \
17 phone/nokia \ 17 phone/nokia \
18 phone/obex \ 18 phone/obex \
19 phone/symbian \ 19 phone/symbian \
20 protocol/alcatel \ 20 protocol/alcatel \
21 protocol/at \ 21 protocol/at \
22 protocol/nokia \ 22 protocol/nokia \
23 protocol/obex \ 23 protocol/obex \
24 protocol/symbian \ 24 protocol/symbian \
25 service/backup \ 25 service/backup \
26 service/sms \ 26 service/sms \
27 phone/nokia/dct3 \ 27 phone/nokia/dct3 \
28 phone/nokia/dct4 28 phone/nokia/dct4
29INCLUDEPATH += . \ 29INCLUDEPATH += . \
30 misc/coding \ 30 misc/coding \
31 misc \ 31 misc \
32 device \ 32 device \
33 phone/nokia/dct4 \ 33 phone/nokia/dct4 \
34 phone/nokia/dct3 \ 34 phone/nokia/dct3 \
35 phone/at \ 35 phone/at \
36 phone/alcatel \ 36 phone/alcatel \
37 phone/obex \ 37 phone/obex \
38 phone/symbian \ 38 phone/symbian \
39 protocol \ 39 protocol \
40 protocol/nokia \ 40 protocol/nokia \
41 protocol/at \ 41 protocol/at \
42 protocol/alcatel \ 42 protocol/alcatel \
43 protocol/obex \ 43 protocol/obex \
44 protocol/symbian \ 44 protocol/symbian \
45 device/serial \ 45 device/serial \
46 device/irda \ 46 device/irda \
47 device/bluetoth \ 47 device/bluetoth \
48 service \ 48 service \
49 service/sms \ 49 service/sms \
50 service/backup \ 50 service/backup \
51 phone/nokia \ 51 phone/nokia \
52 phone 52 phone
53 53
54# Input 54# Input
55HEADERS += config.h \ 55HEADERS += config.h \
56 gammu.h \ 56 gammu.h \
57 gsmcomon.h \ 57 gsmcomon.h \
58 gsmstate.h \ 58 gsmstate.h \
59 device/devfunc.h \ 59 device/devfunc.h \
60 misc/cfg.h \ 60 misc/cfg.h \
61 misc/misc.h \ 61 misc/misc.h \
62 phone/pfunc.h \ 62 phone/pfunc.h \
63 protocol/protocol.h \ 63 protocol/protocol.h \
64 service/gsmcal.h \ 64 service/gsmcal.h \
65 service/gsmcall.h \ 65 service/gsmcall.h \
66 service/gsmdata.h \ 66 service/gsmdata.h \
67 service/gsmlogo.h \ 67 service/gsmlogo.h \
68 service/gsmmisc.h \ 68 service/gsmmisc.h \
69 service/gsmnet.h \ 69 service/gsmnet.h \
70 service/gsmpbk.h \ 70 service/gsmpbk.h \
71 service/gsmprof.h \ 71 service/gsmprof.h \
72 service/gsmring.h \ 72 service/gsmring.h \
73 device/bluetoth/affix.h \ 73 device/bluetoth/affix.h \
74 device/bluetoth/blue_w32.h \
75 device/bluetoth/bluetoth.h \ 74 device/bluetoth/bluetoth.h \
76 device/bluetoth/bluez.h \ 75 device/bluetoth/bluez.h \
77 device/irda/irda.h \ 76 device/irda/irda.h \
78 device/irda/irda_unx.h \
79 device/irda/irda_w32.h \
80 device/serial/ser_djg.h \ 77 device/serial/ser_djg.h \
81 device/serial/ser_unx.h \
82 device/serial/ser_w32.h \
83 misc/coding/coding.h \ 78 misc/coding/coding.h \
84 misc/coding/md5.h \ 79 misc/coding/md5.h \
85 phone/alcatel/alcatel.h \ 80 phone/alcatel/alcatel.h \
86 phone/at/atgen.h \ 81 phone/at/atgen.h \
87 phone/nokia/ncommon.h \ 82 phone/nokia/ncommon.h \
88 phone/nokia/nfunc.h \ 83 phone/nokia/nfunc.h \
89 phone/nokia/nfuncold.h \ 84 phone/nokia/nfuncold.h \
90 phone/obex/obexgen.h \ 85 phone/obex/obexgen.h \
91 phone/symbian/mroutgen.h \ 86 phone/symbian/mroutgen.h \
92 protocol/alcatel/alcabus.h \ 87 protocol/alcatel/alcabus.h \
93 protocol/at/at.h \ 88 protocol/at/at.h \
94 protocol/nokia/fbus2.h \ 89 protocol/nokia/fbus2.h \
95 protocol/nokia/mbus2.h \ 90 protocol/nokia/mbus2.h \
96 protocol/nokia/phonet.h \ 91 protocol/nokia/phonet.h \
97 protocol/obex/obex.h \ 92 protocol/obex/obex.h \
98 protocol/symbian/mrouter.h \ 93 protocol/symbian/mrouter.h \
99 service/backup/backgen.h \ 94 service/backup/backgen.h \
100 service/backup/backics.h \ 95 service/backup/backics.h \
101 service/backup/backldif.h \ 96 service/backup/backldif.h \
102 service/backup/backlmb.h \ 97 service/backup/backlmb.h \
103 service/backup/backtext.h \ 98 service/backup/backtext.h \
104 service/backup/backvcf.h \ 99 service/backup/backvcf.h \
105 service/backup/backvcs.h \ 100 service/backup/backvcs.h \
106 service/backup/gsmback.h \ 101 service/backup/gsmback.h \
107 service/sms/gsmems.h \ 102 service/sms/gsmems.h \
108 service/sms/gsmmulti.h \ 103 service/sms/gsmmulti.h \
109 service/sms/gsmsms.h \ 104 service/sms/gsmsms.h \
110 phone/nokia/dct3/dct3comm.h \ 105 phone/nokia/dct3/dct3comm.h \
111 phone/nokia/dct3/dct3func.h \ 106 phone/nokia/dct3/dct3func.h \
112 phone/nokia/dct3/n6110.h \ 107 phone/nokia/dct3/n6110.h \
113 phone/nokia/dct3/n7110.h \ 108 phone/nokia/dct3/n7110.h \
109 phone/nokia/dct3/n0650.h \
114 phone/nokia/dct3/n9210.h \ 110 phone/nokia/dct3/n9210.h \
115 phone/nokia/dct4/dct4func.h \ 111 phone/nokia/dct4/dct4func.h \
116 phone/nokia/dct4/n3320.h \ 112 phone/nokia/dct4/n3320.h \
117 phone/nokia/dct4/n3650.h \ 113 phone/nokia/dct4/n3650.h \
118 phone/nokia/dct4/n6510.h 114 phone/nokia/dct4/n6510.h
119SOURCES +=gsmcomon.c \ 115SOURCES +=gsmcomon.c \
120gsmstate.c \ 116gsmstate.c \
121misc/misc.c \ 117misc/misc.c \
122misc/cfg.c \ 118misc/cfg.c \
123misc/coding/coding.c \ 119misc/coding/coding.c \
124misc/coding/md5.c \ 120misc/coding/md5.c \
125service/sms/gsmsms.c \ 121service/sms/gsmsms.c \
126service/sms/gsmems.c \ 122service/sms/gsmems.c \
127service/sms/gsmmulti.c \ 123service/sms/gsmmulti.c \
128service/gsmcal.c \ 124service/gsmcal.c \
129service/gsmdata.c \ 125service/gsmdata.c \
130service/gsmpbk.c \ 126service/gsmpbk.c \
131service/gsmring.c \ 127service/gsmring.c \
132service/gsmlogo.c \ 128service/gsmlogo.c \
133service/gsmmisc.c \ 129service/gsmmisc.c \
134service/gsmnet.c \ 130service/gsmnet.c \
135service/backup/gsmback.c \ 131service/backup/gsmback.c \
136service/backup/backldif.c \ 132service/backup/backldif.c \
137service/backup/backlmb.c \ 133service/backup/backlmb.c \
138service/backup/backtext.c \ 134service/backup/backtext.c \
139service/backup/backvcs.c \ 135service/backup/backvcs.c \
140service/backup/backvcf.c \ 136service/backup/backvcf.c \
141service/backup/backics.c \ 137service/backup/backics.c \
142device/bluetoth/affix.c \ 138device/bluetoth/affix.c \
143device/bluetoth/bluez.c \ 139device/bluetoth/bluez.c \
144device/bluetoth/blue_w32.c \
145device/bluetoth/bluetoth.c \ 140device/bluetoth/bluetoth.c \
146device/serial/ser_djg.c \ 141device/serial/ser_djg.c \
147device/irda/irda.c \ 142device/irda/irda.c \
148device/devfunc.c \ 143device/devfunc.c \
149protocol/at/at.c \ 144protocol/at/at.c \
150protocol/alcatel/alcabus.c \ 145protocol/alcatel/alcabus.c \
151protocol/nokia/mbus2.c \ 146protocol/nokia/mbus2.c \
152protocol/nokia/fbus2.c \ 147protocol/nokia/fbus2.c \
153protocol/nokia/phonet.c \ 148protocol/nokia/phonet.c \
154protocol/obex/obex.c \ 149protocol/obex/obex.c \
155protocol/symbian/mrouter.c \ 150protocol/symbian/mrouter.c \
156phone/pfunc.c \ 151phone/pfunc.c \
157phone/at/atgen.c \ 152phone/at/atgen.c \
158phone/at/siemens.c \ 153phone/at/siemens.c \
159phone/at/samsung.c \ 154phone/at/samsung.c \
160phone/at/sonyeric.c \ 155phone/at/sonyeric.c \
161phone/alcatel/alcatel.c \ 156phone/alcatel/alcatel.c \
162phone/nokia/dct3/n6110.c \ 157phone/nokia/dct3/n6110.c \
163phone/nokia/dct3/n7110.c \ 158phone/nokia/dct3/n7110.c \
159phone/nokia/dct3/n0650.c \
164phone/nokia/dct3/n9210.c \ 160phone/nokia/dct3/n9210.c \
165phone/nokia/dct3/dct3func.c \ 161phone/nokia/dct3/dct3func.c \
166phone/nokia/dct4/n3320.c \ 162phone/nokia/dct4/n3320.c \
167phone/nokia/dct4/n3650.c \ 163phone/nokia/dct4/n3650.c \
168phone/nokia/dct4/n6510.c \ 164phone/nokia/dct4/n6510.c \
169phone/nokia/dct4/dct4func.c \ 165phone/nokia/dct4/dct4func.c \
170phone/nokia/nauto.c \ 166phone/nokia/nauto.c \
171phone/nokia/nfunc.c \ 167phone/nokia/nfunc.c \
172phone/nokia/nfuncold.c \ 168phone/nokia/nfuncold.c \
173phone/obex/obexgen.c \ 169phone/obex/obexgen.c \
174phone/symbian/mroutgen.c 170phone/symbian/mroutgen.c
175 171
176DEFINES += DESKTOP_VERSION 172DEFINES += DESKTOP_VERSION
177TARGET = microgammu 173TARGET = microgammu
178CONFIG = warn_off release console 174CONFIG = warn_off release console
179DESTDIR = ../../../bin 175DESTDIR = ../../../bin
180OBJECTS_DIR = obj/unix 176OBJECTS_DIR = obj/unix
181MOC_DIR = moc/unix 177MOC_DIR = moc/unix
182 178
183unix: { 179unix: {
184SOURCES += device/serial/ser_unx.c 180HEADERS += device/serial/ser_unx.h \
181 device/irda/irda_unx.h
182
183SOURCES += device/serial/ser_unx.c \
184
185} 185}
186win32:{ 186win32:{
187SOURCES += device/serial/ser_w32.c 187
188HEADERS += device/serial/ser_w32.h \
189 device/irda/irda_w32.h \
190 device/bluetoth/blue_w32.h
191
192SOURCES += device/serial/ser_w32.c \
193 device/bluetoth/blue_w32.c
188} 194}
diff --git a/gammu/emb/common/commonE.pro b/gammu/emb/common/commonE.pro
index f5b559d..1512814 100644
--- a/gammu/emb/common/commonE.pro
+++ b/gammu/emb/common/commonE.pro
@@ -1,181 +1,187 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Fri Jul 30 22:13:34 2004 2# Automatically generated by qmake (1.07a) Fri Jul 30 22:13:34 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = lib 5TEMPLATE = lib
6DEPENDPATH += device \ 6DEPENDPATH += device \
7 misc \ 7 misc \
8 phone \ 8 phone \
9 protocol \ 9 protocol \
10 service \ 10 service \
11 device/bluetoth \ 11 device/bluetoth \
12 device/irda \ 12 device/irda \
13 device/serial \ 13 device/serial \
14 misc/coding \ 14 misc/coding \
15 phone/alcatel \ 15 phone/alcatel \
16 phone/at \ 16 phone/at \
17 phone/nokia \ 17 phone/nokia \
18 phone/obex \ 18 phone/obex \
19 phone/symbian \ 19 phone/symbian \
20 protocol/alcatel \ 20 protocol/alcatel \
21 protocol/at \ 21 protocol/at \
22 protocol/nokia \ 22 protocol/nokia \
23 protocol/obex \ 23 protocol/obex \
24 protocol/symbian \ 24 protocol/symbian \
25 service/backup \ 25 service/backup \
26 service/sms \ 26 service/sms \
27 phone/nokia/dct3 \ 27 phone/nokia/dct3 \
28 phone/nokia/dct4 28 phone/nokia/dct4
29INCLUDEPATH += . \ 29INCLUDEPATH += . \
30 misc/coding \ 30 misc/coding \
31 misc \ 31 misc \
32 device \ 32 device \
33 phone/nokia/dct4 \ 33 phone/nokia/dct4 \
34 phone/nokia/dct3 \ 34 phone/nokia/dct3 \
35 phone/at \ 35 phone/at \
36 phone/alcatel \ 36 phone/alcatel \
37 phone/obex \ 37 phone/obex \
38 phone/symbian \ 38 phone/symbian \
39 protocol \ 39 protocol \
40 protocol/nokia \ 40 protocol/nokia \
41 protocol/at \ 41 protocol/at \
42 protocol/alcatel \ 42 protocol/alcatel \
43 protocol/obex \ 43 protocol/obex \
44 protocol/symbian \ 44 protocol/symbian \
45 device/serial \ 45 device/serial \
46 device/irda \ 46 device/irda \
47 device/bluetoth \ 47 device/bluetoth \
48 service \ 48 service \
49 service/sms \ 49 service/sms \
50 service/backup \ 50 service/backup \
51 phone/nokia \ 51 phone/nokia \
52 phone 52 phone
53 53
54# Input 54# Input
55HEADERS += config.h \ 55HEADERS += config.h \
56 gammu.h \ 56 gammu.h \
57 gsmcomon.h \ 57 gsmcomon.h \
58 gsmstate.h \ 58 gsmstate.h \
59 device/devfunc.h \ 59 device/devfunc.h \
60 misc/cfg.h \ 60 misc/cfg.h \
61 misc/misc.h \ 61 misc/misc.h \
62 phone/pfunc.h \ 62 phone/pfunc.h \
63 protocol/protocol.h \ 63 protocol/protocol.h \
64 service/gsmcal.h \ 64 service/gsmcal.h \
65 service/gsmcall.h \ 65 service/gsmcall.h \
66 service/gsmdata.h \ 66 service/gsmdata.h \
67 service/gsmlogo.h \ 67 service/gsmlogo.h \
68 service/gsmmisc.h \ 68 service/gsmmisc.h \
69 service/gsmnet.h \ 69 service/gsmnet.h \
70 service/gsmpbk.h \ 70 service/gsmpbk.h \
71 service/gsmprof.h \ 71 service/gsmprof.h \
72 service/gsmring.h \ 72 service/gsmring.h \
73 device/bluetoth/affix.h \ 73 device/bluetoth/affix.h \
74 device/bluetoth/blue_w32.h \
75 device/bluetoth/bluetoth.h \ 74 device/bluetoth/bluetoth.h \
76 device/bluetoth/bluez.h \ 75 device/bluetoth/bluez.h \
77 device/irda/irda.h \ 76 device/irda/irda.h \
78 device/irda/irda_unx.h \ 77 device/irda/irda_unx.h \
79 device/irda/irda_w32.h \
80 device/serial/ser_djg.h \ 78 device/serial/ser_djg.h \
81 device/serial/ser_unx.h \ 79 device/serial/ser_unx.h \
82 device/serial/ser_w32.h \
83 misc/coding/coding.h \ 80 misc/coding/coding.h \
84 misc/coding/md5.h \ 81 misc/coding/md5.h \
85 phone/alcatel/alcatel.h \ 82 phone/alcatel/alcatel.h \
86 phone/at/atgen.h \ 83 phone/at/atgen.h \
87 phone/nokia/ncommon.h \ 84 phone/nokia/ncommon.h \
88 phone/nokia/nfunc.h \ 85 phone/nokia/nfunc.h \
89 phone/nokia/nfuncold.h \ 86 phone/nokia/nfuncold.h \
90 phone/obex/obexgen.h \ 87 phone/obex/obexgen.h \
91 phone/symbian/mroutgen.h \ 88 phone/symbian/mroutgen.h \
92 protocol/alcatel/alcabus.h \ 89 protocol/alcatel/alcabus.h \
93 protocol/at/at.h \ 90 protocol/at/at.h \
94 protocol/nokia/fbus2.h \ 91 protocol/nokia/fbus2.h \
95 protocol/nokia/mbus2.h \ 92 protocol/nokia/mbus2.h \
96 protocol/nokia/phonet.h \ 93 protocol/nokia/phonet.h \
97 protocol/obex/obex.h \ 94 protocol/obex/obex.h \
98 protocol/symbian/mrouter.h \ 95 protocol/symbian/mrouter.h \
99 service/backup/backgen.h \ 96 service/backup/backgen.h \
100 service/backup/backics.h \ 97 service/backup/backics.h \
101 service/backup/backldif.h \ 98 service/backup/backldif.h \
102 service/backup/backlmb.h \ 99 service/backup/backlmb.h \
103 service/backup/backtext.h \ 100 service/backup/backtext.h \
104 service/backup/backvcf.h \ 101 service/backup/backvcf.h \
105 service/backup/backvcs.h \ 102 service/backup/backvcs.h \
106 service/backup/gsmback.h \ 103 service/backup/gsmback.h \
107 service/sms/gsmems.h \ 104 service/sms/gsmems.h \
108 service/sms/gsmmulti.h \ 105 service/sms/gsmmulti.h \
109 service/sms/gsmsms.h \ 106 service/sms/gsmsms.h \
110 phone/nokia/dct3/dct3comm.h \ 107 phone/nokia/dct3/dct3comm.h \
111 phone/nokia/dct3/dct3func.h \ 108 phone/nokia/dct3/dct3func.h \
112 phone/nokia/dct3/n6110.h \ 109 phone/nokia/dct3/n6110.h \
113 phone/nokia/dct3/n7110.h \ 110 phone/nokia/dct3/n7110.h \
114 phone/nokia/dct3/n9210.h \ 111 phone/nokia/dct3/n9210.h \
115 phone/nokia/dct4/dct4func.h \ 112 phone/nokia/dct4/dct4func.h \
116 phone/nokia/dct4/n3320.h \ 113 phone/nokia/dct4/n3320.h \
114 phone/nokia/dct3/n0650.h \
117 phone/nokia/dct4/n3650.h \ 115 phone/nokia/dct4/n3650.h \
118 phone/nokia/dct4/n6510.h 116 phone/nokia/dct4/n6510.h
119SOURCES +=gsmcomon.c \ 117SOURCES +=gsmcomon.c \
120gsmstate.c \ 118gsmstate.c \
121misc/misc.c \ 119misc/misc.c \
122misc/cfg.c \ 120misc/cfg.c \
123misc/coding/coding.c \ 121misc/coding/coding.c \
124misc/coding/md5.c \ 122misc/coding/md5.c \
125service/sms/gsmsms.c \ 123service/sms/gsmsms.c \
126service/sms/gsmems.c \ 124service/sms/gsmems.c \
127service/sms/gsmmulti.c \ 125service/sms/gsmmulti.c \
128service/gsmcal.c \ 126service/gsmcal.c \
129service/gsmdata.c \ 127service/gsmdata.c \
130service/gsmpbk.c \ 128service/gsmpbk.c \
131service/gsmring.c \ 129service/gsmring.c \
132service/gsmlogo.c \ 130service/gsmlogo.c \
133service/gsmmisc.c \ 131service/gsmmisc.c \
134service/gsmnet.c \ 132service/gsmnet.c \
135service/backup/gsmback.c \ 133service/backup/gsmback.c \
136service/backup/backldif.c \ 134service/backup/backldif.c \
137service/backup/backlmb.c \ 135service/backup/backlmb.c \
138service/backup/backtext.c \ 136service/backup/backtext.c \
139service/backup/backvcs.c \ 137service/backup/backvcs.c \
140service/backup/backvcf.c \ 138service/backup/backvcf.c \
141service/backup/backics.c \ 139service/backup/backics.c \
142device/bluetoth/affix.c \ 140device/bluetoth/affix.c \
143device/bluetoth/bluez.c \ 141device/bluetoth/bluez.c \
144device/bluetoth/blue_w32.c \
145device/bluetoth/bluetoth.c \ 142device/bluetoth/bluetoth.c \
146device/serial/ser_unx.c \ 143device/serial/ser_unx.c \
147device/serial/ser_djg.c \ 144device/serial/ser_djg.c \
148device/irda/irda.c \ 145device/irda/irda.c \
149device/devfunc.c \ 146device/devfunc.c \
150protocol/at/at.c \ 147protocol/at/at.c \
151protocol/alcatel/alcabus.c \ 148protocol/alcatel/alcabus.c \
152protocol/nokia/mbus2.c \ 149protocol/nokia/mbus2.c \
153protocol/nokia/fbus2.c \ 150protocol/nokia/fbus2.c \
154protocol/nokia/phonet.c \ 151protocol/nokia/phonet.c \
155protocol/obex/obex.c \ 152protocol/obex/obex.c \
156protocol/symbian/mrouter.c \ 153protocol/symbian/mrouter.c \
157phone/pfunc.c \ 154phone/pfunc.c \
158phone/at/atgen.c \ 155phone/at/atgen.c \
159phone/at/siemens.c \ 156phone/at/siemens.c \
160phone/at/samsung.c \ 157phone/at/samsung.c \
161phone/at/sonyeric.c \ 158phone/at/sonyeric.c \
162phone/alcatel/alcatel.c \ 159phone/alcatel/alcatel.c \
163phone/nokia/dct3/n6110.c \ 160phone/nokia/dct3/n6110.c \
164phone/nokia/dct3/n7110.c \ 161phone/nokia/dct3/n7110.c \
165phone/nokia/dct3/n9210.c \ 162phone/nokia/dct3/n9210.c \
166phone/nokia/dct3/dct3func.c \ 163phone/nokia/dct3/dct3func.c \
167phone/nokia/dct4/n3320.c \ 164phone/nokia/dct4/n3320.c \
168phone/nokia/dct4/n3650.c \ 165phone/nokia/dct4/n3650.c \
169phone/nokia/dct4/n6510.c \ 166phone/nokia/dct4/n6510.c \
167phone/nokia/dct3/n0650.c \
170phone/nokia/dct4/dct4func.c \ 168phone/nokia/dct4/dct4func.c \
171phone/nokia/nauto.c \ 169phone/nokia/nauto.c \
172phone/nokia/nfunc.c \ 170phone/nokia/nfunc.c \
173phone/nokia/nfuncold.c \ 171phone/nokia/nfuncold.c \
174phone/obex/obexgen.c \ 172phone/obex/obexgen.c \
175phone/symbian/mroutgen.c 173phone/symbian/mroutgen.c
176 174
177TARGET = kammu 175TARGET = kammu
178DESTDIR = $(QPEDIR)/lib 176DESTDIR = $(QPEDIR)/lib
179OBJECTS_DIR = obj/$(PLATFORM) 177OBJECTS_DIR = obj/$(PLATFORM)
180MOC_DIR = moc/$(PLATFORM) 178MOC_DIR = moc/$(PLATFORM)
181 CONFIG = warn_off release console 179 CONFIG = warn_off release console
180
181
182
183
184 # device/bluetoth/blue_w32.h \
185 # device/irda/irda_w32.h \
186 # device/serial/ser_w32.h \
187 # device/bluetoth/blue_w32.c \ \ No newline at end of file
diff --git a/gammu/emb/common/device/serial/ser_djg.c b/gammu/emb/common/device/serial/ser_djg.c
index 2524187..609deb8 100644
--- a/gammu/emb/common/device/serial/ser_djg.c
+++ b/gammu/emb/common/device/serial/ser_djg.c
@@ -1,74 +1,443 @@
1/* Some sources from SVAsync (c) 1996, 1997, Samuel Vincent
2 * 7337 Carioca Ct, Rohnert Park, Ca 94928
3 * "you may freely use it in your programs without paying me anything"
4 */
5/* Some sources from DZCOMM */
1 6
2#include "../../gsmstate.h" 7#include "../../gsmstate.h"
3 8
4#ifdef GSM_ENABLE_SERIALDEVICE 9#ifdef GSM_ENABLE_SERIALDEVICE
5#ifdef DJGPP 10#ifdef DJGPP
6 11
7#include "../../gsmcomon.h" 12#include "../../gsmcomon.h"
13#include "../../misc/coding/coding.h"
8#include "ser_djg.h" 14#include "ser_djg.h"
9 15
16#include <stdlib.h>
17#include <stdio.h>
18#include <string.h>
19#include <dos.h>
20#include <dpmi.h>
21#include <pc.h>
22#include <go32.h>
23#include <sys/farptr.h>
24#include <sys/movedata.h>
25#include <conio.h>
26
27extern unsigned short __djgpp_ds_alias;
28extern void SVAsyncProtISR(void);
29
30static unsigned char SVAsyncStatus=0;
31
32static void lock_interrupt_memory(void);
33static void unlock_interrupt_memory(void);
34
35 #define Ctrl8259_0 0x020 /* 8259 port */
36 #define Ctrl8259_1 0x021 /* 8259 port (Masks) */
37 #define BufSize 32768 /* Buffer Size */
38
39static unsigned char VectorNum; /* Vector Number */
40static unsigned char EnableIRQ; /* Mask to enable 8259 IRQ */
41static unsigned char DisableIRQ; /* Mask to disable 8259 IRQ */
42static _go32_dpmi_seginfo ProtVector; /* Old Protmode Vector */
43static _go32_dpmi_seginfo info; /* New Protmode Vector */
44
45/* Register Addresses for the UART */
46static unsigned short Port; /* Port Base Address */
47unsigned short THR; /* Transmitter Holding Register */
48unsigned short RDR; /* Reciever Data Register */
49unsigned short BRDL; /* Baud Rate Divisor, Low byte */
50unsigned short BRDH; /* Baud Rate Divisor, High Byte */
51unsigned short IER; /* Interupt Enable Register */
52unsigned short IIR; /* Interupt Identification Register */
53unsigned short FCR; /* FIFO Control Register */
54unsigned short LCR; /* Line Control Register */
55unsigned short MCR; /* Modem Control Register */
56unsigned short LSR; /* Line Status Register */
57unsigned short MSR; /* Modem Status Register */
58unsigned short SCR; /* SCR Register */
59
60/* Data Buffer */
61 unsigned volatile char RecBuffer[BufSize] = { 0 };
62 unsigned volatile int RecHead, RecTail;
63
64/* This uninstalls the ISR and resets the serial port. */
65static void SVAsyncStop(void)
66{
67 if(!SVAsyncStatus) return;
68 SVAsyncStatus = 0;
69
70 /***** Mask (disable) 8259 IRQ Interrupt */
71 outportb(Ctrl8259_1, (inportb(Ctrl8259_1) | DisableIRQ));
72
73 /***** Disable 8250 interrupt */
74 outportb(LCR, (inportb(LCR) & 0x7F));
75 outportb(IER, 0);
76
77 /***** Set bit 3 in MCR to 0 */
78 outportb(MCR, (inportb(MCR) & 0xF7));
79
80 /***** Interrupts are disabled. Restore saved interrupt vector. */
81 _go32_dpmi_set_protected_mode_interrupt_vector(VectorNum, &ProtVector);
82}
83
84/* This will empty the receive buffer */
85static void SVAsyncClear(void)
86{
87 disable();
88 RecHead = 0;
89 RecTail = 0;
90 enable();
91}
92
93
94/* Sets communication parameters
95 * Baud = 150, 300, 600, 1200, 2400, 4800, 9600, 19200, 28800, 38400, 57600
96 * Control = The value to place in the LCR
97 */
98void SVAsyncSet(unsigned int Baud, unsigned int Control)
99{
100 int divisor;
101 unsigned char divlow, divhigh;
102
103 if (!Baud) return;
104
105 divisor = 115200 / Baud;
106
107 disable();
108
109 outportb(LCR, Control | 0x80); /* Set Port Toggle to BRDL/BRDH registers */
110 divlow = divisor & 0x000000ff;
111 divhigh = (divisor >> 8) & 0x000000ff;
112 outportb(BRDL, divlow); /* Set Baud Rate */
113 outportb(BRDH, divhigh);
114
115 outportb(LCR, Control & 0x007F); /* Set LCR and Port Toggle */
116
117 enable();
118}
119
120/* Sets various handshaking lines */
121void SVAsyncHand(unsigned int Hand)
122{
123 outportb(MCR, Hand | 0x08); /* Keep interrupt enable ON */
124}
125
126static void lock_interrupt_memory(void)
127{
128 int errval;
129 __dpmi_meminfo info;
130 unsigned long address;
131
132 __dpmi_get_segment_base_address(_my_ds(), &address);
133
134 info.address = (int) address + (int) &RDR;
135 info.size = sizeof(RDR);
136 errval = __dpmi_lock_linear_region(&info);
137 if(errval == -1) printf("Error in locking memory\n!");
138
139 info.address = (int) address + (int) &LSR;
140 info.size = sizeof(LSR);
141 errval = __dpmi_lock_linear_region(&info);
142 if(errval == -1) printf("Error in locking memory\n!");
143
144 info.address = (int) address + (int) &RecHead;
145 info.size = sizeof(RecHead);
146 errval = __dpmi_lock_linear_region(&info);
147 if(errval == -1) printf("Error in locking memory\n!");
148
149 info.address = (int) address + (int) &RecBuffer;
150 info.size = sizeof(RecBuffer);
151 errval = __dpmi_lock_linear_region(&info);
152 if(errval == -1) printf("Error in locking memory\n!");
153
154 info.address = (int) address + (int) RecBuffer;
155 info.size = BufSize;
156 errval = __dpmi_lock_linear_region(&info);
157 if(errval == -1) printf("Error in locking memory\n!");
158
159 __dpmi_get_segment_base_address(_my_cs(), &address);
160
161 info.address = (int) address + (int) SVAsyncProtISR;
162 info.size = 4096; /* 4096 bytes is probably overkill. */
163 errval = __dpmi_lock_linear_region(&info);
164 if(errval == -1) printf("Error in locking memory\n!");
165}
166
167static void unlock_interrupt_memory(void)
168{
169 __dpmi_meminfo info;
170 unsigned long address;
171
172 __dpmi_get_segment_base_address(_my_ds(), &address);
173 info.address = (int) address + (int) &RDR;
174 info.size = sizeof(RDR);
175 __dpmi_unlock_linear_region(&info);
176 info.address = (int) address + (int) &LSR;
177 info.size = sizeof(LSR);
178 __dpmi_unlock_linear_region(&info);
179 info.address = (int) address + (int) &RecHead;
180 info.size = sizeof(RecHead);
181 __dpmi_unlock_linear_region(&info);
182 info.address = (int) address + (int) &RecBuffer;
183 info.size = sizeof(RecBuffer);
184 __dpmi_unlock_linear_region(&info);
185 info.address = (int) address + (int) RecBuffer;
186 info.size = BufSize;
187 __dpmi_unlock_linear_region(&info);
188
189 __dpmi_get_segment_base_address(_my_cs(), &address);
190
191 info.address = (int) address + (int) SVAsyncProtISR;
192 info.size = 4096; /* probably overkill */
193 __dpmi_unlock_linear_region(&info);
194}
195
10static GSM_Error serial_close(GSM_StateMachine *s) 196static GSM_Error serial_close(GSM_StateMachine *s)
11{ 197{
12 GSM_Device_SerialData *d = &s->Device.Data.Serial; 198 SVAsyncStop();
13 199
14 return ERR_NOTIMPLEMENTED; 200 return ERR_NONE;
15} 201}
16 202
17static GSM_Error serial_open (GSM_StateMachine *s) 203static GSM_Error serial_open (GSM_StateMachine *s)
18{ 204{
19 GSM_Device_SerialData *d = &s->Device.Data.Serial; 205 GSM_Device_SerialData *d = &s->Device.Data.Serial;
20 206 unsigned char temp;
21 return ERR_NOTIMPLEMENTED; 207 int i;
208
209 /**** Set various things according to com port number */
210 if (mystrncasecmp(s->CurrentConfig->Device,"com1:",0)) {
211 Port = 0x03F8;
212 VectorNum = 0x0C;
213 EnableIRQ = 0xEF;
214 DisableIRQ = 0x10;
215 } else if (mystrncasecmp(s->CurrentConfig->Device,"com2:",0)) {
216 Port = 0x02F8;
217 VectorNum = 0x0B;
218 EnableIRQ = 0xF7;
219 DisableIRQ = 0x08;
220 } else if (mystrncasecmp(s->CurrentConfig->Device,"com3:",0)) {
221 Port = 0x03E8;
222 VectorNum = 0x0C;
223 EnableIRQ = 0xEF;
224 DisableIRQ = 0x10;
225 } else if (mystrncasecmp(s->CurrentConfig->Device,"com4:",0)) {
226 Port = 0x02E8;
227 VectorNum = 0x0B;
228 EnableIRQ = 0xF7;
229 DisableIRQ = 0x08;
230 } else return ERR_NOTSUPPORTED;
231
232 /**** Compute Register locations */
233 THR = Port;
234 RDR = Port;
235 BRDL = Port;
236 BRDH = 1 + Port;
237 IER = 1 + Port;
238 IIR = 2 + Port;
239 FCR = 2 + Port;
240 LCR = 3 + Port;
241 MCR = 4 + Port;
242 LSR = 5 + Port;
243 MSR = 6 + Port;
244 SCR = 7 + Port;
245
246 /***** Initalize Buffer */
247 SVAsyncClear();
248
249 lock_interrupt_memory();
250 atexit(unlock_interrupt_memory);
251 /***** Set bit 3 in MCR to 0 */
252 outportb(MCR, (inportb(MCR) & 0xF7));
253
254 /*** Save and reassign interrupt vectors */
255
256 _go32_dpmi_get_protected_mode_interrupt_vector(VectorNum, &ProtVector);
257
258 info.pm_offset = (int) SVAsyncProtISR;
259 info.pm_selector = _my_cs();
260 _go32_dpmi_set_protected_mode_interrupt_vector(VectorNum, &info);
261
262 atexit(SVAsyncStop);
263
264 /***** Enable 8259 interrupt (IRQ) line for this async adapter */
265 outportb(Ctrl8259_1, (inportb(Ctrl8259_1) & EnableIRQ));
266
267 /***** Enable 8250 Interrupt-on-data-ready */
268 outportb(LCR, (inportb(LCR) & 0x7F));
269
270 outportb(IER, 0);
271 if (inportb(IER)) {
272 SVAsyncStatus = 0;
273 return ERR_UNKNOWN;
274 }
275 outportb(IER, 0x01);
276
277 /***** Clear 8250 Status and data registers */
278 do {
279 temp=inportb(RDR);
280 temp=inportb(LSR);
281 temp=inportb(MSR);
282 temp=inportb(IIR);
283 } while(!(temp & 1));
284
285 /***** Set Bit 3 of MCR -- Enable interupts */
286 outportb(MCR, (inportb(MCR) | 0x08));
287
288 SVAsyncStatus = 1;
289 /***** Clear Buffer Just in case */
290 SVAsyncClear();
291
292 /* Code based on stuff from SVAsync lib.
293 * Clear UART Status and data registers
294 * setting up FIFO if possible
295 */
296 outportb(SCR, 0x55);
297 if (inportb(SCR) == 0x55) {
298 /* On the off chance that SCR is actually hardwired to 0x55,
299 * do the same check with a different value.
300 */
301 outportb(SCR, 0xAA);
302 if (inportb(SCR) == 0xAA) {
303 /* The chip is better than an 8250 - it has a scratch pad */
304 outportb(SCR, i); /* Set SCR back to what it was before */
305 inportb(SCR); /* Give slow motherboards a chance */
306
307 /* Is there a FIFO ? - go through twice for slow motherboards */
308 outportb(FCR, 0x01);
309 i = inportb(FCR);
310 outportb(FCR, 0x01);
311 i = inportb(FCR);
312
313 /* Some old stuff relies on this (no idea why) */
314 outportb(FCR, 0x00);
315 inportb(FCR); /* Give slow motherboards a chance */
316
317 if ((i&0x80) == 0) {
318 smprintf(s,"UART 16450 or UART 8250 with scratch pad\n");
319 } else if ((i&0x40) == 0) {
320 smprintf(s,"UART 16550 - broken FIFO\n");
321 } else {
322 /* It's a 16450A series : try and start the FIFO.
323 * It appears that some chips need a two call protocol, but
324 * those that don't seem to work even if you do start it
325 * twice. The first call is simply to start it, the second
326 * starts it and sets an 8 byte FIFO trigger level.
327 */
328 outportb(FCR, 0x01);
329 inportb(FCR); /* Give slow motherboards a chance */
330 outportb(FCR, 0x87);
331 inportb(FCR); /* Give slow motherboards a chance */
332
333 /* Check that the FIFO initialised */
334 if ((inportb(IIR) & 0xc0) != 0xc0) {
335 /*
336 * It didn't so we assume it isn't there but disable it to
337 * be on the safe side.
338 */
339 outportb(IIR, 0xfe);
340 inportb(IIR); /* Give slow motherboards a chance */
341 smprintf(s,"UART 16450A - FIFO disabled\n");
342 } else {
343 smprintf(s,"UART 16450A - FIFO enabled\n");
344 }
345 }
346 } else {
347 smprintf(s,"UART 8250\n");
348 }
349 }
350
351 d->Control = BITS_8 | STOP_1;
352 d->Parity = false;
353 d->Speed = 9600;
354 SVAsyncSet(d->Speed,d->Control | NO_PARITY);
355
356 return ERR_NONE;
22} 357}
23 358
24static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) 359static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
25{ 360{
26 GSM_Device_SerialData *d = &s->Device.Data.Serial; 361 GSM_Device_SerialData *d = &s->Device.Data.Serial;
27 362
28 return ERR_NOTIMPLEMENTED; 363 d->Parity = parity;
364
365 if (parity) {
366 SVAsyncSet(d->Speed, d->Control | ODD_PARITY);
367 } else {
368 SVAsyncSet(d->Speed, d->Control | NO_PARITY);
369 }
370
371 return ERR_NONE;
29} 372}
30 373
31static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) 374static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
32{ 375{
33 GSM_Device_SerialData *d = &s->Device.Data.Serial; 376 if (dtr && rts) {
377 SVAsyncHand(DTR | RTS);
378 } else if (dtr) {
379 SVAsyncHand(DTR);
380 } else if (rts) {
381 SVAsyncHand(RTS);
382 } else {
383 SVAsyncHand(0);
384 }
34 385
35 return ERR_NOTIMPLEMENTED; 386 return ERR_NONE;
36} 387}
37 388
38static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) 389static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
39{ 390{
40 GSM_Device_SerialData *d = &s->Device.Data.Serial; 391 GSM_Device_SerialData *d = &s->Device.Data.Serial;
41 392
42 return ERR_NOTIMPLEMENTED; 393 d->Speed = speed;
394
395 if (d->Parity) {
396 SVAsyncSet(d->Speed, d->Control | ODD_PARITY);
397 } else {
398 SVAsyncSet(d->Speed, d->Control | NO_PARITY);
399 }
400
401 return ERR_NONE;
43} 402}
44 403
45static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) 404static int serial_read(GSM_StateMachine *s, char *buf, size_t nbytes)
46{ 405{
47 GSM_Device_SerialData *d = &s->Device.Data.Serial; 406 if(RecTail == RecHead) return 0;
407
408 disable();
409 buf[0] = RecBuffer[RecTail++];
410 if(RecTail >= BufSize) RecTail = 0;
411 enable();
48 412
49 return 0; 413 return 1;
50} 414}
51 415
52static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) 416static int serial_write(GSM_StateMachine *s, char *buf, size_t nbytes)
53{ 417{
54 GSM_Device_SerialData *d = &s->Device.Data.Serial; 418 int i;
419
420 for (i=0;i<nbytes;i++) {
421 while(~inportb(LSR) & 0x20);
422 outportb(THR, buf[i]);
423 }
55 424
56 return 0; 425 return i;
57} 426}
58 427
59GSM_Device_Functions SerialDevice = { 428GSM_Device_Functions SerialDevice = {
60 serial_open, 429 serial_open,
61 serial_close, 430 serial_close,
62 serial_setparity, 431 serial_setparity,
63 serial_setdtrrts, 432 serial_setdtrrts,
64 serial_setspeed, 433 serial_setspeed,
65 serial_read, 434 serial_read,
66 serial_write 435 serial_write
67}; 436};
68 437
69#endif 438#endif
70#endif 439#endif
71 440
72/* How should editor hadle tabs in this file? Add editor commands here. 441/* How should editor hadle tabs in this file? Add editor commands here.
73 * vim: noexpandtab sw=8 ts=8 sts=8: 442 * vim: noexpandtab sw=8 ts=8 sts=8:
74 */ 443 */
diff --git a/gammu/emb/common/device/serial/ser_djg.h b/gammu/emb/common/device/serial/ser_djg.h
index b35b282..3bb2a5b 100644
--- a/gammu/emb/common/device/serial/ser_djg.h
+++ b/gammu/emb/common/device/serial/ser_djg.h
@@ -1,15 +1,50 @@
1/* Some sources from SVAsync (c) 1996, 1997, Samuel Vincent
2 * 7337 Carioca Ct, Rohnert Park, Ca 94928
3 * "you may freely use it in your programs without paying me anything"
4 */
1 5
2#ifdef DJGPP 6#ifdef DJGPP
3#ifndef djgppserial_h 7#ifndef djgppserial_h
4#define djgppserial_h 8#define djgppserial_h
5 9
6typedef struct { 10typedef struct {
7 int hPhone; 11 int hPhone;
12 int Speed;
13 unsigned int Control;
14 bool Parity;
8} GSM_Device_SerialData; 15} GSM_Device_SerialData;
9 16
17/* Defines for Com Port Paramaters, the second paramater to SVAsyncSet() */
18#define BITS_8 0x03
19#define BITS_7 0x02
20#define STOP_1 0x00
21#define STOP_2 0x04
22#define EVEN_PARITY 0x18
23#define ODD_PARITY 0x08
24#define NO_PARITY 0x00
25
26/* Defines for SVAsyncHand() */
27#define DTR 0x01
28#define RTS 0x02
29#define USER 0x04
30#define LOOPBACK 0x10
31
32/* Defines for SVAsyncStat() */
33 #define D_CTS 0x0100
34 #define D_DSR 0x0200
35#define D_RI 0x0400
36 #define D_DCD 0x0800
37#define CTS 0x1000
38#define DSR 0x2000
39#define RI 0x4000
40#define DCD 0x8000
41 #define PARITY 0x0004
42#define THREMPTY 0x0020
43#define BREAKDET 0x1000
44
10#endif 45#endif
11#endif 46#endif
12 47
13/* How should editor hadle tabs in this file? Add editor commands here. 48/* How should editor hadle tabs in this file? Add editor commands here.
14 * vim: noexpandtab sw=8 ts=8 sts=8: 49 * vim: noexpandtab sw=8 ts=8 sts=8:
15 */ 50 */
diff --git a/gammu/emb/common/device/serial/ser_unx.c b/gammu/emb/common/device/serial/ser_unx.c
index 69c7515..18b5f6f 100644
--- a/gammu/emb/common/device/serial/ser_unx.c
+++ b/gammu/emb/common/device/serial/ser_unx.c
@@ -1,319 +1,328 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* locking device and settings all speeds by Michal Cihar */ 2/* locking device and settings all speeds by Michal Cihar */
3/* based on some work from Gnokii (www.gnokii.org) 3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later 5 * GNU GPL version 2 or later
6 */ 6 */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#include "../../gsmstate.h" 17#include "../../gsmstate.h"
9 18
10#ifdef GSM_ENABLE_SERIALDEVICE 19#ifdef GSM_ENABLE_SERIALDEVICE
11#ifndef WIN32 20#ifndef WIN32
12#ifndef DJGPP 21#ifndef DJGPP
13 22
14#include <sys/file.h> 23#include <sys/file.h>
15#include <sys/time.h> 24#include <sys/time.h>
16#include <string.h> 25#include <string.h>
17#include <termios.h> 26#include <termios.h>
18#include <errno.h> 27#include <errno.h>
19 28
20#include "../../gsmcomon.h" 29#include "../../gsmcomon.h"
21#include "ser_unx.h" 30#include "ser_unx.h"
22 31
23#ifndef O_NONBLOCK 32#ifndef O_NONBLOCK
24# define O_NONBLOCK 0 33# define O_NONBLOCK 0
25#endif 34#endif
26 35
27#ifdef __NetBSD__ 36#ifdef __NetBSD__
28# define FNONBLOCK O_NONBLOCK 37# define FNONBLOCK O_NONBLOCK
29 38
30# define B57600 0010001 39# define B57600 0010001
31# define B115200 0010002 40# define B115200 0010002
32# define B230400 0010003 41# define B230400 0010003
33# define B460800 0010004 42# define B460800 0010004
34# define B500000 0010005 43# define B500000 0010005
35# define B576000 0010006 44# define B576000 0010006
36# define B921600 0010007 45# define B921600 0010007
37# define B1000000 0010010 46# define B1000000 0010010
38# define B1152000 0010011 47# define B1152000 0010011
39# define B1500000 0010012 48# define B1500000 0010012
40# define B2000000 0010013 49# define B2000000 0010013
41# define B2500000 0010014 50# define B2500000 0010014
42# define B3000000 0010015 51# define B3000000 0010015
43# define B3500000 0010016 52# define B3500000 0010016
44# define B4000000 0010017 53# define B4000000 0010017
45#endif 54#endif
46 55
47static GSM_Error serial_close(GSM_StateMachine *s) 56static GSM_Error serial_close(GSM_StateMachine *s)
48{ 57{
49 GSM_Device_SerialData *d = &s->Device.Data.Serial; 58 GSM_Device_SerialData *d = &s->Device.Data.Serial;
50 59
51 /* Restores old settings */ 60 /* Restores old settings */
52 tcsetattr(d->hPhone, TCSANOW, &d->old_settings); 61 tcsetattr(d->hPhone, TCSANOW, &d->old_settings);
53 62
54 /* Closes device */ 63 /* Closes device */
55 close(d->hPhone); 64 close(d->hPhone);
56 65
57 return ERR_NONE; 66 return ERR_NONE;
58} 67}
59 68
60static GSM_Error serial_open (GSM_StateMachine *s) 69static GSM_Error serial_open (GSM_StateMachine *s)
61{ 70{
62 GSM_Device_SerialData *d = &s->Device.Data.Serial; 71 GSM_Device_SerialData *d = &s->Device.Data.Serial;
63 struct termios t; 72 struct termios t;
64 int i; 73 int i;
65 74
66 /* O_NONBLOCK MUST is required to avoid waiting for DCD */ 75 /* O_NONBLOCK MUST is required to avoid waiting for DCD */
67 d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK); 76 d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK);
68 if (d->hPhone < 0) { 77 if (d->hPhone < 0) {
69 i = errno; 78 i = errno;
70 GSM_OSErrorInfo(s,"open in serial_open"); 79 GSM_OSErrorInfo(s,"open in serial_open");
71 if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory 80 if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory
72 if (i == 13) return ERR_DEVICENOPERMISSION;//permission denied 81 if (i == 13) return ERR_DEVICENOPERMISSION;//permission denied
73 return ERR_DEVICEOPENERROR; 82 return ERR_DEVICEOPENERROR;
74 } 83 }
75 84
76#ifdef TIOCEXCL 85#ifdef TIOCEXCL
77 /* open() calls from other applications shall fail now */ 86 /* open() calls from other applications shall fail now */
78 ioctl(d->hPhone, TIOCEXCL, (char *) 0); 87 ioctl(d->hPhone, TIOCEXCL, (char *) 0);
79#endif 88#endif
80 89
81 if (tcgetattr(d->hPhone, &d->old_settings) == -1) { 90 if (tcgetattr(d->hPhone, &d->old_settings) == -1) {
82 close(d->hPhone); 91 close(d->hPhone);
83 GSM_OSErrorInfo(s,"tcgetattr in serial_open"); 92 GSM_OSErrorInfo(s,"tcgetattr in serial_open");
84 return ERR_DEVICEREADERROR; 93 return ERR_DEVICEREADERROR;
85 } 94 }
86 95
87 if (tcflush(d->hPhone, TCIOFLUSH) == -1) { 96 if (tcflush(d->hPhone, TCIOFLUSH) == -1) {
88 serial_close(s); 97 serial_close(s);
89 GSM_OSErrorInfo(s,"tcflush in serial_open"); 98 GSM_OSErrorInfo(s,"tcflush in serial_open");
90 return ERR_DEVICEOPENERROR; 99 return ERR_DEVICEOPENERROR;
91 } 100 }
92 101
93 memcpy(&t, &d->old_settings, sizeof(struct termios)); 102 memcpy(&t, &d->old_settings, sizeof(struct termios));
94 103
95 /* Opening without parity */ 104 /* Opening without parity */
96 t.c_iflag = IGNPAR; 105 t.c_iflag = IGNPAR;
97 t.c_oflag = 0; 106 t.c_oflag = 0;
98 /* disconnect line, 8 bits, enable receiver, 107 /* disconnect line, 8 bits, enable receiver,
99 * ignore modem lines,lower modem line after disconnect 108 * ignore modem lines,lower modem line after disconnect
100 */ 109 */
101 t.c_cflag = B0 | CS8 | CREAD | CLOCAL | HUPCL; 110 t.c_cflag = B0 | CS8 | CREAD | CLOCAL | HUPCL;
102 /* enable hardware (RTS/CTS) flow control (NON POSIX) */ 111 /* enable hardware (RTS/CTS) flow control (NON POSIX) */
103 /* t.c_cflag |= CRTSCTS; */ 112 /* t.c_cflag |= CRTSCTS; */
104 t.c_lflag = 0; 113 t.c_lflag = 0;
105 t.c_cc[VMIN] = 1; 114 t.c_cc[VMIN] = 1;
106 t.c_cc[VTIME] = 0; 115 t.c_cc[VTIME] = 0;
107 116
108 if (tcsetattr(d->hPhone, TCSANOW, &t) == -1) { 117 if (tcsetattr(d->hPhone, TCSANOW, &t) == -1) {
109 serial_close(s); 118 serial_close(s);
110 GSM_OSErrorInfo(s,"tcsetattr in serial_open"); 119 GSM_OSErrorInfo(s,"tcsetattr in serial_open");
111 return ERR_DEVICEOPENERROR; 120 return ERR_DEVICEOPENERROR;
112 } 121 }
113 122
114 /* Making file descriptor asynchronous. */ 123 /* Making file descriptor asynchronous. */
115 if (fcntl(d->hPhone, F_SETFL, FASYNC | FNONBLOCK) == -1) { 124 if (fcntl(d->hPhone, F_SETFL, FASYNC | FNONBLOCK) == -1) {
116 serial_close(s); 125 serial_close(s);
117 GSM_OSErrorInfo(s,"fcntl in serial_open"); 126 GSM_OSErrorInfo(s,"fcntl in serial_open");
118 return ERR_DEVICEOPENERROR; 127 return ERR_DEVICEOPENERROR;
119 } 128 }
120 129
121 return ERR_NONE; 130 return ERR_NONE;
122} 131}
123 132
124static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) 133static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
125{ 134{
126 GSM_Device_SerialData *d = &s->Device.Data.Serial; 135 GSM_Device_SerialData *d = &s->Device.Data.Serial;
127 struct termios t; 136 struct termios t;
128 137
129 if (tcgetattr(d->hPhone, &t)) { 138 if (tcgetattr(d->hPhone, &t)) {
130 GSM_OSErrorInfo(s,"tcgetattr in serial_setparity"); 139 GSM_OSErrorInfo(s,"tcgetattr in serial_setparity");
131 return ERR_DEVICEREADERROR; 140 return ERR_DEVICEREADERROR;
132 } 141 }
133 142
134 if (parity) { 143 if (parity) {
135 t.c_cflag |= (PARENB | PARODD); 144 t.c_cflag |= (PARENB | PARODD);
136 t.c_iflag = 0; 145 t.c_iflag = 0;
137 } else { 146 } else {
138 t.c_iflag = IGNPAR; 147 t.c_iflag = IGNPAR;
139 } 148 }
140 149
141 if (tcsetattr(d->hPhone, TCSANOW, &t) == -1){ 150 if (tcsetattr(d->hPhone, TCSANOW, &t) == -1){
142 serial_close(s); 151 serial_close(s);
143 GSM_OSErrorInfo(s,"tcsetattr in serial_setparity"); 152 GSM_OSErrorInfo(s,"tcsetattr in serial_setparity");
144 return ERR_DEVICEPARITYERROR; 153 return ERR_DEVICEPARITYERROR;
145 } 154 }
146 155
147 return ERR_NONE; 156 return ERR_NONE;
148} 157}
149 158
150static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) 159static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
151{ 160{
152 GSM_Device_SerialData *d = &s->Device.Data.Serial; 161 GSM_Device_SerialData *d = &s->Device.Data.Serial;
153 struct termios t; 162 struct termios t;
154 unsigned int flags; 163 unsigned int flags;
155 164
156 if (tcgetattr(d->hPhone, &t)) { 165 if (tcgetattr(d->hPhone, &t)) {
157 GSM_OSErrorInfo(s,"tcgetattr in serial_setdtrrts"); 166 GSM_OSErrorInfo(s,"tcgetattr in serial_setdtrrts");
158 return ERR_DEVICEREADERROR; 167 return ERR_DEVICEREADERROR;
159 } 168 }
160 169
161#ifdef CRTSCTS 170#ifdef CRTSCTS
162 /* Disabling hardware flow control */ 171 /* Disabling hardware flow control */
163 t.c_cflag &= ~CRTSCTS; 172 t.c_cflag &= ~CRTSCTS;
164#endif 173#endif
165 174
166 if (tcsetattr(d->hPhone, TCSANOW, &t) == -1) { 175 if (tcsetattr(d->hPhone, TCSANOW, &t) == -1) {
167 serial_close(s); 176 serial_close(s);
168 GSM_OSErrorInfo(s,"tcsetattr in serial_setdtrrts"); 177 GSM_OSErrorInfo(s,"tcsetattr in serial_setdtrrts");
169 return ERR_DEVICEDTRRTSERROR; 178 return ERR_DEVICEDTRRTSERROR;
170 } 179 }
171 180
172 flags = TIOCM_DTR; 181 flags = TIOCM_DTR;
173 if (dtr) { 182 if (dtr) {
174 ioctl(d->hPhone, TIOCMBIS, &flags); 183 ioctl(d->hPhone, TIOCMBIS, &flags);
175 } else { 184 } else {
176 ioctl(d->hPhone, TIOCMBIC, &flags); 185 ioctl(d->hPhone, TIOCMBIC, &flags);
177 } 186 }
178 187
179 flags = TIOCM_RTS; 188 flags = TIOCM_RTS;
180 if (rts) { 189 if (rts) {
181 ioctl(d->hPhone, TIOCMBIS, &flags); 190 ioctl(d->hPhone, TIOCMBIS, &flags);
182 } else { 191 } else {
183 ioctl(d->hPhone, TIOCMBIC, &flags); 192 ioctl(d->hPhone, TIOCMBIC, &flags);
184 } 193 }
185 194
186 flags = 0; 195 flags = 0;
187 ioctl(d->hPhone, TIOCMGET, &flags); 196 ioctl(d->hPhone, TIOCMGET, &flags);
188 197
189 dbgprintf("Serial device:"); 198 dbgprintf("Serial device:");
190 dbgprintf(" DTR is %s", flags&TIOCM_DTR?"up":"down"); 199 dbgprintf(" DTR is %s", flags&TIOCM_DTR?"up":"down");
191 dbgprintf(", RTS is %s", flags&TIOCM_RTS?"up":"down"); 200 dbgprintf(", RTS is %s", flags&TIOCM_RTS?"up":"down");
192 dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down"); 201 dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down");
193 dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down"); 202 dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down");
194 if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR; 203 if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR;
195 if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR; 204 if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR;
196 205
197 return ERR_NONE; 206 return ERR_NONE;
198} 207}
199 208
200static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) 209static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
201{ 210{
202 GSM_Device_SerialData *d = &s->Device.Data.Serial; 211 GSM_Device_SerialData *d = &s->Device.Data.Serial;
203 struct termios t; 212 struct termios t;
204 int speed2 = B19200; 213 int speed2 = B19200;
205 214
206 if (tcgetattr(d->hPhone, &t)) { 215 if (tcgetattr(d->hPhone, &t)) {
207 GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed"); 216 GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed");
208 return ERR_DEVICEREADERROR; 217 return ERR_DEVICEREADERROR;
209 } 218 }
210 219
211 smprintf(s, "Setting speed to %d\n", speed); 220 smprintf(s, "Setting speed to %d\n", speed);
212 221
213 switch (speed) { 222 switch (speed) {
214 case 50: speed2 = B50; break; 223 case 50: speed2 = B50; break;
215 case 75: speed2 = B75; break; 224 case 75: speed2 = B75; break;
216 case 110: speed2 = B110; break; 225 case 110: speed2 = B110; break;
217 case 134: speed2 = B134; break; 226 case 134: speed2 = B134; break;
218 case 150: speed2 = B150; break; 227 case 150: speed2 = B150; break;
219 case 200: speed2 = B200; break; 228 case 200: speed2 = B200; break;
220 case 300: speed2 = B300; break; 229 case 300: speed2 = B300; break;
221 case 600: speed2 = B600; break; 230 case 600: speed2 = B600; break;
222 case 1200: speed2 = B1200; break; 231 case 1200: speed2 = B1200; break;
223 case 1800: speed2 = B1800; break; 232 case 1800: speed2 = B1800; break;
224 case 2400: speed2 = B2400; break; 233 case 2400: speed2 = B2400; break;
225 case 4800: speed2 = B4800; break; 234 case 4800: speed2 = B4800; break;
226 case 9600: speed2 = B9600; break; 235 case 9600: speed2 = B9600; break;
227 case 19200: speed2 = B19200;break; 236 case 19200: speed2 = B19200;break;
228 case 38400: speed2 = B38400;break; 237 case 38400: speed2 = B38400;break;
229#ifdef B57600 238#ifdef B57600
230 case 57600: speed2 = B57600;break; 239 case 57600: speed2 = B57600;break;
231 case 115200: speed2 = B115200;break; 240 case 115200: speed2 = B115200;break;
232 case 230400: speed2 = B230400;break; 241 case 230400: speed2 = B230400;break;
233 case 460800: speed2 = B460800;break; 242 case 460800: speed2 = B460800;break;
234#ifdef B500000 243#ifdef B500000
235 case 500000: speed2 = B500000;break; 244 case 500000: speed2 = B500000;break;
236 case 576000: speed2 = B576000;break; 245 case 576000: speed2 = B576000;break;
237 case 921600: speed2 = B921600;break; 246 case 921600: speed2 = B921600;break;
238 case 1000000: speed2 = B1000000;break; 247 case 1000000: speed2 = B1000000;break;
239 case 1152000: speed2 = B1152000;break; 248 case 1152000: speed2 = B1152000;break;
240 case 1500000: speed2 = B1500000;break; 249 case 1500000: speed2 = B1500000;break;
241 case 2000000: speed2 = B2000000;break; 250 case 2000000: speed2 = B2000000;break;
242 case 2500000: speed2 = B2500000;break; 251 case 2500000: speed2 = B2500000;break;
243 case 3000000: speed2 = B3000000;break; 252 case 3000000: speed2 = B3000000;break;
244 case 3500000: speed2 = B3500000;break; 253 case 3500000: speed2 = B3500000;break;
245 case 4000000: speed2 = B4000000; break; 254 case 4000000: speed2 = B4000000; break;
246#endif 255#endif
247#endif 256#endif
248 } 257 }
249 258
250 /* This should work on all systems because it is done according to POSIX */ 259 /* This should work on all systems because it is done according to POSIX */
251 cfsetispeed(&t, speed2); 260 cfsetispeed(&t, speed2);
252 cfsetospeed(&t, speed2); 261 cfsetospeed(&t, speed2);
253 262
254 if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) { 263 if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) {
255 serial_close(s); 264 serial_close(s);
256 GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed"); 265 GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed");
257 return ERR_DEVICECHANGESPEEDERROR; 266 return ERR_DEVICECHANGESPEEDERROR;
258 } 267 }
259 268
260 return ERR_NONE; 269 return ERR_NONE;
261} 270}
262 271
263static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) 272static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes)
264{ 273{
265 GSM_Device_SerialData *d = &s->Device.Data.Serial; 274 GSM_Device_SerialData *d = &s->Device.Data.Serial;
266 struct timeval timeout2; 275 struct timeval timeout2;
267 fd_set readfds; 276 fd_set readfds;
268 int actual = 0; 277 int actual = 0;
269 278
270 FD_ZERO(&readfds); 279 FD_ZERO(&readfds);
271 FD_SET(d->hPhone, &readfds); 280 FD_SET(d->hPhone, &readfds);
272 281
273 timeout2.tv_sec = 0; 282 timeout2.tv_sec = 0;
274 timeout2.tv_usec = 1; 283 timeout2.tv_usec = 1;
275 284
276 if (select(d->hPhone+1, &readfds, NULL, NULL, &timeout2)) { 285 if (select(d->hPhone+1, &readfds, NULL, NULL, &timeout2)) {
277 actual = read(d->hPhone, buf, nbytes); 286 actual = read(d->hPhone, buf, nbytes);
278 if (actual == -1) GSM_OSErrorInfo(s,"serial_read"); 287 if (actual == -1) GSM_OSErrorInfo(s,"serial_read");
279 } 288 }
280 return actual; 289 return actual;
281} 290}
282 291
283static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) 292static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes)
284{ 293{
285 GSM_Device_SerialData *d = &s->Device.Data.Serial; 294 GSM_Device_SerialData *d = &s->Device.Data.Serial;
286 int ret; 295 int ret;
287 size_t actual = 0; 296 size_t actual = 0;
288 297
289 do { 298 do {
290 ret = write(d->hPhone, (unsigned char *)buf, nbytes - actual); 299 ret = write(d->hPhone, (unsigned char *)buf, nbytes - actual);
291 if (ret < 0 && errno == EAGAIN) continue; 300 if (ret < 0 && errno == EAGAIN) continue;
292 if (ret < 0) { 301 if (ret < 0) {
293 if (actual != nbytes) GSM_OSErrorInfo(s,"serial_write"); 302 if (actual != nbytes) GSM_OSErrorInfo(s,"serial_write");
294 return actual; 303 return actual;
295 } 304 }
296 actual += ret; 305 actual += ret;
297 buf += ret; 306 buf += ret;
298 if (s->ConnectionType == GCT_FBUS2PL2303) my_sleep(1); 307 if (s->ConnectionType == GCT_FBUS2PL2303) my_sleep(1);
299 } while (actual < nbytes); 308 } while (actual < nbytes);
300 return actual; 309 return actual;
301} 310}
302 311
303GSM_Device_Functions SerialDevice = { 312GSM_Device_Functions SerialDevice = {
304 serial_open, 313 serial_open,
305 serial_close, 314 serial_close,
306 serial_setparity, 315 serial_setparity,
307 serial_setdtrrts, 316 serial_setdtrrts,
308 serial_setspeed, 317 serial_setspeed,
309 serial_read, 318 serial_read,
310 serial_write 319 serial_write
311}; 320};
312 321
313#endif 322#endif
314#endif 323#endif
315#endif 324#endif
316 325
317/* How should editor hadle tabs in this file? Add editor commands here. 326/* How should editor hadle tabs in this file? Add editor commands here.
318 * vim: noexpandtab sw=8 ts=8 sts=8: 327 * vim: noexpandtab sw=8 ts=8 sts=8:
319 */ 328 */
diff --git a/gammu/emb/common/device/serial/ser_w32.c b/gammu/emb/common/device/serial/ser_w32.c
index 7d88fc7..a7919fe 100644
--- a/gammu/emb/common/device/serial/ser_w32.c
+++ b/gammu/emb/common/device/serial/ser_w32.c
@@ -1,344 +1,353 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* based on some work from MSDN and others */ 2/* based on some work from MSDN and others */
3/* based on some work from Gnokii (www.gnokii.org) 3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later 5 * GNU GPL version 2 or later
6 */ 6 */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#include "../../gsmstate.h" 17#include "../../gsmstate.h"
9 18
10#ifdef GSM_ENABLE_SERIALDEVICE 19#ifdef GSM_ENABLE_SERIALDEVICE
11#ifdef WIN32 20#ifdef WIN32
12 21
13#include <windows.h> 22#include <windows.h>
14#include <string.h> 23#include <string.h>
15#include <stdio.h> 24#include <stdio.h>
16#include <io.h> 25#include <io.h>
17#include <memory.h> 26#include <memory.h>
18 27
19#include "../../gsmcomon.h" 28#include "../../gsmcomon.h"
20#include "ser_w32.h" 29#include "ser_w32.h"
21 30
22static GSM_Error serial_close(GSM_StateMachine *s) 31static GSM_Error serial_close(GSM_StateMachine *s)
23{ 32{
24 GSM_Device_SerialData *d = &s->Device.Data.Serial; 33 GSM_Device_SerialData *d = &s->Device.Data.Serial;
25 34
26 /* Disables all monitored events for device */ 35 /* Disables all monitored events for device */
27 SetCommMask(d->hPhone, 0); 36 SetCommMask(d->hPhone, 0);
28 37
29 /* Discards all characters from input/output buffer and terminates 38 /* Discards all characters from input/output buffer and terminates
30 * pending read/write operations 39 * pending read/write operations
31 */ 40 */
32 PurgeComm(d->hPhone, PURGE_TXABORT | PURGE_RXABORT | 41 PurgeComm(d->hPhone, PURGE_TXABORT | PURGE_RXABORT |
33 PURGE_TXCLEAR | PURGE_RXCLEAR); 42 PURGE_TXCLEAR | PURGE_RXCLEAR);
34 43
35 /* Clears the DTR (data-terminal-ready) signal */ 44 /* Clears the DTR (data-terminal-ready) signal */
36 EscapeCommFunction(d->hPhone, CLRDTR); 45 EscapeCommFunction(d->hPhone, CLRDTR);
37 46
38 /* Restores old settings */ 47 /* Restores old settings */
39 if (SetCommState(d->hPhone, &d->old_settings)==0) { 48 if (SetCommState(d->hPhone, &d->old_settings)==0) {
40 GSM_OSErrorInfo(s, "SetCommState in serial_close"); 49 GSM_OSErrorInfo(s, "SetCommState in serial_close");
41 } 50 }
42 51
43 /* Closes device */ 52 /* Closes device */
44 if (CloseHandle(d->hPhone)==0) { 53 if (CloseHandle(d->hPhone)==0) {
45 GSM_OSErrorInfo(s, "CloseHandle in serial_close"); 54 GSM_OSErrorInfo(s, "CloseHandle in serial_close");
46 } 55 }
47 56
48 return ERR_NONE; 57 return ERR_NONE;
49} 58}
50 59
51static GSM_Error serial_open (GSM_StateMachine *s) 60static GSM_Error serial_open (GSM_StateMachine *s)
52{ 61{
53 GSM_Device_SerialData *d = &s->Device.Data.Serial; 62 GSM_Device_SerialData *d = &s->Device.Data.Serial;
54 DCB dcb; 63 DCB dcb;
55 unsigned char DeviceName[80],DeviceName2[80]; 64 unsigned char DeviceName[80],DeviceName2[80];
56 int i; 65 int i;
57#ifdef GSM_ENABLE_FBUS2DKU5 66#ifdef GSM_ENABLE_FBUS2DKU5
58 HKEY hKey; 67 HKEY hKey;
59 DWORD DeviceNameLen, KeyNameLen; 68 DWORD DeviceNameLen, KeyNameLen;
60 unsigned char KeyName[100]; 69 unsigned char KeyName[100];
61#endif 70#endif
62 71
63 strcpy(DeviceName2,s->CurrentConfig->Device); 72 strcpy(DeviceName2,s->CurrentConfig->Device);
64 73
65#ifdef GSM_ENABLE_FBUS2DKU5 74#ifdef GSM_ENABLE_FBUS2DKU5
66 if (s->ConnectionType == GCT_FBUS2DKU5) { 75 if (s->ConnectionType == GCT_FBUS2DKU5) {
67 smprintf(s,"Reading DKU5 device\n"); 76 smprintf(s,"Reading DKU5 device\n");
68 DeviceName2[0] = 0; 77 DeviceName2[0] = 0;
69 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { 78 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) {
70 smprintf(s,"Error opening key\n"); 79 smprintf(s,"Error opening key\n");
71 return ERR_DEVICENOTWORK; 80 return ERR_DEVICENOTWORK;
72 } 81 }
73 i = 0; 82 i = 0;
74 while(1) { 83 while(1) {
75 DeviceNameLen = 80; 84 DeviceNameLen = 80;
76 KeyNameLen = 100; 85 KeyNameLen = 100;
77 if (RegEnumValue(hKey,i,KeyName,&KeyNameLen,NULL,NULL,DeviceName2,&DeviceNameLen) != ERROR_SUCCESS) { 86 if (RegEnumValue(hKey,i,KeyName,&KeyNameLen,NULL,NULL,DeviceName2,&DeviceNameLen) != ERROR_SUCCESS) {
78 smprintf(s,"Error reading key value\n"); 87 smprintf(s,"Error reading key value\n");
79 return ERR_DEVICENOTWORK; 88 return ERR_DEVICENOTWORK;
80 } 89 }
81 // smprintf(s,"Key name is %s, value is %s\n",KeyName,DeviceName2); 90 // smprintf(s,"Key name is %s, value is %s\n",KeyName,DeviceName2);
82 if (!strncmp(KeyName,"\\Device\\AtmelVirtualPort",24)) break; 91 if (!strncmp(KeyName,"\\Device\\AtmelVirtualPort",24)) break;
83 i++; 92 i++;
84 } 93 }
85 RegCloseKey(hKey); 94 RegCloseKey(hKey);
86 if (strlen(DeviceName2) == 0) return ERR_DEVICENOTWORK; 95 if (strlen(DeviceName2) == 0) return ERR_DEVICENOTWORK;
87 smprintf(s,"DKU5 device is \"%s\"\n",DeviceName2); 96 smprintf(s,"DKU5 device is \"%s\"\n",DeviceName2);
88 //nodriver 97 //nodriver
89 } 98 }
90#endif 99#endif
91 100
92 if ((s->ConnectionType == GCT_FBUS2DKU5) || 101 if ((s->ConnectionType == GCT_FBUS2DKU5) ||
93 (!strncmp(DeviceName2,"com",3) && strlen(DeviceName2)>3)) { 102 (!strncmp(DeviceName2,"com",3) && strlen(DeviceName2)>3)) {
94 sprintf(DeviceName,"\\\\.\\COM%i",atoi(DeviceName2+3)); 103 sprintf(DeviceName,"\\\\.\\COM%i",atoi(DeviceName2+3));
95 } else { 104 } else {
96 strcpy(DeviceName,DeviceName2); 105 strcpy(DeviceName,DeviceName2);
97 } 106 }
98 107
99 smprintf(s,"Device is %s\n",DeviceName); 108 smprintf(s,"Device is %s\n",DeviceName);
100 109
101 /* Allows for reading/writing, no device sharing */ 110 /* Allows for reading/writing, no device sharing */
102 d->hPhone = CreateFile(DeviceName, 111 d->hPhone = CreateFile(DeviceName,
103 GENERIC_READ | GENERIC_WRITE, 112 GENERIC_READ | GENERIC_WRITE,
104 0, 113 0,
105 0, 114 0,
106 OPEN_EXISTING, 115 OPEN_EXISTING,
107 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 116 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
108 NULL); 117 NULL);
109 118
110 if (d->hPhone == INVALID_HANDLE_VALUE) { 119 if (d->hPhone == INVALID_HANDLE_VALUE) {
111 i = GetLastError(); 120 i = GetLastError();
112 GSM_OSErrorInfo(s, "CreateFile in serial_open"); 121 GSM_OSErrorInfo(s, "CreateFile in serial_open");
113 if (i == 2) return ERR_DEVICENOTWORK; //can't find specified file 122 if (i == 2) return ERR_DEVICENOTWORK; //can't find specified file
114 if (i == 5) return ERR_DEVICEBUSY; //access denied 123 if (i == 5) return ERR_DEVICEBUSY; //access denied
115 if (i == 31) return ERR_DEVICENOTWORK; //attached device not working 124 if (i == 31) return ERR_DEVICENOTWORK; //attached device not working
116 if (i == 123) return ERR_DEVICENOTEXIST; 125 if (i == 123) return ERR_DEVICENOTEXIST;
117 return ERR_DEVICEOPENERROR; 126 return ERR_DEVICEOPENERROR;
118 } 127 }
119 128
120 d->old_settings.DCBlength = sizeof(DCB); 129 d->old_settings.DCBlength = sizeof(DCB);
121 if (GetCommState(d->hPhone, &d->old_settings)==0) { 130 if (GetCommState(d->hPhone, &d->old_settings)==0) {
122 GSM_OSErrorInfo(s, "ReadDevice in serial_open"); 131 GSM_OSErrorInfo(s, "ReadDevice in serial_open");
123 return ERR_DEVICEREADERROR; 132 return ERR_DEVICEREADERROR;
124 } 133 }
125 134
126 /* When char will be received, we will receive notifications */ 135 /* When char will be received, we will receive notifications */
127 SetCommMask(d->hPhone, EV_RXCHAR); 136 SetCommMask(d->hPhone, EV_RXCHAR);
128 137
129 /* Sets size for input/output buffer */ 138 /* Sets size for input/output buffer */
130 SetupComm(d->hPhone, 4096, 4096); 139 SetupComm(d->hPhone, 4096, 4096);
131 140
132 /* Discards all characters from input/output buffer and terminates 141 /* Discards all characters from input/output buffer and terminates
133 * pending read/write operations 142 * pending read/write operations
134 */ 143 */
135 PurgeComm(d->hPhone, PURGE_TXABORT | PURGE_RXABORT | 144 PurgeComm(d->hPhone, PURGE_TXABORT | PURGE_RXABORT |
136 PURGE_TXCLEAR | PURGE_RXCLEAR); 145 PURGE_TXCLEAR | PURGE_RXCLEAR);
137 146
138 memcpy(&dcb, &d->old_settings, sizeof(DCB)); 147 memcpy(&dcb, &d->old_settings, sizeof(DCB));
139 148
140 dcb.ByteSize = 8; 149 dcb.ByteSize = 8;
141 dcb.Parity = NOPARITY; 150 dcb.Parity = NOPARITY;
142 dcb.StopBits = ONESTOPBIT; 151 dcb.StopBits = ONESTOPBIT;
143 152
144 /* No Xon/Xof flow control */ 153 /* No Xon/Xof flow control */
145 // dcb.fOutX = false; 154 // dcb.fOutX = false;
146 // dcb.fInX = false; 155 // dcb.fInX = false;
147 156
148 /* Hardware flow control */ 157 /* Hardware flow control */
149 //dcb.fOutxDsrFlow = true; 158 //dcb.fOutxDsrFlow = true;
150 //dcb.fOutxCtsFlow = true; 159 //dcb.fOutxCtsFlow = true;
151 //dcb.fDtrControl = DTR_CONTROL_HANDSHAKE; 160 //dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
152 //dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; 161 //dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
153 162
154 /* Initialise the port settings */ 163 /* Initialise the port settings */
155 if (SetCommState(d->hPhone, &dcb)==0) { 164 if (SetCommState(d->hPhone, &dcb)==0) {
156 GSM_OSErrorInfo(s, "WriteDevice in serial_open"); 165 GSM_OSErrorInfo(s, "WriteDevice in serial_open");
157 return ERR_DEVICEOPENERROR; 166 return ERR_DEVICEOPENERROR;
158 } 167 }
159 168
160 return ERR_NONE; 169 return ERR_NONE;
161} 170}
162 171
163static GSM_Error serial_setparity (GSM_StateMachine *s, bool parity) 172static GSM_Error serial_setparity (GSM_StateMachine *s, bool parity)
164{ 173{
165 DCB dcb; 174 DCB dcb;
166 GSM_Device_SerialData *d = &s->Device.Data.Serial; 175 GSM_Device_SerialData *d = &s->Device.Data.Serial;
167 176
168 dcb.DCBlength = sizeof(DCB); 177 dcb.DCBlength = sizeof(DCB);
169 if (GetCommState(d->hPhone, &dcb)==0) { 178 if (GetCommState(d->hPhone, &dcb)==0) {
170 GSM_OSErrorInfo(s, "ReadDevice in serial_setparity"); 179 GSM_OSErrorInfo(s, "ReadDevice in serial_setparity");
171 return ERR_DEVICEREADERROR; 180 return ERR_DEVICEREADERROR;
172 } 181 }
173 182
174 if (parity) { 183 if (parity) {
175 dcb.Parity = ODDPARITY; 184 dcb.Parity = ODDPARITY;
176 } else { 185 } else {
177 dcb.Parity = NOPARITY; 186 dcb.Parity = NOPARITY;
178 } 187 }
179 188
180 if (SetCommState(d->hPhone, &dcb)==0) { 189 if (SetCommState(d->hPhone, &dcb)==0) {
181 GSM_OSErrorInfo(s, "WriteDevice in serial_setparity"); 190 GSM_OSErrorInfo(s, "WriteDevice in serial_setparity");
182 return ERR_DEVICEPARITYERROR; 191 return ERR_DEVICEPARITYERROR;
183 } 192 }
184 193
185 return ERR_NONE; 194 return ERR_NONE;
186} 195}
187 196
188static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) 197static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
189{ 198{
190 DCB dcb; 199 DCB dcb;
191 GSM_Device_SerialData *d = &s->Device.Data.Serial; 200 GSM_Device_SerialData *d = &s->Device.Data.Serial;
192 201
193 dcb.DCBlength = sizeof(DCB); 202 dcb.DCBlength = sizeof(DCB);
194 if (GetCommState(d->hPhone, &dcb)==0) { 203 if (GetCommState(d->hPhone, &dcb)==0) {
195 GSM_OSErrorInfo(s, "ReadDevice in serial_setdtrrts"); 204 GSM_OSErrorInfo(s, "ReadDevice in serial_setdtrrts");
196 return ERR_DEVICEREADERROR; 205 return ERR_DEVICEREADERROR;
197 } 206 }
198 207
199 dcb.fOutxDsrFlow = 0; 208 dcb.fOutxDsrFlow = 0;
200 dcb.fDtrControl = DTR_CONTROL_DISABLE; 209 dcb.fDtrControl = DTR_CONTROL_DISABLE;
201 if (dtr) dcb.fDtrControl = DTR_CONTROL_ENABLE; 210 if (dtr) dcb.fDtrControl = DTR_CONTROL_ENABLE;
202 211
203 dcb.fOutxCtsFlow = 0; 212 dcb.fOutxCtsFlow = 0;
204 dcb.fRtsControl = RTS_CONTROL_DISABLE; 213 dcb.fRtsControl = RTS_CONTROL_DISABLE;
205 if (rts) dcb.fRtsControl = RTS_CONTROL_ENABLE; 214 if (rts) dcb.fRtsControl = RTS_CONTROL_ENABLE;
206 215
207 /* no software (Xon/Xof) flow control */ 216 /* no software (Xon/Xof) flow control */
208 dcb.fInX = dcb.fOutX = 0; 217 dcb.fInX = dcb.fOutX = 0;
209 218
210 if (SetCommState(d->hPhone, &dcb)==0) { 219 if (SetCommState(d->hPhone, &dcb)==0) {
211 GSM_OSErrorInfo(s, "WriteDevice in serial_setdtrrts"); 220 GSM_OSErrorInfo(s, "WriteDevice in serial_setdtrrts");
212 return ERR_DEVICEDTRRTSERROR; 221 return ERR_DEVICEDTRRTSERROR;
213 } 222 }
214 223
215 /* the rest of function checks, if setting was really done */ 224 /* the rest of function checks, if setting was really done */
216 225
217 dcb.DCBlength = sizeof(DCB); 226 dcb.DCBlength = sizeof(DCB);
218 GetCommState(d->hPhone, &dcb); 227 GetCommState(d->hPhone, &dcb);
219 228
220 dbgprintf("Serial device:"); 229 dbgprintf("Serial device:");
221 dbgprintf(" DTR is "); 230 dbgprintf(" DTR is ");
222 switch (dcb.fDtrControl) { 231 switch (dcb.fDtrControl) {
223 case DTR_CONTROL_ENABLE : dbgprintf("up"); break; 232 case DTR_CONTROL_ENABLE : dbgprintf("up"); break;
224 case DTR_CONTROL_DISABLE : dbgprintf("down"); break; 233 case DTR_CONTROL_DISABLE : dbgprintf("down"); break;
225 case DTR_CONTROL_HANDSHAKE : dbgprintf("handshake"); break; 234 case DTR_CONTROL_HANDSHAKE : dbgprintf("handshake"); break;
226 } 235 }
227 dbgprintf(", RTS is "); 236 dbgprintf(", RTS is ");
228 switch (dcb.fRtsControl) { 237 switch (dcb.fRtsControl) {
229 case RTS_CONTROL_ENABLE : dbgprintf("up"); break; 238 case RTS_CONTROL_ENABLE : dbgprintf("up"); break;
230 case RTS_CONTROL_DISABLE : dbgprintf("down"); break; 239 case RTS_CONTROL_DISABLE : dbgprintf("down"); break;
231 case RTS_CONTROL_HANDSHAKE : dbgprintf("handshake"); break; 240 case RTS_CONTROL_HANDSHAKE : dbgprintf("handshake"); break;
232 case RTS_CONTROL_TOGGLE : dbgprintf("toggle"); break; 241 case RTS_CONTROL_TOGGLE : dbgprintf("toggle"); break;
233 } 242 }
234 dbgprintf("\n"); 243 dbgprintf("\n");
235 if ( dtr && dcb.fDtrControl != DTR_CONTROL_ENABLE ) return ERR_DEVICEDTRRTSERROR; 244 if ( dtr && dcb.fDtrControl != DTR_CONTROL_ENABLE ) return ERR_DEVICEDTRRTSERROR;
236 if (!dtr && dcb.fDtrControl != DTR_CONTROL_DISABLE) return ERR_DEVICEDTRRTSERROR; 245 if (!dtr && dcb.fDtrControl != DTR_CONTROL_DISABLE) return ERR_DEVICEDTRRTSERROR;
237 if ( rts && dcb.fRtsControl != RTS_CONTROL_ENABLE ) return ERR_DEVICEDTRRTSERROR; 246 if ( rts && dcb.fRtsControl != RTS_CONTROL_ENABLE ) return ERR_DEVICEDTRRTSERROR;
238 if (!rts && dcb.fRtsControl != RTS_CONTROL_DISABLE) return ERR_DEVICEDTRRTSERROR; 247 if (!rts && dcb.fRtsControl != RTS_CONTROL_DISABLE) return ERR_DEVICEDTRRTSERROR;
239 248
240 return ERR_NONE; 249 return ERR_NONE;
241} 250}
242 251
243static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) 252static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
244{ 253{
245 DCB dcb; 254 DCB dcb;
246 GSM_Device_SerialData *d = &s->Device.Data.Serial; 255 GSM_Device_SerialData *d = &s->Device.Data.Serial;
247 256
248 dcb.DCBlength = sizeof(DCB); 257 dcb.DCBlength = sizeof(DCB);
249 if (GetCommState(d->hPhone, &dcb)==0) { 258 if (GetCommState(d->hPhone, &dcb)==0) {
250 GSM_OSErrorInfo(s, "ReadDevice in serial_setspeed"); 259 GSM_OSErrorInfo(s, "ReadDevice in serial_setspeed");
251 return ERR_DEVICEREADERROR; 260 return ERR_DEVICEREADERROR;
252 } 261 }
253 262
254 dcb.BaudRate = speed; 263 dcb.BaudRate = speed;
255 264
256 if (SetCommState(d->hPhone, &dcb)==0) { 265 if (SetCommState(d->hPhone, &dcb)==0) {
257 GSM_OSErrorInfo(s, "WriteDevice in serial_setspeed"); 266 GSM_OSErrorInfo(s, "WriteDevice in serial_setspeed");
258 return ERR_DEVICECHANGESPEEDERROR; 267 return ERR_DEVICECHANGESPEEDERROR;
259 } 268 }
260 269
261 return ERR_NONE; 270 return ERR_NONE;
262} 271}
263 272
264static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) 273static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes)
265{ 274{
266 COMSTAT ComStat; 275 COMSTAT ComStat;
267 DWORD ErrorFlags, Length; 276 DWORD ErrorFlags, Length;
268 GSM_Device_SerialData *d = &s->Device.Data.Serial; 277 GSM_Device_SerialData *d = &s->Device.Data.Serial;
269 278
270 /* Gets information about a communications error and 279 /* Gets information about a communications error and
271 * current status of device 280 * current status of device
272 */ 281 */
273 ClearCommError(d->hPhone, &ErrorFlags, &ComStat); 282 ClearCommError(d->hPhone, &ErrorFlags, &ComStat);
274 Length = ComStat.cbInQue; 283 Length = ComStat.cbInQue;
275 284
276 /* Nothing to read */ 285 /* Nothing to read */
277 if (Length <= 0) return Length; 286 if (Length <= 0) return Length;
278 287
279 /* Read without problems */ 288 /* Read without problems */
280 if (ReadFile(d->hPhone, buf, Length, &Length, &d->osRead)) return Length; 289 if (ReadFile(d->hPhone, buf, Length, &Length, &d->osRead)) return Length;
281 290
282 if (GetLastError() != ERROR_IO_PENDING) { 291 if (GetLastError() != ERROR_IO_PENDING) {
283 GSM_OSErrorInfo(s, "serial_read1"); 292 GSM_OSErrorInfo(s, "serial_read1");
284 Length = 0; 293 Length = 0;
285 ClearCommError(d->hPhone, &ErrorFlags, &ComStat); 294 ClearCommError(d->hPhone, &ErrorFlags, &ComStat);
286 return Length; 295 return Length;
287 } 296 }
288 297
289 while(1) { 298 while(1) {
290 if (GetOverlappedResult(d->hPhone,&d->osRead, &Length, TRUE)) break; 299 if (GetOverlappedResult(d->hPhone,&d->osRead, &Length, TRUE)) break;
291 if (GetLastError() != ERROR_IO_INCOMPLETE) { 300 if (GetLastError() != ERROR_IO_INCOMPLETE) {
292 GSM_OSErrorInfo(s, "serial_read2"); 301 GSM_OSErrorInfo(s, "serial_read2");
293 /* an error occurred, try to recover */ 302 /* an error occurred, try to recover */
294 ClearCommError(d->hPhone, &ErrorFlags, &ComStat); 303 ClearCommError(d->hPhone, &ErrorFlags, &ComStat);
295 break; 304 break;
296 } 305 }
297 } 306 }
298 return Length; 307 return Length;
299} 308}
300 309
301static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) 310static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes)
302{ 311{
303 DWORD BytesWritten,ErrorFlags,BytesSent=0; 312 DWORD BytesWritten,ErrorFlags,BytesSent=0;
304 COMSTAT ComStat; 313 COMSTAT ComStat;
305 GSM_Device_SerialData *d = &s->Device.Data.Serial; 314 GSM_Device_SerialData *d = &s->Device.Data.Serial;
306 315
307 if (WriteFile(d->hPhone, buf, nbytes, &BytesSent, &d->osWrite)) return BytesSent; 316 if (WriteFile(d->hPhone, buf, nbytes, &BytesSent, &d->osWrite)) return BytesSent;
308 317
309 if (GetLastError() != ERROR_IO_PENDING) { 318 if (GetLastError() != ERROR_IO_PENDING) {
310 GSM_OSErrorInfo(s, "serial_write1"); 319 GSM_OSErrorInfo(s, "serial_write1");
311 ClearCommError(d->hPhone, &ErrorFlags, &ComStat); 320 ClearCommError(d->hPhone, &ErrorFlags, &ComStat);
312 return BytesSent; 321 return BytesSent;
313 } 322 }
314 323
315 while (1) { 324 while (1) {
316 if (GetOverlappedResult(d->hPhone, &d->osWrite, &BytesWritten, TRUE)) break; 325 if (GetOverlappedResult(d->hPhone, &d->osWrite, &BytesWritten, TRUE)) break;
317 if (GetLastError() != ERROR_IO_INCOMPLETE) { 326 if (GetLastError() != ERROR_IO_INCOMPLETE) {
318 GSM_OSErrorInfo(s, "serial_write2"); 327 GSM_OSErrorInfo(s, "serial_write2");
319 ClearCommError(d->hPhone, &ErrorFlags, &ComStat); 328 ClearCommError(d->hPhone, &ErrorFlags, &ComStat);
320 break; 329 break;
321 } 330 }
322 BytesSent += BytesWritten; 331 BytesSent += BytesWritten;
323 } 332 }
324 BytesSent += BytesWritten; 333 BytesSent += BytesWritten;
325 334
326 return BytesSent; 335 return BytesSent;
327} 336}
328 337
329GSM_Device_Functions SerialDevice = { 338GSM_Device_Functions SerialDevice = {
330 serial_open, 339 serial_open,
331 serial_close, 340 serial_close,
332 serial_setparity, 341 serial_setparity,
333 serial_setdtrrts, 342 serial_setdtrrts,
334 serial_setspeed, 343 serial_setspeed,
335 serial_read, 344 serial_read,
336 serial_write 345 serial_write
337}; 346};
338 347
339#endif 348#endif
340#endif 349#endif
341 350
342/* How should editor hadle tabs in this file? Add editor commands here. 351/* How should editor hadle tabs in this file? Add editor commands here.
343 * vim: noexpandtab sw=8 ts=8 sts=8: 352 * vim: noexpandtab sw=8 ts=8 sts=8:
344 */ 353 */
diff --git a/gammu/emb/common/gsmstate.c b/gammu/emb/common/gsmstate.c
index 31e365d..c65dc01 100644
--- a/gammu/emb/common/gsmstate.c
+++ b/gammu/emb/common/gsmstate.c
@@ -173,1106 +173,1107 @@ GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s)
173 GSM_RegisterModule(s,&ATGENPhone); 173 GSM_RegisterModule(s,&ATGENPhone);
174 if (s->Phone.Functions!=NULL) return ERR_NONE; 174 if (s->Phone.Functions!=NULL) return ERR_NONE;
175 } 175 }
176#endif 176#endif
177#ifdef GSM_ENABLE_OBEXGEN 177#ifdef GSM_ENABLE_OBEXGEN
178 GSM_RegisterModule(s,&OBEXGENPhone); 178 GSM_RegisterModule(s,&OBEXGENPhone);
179#endif 179#endif
180#ifdef GSM_ENABLE_MROUTERGEN 180#ifdef GSM_ENABLE_MROUTERGEN
181 GSM_RegisterModule(s,&MROUTERGENPhone); 181 GSM_RegisterModule(s,&MROUTERGENPhone);
182#endif 182#endif
183#ifdef GSM_ENABLE_NOKIA3320 183#ifdef GSM_ENABLE_NOKIA3320
184 GSM_RegisterModule(s,&N3320Phone); 184 GSM_RegisterModule(s,&N3320Phone);
185#endif 185#endif
186#ifdef GSM_ENABLE_NOKIA3650 186#ifdef GSM_ENABLE_NOKIA3650
187 GSM_RegisterModule(s,&N3650Phone); 187 GSM_RegisterModule(s,&N3650Phone);
188#endif 188#endif
189#ifdef GSM_ENABLE_NOKIA650 189#ifdef GSM_ENABLE_NOKIA650
190 GSM_RegisterModule(s,&N650Phone); 190 GSM_RegisterModule(s,&N650Phone);
191#endif 191#endif
192#ifdef GSM_ENABLE_NOKIA6110 192#ifdef GSM_ENABLE_NOKIA6110
193 GSM_RegisterModule(s,&N6110Phone); 193 GSM_RegisterModule(s,&N6110Phone);
194#endif 194#endif
195#ifdef GSM_ENABLE_NOKIA6510 195#ifdef GSM_ENABLE_NOKIA6510
196 GSM_RegisterModule(s,&N6510Phone); 196 GSM_RegisterModule(s,&N6510Phone);
197#endif 197#endif
198#ifdef GSM_ENABLE_NOKIA7110 198#ifdef GSM_ENABLE_NOKIA7110
199 GSM_RegisterModule(s,&N7110Phone); 199 GSM_RegisterModule(s,&N7110Phone);
200#endif 200#endif
201#ifdef GSM_ENABLE_NOKIA9210 201#ifdef GSM_ENABLE_NOKIA9210
202 GSM_RegisterModule(s,&N9210Phone); 202 GSM_RegisterModule(s,&N9210Phone);
203#endif 203#endif
204#ifdef GSM_ENABLE_ALCATEL 204#ifdef GSM_ENABLE_ALCATEL
205 GSM_RegisterModule(s,&ALCATELPhone); 205 GSM_RegisterModule(s,&ALCATELPhone);
206#endif 206#endif
207 if (s->Phone.Functions==NULL) return ERR_UNKNOWNMODELSTRING; 207 if (s->Phone.Functions==NULL) return ERR_UNKNOWNMODELSTRING;
208 return ERR_NONE; 208 return ERR_NONE;
209} 209}
210 210
211GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum) 211GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
212{ 212{
213 GSM_Errorerror; 213 GSM_Errorerror;
214 GSM_DateTimetime; 214 GSM_DateTimetime;
215 int i; 215 int i;
216 216
217 for (i=0;i<s->ConfigNum;i++) { 217 for (i=0;i<s->ConfigNum;i++) {
218 s->CurrentConfig = &s->Config[i]; 218 s->CurrentConfig = &s->Config[i];
219 219
220 s->Speed = 0; 220 s->Speed = 0;
221 s->ReplyNum = ReplyNum; 221 s->ReplyNum = ReplyNum;
222 s->Phone.Data.ModelInfo = GetModelData("unknown",NULL,NULL); 222 s->Phone.Data.ModelInfo = GetModelData("unknown",NULL,NULL);
223 s->Phone.Data.Manufacturer[0] = 0; 223 s->Phone.Data.Manufacturer[0] = 0;
224 s->Phone.Data.Model[0] = 0; 224 s->Phone.Data.Model[0] = 0;
225 s->Phone.Data.Version[0] = 0; 225 s->Phone.Data.Version[0] = 0;
226 s->Phone.Data.VerDate[0] = 0; 226 s->Phone.Data.VerDate[0] = 0;
227 s->Phone.Data.VerNum = 0; 227 s->Phone.Data.VerNum = 0;
228 s->Phone.Data.StartInfoCounter = 0; 228 s->Phone.Data.StartInfoCounter = 0;
229 s->Phone.Data.SentMsg = NULL; 229 s->Phone.Data.SentMsg = NULL;
230 230
231 s->Phone.Data.HardwareCache[0] = 0; 231 s->Phone.Data.HardwareCache[0] = 0;
232 s->Phone.Data.ProductCodeCache[0] = 0; 232 s->Phone.Data.ProductCodeCache[0] = 0;
233 s->Phone.Data.EnableIncomingCall = false; 233 s->Phone.Data.EnableIncomingCall = false;
234 s->Phone.Data.EnableIncomingSMS = false; 234 s->Phone.Data.EnableIncomingSMS = false;
235 s->Phone.Data.EnableIncomingCB = false; 235 s->Phone.Data.EnableIncomingCB = false;
236 s->Phone.Data.EnableIncomingUSSD = false; 236 s->Phone.Data.EnableIncomingUSSD = false;
237 s->User.UserReplyFunctions = NULL; 237 s->User.UserReplyFunctions = NULL;
238 s->User.IncomingCall = NULL; 238 s->User.IncomingCall = NULL;
239 s->User.IncomingSMS = NULL; 239 s->User.IncomingSMS = NULL;
240 s->User.IncomingCB = NULL; 240 s->User.IncomingCB = NULL;
241 s->User.IncomingUSSD = NULL; 241 s->User.IncomingUSSD = NULL;
242 s->User.SendSMSStatus = NULL; 242 s->User.SendSMSStatus = NULL;
243 s->LockFile = NULL; 243 s->LockFile = NULL;
244 s->opened = false; 244 s->opened = false;
245 s->Phone.Functions = NULL; 245 s->Phone.Functions = NULL;
246 246
247 s->di = di; 247 s->di = di;
248 s->di.use_global = s->CurrentConfig->UseGlobalDebugFile; 248 s->di.use_global = s->CurrentConfig->UseGlobalDebugFile;
249 GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, &s->di); 249 GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, &s->di);
250 error=GSM_SetDebugFile(s->CurrentConfig->DebugFile, &s->di); 250 error=GSM_SetDebugFile(s->CurrentConfig->DebugFile, &s->di);
251 if (error != ERR_NONE) return error; 251 if (error != ERR_NONE) return error;
252 252
253 if (s->di.dl == DL_TEXTALL || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTERROR || 253 if (s->di.dl == DL_TEXTALL || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTERROR ||
254 s->di.dl == DL_TEXTALLDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTERRORDATE) { 254 s->di.dl == DL_TEXTALLDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTERRORDATE) {
255 smprintf(s,"[Gammu - %s built %s %s",VERSION,__TIME__,__DATE__); 255 smprintf(s,"[Gammu - %s built %s %s",VERSION,__TIME__,__DATE__);
256 if (strlen(GetCompiler()) != 0) { 256 if (strlen(GetCompiler()) != 0) {
257 smprintf(s," in %s",GetCompiler()); 257 smprintf(s," in %s",GetCompiler());
258 } 258 }
259 smprintf(s,"]\n[Connection - \"%s\"]\n",s->CurrentConfig->Connection); 259 smprintf(s,"]\n[Connection - \"%s\"]\n",s->CurrentConfig->Connection);
260 smprintf(s,"[Model type - \"%s\"]\n",s->CurrentConfig->Model); 260 smprintf(s,"[Model type - \"%s\"]\n",s->CurrentConfig->Model);
261 smprintf(s,"[Device - \"%s\"]\n",s->CurrentConfig->Device); 261 smprintf(s,"[Device - \"%s\"]\n",s->CurrentConfig->Device);
262 if (strlen(GetOS()) != 0) { 262 if (strlen(GetOS()) != 0) {
263 smprintf(s,"[Run on - %s]\n",GetOS()); 263 smprintf(s,"[Run on - %s]\n",GetOS());
264 } 264 }
265 } 265 }
266 if (s->di.dl==DL_BINARY) { 266 if (s->di.dl==DL_BINARY) {
267 smprintf(s,"%c",((unsigned char)strlen(VERSION))); 267 smprintf(s,"%c",((unsigned char)strlen(VERSION)));
268 smprintf(s,"%s",VERSION); 268 smprintf(s,"%s",VERSION);
269 } 269 }
270 270
271 error=GSM_RegisterAllConnections(s, s->CurrentConfig->Connection); 271 error=GSM_RegisterAllConnections(s, s->CurrentConfig->Connection);
272 if (error!=ERR_NONE) return error; 272 if (error!=ERR_NONE) return error;
273 273
274 /* Model auto */ 274 /* Model auto */
275 if (s->CurrentConfig->Model[0]==0) { 275 if (s->CurrentConfig->Model[0]==0) {
276 if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) { 276 if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) {
277 error = lock_device(s->CurrentConfig->Device, &(s->LockFile)); 277 error = lock_device(s->CurrentConfig->Device, &(s->LockFile));
278 if (error != ERR_NONE) return error; 278 if (error != ERR_NONE) return error;
279 } 279 }
280 280
281 /* Irda devices can set now model to some specific and 281 /* Irda devices can set now model to some specific and
282 * we don't have to make auto detection later */ 282 * we don't have to make auto detection later */
283 error=s->Device.Functions->OpenDevice(s); 283 error=s->Device.Functions->OpenDevice(s);
284 if (i != s->ConfigNum - 1) { 284 if (i != s->ConfigNum - 1) {
285 if (error == ERR_DEVICEOPENERROR) continue; 285 if (error == ERR_DEVICEOPENERROR) continue;
286 if (error == ERR_DEVICELOCKED) continue; 286 if (error == ERR_DEVICELOCKED) continue;
287 if (error == ERR_DEVICENOTEXIST) continue; 287 if (error == ERR_DEVICENOTEXIST) continue;
288 if (error == ERR_DEVICEBUSY) continue; 288 if (error == ERR_DEVICEBUSY) continue;
289 if (error == ERR_DEVICENOPERMISSION) continue; 289 if (error == ERR_DEVICENOPERMISSION) continue;
290 if (error == ERR_DEVICENODRIVER) continue; 290 if (error == ERR_DEVICENODRIVER) continue;
291 if (error == ERR_DEVICENOTWORK) continue; 291 if (error == ERR_DEVICENOTWORK) continue;
292 } 292 }
293 if (error!=ERR_NONE) { 293 if (error!=ERR_NONE) {
294 if (s->LockFile!=NULL) unlock_device(&(s->LockFile)); 294 if (s->LockFile!=NULL) unlock_device(&(s->LockFile));
295 return error; 295 return error;
296 } 296 }
297 297
298 s->opened = true; 298 s->opened = true;
299 299
300 error=s->Protocol.Functions->Initialise(s); 300 error=s->Protocol.Functions->Initialise(s);
301 if (error!=ERR_NONE) return error; 301 if (error!=ERR_NONE) return error;
302 302
303 /* If still auto model, try to get model by asking phone for it */ 303 /* If still auto model, try to get model by asking phone for it */
304 if (s->Phone.Data.Model[0]==0) { 304 if (s->Phone.Data.Model[0]==0) {
305 smprintf(s,"[Module - \"auto\"]\n"); 305 smprintf(s,"[Module - \"auto\"]\n");
306 switch (s->ConnectionType) { 306 switch (s->ConnectionType) {
307#ifdef GSM_ENABLE_ATGEN 307#ifdef GSM_ENABLE_ATGEN
308 case GCT_AT: 308 case GCT_AT:
309 case GCT_BLUEAT: 309 case GCT_BLUEAT:
310 case GCT_IRDAAT: 310 case GCT_IRDAAT:
311 s->Phone.Functions = &ATGENPhone; 311 s->Phone.Functions = &ATGENPhone;
312 break; 312 break;
313#endif 313#endif
314#ifdef GSM_ENABLE_OBEXGEN 314#ifdef GSM_ENABLE_OBEXGEN
315 case GCT_IRDAOBEX: 315 case GCT_IRDAOBEX:
316 case GCT_BLUEOBEX: 316 case GCT_BLUEOBEX:
317 s->Phone.Functions = &OBEXGENPhone; 317 s->Phone.Functions = &OBEXGENPhone;
318 break; 318 break;
319#endif 319#endif
320#ifdef GSM_ENABLE_MROUTERGEN 320#ifdef GSM_ENABLE_MROUTERGEN
321 case GCT_MROUTERBLUE: 321 case GCT_MROUTERBLUE:
322 s->Phone.Functions = &MROUTERGENPhone; 322 s->Phone.Functions = &MROUTERGENPhone;
323 break; 323 break;
324#endif 324#endif
325#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 325#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
326 case GCT_MBUS2: 326 case GCT_MBUS2:
327 case GCT_FBUS2: 327 case GCT_FBUS2:
328 case GCT_FBUS2DLR3: 328 case GCT_FBUS2DLR3:
329 case GCT_FBUS2DKU5: 329 case GCT_FBUS2DKU5:
330 case GCT_FBUS2PL2303: 330 case GCT_FBUS2PL2303:
331 case GCT_FBUS2BLUE: 331 case GCT_FBUS2BLUE:
332 case GCT_FBUS2IRDA: 332 case GCT_FBUS2IRDA:
333 case GCT_PHONETBLUE: 333 case GCT_PHONETBLUE:
334 case GCT_IRDAPHONET: 334 case GCT_IRDAPHONET:
335 case GCT_BLUEFBUS2: 335 case GCT_BLUEFBUS2:
336 case GCT_BLUEPHONET: 336 case GCT_BLUEPHONET:
337 s->Phone.Functions = &NAUTOPhone; 337 s->Phone.Functions = &NAUTOPhone;
338 break; 338 break;
339#endif 339#endif
340 default: 340 default:
341 s->Phone.Functions = NULL; 341 s->Phone.Functions = NULL;
342 } 342 }
343 if (s->Phone.Functions == NULL) return ERR_UNKNOWN; 343 if (s->Phone.Functions == NULL) return ERR_UNKNOWN;
344 344
345 /* Please note, that AT module need to send first 345 /* Please note, that AT module need to send first
346 * command for enabling echo 346 * command for enabling echo
347 */ 347 */
348 error=s->Phone.Functions->Initialise(s); 348 error=s->Phone.Functions->Initialise(s);
349 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue; 349 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue;
350 if (error != ERR_NONE) return error; 350 if (error != ERR_NONE) return error;
351 351
352 error=s->Phone.Functions->GetModel(s); 352 error=s->Phone.Functions->GetModel(s);
353 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue; 353 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue;
354 if (error != ERR_NONE) return error; 354 if (error != ERR_NONE) return error;
355 } 355 }
356 } 356 }
357 357
358 /* Switching to "correct" module */ 358 /* Switching to "correct" module */
359 error=GSM_RegisterAllPhoneModules(s); 359 error=GSM_RegisterAllPhoneModules(s);
360 if (error!=ERR_NONE) return error; 360 if (error!=ERR_NONE) return error;
361 361
362 /* We didn't open device earlier ? Make it now */ 362 /* We didn't open device earlier ? Make it now */
363 if (!s->opened) { 363 if (!s->opened) {
364 if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) { 364 if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) {
365 error = lock_device(s->CurrentConfig->Device, &(s->LockFile)); 365 error = lock_device(s->CurrentConfig->Device, &(s->LockFile));
366 if (error != ERR_NONE) return error; 366 if (error != ERR_NONE) return error;
367 } 367 }
368 368
369 error=s->Device.Functions->OpenDevice(s); 369 error=s->Device.Functions->OpenDevice(s);
370 if (i != s->ConfigNum - 1) { 370 if (i != s->ConfigNum - 1) {
371 if (error == ERR_DEVICEOPENERROR) continue; 371 if (error == ERR_DEVICEOPENERROR) continue;
372 if (error == ERR_DEVICELOCKED) continue; 372 if (error == ERR_DEVICELOCKED) continue;
373 if (error == ERR_DEVICENOTEXIST) continue; 373 if (error == ERR_DEVICENOTEXIST) continue;
374 if (error == ERR_DEVICEBUSY) continue; 374 if (error == ERR_DEVICEBUSY) continue;
375 if (error == ERR_DEVICENOPERMISSION) continue; 375 if (error == ERR_DEVICENOPERMISSION) continue;
376 if (error == ERR_DEVICENODRIVER) continue; 376 if (error == ERR_DEVICENODRIVER) continue;
377 if (error == ERR_DEVICENOTWORK) continue; 377 if (error == ERR_DEVICENOTWORK) continue;
378 } 378 }
379 if (error!=ERR_NONE) { 379 if (error!=ERR_NONE) {
380 if (s->LockFile!=NULL) unlock_device(&(s->LockFile)); 380 if (s->LockFile!=NULL) unlock_device(&(s->LockFile));
381 return error; 381 return error;
382 } 382 }
383 383
384 s->opened = true; 384 s->opened = true;
385 385
386 error=s->Protocol.Functions->Initialise(s); 386 error=s->Protocol.Functions->Initialise(s);
387 if (error!=ERR_NONE) return error; 387 if (error!=ERR_NONE) return error;
388 } 388 }
389 389
390 error=s->Phone.Functions->Initialise(s); 390 error=s->Phone.Functions->Initialise(s);
391 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue; 391 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue;
392 if (error != ERR_NONE) return error; 392 if (error != ERR_NONE) return error;
393 393
394 if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) { 394 if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) {
395 s->Phone.Functions->ShowStartInfo(s,true); 395 s->Phone.Functions->ShowStartInfo(s,true);
396 s->Phone.Data.StartInfoCounter = 30; 396 s->Phone.Data.StartInfoCounter = 30;
397 } 397 }
398 398
399 if (mystrncasecmp(s->CurrentConfig->SyncTime,"yes",0)) { 399 if (mystrncasecmp(s->CurrentConfig->SyncTime,"yes",0)) {
400 GSM_GetCurrentDateTime (&time); 400 GSM_GetCurrentDateTime (&time);
401 s->Phone.Functions->SetDateTime(s,&time); 401 s->Phone.Functions->SetDateTime(s,&time);
402 } 402 }
403 403
404 /* For debug it's good to have firmware and real model version and manufacturer */ 404 /* For debug it's good to have firmware and real model version and manufacturer */
405 error=s->Phone.Functions->GetManufacturer(s); 405 error=s->Phone.Functions->GetManufacturer(s);
406 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue; 406 if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) continue;
407 if (error != ERR_NONE) return error; 407 if (error != ERR_NONE) return error;
408 error=s->Phone.Functions->GetModel(s); 408 error=s->Phone.Functions->GetModel(s);
409 if (error != ERR_NONE) return error; 409 if (error != ERR_NONE) return error;
410 error=s->Phone.Functions->GetFirmware(s); 410 error=s->Phone.Functions->GetFirmware(s);
411 if (error != ERR_NONE) return error; 411 if (error != ERR_NONE) return error;
412 return ERR_NONE; 412 return ERR_NONE;
413 } 413 }
414 return ERR_UNKNOWN; 414 return ERR_UNKNOWN;
415} 415}
416 416
417int GSM_ReadDevice (GSM_StateMachine *s, bool wait) 417int GSM_ReadDevice (GSM_StateMachine *s, bool wait)
418{ 418{
419 unsigned charbuff[255]; 419 unsigned charbuff[255];
420 int res = 0, count; 420 int res = 0, count;
421 421
422 unsigned inti; 422 unsigned inti;
423 GSM_DateTimeDate; 423 GSM_DateTimeDate;
424 424
425 GSM_GetCurrentDateTime (&Date); 425 GSM_GetCurrentDateTime (&Date);
426 i=Date.Second; 426 i=Date.Second;
427 while (i==Date.Second) { 427 while (i==Date.Second) {
428 res = s->Device.Functions->ReadDevice(s, buff, 255); 428 res = s->Device.Functions->ReadDevice(s, buff, 255);
429 if (!wait) break; 429 if (!wait) break;
430 if (res > 0) break; 430 if (res > 0) break;
431 my_sleep(5); 431 my_sleep(5);
432 GSM_GetCurrentDateTime(&Date); 432 GSM_GetCurrentDateTime(&Date);
433 } 433 }
434 434
435 for (count = 0; count < res; count++) 435 for (count = 0; count < res; count++)
436 s->Protocol.Functions->StateMachine(s,buff[count]); 436 s->Protocol.Functions->StateMachine(s,buff[count]);
437 437
438 return res; 438 return res;
439} 439}
440 440
441GSM_Error GSM_TerminateConnection(GSM_StateMachine *s) 441GSM_Error GSM_TerminateConnection(GSM_StateMachine *s)
442{ 442{
443 GSM_Error error; 443 GSM_Error error;
444 444
445 if (!s->opened) return ERR_UNKNOWN; 445 if (!s->opened) return ERR_UNKNOWN;
446 446
447 smprintf(s,"[Closing]\n"); 447 smprintf(s,"[Closing]\n");
448 448
449 if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) { 449 if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) {
450 if (s->Phone.Data.StartInfoCounter > 0) s->Phone.Functions->ShowStartInfo(s,false); 450 if (s->Phone.Data.StartInfoCounter > 0) s->Phone.Functions->ShowStartInfo(s,false);
451 } 451 }
452 452
453 if (s->Phone.Functions != NULL) { 453 if (s->Phone.Functions != NULL) {
454 error=s->Phone.Functions->Terminate(s); 454 error=s->Phone.Functions->Terminate(s);
455 if (error!=ERR_NONE) return error; 455 if (error!=ERR_NONE) return error;
456 } 456 }
457 457
458 error=s->Protocol.Functions->Terminate(s); 458 error=s->Protocol.Functions->Terminate(s);
459 if (error!=ERR_NONE) return error; 459 if (error!=ERR_NONE) return error;
460 460
461 error = s->Device.Functions->CloseDevice(s); 461 error = s->Device.Functions->CloseDevice(s);
462 if (error!=ERR_NONE) return error; 462 if (error!=ERR_NONE) return error;
463 463
464 s->Phone.Data.ModelInfo = NULL; 464 s->Phone.Data.ModelInfo = NULL;
465 s->Phone.Data.Manufacturer[0] = 0; 465 s->Phone.Data.Manufacturer[0] = 0;
466 s->Phone.Data.Model[0] = 0; 466 s->Phone.Data.Model[0] = 0;
467 s->Phone.Data.Version[0] = 0; 467 s->Phone.Data.Version[0] = 0;
468 s->Phone.Data.VerDate[0] = 0; 468 s->Phone.Data.VerDate[0] = 0;
469 s->Phone.Data.VerNum = 0; 469 s->Phone.Data.VerNum = 0;
470 470
471 if (s->LockFile!=NULL) unlock_device(&(s->LockFile)); 471 if (s->LockFile!=NULL) unlock_device(&(s->LockFile));
472 472
473 if (!s->di.use_global && s->di.dl!=0 && fileno(s->di.df) != 1 && fileno(s->di.df) != 2) fclose(s->di.df); 473 if (!s->di.use_global && s->di.dl!=0 && fileno(s->di.df) != 1 && fileno(s->di.df) != 2) fclose(s->di.df);
474 474
475 s->opened = false; 475 s->opened = false;
476 476
477 return ERR_NONE; 477 return ERR_NONE;
478} 478}
479 479
480GSM_Error GSM_WaitForOnce(GSM_StateMachine *s, unsigned char *buffer, 480GSM_Error GSM_WaitForOnce(GSM_StateMachine *s, unsigned char *buffer,
481 int length, unsigned char type, int time) 481 int length, unsigned char type, int time)
482{ 482{
483 GSM_Phone_Data *Phone = &s->Phone.Data; 483 GSM_Phone_Data *Phone = &s->Phone.Data;
484 GSM_Protocol_Message sentmsg; 484 GSM_Protocol_Message sentmsg;
485 int i; 485 int i;
486 486
487 i=0; 487 i=0;
488 do { 488 do {
489 if (length != 0) { 489 if (length != 0) {
490 sentmsg.Length = length; 490 sentmsg.Length = length;
491 sentmsg.Type= type; 491 sentmsg.Type= type;
492 sentmsg.Buffer = (unsigned char *)malloc(length); 492 sentmsg.Buffer = (unsigned char *)malloc(length);
493 memcpy(sentmsg.Buffer,buffer,length); 493 memcpy(sentmsg.Buffer,buffer,length);
494 Phone->SentMsg = &sentmsg; 494 Phone->SentMsg = &sentmsg;
495 } 495 }
496 496
497 /* Some data received. Reset timer */ 497 /* Some data received. Reset timer */
498 if (GSM_ReadDevice(s,true)!=0) i=0; 498 if (GSM_ReadDevice(s,true)!=0) i=0;
499 499
500 if (length != 0) { 500 if (length != 0) {
501 free (sentmsg.Buffer); 501 free (sentmsg.Buffer);
502 Phone->SentMsg = NULL; 502 Phone->SentMsg = NULL;
503 } 503 }
504 504
505 /* Request completed */ 505 /* Request completed */
506 if (Phone->RequestID==ID_None) return Phone->DispatchError; 506 if (Phone->RequestID==ID_None) return Phone->DispatchError;
507 507
508 i++; 508 i++;
509 } while (i<time); 509 } while (i<time);
510 510
511 return ERR_TIMEOUT; 511 return ERR_TIMEOUT;
512} 512}
513 513
514GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer, 514GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer,
515 int length, unsigned char type, int time, 515 int length, unsigned char type, int time,
516 GSM_Phone_RequestID request) 516 GSM_Phone_RequestID request)
517{ 517{
518 GSM_Phone_Data *Phone = &s->Phone.Data; 518 GSM_Phone_Data *Phone = &s->Phone.Data;
519 GSM_Error error; 519 GSM_Error error;
520 int reply; 520 int reply;
521 521
522 if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) { 522 if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) {
523 if (Phone->StartInfoCounter > 0) { 523 if (Phone->StartInfoCounter > 0) {
524 Phone->StartInfoCounter--; 524 Phone->StartInfoCounter--;
525 if (Phone->StartInfoCounter == 0) s->Phone.Functions->ShowStartInfo(s,false); 525 if (Phone->StartInfoCounter == 0) s->Phone.Functions->ShowStartInfo(s,false);
526 } 526 }
527 } 527 }
528 528
529 Phone->RequestID= request; 529 Phone->RequestID= request;
530 Phone->DispatchError= ERR_TIMEOUT; 530 Phone->DispatchError= ERR_TIMEOUT;
531 531
532 for (reply=0;reply<s->ReplyNum;reply++) { 532 for (reply=0;reply<s->ReplyNum;reply++) {
533 if (reply!=0) { 533 if (reply!=0) {
534 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl == DL_TEXTERROR || 534 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl == DL_TEXTERROR ||
535 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl == DL_TEXTERRORDATE) 535 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl == DL_TEXTERRORDATE)
536 { 536 {
537 smprintf(s, "[Retrying %i type 0x%02X]\n", reply, type); 537 smprintf(s, "[Retrying %i type 0x%02X]\n", reply, type);
538 } 538 }
539 } 539 }
540 error = s->Protocol.Functions->WriteMessage(s, buffer, length, type); 540 error = s->Protocol.Functions->WriteMessage(s, buffer, length, type);
541 if (error!=ERR_NONE) return error; 541 if (error!=ERR_NONE) return error;
542 542
543 error = GSM_WaitForOnce(s, buffer, length, type, time); 543 error = GSM_WaitForOnce(s, buffer, length, type, time);
544 if (error != ERR_TIMEOUT) return error; 544 if (error != ERR_TIMEOUT) return error;
545 } 545 }
546 546
547 return Phone->DispatchError; 547 return Phone->DispatchError;
548} 548}
549 549
550static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Reply, int *reply) 550static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Reply, int *reply)
551{ 551{
552 GSM_Phone_Data *Data = &s->Phone.Data; 552 GSM_Phone_Data *Data = &s->Phone.Data;
553 GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg; 553 GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg;
554 bool execute; 554 bool execute;
555 bool available = false; 555 bool available = false;
556 int i = 0; 556 int i = 0;
557 //int j; 557 // int j;
558 558
559 while (Reply[i].requestID!=ID_None) { 559 while (Reply[i].requestID!=ID_None) {
560 execute=false; 560 execute=false;
561 /* Binary frames like in Nokia */ 561 /* Binary frames like in Nokia */
562 if (strlen(Reply[i].msgtype) < 2) { 562 if (strlen(Reply[i].msgtype) < 2) {
563 if (Reply[i].msgtype[0]==msg->Type) { 563 if (Reply[i].msgtype[0]==msg->Type) {
564 if (Reply[i].subtypechar!=0) { 564 if (Reply[i].subtypechar!=0) {
565 if (Reply[i].subtypechar<=msg->Length) { 565 if (Reply[i].subtypechar<=msg->Length) {
566 if (msg->Buffer[Reply[i].subtypechar]==Reply[i].subtype) 566 if (msg->Buffer[Reply[i].subtypechar]==Reply[i].subtype)
567 execute=true; 567 execute=true;
568 } 568 }
569 } else execute=true; 569 } else execute=true;
570 } 570 }
571 } else { 571 } else {
572 // printf("msg length %i %i\n",strlen(Reply[i].msgtype),msg->Length); 572 // printf("msg length %i %i\n",strlen(Reply[i].msgtype),msg->Length);
573 if ((int)strlen(Reply[i].msgtype)<msg->Length) { 573 if ((int)strlen(Reply[i].msgtype)<msg->Length) {
574 // printf("Comparing \"%s\" and \"",Reply[i].msgtype); 574 // printf("Comparing \"%s\" and \"",Reply[i].msgtype);
575 // for (j=0;j<strlen(Reply[i].msgtype);j++) { 575 // for (j=0;j<strlen(Reply[i].msgtype);j++) {
576 // if (msg->Buffer[j]!=13 && msg->Buffer[j]!=10) { 576 // if (msg->Buffer[j]!=13 && msg->Buffer[j]!=10) {
577 // printf("%c",msg->Buffer[j]); 577 // printf("%c",msg->Buffer[j]);
578 // } 578 // }
579 // } 579 // }
580 // printf("\"\n"); 580 // printf("\"\n");
581 if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) { 581 if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) {
582 execute=true; 582 execute=true;
583 } 583 }
584 } 584 }
585 } 585 }
586 586
587 if (execute) { 587 if (execute) {
588 *reply=i; 588 *reply=i;
589 if (Reply[i].requestID == ID_IncomingFrame || 589 if (Reply[i].requestID == ID_IncomingFrame ||
590 Reply[i].requestID == Data->RequestID || 590 Reply[i].requestID == Data->RequestID ||
591 Data->RequestID== ID_EachFrame) { 591 Data->RequestID== ID_EachFrame) {
592 return ERR_NONE; 592 return ERR_NONE;
593 } 593 }
594 available=true; 594 available=true;
595 } 595 }
596 i++; 596 i++;
597 } 597 }
598 598
599 if (available) { 599 if (available) {
600 return ERR_FRAMENOTREQUESTED; 600 return ERR_FRAMENOTREQUESTED;
601 } else { 601 } else {
602 return ERR_UNKNOWNFRAME; 602 return ERR_UNKNOWNFRAME;
603 } 603 }
604} 604}
605 605
606GSM_Error GSM_DispatchMessage(GSM_StateMachine *s) 606GSM_Error GSM_DispatchMessage(GSM_StateMachine *s)
607{ 607{
608 GSM_Error error= ERR_UNKNOWNFRAME; 608 GSM_Error error= ERR_UNKNOWNFRAME;
609 GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg; 609 GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg;
610 GSM_Phone_Data *Phone= &s->Phone.Data; 610 GSM_Phone_Data *Phone= &s->Phone.Data;
611 bool disp = false; 611 bool disp = false;
612 GSM_Reply_Function*Reply; 612 GSM_Reply_Function*Reply;
613 int reply, i; 613 int reply, i;
614 614
615 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 615 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
616 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 616 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
617 smprintf(s, "RECEIVED frame "); 617 smprintf(s, "RECEIVED frame ");
618 smprintf(s, "type 0x%02X/length 0x%02X/%i", msg->Type, msg->Length, msg->Length); 618 smprintf(s, "type 0x%02X/length 0x%02X/%i", msg->Type, msg->Length, msg->Length);
619 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, msg->Buffer, msg->Length); 619 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, msg->Buffer, msg->Length);
620 if (msg->Length == 0) smprintf(s, "\n"); 620 if (msg->Length == 0) smprintf(s, "\n");
621 fflush(s->di.df); 621 fflush(s->di.df);
622 } 622 }
623 if (s->di.dl==DL_BINARY) { 623 if (s->di.dl==DL_BINARY) {
624 smprintf(s,"%c",0x02);/* Receiving */ 624 smprintf(s,"%c",0x02);/* Receiving */
625 smprintf(s,"%c",msg->Type); 625 smprintf(s,"%c",msg->Type);
626 smprintf(s,"%c",msg->Length/256); 626 smprintf(s,"%c",msg->Length/256);
627 smprintf(s,"%c",msg->Length%256); 627 smprintf(s,"%c",msg->Length%256);
628 for (i=0;i<msg->Length;i++) { 628 for (i=0;i<msg->Length;i++) {
629 smprintf(s,"%c",msg->Buffer[i]); 629 smprintf(s,"%c",msg->Buffer[i]);
630 } 630 }
631 } 631 }
632 632
633 Reply=s->User.UserReplyFunctions; 633 Reply=s->User.UserReplyFunctions;
634 if (Reply!=NULL) error=CheckReplyFunctions(s,Reply,&reply); 634 if (Reply!=NULL) error=CheckReplyFunctions(s,Reply,&reply);
635 635
636 if (error==ERR_UNKNOWNFRAME) { 636 if (error==ERR_UNKNOWNFRAME) {
637 Reply=s->Phone.Functions->ReplyFunctions; 637 Reply=s->Phone.Functions->ReplyFunctions;
638 error=CheckReplyFunctions(s,Reply,&reply); 638 error=CheckReplyFunctions(s,Reply,&reply);
639 } 639 }
640 640
641 if (error==ERR_NONE) { 641 if (error==ERR_NONE) {
642 error=Reply[reply].Function(*msg, s); 642 error=Reply[reply].Function(*msg, s);
643 if (Reply[reply].requestID==Phone->RequestID) { 643 if (Reply[reply].requestID==Phone->RequestID) {
644 if (error == ERR_NEEDANOTHERANSWER) { 644 if (error == ERR_NEEDANOTHERANSWER) {
645 error = ERR_NONE; 645 error = ERR_NONE;
646 } else { 646 } else {
647 Phone->RequestID=ID_None; 647 Phone->RequestID=ID_None;
648 } 648 }
649 } 649 }
650 } 650 }
651 651
652 if (strcmp(s->Phone.Functions->models,"NAUTO")) { 652 if (strcmp(s->Phone.Functions->models,"NAUTO")) {
653 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 653 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
654 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 654 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
655 disp = true; 655 disp = true;
656 switch (error) { 656 switch (error) {
657 case ERR_UNKNOWNRESPONSE: 657 case ERR_UNKNOWNRESPONSE:
658 smprintf(s, "\nUNKNOWN response"); 658 smprintf(s, "\nUNKNOWN response");
659 break; 659 break;
660 case ERR_UNKNOWNFRAME: 660 case ERR_UNKNOWNFRAME:
661 smprintf(s, "\nUNKNOWN frame"); 661 smprintf(s, "\nUNKNOWN frame");
662 break; 662 break;
663 case ERR_FRAMENOTREQUESTED: 663 case ERR_FRAMENOTREQUESTED:
664 smprintf(s, "\nFrame not request now"); 664 smprintf(s, "\nFrame not request now");
665 break; 665 break;
666 default: 666 default:
667 disp = false; 667 disp = false;
668 } 668 }
669 } 669 }
670 670
671 if (error == ERR_UNKNOWNFRAME || error == ERR_FRAMENOTREQUESTED) { 671 if (error == ERR_UNKNOWNFRAME || error == ERR_FRAMENOTREQUESTED) {
672 error = ERR_TIMEOUT; 672 error = ERR_TIMEOUT;
673 } 673 }
674 } 674 }
675 675
676 if (disp) { 676 if (disp) {
677 smprintf(s,". If you can, PLEASE report it (see readme.txt). THANK YOU\n"); 677 smprintf(s,". If you can, PLEASE report it (see readme.txt). THANK YOU\n");
678 if (Phone->SentMsg != NULL) { 678 if (Phone->SentMsg != NULL) {
679 smprintf(s,"LAST SENT frame "); 679 smprintf(s,"LAST SENT frame ");
680 smprintf(s, "type 0x%02X/length %i", Phone->SentMsg->Type, Phone->SentMsg->Length); 680 smprintf(s, "type 0x%02X/length %i", Phone->SentMsg->Type, Phone->SentMsg->Length);
681 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, Phone->SentMsg->Buffer, Phone->SentMsg->Length); 681 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, Phone->SentMsg->Buffer, Phone->SentMsg->Length);
682 } 682 }
683 smprintf(s, "RECEIVED frame "); 683 smprintf(s, "RECEIVED frame ");
684 smprintf(s, "type 0x%02X/length 0x%02X/%i", msg->Type, msg->Length, msg->Length); 684 smprintf(s, "type 0x%02X/length 0x%02X/%i", msg->Type, msg->Length, msg->Length);
685 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, msg->Buffer, msg->Length); 685 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, msg->Buffer, msg->Length);
686 smprintf(s, "\n"); 686 smprintf(s, "\n");
687 } 687 }
688 688
689 return error; 689 return error;
690} 690}
691 691
692INI_Section *GSM_FindGammuRC(void) 692INI_Section *GSM_FindGammuRC(void)
693{ 693{
694 INI_Section*ini_file; 694 INI_Section*ini_file;
695 char *HomeDrive,*HomePath,*FileName=malloc(1); 695 char *HomeDrive,*HomePath,*FileName=malloc(1);
696 int FileNameUsed=1; 696 int FileNameUsed=1;
697 697
698 FileName[0] = 0; 698 FileName[0] = 0;
699#if defined(WIN32) || defined(DJGPP) 699#if defined(WIN32) || defined(DJGPP)
700 HomeDrive = getenv("HOMEDRIVE"); 700 HomeDrive = getenv("HOMEDRIVE");
701 if (HomeDrive) { 701 if (HomeDrive) {
702 FileName = realloc(FileName,FileNameUsed+strlen(HomeDrive)+1); 702 FileName = realloc(FileName,FileNameUsed+strlen(HomeDrive)+1);
703 FileName = strcat(FileName, HomeDrive); 703 FileName = strcat(FileName, HomeDrive);
704 FileNameUsed+= strlen(HomeDrive)+1; 704 FileNameUsed+= strlen(HomeDrive)+1;
705 } 705 }
706 HomePath = getenv("HOMEPATH"); 706 HomePath = getenv("HOMEPATH");
707 if (HomePath) { 707 if (HomePath) {
708 FileName = realloc(FileName,FileNameUsed+strlen(HomePath)+1); 708 FileName = realloc(FileName,FileNameUsed+strlen(HomePath)+1);
709 FileName = strcat(FileName, HomePath); 709 FileName = strcat(FileName, HomePath);
710 FileNameUsed+= strlen(HomePath)+1; 710 FileNameUsed+= strlen(HomePath)+1;
711 } 711 }
712 FileName = realloc(FileName,FileNameUsed+8+1); 712 FileName = realloc(FileName,FileNameUsed+8+1);
713 strcat(FileName, "\\gammurc"); 713 strcat(FileName, "\\gammurc");
714#else 714#else
715 HomeDrive = NULL; 715 HomeDrive = NULL;
716 HomePath = getenv("HOME"); 716 HomePath = getenv("HOME");
717 if (HomePath) { 717 if (HomePath) {
718 FileName = realloc(FileName,FileNameUsed+strlen(HomePath)+1); 718 FileName = realloc(FileName,FileNameUsed+strlen(HomePath)+1);
719 FileName = strcat(FileName, HomePath); 719 FileName = strcat(FileName, HomePath);
720 FileNameUsed+= strlen(HomePath)+1; 720 FileNameUsed+= strlen(HomePath)+1;
721 } 721 }
722 FileName = realloc(FileName,FileNameUsed+9+1); 722 FileName = realloc(FileName,FileNameUsed+9+1);
723 strcat(FileName, "/.gammurc"); 723 strcat(FileName, "/.gammurc");
724#endif 724#endif
725 //dbgprintf("\"%s\"\n",FileName); 725 //dbgprintf("\"%s\"\n",FileName);
726 726
727 ini_file = INI_ReadFile(FileName, false); 727 ini_file = INI_ReadFile(FileName, false);
728 free(FileName); 728 free(FileName);
729 if (ini_file == NULL) { 729 if (ini_file == NULL) {
730#if defined(WIN32) || defined(DJGPP) 730#if defined(WIN32) || defined(DJGPP)
731 ini_file = INI_ReadFile("gammurc", false); 731 ini_file = INI_ReadFile("gammurc", false);
732 if (ini_file == NULL) return NULL; 732 if (ini_file == NULL) return NULL;
733#else 733#else
734 ini_file = INI_ReadFile("/etc/gammurc", false); 734 ini_file = INI_ReadFile("/etc/gammurc", false);
735 if (ini_file == NULL) return NULL; 735 if (ini_file == NULL) return NULL;
736#endif 736#endif
737 } 737 }
738 738
739 return ini_file; 739 return ini_file;
740} 740}
741 741
742bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num) 742bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num)
743{ 743{
744 INI_Section *h; 744 INI_Section *h;
745 unsigned char section[50]; 745 unsigned char section[50];
746 bool found = false; 746 bool found = false;
747 747
748#if defined(WIN32) || defined(DJGPP) 748#if defined(WIN32) || defined(DJGPP)
749 char *DefaultPort = "com2:"; 749 char *DefaultPort = "com2:";
750#else 750#else
751 char *DefaultPort = "/dev/ttyS1"; 751 char *DefaultPort = "/dev/ttyS1";
752#endif 752#endif
753 char *DefaultModel = ""; 753 char *DefaultModel = "";
754 char *DefaultConnection = "fbus"; 754 char *DefaultConnection = "fbus";
755 char *DefaultSynchronizeTime= "no"; 755 char *DefaultSynchronizeTime= "no";
756 char *DefaultDebugFile = ""; 756 char *DefaultDebugFile = "";
757 char *DefaultDebugLevel = ""; 757 char *DefaultDebugLevel = "";
758 char *DefaultLockDevice = "no"; 758 char *DefaultLockDevice = "no";
759 char *DefaultStartInfo = "no"; 759 char *DefaultStartInfo = "no";
760 char *Temp; 760 char *Temp;
761 761
762 /* By default all debug output will go to one filedescriptor */ 762 /* By default all debug output will go to one filedescriptor */
763 bool DefaultUseGlobalDebugFile = true; 763 bool DefaultUseGlobalDebugFile = true;
764 764
765 cfg->Device = DefaultPort; 765 cfg->Device = DefaultPort;
766 cfg->Connection = DefaultConnection; 766 cfg->Connection = DefaultConnection;
767 cfg->SyncTime = DefaultSynchronizeTime; 767 cfg->SyncTime = DefaultSynchronizeTime;
768 cfg->DebugFile = DefaultDebugFile; 768 cfg->DebugFile = DefaultDebugFile;
769 strcpy(cfg->Model,DefaultModel); 769 strcpy(cfg->Model,DefaultModel);
770 strcpy(cfg->DebugLevel,DefaultDebugLevel); 770 strcpy(cfg->DebugLevel,DefaultDebugLevel);
771 cfg->LockDevice = DefaultLockDevice; 771 cfg->LockDevice = DefaultLockDevice;
772 cfg->StartInfo = DefaultStartInfo; 772 cfg->StartInfo = DefaultStartInfo;
773 cfg->DefaultDevice = true; 773 cfg->DefaultDevice = true;
774 cfg->DefaultModel = true; 774 cfg->DefaultModel = true;
775 cfg->DefaultConnection = true; 775 cfg->DefaultConnection = true;
776 cfg->DefaultSyncTime = true; 776 cfg->DefaultSyncTime = true;
777 cfg->DefaultDebugFile = true; 777 cfg->DefaultDebugFile = true;
778 cfg->DefaultDebugLevel = true; 778 cfg->DefaultDebugLevel = true;
779 cfg->DefaultLockDevice = true; 779 cfg->DefaultLockDevice = true;
780 cfg->DefaultStartInfo = true; 780 cfg->DefaultStartInfo = true;
781 781
782 cfg->UseGlobalDebugFile = DefaultUseGlobalDebugFile; 782 cfg->UseGlobalDebugFile = DefaultUseGlobalDebugFile;
783 783
784 if (cfg_info==NULL) return false; 784 if (cfg_info==NULL) return false;
785 785
786 if (num == 0) { 786 if (num == 0) {
787 sprintf(section,"gammu"); 787 sprintf(section,"gammu");
788 } else { 788 } else {
789 sprintf(section,"gammu%i",num); 789 sprintf(section,"gammu%i",num);
790 } 790 }
791 for (h = cfg_info; h != NULL; h = h->Next) { 791 for (h = cfg_info; h != NULL; h = h->Next) {
792 if (mystrncasecmp(section, h->SectionName, strlen(section))) { 792 if (mystrncasecmp(section, h->SectionName, strlen(section))) {
793 found = true; 793 found = true;
794 break; 794 break;
795 } 795 }
796 } 796 }
797 if (!found) return false; 797 if (!found) return false;
798 798
799 cfg->Device = INI_GetValue(cfg_info, section, "port", false); 799 cfg->Device = INI_GetValue(cfg_info, section, "port", false);
800 if (!cfg->Device) { 800 if (!cfg->Device) {
801 free(cfg->Device); 801 free(cfg->Device);
802 cfg->Device = strdup(DefaultPort); 802 cfg->Device = strdup(DefaultPort);
803 } else { 803 } else {
804 cfg->DefaultDevice = false; 804 cfg->DefaultDevice = false;
805 } 805 }
806 cfg->Connection = INI_GetValue(cfg_info, section, "connection", false); 806 cfg->Connection = INI_GetValue(cfg_info, section, "connection", false);
807 if (!cfg->Connection) { 807 if (!cfg->Connection) {
808 free(cfg->Connection); 808 free(cfg->Connection);
809 cfg->Connection = strdup(DefaultConnection); 809 cfg->Connection = strdup(DefaultConnection);
810 } else { 810 } else {
811 cfg->DefaultConnection = false; 811 cfg->DefaultConnection = false;
812 } 812 }
813 cfg->SyncTime = INI_GetValue(cfg_info, section, "synchronizetime",false); 813 cfg->SyncTime = INI_GetValue(cfg_info, section, "synchronizetime",false);
814 if (!cfg->SyncTime) { 814 if (!cfg->SyncTime) {
815 free(cfg->SyncTime); 815 free(cfg->SyncTime);
816 cfg->SyncTime = strdup(DefaultSynchronizeTime); 816 cfg->SyncTime = strdup(DefaultSynchronizeTime);
817 } else { 817 } else {
818 cfg->DefaultSyncTime = false; 818 cfg->DefaultSyncTime = false;
819 } 819 }
820 cfg->DebugFile = INI_GetValue(cfg_info, section, "logfile", false); 820 cfg->DebugFile = INI_GetValue(cfg_info, section, "logfile", false);
821 if (!cfg->DebugFile) { 821 if (!cfg->DebugFile) {
822 free(cfg->DebugFile); 822 free(cfg->DebugFile);
823 cfg->DebugFile = strdup(DefaultDebugFile); 823 cfg->DebugFile = strdup(DefaultDebugFile);
824 } else { 824 } else {
825 cfg->DefaultDebugFile = false; 825 cfg->DefaultDebugFile = false;
826 } 826 }
827 cfg->LockDevice = INI_GetValue(cfg_info, section, "use_locking", false); 827 cfg->LockDevice = INI_GetValue(cfg_info, section, "use_locking", false);
828 if (!cfg->LockDevice) { 828 if (!cfg->LockDevice) {
829 free(cfg->LockDevice); 829 free(cfg->LockDevice);
830 cfg->LockDevice = strdup(DefaultLockDevice); 830 cfg->LockDevice = strdup(DefaultLockDevice);
831 } else { 831 } else {
832 cfg->DefaultLockDevice = false; 832 cfg->DefaultLockDevice = false;
833 } 833 }
834 Temp = INI_GetValue(cfg_info, section, "model", false); 834 Temp = INI_GetValue(cfg_info, section, "model", false);
835 if (!Temp) { 835 if (!Temp) {
836 strcpy(cfg->Model,DefaultModel); 836 strcpy(cfg->Model,DefaultModel);
837 } else { 837 } else {
838 cfg->DefaultModel = false; 838 cfg->DefaultModel = false;
839 strcpy(cfg->Model,Temp); 839 strcpy(cfg->Model,Temp);
840 } 840 }
841 Temp = INI_GetValue(cfg_info, section, "logformat", false); 841 Temp = INI_GetValue(cfg_info, section, "logformat", false);
842 if (!Temp) { 842 if (!Temp) {
843 strcpy(cfg->DebugLevel,DefaultDebugLevel); 843 strcpy(cfg->DebugLevel,DefaultDebugLevel);
844 } else { 844 } else {
845 cfg->DefaultDebugLevel = false; 845 cfg->DefaultDebugLevel = false;
846 strcpy(cfg->DebugLevel,Temp); 846 strcpy(cfg->DebugLevel,Temp);
847 } 847 }
848 cfg->StartInfo = INI_GetValue(cfg_info, section, "startinfo", false); 848 cfg->StartInfo = INI_GetValue(cfg_info, section, "startinfo", false);
849 if (!cfg->StartInfo) { 849 if (!cfg->StartInfo) {
850 free(cfg->StartInfo); 850 free(cfg->StartInfo);
851 cfg->StartInfo = strdup(DefaultStartInfo); 851 cfg->StartInfo = strdup(DefaultStartInfo);
852 } else { 852 } else {
853 cfg->DefaultStartInfo = false; 853 cfg->DefaultStartInfo = false;
854 } 854 }
855 return true; 855 return true;
856} 856}
857 857
858static OnePhoneModel allmodels[] = { 858static OnePhoneModel allmodels[] = {
859#ifdef GSM_ENABLE_NOKIA650 859#ifdef GSM_ENABLE_NOKIA650
860 {"0650" ,"THF-12","", {0}}, 860 {"0650" ,"THF-12","", {0}},
861#endif 861#endif
862#ifdef GSM_ENABLE_NOKIA6510 862#ifdef GSM_ENABLE_NOKIA6510
863 {"1100" ,"RH-18" ,"", {0}}, 863 {"1100" ,"RH-18" ,"", {0}},
864 {"1100a","RH-38" ,"", {0}}, 864 {"1100a","RH-38" ,"", {0}},
865 {"1100b","RH-36" ,"", {0}}, 865 {"1100b","RH-36" ,"", {0}},
866#endif 866#endif
867#ifdef GSM_ENABLE_NOKIA6110 867#ifdef GSM_ENABLE_NOKIA6110
868 {"2100" ,"NAM-2" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess 868 {"2100" ,"NAM-2" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess
869#endif 869#endif
870#ifdef GSM_ENABLE_NOKIA6510 870#ifdef GSM_ENABLE_NOKIA6510
871 {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme 871 {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
872 {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme 872 {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
873 {"3105" ,"RH-48" ,"Nokia 3105",{F_PBKTONEGAL,F_PBKSMSLIST,F_VOICETAGS,0}},//fixme
873 {"3108", "RH-6", "Nokia 3108",{0}}, //does it have irda ? 874 {"3108", "RH-6", "Nokia 3108",{0}}, //does it have irda ?
874 {"3200", "RH-30" ,"Nokia 3200",{F_PBKTONEGAL,0}},//fixme 875 {"3200", "RH-30" ,"Nokia 3200",{F_PBKTONEGAL,0}},//fixme
875 {"3200a","RH-31" ,"Nokia 3200",{F_PBKTONEGAL,0}},//fixme 876 {"3200a","RH-31" ,"Nokia 3200",{F_PBKTONEGAL,0}},//fixme
876#endif 877#endif
877#ifdef GSM_ENABLE_NOKIA6110 878#ifdef GSM_ENABLE_NOKIA6110
878 {"3210" ,"NSE-8" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 879 {"3210" ,"NSE-8" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
879 {"3210" ,"NSE-9" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 880 {"3210" ,"NSE-9" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
880#endif 881#endif
881#ifdef GSM_ENABLE_NOKIA6510 882#ifdef GSM_ENABLE_NOKIA6510
882 {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme 883 {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
883 {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme 884 {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
884#endif 885#endif
885#ifdef GSM_ENABLE_NOKIA6110 886#ifdef GSM_ENABLE_NOKIA6110
886 {"3310" ,"NHM-5" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}}, 887 {"3310" ,"NHM-5" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},
887#endif 888#endif
888#ifdef GSM_ENABLE_NOKIA3320 889#ifdef GSM_ENABLE_NOKIA3320
889 {"3320" ,"NPC-1" ,"Nokia 3320", {F_CAL62,F_DAYMONTH,0}},//fixme 890 {"3320" ,"NPC-1" ,"Nokia 3320", {F_CAL62,F_DAYMONTH,0}},//fixme
890#endif 891#endif
891#ifdef GSM_ENABLE_NOKIA6110 892#ifdef GSM_ENABLE_NOKIA6110
892 {"3330" ,"NHM-6" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 893 {"3330" ,"NHM-6" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
893 {"3390" ,"NPB-1" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 894 {"3390" ,"NPB-1" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
894 {"3410" ,"NHM-2" ,"", {F_RING_SM,F_CAL33,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}}, 895 {"3410" ,"NHM-2" ,"", {F_RING_SM,F_CAL33,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},
895#endif 896#endif
896#ifdef GSM_ENABLE_NOKIA6510 897#ifdef GSM_ENABLE_NOKIA6510
897 {"3510" ,"NHM-8" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}}, 898 {"3510" ,"NHM-8" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}},
898 {"3510i","RH-9" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}}, 899 {"3510i","RH-9" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}},
899 {"3530" ,"RH-9" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}}, 900 {"3530" ,"RH-9" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}},
900 {"3589i","RH-44" ,"", {F_VOICETAGS,0}}, 901 {"3589i","RH-44" ,"", {F_VOICETAGS,0}},
901 {"3590" ,"NPM-8" ,"", {0}},//irda? 902 {"3590" ,"NPM-8" ,"", {0}},//irda?
902 {"3595" ,"NPM-10" ,"", {0}},//irda? 903 {"3595" ,"NPM-10" ,"", {0}},//irda?
903#endif 904#endif
904#ifdef GSM_ENABLE_NOKIA6110 905#ifdef GSM_ENABLE_NOKIA6110
905 {"3610" ,"NAM-1" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess 906 {"3610" ,"NAM-1" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess
906#endif 907#endif
907#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA3650) 908#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA3650)
908 {"3650" ,"NHL-8" ,"Nokia 3650", {0}}, 909 {"3650" ,"NHL-8" ,"Nokia 3650", {0}},
909 {"NGAGE","NEM-4" ,"", {F_RADIO,0}}, 910 {"NGAGE","NEM-4" ,"", {F_RADIO,0}},
910#endif 911#endif
911#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 912#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
912 {"5100" ,"NPM-6" ,"Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 913 {"5100" ,"NPM-6" ,"Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
913 {"5100" ,"NPM-6U","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 914 {"5100" ,"NPM-6U","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
914 {"5100" ,"NPM-6X","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 915 {"5100" ,"NPM-6X","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
915 {"5140" ,"NPL-4" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}}, 916 {"5140" ,"NPL-4" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
916 {"5140" ,"NPL-5" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}}, 917 {"5140" ,"NPL-5" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
917#endif 918#endif
918#ifdef GSM_ENABLE_NOKIA6110 919#ifdef GSM_ENABLE_NOKIA6110
919 {"5110" ,"NSE-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 920 {"5110" ,"NSE-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
920 {"5110i","NSE-2" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 921 {"5110i","NSE-2" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
921 {"5130" ,"NSK-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 922 {"5130" ,"NSK-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
922 {"5190" ,"NSB-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 923 {"5190" ,"NSB-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
923#endif 924#endif
924#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110) 925#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
925 {"5210" ,"NSM-5" ,"Nokia 5210", {F_CAL52,F_NOSTARTANI,F_NOPICTUREUNI,F_NODTMF,0}}, 926 {"5210" ,"NSM-5" ,"Nokia 5210", {F_CAL52,F_NOSTARTANI,F_NOPICTUREUNI,F_NODTMF,0}},
926#endif 927#endif
927#ifdef GSM_ENABLE_NOKIA6110 928#ifdef GSM_ENABLE_NOKIA6110
928 {"5510" ,"NPM-5" ,"", {F_NOCALLER,F_PROFILES33,F_NOPICTUREUNI,0}}, 929 {"5510" ,"NPM-5" ,"", {F_NOCALLER,F_PROFILES33,F_NOPICTUREUNI,0}},
929#endif 930#endif
930#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 931#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
931 {"6100" ,"NPL-2" ,"Nokia 6100", {F_PBKTONEGAL,F_TODO66,0}}, 932 {"6100" ,"NPL-2" ,"Nokia 6100", {F_PBKTONEGAL,F_TODO66,0}},
932#endif 933#endif
933#ifdef GSM_ENABLE_NOKIA6110 934#ifdef GSM_ENABLE_NOKIA6110
934 {"6110" ,"NSE-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}}, 935 {"6110" ,"NSE-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
935 {"6130" ,"NSK-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}}, 936 {"6130" ,"NSK-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
936 {"6150" ,"NSM-1" ,"", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,F_NOPICTUREUNI,0}}, 937 {"6150" ,"NSM-1" ,"", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,F_NOPICTUREUNI,0}},
937 {"6190" ,"NSB-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}}, 938 {"6190" ,"NSB-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
938#endif 939#endif
939#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 940#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
940 {"6200" ,"NPL-3" ,"Nokia 6200", {F_PBKTONEGAL,0}}, 941 {"6200" ,"NPL-3" ,"Nokia 6200", {F_PBKTONEGAL,0}},
941 {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}}, 942 {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
942#endif 943#endif
943#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110) 944#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110)
944 {"6210" ,"NPE-3" ,"Nokia 6210", {F_VOICETAGS,F_CAL62,0}}, 945 {"6210" ,"NPE-3" ,"Nokia 6210", {F_VOICETAGS,F_CAL62,0}},
945 {"6250" ,"NHM-3" ,"Nokia 6250", {F_VOICETAGS,F_CAL62,0}}, 946 {"6250" ,"NHM-3" ,"Nokia 6250", {F_VOICETAGS,F_CAL62,0}},
946#endif 947#endif
947#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 948#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
948 {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}}, 949 {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
949 {"6310" ,"NPE-4" ,"Nokia 6310", {F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}}, 950 {"6310" ,"NPE-4" ,"Nokia 6310", {F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
950 {"6310i","NPL-1" ,"Nokia 6310i",{F_TODO63,F_CAL65,F_NOMIDI,F_BLUETOOTH,F_NOMMS,F_VOICETAGS,0}}, 951 {"6310i","NPL-1" ,"Nokia 6310i",{F_TODO63,F_CAL65,F_NOMIDI,F_BLUETOOTH,F_NOMMS,F_VOICETAGS,0}},
951 {"6385" ,"NHP-2AX","Nokia 6385",{F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}}, 952 {"6385" ,"NHP-2AX","Nokia 6385",{F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
952 {"6510" ,"NPM-9" ,"Nokia 6510", {F_TODO63,F_CAL65,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}}, 953 {"6510" ,"NPM-9" ,"Nokia 6510", {F_TODO63,F_CAL65,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
953 {"6610" ,"NHL-4U","Nokia 6610", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 954 {"6610" ,"NHL-4U","Nokia 6610", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
954 {"6610i","RM-37" ,"Nokia 6610i",{F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 955 {"6610i","RM-37" ,"Nokia 6610i",{F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
955 {"6800" ,"NSB-9" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}}, 956 {"6800" ,"NSB-9" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
956 {"6800" ,"NHL-6" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}}, 957 {"6800" ,"NHL-6" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
957 {"6810" ,"RM-2" ,"Nokia 6810", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess 958 {"6810" ,"RM-2" ,"Nokia 6810", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_NOTES,0}},//quess
958 {"6820" ,"NHL-9" ,"Nokia 6820", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess 959 {"6820" ,"NHL-9" ,"Nokia 6820", {F_PBKTONEGAL,F_TODO66,F_PBKSMSLIST,F_NOTES,0}},//quess
959#endif 960#endif
960#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110) 961#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110)
961 {"7110" ,"NSE-5" ,"Nokia 7110", {F_CAL62,0}}, 962 {"7110" ,"NSE-5" ,"Nokia 7110", {F_CAL62,0}},
962 {"7190" ,"NSB-5" ,"Nokia 7190", {F_CAL62,0}}, 963 {"7190" ,"NSB-5" ,"Nokia 7190", {F_CAL62,0}},
963#endif 964#endif
964#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 965#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
965 {"7200" ,"RH-23" ,"Nokia 7200", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}},//quess 966 {"7200" ,"RH-23" ,"Nokia 7200", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}},//quess
966 {"7210" ,"NHL-4" ,"Nokia 7210", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 967 {"7210" ,"NHL-4" ,"Nokia 7210", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
967 {"7250" ,"NHL-4J","Nokia 7250", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}}, 968 {"7250" ,"NHL-4J","Nokia 7250", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}},
968 {"7250i","NHL-4JX","Nokia 7250i",{F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}}, 969 {"7250i","NHL-4JX","Nokia 7250i",{F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}},
969 {"7600", "NMM-3", "Nokia 7600", {F_TODO66,0}}, 970 {"7600", "NMM-3", "Nokia 7600", {F_TODO66,0}},
970#endif 971#endif
971#if defined(GSM_ENABLE_ATGEN) 972#if defined(GSM_ENABLE_ATGEN)
972 {"7650" ,"NHL-2" ,"Nokia 7650", {0}}, 973 {"7650" ,"NHL-2" ,"Nokia 7650", {0}},
973#endif 974#endif
974#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110) 975#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
975 {"8210" ,"NSM-3" ,"Nokia 8210", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}}, 976 {"8210" ,"NSM-3" ,"Nokia 8210", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}},
976 {"8250" ,"NSM-3D","Nokia 8250", {F_NOWAP,F_NOSTARTANI,F_CAL82,F_NOPICTUREUNI,0}}, 977 {"8250" ,"NSM-3D","Nokia 8250", {F_NOWAP,F_NOSTARTANI,F_CAL82,F_NOPICTUREUNI,0}},
977 {"8290" ,"NSB-7" ,"Nokia 8290", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}}, 978 {"8290" ,"NSB-7" ,"Nokia 8290", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}},
978#endif 979#endif
979#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 980#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
980 {"8310" ,"NHM-7" ,"Nokia 8310", {F_CAL62,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}}, 981 {"8310" ,"NHM-7" ,"Nokia 8310", {F_CAL62,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
981 {"8390" ,"NSB-8" ,"Nokia 8390", {F_CAL62,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}}, 982 {"8390" ,"NSB-8" ,"Nokia 8390", {F_CAL62,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
982#endif 983#endif
983#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110) 984#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
984 {"8850" ,"NSM-2" ,"Nokia 8850", {0}}, 985 {"8850" ,"NSM-2" ,"Nokia 8850", {0}},
985 {"8855" ,"NSM-4" ,"Nokia 8855", {0}}, 986 {"8855" ,"NSM-4" ,"Nokia 8855", {0}},
986 {"8890" ,"NSB-6" ,"Nokia 8890", {0}}, 987 {"8890" ,"NSB-6" ,"Nokia 8890", {0}},
987#endif 988#endif
988#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 989#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
989 {"8910" ,"NHM-4" ,"Nokia 8910", {F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}}, 990 {"8910" ,"NHM-4" ,"Nokia 8910", {F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}},
990 {"8910i","NHM-4" ,"Nokia 8910i",{F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}}, 991 {"8910i","NHM-4" ,"Nokia 8910i",{F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}},
991#endif 992#endif
992#ifdef GSM_ENABLE_NOKIA9210 993#ifdef GSM_ENABLE_NOKIA9210
993 {"9210" ,"RAE-3" ,"", {0}}, 994 {"9210" ,"RAE-3" ,"", {0}},
994 {"9210i","RAE-5" ,"", {0}}, 995 {"9210i","RAE-5" ,"", {0}},
995#endif 996#endif
996#ifdef GSM_ENABLE_ATGEN 997#ifdef GSM_ENABLE_ATGEN
997 {"at" , "at", "", {0}}, 998 {"at" , "at", "", {0}},
998 /* Siemens */ 999 /* Siemens */
999 {"M20" , "M20", "", {F_M20SMS,F_SLOWWRITE,0}}, 1000 {"M20" , "M20", "", {F_M20SMS,F_SLOWWRITE,0}},
1000 {"MC35" , "MC35", "", {0}}, 1001 {"MC35" , "MC35", "", {0}},
1001 {"TC35" , "TC35", "", {0}}, 1002 {"TC35" , "TC35", "", {0}},
1002 {"S25", "S25", "SIEMENS S25", {0}}, 1003 {"S25", "S25", "SIEMENS S25", {0}},
1003 {"C35i" , "C35i", "", {0}}, 1004 {"C35i" , "C35i", "", {0}},
1004 {"S35i" , "S35i", "", {0}}, 1005 {"S35i" , "S35i", "", {0}},
1005 {"M35i" , "M35i", "", {0}}, 1006 {"M35i" , "M35i", "", {0}},
1006 {"S40" , "Siemens S40", "", {0}}, 1007 {"S40" , "Siemens S40", "", {0}},
1007 {"C45" , "C45", "", {0}}, 1008 {"C45" , "C45", "", {0}},
1008 {"S45" , "S45", "", {0}}, 1009 {"S45" , "S45", "", {0}},
1009 {"ME45" , "ME45", "", {0}}, 1010 {"ME45" , "ME45", "", {0}},
1010 {"SL45" , "SL45", "", {0}}, 1011 {"SL45" , "SL45", "", {0}},
1011 {"SL45i" , "SL45i", "", {0}}, 1012 {"SL45i" , "SL45i", "", {0}},
1012 {"M50" , "M50", "", {0}}, 1013 {"M50" , "M50", "", {0}},
1013 {"S45" , "6618" , "", {0}}, 1014 {"S45" , "6618" , "", {0}},
1014 {"ME45" , "3618" , "", {0}}, 1015 {"ME45" , "3618" , "", {0}},
1015 {"S55" , "S55" , "", {0}}, 1016 {"S55" , "S55" , "", {0}},
1016 /* Samsung */ 1017 /* Samsung */
1017 {"S100" , "SGH-S100" , "", {0}}, 1018 {"S100" , "SGH-S100" , "", {0}},
1018 {"S200" , "SGH-S200" , "", {0}}, 1019 {"S200" , "SGH-S200" , "", {0}},
1019 {"S300" , "SGH-S300" , "", {0}}, 1020 {"S300" , "SGH-S300" , "", {0}},
1020 {"S500" , "SGH-S500" , "", {0}}, 1021 {"S500" , "SGH-S500" , "", {0}},
1021 {"V200" , "SGH-V200" , "", {0}}, 1022 {"V200" , "SGH-V200" , "", {0}},
1022 {"T100" , "SGH-T100" , "", {0}}, 1023 {"T100" , "SGH-T100" , "", {0}},
1023 {"E700" , "SGH-E700" , "", {0}}, 1024 {"E700" , "SGH-E700" , "", {0}},
1024 /* Ericsson/Sony Ericsson */ 1025 /* Ericsson/Sony Ericsson */
1025 {"T28s", "1101101-BVT28s","", {0}}, 1026 {"T28s", "1101101-BVT28s","", {0}},
1026 {"R320s" , "1101201-BV R320s","", {0}}, 1027 {"R320s" , "1101201-BV R320s","", {0}},
1027 {"R380s", "7100101-BVR380s" ,"", {0}}, 1028 {"R380s", "7100101-BVR380s" ,"", {0}},
1028 {"R520m", "1130101-BVR520m" ,"", {0}}, 1029 {"R520m", "1130101-BVR520m" ,"", {0}},
1029 {"T39m", "1130102-BVT39m" ,"", {0}}, 1030 {"T39m", "1130102-BVT39m" ,"", {0}},
1030 {"T65", "1101901-BVT65" , "", {0}}, 1031 {"T65", "1101901-BVT65" , "", {0}},
1031 {"T68", "1130201-BVT68" , "", {0}}, 1032 {"T68", "1130201-BVT68" , "", {0}},
1032 {"T68i", "1130202-BVT68" , "", {0}}, 1033 {"T68i", "1130202-BVT68" , "", {0}},
1033 {"R600", "102001-BVR600" , "", {0}}, 1034 {"R600", "102001-BVR600" , "", {0}},
1034 {"T200", "1130501-BVT200" ,"", {0}}, 1035 {"T200", "1130501-BVT200" ,"", {0}},
1035 {"T300", "1130601-BVT300" ,"T300", {0}}, 1036 {"T300", "1130601-BVT300" ,"T300", {0}},
1036 {"T310", "1130602-BVT310" ,"", {0}}, 1037 {"T310", "1130602-BVT310" ,"", {0}},
1037 {"P800", "7130501-BVP800" ,"", {0}}, 1038 {"P800", "7130501-BVP800" ,"", {0}},
1038 /* Other */ 1039 /* Other */
1039 {"iPAQ" , "iPAQ" , "" , {0}}, 1040 {"iPAQ" , "iPAQ" , "" , {0}},
1040 {"A2D" , "A2D" , "" , {0}}, 1041 {"A2D" , "A2D" , "" , {0}},
1041 {"9210" , "RAE-3", "Nokia Communicator GSM900/1800",{0}}, 1042 {"9210" , "RAE-3", "Nokia Communicator GSM900/1800",{0}},
1042 {"myV-65", "myV-65 GPRS", "", {F_SMSME900,0}}, 1043 {"myV-65", "myV-65 GPRS", "", {F_SMSME900,0}},
1043#endif 1044#endif
1044#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_ALCATEL) 1045#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_ALCATEL)
1045 {"BE5", "ONE TOUCH 500","", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}}, 1046 {"BE5", "ONE TOUCH 500","", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}},
1046 {"BH4", "ONE TOUCH 535","ALCATEL OT535", {F_ALCATEL,F_SMSONLYSENT,0}}, 1047 {"BH4", "ONE TOUCH 535","ALCATEL OT535", {F_ALCATEL,F_SMSONLYSENT,0}},
1047 {"BF5", "ONE TOUCH 715","ALCATEL OT715", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}}, 1048 {"BF5", "ONE TOUCH 715","ALCATEL OT715", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}},
1048#endif 1049#endif
1049 {"unknown", "" ,"", {0}} 1050 {"unknown", "" ,"", {0}}
1050}; 1051};
1051 1052
1052OnePhoneModel *GetModelData(char *model, char *number, char *irdamodel) 1053OnePhoneModel *GetModelData(char *model, char *number, char *irdamodel)
1053{ 1054{
1054 int i = 0; 1055 int i = 0;
1055 1056
1056 while (strcmp(allmodels[i].number,"") != 0) { 1057 while (strcmp(allmodels[i].number,"") != 0) {
1057 if (model !=NULL) { 1058 if (model !=NULL) {
1058 if (strcmp (model, allmodels[i].model) == 0) { 1059 if (strcmp (model, allmodels[i].model) == 0) {
1059 return (&allmodels[i]); 1060 return (&allmodels[i]);
1060 } 1061 }
1061 } 1062 }
1062 if (number !=NULL) { 1063 if (number !=NULL) {
1063 if (strcmp (number, allmodels[i].number) == 0) { 1064 if (strcmp (number, allmodels[i].number) == 0) {
1064 return (&allmodels[i]); 1065 return (&allmodels[i]);
1065 } 1066 }
1066 } 1067 }
1067 if (irdamodel !=NULL) { 1068 if (irdamodel !=NULL) {
1068 if (strcmp (irdamodel, allmodels[i].irdamodel) == 0) { 1069 if (strcmp (irdamodel, allmodels[i].irdamodel) == 0) {
1069 return (&allmodels[i]); 1070 return (&allmodels[i]);
1070 } 1071 }
1071 } 1072 }
1072 i++; 1073 i++;
1073 } 1074 }
1074 return (&allmodels[i]); 1075 return (&allmodels[i]);
1075} 1076}
1076 1077
1077bool IsPhoneFeatureAvailable(OnePhoneModel *model, Feature feature) 1078bool IsPhoneFeatureAvailable(OnePhoneModel *model, Feature feature)
1078{ 1079{
1079 int i= 0; 1080 int i= 0;
1080 boolretval = false; 1081 boolretval = false;
1081 1082
1082 while (model->features[i] != 0) { 1083 while (model->features[i] != 0) {
1083 if (model->features[i] == feature) { 1084 if (model->features[i] == feature) {
1084 retval = true; 1085 retval = true;
1085 break; 1086 break;
1086 } 1087 }
1087 i++; 1088 i++;
1088 } 1089 }
1089 return retval; 1090 return retval;
1090} 1091}
1091 1092
1092void GSM_DumpMessageLevel2(GSM_StateMachine *s, unsigned char *message, int messagesize, int type) 1093void GSM_DumpMessageLevel2(GSM_StateMachine *s, unsigned char *message, int messagesize, int type)
1093{ 1094{
1094 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 1095 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
1095 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 1096 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
1096 smprintf(s,"SENDING frame "); 1097 smprintf(s,"SENDING frame ");
1097 smprintf(s,"type 0x%02X/length 0x%02X/%i", type, messagesize, messagesize); 1098 smprintf(s,"type 0x%02X/length 0x%02X/%i", type, messagesize, messagesize);
1098 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, message, messagesize); 1099 DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, message, messagesize);
1099 if (messagesize == 0) smprintf(s,"\n"); 1100 if (messagesize == 0) smprintf(s,"\n");
1100 if (s->di.df) fflush(s->di.df); 1101 if (s->di.df) fflush(s->di.df);
1101 } 1102 }
1102} 1103}
1103 1104
1104void GSM_DumpMessageLevel3(GSM_StateMachine *s, unsigned char *message, int messagesize, int type) 1105void GSM_DumpMessageLevel3(GSM_StateMachine *s, unsigned char *message, int messagesize, int type)
1105{ 1106{
1106 int i; 1107 int i;
1107 1108
1108 if (s->di.dl==DL_BINARY) { 1109 if (s->di.dl==DL_BINARY) {
1109 smprintf(s,"%c",0x01);/* Sending */ 1110 smprintf(s,"%c",0x01);/* Sending */
1110 smprintf(s,"%c",type); 1111 smprintf(s,"%c",type);
1111 smprintf(s,"%c",messagesize/256); 1112 smprintf(s,"%c",messagesize/256);
1112 smprintf(s,"%c",messagesize%256); 1113 smprintf(s,"%c",messagesize%256);
1113 for (i=0;i<messagesize;i++) smprintf(s,"%c",message[i]); 1114 for (i=0;i<messagesize;i++) smprintf(s,"%c",message[i]);
1114 } 1115 }
1115} 1116}
1116 1117
1117#ifdef __GNUC__ 1118#ifdef __GNUC__
1118__attribute__((format(printf, 2, 3))) 1119__attribute__((format(printf, 2, 3)))
1119#endif 1120#endif
1120int smprintf(GSM_StateMachine *s, const char *format, ...) 1121int smprintf(GSM_StateMachine *s, const char *format, ...)
1121{ 1122{
1122 va_list argp; 1123 va_list argp;
1123 int result=0; 1124 int result=0;
1124 unsigned charbuffer[2000]; 1125 unsigned charbuffer[2000];
1125 Debug_Leveldl; 1126 Debug_Leveldl;
1126 FILE *df; 1127 FILE *df;
1127 1128
1128 va_start(argp, format); 1129 va_start(argp, format);
1129 if (s == NULL) { 1130 if (s == NULL) {
1130 dl = di.dl; 1131 dl = di.dl;
1131 df = di.df; 1132 df = di.df;
1132 } else { 1133 } else {
1133 dl = s->di.dl; 1134 dl = s->di.dl;
1134 if (s->di.use_global) { 1135 if (s->di.use_global) {
1135 df = di.df; 1136 df = di.df;
1136 } else { 1137 } else {
1137 df = s->di.df; 1138 df = s->di.df;
1138 } 1139 }
1139 } 1140 }
1140 1141
1141 if (dl != 0) { 1142 if (dl != 0) {
1142 result = vsprintf(buffer, format, argp); 1143 result = vsprintf(buffer, format, argp);
1143 result = smfprintf(df, dl, "%s", buffer); 1144 result = smfprintf(df, dl, "%s", buffer);
1144 } 1145 }
1145 1146
1146 va_end(argp); 1147 va_end(argp);
1147 return result; 1148 return result;
1148} 1149}
1149 1150
1150void GSM_OSErrorInfo(GSM_StateMachine *s, char *description) 1151void GSM_OSErrorInfo(GSM_StateMachine *s, char *description)
1151{ 1152{
1152#ifdef WIN32 1153#ifdef WIN32
1153 int i; 1154 int i;
1154 unsigned char *lpMsgBuf; 1155 unsigned char *lpMsgBuf;
1155 1156
1156 /* We don't use errno in win32 - GetLastError gives better info */ 1157 /* We don't use errno in win32 - GetLastError gives better info */
1157 if (GetLastError()!=-1) { 1158 if (GetLastError()!=-1) {
1158 if (s->di.dl == DL_TEXTERROR || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTALL || 1159 if (s->di.dl == DL_TEXTERROR || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTALL ||
1159 s->di.dl == DL_TEXTERRORDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTALLDATE) { 1160 s->di.dl == DL_TEXTERRORDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTALLDATE) {
1160 FormatMessage( 1161 FormatMessage(
1161 FORMAT_MESSAGE_ALLOCATE_BUFFER | 1162 FORMAT_MESSAGE_ALLOCATE_BUFFER |
1162 FORMAT_MESSAGE_FROM_SYSTEM | 1163 FORMAT_MESSAGE_FROM_SYSTEM |
1163 FORMAT_MESSAGE_IGNORE_INSERTS, 1164 FORMAT_MESSAGE_IGNORE_INSERTS,
1164 NULL, 1165 NULL,
1165 GetLastError(), 1166 GetLastError(),
1166 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 1167 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
1167 (LPTSTR) &lpMsgBuf, 1168 (LPTSTR) &lpMsgBuf,
1168 0, 1169 0,
1169 NULL 1170 NULL
1170 ); 1171 );
1171 for (i=0;i<(int)strlen(lpMsgBuf);i++) { 1172 for (i=0;i<(int)strlen(lpMsgBuf);i++) {
1172 if (lpMsgBuf[i] == 13 || lpMsgBuf[i] == 10) { 1173 if (lpMsgBuf[i] == 13 || lpMsgBuf[i] == 10) {
1173 lpMsgBuf[i] = ' '; 1174 lpMsgBuf[i] = ' ';
1174 } 1175 }
1175 } 1176 }
1176 smprintf(s,"[System error - %s, %i, \"%s\"]\n",description,GetLastError(),(LPCTSTR)lpMsgBuf); 1177 smprintf(s,"[System error - %s, %i, \"%s\"]\n",description,GetLastError(),(LPCTSTR)lpMsgBuf);
1177 LocalFree(lpMsgBuf); 1178 LocalFree(lpMsgBuf);
1178 } 1179 }
1179 } 1180 }
1180 return; 1181 return;
1181#endif 1182#endif
1182 1183
1183 if (errno!=-1) { 1184 if (errno!=-1) {
1184 if (s->di.dl == DL_TEXTERROR || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTALL || 1185 if (s->di.dl == DL_TEXTERROR || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTALL ||
1185 s->di.dl == DL_TEXTERRORDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTALLDATE) { 1186 s->di.dl == DL_TEXTERRORDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTALLDATE) {
1186 smprintf(s,"[System error - %s, %i, \"%s\"]\n",description,errno,strerror(errno)); 1187 smprintf(s,"[System error - %s, %i, \"%s\"]\n",description,errno,strerror(errno));
1187 } 1188 }
1188 } 1189 }
1189} 1190}
1190 1191
1191#ifdef GSM_ENABLE_BACKUP 1192#ifdef GSM_ENABLE_BACKUP
1192 1193
1193void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info) 1194void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info)
1194{ 1195{
1195 GSM_Error error; 1196 GSM_Error error;
1196 GSM_MemoryStatusMemStatus; 1197 GSM_MemoryStatusMemStatus;
1197 GSM_ToDoStatus ToDoStatus; 1198 GSM_ToDoStatus ToDoStatus;
1198 GSM_CalendarEntry Note; 1199 GSM_CalendarEntry Note;
1199 GSM_WAPBookmark Bookmark; 1200 GSM_WAPBookmark Bookmark;
1200 GSM_MultiWAPSettingsWAPSettings; 1201 GSM_MultiWAPSettingsWAPSettings;
1201 GSM_FMStation FMStation; 1202 GSM_FMStation FMStation;
1202 GSM_GPRSAccessPointGPRSPoint; 1203 GSM_GPRSAccessPointGPRSPoint;
1203 // GSM_Profile Profile; 1204 // GSM_Profile Profile;
1204 1205
1205 if (info->PhonePhonebook) { 1206 if (info->PhonePhonebook) {
1206 MemStatus.MemoryType = MEM_ME; 1207 MemStatus.MemoryType = MEM_ME;
1207 error=s->Phone.Functions->GetMemoryStatus(s, &MemStatus); 1208 error=s->Phone.Functions->GetMemoryStatus(s, &MemStatus);
1208 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { 1209 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
1209 } else { 1210 } else {
1210 info->PhonePhonebook = false; 1211 info->PhonePhonebook = false;
1211 } 1212 }
1212 } 1213 }
1213 if (info->SIMPhonebook) { 1214 if (info->SIMPhonebook) {
1214 MemStatus.MemoryType = MEM_SM; 1215 MemStatus.MemoryType = MEM_SM;
1215 error=s->Phone.Functions->GetMemoryStatus(s, &MemStatus); 1216 error=s->Phone.Functions->GetMemoryStatus(s, &MemStatus);
1216 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { 1217 if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
1217 } else { 1218 } else {
1218 info->SIMPhonebook = false; 1219 info->SIMPhonebook = false;
1219 } 1220 }
1220 } 1221 }
1221 if (info->Calendar) { 1222 if (info->Calendar) {
1222 error=s->Phone.Functions->GetNextCalendar(s,&Note,true); 1223 error=s->Phone.Functions->GetNextCalendar(s,&Note,true);
1223 if (error!=ERR_NONE) info->Calendar = false; 1224 if (error!=ERR_NONE) info->Calendar = false;
1224 } 1225 }
1225 if (info->ToDo) { 1226 if (info->ToDo) {
1226 error=s->Phone.Functions->GetToDoStatus(s,&ToDoStatus); 1227 error=s->Phone.Functions->GetToDoStatus(s,&ToDoStatus);
1227 if (error == ERR_NONE && ToDoStatus.Used != 0) { 1228 if (error == ERR_NONE && ToDoStatus.Used != 0) {
1228 } else { 1229 } else {
1229 info->ToDo = false; 1230 info->ToDo = false;
1230 } 1231 }
1231 } 1232 }
1232 if (info->WAPBookmark) { 1233 if (info->WAPBookmark) {
1233 Bookmark.Location = 1; 1234 Bookmark.Location = 1;
1234 error=s->Phone.Functions->GetWAPBookmark(s,&Bookmark); 1235 error=s->Phone.Functions->GetWAPBookmark(s,&Bookmark);
1235 if (error == ERR_NONE) { 1236 if (error == ERR_NONE) {
1236 } else { 1237 } else {
1237 info->WAPBookmark = false; 1238 info->WAPBookmark = false;
1238 } 1239 }
1239 } 1240 }
1240 if (info->WAPSettings) { 1241 if (info->WAPSettings) {
1241 WAPSettings.Location = 1; 1242 WAPSettings.Location = 1;
1242 error=s->Phone.Functions->GetWAPSettings(s,&WAPSettings); 1243 error=s->Phone.Functions->GetWAPSettings(s,&WAPSettings);
1243 if (error == ERR_NONE) { 1244 if (error == ERR_NONE) {
1244 } else { 1245 } else {
1245 info->WAPSettings = false; 1246 info->WAPSettings = false;
1246 } 1247 }
1247 } 1248 }
1248 if (info->MMSSettings) { 1249 if (info->MMSSettings) {
1249 WAPSettings.Location = 1; 1250 WAPSettings.Location = 1;
1250 error=s->Phone.Functions->GetMMSSettings(s,&WAPSettings); 1251 error=s->Phone.Functions->GetMMSSettings(s,&WAPSettings);
1251 if (error == ERR_NONE) { 1252 if (error == ERR_NONE) {
1252 } else { 1253 } else {
1253 info->WAPSettings = false; 1254 info->WAPSettings = false;
1254 } 1255 }
1255 } 1256 }
1256 if (info->FMStation) { 1257 if (info->FMStation) {
1257 FMStation.Location = 1; 1258 FMStation.Location = 1;
1258 error = s->Phone.Functions->GetFMStation(s,&FMStation); 1259 error = s->Phone.Functions->GetFMStation(s,&FMStation);
1259 if (error == ERR_NONE || error == ERR_EMPTY) { 1260 if (error == ERR_NONE || error == ERR_EMPTY) {
1260 } else { 1261 } else {
1261 info->FMStation = false; 1262 info->FMStation = false;
1262 } 1263 }
1263 } 1264 }
1264 if (info->GPRSPoint) { 1265 if (info->GPRSPoint) {
1265 GPRSPoint.Location = 1; 1266 GPRSPoint.Location = 1;
1266 error = s->Phone.Functions->GetGPRSAccessPoint(s,&GPRSPoint); 1267 error = s->Phone.Functions->GetGPRSAccessPoint(s,&GPRSPoint);
1267 if (error == ERR_NONE || error == ERR_EMPTY) { 1268 if (error == ERR_NONE || error == ERR_EMPTY) {
1268 } else { 1269 } else {
1269 info->GPRSPoint = false; 1270 info->GPRSPoint = false;
1270 } 1271 }
1271 } 1272 }
1272} 1273}
1273 1274
1274#endif 1275#endif
1275 1276
1276/* How should editor hadle tabs in this file? Add editor commands here. 1277/* How should editor hadle tabs in this file? Add editor commands here.
1277 * vim: noexpandtab sw=8 ts=8 sts=8: 1278 * vim: noexpandtab sw=8 ts=8 sts=8:
1278 */ 1279 */
diff --git a/gammu/emb/common/gsmstate.h b/gammu/emb/common/gsmstate.h
index 2b4806c..6861fbc 100644
--- a/gammu/emb/common/gsmstate.h
+++ b/gammu/emb/common/gsmstate.h
@@ -1,764 +1,765 @@
1/* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */
2 2
3#ifndef __gsm_state_h 3#ifndef __gsm_state_h
4#define __gsm_state_h 4#define __gsm_state_h
5 5
6#include <time.h> 6#include <time.h>
7 7
8#include "config.h" 8#include "config.h"
9#include "misc/cfg.h" 9#include "misc/cfg.h"
10 10
11 typedef struct _GSM_StateMachine GSM_StateMachine; 11 typedef struct _GSM_StateMachine GSM_StateMachine;
12 typedef struct _GSM_User GSM_User; 12 typedef struct _GSM_User GSM_User;
13 typedef struct _OnePhoneModel OnePhoneModel; 13 typedef struct _OnePhoneModel OnePhoneModel;
14 typedef struct _GSM_Reply_FunctionGSM_Reply_Function; 14 typedef struct _GSM_Reply_FunctionGSM_Reply_Function;
15 15
16#ifdef GSM_ENABLE_NOKIA3320 16#ifdef GSM_ENABLE_NOKIA3320
17# include "phone/nokia/dct4/n3320.h" 17# include "phone/nokia/dct4/n3320.h"
18#endif 18#endif
19#ifdef GSM_ENABLE_NOKIA3650 19#ifdef GSM_ENABLE_NOKIA3650
20# include "phone/nokia/dct4/n3650.h" 20# include "phone/nokia/dct4/n3650.h"
21#endif 21#endif
22#ifdef GSM_ENABLE_NOKIA650 22#ifdef GSM_ENABLE_NOKIA650
23# include "phone/nokia/dct3/n0650.h" 23# include "phone/nokia/dct3/n0650.h"
24#endif 24#endif
25#ifdef GSM_ENABLE_NOKIA6110 25#ifdef GSM_ENABLE_NOKIA6110
26# include "phone/nokia/dct3/n6110.h" 26# include "phone/nokia/dct3/n6110.h"
27#endif 27#endif
28#ifdef GSM_ENABLE_NOKIA6510 28#ifdef GSM_ENABLE_NOKIA6510
29# include "phone/nokia/dct4/n6510.h" 29# include "phone/nokia/dct4/n6510.h"
30#endif 30#endif
31#ifdef GSM_ENABLE_NOKIA7110 31#ifdef GSM_ENABLE_NOKIA7110
32# include "phone/nokia/dct3/n7110.h" 32# include "phone/nokia/dct3/n7110.h"
33#endif 33#endif
34#ifdef GSM_ENABLE_NOKIA9210 34#ifdef GSM_ENABLE_NOKIA9210
35# include "phone/nokia/dct3/n9210.h" 35# include "phone/nokia/dct3/n9210.h"
36#endif 36#endif
37#ifdef GSM_ENABLE_ATGEN 37#ifdef GSM_ENABLE_ATGEN
38# include "phone/at/atgen.h" 38# include "phone/at/atgen.h"
39#endif 39#endif
40#ifdef GSM_ENABLE_ALCATEL 40#ifdef GSM_ENABLE_ALCATEL
41# include "phone/alcatel/alcatel.h" 41# include "phone/alcatel/alcatel.h"
42#endif 42#endif
43#ifdef GSM_ENABLE_OBEXGEN 43#ifdef GSM_ENABLE_OBEXGEN
44# include "phone/obex/obexgen.h" 44# include "phone/obex/obexgen.h"
45#endif 45#endif
46#ifdef GSM_ENABLE_MROUTERGEN 46#ifdef GSM_ENABLE_MROUTERGEN
47# include "phone/symbian/mroutgen.h" 47# include "phone/symbian/mroutgen.h"
48#endif 48#endif
49 49
50#ifndef GSM_USED_MBUS2 50#ifndef GSM_USED_MBUS2
51# undef GSM_ENABLE_MBUS2 51# undef GSM_ENABLE_MBUS2
52#endif 52#endif
53#ifndef GSM_USED_FBUS2 53#ifndef GSM_USED_FBUS2
54# undef GSM_ENABLE_FBUS2 54# undef GSM_ENABLE_FBUS2
55#endif 55#endif
56#ifndef GSM_USED_FBUS2DLR3 56#ifndef GSM_USED_FBUS2DLR3
57# undef GSM_ENABLE_FBUS2DLR3 57# undef GSM_ENABLE_FBUS2DLR3
58#endif 58#endif
59#ifndef GSM_USED_FBUS2DKU5 59#ifndef GSM_USED_FBUS2DKU5
60# undef GSM_ENABLE_FBUS2DKU5 60# undef GSM_ENABLE_FBUS2DKU5
61#endif 61#endif
62#ifndef GSM_USED_FBUS2PL2303 62#ifndef GSM_USED_FBUS2PL2303
63# undef GSM_ENABLE_FBUS2PL2303 63# undef GSM_ENABLE_FBUS2PL2303
64#endif 64#endif
65#ifndef GSM_USED_FBUS2BLUE 65#ifndef GSM_USED_FBUS2BLUE
66# undef GSM_ENABLE_FBUS2BLUE 66# undef GSM_ENABLE_FBUS2BLUE
67#endif 67#endif
68#ifndef GSM_USED_FBUS2IRDA 68#ifndef GSM_USED_FBUS2IRDA
69# undef GSM_ENABLE_FBUS2IRDA 69# undef GSM_ENABLE_FBUS2IRDA
70#endif 70#endif
71#ifndef GSM_USED_PHONETBLUE 71#ifndef GSM_USED_PHONETBLUE
72# undef GSM_ENABLE_PHONETBLUE 72# undef GSM_ENABLE_PHONETBLUE
73#endif 73#endif
74#ifndef GSM_USED_AT 74#ifndef GSM_USED_AT
75# undef GSM_ENABLE_AT 75# undef GSM_ENABLE_AT
76#endif 76#endif
77#ifndef GSM_USED_IRDAOBEX 77#ifndef GSM_USED_IRDAOBEX
78# undef GSM_ENABLE_IRDAOBEX 78# undef GSM_ENABLE_IRDAOBEX
79#endif 79#endif
80#ifndef GSM_USED_BLUEOBEX 80#ifndef GSM_USED_BLUEOBEX
81# undef GSM_ENABLE_BLUEOBEX 81# undef GSM_ENABLE_BLUEOBEX
82#endif 82#endif
83#ifndef GSM_USED_ALCABUS 83#ifndef GSM_USED_ALCABUS
84# undef GSM_ENABLE_ALCABUS 84# undef GSM_ENABLE_ALCABUS
85#endif 85#endif
86#ifndef GSM_USED_IRDAPHONET 86#ifndef GSM_USED_IRDAPHONET
87# undef GSM_ENABLE_IRDAPHONET 87# undef GSM_ENABLE_IRDAPHONET
88#endif 88#endif
89#ifndef GSM_USED_BLUEFBUS2 89#ifndef GSM_USED_BLUEFBUS2
90# undef GSM_ENABLE_BLUEFBUS2 90# undef GSM_ENABLE_BLUEFBUS2
91#endif 91#endif
92#ifndef GSM_USED_BLUEPHONET 92#ifndef GSM_USED_BLUEPHONET
93# undef GSM_ENABLE_BLUEPHONET 93# undef GSM_ENABLE_BLUEPHONET
94#endif 94#endif
95#ifndef GSM_USED_BLUEAT 95#ifndef GSM_USED_BLUEAT
96# undef GSM_ENABLE_BLUEAT 96# undef GSM_ENABLE_BLUEAT
97#endif 97#endif
98#ifndef GSM_USED_IRDAAT 98#ifndef GSM_USED_IRDAAT
99# undef GSM_ENABLE_IRDAAT 99# undef GSM_ENABLE_IRDAAT
100#endif 100#endif
101#ifndef GSM_USED_MROUTERBLUE 101#ifndef GSM_USED_MROUTERBLUE
102# undef GSM_ENABLE_MROUTERBLUE 102# undef GSM_ENABLE_MROUTERBLUE
103#endif 103#endif
104 104
105#if defined(GSM_ENABLE_NOKIA3320) || defined(GSM_ENABLE_NOKIA650) || defined(GSM_ENABLE_NOKIA6110) || defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210) 105#if defined(GSM_ENABLE_NOKIA3320) || defined(GSM_ENABLE_NOKIA650) || defined(GSM_ENABLE_NOKIA6110) || defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
106# define GSM_ENABLE_NOKIA_DCT3 106# define GSM_ENABLE_NOKIA_DCT3
107#endif 107#endif
108#if defined(GSM_ENABLE_NOKIA3650) || defined(GSM_ENABLE_NOKIA6510) 108#if defined(GSM_ENABLE_NOKIA3650) || defined(GSM_ENABLE_NOKIA6510)
109# define GSM_ENABLE_NOKIA_DCT4 109# define GSM_ENABLE_NOKIA_DCT4
110#endif 110#endif
111 111
112#include "protocol/protocol.h" 112#include "protocol/protocol.h"
113#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) 113#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303)
114# include "protocol/nokia/fbus2.h" 114# include "protocol/nokia/fbus2.h"
115#endif 115#endif
116#ifdef GSM_ENABLE_MBUS2 116#ifdef GSM_ENABLE_MBUS2
117# include "protocol/nokia/mbus2.h" 117# include "protocol/nokia/mbus2.h"
118#endif 118#endif
119#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) 119#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET)
120# include "protocol/nokia/phonet.h" 120# include "protocol/nokia/phonet.h"
121#endif 121#endif
122#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) 122#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT)
123# include "protocol/at/at.h" 123# include "protocol/at/at.h"
124#endif 124#endif
125#ifdef GSM_ENABLE_ALCABUS 125#ifdef GSM_ENABLE_ALCABUS
126# include "protocol/alcatel/alcabus.h" 126# include "protocol/alcatel/alcabus.h"
127#endif 127#endif
128#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) 128#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX)
129# include "protocol/obex/obex.h" 129# include "protocol/obex/obex.h"
130#endif 130#endif
131#if defined(GSM_ENABLE_MROUTERBLUE) 131#if defined(GSM_ENABLE_MROUTERBLUE)
132# include "protocol/symbian/mrouter.h" 132# include "protocol/symbian/mrouter.h"
133#endif 133#endif
134 134
135#define GSM_ENABLE_SERIALDEVICE 135#define GSM_ENABLE_SERIALDEVICE
136#ifndef GSM_USED_SERIALDEVICE 136#ifndef GSM_USED_SERIALDEVICE
137# undef GSM_ENABLE_SERIALDEVICE 137# undef GSM_ENABLE_SERIALDEVICE
138#endif 138#endif
139#define GSM_ENABLE_IRDADEVICE 139#define GSM_ENABLE_IRDADEVICE
140#ifndef GSM_USED_IRDADEVICE 140#ifndef GSM_USED_IRDADEVICE
141# undef GSM_ENABLE_IRDADEVICE 141# undef GSM_ENABLE_IRDADEVICE
142#endif 142#endif
143#define GSM_ENABLE_BLUETOOTHDEVICE 143#define GSM_ENABLE_BLUETOOTHDEVICE
144#ifndef GSM_USED_BLUETOOTHDEVICE 144#ifndef GSM_USED_BLUETOOTHDEVICE
145# undef GSM_ENABLE_BLUETOOTHDEVICE 145# undef GSM_ENABLE_BLUETOOTHDEVICE
146#endif 146#endif
147 147
148#ifdef DJGPP 148#ifdef DJGPP
149# undef GSM_ENABLE_IRDADEVICE 149# undef GSM_ENABLE_IRDADEVICE
150# undef GSM_ENABLE_IRDAPHONET 150# undef GSM_ENABLE_IRDAPHONET
151# undef GSM_ENABLE_IRDAOBEX 151# undef GSM_ENABLE_IRDAOBEX
152# undef GSM_ENABLE_IRDAAT 152# undef GSM_ENABLE_IRDAAT
153# undef GSM_ENABLE_FBUS2IRDA 153# undef GSM_ENABLE_FBUS2IRDA
154 154
155# undef GSM_ENABLE_BLUETOOTHDEVICE 155# undef GSM_ENABLE_BLUETOOTHDEVICE
156# undef GSM_ENABLE_BLUEPHONET 156# undef GSM_ENABLE_BLUEPHONET
157# undef GSM_ENABLE_BLUEOBEX 157# undef GSM_ENABLE_BLUEOBEX
158# undef GSM_ENABLE_BLUEAT 158# undef GSM_ENABLE_BLUEAT
159# undef GSM_ENABLE_BLUEFBUS2 159# undef GSM_ENABLE_BLUEFBUS2
160# undef GSM_ENABLE_PHONETBLUE 160# undef GSM_ENABLE_PHONETBLUE
161# undef GSM_ENABLE_FBUS2BLUE 161# undef GSM_ENABLE_FBUS2BLUE
162# undef GSM_ENABLE_MROUTERBLUE 162# undef GSM_ENABLE_MROUTERBLUE
163#endif 163#endif
164 164
165#ifndef WIN32 165#ifndef WIN32
166# ifdef ENABLE_LGPL 166# ifdef ENABLE_LGPL
167# undef GSM_ENABLE_IRDADEVICE 167# undef GSM_ENABLE_IRDADEVICE
168# undef GSM_ENABLE_IRDAPHONET 168# undef GSM_ENABLE_IRDAPHONET
169# undef GSM_ENABLE_IRDAOBEX 169# undef GSM_ENABLE_IRDAOBEX
170# undef GSM_ENABLE_IRDAAT 170# undef GSM_ENABLE_IRDAAT
171# undef GSM_ENABLE_FBUS2IRDA 171# undef GSM_ENABLE_FBUS2IRDA
172 172
173# undef GSM_ENABLE_BLUETOOTHDEVICE 173# undef GSM_ENABLE_BLUETOOTHDEVICE
174# undef GSM_ENABLE_BLUEPHONET 174# undef GSM_ENABLE_BLUEPHONET
175# undef GSM_ENABLE_BLUEOBEX 175# undef GSM_ENABLE_BLUEOBEX
176# undef GSM_ENABLE_BLUEAT 176# undef GSM_ENABLE_BLUEAT
177# undef GSM_ENABLE_BLUEFBUS2 177# undef GSM_ENABLE_BLUEFBUS2
178# undef GSM_ENABLE_PHONETBLUE 178# undef GSM_ENABLE_PHONETBLUE
179# undef GSM_ENABLE_FBUS2BLUE 179# undef GSM_ENABLE_FBUS2BLUE
180# undef GSM_ENABLE_MROUTERBLUE 180# undef GSM_ENABLE_MROUTERBLUE
181# endif 181# endif
182#endif 182#endif
183 183
184#ifdef GSM_ENABLE_SERIALDEVICE 184#ifdef GSM_ENABLE_SERIALDEVICE
185# include "device/serial/ser_w32.h" 185# include "device/serial/ser_w32.h"
186# include "device/serial/ser_unx.h" 186# include "device/serial/ser_unx.h"
187# include "device/serial/ser_djg.h" 187# include "device/serial/ser_djg.h"
188#endif 188#endif
189#ifdef GSM_ENABLE_IRDADEVICE 189#ifdef GSM_ENABLE_IRDADEVICE
190# include "device/irda/irda.h" 190# include "device/irda/irda.h"
191#endif 191#endif
192#ifdef GSM_ENABLE_BLUETOOTHDEVICE 192#ifdef GSM_ENABLE_BLUETOOTHDEVICE
193# include "device/bluetoth/bluetoth.h" 193# include "device/bluetoth/bluetoth.h"
194#endif 194#endif
195 195
196#include "service/gsmpbk.h" 196#include "service/gsmpbk.h"
197#include "service/gsmnet.h" 197#include "service/gsmnet.h"
198#include "service/gsmring.h" 198#include "service/gsmring.h"
199#include "service/gsmcal.h" 199#include "service/gsmcal.h"
200#include "service/gsmdata.h" 200#include "service/gsmdata.h"
201#include "service/gsmlogo.h" 201#include "service/gsmlogo.h"
202#include "service/gsmmisc.h" 202#include "service/gsmmisc.h"
203#include "service/gsmprof.h" 203#include "service/gsmprof.h"
204#include "service/gsmcall.h" 204#include "service/gsmcall.h"
205#include "service/sms/gsmsms.h" 205#include "service/sms/gsmsms.h"
206#include "service/sms/gsmems.h" 206#include "service/sms/gsmems.h"
207#include "service/sms/gsmmulti.h" 207#include "service/sms/gsmmulti.h"
208#include "service/backup/gsmback.h" 208#include "service/backup/gsmback.h"
209 209
210 210
211/* ------------------------- Device layer ---------------------------------- */ 211/* ------------------------- Device layer ---------------------------------- */
212 212
213/** 213/**
214 * Device functions, each device has to provide these. 214 * Device functions, each device has to provide these.
215 */ 215 */
216typedef struct { 216typedef struct {
217 /** 217 /**
218 * Opens device. 218 * Opens device.
219 */ 219 */
220 GSM_Error (*OpenDevice) (GSM_StateMachine *s); 220 GSM_Error (*OpenDevice) (GSM_StateMachine *s);
221 /** 221 /**
222 * Closes device. 222 * Closes device.
223 */ 223 */
224 GSM_Error (*CloseDevice) (GSM_StateMachine *s); 224 GSM_Error (*CloseDevice) (GSM_StateMachine *s);
225 /** 225 /**
226 * Sets parity for device. 226 * Sets parity for device.
227 */ 227 */
228 GSM_Error (*DeviceSetParity) (GSM_StateMachine *s, bool parity); 228 GSM_Error (*DeviceSetParity) (GSM_StateMachine *s, bool parity);
229 /** 229 /**
230 * Sets dtr (data to read) and rts (ready to send) flags. 230 * Sets dtr (data to read) and rts (ready to send) flags.
231 */ 231 */
232 GSM_Error (*DeviceSetDtrRts) (GSM_StateMachine *s, bool dtr, bool rts); 232 GSM_Error (*DeviceSetDtrRts) (GSM_StateMachine *s, bool dtr, bool rts);
233 /** 233 /**
234 * Sets device speed. 234 * Sets device speed.
235 */ 235 */
236 GSM_Error (*DeviceSetSpeed) (GSM_StateMachine *s, int speed); 236 GSM_Error (*DeviceSetSpeed) (GSM_StateMachine *s, int speed);
237 /** 237 /**
238 * Attempts to read nbytes from device. 238 * Attempts to read nbytes from device.
239 */ 239 */
240 int (*ReadDevice) (GSM_StateMachine *s, void *buf, size_t nbytes); 240 int (*ReadDevice) (GSM_StateMachine *s, void *buf, size_t nbytes);
241 /** 241 /**
242 * Attempts to read nbytes from device. 242 * Attempts to read nbytes from device.
243 */ 243 */
244 int (*WriteDevice) (GSM_StateMachine *s, void *buf, size_t nbytes); 244 int (*WriteDevice) (GSM_StateMachine *s, void *buf, size_t nbytes);
245} GSM_Device_Functions; 245} GSM_Device_Functions;
246 246
247#ifdef GSM_ENABLE_SERIALDEVICE 247#ifdef GSM_ENABLE_SERIALDEVICE
248 extern GSM_Device_Functions SerialDevice; 248 extern GSM_Device_Functions SerialDevice;
249#endif 249#endif
250#ifdef GSM_ENABLE_IRDADEVICE 250#ifdef GSM_ENABLE_IRDADEVICE
251 extern GSM_Device_Functions IrdaDevice; 251 extern GSM_Device_Functions IrdaDevice;
252#endif 252#endif
253#ifdef GSM_ENABLE_BLUETOOTHDEVICE 253#ifdef GSM_ENABLE_BLUETOOTHDEVICE
254 extern GSM_Device_Functions BlueToothDevice; 254 extern GSM_Device_Functions BlueToothDevice;
255#endif 255#endif
256 256
257/** 257/**
258 * Structure containing device specific data and pointer to device functions - 258 * Structure containing device specific data and pointer to device functions -
259 * @ref GSM_Device_Functions. The data are in a union, so you can use only 259 * @ref GSM_Device_Functions. The data are in a union, so you can use only
260 * one device at one time. 260 * one device at one time.
261 */ 261 */
262typedef struct { 262typedef struct {
263 union { 263 union {
264 char fake; 264 char fake;
265#ifdef GSM_ENABLE_SERIALDEVICE 265#ifdef GSM_ENABLE_SERIALDEVICE
266 GSM_Device_SerialData Serial; 266 GSM_Device_SerialData Serial;
267#endif 267#endif
268#ifdef GSM_ENABLE_IRDADEVICE 268#ifdef GSM_ENABLE_IRDADEVICE
269 GSM_Device_IrdaData Irda; 269 GSM_Device_IrdaData Irda;
270#endif 270#endif
271#ifdef GSM_ENABLE_BLUETOOTHDEVICE 271#ifdef GSM_ENABLE_BLUETOOTHDEVICE
272 GSM_Device_BlueToothDataBlueTooth; 272 GSM_Device_BlueToothDataBlueTooth;
273#endif 273#endif
274 } Data; 274 } Data;
275 GSM_Device_Functions *Functions; 275 GSM_Device_Functions *Functions;
276} GSM_Device; 276} GSM_Device;
277 277
278/* ---------------------- Protocol layer ----------------------------------- */ 278/* ---------------------- Protocol layer ----------------------------------- */
279 279
280/** 280/**
281 * Protocol functions, each protocol has to implement these. 281 * Protocol functions, each protocol has to implement these.
282 */ 282 */
283typedef struct { 283typedef struct {
284 /** 284 /**
285 * Writes message to device. 285 * Writes message to device.
286 */ 286 */
287 GSM_Error (*WriteMessage) (GSM_StateMachine *s, unsigned char *buffer, 287 GSM_Error (*WriteMessage) (GSM_StateMachine *s, unsigned char *buffer,
288 int length, unsigned char type); 288 int length, unsigned char type);
289 /** 289 /**
290 * This one is called when character is received from device. 290 * This one is called when character is received from device.
291 */ 291 */
292 GSM_Error (*StateMachine) (GSM_StateMachine *s, unsigned char rx_char); 292 GSM_Error (*StateMachine) (GSM_StateMachine *s, unsigned char rx_char);
293 /** 293 /**
294 * Protocol initialisation. 294 * Protocol initialisation.
295 */ 295 */
296 GSM_Error (*Initialise) (GSM_StateMachine *s); 296 GSM_Error (*Initialise) (GSM_StateMachine *s);
297 /** 297 /**
298 * Protocol termination. 298 * Protocol termination.
299 */ 299 */
300 GSM_Error (*Terminate) (GSM_StateMachine *s); 300 GSM_Error (*Terminate) (GSM_StateMachine *s);
301} GSM_Protocol_Functions; 301} GSM_Protocol_Functions;
302 302
303#ifdef GSM_ENABLE_MBUS2 303#ifdef GSM_ENABLE_MBUS2
304 extern GSM_Protocol_Functions MBUS2Protocol; 304 extern GSM_Protocol_Functions MBUS2Protocol;
305#endif 305#endif
306#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 306#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303)
307 extern GSM_Protocol_Functions FBUS2Protocol; 307 extern GSM_Protocol_Functions FBUS2Protocol;
308#endif 308#endif
309#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) 309#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET)
310 extern GSM_Protocol_Functions PHONETProtocol; 310 extern GSM_Protocol_Functions PHONETProtocol;
311#endif 311#endif
312#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) 312#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT)
313 extern GSM_Protocol_Functions ATProtocol; 313 extern GSM_Protocol_Functions ATProtocol;
314#endif 314#endif
315#ifdef GSM_ENABLE_ALCABUS 315#ifdef GSM_ENABLE_ALCABUS
316 extern GSM_Protocol_Functions ALCABUSProtocol; 316 extern GSM_Protocol_Functions ALCABUSProtocol;
317#endif 317#endif
318#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) 318#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX)
319 extern GSM_Protocol_Functions OBEXProtocol; 319 extern GSM_Protocol_Functions OBEXProtocol;
320#endif 320#endif
321#if defined(GSM_ENABLE_MROUTERBLUE) 321#if defined(GSM_ENABLE_MROUTERBLUE)
322 extern GSM_Protocol_Functions MROUTERProtocol; 322 extern GSM_Protocol_Functions MROUTERProtocol;
323#endif 323#endif
324 324
325/** 325/**
326 * Structure containing protocol specific data and pointer to protocol 326 * Structure containing protocol specific data and pointer to protocol
327 * functions - @ref GSM_Protocol_Functions. The data are in a structure, so 327 * functions - @ref GSM_Protocol_Functions. The data are in a structure, so
328 * you may use more protocols at once and switch between them. 328 * you may use more protocols at once and switch between them.
329 */ 329 */
330typedef struct { 330typedef struct {
331 struct { 331 struct {
332 char fake; 332 char fake;
333#ifdef GSM_ENABLE_MBUS2 333#ifdef GSM_ENABLE_MBUS2
334 GSM_Protocol_MBUS2Data MBUS2; 334 GSM_Protocol_MBUS2Data MBUS2;
335#endif 335#endif
336#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) 336#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2)
337 GSM_Protocol_FBUS2Data FBUS2; 337 GSM_Protocol_FBUS2Data FBUS2;
338#endif 338#endif
339#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) 339#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET)
340 GSM_Protocol_PHONETData PHONET; 340 GSM_Protocol_PHONETData PHONET;
341#endif 341#endif
342#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) 342#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT)
343 GSM_Protocol_ATData AT; 343 GSM_Protocol_ATData AT;
344#endif 344#endif
345#ifdef GSM_ENABLE_ALCABUS 345#ifdef GSM_ENABLE_ALCABUS
346 GSM_Protocol_ALCABUSDataALCABUS; 346 GSM_Protocol_ALCABUSDataALCABUS;
347#endif 347#endif
348#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) 348#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX)
349 GSM_Protocol_OBEXData OBEX; 349 GSM_Protocol_OBEXData OBEX;
350#endif 350#endif
351#if defined(GSM_ENABLE_MROUTERBLUE) 351#if defined(GSM_ENABLE_MROUTERBLUE)
352 GSM_Protocol_MROUTERDataMROUTER; 352 GSM_Protocol_MROUTERDataMROUTER;
353#endif 353#endif
354 } Data; 354 } Data;
355 GSM_Protocol_Functions *Functions; 355 GSM_Protocol_Functions *Functions;
356} GSM_Protocol; 356} GSM_Protocol;
357 357
358/* -------------------------- Phone layer ---------------------------------- */ 358/* -------------------------- Phone layer ---------------------------------- */
359 359
360/** 360/**
361 * Phone requests identificators, these are used for internally identifying 361 * Phone requests identificators, these are used for internally identifying
362 * which operation is being performed. 362 * which operation is being performed.
363 */ 363 */
364typedef enum { 364typedef enum {
365 ID_None=1, 365 ID_None=1,
366 ID_GetModel, 366 ID_GetModel,
367 ID_GetFirmware, 367 ID_GetFirmware,
368 ID_EnableSecurity, 368 ID_EnableSecurity,
369 ID_GetIMEI, 369 ID_GetIMEI,
370 ID_GetDateTime, 370 ID_GetDateTime,
371 ID_GetAlarm, 371 ID_GetAlarm,
372 ID_GetMemory, 372 ID_GetMemory,
373 ID_GetMemoryStatus, 373 ID_GetMemoryStatus,
374 ID_GetSMSC, 374 ID_GetSMSC,
375 ID_GetSMSMessage, 375 ID_GetSMSMessage,
376 ID_EnableEcho, 376 ID_EnableEcho,
377 ID_EnableErrorInfo, 377 ID_EnableErrorInfo,
378 ID_SetOBEX, 378 ID_SetOBEX,
379 ID_SetUSSD, 379 ID_SetUSSD,
380 ID_GetNote, 380 ID_GetNote,
381 ID_SetNote,
381 ID_GetSignalQuality, 382 ID_GetSignalQuality,
382 ID_GetBatteryCharge, 383 ID_GetBatteryCharge,
383 ID_GetSMSFolders, 384 ID_GetSMSFolders,
384 ID_GetSMSFolderStatus, 385 ID_GetSMSFolderStatus,
385 ID_GetSMSStatus, 386 ID_GetSMSStatus,
386 ID_AddSMSFolder, 387 ID_AddSMSFolder,
387 ID_GetNetworkInfo, 388 ID_GetNetworkInfo,
388 ID_GetRingtone, 389 ID_GetRingtone,
389 ID_DialVoice, 390 ID_DialVoice,
390 ID_GetCalendarNotesInfo, 391 ID_GetCalendarNotesInfo,
391 ID_GetCalendarNote, 392 ID_GetCalendarNote,
392 ID_GetSecurityCode, 393 ID_GetSecurityCode,
393 ID_GetWAPBookmark, 394 ID_GetWAPBookmark,
394 ID_GetBitmap, 395 ID_GetBitmap,
395 ID_SaveSMSMessage, 396 ID_SaveSMSMessage,
396 ID_CancelCall, 397 ID_CancelCall,
397 ID_SetDateTime, 398 ID_SetDateTime,
398 ID_SetAlarm, 399 ID_SetAlarm,
399 ID_DisableConnectFunc, 400 ID_DisableConnectFunc,
400 ID_EnableConnectFunc, 401 ID_EnableConnectFunc,
401 ID_AnswerCall, 402 ID_AnswerCall,
402 ID_SetBitmap, 403 ID_SetBitmap,
403 ID_SetRingtone, 404 ID_SetRingtone,
404 ID_DeleteSMSMessage, 405 ID_DeleteSMSMessage,
405 ID_DeleteCalendarNote, 406 ID_DeleteCalendarNote,
406 ID_SetPath, 407 ID_SetPath,
407 ID_SetSMSC, 408 ID_SetSMSC,
408 ID_SetProfile, 409 ID_SetProfile,
409 ID_SetMemory, 410 ID_SetMemory,
410 ID_DeleteMemory, 411 ID_DeleteMemory,
411 ID_SetCalendarNote, 412 ID_SetCalendarNote,
412 ID_SetIncomingSMS, 413 ID_SetIncomingSMS,
413 ID_SetIncomingCB, 414 ID_SetIncomingCB,
414 ID_GetCalendarNotePos, 415 ID_GetCalendarNotePos,
415 ID_Initialise, 416 ID_Initialise,
416 ID_GetConnectSet, 417 ID_GetConnectSet,
417 ID_SetWAPBookmark, 418 ID_SetWAPBookmark,
418 ID_GetLocale, 419 ID_GetLocale,
419 ID_SetLocale, 420 ID_SetLocale,
420 ID_GetCalendarSettings, 421 ID_GetCalendarSettings,
421 ID_SetCalendarSettings, 422 ID_SetCalendarSettings,
422 ID_GetGPRSPoint, 423 ID_GetGPRSPoint,
423 ID_SetGPRSPoint, 424 ID_SetGPRSPoint,
424 ID_EnableGPRSPoint, 425 ID_EnableGPRSPoint,
425 ID_DeleteWAPBookmark, 426 ID_DeleteWAPBookmark,
426 ID_Netmonitor, 427 ID_Netmonitor,
427 ID_HoldCall, 428 ID_HoldCall,
428 ID_UnholdCall, 429 ID_UnholdCall,
429 ID_ConferenceCall, 430 ID_ConferenceCall,
430 ID_SplitCall, 431 ID_SplitCall,
431 ID_TransferCall, 432 ID_TransferCall,
432 ID_SwitchCall, 433 ID_SwitchCall,
433 ID_GetManufactureMonth, 434 ID_GetManufactureMonth,
434 ID_GetProductCode, 435 ID_GetProductCode,
435 ID_GetOriginalIMEI, 436 ID_GetOriginalIMEI,
436 ID_GetHardware, 437 ID_GetHardware,
437 ID_GetPPM, 438 ID_GetPPM,
438 ID_GetSMSMode, 439 ID_GetSMSMode,
439 ID_GetSMSMemories, 440 ID_GetSMSMemories,
440 ID_GetManufacturer, 441 ID_GetManufacturer,
441 ID_SetMemoryType, 442 ID_SetMemoryType,
442 ID_SetMemoryCharset, 443 ID_SetMemoryCharset,
443 ID_GetMMSSettings, 444 ID_GetMMSSettings,
444 ID_SetSMSParameters, 445 ID_SetSMSParameters,
445 ID_GetFMStation, 446 ID_GetFMStation,
446 ID_SetFMStation, 447 ID_SetFMStation,
447 ID_GetLanguage, 448 ID_GetLanguage,
448 ID_SetFastSMSSending, 449 ID_SetFastSMSSending,
449 ID_Reset, 450 ID_Reset,
450 ID_GetToDo, 451 ID_GetToDo,
451 ID_PressKey, 452 ID_PressKey,
452 ID_DeleteAllToDo, 453 ID_DeleteAllToDo,
453 ID_SetLight, 454 ID_SetLight,
454 ID_Divert, 455 ID_Divert,
455 ID_SetToDo, 456 ID_SetToDo,
456 ID_PlayTone, 457 ID_PlayTone,
457 ID_GetChatSettings, 458 ID_GetChatSettings,
458 ID_GetSyncMLSettings, 459 ID_GetSyncMLSettings,
459 ID_GetSyncMLName, 460 ID_GetSyncMLName,
460 ID_GetSecurityStatus, 461 ID_GetSecurityStatus,
461 ID_EnterSecurityCode, 462 ID_EnterSecurityCode,
462 ID_GetProfile, 463 ID_GetProfile,
463 ID_GetRingtonesInfo, 464 ID_GetRingtonesInfo,
464 ID_MakeAuthentication, 465 ID_MakeAuthentication,
465 ID_GetSpeedDial, 466 ID_GetSpeedDial,
466 ID_ResetPhoneSettings, 467 ID_ResetPhoneSettings,
467 ID_SendDTMF, 468 ID_SendDTMF,
468 ID_GetDisplayStatus, 469 ID_GetDisplayStatus,
469 ID_SetAutoNetworkLogin, 470 ID_SetAutoNetworkLogin,
470 ID_SetConnectSet, 471 ID_SetConnectSet,
471 ID_SetMMSSettings, 472 ID_SetMMSSettings,
472 ID_GetSIMIMSI, 473 ID_GetSIMIMSI,
473 ID_GetFileInfo, 474 ID_GetFileInfo,
474 ID_FileSystemStatus, 475 ID_FileSystemStatus,
475 ID_GetFile, 476 ID_GetFile,
476 ID_AddFile, 477 ID_AddFile,
477 ID_AddFolder, 478 ID_AddFolder,
478 ID_DeleteFile, 479 ID_DeleteFile,
479#ifdef GSM_ENABLE_ALCATEL 480#ifdef GSM_ENABLE_ALCATEL
480 /* AT mode */ 481 /* AT mode */
481 ID_SetFlowControl, 482 ID_SetFlowControl,
482 ID_AlcatelConnect, 483 ID_AlcatelConnect,
483 ID_AlcatelProtocol, 484 ID_AlcatelProtocol,
484 485
485 /* Binary mode */ 486 /* Binary mode */
486 ID_AlcatelAttach, 487 ID_AlcatelAttach,
487 ID_AlcatelDetach, 488 ID_AlcatelDetach,
488 ID_AlcatelCommit, 489 ID_AlcatelCommit,
489 ID_AlcatelCommit2, 490 ID_AlcatelCommit2,
490 ID_AlcatelEnd, 491 ID_AlcatelEnd,
491 ID_AlcatelClose, 492 ID_AlcatelClose,
492 ID_AlcatelStart, 493 ID_AlcatelStart,
493 ID_AlcatelSelect1, 494 ID_AlcatelSelect1,
494 ID_AlcatelSelect2, 495 ID_AlcatelSelect2,
495 ID_AlcatelSelect3, 496 ID_AlcatelSelect3,
496 ID_AlcatelBegin1, 497 ID_AlcatelBegin1,
497 ID_AlcatelBegin2, 498 ID_AlcatelBegin2,
498 ID_AlcatelGetIds1, 499 ID_AlcatelGetIds1,
499 ID_AlcatelGetIds2, 500 ID_AlcatelGetIds2,
500 ID_AlcatelGetCategories1, 501 ID_AlcatelGetCategories1,
501 ID_AlcatelGetCategories2, 502 ID_AlcatelGetCategories2,
502 ID_AlcatelGetCategoryText1, 503 ID_AlcatelGetCategoryText1,
503 ID_AlcatelGetCategoryText2, 504 ID_AlcatelGetCategoryText2,
504 ID_AlcatelAddCategoryText1, 505 ID_AlcatelAddCategoryText1,
505 ID_AlcatelAddCategoryText2, 506 ID_AlcatelAddCategoryText2,
506 ID_AlcatelGetFields1, 507 ID_AlcatelGetFields1,
507 ID_AlcatelGetFields2, 508 ID_AlcatelGetFields2,
508 ID_AlcatelGetFieldValue1, 509 ID_AlcatelGetFieldValue1,
509 ID_AlcatelGetFieldValue2, 510 ID_AlcatelGetFieldValue2,
510 ID_AlcatelDeleteItem1, 511 ID_AlcatelDeleteItem1,
511 ID_AlcatelDeleteItem2, 512 ID_AlcatelDeleteItem2,
512 ID_AlcatelDeleteField, 513 ID_AlcatelDeleteField,
513 ID_AlcatelCreateField, 514 ID_AlcatelCreateField,
514 ID_AlcatelUpdateField, 515 ID_AlcatelUpdateField,
515#endif 516#endif
516 ID_IncomingFrame, 517 ID_IncomingFrame,
517 518
518 ID_User1, 519 ID_User1,
519 ID_User2, 520 ID_User2,
520 ID_User3, 521 ID_User3,
521 ID_User4, 522 ID_User4,
522 ID_User5, 523 ID_User5,
523 ID_User6, 524 ID_User6,
524 ID_User7, 525 ID_User7,
525 ID_User8, 526 ID_User8,
526 ID_User9, 527 ID_User9,
527 ID_User10, 528 ID_User10,
528 529
529 ID_EachFrame 530 ID_EachFrame
530} GSM_Phone_RequestID; 531} GSM_Phone_RequestID;
531 532
532/** 533/**
533 * Phone related data are stored here. 534 * Phone related data are stored here.
534 */ 535 */
535typedef struct { 536typedef struct {
536 /** 537 /**
537 * Phone IMEI (or serial number). 538 * Phone IMEI (or serial number).
538 */ 539 */
539 char IMEI[MAX_IMEI_LENGTH]; 540 char IMEI[MAX_IMEI_LENGTH];
540 /** 541 /**
541 * Phone manufacturer as reported by phone. 542 * Phone manufacturer as reported by phone.
542 */ 543 */
543 char Manufacturer[MAX_MANUFACTURER_LENGTH]; 544 char Manufacturer[MAX_MANUFACTURER_LENGTH];
544 /** 545 /**
545 * Phone model as reported by phone. 546 * Phone model as reported by phone.
546 */ 547 */
547 char Model[MAX_MODEL_LENGTH]; 548 char Model[MAX_MODEL_LENGTH];
548 /** 549 /**
549 * Model information, pointer to static @ref allmodels array. 550 * Model information, pointer to static @ref allmodels array.
550 */ 551 */
551 OnePhoneModel *ModelInfo; 552 OnePhoneModel *ModelInfo;
552 /** 553 /**
553 * Phone version as reported by phone. It doesn't have to be numerical 554 * Phone version as reported by phone. It doesn't have to be numerical
554 * at all. 555 * at all.
555 */ 556 */
556 char Version[MAX_VERSION_LENGTH]; 557 char Version[MAX_VERSION_LENGTH];
557 /** 558 /**
558 * Phone version date, might be empty for some models. 559 * Phone version date, might be empty for some models.
559 */ 560 */
560 char VerDate[MAX_VERSION_DATE_LENGTH]; 561 char VerDate[MAX_VERSION_DATE_LENGTH];
561 /** 562 /**
562 * Phone version as number, if applicable. 563 * Phone version as number, if applicable.
563 */ 564 */
564 double VerNum; 565 double VerNum;
565 /** 566 /**
566 * Cache for hardware version used by some modules. 567 * Cache for hardware version used by some modules.
567 */ 568 */
568 char HardwareCache[50]; 569 char HardwareCache[50];
569 /** 570 /**
570 * Cache for product code version used by some modules. 571 * Cache for product code version used by some modules.
571 */ 572 */
572 char ProductCodeCache[50]; 573 char ProductCodeCache[50];
573 574
574 /** 575 /**
575 * Counter used for disabling startup info on phone, see 576 * Counter used for disabling startup info on phone, see
576 * @ref GSM_Phone_Functions::ShowStartInfo . After this is 0, the startup info is hidden. 577 * @ref GSM_Phone_Functions::ShowStartInfo . After this is 0, the startup info is hidden.
577 */ 578 */
578 int StartInfoCounter; 579 int StartInfoCounter;
579 580
580 /** 581 /**
581 * Pointer to structure used internally by phone drivers. 582 * Pointer to structure used internally by phone drivers.
582 */ 583 */
583 GSM_GPRSAccessPoint*GPRSPoint; 584 GSM_GPRSAccessPoint*GPRSPoint;
584 /** 585 /**
585 * Pointer to structure used internally by phone drivers. 586 * Pointer to structure used internally by phone drivers.
586 */ 587 */
587 GSM_SpeedDial *SpeedDial; 588 GSM_SpeedDial *SpeedDial;
588 /** 589 /**
589 * Pointer to structure used internally by phone drivers. 590 * Pointer to structure used internally by phone drivers.
590 */ 591 */
591 GSM_DateTime *DateTime; 592 GSM_DateTime *DateTime;
592 /** 593 /**
593 * Pointer to structure used internally by phone drivers. 594 * Pointer to structure used internally by phone drivers.
594 */ 595 */
595 GSM_Alarm *Alarm; 596 GSM_Alarm *Alarm;
596 /** 597 /**
597 * Pointer to structure used internally by phone drivers. 598 * Pointer to structure used internally by phone drivers.
598 */ 599 */
599 GSM_MemoryEntry *Memory; 600 GSM_MemoryEntry *Memory;
600 /** 601 /**
601 * Pointer to structure used internally by phone drivers. 602 * Pointer to structure used internally by phone drivers.
602 */ 603 */
603 GSM_MemoryStatus*MemoryStatus; 604 GSM_MemoryStatus*MemoryStatus;
604 /** 605 /**
605 * Pointer to structure used internally by phone drivers. 606 * Pointer to structure used internally by phone drivers.
606 */ 607 */
607 GSM_SMSC *SMSC; 608 GSM_SMSC *SMSC;
608 /** 609 /**
609 * Pointer to structure used internally by phone drivers. 610 * Pointer to structure used internally by phone drivers.
610 */ 611 */
611 GSM_MultiSMSMessage*GetSMSMessage; 612 GSM_MultiSMSMessage*GetSMSMessage;
612 /** 613 /**
613 * Pointer to structure used internally by phone drivers. 614 * Pointer to structure used internally by phone drivers.
614 */ 615 */
615 GSM_SMSMessage *SaveSMSMessage; 616 GSM_SMSMessage *SaveSMSMessage;
616 /** 617 /**
617 * Pointer to structure used internally by phone drivers. 618 * Pointer to structure used internally by phone drivers.
618 */ 619 */
619 GSM_SMSMemoryStatus*SMSStatus; 620 GSM_SMSMemoryStatus*SMSStatus;
620 /** 621 /**
621 * Pointer to structure used internally by phone drivers. 622 * Pointer to structure used internally by phone drivers.
622 */ 623 */
623 GSM_SMSFolders *SMSFolders; 624 GSM_SMSFolders *SMSFolders;
624 /** 625 /**
625 * Used internally by phone drivers. 626 * Used internally by phone drivers.
626 */ 627 */
627 int *VoiceRecord; 628 int *VoiceRecord;
628 /** 629 /**
629 * Used internally by phone drivers. 630 * Used internally by phone drivers.
630 */ 631 */
631 int CallID; 632 int CallID;
632 /** 633 /**
633 * Pointer to structure used internally by phone drivers. 634 * Pointer to structure used internally by phone drivers.
634 */ 635 */
635 GSM_SignalQuality*SignalQuality; 636 GSM_SignalQuality*SignalQuality;
636 /** 637 /**
637 * Pointer to structure used internally by phone drivers. 638 * Pointer to structure used internally by phone drivers.
638 */ 639 */
639 GSM_BatteryCharge*BatteryCharge; 640 GSM_BatteryCharge*BatteryCharge;
640 /** 641 /**
641 * Pointer to structure used internally by phone drivers. 642 * Pointer to structure used internally by phone drivers.
642 */ 643 */
643 GSM_NetworkInfo *NetworkInfo; 644 GSM_NetworkInfo *NetworkInfo;
644 /** 645 /**
645 * Pointer to structure used internally by phone drivers. 646 * Pointer to structure used internally by phone drivers.
646 */ 647 */
647 GSM_Ringtone *Ringtone; 648 GSM_Ringtone *Ringtone;
648 /** 649 /**
649 * Pointer to structure used internally by phone drivers. 650 * Pointer to structure used internally by phone drivers.
650 */ 651 */
651 GSM_CalendarEntry*Cal; 652 GSM_CalendarEntry*Cal;
652 /** 653 /**
653 * Used internally by phone drivers. 654 * Used internally by phone drivers.
654 */ 655 */
655 unsigned char *SecurityCode; 656 unsigned char *SecurityCode;
656 /** 657 /**
657 * Pointer to structure used internally by phone drivers. 658 * Pointer to structure used internally by phone drivers.
658 */ 659 */
659 GSM_WAPBookmark *WAPBookmark; 660 GSM_WAPBookmark *WAPBookmark;
660 /** 661 /**
661 * Pointer to structure used internally by phone drivers. 662 * Pointer to structure used internally by phone drivers.
662 */ 663 */
663 GSM_MultiWAPSettings*WAPSettings; 664 GSM_MultiWAPSettings*WAPSettings;
664 /** 665 /**
665 * Pointer to structure used internally by phone drivers. 666 * Pointer to structure used internally by phone drivers.
666 */ 667 */
667 GSM_Bitmap *Bitmap; 668 GSM_Bitmap *Bitmap;
668 /** 669 /**
669 * Used internally by phone drivers. 670 * Used internally by phone drivers.
670 */ 671 */
671 unsigned char *Netmonitor; 672 unsigned char *Netmonitor;
672 /** 673 /**
673 * Pointer to structure used internally by phone drivers. 674 * Pointer to structure used internally by phone drivers.
674 */ 675 */
675 GSM_MultiCallDivert*Divert; 676 GSM_MultiCallDivert*Divert;
676 /** 677 /**
677 * Pointer to structure used internally by phone drivers. 678 * Pointer to structure used internally by phone drivers.
678 */ 679 */
679 GSM_ToDoEntry *ToDo; 680 GSM_ToDoEntry *ToDo;
680 GSM_NoteEntry *Note; 681 GSM_NoteEntry *Note;
681 /** 682 /**
682 * Used internally by phone drivers. 683 * Used internally by phone drivers.
683 */ 684 */
684 bool PressKey; 685 bool PressKey;
685 /** 686 /**
686 * Pointer to structure used internally by phone drivers. 687 * Pointer to structure used internally by phone drivers.
687 */ 688 */
688 GSM_SecurityCodeType*SecurityStatus; 689 GSM_SecurityCodeType*SecurityStatus;
689 /** 690 /**
690 * Pointer to structure used internally by phone drivers. 691 * Pointer to structure used internally by phone drivers.
691 */ 692 */
692 GSM_Profile *Profile; 693 GSM_Profile *Profile;
693 /** 694 /**
694 * Pointer to structure used internally by phone drivers. 695 * Pointer to structure used internally by phone drivers.
695 */ 696 */
696 GSM_AllRingtonesInfo*RingtonesInfo; 697 GSM_AllRingtonesInfo*RingtonesInfo;
697 /** 698 /**
698 * Pointer to structure used internally by phone drivers. 699 * Pointer to structure used internally by phone drivers.
699 */ 700 */
700 GSM_DisplayFeatures*DisplayFeatures; 701 GSM_DisplayFeatures*DisplayFeatures;
701 /** 702 /**
702 * Pointer to structure used internally by phone drivers. 703 * Pointer to structure used internally by phone drivers.
703 */ 704 */
704 GSM_FMStation *FMStation; 705 GSM_FMStation *FMStation;
705 /** 706 /**
706 * Pointer to structure used internally by phone drivers. 707 * Pointer to structure used internally by phone drivers.
707 */ 708 */
708 GSM_Locale *Locale; 709 GSM_Locale *Locale;
709 /** 710 /**
710 * Pointer to structure used internally by phone drivers. 711 * Pointer to structure used internally by phone drivers.
711 */ 712 */
712 GSM_CalendarSettings*CalendarSettings; 713 GSM_CalendarSettings*CalendarSettings;
713 /** 714 /**
714 * Used internally by phone drivers. 715 * Used internally by phone drivers.
715 */ 716 */
716 unsigned char *PhoneString; 717 unsigned char *PhoneString;
717 /** 718 /**
718 * Used internally by phone drivers. 719 * Used internally by phone drivers.
719 */ 720 */
720 int StartPhoneString; 721 int StartPhoneString;
721 /** 722 /**
722 * Pointer to structure used internally by phone drivers. 723 * Pointer to structure used internally by phone drivers.
723 */ 724 */
724 GSM_File *FileInfo; 725 GSM_File *FileInfo;
725 /** 726 /**
726 * Pointer to structure used internally by phone drivers. 727 * Pointer to structure used internally by phone drivers.
727 */ 728 */
728 GSM_File *File; 729 GSM_File *File;
729 /** 730 /**
730 * Pointer to structure used internally by phone drivers. 731 * Pointer to structure used internally by phone drivers.
731 */ 732 */
732 GSM_FileSystemStatus*FileSystemStatus; 733 GSM_FileSystemStatus*FileSystemStatus;
733 GSM_ChatSettings*ChatSettings; 734 GSM_ChatSettings*ChatSettings;
734 GSM_SyncMLSettings*SyncMLSettings; 735 GSM_SyncMLSettings*SyncMLSettings;
735 736
736 /** 737 /**
737 * Should phone notify about incoming calls? 738 * Should phone notify about incoming calls?
738 */ 739 */
739 bool EnableIncomingCall; 740 bool EnableIncomingCall;
740 /** 741 /**
741 * Should phone notify about incoming SMSes? 742 * Should phone notify about incoming SMSes?
742 */ 743 */
743 bool EnableIncomingSMS; 744 bool EnableIncomingSMS;
744 /** 745 /**
745 * Should phone notify about incoming CBs? 746 * Should phone notify about incoming CBs?
746 */ 747 */
747 bool EnableIncomingCB; 748 bool EnableIncomingCB;
748 /** 749 /**
749 * Should phone notify about incoming USSDs? 750 * Should phone notify about incoming USSDs?
750 */ 751 */
751 bool EnableIncomingUSSD; 752 bool EnableIncomingUSSD;
752 753
753 /** 754 /**
754 * Last message received from phone. 755 * Last message received from phone.
755 */ 756 */
756 GSM_Protocol_Message*RequestMsg; 757 GSM_Protocol_Message*RequestMsg;
757 /** 758 /**
758 * Last message sent by Gammu. 759 * Last message sent by Gammu.
759 */ 760 */
760 GSM_Protocol_Message*SentMsg; 761 GSM_Protocol_Message*SentMsg;
761 /** 762 /**
762 * What operation is being performed now, see @ref GSM_Phone_RequestID 763 * What operation is being performed now, see @ref GSM_Phone_RequestID
763 * for possible values. 764 * for possible values.
764 */ 765 */
@@ -909,671 +910,696 @@ typedef struct {
909 * Gets PPM (Post Programmable Memory) info from phone 910 * Gets PPM (Post Programmable Memory) info from phone
910 * (in other words for Nokia get, which language pack is in phone) 911 * (in other words for Nokia get, which language pack is in phone)
911 */ 912 */
912 GSM_Error (*GetPPM) (GSM_StateMachine *s, char *value); 913 GSM_Error (*GetPPM) (GSM_StateMachine *s, char *value);
913 /** 914 /**
914 * Gets SIM IMSI from phone. 915 * Gets SIM IMSI from phone.
915 */ 916 */
916 GSM_Error (*GetSIMIMSI) (GSM_StateMachine *s, char *IMSI); 917 GSM_Error (*GetSIMIMSI) (GSM_StateMachine *s, char *IMSI);
917 /** 918 /**
918 * Reads date and time from phone. 919 * Reads date and time from phone.
919 */ 920 */
920 GSM_Error (*GetDateTime)(GSM_StateMachine *s, GSM_DateTime *date_time); 921 GSM_Error (*GetDateTime)(GSM_StateMachine *s, GSM_DateTime *date_time);
921 /** 922 /**
922 * Sets date and time in phone. 923 * Sets date and time in phone.
923 */ 924 */
924 GSM_Error (*SetDateTime)(GSM_StateMachine *s, GSM_DateTime *date_time); 925 GSM_Error (*SetDateTime)(GSM_StateMachine *s, GSM_DateTime *date_time);
925 /** 926 /**
926 * Reads alarm set in phone. 927 * Reads alarm set in phone.
927 */ 928 */
928 GSM_Error (*GetAlarm) (GSM_StateMachine *s, GSM_Alarm*alarm); 929 GSM_Error (*GetAlarm) (GSM_StateMachine *s, GSM_Alarm*alarm);
929 /** 930 /**
930 * Sets alarm in phone. 931 * Sets alarm in phone.
931 */ 932 */
932 GSM_Error (*SetAlarm) (GSM_StateMachine *s, GSM_Alarm *alarm); 933 GSM_Error (*SetAlarm) (GSM_StateMachine *s, GSM_Alarm *alarm);
933 /** 934 /**
934 * Gets locale from phone. 935 * Gets locale from phone.
935 */ 936 */
936 GSM_Error (*GetLocale) (GSM_StateMachine *s, GSM_Locale *locale); 937 GSM_Error (*GetLocale) (GSM_StateMachine *s, GSM_Locale *locale);
937 /** 938 /**
938 * Sets locale of phone. 939 * Sets locale of phone.
939 */ 940 */
940 GSM_Error (*SetLocale) (GSM_StateMachine *s, GSM_Locale *locale); 941 GSM_Error (*SetLocale) (GSM_StateMachine *s, GSM_Locale *locale);
941 /** 942 /**
942 * Emulates key press or key release. 943 * Emulates key press or key release.
943 */ 944 */
944 GSM_Error (*PressKey) (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); 945 GSM_Error (*PressKey) (GSM_StateMachine *s, GSM_KeyCode Key, bool Press);
945 /** 946 /**
946 * Performs phone reset. 947 * Performs phone reset.
947 */ 948 */
948 GSM_Error (*Reset) (GSM_StateMachine *s, bool hard); 949 GSM_Error (*Reset) (GSM_StateMachine *s, bool hard);
949 /** 950 /**
950 * Resets phone settings. 951 * Resets phone settings.
951 */ 952 */
952 GSM_Error (*ResetPhoneSettings) (GSM_StateMachine *s, GSM_ResetSettingsType Type); 953 GSM_Error (*ResetPhoneSettings) (GSM_StateMachine *s, GSM_ResetSettingsType Type);
953 /** 954 /**
954 * Enters security code (PIN, PUK,...) . 955 * Enters security code (PIN, PUK,...) .
955 */ 956 */
956 GSM_Error (*EnterSecurityCode) (GSM_StateMachine *s, GSM_SecurityCode Code); 957 GSM_Error (*EnterSecurityCode) (GSM_StateMachine *s, GSM_SecurityCode Code);
957 /** 958 /**
958 * Queries whether some security code needs to be entered./ 959 * Queries whether some security code needs to be entered./
959 */ 960 */
960 GSM_Error (*GetSecurityStatus) (GSM_StateMachine *s, GSM_SecurityCodeType *Status); 961 GSM_Error (*GetSecurityStatus) (GSM_StateMachine *s, GSM_SecurityCodeType *Status);
961 /** 962 /**
962 * Acquired display status. 963 * Acquired display status.
963 */ 964 */
964 GSM_Error (*GetDisplayStatus) (GSM_StateMachine *s, GSM_DisplayFeatures *features); 965 GSM_Error (*GetDisplayStatus) (GSM_StateMachine *s, GSM_DisplayFeatures *features);
965 /** 966 /**
966 * Enables network auto login. 967 * Enables network auto login.
967 */ 968 */
968 GSM_Error (*SetAutoNetworkLogin)(GSM_StateMachine *s); 969 GSM_Error (*SetAutoNetworkLogin)(GSM_StateMachine *s);
969 /** 970 /**
970 * Gets information about batery charge and phone charging state. 971 * Gets information about batery charge and phone charging state.
971 */ 972 */
972 GSM_Error (*GetBatteryCharge) (GSM_StateMachine *s, GSM_BatteryCharge *bat); 973 GSM_Error (*GetBatteryCharge) (GSM_StateMachine *s, GSM_BatteryCharge *bat);
973 /** 974 /**
974 * Reads signal quality (strength and error rate). 975 * Reads signal quality (strength and error rate).
975 */ 976 */
976 GSM_Error (*GetSignalQuality) (GSM_StateMachine *s, GSM_SignalQuality *sig); 977 GSM_Error (*GetSignalQuality) (GSM_StateMachine *s, GSM_SignalQuality *sig);
977 /** 978 /**
978 * Gets network information. 979 * Gets network information.
979 */ 980 */
980 GSM_Error (*GetNetworkInfo) (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); 981 GSM_Error (*GetNetworkInfo) (GSM_StateMachine *s, GSM_NetworkInfo *netinfo);
981 /** 982 /**
982 * Reads category from phone. 983 * Reads category from phone.
983 */ 984 */
984 GSM_Error (*GetCategory)(GSM_StateMachine *s, GSM_Category *Category); 985 GSM_Error (*GetCategory)(GSM_StateMachine *s, GSM_Category *Category);
985 /** 986 /**
986 * Adds category to phone. 987 * Adds category to phone.
987 */ 988 */
988 GSM_Error (*AddCategory)(GSM_StateMachine *s, GSM_Category *Category); 989 GSM_Error (*AddCategory)(GSM_StateMachine *s, GSM_Category *Category);
989 /** 990 /**
990 * Reads category status (number of used entries) from phone. 991 * Reads category status (number of used entries) from phone.
991 */ 992 */
992 GSM_Error (*GetCategoryStatus) (GSM_StateMachine *s, GSM_CategoryStatus *Status); 993 GSM_Error (*GetCategoryStatus) (GSM_StateMachine *s, GSM_CategoryStatus *Status);
993 /** 994 /**
994 * Gets memory (phonebooks or calls) status (eg. number of used and 995 * Gets memory (phonebooks or calls) status (eg. number of used and
995 * free entries). 996 * free entries).
996 */ 997 */
997 GSM_Error (*GetMemoryStatus) (GSM_StateMachine *s, GSM_MemoryStatus *status); 998 GSM_Error (*GetMemoryStatus) (GSM_StateMachine *s, GSM_MemoryStatus *status);
998 /** 999 /**
999 * Reads entry from memory (phonebooks or calls). Which entry should 1000 * Reads entry from memory (phonebooks or calls). Which entry should
1000 * be read is defined in entry. 1001 * be read is defined in entry.
1001 */ 1002 */
1002 GSM_Error (*GetMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 1003 GSM_Error (*GetMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry);
1003 /** 1004 /**
1004 * Reads entry from memory (phonebooks or calls). Which entry should 1005 * Reads entry from memory (phonebooks or calls). Which entry should
1005 * be read is defined in entry. This can be easily used for reading all entries. 1006 * be read is defined in entry. This can be easily used for reading all entries.
1006 */ 1007 */
1007 GSM_Error (*GetNextMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start); 1008 GSM_Error (*GetNextMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start);
1008 /** 1009 /**
1009 * Sets memory (phonebooks or calls) entry. 1010 * Sets memory (phonebooks or calls) entry.
1010 */ 1011 */
1011 GSM_Error (*SetMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 1012 GSM_Error (*SetMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry);
1012 /** 1013 /**
1013 * Deletes memory (phonebooks or calls) entry. 1014 * Deletes memory (phonebooks or calls) entry.
1014 */ 1015 */
1015 GSM_Error (*AddMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 1016 GSM_Error (*AddMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry);
1016 /** 1017 /**
1017 * Deletes memory (phonebooks or calls) entry. 1018 * Deletes memory (phonebooks or calls) entry.
1018 */ 1019 */
1019 GSM_Error (*DeleteMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry); 1020 GSM_Error (*DeleteMemory) (GSM_StateMachine *s, GSM_MemoryEntry *entry);
1020 /** 1021 /**
1021 * Deletes all memory (phonebooks or calls) entries of specified type. 1022 * Deletes all memory (phonebooks or calls) entries of specified type.
1022 */ 1023 */
1023 GSM_Error (*DeleteAllMemory) (GSM_StateMachine *s, GSM_MemoryType MemoryType); 1024 GSM_Error (*DeleteAllMemory) (GSM_StateMachine *s, GSM_MemoryType MemoryType);
1024 /** 1025 /**
1025 * Gets speed dial. 1026 * Gets speed dial.
1026 */ 1027 */
1027 GSM_Error (*GetSpeedDial) (GSM_StateMachine *s, GSM_SpeedDial *Speed); 1028 GSM_Error (*GetSpeedDial) (GSM_StateMachine *s, GSM_SpeedDial *Speed);
1028 /** 1029 /**
1029 * Sets speed dial. 1030 * Sets speed dial.
1030 */ 1031 */
1031 GSM_Error (*SetSpeedDial) (GSM_StateMachine *s, GSM_SpeedDial *Speed); 1032 GSM_Error (*SetSpeedDial) (GSM_StateMachine *s, GSM_SpeedDial *Speed);
1032 /** 1033 /**
1033 * Gets SMS Service Center number and SMS settings. 1034 * Gets SMS Service Center number and SMS settings.
1034 */ 1035 */
1035 GSM_Error (*GetSMSC) (GSM_StateMachine *s, GSM_SMSC *smsc); 1036 GSM_Error (*GetSMSC) (GSM_StateMachine *s, GSM_SMSC *smsc);
1036 /** 1037 /**
1037 * Sets SMS Service Center number and SMS settings. 1038 * Sets SMS Service Center number and SMS settings.
1038 */ 1039 */
1039 GSM_Error (*SetSMSC) (GSM_StateMachine *s, GSM_SMSC *smsc); 1040 GSM_Error (*SetSMSC) (GSM_StateMachine *s, GSM_SMSC *smsc);
1040 /** 1041 /**
1041 * Gets information about SMS memory (read/unread/size of memory for 1042 * Gets information about SMS memory (read/unread/size of memory for
1042 * both SIM and phone). 1043 * both SIM and phone).
1043 */ 1044 */
1044 GSM_Error (*GetSMSStatus) (GSM_StateMachine *s, GSM_SMSMemoryStatus *status); 1045 GSM_Error (*GetSMSStatus) (GSM_StateMachine *s, GSM_SMSMemoryStatus *status);
1045 /** 1046 /**
1046 * Reads SMS message. 1047 * Reads SMS message.
1047 */ 1048 */
1048 GSM_Error (*GetSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms); 1049 GSM_Error (*GetSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms);
1049 /** 1050 /**
1050 * Reads next (or first if start set) SMS message. This might be 1051 * Reads next (or first if start set) SMS message. This might be
1051 * faster for some phones than using @ref GetSMS for each message. 1052 * faster for some phones than using @ref GetSMS for each message.
1052 */ 1053 */
1053 GSM_Error (*GetNextSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start); 1054 GSM_Error (*GetNextSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start);
1054 /** 1055 /**
1055 * Sets SMS. 1056 * Sets SMS.
1056 */ 1057 */
1057 GSM_Error (*SetSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1058 GSM_Error (*SetSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
1058 /** 1059 /**
1059 * Adds SMS to specified folder. 1060 * Adds SMS to specified folder.
1060 */ 1061 */
1061 GSM_Error (*AddSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1062 GSM_Error (*AddSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
1062 /** 1063 /**
1063 * Deletes SMS. 1064 * Deletes SMS.
1064 */ 1065 */
1065 GSM_Error (*DeleteSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1066 GSM_Error (*DeleteSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
1066 /** 1067 /**
1067 * Sends SMS. 1068 * Sends SMS.
1068 */ 1069 */
1069 GSM_Error (*SendSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1070 GSM_Error (*SendSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
1070 /** 1071 /**
1071 * Sends SMS already saved in phone. 1072 * Sends SMS already saved in phone.
1072 */ 1073 */
1073 GSM_Error (*SendSavedSMS)(GSM_StateMachine *s, int Folder, int Location); 1074 GSM_Error (*SendSavedSMS)(GSM_StateMachine *s, int Folder, int Location);
1074 GSM_Error (*SetFastSMSSending) (GSM_StateMachine *s, bool enable); 1075 GSM_Error (*SetFastSMSSending) (GSM_StateMachine *s, bool enable);
1075 /** 1076 /**
1076 * Enable/disable notification on incoming SMS. 1077 * Enable/disable notification on incoming SMS.
1077 */ 1078 */
1078 GSM_Error (*SetIncomingSMS) (GSM_StateMachine *s, bool enable); 1079 GSM_Error (*SetIncomingSMS) (GSM_StateMachine *s, bool enable);
1079 /** 1080 /**
1080 * Gets network information from phone. 1081 * Gets network information from phone.
1081 */ 1082 */
1082 GSM_Error (*SetIncomingCB) (GSM_StateMachine *s, bool enable); 1083 GSM_Error (*SetIncomingCB) (GSM_StateMachine *s, bool enable);
1083 /** 1084 /**
1084 * Returns SMS folders information. 1085 * Returns SMS folders information.
1085 */ 1086 */
1086 GSM_Error (*GetSMSFolders) (GSM_StateMachine *s, GSM_SMSFolders *folders); 1087 GSM_Error (*GetSMSFolders) (GSM_StateMachine *s, GSM_SMSFolders *folders);
1087 /** 1088 /**
1088 * Creates SMS folder. 1089 * Creates SMS folder.
1089 */ 1090 */
1090 GSM_Error (*AddSMSFolder) (GSM_StateMachine *s, unsigned char *name); 1091 GSM_Error (*AddSMSFolder) (GSM_StateMachine *s, unsigned char *name);
1091 /** 1092 /**
1092 * Deletes SMS folder. 1093 * Deletes SMS folder.
1093 */ 1094 */
1094 GSM_Error (*DeleteSMSFolder) (GSM_StateMachine *s, int ID); 1095 GSM_Error (*DeleteSMSFolder) (GSM_StateMachine *s, int ID);
1095 /** 1096 /**
1096 * Dials number and starts voice call. 1097 * Dials number and starts voice call.
1097 */ 1098 */
1098 GSM_Error (*DialVoice) (GSM_StateMachine *s, char *Number, GSM_CallShowNumber ShowNumber); 1099 GSM_Error (*DialVoice) (GSM_StateMachine *s, char *Number, GSM_CallShowNumber ShowNumber);
1099 /** 1100 /**
1100 * Accept current incoming call. 1101 * Accept current incoming call.
1101 */ 1102 */
1102 GSM_Error (*AnswerCall) (GSM_StateMachine *s, int ID, bool all); 1103 GSM_Error (*AnswerCall) (GSM_StateMachine *s, int ID, bool all);
1103 /** 1104 /**
1104 * Deny current incoming call. 1105 * Deny current incoming call.
1105 */ 1106 */
1106 GSM_Error (*CancelCall) (GSM_StateMachine *s, int ID, bool all); 1107 GSM_Error (*CancelCall) (GSM_StateMachine *s, int ID, bool all);
1107 /** 1108 /**
1108 * Holds call. 1109 * Holds call.
1109 */ 1110 */
1110 GSM_Error (*HoldCall) (GSM_StateMachine *s, int ID); 1111 GSM_Error (*HoldCall) (GSM_StateMachine *s, int ID);
1111 /** 1112 /**
1112 * Unholds call. 1113 * Unholds call.
1113 */ 1114 */
1114 GSM_Error (*UnholdCall) (GSM_StateMachine *s, int ID); 1115 GSM_Error (*UnholdCall) (GSM_StateMachine *s, int ID);
1115 /** 1116 /**
1116 * Initiates conference call. 1117 * Initiates conference call.
1117 */ 1118 */
1118 GSM_Error (*ConferenceCall) (GSM_StateMachine *s, int ID); 1119 GSM_Error (*ConferenceCall) (GSM_StateMachine *s, int ID);
1119 /** 1120 /**
1120 * Splits call. 1121 * Splits call.
1121 */ 1122 */
1122 GSM_Error (*SplitCall) (GSM_StateMachine *s, int ID); 1123 GSM_Error (*SplitCall) (GSM_StateMachine *s, int ID);
1123 /** 1124 /**
1124 * Transfers call. 1125 * Transfers call.
1125 */ 1126 */
1126 GSM_Error (*TransferCall) (GSM_StateMachine *s, int ID, bool next); 1127 GSM_Error (*TransferCall) (GSM_StateMachine *s, int ID, bool next);
1127 /** 1128 /**
1128 * Switches call. 1129 * Switches call.
1129 */ 1130 */
1130 GSM_Error (*SwitchCall) (GSM_StateMachine *s, int ID, bool next); 1131 GSM_Error (*SwitchCall) (GSM_StateMachine *s, int ID, bool next);
1131 /** 1132 /**
1132 * Gets call diverts. 1133 * Gets call diverts.
1133 */ 1134 */
1134 GSM_Error (*GetCallDivert) (GSM_StateMachine *s, GSM_MultiCallDivert *divert); 1135 GSM_Error (*GetCallDivert) (GSM_StateMachine *s, GSM_MultiCallDivert *divert);
1135 /** 1136 /**
1136 * Sets call diverts. 1137 * Sets call diverts.
1137 */ 1138 */
1138 GSM_Error (*SetCallDivert) (GSM_StateMachine *s, GSM_MultiCallDivert *divert); 1139 GSM_Error (*SetCallDivert) (GSM_StateMachine *s, GSM_MultiCallDivert *divert);
1139 /** 1140 /**
1140 * Cancels all diverts. 1141 * Cancels all diverts.
1141 */ 1142 */
1142 GSM_Error (*CancelAllDiverts) (GSM_StateMachine *s); 1143 GSM_Error (*CancelAllDiverts) (GSM_StateMachine *s);
1143 /** 1144 /**
1144 * Activates/deactivates noticing about incoming calls. 1145 * Activates/deactivates noticing about incoming calls.
1145 */ 1146 */
1146 GSM_Error (*SetIncomingCall) (GSM_StateMachine *s, bool enable); 1147 GSM_Error (*SetIncomingCall) (GSM_StateMachine *s, bool enable);
1147 /** 1148 /**
1148 * Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services). 1149 * Activates/deactivates noticing about incoming USSDs (UnStructured Supplementary Services).
1149 */ 1150 */
1150 GSM_Error (*SetIncomingUSSD) (GSM_StateMachine *s, bool enable); 1151 GSM_Error (*SetIncomingUSSD) (GSM_StateMachine *s, bool enable);
1151 /** 1152 /**
1152 * Sends DTMF (Dual Tone Multi Frequency) tone. 1153 * Sends DTMF (Dual Tone Multi Frequency) tone.
1153 */ 1154 */
1154 GSM_Error (*SendDTMF) (GSM_StateMachine *s, char *sequence); 1155 GSM_Error (*SendDTMF) (GSM_StateMachine *s, char *sequence);
1155 /** 1156 /**
1156 * Gets ringtone from phone. 1157 * Gets ringtone from phone.
1157 */ 1158 */
1158 GSM_Error (*GetRingtone)(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone); 1159 GSM_Error (*GetRingtone)(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone);
1159 /** 1160 /**
1160 * Sets ringtone in phone. 1161 * Sets ringtone in phone.
1161 */ 1162 */
1162 GSM_Error (*SetRingtone)(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength); 1163 GSM_Error (*SetRingtone)(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength);
1163 /** 1164 /**
1164 * Acquires ringtone informaiton. 1165 * Acquires ringtone informaiton.
1165 */ 1166 */
1166 GSM_Error (*GetRingtonesInfo) (GSM_StateMachine *s, GSM_AllRingtonesInfo *Info); 1167 GSM_Error (*GetRingtonesInfo) (GSM_StateMachine *s, GSM_AllRingtonesInfo *Info);
1167 /** 1168 /**
1168 * Deletes user defined ringtones from phone. 1169 * Deletes user defined ringtones from phone.
1169 */ 1170 */
1170 GSM_Error (*DeleteUserRingtones)(GSM_StateMachine *s); 1171 GSM_Error (*DeleteUserRingtones)(GSM_StateMachine *s);
1171 /** 1172 /**
1172 * Plays tone. 1173 * Plays tone.
1173 */ 1174 */
1174 GSM_Error (*PlayTone) (GSM_StateMachine *s, int Herz, unsigned char Volume, bool start); 1175 GSM_Error (*PlayTone) (GSM_StateMachine *s, int Herz, unsigned char Volume, bool start);
1175 /** 1176 /**
1176 * Reads WAP bookmark. 1177 * Reads WAP bookmark.
1177 */ 1178 */
1178 GSM_Error (*GetWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 1179 GSM_Error (*GetWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
1179 /** 1180 /**
1180 * Sets WAP bookmark. 1181 * Sets WAP bookmark.
1181 */ 1182 */
1182 GSM_Error (*SetWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 1183 GSM_Error (*SetWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
1183 /** 1184 /**
1184 * Deletes WAP bookmark. 1185 * Deletes WAP bookmark.
1185 */ 1186 */
1186 GSM_Error (*DeleteWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); 1187 GSM_Error (*DeleteWAPBookmark) (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
1187 /** 1188 /**
1188 * Acquires WAP settings. 1189 * Acquires WAP settings.
1189 */ 1190 */
1190 GSM_Error (*GetWAPSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1191 GSM_Error (*GetWAPSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings);
1191 /** 1192 /**
1192 * Changes WAP settings. 1193 * Changes WAP settings.
1193 */ 1194 */
1194 GSM_Error (*SetWAPSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1195 GSM_Error (*SetWAPSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings);
1195 /** 1196 /**
1196 * Acquires MMS settings. 1197 * Acquires MMS settings.
1197 */ 1198 */
1198 GSM_Error (*GetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1199 GSM_Error (*GetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings);
1199 /** 1200 /**
1200 * Changes MMS settings. 1201 * Changes MMS settings.
1201 */ 1202 */
1202 GSM_Error (*SetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); 1203 GSM_Error (*SetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings);
1203 /** 1204 /**
1204 * Acquires SyncML settings. 1205 * Acquires SyncML settings.
1205 */ 1206 */
1206 GSM_Error (*GetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings); 1207 GSM_Error (*GetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings);
1207 /** 1208 /**
1208 * Changes SyncML settings. 1209 * Changes SyncML settings.
1209 */ 1210 */
1210 GSM_Error (*SetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings); 1211 GSM_Error (*SetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings);
1211 /** 1212 /**
1212 * Acquires chat/presence settings. 1213 * Acquires chat/presence settings.
1213 */ 1214 */
1214 GSM_Error (*GetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings); 1215 GSM_Error (*GetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings);
1215 /** 1216 /**
1216 * Changes chat/presence settings. 1217 * Changes chat/presence settings.
1217 */ 1218 */
1218 GSM_Error (*SetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings); 1219 GSM_Error (*SetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings);
1219 /** 1220 /**
1220 * Gets bitmap. 1221 * Gets bitmap.
1221 */ 1222 */
1222 GSM_Error (*GetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap); 1223 GSM_Error (*GetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
1223 /** 1224 /**
1224 * Sets bitmap. 1225 * Sets bitmap.
1225 */ 1226 */
1226 GSM_Error (*SetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap); 1227 GSM_Error (*SetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
1227 /** 1228 /**
1228 * Gets status of ToDos (count of used entries). 1229 * Gets status of ToDos (count of used entries).
1229 */ 1230 */
1230 GSM_Error (*GetToDoStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status); 1231 GSM_Error (*GetToDoStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status);
1231 /** 1232 /**
1232 * Reads ToDo from phone. 1233 * Reads ToDo from phone.
1233 */ 1234 */
1234 GSM_Error (*GetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1235 GSM_Error (*GetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
1235 /** 1236 /**
1236 * Reads ToDo from phone. 1237 * Reads ToDo from phone.
1237 */ 1238 */
1238 GSM_Error (*GetNextToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start); 1239 GSM_Error (*GetNextToDo)(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start);
1239 /** 1240 /**
1240 * Sets ToDo in phone. 1241 * Sets ToDo in phone.
1241 */ 1242 */
1242 GSM_Error (*SetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1243 GSM_Error (*SetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
1243 /** 1244 /**
1244 * Adds ToDo in phone. 1245 * Adds ToDo in phone.
1245 */ 1246 */
1246 GSM_Error (*AddToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1247 GSM_Error (*AddToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
1247 /** 1248 /**
1248 * Deletes ToDo entry in phone. 1249 * Deletes ToDo entry in phone.
1249 */ 1250 */
1250 GSM_Error (*DeleteToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); 1251 GSM_Error (*DeleteToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
1251 /** 1252 /**
1252 * Deletes all todo entries in phone. 1253 * Deletes all todo entries in phone.
1253 */ 1254 */
1254 GSM_Error (*DeleteAllToDo) (GSM_StateMachine *s); 1255 GSM_Error (*DeleteAllToDo) (GSM_StateMachine *s);
1255 /** 1256 /**
1256 * Retrieves calendar status (number of used entries). 1257 * Retrieves calendar status (number of used entries).
1257 */ 1258 */
1258 GSM_Error (*GetCalendarStatus) (GSM_StateMachine *s, GSM_CalendarStatus *Status); 1259 GSM_Error (*GetCalendarStatus) (GSM_StateMachine *s, GSM_CalendarStatus *Status);
1259 /** 1260 /**
1260 * Retrieves calendar entry. 1261 * Retrieves calendar entry.
1261 */ 1262 */
1262 GSM_Error (*GetCalendar)(GSM_StateMachine *s, GSM_CalendarEntry *Note); 1263 GSM_Error (*GetCalendar)(GSM_StateMachine *s, GSM_CalendarEntry *Note);
1263 /** 1264 /**
1264 * Retrieves calendar entry. This is useful for continuous reading of all 1265 * Retrieves calendar entry. This is useful for continuous reading of all
1265 * calendar entries. 1266 * calendar entries.
1266 */ 1267 */
1267 GSM_Error (*GetNextCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start); 1268 GSM_Error (*GetNextCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
1268 /** 1269 /**
1269 * Sets calendar entry 1270 * Sets calendar entry
1270 */ 1271 */
1271 GSM_Error (*SetCalendar)(GSM_StateMachine *s, GSM_CalendarEntry *Note); 1272 GSM_Error (*SetCalendar)(GSM_StateMachine *s, GSM_CalendarEntry *Note);
1272 /** 1273 /**
1273 * Adds calendar entry. 1274 * Adds calendar entry.
1274 */ 1275 */
1275 GSM_Error (*AddCalendar)(GSM_StateMachine *s, GSM_CalendarEntry *Note); 1276 GSM_Error (*AddCalendar)(GSM_StateMachine *s, GSM_CalendarEntry *Note);
1276 /** 1277 /**
1277 * Deletes calendar entry. 1278 * Deletes calendar entry.
1278 */ 1279 */
1279 GSM_Error (*DeleteCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note); 1280 GSM_Error (*DeleteCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note);
1280 /** 1281 /**
1281 * Deletes all calendar entries. 1282 * Deletes all calendar entries.
1282 */ 1283 */
1283 GSM_Error (*DeleteAllCalendar) (GSM_StateMachine *s); 1284 GSM_Error (*DeleteAllCalendar) (GSM_StateMachine *s);
1284 /** 1285 /**
1285 * Reads calendar settings. 1286 * Reads calendar settings.
1286 */ 1287 */
1287 GSM_Error (*GetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings); 1288 GSM_Error (*GetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings);
1288 /** 1289 /**
1289 * Sets calendar settings. 1290 * Sets calendar settings.
1290 */ 1291 */
1291 GSM_Error (*SetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings); 1292 GSM_Error (*SetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings);
1292 /** 1293 /**
1293 * Gets note. 1294 * Retrieves notes status (number of used entries).
1294 */ 1295 */
1295 GSM_Error (*GetNextNote)(GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh); 1296 GSM_Error (*GetNotesStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status);
1297 /**
1298 * Retrieves notes entry.
1299 */
1300 GSM_Error (*GetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note);
1301 /**
1302 * Retrieves note entry. This is useful for continuous reading of all
1303 * notes entries.
1304 */
1305 GSM_Error (*GetNextNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool start);
1306 /**
1307 * Sets note entry
1308 */
1309 GSM_Error (*SetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note);
1310 /**
1311 * Adds note entry.
1312 */
1313 GSM_Error (*AddNote) (GSM_StateMachine *s, GSM_NoteEntry *Note);
1314 /**
1315 * Deletes note entry.
1316 */
1317 GSM_Error (*DeleteNote) (GSM_StateMachine *s, GSM_NoteEntry *Note);
1318 /**
1319 * Deletes all notes entries.
1320 */
1321 GSM_Error (*DeleteAllNotes) (GSM_StateMachine *s);
1296 /** 1322 /**
1297 * Reads profile. 1323 * Reads profile.
1298 */ 1324 */
1299 GSM_Error (*GetProfile) (GSM_StateMachine *s, GSM_Profile *Profile); 1325 GSM_Error (*GetProfile) (GSM_StateMachine *s, GSM_Profile *Profile);
1300 /** 1326 /**
1301 * Updates profile. 1327 * Updates profile.
1302 */ 1328 */
1303 GSM_Error (*SetProfile) (GSM_StateMachine *s, GSM_Profile *Profile); 1329 GSM_Error (*SetProfile) (GSM_StateMachine *s, GSM_Profile *Profile);
1304 /** 1330 /**
1305 * Reads FM station. 1331 * Reads FM station.
1306 */ 1332 */
1307 GSM_Error (*GetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation); 1333 GSM_Error (*GetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation);
1308 /** 1334 /**
1309 * Sets FM station. 1335 * Sets FM station.
1310 */ 1336 */
1311 GSM_Error (*SetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation); 1337 GSM_Error (*SetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation);
1312 /** 1338 /**
1313 * Clears defined FM stations. 1339 * Clears defined FM stations.
1314 */ 1340 */
1315 GSM_Error (*ClearFMStations) (GSM_StateMachine *s); 1341 GSM_Error (*ClearFMStations) (GSM_StateMachine *s);
1316 /** 1342 /**
1317 * Gets next filename from filesystem. 1343 * Gets next filename from filesystem.
1318 */ 1344 */
1319 GSM_Error (*GetNextFileFolder) (GSM_StateMachine *s, GSM_File *File, bool start); 1345 GSM_Error (*GetNextFileFolder) (GSM_StateMachine *s, GSM_File *File, bool start);
1320 /** 1346 /**
1321 * Gets file part from filesystem. 1347 * Gets file part from filesystem.
1322 */ 1348 */
1323 GSM_Error (*GetFilePart)(GSM_StateMachine *s, GSM_File *File); 1349 GSM_Error (*GetFilePart)(GSM_StateMachine *s, GSM_File *File);
1324 /** 1350 /**
1325 * Adds file part to filesystem. 1351 * Adds file part to filesystem.
1326 */ 1352 */
1327 GSM_Error (*AddFilePart)(GSM_StateMachine *s, GSM_File *File, int *Pos); 1353 GSM_Error (*AddFilePart)(GSM_StateMachine *s, GSM_File *File, int *Pos);
1328 /** 1354 /**
1329 * Acquires filesystem status. 1355 * Acquires filesystem status.
1330 */ 1356 */
1331 GSM_Error (*GetFileSystemStatus)(GSM_StateMachine *s, GSM_FileSystemStatus *Status); 1357 GSM_Error (*GetFileSystemStatus)(GSM_StateMachine *s, GSM_FileSystemStatus *Status);
1332 /** 1358 /**
1333 * Deletes file from filessytem. 1359 * Deletes file from filessytem.
1334 */ 1360 */
1335 GSM_Error (*DeleteFile) (GSM_StateMachine *s, unsigned char *ID); 1361 GSM_Error (*DeleteFile) (GSM_StateMachine *s, unsigned char *ID);
1336 /** 1362 /**
1337 * Adds folder to filesystem. 1363 * Adds folder to filesystem.
1338 */ 1364 */
1339 GSM_Error (*AddFolder) (GSM_StateMachine *s, GSM_File *File); 1365 GSM_Error (*AddFolder) (GSM_StateMachine *s, GSM_File *File);
1340 /** 1366 /**
1341 * Gets GPRS access point. 1367 * Gets GPRS access point.
1342 */ 1368 */
1343 GSM_Error (*GetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point); 1369 GSM_Error (*GetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point);
1344 /** 1370 /**
1345 * Sets GPRS access point. 1371 * Sets GPRS access point.
1346 */ 1372 */
1347 GSM_Error (*SetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point); 1373 GSM_Error (*SetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point);
1348} GSM_Phone_Functions; 1374} GSM_Phone_Functions;
1349 1375
1350 extern GSM_Phone_Functions NAUTOPhone; 1376 extern GSM_Phone_Functions NAUTOPhone;
1351#ifdef GSM_ENABLE_NOKIA3320 1377#ifdef GSM_ENABLE_NOKIA3320
1352 extern GSM_Phone_Functions N3320Phone; 1378 extern GSM_Phone_Functions N3320Phone;
1353#endif 1379#endif
1354#ifdef GSM_ENABLE_NOKIA3650 1380#ifdef GSM_ENABLE_NOKIA3650
1355 extern GSM_Phone_Functions N3650Phone; 1381 extern GSM_Phone_Functions N3650Phone;
1356#endif 1382#endif
1357#ifdef GSM_ENABLE_NOKIA6110 1383#ifdef GSM_ENABLE_NOKIA6110
1358 extern GSM_Phone_Functions N6110Phone; 1384 extern GSM_Phone_Functions N6110Phone;
1359#endif 1385#endif
1360#ifdef GSM_ENABLE_NOKIA650 1386#ifdef GSM_ENABLE_NOKIA650
1361 extern GSM_Phone_Functions N650Phone; 1387 extern GSM_Phone_Functions N650Phone;
1362#endif 1388#endif
1363#ifdef GSM_ENABLE_NOKIA6510 1389#ifdef GSM_ENABLE_NOKIA6510
1364 extern GSM_Phone_Functions N6510Phone; 1390 extern GSM_Phone_Functions N6510Phone;
1365#endif 1391#endif
1366#ifdef GSM_ENABLE_NOKIA7110 1392#ifdef GSM_ENABLE_NOKIA7110
1367 extern GSM_Phone_Functions N7110Phone; 1393 extern GSM_Phone_Functions N7110Phone;
1368#endif 1394#endif
1369#ifdef GSM_ENABLE_NOKIA9210 1395#ifdef GSM_ENABLE_NOKIA9210
1370 extern GSM_Phone_Functions N9210Phone; 1396 extern GSM_Phone_Functions N9210Phone;
1371#endif 1397#endif
1372#ifdef GSM_ENABLE_ATGEN 1398#ifdef GSM_ENABLE_ATGEN
1373 extern GSM_Phone_Functions ATGENPhone; 1399 extern GSM_Phone_Functions ATGENPhone;
1374#endif 1400#endif
1375#ifdef GSM_ENABLE_ALCATEL 1401#ifdef GSM_ENABLE_ALCATEL
1376 extern GSM_Phone_Functions ALCATELPhone; 1402 extern GSM_Phone_Functions ALCATELPhone;
1377#endif 1403#endif
1378#ifdef GSM_ENABLE_OBEXGEN 1404#ifdef GSM_ENABLE_OBEXGEN
1379 extern GSM_Phone_Functions OBEXGENPhone; 1405 extern GSM_Phone_Functions OBEXGENPhone;
1380#endif 1406#endif
1381#ifdef GSM_ENABLE_MROUTERGEN 1407#ifdef GSM_ENABLE_MROUTERGEN
1382 extern GSM_Phone_Functions MROUTERGENPhone; 1408 extern GSM_Phone_Functions MROUTERGENPhone;
1383#endif 1409#endif
1384 1410
1385typedef struct { 1411typedef struct {
1386 GSM_Phone_Data Data; 1412 GSM_Phone_Data Data;
1387 GSM_Phone_Functions*Functions; 1413 GSM_Phone_Functions*Functions;
1388} GSM_Phone; 1414} GSM_Phone;
1389 1415
1390/* --------------------------- User layer ---------------------------------- */ 1416/* --------------------------- User layer ---------------------------------- */
1391 1417
1392struct _GSM_User { 1418struct _GSM_User {
1393 GSM_Reply_Function *UserReplyFunctions; 1419 GSM_Reply_Function *UserReplyFunctions;
1394 1420
1395 void (*IncomingCall) (char *Device, GSM_Call call); 1421 void (*IncomingCall) (char *Device, GSM_Call call);
1396 void (*IncomingSMS)(char *Device, GSM_SMSMessage sms); 1422 void (*IncomingSMS)(char *Device, GSM_SMSMessage sms);
1397 void (*IncomingCB) (char *Device, GSM_CBMessage cb); 1423 void (*IncomingCB) (char *Device, GSM_CBMessage cb);
1398 void (*IncomingUSSD) (char *Device, char *Text); 1424 void (*IncomingUSSD) (char *Device, char *Text);
1399 void (*SendSMSStatus) (char *Device, int status, int MessageReference); 1425 void (*SendSMSStatus) (char *Device, int status, int MessageReference);
1400}; 1426};
1401 1427
1402/* --------------------------- Statemachine layer -------------------------- */ 1428/* --------------------------- Statemachine layer -------------------------- */
1403 1429
1404typedef enum { 1430typedef enum {
1405 GCT_MBUS2=1, 1431 GCT_MBUS2=1,
1406 GCT_FBUS2, 1432 GCT_FBUS2,
1407 GCT_FBUS2DLR3, 1433 GCT_FBUS2DLR3,
1408 GCT_FBUS2DKU5, 1434 GCT_FBUS2DKU5,
1409 GCT_FBUS2PL2303, 1435 GCT_FBUS2PL2303,
1410 GCT_FBUS2BLUE, 1436 GCT_FBUS2BLUE,
1411 GCT_FBUS2IRDA, 1437 GCT_FBUS2IRDA,
1412 GCT_PHONETBLUE, 1438 GCT_PHONETBLUE,
1413 GCT_AT, 1439 GCT_AT,
1414 GCT_MROUTERBLUE, 1440 GCT_MROUTERBLUE,
1415 1441
1416 GCT_IRDAOBEX, 1442 GCT_IRDAOBEX,
1417 GCT_IRDAAT, 1443 GCT_IRDAAT,
1418 GCT_IRDAPHONET, 1444 GCT_IRDAPHONET,
1419 GCT_BLUEFBUS2, 1445 GCT_BLUEFBUS2,
1420 GCT_BLUEAT, 1446 GCT_BLUEAT,
1421 GCT_BLUEPHONET, 1447 GCT_BLUEPHONET,
1422 GCT_BLUEOBEX 1448 GCT_BLUEOBEX
1423} GSM_ConnectionType; 1449} GSM_ConnectionType;
1424 1450
1425typedef struct { 1451typedef struct {
1426 /* Config file (or Registry or...) variables */ 1452 /* Config file (or Registry or...) variables */
1427 char Model[50]; /* Model from config file */ 1453 char Model[50]; /* Model from config file */
1428 char DebugLevel[50]; /* Debug level */ 1454 char DebugLevel[50]; /* Debug level */
1429 char *Device; /* Device name from config file */ 1455 char *Device; /* Device name from config file */
1430 char *Connection; /* Connection type as string */ 1456 char *Connection; /* Connection type as string */
1431 char *SyncTime; /* Synchronize time on startup? */ 1457 char *SyncTime; /* Synchronize time on startup? */
1432 char *LockDevice; /* Lock device ? (Unix) */ 1458 char *LockDevice; /* Lock device ? (Unix) */
1433 char *DebugFile; /* Name of debug file */ 1459 char *DebugFile; /* Name of debug file */
1434 char *Localize; /* Name of localisation file */ 1460 char *Localize; /* Name of localisation file */
1435 char *StartInfo; /* Display something during start ? */ 1461 char *StartInfo; /* Display something during start ? */
1436 bool UseGlobalDebugFile;/* Should we use global debug file?*/ 1462 bool UseGlobalDebugFile;/* Should we use global debug file?*/
1437 bool DefaultModel; 1463 bool DefaultModel;
1438 bool DefaultDebugLevel; 1464 bool DefaultDebugLevel;
1439 bool DefaultDevice; 1465 bool DefaultDevice;
1440 bool DefaultConnection; 1466 bool DefaultConnection;
1441 bool DefaultSyncTime; 1467 bool DefaultSyncTime;
1442 bool DefaultLockDevice; 1468 bool DefaultLockDevice;
1443 bool DefaultDebugFile; 1469 bool DefaultDebugFile;
1444 bool DefaultLocalize; 1470 bool DefaultLocalize;
1445 bool DefaultStartInfo; 1471 bool DefaultStartInfo;
1446} GSM_Config; 1472} GSM_Config;
1447 1473
1448 #define MAX_CONFIG_NUM 5 1474 #define MAX_CONFIG_NUM 5
1449 1475
1450struct _GSM_StateMachine { 1476struct _GSM_StateMachine {
1451 GSM_ConnectionType ConnectionType; /* Type of connection as int */ 1477 GSM_ConnectionType ConnectionType; /* Type of connection as int */
1452 char *LockFile; /* Lock file name for Unix */ 1478 char *LockFile; /* Lock file name for Unix */
1453 Debug_Info di; /* Debug information */ 1479 Debug_Info di; /* Debug information */
1454 bool opened; /* Is connection opened ? */ 1480 bool opened; /* Is connection opened ? */
1455 GSM_Config Config[MAX_CONFIG_NUM + 1]; 1481 GSM_Config Config[MAX_CONFIG_NUM + 1];
1456 GSM_Config *CurrentConfig; /* Config file (or Registry or...) variables */ 1482 GSM_Config *CurrentConfig; /* Config file (or Registry or...) variables */
1457 int ConfigNum; 1483 int ConfigNum;
1458 INI_Section *msg; /* Localisation strings structure */ 1484 INI_Section *msg; /* Localisation strings structure */
1459 int ReplyNum; /* How many times make sth. */ 1485 int ReplyNum; /* How many times make sth. */
1460 int Speed; /* For some protocols used speed */ 1486 int Speed; /* For some protocols used speed */
1461 1487
1462 GSM_Device Device; 1488 GSM_Device Device;
1463 GSM_Protocol Protocol; 1489 GSM_Protocol Protocol;
1464 GSM_Phone Phone; 1490 GSM_Phone Phone;
1465 GSM_User User; 1491 GSM_User User;
1466}; 1492};
1467 1493
1468/* ------------------------ Other general definitions ---------------------- */ 1494/* ------------------------ Other general definitions ---------------------- */
1469 1495
1470 GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s); 1496 GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s);
1471 1497
1472 GSM_Error GSM_InitConnection (GSM_StateMachine *s, int ReplyNum); 1498 GSM_Error GSM_InitConnection (GSM_StateMachine *s, int ReplyNum);
1473 GSM_Error GSM_TerminateConnection(GSM_StateMachine *s); 1499 GSM_Error GSM_TerminateConnection(GSM_StateMachine *s);
1474 1500
1475 int GSM_ReadDevice (GSM_StateMachine *s, bool wait); 1501 int GSM_ReadDevice (GSM_StateMachine *s, bool wait);
1476 1502
1477 GSM_Error GSM_WaitForOnce (GSM_StateMachine *s, unsigned char *buffer, 1503 GSM_Error GSM_WaitForOnce (GSM_StateMachine *s, unsigned char *buffer,
1478 int length, unsigned char type, int time); 1504 int length, unsigned char type, int time);
1479 1505
1480 GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer, 1506 GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer,
1481 int length, unsigned char type, int time, 1507 int length, unsigned char type, int time,
1482 GSM_Phone_RequestID request); 1508 GSM_Phone_RequestID request);
1483 1509
1484 GSM_Error GSM_DispatchMessage (GSM_StateMachine *s); 1510 GSM_Error GSM_DispatchMessage (GSM_StateMachine *s);
1485 1511
1486 INI_Section *GSM_FindGammuRC(void); 1512 INI_Section *GSM_FindGammuRC(void);
1487 1513
1488 bool GSM_ReadConfig (INI_Section *cfg_info, GSM_Config *cfg, int num); 1514 bool GSM_ReadConfig (INI_Section *cfg_info, GSM_Config *cfg, int num);
1489 1515
1490 void GSM_DumpMessageLevel2 (GSM_StateMachine *s, unsigned char *message, int messagesize, int type); 1516 void GSM_DumpMessageLevel2 (GSM_StateMachine *s, unsigned char *message, int messagesize, int type);
1491 void GSM_DumpMessageLevel3 (GSM_StateMachine *s, unsigned char *message, int messagesize, int type); 1517 void GSM_DumpMessageLevel3 (GSM_StateMachine *s, unsigned char *message, int messagesize, int type);
1492 1518
1493/* ---------------------- Phone features ----------------------------------- */ 1519/* ---------------------- Phone features ----------------------------------- */
1494 1520
1495typedef enum { 1521typedef enum {
1496 /* n6110.c */ 1522 /* n6110.c */
1497 F_CAL33 = 1, /* Calendar,3310 style - 10 reminders, Unicode, 3 coding types*/ 1523 F_CAL33 = 1, /* Calendar,3310 style - 10 reminders, Unicode, 3 coding types*/
1498 F_CAL52, /* Calendar,5210 style - full Unicode, etc. */ 1524 F_CAL52, /* Calendar,5210 style - full Unicode, etc. */
1499 F_CAL82, /* Calendar,8250 style - "normal", but with Unicode */ 1525 F_CAL82, /* Calendar,8250 style - "normal", but with Unicode */
1500 F_RING_SM, /* Ringtones returned in SM format - 33xx */ 1526 F_RING_SM, /* Ringtones returned in SM format - 33xx */
1501 F_NORING, /* No ringtones */ 1527 F_NORING, /* No ringtones */
1502 F_NOPBKUNICODE, /* No phonebook in Unicode */ 1528 F_NOPBKUNICODE, /* No phonebook in Unicode */
1503 F_NOWAP, /* No WAP */ 1529 F_NOWAP, /* No WAP */
1504 F_NOCALLER, /* No caller groups */ 1530 F_NOCALLER, /* No caller groups */
1505 F_NOPICTURE, /* No Picture Images */ 1531 F_NOPICTURE, /* No Picture Images */
1506 F_NOPICTUREUNI, /* No Picture Images text in Unicode */ 1532 F_NOPICTUREUNI, /* No Picture Images text in Unicode */
1507 F_NOSTARTUP, /* No startup logo */ 1533 F_NOSTARTUP, /* No startup logo */
1508 F_NOCALENDAR, /* No calendar */ 1534 F_NOCALENDAR, /* No calendar */
1509 F_NOSTARTANI, /* Startup logo is not animated */ 1535 F_NOSTARTANI, /* Startup logo is not animated */
1510 F_POWER_BATT, /* Network and battery level get from netmonitor */ 1536 F_POWER_BATT, /* Network and battery level get from netmonitor */
1511 F_PROFILES33, /* Phone profiles in 3310 style */ 1537 F_PROFILES33, /* Phone profiles in 3310 style */
1512 F_PROFILES51, /* Phone profiles in 5110 style */ 1538 F_PROFILES51, /* Phone profiles in 5110 style */
1513 F_MAGICBYTES, /* Phone can make authentication with magic bytes */ 1539 F_MAGICBYTES, /* Phone can make authentication with magic bytes */
1514 F_NODTMF, /* Phone can't send DTMF */ 1540 F_NODTMF, /* Phone can't send DTMF */
1515 F_DISPSTATUS, /* Phone return display status */ 1541 F_DISPSTATUS, /* Phone return display status */
1516 F_NOCALLINFO, 1542 F_NOCALLINFO,
1517 1543
1518 /* n3320.c */ 1544 /* n3320.c */
1519 F_DAYMONTH, /* Day and month reversed in pbk, when compare to GSM models*/ 1545 F_DAYMONTH, /* Day and month reversed in pbk, when compare to GSM models*/
1520 1546
1521 /* n6510.c */ 1547 /* n6510.c */
1522 F_PBK35, /* Phonebook in 3510 style with ringtones ID */ 1548 F_PBK35, /* Phonebook in 3510 style with ringtones ID */
1523 F_PBKIMG, /* Phonebook in 7250 style with picture ID */ 1549 F_PBKIMG, /* Phonebook in 7250 style with picture ID */
1524 F_PBKTONEGAL,/* Phonebook with selecting ringtones from gallery */ 1550 F_PBKTONEGAL,/* Phonebook with selecting ringtones from gallery */
1525 F_PBKSMSLIST, /* Phonebook with SMS list */ 1551 F_PBKSMSLIST, /* Phonebook with SMS list */
1526 F_PBKUSER, /* Phonebook with user ID */ 1552 F_PBKUSER, /* Phonebook with user ID */
1527 F_RADIO, /* Phone with FM radio */ 1553 F_RADIO, /* Phone with FM radio */
1528 F_TODO63, /* ToDo in 6310 style - 0x55 msg type */ 1554 F_TODO63, /* ToDo in 6310 style - 0x55 msg type */
1529 F_TODO66, /* ToDo in 6610 style - like calendar, with date and other*/ 1555 F_TODO66, /* ToDo in 6610 style - like calendar, with date and other*/
1530 F_NOMIDI, /* No ringtones in MIDI */ 1556 F_NOMIDI, /* No ringtones in MIDI */
1531 F_BLUETOOTH, /* Bluetooth support */ 1557 F_BLUETOOTH, /* Bluetooth support */
1532 F_NOFILESYSTEM, /* No images, ringtones, java saved in special filesystem*/ 1558 F_NOFILESYSTEM, /* No images, ringtones, java saved in special filesystem*/
1533 F_NOMMS, /* No MMS sets in phone */ 1559 F_NOMMS, /* No MMS sets in phone */
1534 F_NOGPRSPOINT, /* GPRS point are not useable */ 1560 F_NOGPRSPOINT, /* GPRS point are not useable */
1535 F_CAL35, /* Calendar,3510 style - Reminder,Call,Birthday */ 1561 F_CAL35, /* Calendar,3510 style - Reminder,Call,Birthday */
1536 F_CAL65, /* Calendar,6510 style - CBMM, method 3 */ 1562 F_CAL65, /* Calendar,6510 style - CBMM, method 3 */
1537 F_WAPMMSPROXY, /* WAP & MMS settings contains first & second proxy */ 1563 F_WAPMMSPROXY, /* WAP & MMS settings contains first & second proxy */
1538 1564
1539 /* n6510.c && n7110.c */ 1565 /* n6510.c && n7110.c */
1540 F_VOICETAGS, /* Voice tags available */ 1566 F_VOICETAGS, /* Voice tags available */
1541 F_CAL62, /* Calendar,6210 style - Call,Birthday,Memo,Meeting */ 1567 F_CAL62, /* Calendar,6210 style - Call,Birthday,Memo,Meeting */
1542 F_NOTES, 1568 F_NOTES,
1543 1569
1544 /* AT modules */ 1570 /* AT modules */
1545 F_SMSONLYSENT, /* Phone supports only sent/unsent messages */ 1571 F_SMSONLYSENT, /* Phone supports only sent/unsent messages */
1546 F_BROKENCPBS, /* CPBS on some memories can hang phone */ 1572 F_BROKENCPBS, /* CPBS on some memories can hang phone */
1547 F_M20SMS, /* Siemens M20 like SMS handling */ 1573 F_M20SMS, /* Siemens M20 like SMS handling */
1548 F_SLOWWRITE, /* Use slower writing which some phone need */ 1574 F_SLOWWRITE, /* Use slower writing which some phone need */
1549 F_SMSME900, /* SMS in ME start from location 900 - case of Sagem */ 1575 F_SMSME900, /* SMS in ME start from location 900 - case of Sagem */
1550 F_ALCATEL /* Phone supports Alcatel protocol */ 1576 F_ALCATEL /* Phone supports Alcatel protocol */
1551} Feature; 1577} Feature;
1552 1578
1553/* For models table */ 1579/* For models table */
1554struct _OnePhoneModel { 1580struct _OnePhoneModel {
1555 char *model; 1581 char *model;
1556 char *number; 1582 char *number;
1557 char *irdamodel; 1583 char *irdamodel;
1558 Feature features[12]; 1584 Feature features[12];
1559}; 1585};
1560 1586
1561 bool IsPhoneFeatureAvailable(OnePhoneModel *model, Feature feature); 1587 bool IsPhoneFeatureAvailable(OnePhoneModel *model, Feature feature);
1562 OnePhoneModel *GetModelData (char *model, char *number, char *irdamodel); 1588 OnePhoneModel *GetModelData (char *model, char *number, char *irdamodel);
1563 1589
1564#ifdef __GNUC__ 1590#ifdef __GNUC__
1565__attribute__((format(printf, 2, 3))) 1591__attribute__((format(printf, 2, 3)))
1566#endif 1592#endif
1567int smprintf(GSM_StateMachine *s, const char *format, ...); 1593int smprintf(GSM_StateMachine *s, const char *format, ...);
1568 1594
1569void GSM_OSErrorInfo(GSM_StateMachine *s, char *description); 1595void GSM_OSErrorInfo(GSM_StateMachine *s, char *description);
1570 1596
1571#ifdef GSM_ENABLE_BACKUP 1597#ifdef GSM_ENABLE_BACKUP
1572void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info); 1598void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info);
1573#endif 1599#endif
1574 1600
1575#endif 1601#endif
1576 1602
1577/* How should editor hadle tabs in this file? Add editor commands here. 1603/* How should editor hadle tabs in this file? Add editor commands here.
1578 * vim: noexpandtab sw=8 ts=8 sts=8: 1604 * vim: noexpandtab sw=8 ts=8 sts=8:
1579 */ 1605 */
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c
index 3821f13..b75077f 100644
--- a/gammu/emb/common/phone/alcatel/alcatel.c
+++ b/gammu/emb/common/phone/alcatel/alcatel.c
@@ -3598,406 +3598,412 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3598 default: 3598 default:
3599 val = 1; 3599 val = 1;
3600 break; 3600 break;
3601 } 3601 }
3602 /* This one seems to be byte for BF5 and enum for BE5 */ 3602 /* This one seems to be byte for BF5 and enum for BE5 */
3603 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 3603 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
3604 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error; 3604 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error;
3605 } else { 3605 } else {
3606 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error; 3606 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error;
3607 } 3607 }
3608 UpdatedFields[7] = true; 3608 UpdatedFields[7] = true;
3609 3609
3610 for (i = 0; i < ToDo->EntriesNum; i++) { 3610 for (i = 0; i < ToDo->EntriesNum; i++) {
3611 switch (ToDo->Entries[i].EntryType) { 3611 switch (ToDo->Entries[i].EntryType) {
3612 case TODO_END_DATETIME: 3612 case TODO_END_DATETIME:
3613 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3613 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3614 UpdatedFields[0] = true; 3614 UpdatedFields[0] = true;
3615 break; 3615 break;
3616 case TODO_COMPLETED: 3616 case TODO_COMPLETED:
3617 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3617 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3618 UpdatedFields[1] = true; 3618 UpdatedFields[1] = true;
3619 break; 3619 break;
3620 case TODO_ALARM_DATETIME: 3620 case TODO_ALARM_DATETIME:
3621 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3621 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3622 UpdatedFields[2] = true; 3622 UpdatedFields[2] = true;
3623 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3623 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3624 UpdatedFields[3] = true; 3624 UpdatedFields[3] = true;
3625 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3625 if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3626 UpdatedFields[10] = true; 3626 UpdatedFields[10] = true;
3627 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3627 if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3628 UpdatedFields[11] = true; 3628 UpdatedFields[11] = true;
3629 break; 3629 break;
3630 case TODO_TEXT: 3630 case TODO_TEXT:
3631 if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3631 if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3632 UpdatedFields[4] = true; 3632 UpdatedFields[4] = true;
3633 break; 3633 break;
3634 case TODO_PRIVATE: 3634 case TODO_PRIVATE:
3635 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3635 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3636 UpdatedFields[5] = true; 3636 UpdatedFields[5] = true;
3637 break; 3637 break;
3638 case TODO_CATEGORY: 3638 case TODO_CATEGORY:
3639 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3639 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3640 UpdatedFields[6] = true; 3640 UpdatedFields[6] = true;
3641 break; 3641 break;
3642 case TODO_CONTACTID: 3642 case TODO_CONTACTID:
3643 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3643 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3644 UpdatedFields[8] = true; 3644 UpdatedFields[8] = true;
3645 contact_set = true; 3645 contact_set = true;
3646 break; 3646 break;
3647 case TODO_PHONE: 3647 case TODO_PHONE:
3648 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3648 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3649 UpdatedFields[9] = true; 3649 UpdatedFields[9] = true;
3650 phone_set = true; 3650 phone_set = true;
3651 break; 3651 break;
3652 default: 3652 default:
3653 break; 3653 break;
3654 } 3654 }
3655 } 3655 }
3656 if (!contact_set) { 3656 if (!contact_set) {
3657 if (phone_set) { 3657 if (phone_set) {
3658 val = 0xffffffff; 3658 val = 0xffffffff;
3659 } else { 3659 } else {
3660 val = 0; 3660 val = 0;
3661 } 3661 }
3662 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &val)) != ERR_NONE) return error; 3662 if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &val)) != ERR_NONE) return error;
3663 UpdatedFields[8] = true; 3663 UpdatedFields[8] = true;
3664 } 3664 }
3665 3665
3666 3666
3667 /* If we didn't update some field, we have to delete it... */ 3667 /* If we didn't update some field, we have to delete it... */
3668 for (i=0; i<Priv->CurrentFieldsCount; i++) { 3668 for (i=0; i<Priv->CurrentFieldsCount; i++) {
3669 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, ToDo->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; 3669 if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, ToDo->Location, Priv->CurrentFields[i])) != ERR_NONE) return error;
3670 } 3670 }
3671 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3671 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3672 return ERR_NONE; 3672 return ERR_NONE;
3673} 3673}
3674 3674
3675static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3675static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3676{ 3676{
3677 GSM_Error error; 3677 GSM_Error error;
3678 3678
3679 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3679 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3680 /* Delete ToDo */ 3680 /* Delete ToDo */
3681 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3681 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3682 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { 3682 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) {
3683 /* Entry was empty => no error */ 3683 /* Entry was empty => no error */
3684 return ERR_NONE; 3684 return ERR_NONE;
3685 } 3685 }
3686 error = ALCATEL_DeleteItem(s, ToDo->Location); 3686 error = ALCATEL_DeleteItem(s, ToDo->Location);
3687 if (error != ERR_NONE) return error; 3687 if (error != ERR_NONE) return error;
3688 /* Refresh list */ 3688 /* Refresh list */
3689 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3689 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3690 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3690 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3691 return ERR_NONE; 3691 return ERR_NONE;
3692} 3692}
3693 3693
3694static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status) 3694static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status)
3695{ 3695{
3696 GSM_Alcatel_BinaryTypetype; 3696 GSM_Alcatel_BinaryTypetype;
3697 GSM_Error error; 3697 GSM_Error error;
3698 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3698 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3699 3699
3700 switch (Status->Type) { 3700 switch (Status->Type) {
3701 case Category_ToDo: type = TypeToDo; break; 3701 case Category_ToDo: type = TypeToDo; break;
3702 case Category_Phonebook: type = TypeContacts; break; 3702 case Category_Phonebook: type = TypeContacts; break;
3703 default: return ERR_NOTSUPPORTED; 3703 default: return ERR_NOTSUPPORTED;
3704 } 3704 }
3705 if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; 3705 if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error;
3706 if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error; 3706 if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error;
3707 3707
3708 Status->Used = Priv->CurrentCategoriesCount; 3708 Status->Used = Priv->CurrentCategoriesCount;
3709 3709
3710 return ERR_NONE; 3710 return ERR_NONE;
3711} 3711}
3712 3712
3713static GSM_Error ALCATEL_GetCategory(GSM_StateMachine *s, GSM_Category *Category) 3713static GSM_Error ALCATEL_GetCategory(GSM_StateMachine *s, GSM_Category *Category)
3714{ 3714{
3715 GSM_Alcatel_BinaryTypetype; 3715 GSM_Alcatel_BinaryTypetype;
3716 GSM_Error error; 3716 GSM_Error error;
3717 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3717 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3718 3718
3719 switch (Category->Type) { 3719 switch (Category->Type) {
3720 case Category_ToDo: type = TypeToDo; break; 3720 case Category_ToDo: type = TypeToDo; break;
3721 case Category_Phonebook: type = TypeContacts; break; 3721 case Category_Phonebook: type = TypeContacts; break;
3722 default: return ERR_NOTSUPPORTED; 3722 default: return ERR_NOTSUPPORTED;
3723 } 3723 }
3724 if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; 3724 if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error;
3725 if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error; 3725 if ((error = ALCATEL_GetAvailableCategoryIds(s))!= ERR_NONE) return error;
3726 if ((error = ALCATEL_IsCategoryIdAvailable(s, Category->Location))!= ERR_NONE) return error; 3726 if ((error = ALCATEL_IsCategoryIdAvailable(s, Category->Location))!= ERR_NONE) return error;
3727 if ((error = ALCATEL_GetCategoryText(s, Category->Location))!= ERR_NONE) return error; 3727 if ((error = ALCATEL_GetCategoryText(s, Category->Location))!= ERR_NONE) return error;
3728 3728
3729 CopyUnicodeString(Category->Name, Priv->ReturnString); 3729 CopyUnicodeString(Category->Name, Priv->ReturnString);
3730 3730
3731 return ERR_NONE; 3731 return ERR_NONE;
3732} 3732}
3733 3733
3734static GSM_Error ALCATEL_AddCategory(GSM_StateMachine *s, GSM_Category *Category) 3734static GSM_Error ALCATEL_AddCategory(GSM_StateMachine *s, GSM_Category *Category)
3735{ 3735{
3736 GSM_Alcatel_BinaryTypetype; 3736 GSM_Alcatel_BinaryTypetype;
3737 GSM_Error error; 3737 GSM_Error error;
3738 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3738 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3739 3739
3740 switch (Category->Type) { 3740 switch (Category->Type) {
3741 case Category_ToDo: type = TypeToDo; break; 3741 case Category_ToDo: type = TypeToDo; break;
3742 case Category_Phonebook: type = TypeContacts; break; 3742 case Category_Phonebook: type = TypeContacts; break;
3743 default: return ERR_NOTSUPPORTED; 3743 default: return ERR_NOTSUPPORTED;
3744 } 3744 }
3745 if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error; 3745 if ((error = ALCATEL_GoToBinaryState(s, StateSession, type, 0))!= ERR_NONE) return error;
3746 if ((error = ALCATEL_AddCategoryText(s, Category->Name))!= ERR_NONE) return error; 3746 if ((error = ALCATEL_AddCategoryText(s, Category->Name))!= ERR_NONE) return error;
3747 3747
3748 Category->Location = Priv->ReturnInt; 3748 Category->Location = Priv->ReturnInt;
3749 3749
3750 return ERR_NONE; 3750 return ERR_NONE;
3751} 3751}
3752 3752
3753static GSM_Error ALCATEL_GetProductCode(GSM_StateMachine *s, char *value) 3753static GSM_Error ALCATEL_GetProductCode(GSM_StateMachine *s, char *value)
3754{ 3754{
3755 strcpy(value, s->Phone.Data.ModelInfo->model); 3755 strcpy(value, s->Phone.Data.ModelInfo->model);
3756 return ERR_NONE; 3756 return ERR_NONE;
3757} 3757}
3758 3758
3759static GSM_Error ALCATEL_DispatchMessage(GSM_StateMachine *s) 3759static GSM_Error ALCATEL_DispatchMessage(GSM_StateMachine *s)
3760{ 3760{
3761 if (s->Phone.Data.Priv.ALCATEL.Mode == ModeBinary) { 3761 if (s->Phone.Data.Priv.ALCATEL.Mode == ModeBinary) {
3762 return GSM_DispatchMessage(s); 3762 return GSM_DispatchMessage(s);
3763 } else { 3763 } else {
3764 return ATGEN_DispatchMessage(s); 3764 return ATGEN_DispatchMessage(s);
3765 } 3765 }
3766} 3766}
3767 3767
3768static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine *s) 3768static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine *s)
3769{ 3769{
3770 /* All error values are just VERY wild guesses, but these seems to work 3770 /* All error values are just VERY wild guesses, but these seems to work
3771 * almost as expected ... 3771 * almost as expected ...
3772 */ 3772 */
3773 switch (msg.Buffer[8]) { 3773 switch (msg.Buffer[8]) {
3774 case 0x00: /* no error */ 3774 case 0x00: /* no error */
3775 return ERR_NONE; 3775 return ERR_NONE;
3776 case 0x10: /* same thing opened in phone menus */ 3776 case 0x10: /* same thing opened in phone menus */
3777 return ERR_INSIDEPHONEMENU; 3777 return ERR_INSIDEPHONEMENU;
3778 case 0x13: 3778 case 0x13:
3779 /* This appears in more cases: 3779 /* This appears in more cases:
3780 *- phone needs PIN code 3780 *- phone needs PIN code
3781 *- we want to close not opened session 3781 *- we want to close not opened session
3782 * For normal users the second case shouldn't occur... 3782 * For normal users the second case shouldn't occur...
3783 */ 3783 */
3784 return ERR_SECURITYERROR; 3784 return ERR_SECURITYERROR;
3785 case 0x14: /* Bad data */ 3785 case 0x14: /* Bad data */
3786 case 0x2f: /* Closing session when not opened */ 3786 case 0x2f: /* Closing session when not opened */
3787 case 0x1f: /* Bad in/out counter in packet/ack */ 3787 case 0x1f: /* Bad in/out counter in packet/ack */
3788 case 0x0e: /* Openning session when not closed */ 3788 case 0x0e: /* Openning session when not closed */
3789 case 0x0C: /* Bad id (item/database) */ 3789 case 0x0C: /* Bad id (item/database) */
3790 case 0x11: /* Bad list id */ 3790 case 0x11: /* Bad list id */
3791 case 0x2A: /* Nonexistant field/item id */ 3791 case 0x2A: /* Nonexistant field/item id */
3792 case 0x35: /* Too long text */ 3792 case 0x35: /* Too long text */
3793 return ERR_BUG; 3793 return ERR_BUG;
3794 case 0x23: /* Session opened */ 3794 case 0x23: /* Session opened */
3795 case 0x80: /* Transfer started */ 3795 case 0x80: /* Transfer started */
3796 return ERR_NONE; 3796 return ERR_NONE;
3797 case 0x82: /* Transfer canceled */ 3797 case 0x82: /* Transfer canceled */
3798 return ERR_CANCELED; 3798 return ERR_CANCELED;
3799 default: 3799 default:
3800 smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]); 3800 smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]);
3801 return ERR_NONE; 3801 return ERR_NONE;
3802 } 3802 }
3803} 3803}
3804 3804
3805static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) 3805static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s)
3806{ 3806{
3807 s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24); 3807 s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24);
3808 smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord); 3808 smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord);
3809 return ERR_NONE; 3809 return ERR_NONE;
3810} 3810}
3811 3811
3812static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) 3812static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable)
3813{ 3813{
3814 GSM_Error error; 3814 GSM_Error error;
3815 3815
3816 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3816 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3817 return ATGEN_SetIncomingCB(s, enable); 3817 return ATGEN_SetIncomingCB(s, enable);
3818} 3818}
3819 3819
3820static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) 3820static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable)
3821{ 3821{
3822 GSM_Error error; 3822 GSM_Error error;
3823 3823
3824 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3824 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3825 return ATGEN_SetIncomingSMS(s, enable); 3825 return ATGEN_SetIncomingSMS(s, enable);
3826} 3826}
3827 3827
3828static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable) 3828static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3829{ 3829{
3830 GSM_Error error; 3830 GSM_Error error;
3831 3831
3832 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3832 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3833 return ATGEN_SetFastSMSSending(s, enable); 3833 return ATGEN_SetFastSMSSending(s, enable);
3834} 3834}
3835 3835
3836static GSM_Reply_Function ALCATELReplyFunctions[] = { 3836static GSM_Reply_Function ALCATELReplyFunctions[] = {
3837 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, 3837 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach },
3838 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, 3838 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach },
3839 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, 3839 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit },
3840 {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, 3840 {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 },
3841 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, 3841 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd },
3842 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, 3842 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose },
3843 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, 3843 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart },
3844 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, 3844 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 },
3845 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, 3845 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 },
3846 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, 3846 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 },
3847 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, 3847 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 },
3848 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, 3848 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 },
3849 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, 3849 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 },
3850 {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, 3850 {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 },
3851 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1}, 3851 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1},
3852 {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2}, 3852 {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2},
3853 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1}, 3853 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1},
3854 {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2}, 3854 {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2},
3855 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1}, 3855 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1},
3856 {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2}, 3856 {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2},
3857 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, 3857 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 },
3858 {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, 3858 {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 },
3859 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1}, 3859 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1},
3860 {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2}, 3860 {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2},
3861 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, 3861 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField },
3862 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, 3862 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 },
3863 {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, 3863 {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 },
3864 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, 3864 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField },
3865 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, 3865 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField },
3866 {NULL, "\x00",0x00,0x00, ID_None } 3866 {NULL, "\x00",0x00,0x00, ID_None }
3867}; 3867};
3868 3868
3869GSM_Phone_Functions ALCATELPhone = { 3869GSM_Phone_Functions ALCATELPhone = {
3870 /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all 3870 /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all
3871 * they were ever really released, if yes add them here also. 3871 * they were ever really released, if yes add them here also.
3872 */ 3872 */
3873 "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", 3873 "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4",
3874 ALCATELReplyFunctions, 3874 ALCATELReplyFunctions,
3875 ALCATEL_Initialise, 3875 ALCATEL_Initialise,
3876 ALCATEL_Terminate, 3876 ALCATEL_Terminate,
3877 ALCATEL_DispatchMessage, 3877 ALCATEL_DispatchMessage,
3878 NOTSUPPORTED, /* ShowStartInfo */ 3878 NOTSUPPORTED, /* ShowStartInfo */
3879 ALCATEL_GetManufacturer, 3879 ALCATEL_GetManufacturer,
3880 ALCATEL_GetModel, 3880 ALCATEL_GetModel,
3881 ALCATEL_GetFirmware, 3881 ALCATEL_GetFirmware,
3882 ALCATEL_GetIMEI, 3882 ALCATEL_GetIMEI,
3883 NOTSUPPORTED, /* GetOriginalIMEI */ 3883 NOTSUPPORTED, /* GetOriginalIMEI */
3884 NOTSUPPORTED, /* GetManufactureMonth*/ 3884 NOTSUPPORTED, /* GetManufactureMonth*/
3885 ALCATEL_GetProductCode, 3885 ALCATEL_GetProductCode,
3886 NOTSUPPORTED, /* GetHardware */ 3886 NOTSUPPORTED, /* GetHardware */
3887 NOTSUPPORTED, /* GetPPM */ 3887 NOTSUPPORTED, /* GetPPM */
3888 ALCATEL_GetSIMIMSI, 3888 ALCATEL_GetSIMIMSI,
3889 ALCATEL_GetDateTime, 3889 ALCATEL_GetDateTime,
3890 ALCATEL_SetDateTime, 3890 ALCATEL_SetDateTime,
3891 ALCATEL_GetAlarm, 3891 ALCATEL_GetAlarm,
3892 ALCATEL_SetAlarm, 3892 ALCATEL_SetAlarm,
3893 NOTSUPPORTED, /* GetLocale */ 3893 NOTSUPPORTED, /* GetLocale */
3894 NOTSUPPORTED, /* SetLocale */ 3894 NOTSUPPORTED, /* SetLocale */
3895 ALCATEL_PressKey, 3895 ALCATEL_PressKey,
3896 ALCATEL_Reset, 3896 ALCATEL_Reset,
3897 ALCATEL_ResetPhoneSettings, 3897 ALCATEL_ResetPhoneSettings,
3898 ALCATEL_EnterSecurityCode, 3898 ALCATEL_EnterSecurityCode,
3899 ALCATEL_GetSecurityStatus, 3899 ALCATEL_GetSecurityStatus,
3900 ALCATEL_GetDisplayStatus, 3900 ALCATEL_GetDisplayStatus,
3901 ALCATEL_SetAutoNetworkLogin, 3901 ALCATEL_SetAutoNetworkLogin,
3902 ALCATEL_GetBatteryCharge, 3902 ALCATEL_GetBatteryCharge,
3903 ALCATEL_GetSignalStrength, 3903 ALCATEL_GetSignalStrength,
3904 ALCATEL_GetNetworkInfo, 3904 ALCATEL_GetNetworkInfo,
3905 ALCATEL_GetCategory, 3905 ALCATEL_GetCategory,
3906 ALCATEL_AddCategory, 3906 ALCATEL_AddCategory,
3907 ALCATEL_GetCategoryStatus, 3907 ALCATEL_GetCategoryStatus,
3908 ALCATEL_GetMemoryStatus, 3908 ALCATEL_GetMemoryStatus,
3909 ALCATEL_GetMemory, 3909 ALCATEL_GetMemory,
3910 ALCATEL_GetNextMemory, 3910 ALCATEL_GetNextMemory,
3911 ALCATEL_SetMemory, 3911 ALCATEL_SetMemory,
3912 ALCATEL_AddMemory, 3912 ALCATEL_AddMemory,
3913 ALCATEL_DeleteMemory, 3913 ALCATEL_DeleteMemory,
3914 ALCATEL_DeleteAllMemory, 3914 ALCATEL_DeleteAllMemory,
3915 NOTSUPPORTED, /* GetSpeedDial */ 3915 NOTSUPPORTED, /* GetSpeedDial */
3916 NOTSUPPORTED, /* SetSpeedDial */ 3916 NOTSUPPORTED, /* SetSpeedDial */
3917 ALCATEL_GetSMSC, 3917 ALCATEL_GetSMSC,
3918 ALCATEL_SetSMSC, 3918 ALCATEL_SetSMSC,
3919 ALCATEL_GetSMSStatus, 3919 ALCATEL_GetSMSStatus,
3920 ALCATEL_GetSMS, 3920 ALCATEL_GetSMS,
3921 ALCATEL_GetNextSMS, 3921 ALCATEL_GetNextSMS,
3922 NOTSUPPORTED, /* SetSMS */ 3922 NOTSUPPORTED, /* SetSMS */
3923 ALCATEL_AddSMS, 3923 ALCATEL_AddSMS,
3924 ALCATEL_DeleteSMS, 3924 ALCATEL_DeleteSMS,
3925 ALCATEL_SendSMS, 3925 ALCATEL_SendSMS,
3926 ALCATEL_SendSavedSMS, 3926 ALCATEL_SendSavedSMS,
3927 ALCATEL_SetFastSMSSending, 3927 ALCATEL_SetFastSMSSending,
3928 ALCATEL_SetIncomingSMS, 3928 ALCATEL_SetIncomingSMS,
3929 ALCATEL_SetIncomingCB, 3929 ALCATEL_SetIncomingCB,
3930 ALCATEL_GetSMSFolders, 3930 ALCATEL_GetSMSFolders,
3931 NOTSUPPORTED, /* AddSMSFolder */ 3931 NOTSUPPORTED, /* AddSMSFolder */
3932 NOTSUPPORTED, /* DeleteSMSFolder */ 3932 NOTSUPPORTED, /* DeleteSMSFolder */
3933 ALCATEL_DialVoice, 3933 ALCATEL_DialVoice,
3934 ALCATEL_AnswerCall, 3934 ALCATEL_AnswerCall,
3935 ALCATEL_CancelCall, 3935 ALCATEL_CancelCall,
3936 NOTSUPPORTED, /* HoldCall */ 3936 NOTSUPPORTED, /* HoldCall */
3937 NOTSUPPORTED, /* UnholdCall */ 3937 NOTSUPPORTED, /* UnholdCall */
3938 NOTSUPPORTED, /* ConferenceCall */ 3938 NOTSUPPORTED, /* ConferenceCall */
3939 NOTSUPPORTED, /* SplitCall */ 3939 NOTSUPPORTED, /* SplitCall */
3940 NOTSUPPORTED, /* TransferCall */ 3940 NOTSUPPORTED, /* TransferCall */
3941 NOTSUPPORTED, /* SwitchCall */ 3941 NOTSUPPORTED, /* SwitchCall */
3942 NOTSUPPORTED, /* GetCallDivert */ 3942 NOTSUPPORTED, /* GetCallDivert */
3943 NOTSUPPORTED, /* SetCallDivert */ 3943 NOTSUPPORTED, /* SetCallDivert */
3944 NOTSUPPORTED, /* CancelAllDiverts*/ 3944 NOTSUPPORTED, /* CancelAllDiverts*/
3945 NONEFUNCTION, /* SetIncomingCall */ 3945 NONEFUNCTION, /* SetIncomingCall */
3946 NOTSUPPORTED, /* SetIncomingUSSD */ 3946 NOTSUPPORTED, /* SetIncomingUSSD */
3947 ALCATEL_SendDTMF, 3947 ALCATEL_SendDTMF,
3948 NOTSUPPORTED, /* GetRingtone */ 3948 NOTSUPPORTED, /* GetRingtone */
3949 NOTSUPPORTED, /* SetRingtone */ 3949 NOTSUPPORTED, /* SetRingtone */
3950 NOTSUPPORTED, /* GetRingtonesInfo*/ 3950 NOTSUPPORTED, /* GetRingtonesInfo*/
3951 NOTSUPPORTED, /* DeleteUserRingtones*/ 3951 NOTSUPPORTED, /* DeleteUserRingtones*/
3952 NOTSUPPORTED, /* PlayTone */ 3952 NOTSUPPORTED, /* PlayTone */
3953 NOTSUPPORTED, /* GetWAPBookmark */ 3953 NOTSUPPORTED, /* GetWAPBookmark */
3954 NOTSUPPORTED, /* SetWAPBookmark */ 3954 NOTSUPPORTED, /* SetWAPBookmark */
3955 NOTSUPPORTED, /* DeleteWAPBookmark*/ 3955 NOTSUPPORTED, /* DeleteWAPBookmark*/
3956 NOTSUPPORTED, /* GetWAPSettings */ 3956 NOTSUPPORTED, /* GetWAPSettings */
3957 NOTSUPPORTED, /* SetWAPSettings */ 3957 NOTSUPPORTED, /* SetWAPSettings */
3958 NOTSUPPORTED, /* GetMMSSettings */ 3958 NOTSUPPORTED, /* GetMMSSettings */
3959 NOTSUPPORTED, /* SetMMSSettings */ 3959 NOTSUPPORTED, /* SetMMSSettings */
3960 NOTSUPPORTED, /* GetSyncMLSettings*/ 3960 NOTSUPPORTED, /* GetSyncMLSettings*/
3961 NOTSUPPORTED, /* SetSyncMLSettings*/ 3961 NOTSUPPORTED, /* SetSyncMLSettings*/
3962 NOTSUPPORTED, /* GetChatSettings */ 3962 NOTSUPPORTED, /* GetChatSettings */
3963 NOTSUPPORTED, /* SetChatSettings */ 3963 NOTSUPPORTED, /* SetChatSettings */
3964 NOTSUPPORTED, /* GetBitmap */ 3964 NOTSUPPORTED, /* GetBitmap */
3965 NOTSUPPORTED, /* SetBitmap */ 3965 NOTSUPPORTED, /* SetBitmap */
3966 ALCATEL_GetToDoStatus, 3966 ALCATEL_GetToDoStatus,
3967 ALCATEL_GetToDo, 3967 ALCATEL_GetToDo,
3968 ALCATEL_GetNextToDo, 3968 ALCATEL_GetNextToDo,
3969 ALCATEL_SetToDo, 3969 ALCATEL_SetToDo,
3970 ALCATEL_AddToDo, 3970 ALCATEL_AddToDo,
3971 ALCATEL_DeleteToDo, 3971 ALCATEL_DeleteToDo,
3972 ALCATEL_DeleteAllToDo, 3972 ALCATEL_DeleteAllToDo,
3973 ALCATEL_GetCalendarStatus, 3973 ALCATEL_GetCalendarStatus,
3974 ALCATEL_GetCalendar, 3974 ALCATEL_GetCalendar,
3975 ALCATEL_GetNextCalendar, 3975 ALCATEL_GetNextCalendar,
3976 ALCATEL_SetCalendar, 3976 ALCATEL_SetCalendar,
3977 ALCATEL_AddCalendar, 3977 ALCATEL_AddCalendar,
3978 ALCATEL_DeleteCalendar, 3978 ALCATEL_DeleteCalendar,
3979 ALCATEL_DeleteAllCalendar, 3979 ALCATEL_DeleteAllCalendar,
3980 NOTSUPPORTED, /* GetCalendarSettings*/ 3980 NOTSUPPORTED, /* GetCalendarSettings*/
3981 NOTSUPPORTED, /* SetCalendarSettings*/ 3981 NOTSUPPORTED, /* SetCalendarSettings*/
3982 NOTSUPPORTED, /* GetNoteStatus */
3983 NOTSUPPORTED, /* GetNote */
3982 NOTSUPPORTED, /* GetNextNote */ 3984 NOTSUPPORTED, /* GetNextNote */
3985 NOTSUPPORTED, /* SetNote */
3986 NOTSUPPORTED, /* AddNote */
3987 NOTSUPPORTED, /* DeleteNote */
3988 NOTSUPPORTED, /* DeleteAllNotes */
3983 NOTSUPPORTED, /* GetProfile */ 3989 NOTSUPPORTED, /* GetProfile */
3984 NOTSUPPORTED, /* SetProfile */ 3990 NOTSUPPORTED, /* SetProfile */
3985 NOTSUPPORTED, /* GetFMStation */ 3991 NOTSUPPORTED, /* GetFMStation */
3986 NOTSUPPORTED, /* SetFMStation */ 3992 NOTSUPPORTED, /* SetFMStation */
3987 NOTSUPPORTED, /* ClearFMStations */ 3993 NOTSUPPORTED, /* ClearFMStations */
3988 NOTSUPPORTED, /* GetNextFileFolder*/ 3994 NOTSUPPORTED, /* GetNextFileFolder*/
3989 NOTSUPPORTED, /* GetFilePart */ 3995 NOTSUPPORTED, /* GetFilePart */
3990 NOTSUPPORTED, /* AddFilePart */ 3996 NOTSUPPORTED, /* AddFilePart */
3991 NOTSUPPORTED, /* GetFileSystemStatus*/ 3997 NOTSUPPORTED, /* GetFileSystemStatus*/
3992 NOTSUPPORTED, /* DeleteFile */ 3998 NOTSUPPORTED, /* DeleteFile */
3993 NOTSUPPORTED, /* AddFolder */ 3999 NOTSUPPORTED, /* AddFolder */
3994 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 4000 NOTSUPPORTED, /* GetGPRSAccessPoint*/
3995 NOTSUPPORTED /* SetGPRSAccessPoint*/ 4001 NOTSUPPORTED /* SetGPRSAccessPoint*/
3996}; 4002};
3997 4003
3998#endif 4004#endif
3999#endif 4005#endif
4000 4006
4001/* How should editor hadle tabs in this file? Add editor commands here. 4007/* How should editor hadle tabs in this file? Add editor commands here.
4002 * vim: noexpandtab sw=8 ts=8 sts=8: 4008 * vim: noexpandtab sw=8 ts=8 sts=8:
4003 */ 4009 */
diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c
index ba23eb2..a875f0a 100644
--- a/gammu/emb/common/phone/at/atgen.c
+++ b/gammu/emb/common/phone/at/atgen.c
@@ -315,769 +315,769 @@ GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
315 315
316 /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */ 316 /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */
317 if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) { 317 if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) {
318 err = line + 11; 318 err = line + 11;
319 Priv->ErrorCode = atoi(err); 319 Priv->ErrorCode = atoi(err);
320 320
321 if (Priv->ErrorCode == -1) { 321 if (Priv->ErrorCode == -1) {
322 Priv->ErrorText = "[Samsung] Empty location"; 322 Priv->ErrorText = "[Samsung] Empty location";
323 return GSM_DispatchMessage(s); 323 return GSM_DispatchMessage(s);
324 } 324 }
325 } 325 }
326 326
327 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) { 327 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) {
328 j = 0; 328 j = 0;
329 /* One char behind +CM[SE] ERROR */ 329 /* One char behind +CM[SE] ERROR */
330 err = line + 12; 330 err = line + 12;
331 while (err[j] && !isalnum(err[j])) j++; 331 while (err[j] && !isalnum(err[j])) j++;
332 if (isdigit(err[j])) { 332 if (isdigit(err[j])) {
333 Priv->ErrorCode = atoi(&(err[j])); 333 Priv->ErrorCode = atoi(&(err[j]));
334 k = 0; 334 k = 0;
335 while (ErrorCodes[k].Number != -1) { 335 while (ErrorCodes[k].Number != -1) {
336 if (ErrorCodes[k].Number == Priv->ErrorCode) { 336 if (ErrorCodes[k].Number == Priv->ErrorCode) {
337 Priv->ErrorText = (char *)&(ErrorCodes[k].Text); 337 Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
338 break; 338 break;
339 } 339 }
340 k++; 340 k++;
341 } 341 }
342 } else if (isalpha(err[j])) { 342 } else if (isalpha(err[j])) {
343 k = 0; 343 k = 0;
344 while (ErrorCodes[k].Number != -1) { 344 while (ErrorCodes[k].Number != -1) {
345 if (!strncmp(err + j, ErrorCodes[k].Text, strlen(ErrorCodes[k].Text))) { 345 if (!strncmp(err + j, ErrorCodes[k].Text, strlen(ErrorCodes[k].Text))) {
346 Priv->ErrorCode = ErrorCodes[k].Number; 346 Priv->ErrorCode = ErrorCodes[k].Number;
347 Priv->ErrorText = (char *)&(ErrorCodes[k].Text); 347 Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
348 break; 348 break;
349 } 349 }
350 k++; 350 k++;
351 } 351 }
352 } 352 }
353 } 353 }
354 return GSM_DispatchMessage(s); 354 return GSM_DispatchMessage(s);
355} 355}
356 356
357GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s) 357GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
358{ 358{
359 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 359 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
360 case AT_Reply_OK: 360 case AT_Reply_OK:
361 case AT_Reply_Connect: 361 case AT_Reply_Connect:
362 return ERR_NONE; 362 return ERR_NONE;
363 case AT_Reply_Error: 363 case AT_Reply_Error:
364 return ERR_UNKNOWN; 364 return ERR_UNKNOWN;
365 case AT_Reply_CMSError: 365 case AT_Reply_CMSError:
366 return ATGEN_HandleCMSError(s); 366 return ATGEN_HandleCMSError(s);
367 case AT_Reply_CMEError: 367 case AT_Reply_CMEError:
368 return ATGEN_HandleCMEError(s); 368 return ATGEN_HandleCMEError(s);
369 default: 369 default:
370 break; 370 break;
371 } 371 }
372 return ERR_UNKNOWNRESPONSE; 372 return ERR_UNKNOWNRESPONSE;
373} 373}
374 374
375GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s) 375GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s)
376{ 376{
377 unsigned char buffer[2000],buffer2[4000]; 377 unsigned char buffer[2000],buffer2[4000];
378 int i = 10; 378 int i = 10;
379 379
380 /* Ugly hack */ 380 /* Ugly hack */
381 while (msg.Buffer[i]!=13) i++; 381 while (msg.Buffer[i]!=13) i++;
382 i = i - 6; 382 i = i - 6;
383 memcpy(buffer,msg.Buffer+10,i-11); 383 memcpy(buffer,msg.Buffer+10,i-11);
384 buffer[i-11] = 0x00; 384 buffer[i-11] = 0x00;
385 385
386 smprintf(s, "USSD reply: \"%s\"\n",buffer); 386 smprintf(s, "USSD reply: \"%s\"\n",buffer);
387 387
388 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) { 388 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
389 EncodeUnicode(buffer2,buffer,strlen(buffer)); 389 EncodeUnicode(buffer2,buffer,strlen(buffer));
390 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2); 390 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
391 } 391 }
392 392
393 return ERR_NONE; 393 return ERR_NONE;
394} 394}
395 395
396GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable) 396GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
397{ 397{
398 GSM_Error error; 398 GSM_Error error;
399 399
400 if (enable) { 400 if (enable) {
401 smprintf(s, "Enabling incoming USSD\n"); 401 smprintf(s, "Enabling incoming USSD\n");
402 error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD); 402 error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD);
403 } else { 403 } else {
404 smprintf(s, "Disabling incoming USSD\n"); 404 smprintf(s, "Disabling incoming USSD\n");
405 error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD); 405 error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD);
406 } 406 }
407 if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable; 407 if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable;
408 return error; 408 return error;
409} 409}
410 410
411GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s) 411GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
412{ 412{
413 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 413 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
414 GSM_Phone_Data *Data = &s->Phone.Data; 414 GSM_Phone_Data *Data = &s->Phone.Data;
415 415
416 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED; 416 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED;
417 417
418 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) { 418 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) {
419 CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2); 419 CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2);
420 420
421 /* Sometimes phone adds this before manufacturer (Sagem) */ 421 /* Sometimes phone adds this before manufacturer (Sagem) */
422 if (strncmp("+CGMM: ", Data->Model, 7) == 0) { 422 if (strncmp("+CGMM: ", Data->Model, 7) == 0) {
423 memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1); 423 memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1);
424 } 424 }
425 425
426 Data->ModelInfo = GetModelData(NULL,Data->Model,NULL); 426 Data->ModelInfo = GetModelData(NULL,Data->Model,NULL);
427 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model); 427 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model);
428 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL); 428 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL);
429 429
430 if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number); 430 if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number);
431 431
432 if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia; 432 if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia;
433 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens; 433 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens;
434 else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens; 434 else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens;
435 else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens; 435 else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens;
436 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP; 436 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP;
437 437
438 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20"); 438 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20");
439 else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35"); 439 else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35");
440 else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35"); 440 else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35");
441 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ"); 441 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ");
442 } else { 442 } else {
443 smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); 443 smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2)));
444 } 444 }
445 445
446 return ERR_NONE; 446 return ERR_NONE;
447} 447}
448 448
449GSM_Error ATGEN_GetModel(GSM_StateMachine *s) 449GSM_Error ATGEN_GetModel(GSM_StateMachine *s)
450{ 450{
451 GSM_Error error; 451 GSM_Error error;
452 452
453 if (s->Phone.Data.Model[0] != 0) return ERR_NONE; 453 if (s->Phone.Data.Model[0] != 0) return ERR_NONE;
454 454
455 smprintf(s, "Getting model\n"); 455 smprintf(s, "Getting model\n");
456 error=GSM_WaitFor (s, "AT+CGMM\r", 8, 0x00, 3, ID_GetModel); 456 error=GSM_WaitFor (s, "AT+CGMM\r", 8, 0x00, 3, ID_GetModel);
457 if (error==ERR_NONE) { 457 if (error==ERR_NONE) {
458 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 458 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
459 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 459 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
460 smprintf(s, "[Connected model - \"%s\"]\n",s->Phone.Data.Model); 460 smprintf(s, "[Connected model - \"%s\"]\n",s->Phone.Data.Model);
461 } 461 }
462 } 462 }
463 return error; 463 return error;
464} 464}
465 465
466GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine *s) 466GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine *s)
467{ 467{
468 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 468 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
469 469
470 switch (Priv->ReplyState) { 470 switch (Priv->ReplyState) {
471 case AT_Reply_OK: 471 case AT_Reply_OK:
472 smprintf(s, "Manufacturer info received\n"); 472 smprintf(s, "Manufacturer info received\n");
473 Priv->Manufacturer = AT_Unknown; 473 Priv->Manufacturer = AT_Unknown;
474 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MANUFACTURER_LENGTH) { 474 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MANUFACTURER_LENGTH) {
475 CopyLineString(s->Phone.Data.Manufacturer, msg.Buffer, Priv->Lines, 2); 475 CopyLineString(s->Phone.Data.Manufacturer, msg.Buffer, Priv->Lines, 2);
476 } else { 476 } else {
477 smprintf(s, "WARNING: Manufacturer name too long, increase MAX_MANUFACTURER_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); 477 smprintf(s, "WARNING: Manufacturer name too long, increase MAX_MANUFACTURER_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2)));
478 s->Phone.Data.Manufacturer[0] = 0; 478 s->Phone.Data.Manufacturer[0] = 0;
479 } 479 }
480 /* Sometimes phone adds this before manufacturer (Sagem) */ 480 /* Sometimes phone adds this before manufacturer (Sagem) */
481 if (strncmp("+CGMI: ", s->Phone.Data.Manufacturer, 7) == 0) { 481 if (strncmp("+CGMI: ", s->Phone.Data.Manufacturer, 7) == 0) {
482 memmove(s->Phone.Data.Manufacturer, s->Phone.Data.Manufacturer + 7, strlen(s->Phone.Data.Manufacturer + 7) + 1); 482 memmove(s->Phone.Data.Manufacturer, s->Phone.Data.Manufacturer + 7, strlen(s->Phone.Data.Manufacturer + 7) + 1);
483 } 483 }
484 if (strstr(msg.Buffer,"Falcom")) { 484 if (strstr(msg.Buffer,"Falcom")) {
485 smprintf(s, "Falcom\n"); 485 smprintf(s, "Falcom\n");
486 strcpy(s->Phone.Data.Manufacturer,"Falcom"); 486 strcpy(s->Phone.Data.Manufacturer,"Falcom");
487 Priv->Manufacturer = AT_Falcom; 487 Priv->Manufacturer = AT_Falcom;
488 if (strstr(msg.Buffer,"A2D")) { 488 if (strstr(msg.Buffer,"A2D")) {
489 strcpy(s->Phone.Data.Model,"A2D"); 489 strcpy(s->Phone.Data.Model,"A2D");
490 s->Phone.Data.ModelInfo = GetModelData(NULL,s->Phone.Data.Model,NULL); 490 s->Phone.Data.ModelInfo = GetModelData(NULL,s->Phone.Data.Model,NULL);
491 smprintf(s, "Model A2D\n"); 491 smprintf(s, "Model A2D\n");
492 } 492 }
493 } 493 }
494 if (strstr(msg.Buffer,"Nokia")) { 494 if (strstr(msg.Buffer,"Nokia")) {
495 smprintf(s, "Nokia\n"); 495 smprintf(s, "Nokia\n");
496 strcpy(s->Phone.Data.Manufacturer,"Nokia"); 496 strcpy(s->Phone.Data.Manufacturer,"Nokia");
497 Priv->Manufacturer = AT_Nokia; 497 Priv->Manufacturer = AT_Nokia;
498 } 498 }
499 if (strstr(msg.Buffer,"SIEMENS")) { 499 if (strstr(msg.Buffer,"SIEMENS")) {
500 smprintf(s, "Siemens\n"); 500 smprintf(s, "Siemens\n");
501 strcpy(s->Phone.Data.Manufacturer,"Siemens"); 501 strcpy(s->Phone.Data.Manufacturer,"Siemens");
502 Priv->Manufacturer = AT_Siemens; 502 Priv->Manufacturer = AT_Siemens;
503 } 503 }
504 if (strstr(msg.Buffer,"ERICSSON")) { 504 if (strstr(msg.Buffer,"ERICSSON")) {
505 smprintf(s, "Ericsson\n"); 505 smprintf(s, "Ericsson\n");
506 strcpy(s->Phone.Data.Manufacturer,"Ericsson"); 506 strcpy(s->Phone.Data.Manufacturer,"Ericsson");
507 Priv->Manufacturer = AT_Ericsson; 507 Priv->Manufacturer = AT_Ericsson;
508 } 508 }
509 if (strstr(msg.Buffer,"iPAQ")) { 509 if (strstr(msg.Buffer,"iPAQ")) {
510 smprintf(s, "iPAQ\n"); 510 smprintf(s, "iPAQ\n");
511 strcpy(s->Phone.Data.Manufacturer,"HP"); 511 strcpy(s->Phone.Data.Manufacturer,"HP");
512 Priv->Manufacturer = AT_HP; 512 Priv->Manufacturer = AT_HP;
513 } 513 }
514 if (strstr(msg.Buffer,"ALCATEL")) { 514 if (strstr(msg.Buffer,"ALCATEL")) {
515 smprintf(s, "Alcatel\n"); 515 smprintf(s, "Alcatel\n");
516 strcpy(s->Phone.Data.Manufacturer,"Alcatel"); 516 strcpy(s->Phone.Data.Manufacturer,"Alcatel");
517 Priv->Manufacturer = AT_Alcatel; 517 Priv->Manufacturer = AT_Alcatel;
518 } 518 }
519 if (strstr(msg.Buffer,"SAGEM")) { 519 if (strstr(msg.Buffer,"SAGEM")) {
520 smprintf(s, "Sagem\n"); 520 smprintf(s, "Sagem\n");
521 strcpy(s->Phone.Data.Manufacturer,"Sagem"); 521 strcpy(s->Phone.Data.Manufacturer,"Sagem");
522 Priv->Manufacturer = AT_Sagem; 522 Priv->Manufacturer = AT_Sagem;
523 } 523 }
524 if (strstr(msg.Buffer,"Samsung")) { 524 if (strstr(msg.Buffer,"Samsung")) {
525 smprintf(s, "Samsung\n"); 525 smprintf(s, "Samsung\n");
526 strcpy(s->Phone.Data.Manufacturer,"Samsung"); 526 strcpy(s->Phone.Data.Manufacturer,"Samsung");
527 Priv->Manufacturer = AT_Samsung; 527 Priv->Manufacturer = AT_Samsung;
528 } 528 }
529 return ERR_NONE; 529 return ERR_NONE;
530 case AT_Reply_CMSError: 530 case AT_Reply_CMSError:
531 return ATGEN_HandleCMSError(s); 531 return ATGEN_HandleCMSError(s);
532 default: 532 default:
533 break; 533 break;
534 } 534 }
535 return ERR_UNKNOWNRESPONSE; 535 return ERR_UNKNOWNRESPONSE;
536} 536}
537 537
538GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s) 538GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s)
539{ 539{
540 if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE; 540 if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE;
541 541
542 return GSM_WaitFor (s, "AT+CGMI\r", 8, 0x00, 4, ID_GetManufacturer); 542 return GSM_WaitFor (s, "AT+CGMI\r", 8, 0x00, 4, ID_GetManufacturer);
543} 543}
544 544
545GSM_Error ATGEN_ReplyGetFirmwareCGMR(GSM_Protocol_Message msg, GSM_StateMachine *s) 545GSM_Error ATGEN_ReplyGetFirmwareCGMR(GSM_Protocol_Message msg, GSM_StateMachine *s)
546{ 546{
547 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 547 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
548 unsigned int i = 0; 548 unsigned int i = 0;
549 549
550 strcpy(s->Phone.Data.Version,"unknown"); 550 strcpy(s->Phone.Data.Version,"unknown");
551 s->Phone.Data.VerNum = 0; 551 s->Phone.Data.VerNum = 0;
552 if (Priv->ReplyState == AT_Reply_OK) { 552 if (Priv->ReplyState == AT_Reply_OK) {
553 CopyLineString(s->Phone.Data.Version, msg.Buffer, Priv->Lines, 2); 553 CopyLineString(s->Phone.Data.Version, msg.Buffer, Priv->Lines, 2);
554 /* Sometimes phone adds this before manufacturer (Sagem) */ 554 /* Sometimes phone adds this before manufacturer (Sagem) */
555 if (strncmp("+CGMR: ", s->Phone.Data.Version, 7) == 0) { 555 if (strncmp("+CGMR: ", s->Phone.Data.Version, 7) == 0) {
556 memmove(s->Phone.Data.Version, s->Phone.Data.Version + 7, strlen(s->Phone.Data.Version + 7) + 1); 556 memmove(s->Phone.Data.Version, s->Phone.Data.Version + 7, strlen(s->Phone.Data.Version + 7) + 1);
557 } 557 }
558 } 558 }
559 if (Priv->Manufacturer == AT_Ericsson) { 559 if (Priv->Manufacturer == AT_Ericsson) {
560 while (1) { 560 while (1) {
561 if (s->Phone.Data.Version[i] == 0x20) { 561 if (s->Phone.Data.Version[i] == 0x20) {
562 s->Phone.Data.Version[i] = 0x00; 562 s->Phone.Data.Version[i] = 0x00;
563 break; 563 break;
564 } 564 }
565 if (i == strlen(s->Phone.Data.Version)) break; 565 if (i == strlen(s->Phone.Data.Version)) break;
566 i++; 566 i++;
567 } 567 }
568 } 568 }
569 smprintf(s, "Received firmware version: \"%s\"\n",s->Phone.Data.Version); 569 smprintf(s, "Received firmware version: \"%s\"\n",s->Phone.Data.Version);
570 GSM_CreateFirmwareNumber(s); 570 GSM_CreateFirmwareNumber(s);
571 return ERR_NONE; 571 return ERR_NONE;
572} 572}
573 573
574GSM_Error ATGEN_ReplyGetFirmwareATI(GSM_Protocol_Message msg, GSM_StateMachine *s) 574GSM_Error ATGEN_ReplyGetFirmwareATI(GSM_Protocol_Message msg, GSM_StateMachine *s)
575{ 575{
576 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 576 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
577 577
578 switch (Priv->ReplyState) { 578 switch (Priv->ReplyState) {
579 case AT_Reply_OK: 579 case AT_Reply_OK:
580 // strcpy(Data->Version,"0.00"); 580 // strcpy(Data->Version,"0.00");
581 // *Data->VersionNum=0; 581 // *Data->VersionNum=0;
582 // if (Data->Priv.ATGEN.ReplyState==AT_Reply_OK) { 582 // if (Data->Priv.ATGEN.ReplyState==AT_Reply_OK) {
583 // CopyLineString(Data->Version, msg.Buffer, Priv->Lines, 2); 583 // CopyLineString(Data->Version, msg.Buffer, Priv->Lines, 2);
584 // } 584 // }
585 // smprintf(s, "Received firmware version: \"%s\"\n",Data->Version); 585 // smprintf(s, "Received firmware version: \"%s\"\n",Data->Version);
586 // GSM_CreateFirmwareNumber(Data); 586 // GSM_CreateFirmwareNumber(Data);
587 // return ERR_NONE; 587 // return ERR_NONE;
588 case AT_Reply_Error: 588 case AT_Reply_Error:
589 return ERR_NOTSUPPORTED; 589 return ERR_NOTSUPPORTED;
590 case AT_Reply_CMSError: 590 case AT_Reply_CMSError:
591 return ATGEN_HandleCMSError(s); 591 return ATGEN_HandleCMSError(s);
592 default: 592 default:
593 break; 593 break;
594 } 594 }
595 return ERR_UNKNOWNRESPONSE; 595 return ERR_UNKNOWNRESPONSE;
596} 596}
597 597
598GSM_Error ATGEN_GetFirmware(GSM_StateMachine *s) 598GSM_Error ATGEN_GetFirmware(GSM_StateMachine *s)
599{ 599{
600 GSM_Error error; 600 GSM_Error error;
601 601
602 if (s->Phone.Data.Version[0] != 0) return ERR_NONE; 602 if (s->Phone.Data.Version[0] != 0) return ERR_NONE;
603 603
604 error=ATGEN_GetManufacturer(s); 604 error=ATGEN_GetManufacturer(s);
605 if (error != ERR_NONE) return error; 605 if (error != ERR_NONE) return error;
606 606
607 //smprintf(s, "Getting firmware - method 1\n"); 607 //smprintf(s, "Getting firmware - method 1\n");
608 //error=GSM_WaitFor (s, "ATI\r", 4, 0x00, 3, ID_GetFirmware); 608 //error=GSM_WaitFor (s, "ATI\r", 4, 0x00, 3, ID_GetFirmware);
609 //if (error != ERR_NONE) { 609 //if (error != ERR_NONE) {
610 smprintf(s, "Getting firmware - method 2\n"); 610 smprintf(s, "Getting firmware - method 2\n");
611 error=GSM_WaitFor (s, "AT+CGMR\r", 8, 0x00, 3, ID_GetFirmware); 611 error=GSM_WaitFor (s, "AT+CGMR\r", 8, 0x00, 3, ID_GetFirmware);
612 //} 612 //}
613 if (error==ERR_NONE) { 613 if (error==ERR_NONE) {
614 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 614 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
615 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 615 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
616 smprintf(s, "[Firmware version - \"%s\"]\n",s->Phone.Data.Version); 616 smprintf(s, "[Firmware version - \"%s\"]\n",s->Phone.Data.Version);
617 } 617 }
618 } 618 }
619 return error; 619 return error;
620} 620}
621 621
622GSM_Error ATGEN_Initialise(GSM_StateMachine *s) 622GSM_Error ATGEN_Initialise(GSM_StateMachine *s)
623{ 623{
624 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 624 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
625 GSM_Error error; 625 GSM_Error error;
626 char buff[2]; 626 char buff[2];
627 627
628 Priv->SMSMode = 0; 628 Priv->SMSMode = 0;
629 Priv->Manufacturer = 0; 629 Priv->Manufacturer = 0;
630 Priv->PhoneSMSMemory = 0; 630 Priv->PhoneSMSMemory = 0;
631 Priv->CanSaveSMS = false; 631 Priv->CanSaveSMS = false;
632 Priv->SIMSMSMemory = 0; 632 Priv->SIMSMSMemory = 0;
633 Priv->SMSMemory = 0; 633 Priv->SMSMemory = 0;
634 Priv->PBKMemory = 0; 634 Priv->PBKMemory = 0;
635 Priv->PBKSBNR = 0; 635 Priv->PBKSBNR = 0;
636 Priv->PBKCharset = 0; 636 Priv->PBKCharset = 0;
637 Priv->UCS2CharsetFailed = false; 637 Priv->UCS2CharsetFailed = false;
638 Priv->NonUCS2CharsetFailed= false; 638 Priv->NonUCS2CharsetFailed= false;
639 Priv->PBKMemories[0] = 0; 639 Priv->PBKMemories[0] = 0;
640 Priv->FirstCalendarPos = 0; 640 Priv->FirstCalendarPos = 0;
641 Priv->NextMemoryEntry = 0; 641 Priv->NextMemoryEntry = 0;
642 Priv->FirstMemoryEntry = 0; 642 Priv->FirstMemoryEntry = 0;
643 Priv->file.Used = 0; 643 Priv->file.Used = 0;
644 Priv->file.Buffer = NULL; 644 Priv->file.Buffer = NULL;
645 Priv->OBEX = false; 645 Priv->OBEX = false;
646 Priv->MemorySize = 0; 646 Priv->MemorySize = 0;
647 Priv->TextLength = 0; 647 Priv->TextLength = 0;
648 Priv->NumberLength = 0; 648 Priv->NumberLength = 0;
649 649
650 Priv->ErrorText = NULL; 650 Priv->ErrorText = NULL;
651 651
652 if (s->ConnectionType != GCT_IRDAAT && s->ConnectionType != GCT_BLUEAT) { 652 if (s->ConnectionType != GCT_IRDAAT && s->ConnectionType != GCT_BLUEAT) {
653 /* We try to escape AT+CMGS mode, at least Siemens M20 653 /* We try to escape AT+CMGS mode, at least Siemens M20
654 * then needs to get some rest 654 * then needs to get some rest
655 */ 655 */
656 smprintf(s, "Escaping SMS mode\n"); 656 smprintf(s, "Escaping SMS mode\n");
657 error = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00); 657 error = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00);
658 if (error!=ERR_NONE) return error; 658 if (error!=ERR_NONE) return error;
659 659
660 /* Grab any possible garbage */ 660 /* Grab any possible garbage */
661 while (s->Device.Functions->ReadDevice(s, buff, 2) > 0) my_sleep(10); 661 while (s->Device.Functions->ReadDevice(s, buff, 2) > 0) my_sleep(10);
662 } 662 }
663 663
664 /* When some phones (Alcatel BE5) is first time connected, it needs extra 664 /* When some phones (Alcatel BE5) is first time connected, it needs extra
665 * time to react, sending just AT wakes up the phone and it then can react 665 * time to react, sending just AT wakes up the phone and it then can react
666 * to ATE1. We don't need to check whether this fails as it is just to 666 * to ATE1. We don't need to check whether this fails as it is just to
667 * wake up the phone and does nothing. 667 * wake up the phone and does nothing.
668 */ 668 */
669 smprintf(s, "Sending simple AT command to wake up some devices\n"); 669 smprintf(s, "Sending simple AT command to wake up some devices\n");
670 GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame); 670 GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame);
671 671
672 smprintf(s, "Enabling echo\n"); 672 smprintf(s, "Enabling echo\n");
673 error = GSM_WaitFor (s, "ATE1\r", 5, 0x00, 3, ID_EnableEcho); 673 error = GSM_WaitFor (s, "ATE1\r", 5, 0x00, 3, ID_EnableEcho);
674 if (error != ERR_NONE) return error; 674 if (error != ERR_NONE) return error;
675 675
676 smprintf(s, "Enabling CME errors\n"); 676 smprintf(s, "Enabling CME errors\n");
677 /* Try numeric errors */ 677 /* Try numeric errors */
678 if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { 678 if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
679 /* Try textual errors */ 679 /* Try textual errors */
680 if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { 680 if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
681 smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n"); 681 smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n");
682 } 682 }
683 } 683 }
684 684
685 error = ATGEN_GetModel(s); 685 error = ATGEN_GetModel(s);
686 if (error != ERR_NONE) return error; 686 if (error != ERR_NONE) return error;
687 687
688 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) { 688 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) {
689 s->Protocol.Data.AT.FastWrite = true; 689 s->Protocol.Data.AT.FastWrite = true;
690 } 690 }
691 691
692 return error; 692 return error;
693} 693}
694 694
695GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 695GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
696{ 696{
697 unsigned char req[50]; 697 unsigned char req[50];
698 698
699 if (smsc->Location!=1) return ERR_NOTSUPPORTED; 699 if (smsc->Location!=1) return ERR_INVALIDLOCATION;
700 700
701 sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number)); 701 sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number));
702 702
703 smprintf(s, "Setting SMSC\n"); 703 smprintf(s, "Setting SMSC\n");
704 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC); 704 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC);
705} 705}
706 706
707GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s) 707GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s)
708{ 708{
709 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 709 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
710 case AT_Reply_OK: 710 case AT_Reply_OK:
711 /* Reply here is: 711 /* Reply here is:
712 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]] 712 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]]
713 * each memory is in quotes, 713 * each memory is in quotes,
714 * Example: ("SM"), ("SM"), ("SM") 714 * Example: ("SM"), ("SM"), ("SM")
715 * 715 *
716 * We need to get from this supported memories. For this case 716 * We need to get from this supported memories. For this case
717 * we assume, that just appearence of memory makes it 717 * we assume, that just appearence of memory makes it
718 * available for everything. Then we need to find out whether 718 * available for everything. Then we need to find out whether
719 * phone supports writing to memory. This is done by searching 719 * phone supports writing to memory. This is done by searching
720 * for "), (", which will appear between lists. 720 * for "), (", which will appear between lists.
721 */ 721 */
722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false; 722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) { 723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
724 s->Phone.Data.Priv.ATGEN.CanSaveSMS = true; 724 s->Phone.Data.Priv.ATGEN.CanSaveSMS = true;
725 } 725 }
726 726
727 if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE; 727 if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE;
728 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE; 728 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE;
729 729
730 if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE; 730 if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE;
731 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE; 731 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE;
732 732
733 smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory); 733 smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
734 if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true"); 734 if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true");
735 smprintf(s, "\n"); 735 smprintf(s, "\n");
736 return ERR_NONE; 736 return ERR_NONE;
737 case AT_Reply_Error: 737 case AT_Reply_Error:
738 case AT_Reply_CMSError: 738 case AT_Reply_CMSError:
739 return ATGEN_HandleCMSError(s); 739 return ATGEN_HandleCMSError(s);
740 case AT_Reply_CMEError: 740 case AT_Reply_CMEError:
741 return ATGEN_HandleCMEError(s); 741 return ATGEN_HandleCMEError(s);
742 default: 742 default:
743 return ERR_UNKNOWNRESPONSE; 743 return ERR_UNKNOWNRESPONSE;
744 } 744 }
745} 745}
746 746
747GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s) 747GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s)
748{ 748{
749 smprintf(s, "Getting available SMS memories\n"); 749 smprintf(s, "Getting available SMS memories\n");
750 return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories); 750 return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories);
751} 751}
752 752
753GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM) 753GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM)
754{ 754{
755 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 755 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
756 char req[] = "AT+CPMS=\"XX\",\"XX\"\r"; 756 char req[] = "AT+CPMS=\"XX\",\"XX\"\r";
757 int reqlen = 18; 757 int reqlen = 18;
758 GSM_Error error; 758 GSM_Error error;
759 759
760 if ((SIM && Priv->SIMSMSMemory == 0) || (!SIM && Priv->PhoneSMSMemory == 0)) { 760 if ((SIM && Priv->SIMSMSMemory == 0) || (!SIM && Priv->PhoneSMSMemory == 0)) {
761 /* We silently ignore error here, because when this fails, we can try to setmemory anyway */ 761 /* We silently ignore error here, because when this fails, we can try to setmemory anyway */
762 ATGEN_GetSMSMemories(s); 762 ATGEN_GetSMSMemories(s);
763 } 763 }
764 764
765 /* If phone can not save SMS, don't try to set memory for saving */ 765 /* If phone can not save SMS, don't try to set memory for saving */
766 if (!Priv->CanSaveSMS) { 766 if (!Priv->CanSaveSMS) {
767 req[12] = '\r'; 767 req[12] = '\r';
768 reqlen = 13; 768 reqlen = 13;
769 } 769 }
770 770
771 if (SIM) { 771 if (SIM) {
772 if (Priv->SMSMemory == MEM_SM) return ERR_NONE; 772 if (Priv->SMSMemory == MEM_SM) return ERR_NONE;
773 if (Priv->SIMSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED; 773 if (Priv->SIMSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED;
774 774
775 req[9] = 'S'; req[10] = 'M'; 775 req[9] = 'S'; req[10] = 'M';
776 req[14] = 'S'; req[15] = 'M'; 776 req[14] = 'S'; req[15] = 'M';
777 777
778 smprintf(s, "Setting SMS memory type to SM\n"); 778 smprintf(s, "Setting SMS memory type to SM\n");
779 error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType); 779 error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType);
780 if (Priv->SIMSMSMemory == 0 && error == ERR_NONE) { 780 if (Priv->SIMSMSMemory == 0 && error == ERR_NONE) {
781 Priv->SIMSMSMemory = AT_AVAILABLE; 781 Priv->SIMSMSMemory = AT_AVAILABLE;
782 } 782 }
783 if (error == ERR_NOTSUPPORTED) { 783 if (error == ERR_NOTSUPPORTED) {
784 smprintf(s, "Can't access SIM card?\n"); 784 smprintf(s, "Can't access SIM card?\n");
785 return ERR_SECURITYERROR; 785 return ERR_SECURITYERROR;
786 } 786 }
787 if (error != ERR_NONE) return error; 787 if (error != ERR_NONE) return error;
788 Priv->SMSMemory = MEM_SM; 788 Priv->SMSMemory = MEM_SM;
789 } else { 789 } else {
790 if (Priv->SMSMemory == MEM_ME) return ERR_NONE; 790 if (Priv->SMSMemory == MEM_ME) return ERR_NONE;
791 if (Priv->PhoneSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED; 791 if (Priv->PhoneSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED;
792 792
793 req[9] = 'M'; req[10] = 'E'; 793 req[9] = 'M'; req[10] = 'E';
794 req[14] = 'M'; req[15] = 'E'; 794 req[14] = 'M'; req[15] = 'E';
795 795
796 smprintf(s, "Setting SMS memory type to ME\n"); 796 smprintf(s, "Setting SMS memory type to ME\n");
797 error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType); 797 error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType);
798 if (Priv->PhoneSMSMemory == 0 && error == ERR_NONE) { 798 if (Priv->PhoneSMSMemory == 0 && error == ERR_NONE) {
799 Priv->PhoneSMSMemory = AT_AVAILABLE; 799 Priv->PhoneSMSMemory = AT_AVAILABLE;
800 } 800 }
801 if (error == ERR_NONE) Priv->SMSMemory = MEM_ME; 801 if (error == ERR_NONE) Priv->SMSMemory = MEM_ME;
802 } 802 }
803 return error; 803 return error;
804} 804}
805 805
806GSM_Error ATGEN_GetSMSMode(GSM_StateMachine *s) 806GSM_Error ATGEN_GetSMSMode(GSM_StateMachine *s)
807{ 807{
808 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 808 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
809 GSM_Error error; 809 GSM_Error error;
810 810
811 if (Priv->SMSMode != 0) return ERR_NONE; 811 if (Priv->SMSMode != 0) return ERR_NONE;
812 812
813 smprintf(s, "Trying SMS PDU mode\n"); 813 smprintf(s, "Trying SMS PDU mode\n");
814 error=GSM_WaitFor (s, "AT+CMGF=0\r", 10, 0x00, 3, ID_GetSMSMode); 814 error=GSM_WaitFor (s, "AT+CMGF=0\r", 10, 0x00, 3, ID_GetSMSMode);
815 if (error==ERR_NONE) { 815 if (error==ERR_NONE) {
816 Priv->SMSMode = SMS_AT_PDU; 816 Priv->SMSMode = SMS_AT_PDU;
817 return ERR_NONE; 817 return ERR_NONE;
818 } 818 }
819 819
820 smprintf(s, "Trying SMS text mode\n"); 820 smprintf(s, "Trying SMS text mode\n");
821 error=GSM_WaitFor (s, "AT+CMGF=1\r", 10, 0x00, 3, ID_GetSMSMode); 821 error=GSM_WaitFor (s, "AT+CMGF=1\r", 10, 0x00, 3, ID_GetSMSMode);
822 if (error==ERR_NONE) { 822 if (error==ERR_NONE) {
823 smprintf(s, "Enabling displaying all parameters in text mode\n"); 823 smprintf(s, "Enabling displaying all parameters in text mode\n");
824 error=GSM_WaitFor (s, "AT+CSDH=1\r", 10, 0x00, 3, ID_GetSMSMode); 824 error=GSM_WaitFor (s, "AT+CSDH=1\r", 10, 0x00, 3, ID_GetSMSMode);
825 if (error == ERR_NONE) Priv->SMSMode = SMS_AT_TXT; 825 if (error == ERR_NONE) Priv->SMSMode = SMS_AT_TXT;
826 } 826 }
827 827
828 return error; 828 return error;
829} 829}
830 830
831GSM_Error ATGEN_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location) 831GSM_Error ATGEN_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location)
832{ 832{
833 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 833 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
834 int ifolderid, maxfolder; 834 int ifolderid, maxfolder;
835 GSM_Error error; 835 GSM_Error error;
836 836
837 if (Priv->PhoneSMSMemory == 0) { 837 if (Priv->PhoneSMSMemory == 0) {
838 error = ATGEN_SetSMSMemory(s, false); 838 error = ATGEN_SetSMSMemory(s, false);
839 if (error != ERR_NONE && error != ERR_NOTSUPPORTED) return error; 839 if (error != ERR_NONE && error != ERR_NOTSUPPORTED) return error;
840 } 840 }
841 if (Priv->SIMSMSMemory == 0) { 841 if (Priv->SIMSMSMemory == 0) {
842 error = ATGEN_SetSMSMemory(s, true); 842 error = ATGEN_SetSMSMemory(s, true);
843 if (error != ERR_NONE && error != ERR_NOTSUPPORTED) return error; 843 if (error != ERR_NONE && error != ERR_NOTSUPPORTED) return error;
844 } 844 }
845 845
846 if (Priv->SIMSMSMemory != AT_AVAILABLE && Priv->PhoneSMSMemory != AT_AVAILABLE) { 846 if (Priv->SIMSMSMemory != AT_AVAILABLE && Priv->PhoneSMSMemory != AT_AVAILABLE) {
847 /* No SMS memory at all */ 847 /* No SMS memory at all */
848 return ERR_NOTSUPPORTED; 848 return ERR_NOTSUPPORTED;
849 } 849 }
850 if (Priv->SIMSMSMemory == AT_AVAILABLE && Priv->PhoneSMSMemory == AT_AVAILABLE) { 850 if (Priv->SIMSMSMemory == AT_AVAILABLE && Priv->PhoneSMSMemory == AT_AVAILABLE) {
851 /* Both available */ 851 /* Both available */
852 maxfolder = 2; 852 maxfolder = 2;
853 } else { 853 } else {
854 /* One available */ 854 /* One available */
855 maxfolder = 1; 855 maxfolder = 1;
856 } 856 }
857 857
858 /* simulate flat SMS memory */ 858 /* simulate flat SMS memory */
859 if (sms->Folder == 0x00) { 859 if (sms->Folder == 0x00) {
860 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER; 860 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER;
861 if (ifolderid + 1 > maxfolder) return ERR_NOTSUPPORTED; 861 if (ifolderid + 1 > maxfolder) return ERR_NOTSUPPORTED;
862 *folderid = ifolderid + 1; 862 *folderid = ifolderid + 1;
863 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER; 863 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER;
864 } else { 864 } else {
865 if (sms->Folder > 2 * maxfolder) return ERR_NOTSUPPORTED; 865 if (sms->Folder > 2 * maxfolder) return ERR_NOTSUPPORTED;
866 *folderid = sms->Folder <= 2 ? 1 : 2; 866 *folderid = sms->Folder <= 2 ? 1 : 2;
867 *location = sms->Location; 867 *location = sms->Location;
868 } 868 }
869 smprintf(s, "SMS folder %i & location %i -> ATGEN folder %i & location %i\n", 869 smprintf(s, "SMS folder %i & location %i -> ATGEN folder %i & location %i\n",
870 sms->Folder,sms->Location,*folderid,*location); 870 sms->Folder,sms->Location,*folderid,*location);
871 871
872 if (Priv->SIMSMSMemory == AT_AVAILABLE && *folderid == 1) { 872 if (Priv->SIMSMSMemory == AT_AVAILABLE && *folderid == 1) {
873 return ATGEN_SetSMSMemory(s, true); 873 return ATGEN_SetSMSMemory(s, true);
874 } else { 874 } else {
875 return ATGEN_SetSMSMemory(s, false); 875 return ATGEN_SetSMSMemory(s, false);
876 } 876 }
877} 877}
878 878
879void ATGEN_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location) 879void ATGEN_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
880{ 880{
881 sms->Folder= 0; 881 sms->Folder= 0;
882 sms->Location= (folderid - 1) * PHONE_MAXSMSINFOLDER + location; 882 sms->Location= (folderid - 1) * PHONE_MAXSMSINFOLDER + location;
883 smprintf(s, "ATGEN folder %i & location %i -> SMS folder %i & location %i\n", 883 smprintf(s, "ATGEN folder %i & location %i -> SMS folder %i & location %i\n",
884 folderid,location,sms->Folder,sms->Location); 884 folderid,location,sms->Folder,sms->Location);
885} 885}
886 886
887GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 887GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
888{ 888{
889 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 889 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
890 GSM_SMSMessage *sms= &s->Phone.Data.GetSMSMessage->SMS[0]; 890 GSM_SMSMessage *sms= &s->Phone.Data.GetSMSMessage->SMS[0];
891 int current = 0, current2, i; 891 int current = 0, current2, i;
892 unsigned char buffer[300],smsframe[800]; 892 unsigned char buffer[300],smsframe[800];
893 unsigned char firstbyte, TPDCS, TPUDL, TPStatus; 893 unsigned char firstbyte, TPDCS, TPUDL, TPStatus;
894 GSM_Error error; 894 GSM_Error error;
895 895
896 switch (Priv->ReplyState) { 896 switch (Priv->ReplyState) {
897 case AT_Reply_OK: 897 case AT_Reply_OK:
898 if (Priv->Lines.numbers[4] == 0x00) return ERR_EMPTY; 898 if (Priv->Lines.numbers[4] == 0x00) return ERR_EMPTY;
899 s->Phone.Data.GetSMSMessage->Number = 1; 899 s->Phone.Data.GetSMSMessage->Number = 1;
900 s->Phone.Data.GetSMSMessage->SMS[0].Name[0] = 0; 900 s->Phone.Data.GetSMSMessage->SMS[0].Name[0] = 0;
901 s->Phone.Data.GetSMSMessage->SMS[0].Name[1]= 0; 901 s->Phone.Data.GetSMSMessage->SMS[0].Name[1]= 0;
902 switch (Priv->SMSMode) { 902 switch (Priv->SMSMode) {
903 case SMS_AT_PDU: 903 case SMS_AT_PDU:
904 CopyLineString(buffer, msg.Buffer, Priv->Lines, 2); 904 CopyLineString(buffer, msg.Buffer, Priv->Lines, 2);
905 switch (buffer[7]) { 905 switch (buffer[7]) {
906 case '0': sms->State = SMS_UnRead; break; 906 case '0': sms->State = SMS_UnRead; break;
907 case '1': sms->State = SMS_Read;break; 907 case '1': sms->State = SMS_Read;break;
908 case '2': sms->State = SMS_UnSent;break; 908 case '2': sms->State = SMS_UnSent;break;
909 default : sms->State = SMS_Sent;break;//case '3' 909 default : sms->State = SMS_Sent;break;//case '3'
910 } 910 }
911 DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3))); 911 DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3)));
912 /* Siemens MC35 (only ?) */ 912 /* Siemens MC35 (only ?) */
913 if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY; 913 if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY;
914 /* Siemens M20 */ 914 /* Siemens M20 */
915 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 915 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
916 /* we check for the most often visible */ 916 /* we check for the most often visible */
917 if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN && 917 if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN &&
918 buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) { 918 buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
919 /* Seems to be Delivery Report */ 919 /* Seems to be Delivery Report */
920 smprintf(s, "SMS type - status report (M20 style)\n"); 920 smprintf(s, "SMS type - status report (M20 style)\n");
921 sms->PDU = SMS_Status_Report; 921 sms->PDU = SMS_Status_Report;
922 sms->Folder = 1;/*INBOX SIM*/ 922 sms->Folder = 1;/*INBOX SIM*/
923 sms->InboxFolder = true; 923 sms->InboxFolder = true;
924 924
925 smsframe[12]=buffer[current++]; 925 smsframe[12]=buffer[current++];
926 smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++]; 926 smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++];
927 current2=((buffer[current])+1)/2+1; 927 current2=((buffer[current])+1)/2+1;
928 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; 928 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
929 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; 929 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
930 smsframe[0] = 0; 930 smsframe[0] = 0;
931 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; 931 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
932 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; 932 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
933 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); 933 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
934 return ERR_NONE; 934 return ERR_NONE;
935 } 935 }
936 } 936 }
937 /* We use locations from SMS layouts like in ../phone2.c(h) */ 937 /* We use locations from SMS layouts like in ../phone2.c(h) */
938 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++]; 938 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++];
939 smsframe[12]=buffer[current++]; 939 smsframe[12]=buffer[current++];
940 /* See GSM 03.40 section 9.2.3.1 */ 940 /* See GSM 03.40 section 9.2.3.1 */
941 switch (smsframe[12] & 0x03) { 941 switch (smsframe[12] & 0x03) {
942 case 0x00: 942 case 0x00:
943 smprintf(s, "SMS type - deliver\n"); 943 smprintf(s, "SMS type - deliver\n");
944 sms->PDU = SMS_Deliver; 944 sms->PDU = SMS_Deliver;
945 if (Priv->SMSMemory == MEM_SM) { 945 if (Priv->SMSMemory == MEM_SM) {
946 sms->Folder = 1; /*INBOX SIM*/ 946 sms->Folder = 1; /*INBOX SIM*/
947 } else { 947 } else {
948 sms->Folder = 3; /*INBOX ME*/ 948 sms->Folder = 3; /*INBOX ME*/
949 } 949 }
950 sms->InboxFolder = true; 950 sms->InboxFolder = true;
951 current2=((buffer[current])+1)/2+1; 951 current2=((buffer[current])+1)/2+1;
952 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 952 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
953 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) { 953 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
954 smprintf(s, "Trying to read alphanumeric number\n"); 954 smprintf(s, "Trying to read alphanumeric number\n");
955 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 955 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
956 current+=6; 956 current+=6;
957 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++]; 957 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++];
958 } else { 958 } else {
959 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 959 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
960 } 960 }
961 } else { 961 } else {
962 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 962 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
963 } 963 }
964 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; 964 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++];
965 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; 965 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++];
966 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++]; 966 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++];
967 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++]; 967 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++];
968 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++]; 968 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++];
969 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSDeliver); 969 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSDeliver);
970 return ERR_NONE; 970 return ERR_NONE;
971 case 0x01: 971 case 0x01:
972 smprintf(s, "SMS type - submit\n"); 972 smprintf(s, "SMS type - submit\n");
973 sms->PDU = SMS_Submit; 973 sms->PDU = SMS_Submit;
974 if (Priv->SMSMemory == MEM_SM) { 974 if (Priv->SMSMemory == MEM_SM) {
975 sms->Folder = 2; /*OUTBOX SIM*/ 975 sms->Folder = 2; /*OUTBOX SIM*/
976 smprintf(s, "Outbox SIM\n"); 976 smprintf(s, "Outbox SIM\n");
977 } else { 977 } else {
978 sms->Folder = 4; /*OUTBOX ME*/ 978 sms->Folder = 4; /*OUTBOX ME*/
979 } 979 }
980 sms->InboxFolder = false; 980 sms->InboxFolder = false;
981 smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++]; 981 smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++];
982 current2=((buffer[current])+1)/2+1; 982 current2=((buffer[current])+1)/2+1;
983 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 983 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
984 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) { 984 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
985 smprintf(s, "Trying to read alphanumeric number\n"); 985 smprintf(s, "Trying to read alphanumeric number\n");
986 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 986 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
987 current+=6; 987 current+=6;
988 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++]; 988 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++];
989 } else { 989 } else {
990 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 990 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
991 } 991 }
992 } else { 992 } else {
993 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 993 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
994 } 994 }
995 smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++]; 995 smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++];
996 smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++]; 996 smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++];
997 /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */ 997 /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */
998 if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now 998 if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now
999 smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++]; 999 smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++];
1000 for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++]; 1000 for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++];
1001 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit); 1001 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit);
1002 return ERR_NONE; 1002 return ERR_NONE;
1003 case 0x02: 1003 case 0x02:
1004 smprintf(s, "SMS type - status report\n"); 1004 smprintf(s, "SMS type - status report\n");
1005 sms->PDU = SMS_Status_Report; 1005 sms->PDU = SMS_Status_Report;
1006 sms->Folder = 1;/*INBOX SIM*/ 1006 sms->Folder = 1;/*INBOX SIM*/
1007 sms->InboxFolder = true; 1007 sms->InboxFolder = true;
1008 smprintf(s, "TPMR is %d\n",buffer[current]); 1008 smprintf(s, "TPMR is %d\n",buffer[current]);
1009 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++]; 1009 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++];
1010 current2=((buffer[current])+1)/2+1; 1010 current2=((buffer[current])+1)/2+1;
1011 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; 1011 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
1012 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; 1012 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
1013 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; 1013 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
1014 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; 1014 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
1015 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); 1015 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
1016 return ERR_NONE; 1016 return ERR_NONE;
1017 } 1017 }
1018 break; 1018 break;
1019 case SMS_AT_TXT: 1019 case SMS_AT_TXT:
1020 current = 0; 1020 current = 0;
1021 while (msg.Buffer[current]!='"') current++; 1021 while (msg.Buffer[current]!='"') current++;
1022 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1022 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1023 if (!strcmp(buffer,"\"0\"") || !strcmp(buffer,"\"REC UNREAD\"")) { 1023 if (!strcmp(buffer,"\"0\"") || !strcmp(buffer,"\"REC UNREAD\"")) {
1024 smprintf(s, "SMS type - deliver\n"); 1024 smprintf(s, "SMS type - deliver\n");
1025 sms->State = SMS_UnRead; 1025 sms->State = SMS_UnRead;
1026 sms->PDU = SMS_Deliver; 1026 sms->PDU = SMS_Deliver;
1027 if (Priv->SMSMemory == MEM_SM) { 1027 if (Priv->SMSMemory == MEM_SM) {
1028 sms->Folder = 1; /*INBOX SIM*/ 1028 sms->Folder = 1; /*INBOX SIM*/
1029 } else { 1029 } else {
1030 sms->Folder = 3; /*INBOX ME*/ 1030 sms->Folder = 3; /*INBOX ME*/
1031 } 1031 }
1032 sms->InboxFolder = true; 1032 sms->InboxFolder = true;
1033 } else if (!strcmp(buffer,"\"1\"") || !strcmp(buffer,"\"REC READ\"")) { 1033 } else if (!strcmp(buffer,"\"1\"") || !strcmp(buffer,"\"REC READ\"")) {
1034 smprintf(s, "SMS type - deliver\n"); 1034 smprintf(s, "SMS type - deliver\n");
1035 sms->State = SMS_Read; 1035 sms->State = SMS_Read;
1036 sms->PDU = SMS_Deliver; 1036 sms->PDU = SMS_Deliver;
1037 if (Priv->SMSMemory == MEM_SM) { 1037 if (Priv->SMSMemory == MEM_SM) {
1038 sms->Folder = 1; /*INBOX SIM*/ 1038 sms->Folder = 1; /*INBOX SIM*/
1039 } else { 1039 } else {
1040 sms->Folder = 3; /*INBOX ME*/ 1040 sms->Folder = 3; /*INBOX ME*/
1041 } 1041 }
1042 sms->InboxFolder = true; 1042 sms->InboxFolder = true;
1043 } else if (!strcmp(buffer,"\"2\"") || !strcmp(buffer,"\"STO UNSENT\"")) { 1043 } else if (!strcmp(buffer,"\"2\"") || !strcmp(buffer,"\"STO UNSENT\"")) {
1044 smprintf(s, "SMS type - submit\n"); 1044 smprintf(s, "SMS type - submit\n");
1045 sms->State = SMS_UnSent; 1045 sms->State = SMS_UnSent;
1046 sms->PDU = SMS_Submit; 1046 sms->PDU = SMS_Submit;
1047 if (Priv->SMSMemory == MEM_SM) { 1047 if (Priv->SMSMemory == MEM_SM) {
1048 sms->Folder = 2; /*OUTBOX SIM*/ 1048 sms->Folder = 2; /*OUTBOX SIM*/
1049 } else { 1049 } else {
1050 sms->Folder = 4; /*OUTBOX ME*/ 1050 sms->Folder = 4; /*OUTBOX ME*/
1051 } 1051 }
1052 sms->InboxFolder = false; 1052 sms->InboxFolder = false;
1053 } else if (!strcmp(buffer,"\"3\"") || !strcmp(buffer,"\"STO SENT\"")) { 1053 } else if (!strcmp(buffer,"\"3\"") || !strcmp(buffer,"\"STO SENT\"")) {
1054 smprintf(s, "SMS type - submit\n"); 1054 smprintf(s, "SMS type - submit\n");
1055 sms->State = SMS_Sent; 1055 sms->State = SMS_Sent;
1056 sms->PDU = SMS_Submit; 1056 sms->PDU = SMS_Submit;
1057 if (Priv->SMSMemory == MEM_SM) { 1057 if (Priv->SMSMemory == MEM_SM) {
1058 sms->Folder = 2; /*OUTBOX SIM*/ 1058 sms->Folder = 2; /*OUTBOX SIM*/
1059 } else { 1059 } else {
1060 sms->Folder = 4; /*OUTBOX ME*/ 1060 sms->Folder = 4; /*OUTBOX ME*/
1061 } 1061 }
1062 sms->InboxFolder = false; 1062 sms->InboxFolder = false;
1063 } 1063 }
1064 current += ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1064 current += ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1065 /* It's delivery report according to Nokia AT standards */ 1065 /* It's delivery report according to Nokia AT standards */
1066 if (sms->Folder==1 && buffer[0]!=0 && buffer[0]!='"') { 1066 if (sms->Folder==1 && buffer[0]!=0 && buffer[0]!='"') {
1067 /* ??? */ 1067 /* ??? */
1068 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1068 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1069 /* format of sender number */ 1069 /* format of sender number */
1070 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1070 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1071 /* Sender number */ 1071 /* Sender number */
1072 /* FIXME: support for all formats */ 1072 /* FIXME: support for all formats */
1073 EncodeUnicode(sms->Number,buffer+1,strlen(buffer)-2); 1073 EncodeUnicode(sms->Number,buffer+1,strlen(buffer)-2);
1074 smprintf(s, "Sender \"%s\"\n",DecodeUnicodeString(sms->Number)); 1074 smprintf(s, "Sender \"%s\"\n",DecodeUnicodeString(sms->Number));
1075 /* ??? */ 1075 /* ??? */
1076 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1076 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1077 /* Sending datetime */ 1077 /* Sending datetime */
1078 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); 1078 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
1079 i = strlen(buffer); 1079 i = strlen(buffer);
1080 buffer[i] = ','; 1080 buffer[i] = ',';
1081 i++; 1081 i++;
1082 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer+i); 1082 current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer+i);
1083 smprintf(s, "\"%s\"\n",buffer); 1083 smprintf(s, "\"%s\"\n",buffer);
@@ -3458,405 +3458,411 @@ GSM_Error ATGEN_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
3458 3458
3459 DecodeHexBin (Buffer,msg.Buffer+6,msg.Length-6); 3459 DecodeHexBin (Buffer,msg.Buffer+6,msg.Length-6);
3460 DumpMessage(stdout, di.dl ,Buffer,msg.Length-6); 3460 DumpMessage(stdout, di.dl ,Buffer,msg.Length-6);
3461 3461
3462 CB.Channel = Buffer[4]; 3462 CB.Channel = Buffer[4];
3463 3463
3464 for (j=0;j<msg.Length;j++) { 3464 for (j=0;j<msg.Length;j++) {
3465 smprintf(s, "j=%i\n",j); 3465 smprintf(s, "j=%i\n",j);
3466 i=GSM_UnpackEightBitsToSeven(0, msg.Buffer[6], msg.Buffer[6], msg.Buffer+j, Buffer2); 3466 i=GSM_UnpackEightBitsToSeven(0, msg.Buffer[6], msg.Buffer[6], msg.Buffer+j, Buffer2);
3467 //i = msg.Buffer[6] - 1; 3467 //i = msg.Buffer[6] - 1;
3468 //while (i!=0) { 3468 //while (i!=0) {
3469 // if (Buffer[i] == 13) i = i - 1; else break; 3469 // if (Buffer[i] == 13) i = i - 1; else break;
3470 //} 3470 //}
3471 DecodeDefault(CB.Text, Buffer2, msg.Buffer[6], false, NULL); 3471 DecodeDefault(CB.Text, Buffer2, msg.Buffer[6], false, NULL);
3472 smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text)); 3472 smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text));
3473 } 3473 }
3474 if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) { 3474 if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) {
3475 s->User.IncomingCB(s->CurrentConfig->Device,CB); 3475 s->User.IncomingCB(s->CurrentConfig->Device,CB);
3476 } 3476 }
3477 return ERR_NONE; 3477 return ERR_NONE;
3478} 3478}
3479 3479
3480#endif 3480#endif
3481 3481
3482GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable) 3482GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
3483{ 3483{
3484#ifdef GSM_ENABLE_CELLBROADCAST 3484#ifdef GSM_ENABLE_CELLBROADCAST
3485 if (s->Phone.Data.EnableIncomingCB!=enable) { 3485 if (s->Phone.Data.EnableIncomingCB!=enable) {
3486 s->Phone.Data.EnableIncomingCB = enable; 3486 s->Phone.Data.EnableIncomingCB = enable;
3487 if (enable) { 3487 if (enable) {
3488 smprintf(s, "Enabling incoming CB\n"); 3488 smprintf(s, "Enabling incoming CB\n");
3489 return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB); 3489 return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB);
3490 } else { 3490 } else {
3491 smprintf(s, "Disabling incoming CB\n"); 3491 smprintf(s, "Disabling incoming CB\n");
3492 return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB); 3492 return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB);
3493 } 3493 }
3494 } 3494 }
3495 return ERR_NONE; 3495 return ERR_NONE;
3496#else 3496#else
3497 return ERR_SOURCENOTAVAILABLE; 3497 return ERR_SOURCENOTAVAILABLE;
3498#endif 3498#endif
3499} 3499}
3500 3500
3501GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable) 3501GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3502{ 3502{
3503 if (enable) { 3503 if (enable) {
3504 smprintf(s, "Enabling fast SMS sending\n"); 3504 smprintf(s, "Enabling fast SMS sending\n");
3505 return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending); 3505 return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending);
3506 } else { 3506 } else {
3507 smprintf(s, "Disabling fast SMS sending\n"); 3507 smprintf(s, "Disabling fast SMS sending\n");
3508 return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending); 3508 return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending);
3509 } 3509 }
3510} 3510}
3511 3511
3512GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 3512GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
3513{ 3513{
3514 smprintf(s, "Incoming SMS\n"); 3514 smprintf(s, "Incoming SMS\n");
3515 return ERR_NONE; 3515 return ERR_NONE;
3516} 3516}
3517 3517
3518GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s) 3518GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s)
3519{ 3519{
3520 GSM_Phone_Data *Data = &s->Phone.Data; 3520 GSM_Phone_Data *Data = &s->Phone.Data;
3521 GSM_SMSMessage sms; 3521 GSM_SMSMessage sms;
3522 int current = 0, current2, i=0; 3522 int current = 0, current2, i=0;
3523 unsigned char buffer[300],smsframe[800]; 3523 unsigned char buffer[300],smsframe[800];
3524 3524
3525 smprintf(s, "Incoming SMS received (Deliver)\n"); 3525 smprintf(s, "Incoming SMS received (Deliver)\n");
3526 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) { 3526 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
3527 sms.State = SMS_UnRead; 3527 sms.State = SMS_UnRead;
3528 sms.InboxFolder = true; 3528 sms.InboxFolder = true;
3529 sms.PDU = SMS_Deliver; 3529 sms.PDU = SMS_Deliver;
3530 3530
3531 /* T310 with larger SMS goes crazy and mix this incoming 3531 /* T310 with larger SMS goes crazy and mix this incoming
3532 * frame with normal answers. PDU is always last frame 3532 * frame with normal answers. PDU is always last frame
3533 * We find its' number and parse it */ 3533 * We find its' number and parse it */
3534 while (Data->Priv.ATGEN.Lines.numbers[i*2+1] != 0) { 3534 while (Data->Priv.ATGEN.Lines.numbers[i*2+1] != 0) {
3535 /* FIXME: handle special chars correctly */ 3535 /* FIXME: handle special chars correctly */
3536 i++; 3536 i++;
3537 } 3537 }
3538 DecodeHexBin (buffer, 3538 DecodeHexBin (buffer,
3539 GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i), 3539 GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i),
3540 strlen(GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i))); 3540 strlen(GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i)));
3541 3541
3542 /* We use locations from SMS layouts like in ../phone2.c(h) */ 3542 /* We use locations from SMS layouts like in ../phone2.c(h) */
3543 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++]; 3543 for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++];
3544 smsframe[12]=buffer[current++]; 3544 smsframe[12]=buffer[current++];
3545 3545
3546 current2=((buffer[current])+1)/2+1; 3546 current2=((buffer[current])+1)/2+1;
3547 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 3547 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
3548 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; 3548 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++];
3549 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; 3549 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++];
3550 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++]; 3550 for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++];
3551 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++]; 3551 smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++];
3552 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++]; 3552 for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++];
3553 GSM_DecodeSMSFrame(&sms,smsframe,PHONE_SMSDeliver); 3553 GSM_DecodeSMSFrame(&sms,smsframe,PHONE_SMSDeliver);
3554 3554
3555 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 3555 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
3556 } 3556 }
3557 return ERR_NONE; 3557 return ERR_NONE;
3558} 3558}
3559 3559
3560/* I don't have phone able to do it and can't fill it */ 3560/* I don't have phone able to do it and can't fill it */
3561GSM_Error ATGEN_IncomingSMSReport(GSM_Protocol_Message msg, GSM_StateMachine *s) 3561GSM_Error ATGEN_IncomingSMSReport(GSM_Protocol_Message msg, GSM_StateMachine *s)
3562{ 3562{
3563 smprintf(s, "Incoming SMS received (Report)\n"); 3563 smprintf(s, "Incoming SMS received (Report)\n");
3564 return ERR_NONE; 3564 return ERR_NONE;
3565} 3565}
3566 3566
3567GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable) 3567GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
3568{ 3568{
3569 /* Nokia returns OK, but doesn't return anything */ 3569 /* Nokia returns OK, but doesn't return anything */
3570 if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Nokia) return ERR_NOTSUPPORTED; 3570 if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Nokia) return ERR_NOTSUPPORTED;
3571 3571
3572 if (s->Phone.Data.EnableIncomingSMS!=enable) { 3572 if (s->Phone.Data.EnableIncomingSMS!=enable) {
3573 s->Phone.Data.EnableIncomingSMS = enable; 3573 s->Phone.Data.EnableIncomingSMS = enable;
3574 if (enable) { 3574 if (enable) {
3575 smprintf(s, "Enabling incoming SMS\n"); 3575 smprintf(s, "Enabling incoming SMS\n");
3576 3576
3577 /* Delivery reports */ 3577 /* Delivery reports */
3578 GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS); 3578 GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS);
3579 3579
3580 /* SMS deliver */ 3580 /* SMS deliver */
3581 return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS); 3581 return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS);
3582 } else { 3582 } else {
3583 smprintf(s, "Disabling incoming SMS\n"); 3583 smprintf(s, "Disabling incoming SMS\n");
3584 return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS); 3584 return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS);
3585 } 3585 }
3586 } 3586 }
3587 return ERR_NONE; 3587 return ERR_NONE;
3588} 3588}
3589 3589
3590GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale) 3590GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3591{ 3591{
3592 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale); 3592 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale);
3593 return ERR_NOTSUPPORTED; 3593 return ERR_NOTSUPPORTED;
3594} 3594}
3595 3595
3596GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale) 3596GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3597{ 3597{
3598 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale); 3598 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale);
3599 return ERR_NOTSUPPORTED; 3599 return ERR_NOTSUPPORTED;
3600} 3600}
3601 3601
3602GSM_Reply_Function ATGENReplyFunctions[] = { 3602GSM_Reply_Function ATGENReplyFunctions[] = {
3603 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame }, 3603 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame },
3604 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho }, 3604 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho },
3605 {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo }, 3605 {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo },
3606 {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey }, 3606 {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey },
3607 {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI }, 3607 {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI },
3608 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX }, 3608 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX },
3609 3609
3610 {ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale }, 3610 {ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale },
3611 {ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale }, 3611 {ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale },
3612 {ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale }, 3612 {ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale },
3613 {ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale }, 3613 {ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale },
3614 3614
3615#ifdef GSM_ENABLE_CELLBROADCAST 3615#ifdef GSM_ENABLE_CELLBROADCAST
3616 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame }, 3616 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame },
3617 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB }, 3617 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB },
3618#endif 3618#endif
3619 3619
3620 {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame }, 3620 {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame },
3621 {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge }, 3621 {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge },
3622 3622
3623 {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel }, 3623 {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel },
3624 {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer }, 3624 {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer },
3625 {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware }, 3625 {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware },
3626 {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware }, 3626 {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware },
3627 {ATGEN_ReplyGetIMEI, "AT+CGSN" ,0x00,0x00,ID_GetIMEI }, 3627 {ATGEN_ReplyGetIMEI, "AT+CGSN" ,0x00,0x00,ID_GetIMEI },
3628 3628
3629 {ATGEN_ReplySendSMS, "AT+CMGS" ,0x00,0x00,ID_IncomingFrame }, 3629 {ATGEN_ReplySendSMS, "AT+CMGS" ,0x00,0x00,ID_IncomingFrame },
3630 {ATGEN_ReplySendSMS, "AT+CMSS" ,0x00,0x00,ID_IncomingFrame }, 3630 {ATGEN_ReplySendSMS, "AT+CMSS" ,0x00,0x00,ID_IncomingFrame },
3631 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingSMS }, 3631 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingSMS },
3632 {ATGEN_GenericReply, "AT+CMGF" ,0x00,0x00,ID_GetSMSMode }, 3632 {ATGEN_GenericReply, "AT+CMGF" ,0x00,0x00,ID_GetSMSMode },
3633 {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode }, 3633 {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode },
3634 {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage }, 3634 {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage },
3635 {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType }, 3635 {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType },
3636 {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus }, 3636 {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus },
3637 {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories }, 3637 {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories },
3638 {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage }, 3638 {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage },
3639 {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters }, 3639 {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters },
3640 {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC }, 3640 {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC },
3641 {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC }, 3641 {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC },
3642 {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage }, 3642 {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage },
3643 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters }, 3643 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters },
3644 {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters }, 3644 {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters },
3645 {ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending }, 3645 {ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending },
3646 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame }, 3646 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame },
3647 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame }, 3647 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame },
3648 {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame }, 3648 {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame },
3649 {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame }, 3649 {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame },
3650 3650
3651 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime }, 3651 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime },
3652 {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime }, 3652 {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime },
3653 {ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm }, 3653 {ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm },
3654 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm }, 3654 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm },
3655 3655
3656 {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo }, 3656 {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo },
3657 {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo }, 3657 {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo },
3658 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo }, 3658 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo },
3659 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin}, 3659 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin},
3660 {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo }, 3660 {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo },
3661 {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality }, 3661 {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality },
3662 {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame }, 3662 {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame },
3663 {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame }, 3663 {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame },
3664 {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame }, 3664 {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame },
3665 3665
3666 {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType }, 3666 {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType },
3667 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType }, 3667 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType },
3668 {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus }, 3668 {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus },
3669// /* Samsung phones reply +CPBR: after OK --claudio*/ 3669// /* Samsung phones reply +CPBR: after OK --claudio*/
3670 {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus }, 3670 {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus },
3671 {ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus }, 3671 {ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus },
3672 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus }, 3672 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus },
3673 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset }, 3673 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset },
3674 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory }, 3674 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory },
3675 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory }, 3675 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory },
3676 {SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory }, 3676 {SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
3677 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory }, 3677 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory },
3678 3678
3679 {SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap }, 3679 {SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
3680 {SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap }, 3680 {SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
3681 3681
3682 {SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone }, 3682 {SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
3683 {SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone }, 3683 {SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
3684 3684
3685 {SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote }, 3685 {SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
3686 {SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote }, 3686 {SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
3687 {SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote }, 3687 {SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote },
3688 3688
3689 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode }, 3689 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode },
3690 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode }, 3690 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode },
3691 {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus }, 3691 {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus },
3692 {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame }, 3692 {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame },
3693 3693
3694 {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF }, 3694 {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF },
3695 {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall }, 3695 {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall },
3696 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice }, 3696 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice },
3697 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall }, 3697 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall },
3698 {ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD }, 3698 {ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
3699 {ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame }, 3699 {ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
3700 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame }, 3700 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
3701 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame }, 3701 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
3702 {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame }, 3702 {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame },
3703 {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame }, 3703 {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame },
3704 {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame }, 3704 {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame },
3705 3705
3706 {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset }, 3706 {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset },
3707 {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset }, 3707 {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset },
3708 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings }, 3708 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings },
3709 3709
3710 {SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap }, 3710 {SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap },
3711 {SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap }, 3711 {SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap },
3712 3712
3713 {SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone }, 3713 {SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone },
3714 {SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone }, 3714 {SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone },
3715 3715
3716#ifdef GSM_ENABLE_ALCATEL 3716#ifdef GSM_ENABLE_ALCATEL
3717/* Why do I give Alcatel specific things here? It's simple, Alcatel needs 3717/* Why do I give Alcatel specific things here? It's simple, Alcatel needs
3718 * some AT commands to start it's binary mode, so this needs to be in AT 3718 * some AT commands to start it's binary mode, so this needs to be in AT
3719 * related stuff. 3719 * related stuff.
3720 * 3720 *
3721 * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel 3721 * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel
3722 * specific and it's part of ETSI specifications 3722 * specific and it's part of ETSI specifications
3723 */ 3723 */
3724 {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl }, 3724 {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl },
3725 {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol }, 3725 {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol },
3726 {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect }, 3726 {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect },
3727#endif 3727#endif
3728 3728
3729 {NULL, "\x00" ,0x00,0x00,ID_None } 3729 {NULL, "\x00" ,0x00,0x00,ID_None }
3730}; 3730};
3731 3731
3732GSM_Phone_Functions ATGENPhone = { 3732GSM_Phone_Functions ATGENPhone = {
3733 "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210", 3733 "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210",
3734 ATGENReplyFunctions, 3734 ATGENReplyFunctions,
3735 ATGEN_Initialise, 3735 ATGEN_Initialise,
3736 ATGEN_Terminate, 3736 ATGEN_Terminate,
3737 ATGEN_DispatchMessage, 3737 ATGEN_DispatchMessage,
3738 NOTSUPPORTED, /* ShowStartInfo */ 3738 NOTSUPPORTED, /* ShowStartInfo */
3739 ATGEN_GetManufacturer, 3739 ATGEN_GetManufacturer,
3740 ATGEN_GetModel, 3740 ATGEN_GetModel,
3741 ATGEN_GetFirmware, 3741 ATGEN_GetFirmware,
3742 ATGEN_GetIMEI, 3742 ATGEN_GetIMEI,
3743 NOTSUPPORTED, /* GetOriginalIMEI */ 3743 NOTSUPPORTED, /* GetOriginalIMEI */
3744 NOTSUPPORTED, /* GetManufactureMonth*/ 3744 NOTSUPPORTED, /* GetManufactureMonth*/
3745 NOTSUPPORTED, /* GetProductCode */ 3745 NOTSUPPORTED, /* GetProductCode */
3746 NOTSUPPORTED, /* GetHardware */ 3746 NOTSUPPORTED, /* GetHardware */
3747 NOTSUPPORTED, /* GetPPM */ 3747 NOTSUPPORTED, /* GetPPM */
3748 ATGEN_GetSIMIMSI, 3748 ATGEN_GetSIMIMSI,
3749 ATGEN_GetDateTime, 3749 ATGEN_GetDateTime,
3750 ATGEN_SetDateTime, 3750 ATGEN_SetDateTime,
3751 ATGEN_GetAlarm, 3751 ATGEN_GetAlarm,
3752 ATGEN_SetAlarm, 3752 ATGEN_SetAlarm,
3753 ATGEN_GetLocale, 3753 ATGEN_GetLocale,
3754 ATGEN_SetLocale, 3754 ATGEN_SetLocale,
3755 ATGEN_PressKey, 3755 ATGEN_PressKey,
3756 ATGEN_Reset, 3756 ATGEN_Reset,
3757 ATGEN_ResetPhoneSettings, 3757 ATGEN_ResetPhoneSettings,
3758 ATGEN_EnterSecurityCode, 3758 ATGEN_EnterSecurityCode,
3759 ATGEN_GetSecurityStatus, 3759 ATGEN_GetSecurityStatus,
3760 ATGEN_GetDisplayStatus, 3760 ATGEN_GetDisplayStatus,
3761 ATGEN_SetAutoNetworkLogin, 3761 ATGEN_SetAutoNetworkLogin,
3762 ATGEN_GetBatteryCharge, 3762 ATGEN_GetBatteryCharge,
3763 ATGEN_GetSignalQuality, 3763 ATGEN_GetSignalQuality,
3764 ATGEN_GetNetworkInfo, 3764 ATGEN_GetNetworkInfo,
3765 NOTSUPPORTED, /* GetCategory */ 3765 NOTSUPPORTED, /* GetCategory */
3766 NOTSUPPORTED, /* AddCategory */ 3766 NOTSUPPORTED, /* AddCategory */
3767 NOTSUPPORTED, /* GetCategoryStatus */ 3767 NOTSUPPORTED, /* GetCategoryStatus */
3768 ATGEN_GetMemoryStatus, 3768 ATGEN_GetMemoryStatus,
3769 ATGEN_GetMemory, 3769 ATGEN_GetMemory,
3770 ATGEN_GetNextMemory, 3770 ATGEN_GetNextMemory,
3771 ATGEN_SetMemory, 3771 ATGEN_SetMemory,
3772 ATGEN_AddMemory, 3772 ATGEN_AddMemory,
3773 ATGEN_DeleteMemory, 3773 ATGEN_DeleteMemory,
3774 ATGEN_DeleteAllMemory, 3774 ATGEN_DeleteAllMemory,
3775 NOTSUPPORTED, /* GetSpeedDial */ 3775 NOTSUPPORTED, /* GetSpeedDial */
3776 NOTSUPPORTED, /* SetSpeedDial */ 3776 NOTSUPPORTED, /* SetSpeedDial */
3777 ATGEN_GetSMSC, 3777 ATGEN_GetSMSC,
3778 ATGEN_SetSMSC, 3778 ATGEN_SetSMSC,
3779 ATGEN_GetSMSStatus, 3779 ATGEN_GetSMSStatus,
3780 ATGEN_GetSMS, 3780 ATGEN_GetSMS,
3781 ATGEN_GetNextSMS, 3781 ATGEN_GetNextSMS,
3782 NOTSUPPORTED, /* SetSMS */ 3782 NOTSUPPORTED, /* SetSMS */
3783 ATGEN_AddSMS, 3783 ATGEN_AddSMS,
3784 ATGEN_DeleteSMS, 3784 ATGEN_DeleteSMS,
3785 ATGEN_SendSMS, 3785 ATGEN_SendSMS,
3786 ATGEN_SendSavedSMS, 3786 ATGEN_SendSavedSMS,
3787 ATGEN_SetFastSMSSending, 3787 ATGEN_SetFastSMSSending,
3788 ATGEN_SetIncomingSMS, 3788 ATGEN_SetIncomingSMS,
3789 ATGEN_SetIncomingCB, 3789 ATGEN_SetIncomingCB,
3790 ATGEN_GetSMSFolders, 3790 ATGEN_GetSMSFolders,
3791 NOTSUPPORTED, /* AddSMSFolder */ 3791 NOTSUPPORTED, /* AddSMSFolder */
3792 NOTSUPPORTED, /* DeleteSMSFolder */ 3792 NOTSUPPORTED, /* DeleteSMSFolder */
3793 ATGEN_DialVoice, 3793 ATGEN_DialVoice,
3794 ATGEN_AnswerCall, 3794 ATGEN_AnswerCall,
3795 ATGEN_CancelCall, 3795 ATGEN_CancelCall,
3796 NOTSUPPORTED, /* HoldCall */ 3796 NOTSUPPORTED, /* HoldCall */
3797 NOTSUPPORTED, /* UnholdCall */ 3797 NOTSUPPORTED, /* UnholdCall */
3798 NOTSUPPORTED, /* ConferenceCall */ 3798 NOTSUPPORTED, /* ConferenceCall */
3799 NOTSUPPORTED, /* SplitCall */ 3799 NOTSUPPORTED, /* SplitCall */
3800 NOTSUPPORTED, /* TransferCall */ 3800 NOTSUPPORTED, /* TransferCall */
3801 NOTSUPPORTED, /* SwitchCall */ 3801 NOTSUPPORTED, /* SwitchCall */
3802 NOTSUPPORTED, /* GetCallDivert */ 3802 NOTSUPPORTED, /* GetCallDivert */
3803 NOTSUPPORTED, /* SetCallDivert */ 3803 NOTSUPPORTED, /* SetCallDivert */
3804 NOTSUPPORTED, /* CancelAllDiverts*/ 3804 NOTSUPPORTED, /* CancelAllDiverts*/
3805 NONEFUNCTION, /* SetIncomingCall */ 3805 NONEFUNCTION, /* SetIncomingCall */
3806 ATGEN_SetIncomingUSSD, 3806 ATGEN_SetIncomingUSSD,
3807 ATGEN_SendDTMF, 3807 ATGEN_SendDTMF,
3808 ATGEN_GetRingtone, 3808 ATGEN_GetRingtone,
3809 ATGEN_SetRingtone, 3809 ATGEN_SetRingtone,
3810 NOTSUPPORTED, /* GetRingtonesInfo*/ 3810 NOTSUPPORTED, /* GetRingtonesInfo*/
3811 NOTSUPPORTED, /* DeleteUserRingtones*/ 3811 NOTSUPPORTED, /* DeleteUserRingtones*/
3812 NOTSUPPORTED, /* PlayTone */ 3812 NOTSUPPORTED, /* PlayTone */
3813 NOTSUPPORTED, /* GetWAPBookmark */ 3813 NOTSUPPORTED, /* GetWAPBookmark */
3814 NOTSUPPORTED, /* SetWAPBookmark */ 3814 NOTSUPPORTED, /* SetWAPBookmark */
3815 NOTSUPPORTED, /* DeleteWAPBookmark */ 3815 NOTSUPPORTED, /* DeleteWAPBookmark */
3816 NOTSUPPORTED, /* GetWAPSettings */ 3816 NOTSUPPORTED, /* GetWAPSettings */
3817 NOTSUPPORTED, /* SetWAPSettings */ 3817 NOTSUPPORTED, /* SetWAPSettings */
3818 NOTSUPPORTED, /* GetMMSSettings */ 3818 NOTSUPPORTED, /* GetMMSSettings */
3819 NOTSUPPORTED, /* SetMMSSettings */ 3819 NOTSUPPORTED, /* SetMMSSettings */
3820 NOTSUPPORTED, /* GetSyncMLSettings*/ 3820 NOTSUPPORTED, /* GetSyncMLSettings*/
3821 NOTSUPPORTED, /* SetSyncMLSettings*/ 3821 NOTSUPPORTED, /* SetSyncMLSettings*/
3822 NOTSUPPORTED, /* GetChatSettings */ 3822 NOTSUPPORTED, /* GetChatSettings */
3823 NOTSUPPORTED, /* SetChatSettings */ 3823 NOTSUPPORTED, /* SetChatSettings */
3824 ATGEN_GetBitmap, /* GetBitmap */ 3824 ATGEN_GetBitmap, /* GetBitmap */
3825 ATGEN_SetBitmap, /* SetBitmap */ 3825 ATGEN_SetBitmap, /* SetBitmap */
3826 SONYERIC_GetToDoStatus, 3826 SONYERIC_GetToDoStatus,
3827 NOTSUPPORTED, /* GetToDo */ 3827 NOTSUPPORTED, /* GetToDo */
3828 SONYERIC_GetNextToDo, 3828 SONYERIC_GetNextToDo,
3829 NOTSUPPORTED, /* SetToDo */ 3829 NOTSUPPORTED, /* SetToDo */
3830 SONYERIC_AddToDo, 3830 SONYERIC_AddToDo,
3831 NOTSUPPORTED, /* DeleteToDo */ 3831 NOTSUPPORTED, /* DeleteToDo */
3832 SONYERIC_DeleteAllToDo, 3832 SONYERIC_DeleteAllToDo,
3833 SONYERIC_GetCalendarStatus, 3833 SONYERIC_GetCalendarStatus,
3834 NOTIMPLEMENTED, /* GetCalendar */ 3834 NOTIMPLEMENTED, /* GetCalendar */
3835 ATGEN_GetNextCalendar, 3835 ATGEN_GetNextCalendar,
3836 NOTIMPLEMENTED, /* SetCalendar */ 3836 NOTIMPLEMENTED, /* SetCalendar */
3837 ATGEN_AddCalendarNote, 3837 ATGEN_AddCalendarNote,
3838 ATGEN_DelCalendarNote, 3838 ATGEN_DelCalendarNote,
3839 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 3839 NOTIMPLEMENTED, /* DeleteAllCalendar*/
3840 NOTSUPPORTED, /* GetCalendarSettings*/ 3840 NOTSUPPORTED, /* GetCalendarSettings*/
3841 NOTSUPPORTED, /* SetCalendarSettings*/ 3841 NOTSUPPORTED, /* SetCalendarSettings*/
3842 NOTSUPPORTED, /* GetNoteStatus */
3843 NOTSUPPORTED, /* GetNote */
3842 NOTSUPPORTED, /* GetNextNote */ 3844 NOTSUPPORTED, /* GetNextNote */
3845 NOTSUPPORTED, /* SetNote */
3846 NOTSUPPORTED, /* AddNote */
3847 NOTSUPPORTED, /* DeleteNote */
3848 NOTSUPPORTED, /* DeleteAllNotes */
3843 NOTSUPPORTED, /* GetProfile */ 3849 NOTSUPPORTED, /* GetProfile */
3844 NOTSUPPORTED, /* SetProfile */ 3850 NOTSUPPORTED, /* SetProfile */
3845 NOTSUPPORTED, /* GetFMStation */ 3851 NOTSUPPORTED, /* GetFMStation */
3846 NOTSUPPORTED, /* SetFMStation */ 3852 NOTSUPPORTED, /* SetFMStation */
3847 NOTSUPPORTED, /* ClearFMStations */ 3853 NOTSUPPORTED, /* ClearFMStations */
3848 NOTSUPPORTED, /* GetNextFileFolder*/ 3854 NOTSUPPORTED, /* GetNextFileFolder*/
3849 NOTSUPPORTED, /* GetFilePart */ 3855 NOTSUPPORTED, /* GetFilePart */
3850 NOTSUPPORTED, /* AddFile */ 3856 NOTSUPPORTED, /* AddFile */
3851 NOTSUPPORTED, /* GetFileSystemStatus*/ 3857 NOTSUPPORTED, /* GetFileSystemStatus*/
3852 NOTSUPPORTED, /* DeleteFile */ 3858 NOTSUPPORTED, /* DeleteFile */
3853 NOTSUPPORTED, /* AddFolder */ 3859 NOTSUPPORTED, /* AddFolder */
3854 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 3860 NOTSUPPORTED, /* GetGPRSAccessPoint*/
3855 NOTSUPPORTED /* SetGPRSAccessPoint*/ 3861 NOTSUPPORTED /* SetGPRSAccessPoint*/
3856}; 3862};
3857 3863
3858#endif 3864#endif
3859 3865
3860/* How should editor hadle tabs in this file? Add editor commands here. 3866/* How should editor hadle tabs in this file? Add editor commands here.
3861 * vim: noexpandtab sw=8 ts=8 sts=8: 3867 * vim: noexpandtab sw=8 ts=8 sts=8:
3862 */ 3868 */
diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c
index 8eeb39b..363e043 100644
--- a/gammu/emb/common/phone/at/sonyeric.c
+++ b/gammu/emb/common/phone/at/sonyeric.c
@@ -1,520 +1,521 @@
1/* (c) 2003 by Marcin Wiacek */ 1/* (c) 2003 by Marcin Wiacek */
2 2
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13 13
14#include "atgen.h" 14#include "atgen.h"
15#include "sonyeric.h" 15#include "sonyeric.h"
16 16
17#ifdef GSM_ENABLE_OBEXGEN 17#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
18 18
19#include "../obex/obexgen.h" 19#include "../obex/obexgen.h"
20 20
21 extern GSM_Protocol_Functions OBEXProtocol;
21 extern GSM_Reply_FunctionOBEXGENReplyFunctions[]; 22 extern GSM_Reply_FunctionOBEXGENReplyFunctions[];
22 extern GSM_Reply_FunctionATGENReplyFunctions[]; 23 extern GSM_Reply_FunctionATGENReplyFunctions[];
23 24
24static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s) 25static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
25{ 26{
26 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 27 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
27 GSM_Error error; 28 GSM_Error error;
28 29
29 if (Priv->OBEX) return ERR_NONE; 30 if (Priv->OBEX) return ERR_NONE;
30 31
31 dbgprintf ("Changing to OBEX\n"); 32 dbgprintf ("Changing to OBEX\n");
32 33
33 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX); 34 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX);
34 if (error != ERR_NONE) return error; 35 if (error != ERR_NONE) return error;
35 36
36 error = s->Protocol.Functions->Terminate(s); 37 error = s->Protocol.Functions->Terminate(s);
37 if (error != ERR_NONE) return error; 38 if (error != ERR_NONE) return error;
38 39
39 s->Protocol.Functions = &OBEXProtocol; 40 s->Protocol.Functions = &OBEXProtocol;
40 error = s->Protocol.Functions->Initialise(s); 41 error = s->Protocol.Functions->Initialise(s);
41 if (error != ERR_NONE) { 42 if (error != ERR_NONE) {
42 s->Protocol.Functions = &ATProtocol; 43 s->Protocol.Functions = &ATProtocol;
43 return error; 44 return error;
44 } 45 }
45 strcpy(s->CurrentConfig->Model,"seobex"); 46 strcpy(s->CurrentConfig->Model,"seobex");
46 s->Phone.Data.Priv.OBEXGEN.Service = 0; 47 s->Phone.Data.Priv.OBEXGEN.Service = 0;
47 s->Phone.Functions->DispatchMessage= GSM_DispatchMessage; 48 s->Phone.Functions->DispatchMessage= GSM_DispatchMessage;
48 s->Phone.Functions->ReplyFunctions= OBEXGENReplyFunctions; 49 s->Phone.Functions->ReplyFunctions= OBEXGENReplyFunctions;
49 Priv->OBEX = true; 50 Priv->OBEX = true;
50 return ERR_NONE; 51 return ERR_NONE;
51} 52}
52 53
53static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s) 54static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s)
54{ 55{
55 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 56 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
56 GSM_Error error; 57 GSM_Error error;
57 58
58 if (!Priv->OBEX) return ERR_NONE; 59 if (!Priv->OBEX) return ERR_NONE;
59 60
60 dbgprintf ("Changing to AT\n"); 61 dbgprintf ("Changing to AT\n");
61 62
62 error = OBEXGEN_Disconnect(s); 63 error = OBEXGEN_Disconnect(s);
63 if (error != ERR_NONE) return error; 64 if (error != ERR_NONE) return error;
64 65
65 error = s->Protocol.Functions->Terminate(s); 66 error = s->Protocol.Functions->Terminate(s);
66 if (error != ERR_NONE) return error; 67 if (error != ERR_NONE) return error;
67 68
68 s->Protocol.Functions = &ATProtocol; 69 s->Protocol.Functions = &ATProtocol;
69 error = s->Protocol.Functions->Initialise(s); 70 error = s->Protocol.Functions->Initialise(s);
70 if (error != ERR_NONE) { 71 if (error != ERR_NONE) {
71 s->Protocol.Functions = &OBEXProtocol; 72 s->Protocol.Functions = &OBEXProtocol;
72 return error; 73 return error;
73 } 74 }
74 strcpy(s->CurrentConfig->Model,"at"); 75 strcpy(s->CurrentConfig->Model,"at");
75 s->Phone.Functions->DispatchMessage= ATGEN_DispatchMessage; 76 s->Phone.Functions->DispatchMessage= ATGEN_DispatchMessage;
76 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; 77 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions;
77 Priv->OBEX = false; 78 Priv->OBEX = false;
78 return ERR_NONE; 79 return ERR_NONE;
79} 80}
80 81
81static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName) 82static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName)
82{ 83{
83 GSM_Error error; 84 GSM_Error error;
84 85
85 strcpy(File->ID_FullName,FileName); 86 strcpy(File->ID_FullName,FileName);
86 File->Used = 0; 87 File->Used = 0;
87 if (File->Buffer != NULL) free(File->Buffer); 88 if (File->Buffer != NULL) free(File->Buffer);
88 File->Buffer = NULL; 89 File->Buffer = NULL;
89 90
90 error = SONYERIC_SetOBEXMode(s); 91 error = SONYERIC_SetOBEXMode(s);
91 if (error != ERR_NONE) return error; 92 if (error != ERR_NONE) return error;
92 93
93 error = ERR_NONE; 94 error = ERR_NONE;
94 while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File); 95 while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File);
95 if (error != ERR_EMPTY) return error; 96 if (error != ERR_EMPTY) return error;
96 97
97 return SONYERIC_SetATMode(s); 98 return SONYERIC_SetATMode(s);
98} 99}
99 100
100static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length) 101static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length)
101{ 102{
102 GSM_Errorerror; 103 GSM_Errorerror;
103 GSM_File File; 104 GSM_File File;
104 int Pos = 0; 105 int Pos = 0;
105 106
106 error = SONYERIC_SetOBEXMode(s); 107 error = SONYERIC_SetOBEXMode(s);
107 if (error != ERR_NONE) return error; 108 if (error != ERR_NONE) return error;
108 109
109 strcpy(File.ID_FullName,FileName); 110 strcpy(File.ID_FullName,FileName);
110 EncodeUnicode(File.Name,FileName,strlen(FileName)); 111 EncodeUnicode(File.Name,FileName,strlen(FileName));
111 File.Used = Length; 112 File.Used = Length;
112 File.Buffer = malloc(Length); 113 File.Buffer = malloc(Length);
113 memcpy(File.Buffer,Buffer,Length); 114 memcpy(File.Buffer,Buffer,Length);
114 115
115 error = ERR_NONE; 116 error = ERR_NONE;
116 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos); 117 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos);
117 free(File.Buffer); 118 free(File.Buffer);
118 if (error != ERR_EMPTY) return error; 119 if (error != ERR_EMPTY) return error;
119 120
120 return SONYERIC_SetATMode(s); 121 return SONYERIC_SetATMode(s);
121} 122}
122 123
123#endif 124#endif
124 125
125GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 126GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
126{ 127{
127#ifdef GSM_ENABLE_OBEXGEN 128#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
128 GSM_Error error; 129 GSM_Error error;
129 GSM_ToDoEntry ToDo; 130 GSM_ToDoEntry ToDo;
130 int Pos, num, Loc; 131 int Pos, num, Loc;
131 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 132 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
132 133
133 if (start) { 134 if (start) {
134 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 135 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
135 if (error != ERR_NONE) return error; 136 if (error != ERR_NONE) return error;
136 137
137 Note->Location = 1; 138 Note->Location = 1;
138 } else { 139 } else {
139 Note->Location++; 140 Note->Location++;
140 } 141 }
141 smprintf(s, "Getting calendar note %i\n",Note->Location); 142 smprintf(s, "Getting calendar note %i\n",Note->Location);
142 143
143 Loc = Note->Location; 144 Loc = Note->Location;
144 Pos = 0; 145 Pos = 0;
145 num = 0; 146 num = 0;
146 while (1) { 147 while (1) {
147 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 148 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
148 if (error == ERR_EMPTY) break; 149 if (error == ERR_EMPTY) break;
149 if (error != ERR_NONE) return error; 150 if (error != ERR_NONE) return error;
150 if (Note->EntriesNum != 0) { 151 if (Note->EntriesNum != 0) {
151 num++; 152 num++;
152 if (num == Loc) return ERR_NONE; 153 if (num == Loc) return ERR_NONE;
153 } 154 }
154 } 155 }
155 return ERR_EMPTY; 156 return ERR_EMPTY;
156#else 157#else
157 return ERR_SOURCENOTAVAILABLE; 158 return ERR_SOURCENOTAVAILABLE;
158#endif 159#endif
159} 160}
160 161
161GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 162GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
162{ 163{
163#ifdef GSM_ENABLE_OBEXGEN 164#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
164 GSM_Error error; 165 GSM_Error error;
165 GSM_CalendarEntryCalendar; 166 GSM_CalendarEntryCalendar;
166 int Pos, num, Loc; 167 int Pos, num, Loc;
167 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 168 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
168 169
169 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 170 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
170 171
171 if (start) { 172 if (start) {
172 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 173 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
173 if (error != ERR_NONE) return error; 174 if (error != ERR_NONE) return error;
174 175
175 ToDo->Location = 1; 176 ToDo->Location = 1;
176 } else { 177 } else {
177 ToDo->Location++; 178 ToDo->Location++;
178 } 179 }
179 smprintf(s,"Getting ToDo %i\n",ToDo->Location); 180 smprintf(s,"Getting ToDo %i\n",ToDo->Location);
180 181
181 Loc = ToDo->Location; 182 Loc = ToDo->Location;
182 Pos = 0; 183 Pos = 0;
183 num = 0; 184 num = 0;
184 while (1) { 185 while (1) {
185 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 186 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
186 if (error == ERR_EMPTY) break; 187 if (error == ERR_EMPTY) break;
187 if (error != ERR_NONE) return error; 188 if (error != ERR_NONE) return error;
188 if (ToDo->EntriesNum != 0) { 189 if (ToDo->EntriesNum != 0) {
189 num++; 190 num++;
190 if (num == Loc) return ERR_NONE; 191 if (num == Loc) return ERR_NONE;
191 } 192 }
192 } 193 }
193 194
194 return ERR_EMPTY; 195 return ERR_EMPTY;
195#else 196#else
196 return ERR_SOURCENOTAVAILABLE; 197 return ERR_SOURCENOTAVAILABLE;
197#endif 198#endif
198} 199}
199 200
200GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 201GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
201{ 202{
202#ifdef GSM_ENABLE_OBEXGEN 203#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
203 GSM_Error error; 204 GSM_Error error;
204 GSM_ToDoEntry ToDo; 205 GSM_ToDoEntry ToDo;
205 GSM_CalendarEntry Calendar; 206 GSM_CalendarEntry Calendar;
206 int Pos; 207 int Pos;
207 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 208 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
208 209
209 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 210 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
210 211
211 smprintf(s,"Getting ToDo status\n"); 212 smprintf(s,"Getting ToDo status\n");
212 213
213 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 214 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
214 if (error != ERR_NONE) return error; 215 if (error != ERR_NONE) return error;
215 216
216 status->Used = 0; 217 status->Used = 0;
217 Pos = 0; 218 Pos = 0;
218 while (1) { 219 while (1) {
219 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 220 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
220 if (error == ERR_EMPTY) break; 221 if (error == ERR_EMPTY) break;
221 if (error != ERR_NONE) return error; 222 if (error != ERR_NONE) return error;
222 if (ToDo.EntriesNum != 0) status->Used++; 223 if (ToDo.EntriesNum != 0) status->Used++;
223 } 224 }
224 225
225 return ERR_NONE; 226 return ERR_NONE;
226#else 227#else
227 return ERR_SOURCENOTAVAILABLE; 228 return ERR_SOURCENOTAVAILABLE;
228#endif 229#endif
229} 230}
230 231
231GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 232GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
232{ 233{
233#ifdef GSM_ENABLE_OBEXGEN 234#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
234 unsigned char req[5000]; 235 unsigned char req[5000];
235 int size=0; 236 int size=0;
236 237
237 smprintf(s,"Adding calendar note\n"); 238 smprintf(s,"Adding calendar note\n");
238 239
239 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar); 240 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar);
240 241
241 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 242 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
242#else 243#else
243 return ERR_SOURCENOTAVAILABLE; 244 return ERR_SOURCENOTAVAILABLE;
244#endif 245#endif
245} 246}
246 247
247GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 248GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
248{ 249{
249#ifdef GSM_ENABLE_OBEXGEN 250#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
250 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 251 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
251 unsigned char req[5000]; 252 unsigned char req[5000];
252 int size=0; 253 int size=0;
253 254
254 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 255 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
255 256
256 smprintf(s,"Adding ToDo\n"); 257 smprintf(s,"Adding ToDo\n");
257 258
258 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo); 259 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo);
259 260
260 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 261 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
261#else 262#else
262 return ERR_SOURCENOTAVAILABLE; 263 return ERR_SOURCENOTAVAILABLE;
263#endif 264#endif
264} 265}
265 266
266GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) 267GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
267{ 268{
268#ifdef GSM_ENABLE_OBEXGEN 269#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
269 GSM_Error error; 270 GSM_Error error;
270 int Pos,Level = 0,Used; 271 int Pos,Level = 0,Used;
271 unsigned char *Buf; 272 unsigned char *Buf;
272 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 273 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
273 unsigned char Line[2000]; 274 unsigned char Line[2000];
274 275
275 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 276 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
276 277
277 smprintf(s,"Deleting all ToDo\n"); 278 smprintf(s,"Deleting all ToDo\n");
278 279
279 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 280 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
280 if (error != ERR_NONE) return error; 281 if (error != ERR_NONE) return error;
281 282
282 Pos = 0; 283 Pos = 0;
283 Buf = NULL; 284 Buf = NULL;
284 Used = 0; 285 Used = 0;
285 while (1) { 286 while (1) {
286 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); 287 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
287 if (strlen(Line) == 0) break; 288 if (strlen(Line) == 0) break;
288 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); 289 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
289 switch (Level) { 290 switch (Level) {
290 case 0: 291 case 0:
291 if (strstr(Line,"BEGIN:VTODO")) { 292 if (strstr(Line,"BEGIN:VTODO")) {
292 Level = 2; 293 Level = 2;
293 break; 294 break;
294 } 295 }
295 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3); 296 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
296 strcpy(Buf+Used,Line); 297 strcpy(Buf+Used,Line);
297 Used=Used+strlen(Line)+3; 298 Used=Used+strlen(Line)+3;
298 Buf[Used-3] = 13; 299 Buf[Used-3] = 13;
299 Buf[Used-2] = 10; 300 Buf[Used-2] = 10;
300 Buf[Used-1] = 0x00; 301 Buf[Used-1] = 0x00;
301 break; 302 break;
302 case 2: /* ToDo note */ 303 case 2: /* ToDo note */
303 if (strstr(Line,"END:VTODO")) { 304 if (strstr(Line,"END:VTODO")) {
304 Level = 0; 305 Level = 0;
305 } 306 }
306 break; 307 break;
307 } 308 }
308 } 309 }
309 310
310 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 311 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
311 //if (Buf != NULL) free(Buf); 312 //if (Buf != NULL) free(Buf);
312 return error; 313 return error;
313#else 314#else
314 return ERR_SOURCENOTAVAILABLE; 315 return ERR_SOURCENOTAVAILABLE;
315#endif 316#endif
316} 317}
317 318
318GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 319GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
319{ 320{
320#ifdef GSM_ENABLE_OBEXGEN 321#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
321 GSM_Error error; 322 GSM_Error error;
322 int Pos,Level = 0,Loc=0,Used; 323 int Pos,Level = 0,Loc=0,Used;
323 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 324 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
324 unsigned char Line[2000]; 325 unsigned char Line[2000];
325 unsigned char *Buf; 326 unsigned char *Buf;
326 327
327 smprintf(s, "Deleting calendar note %i\n",Note->Location); 328 smprintf(s, "Deleting calendar note %i\n",Note->Location);
328 329
329 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 330 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
330 if (error != ERR_NONE) return error; 331 if (error != ERR_NONE) return error;
331 332
332 Pos = 0; 333 Pos = 0;
333 Buf = NULL; 334 Buf = NULL;
334 Used = 0; 335 Used = 0;
335 while (1) { 336 while (1) {
336 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); 337 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
337 if (strlen(Line) == 0) break; 338 if (strlen(Line) == 0) break;
338 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); 339 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
339 switch (Level) { 340 switch (Level) {
340 case 0: 341 case 0:
341 if (strstr(Line,"BEGIN:VEVENT")) { 342 if (strstr(Line,"BEGIN:VEVENT")) {
342 Loc++; 343 Loc++;
343 if (Loc == Note->Location) { 344 if (Loc == Note->Location) {
344 Level = 1; 345 Level = 1;
345 break; 346 break;
346 } 347 }
347 } 348 }
348 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3); 349 Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
349 strcpy(Buf+Used,Line); 350 strcpy(Buf+Used,Line);
350 Used=Used+strlen(Line)+3; 351 Used=Used+strlen(Line)+3;
351 Buf[Used-3] = 13; 352 Buf[Used-3] = 13;
352 Buf[Used-2] = 10; 353 Buf[Used-2] = 10;
353 Buf[Used-1] = 0x00; 354 Buf[Used-1] = 0x00;
354 break; 355 break;
355 case 1: /* Calendar note */ 356 case 1: /* Calendar note */
356 if (strstr(Line,"END:VEVENT")) { 357 if (strstr(Line,"END:VEVENT")) {
357 Level = 0; 358 Level = 0;
358 } 359 }
359 break; 360 break;
360 } 361 }
361 } 362 }
362 363
363 DumpMessage(s->di.df, s->di.dl, Buf, Used); 364 DumpMessage(s->di.df, s->di.dl, Buf, Used);
364 365
365 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 366 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
366 if (Buf != NULL) free(Buf); 367 if (Buf != NULL) free(Buf);
367 return error; 368 return error;
368#else 369#else
369 return ERR_SOURCENOTAVAILABLE; 370 return ERR_SOURCENOTAVAILABLE;
370#endif 371#endif
371} 372}
372 373
373GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 374GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
374{ 375{
375#ifdef GSM_ENABLE_OBEXGEN 376#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
376 GSM_Error error; 377 GSM_Error error;
377 GSM_ToDoEntry ToDo; 378 GSM_ToDoEntry ToDo;
378 GSM_CalendarEntry Calendar; 379 GSM_CalendarEntry Calendar;
379 int Pos; 380 int Pos;
380 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 381 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
381 382
382 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 383 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
383 384
384 smprintf(s, "Getting calendar status\n"); 385 smprintf(s, "Getting calendar status\n");
385 386
386 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 387 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
387 if (error != ERR_NONE) return error; 388 if (error != ERR_NONE) return error;
388 389
389 Status->Used = 0; 390 Status->Used = 0;
390 Pos = 0; 391 Pos = 0;
391 while (1) { 392 while (1) {
392 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 393 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
393 if (error == ERR_EMPTY) break; 394 if (error == ERR_EMPTY) break;
394 if (error != ERR_NONE) return error; 395 if (error != ERR_NONE) return error;
395 if (Calendar.EntriesNum != 0) Status->Used++; 396 if (Calendar.EntriesNum != 0) Status->Used++;
396 } 397 }
397 398
398 return ERR_NONE; 399 return ERR_NONE;
399#else 400#else
400 return ERR_SOURCENOTAVAILABLE; 401 return ERR_SOURCENOTAVAILABLE;
401#endif 402#endif
402} 403}
403 404
404GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s) 405GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
405 { /*Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar 406 { /*Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar
406 License: Whatever the current maintainer of gammulib chooses, as long as there 407 License: Whatever the current maintainer of gammulib chooses, as long as there
407 is an easy way to obtain the source under GPL, otherwise the author's parts 408 is an easy way to obtain the source under GPL, otherwise the author's parts
408 of this function are GPL 2.0. 409 of this function are GPL 2.0.
409 */ 410 */
410 GSM_Locale*locale = s->Phone.Data.Locale; 411 GSM_Locale*locale = s->Phone.Data.Locale;
411 char format; 412 char format;
412 413
413 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 414 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
414 case AT_Reply_OK: 415 case AT_Reply_OK:
415 smprintf(s, "Date settings received\n"); 416 smprintf(s, "Date settings received\n");
416 format=atoi(msg.Buffer); 417 format=atoi(msg.Buffer);
417 switch (format) { 418 switch (format) {
418 case 0: locale->DateFormat = GSM_Date_OFF; 419 case 0: locale->DateFormat = GSM_Date_OFF;
419 locale->DateSeparator = 0; 420 locale->DateSeparator = 0;
420 break; 421 break;
421 case 1: locale->DateFormat = GSM_Date_DDMMMYY; 422 case 1: locale->DateFormat = GSM_Date_DDMMMYY;
422 locale->DateSeparator = '-'; 423 locale->DateSeparator = '-';
423 break; 424 break;
424 case 2: locale->DateFormat = GSM_Date_DDMMYY; 425 case 2: locale->DateFormat = GSM_Date_DDMMYY;
425 locale->DateSeparator = '-'; 426 locale->DateSeparator = '-';
426 break; 427 break;
427 case 3: locale->DateFormat = GSM_Date_MMDDYY; 428 case 3: locale->DateFormat = GSM_Date_MMDDYY;
428 locale->DateSeparator = '/'; 429 locale->DateSeparator = '/';
429 break; 430 break;
430 case 4: locale->DateFormat = GSM_Date_DDMMYY; 431 case 4: locale->DateFormat = GSM_Date_DDMMYY;
431 locale->DateSeparator = '/'; 432 locale->DateSeparator = '/';
432 break; 433 break;
433 case 5: locale->DateFormat = GSM_Date_DDMMYY; 434 case 5: locale->DateFormat = GSM_Date_DDMMYY;
434 locale->DateSeparator = '.'; 435 locale->DateSeparator = '.';
435 break; 436 break;
436 case 6: locale->DateFormat = GSM_Date_YYMMDD; 437 case 6: locale->DateFormat = GSM_Date_YYMMDD;
437 locale->DateSeparator = 0; 438 locale->DateSeparator = 0;
438 break; 439 break;
439 case 7: locale->DateFormat = GSM_Date_YYMMDD; 440 case 7: locale->DateFormat = GSM_Date_YYMMDD;
440 locale->DateSeparator = '-'; 441 locale->DateSeparator = '-';
441 break; 442 break;
442 default:return ERR_UNKNOWNRESPONSE; 443 default:return ERR_UNKNOWNRESPONSE;
443 } 444 }
444 default: 445 default:
445 return ERR_NOTSUPPORTED; 446 return ERR_NOTSUPPORTED;
446 } 447 }
447} 448}
448 449
449GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s) 450GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
450 { /*Author: Peter Ondraska 451 { /*Author: Peter Ondraska
451 License: Whatever the current maintainer of gammulib chooses, as long as there 452 License: Whatever the current maintainer of gammulib chooses, as long as there
452 is an easy way to obtain the source under GPL, otherwise the author's parts 453 is an easy way to obtain the source under GPL, otherwise the author's parts
453 of this function are GPL 2.0. 454 of this function are GPL 2.0.
454 */ 455 */
455 char format; 456 char format;
456 457
457 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 458 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
458 case AT_Reply_OK: 459 case AT_Reply_OK:
459 smprintf(s, "Time settings received\n"); 460 smprintf(s, "Time settings received\n");
460 format=atoi(msg.Buffer); 461 format=atoi(msg.Buffer);
461 switch (format) { 462 switch (format) {
462 case 1: 463 case 1:
463 case 2: s->Phone.Data.Locale->AMPMTime=(format==2); 464 case 2: s->Phone.Data.Locale->AMPMTime=(format==2);
464 return ERR_NONE; 465 return ERR_NONE;
465 default:return ERR_UNKNOWNRESPONSE; 466 default:return ERR_UNKNOWNRESPONSE;
466 } 467 }
467 default: return ERR_NOTSUPPORTED; 468 default: return ERR_NOTSUPPORTED;
468 } 469 }
469} 470}
470 471
471GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale) 472GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
472{ 473{
473 GSM_Error error; 474 GSM_Error error;
474 475
475 s->Phone.Data.Locale = locale; 476 s->Phone.Data.Locale = locale;
476 477
477 smprintf(s, "Getting date format\n"); 478 smprintf(s, "Getting date format\n");
478 error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale); 479 error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale);
479 if (error!=ERR_NONE) return error; 480 if (error!=ERR_NONE) return error;
480 481
481 smprintf(s, "Getting time format\n"); 482 smprintf(s, "Getting time format\n");
482 return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale); 483 return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale);
483} 484}
484 485
485 486
486GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale) 487GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
487 { /*Author: Peter Ondraska 488 { /*Author: Peter Ondraska
488 License: Whatever the current maintainer of gammulib chooses, as long as there 489 License: Whatever the current maintainer of gammulib chooses, as long as there
489 is an easy way to obtain the source under GPL, otherwise the author's parts 490 is an easy way to obtain the source under GPL, otherwise the author's parts
490 of this function are GPL 2.0. 491 of this function are GPL 2.0.
491 */ 492 */
492 /* this is not yet supported by gammu.c */ 493 /* this is not yet supported by gammu.c */
493 intformat=0; 494 intformat=0;
494 charreq[12]; 495 charreq[12];
495 496
496 if (locale->DateFormat==GSM_Date_OFF) { format=0; } else 497 if (locale->DateFormat==GSM_Date_OFF) { format=0; } else
497 if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else 498 if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else
498 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else 499 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else
499 if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else 500 if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else
500 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else 501 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else
501 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else 502 if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else
502 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else 503 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else
503 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; } 504 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; }
504 else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */ 505 else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */
505 506
506 sprintf(req,"AT+ESDF=%i\r",format); 507 sprintf(req,"AT+ESDF=%i\r",format);
507 smprintf(s, "Setting date format\n"); 508 smprintf(s, "Setting date format\n");
508 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale); 509 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
509 510
510 if (locale->AMPMTime) { format=2; } else { format=1; } 511 if (locale->AMPMTime) { format=2; } else { format=1; }
511 sprintf(req,"AT+ESTF=%i\r",format); 512 sprintf(req,"AT+ESTF=%i\r",format);
512 smprintf(s, "Setting time format\n"); 513 smprintf(s, "Setting time format\n");
513 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale); 514 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
514} 515}
515 516
516#endif 517#endif
517 518
518/* How should editor hadle tabs in this file? Add editor commands here. 519/* How should editor hadle tabs in this file? Add editor commands here.
519 * vim: noexpandtab sw=8 ts=8 sts=8: 520 * vim: noexpandtab sw=8 ts=8 sts=8:
520 */ 521 */
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c
index 17cd0a4..9810a35 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.c
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c
@@ -1,899 +1,908 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* resetting DCT4 phones settings (c) by Walek */ 2/* resetting DCT4 phones settings (c) by Walek */
3/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org) 3/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later 5 * GNU GPL version 2 or later
6 */ 6 */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#include <string.h> /* memcpy only */ 17#include <string.h> /* memcpy only */
9#include <stdio.h> 18#include <stdio.h>
10#include <ctype.h> 19#include <ctype.h>
11 20
12#include "../../../gsmstate.h" 21#include "../../../gsmstate.h"
13#include "../../../misc/coding/coding.h" 22#include "../../../misc/coding/coding.h"
14#include "../../../service/sms/gsmsms.h" 23#include "../../../service/sms/gsmsms.h"
15#include "../../pfunc.h" 24#include "../../pfunc.h"
16#include "../nfunc.h" 25#include "../nfunc.h"
17#include "dct3func.h" 26#include "dct3func.h"
18 27
19#ifdef GSM_ENABLE_NOKIA_DCT3 28#ifdef GSM_ENABLE_NOKIA_DCT3
20 29
21GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 30GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
22{ 31{
23 GSM_Error error; 32 GSM_Error error;
24 33
25 /* We have to enable WAP frames in phone */ 34 /* We have to enable WAP frames in phone */
26 error=DCT3DCT4_EnableWAPFunctions(s); 35 error=DCT3DCT4_EnableWAPFunctions(s);
27 if (error!=ERR_NONE) return error; 36 if (error!=ERR_NONE) return error;
28 37
29 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); 38 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
30} 39}
31 40
32GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 41GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
33{ 42{
34 GSM_Error error; 43 GSM_Error error;
35 44
36 /* We have to enable WAP frames in phone */ 45 /* We have to enable WAP frames in phone */
37 error=DCT3DCT4_EnableWAPFunctions(s); 46 error=DCT3DCT4_EnableWAPFunctions(s);
38 if (error!=ERR_NONE) return error; 47 if (error!=ERR_NONE) return error;
39 48
40 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); 49 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark);
41} 50}
42 51
43GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s) 52GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s)
44{ 53{
45 GSM_Phone_Data *Data = &s->Phone.Data; 54 GSM_Phone_Data *Data = &s->Phone.Data;
46 55
47 switch (msg.Buffer[2]) { 56 switch (msg.Buffer[2]) {
48 case 0x46: 57 case 0x46:
49 smprintf(s, "Pressing key OK\n"); 58 smprintf(s, "Pressing key OK\n");
50 if (Data->PressKey) return ERR_NONE; 59 if (Data->PressKey) return ERR_NONE;
51 break; 60 break;
52 case 0x47: 61 case 0x47:
53 smprintf(s, "Releasing key OK\n"); 62 smprintf(s, "Releasing key OK\n");
54 if (!Data->PressKey) return ERR_NONE; 63 if (!Data->PressKey) return ERR_NONE;
55 break; 64 break;
56 } 65 }
57 return ERR_UNKNOWNRESPONSE; 66 return ERR_UNKNOWNRESPONSE;
58} 67}
59 68
60GSM_Error DCT3_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 69GSM_Error DCT3_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
61{ 70{
62 unsigned char PressReq[] = {0x00, 0x01, 0x46, 0x00, 0x01, 71 unsigned char PressReq[] = {0x00, 0x01, 0x46, 0x00, 0x01,
63 0x0a}; /* Key code */ 72 0x0a}; /* Key code */
64 unsigned char ReleaseReq[] = {0x00, 0x01, 0x47, 0x00, 0x01, 0x0c}; 73 unsigned char ReleaseReq[] = {0x00, 0x01, 0x47, 0x00, 0x01, 0x0c};
65 74
66 if (Press) { 75 if (Press) {
67 PressReq[5] = Key; 76 PressReq[5] = Key;
68 s->Phone.Data.PressKey = true; 77 s->Phone.Data.PressKey = true;
69 smprintf(s, "Pressing key\n"); 78 smprintf(s, "Pressing key\n");
70 return GSM_WaitFor (s, PressReq, 6, 0xd1, 4, ID_PressKey); 79 return GSM_WaitFor (s, PressReq, 6, 0xd1, 4, ID_PressKey);
71 } else { 80 } else {
72 s->Phone.Data.PressKey = false; 81 s->Phone.Data.PressKey = false;
73 smprintf(s, "Releasing key\n"); 82 smprintf(s, "Releasing key\n");
74 return GSM_WaitFor (s, ReleaseReq, 6, 0xd1, 4, ID_PressKey); 83 return GSM_WaitFor (s, ReleaseReq, 6, 0xd1, 4, ID_PressKey);
75 } 84 }
76} 85}
77 86
78GSM_Error DCT3_ReplyPlayTone(GSM_Protocol_Message msg, GSM_StateMachine *s) 87GSM_Error DCT3_ReplyPlayTone(GSM_Protocol_Message msg, GSM_StateMachine *s)
79{ 88{
80 smprintf(s, "Tone played\n"); 89 smprintf(s, "Tone played\n");
81 return ERR_NONE; 90 return ERR_NONE;
82} 91}
83 92
84GSM_Error DCT3_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start) 93GSM_Error DCT3_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start)
85{ 94{
86 GSM_Error error; 95 GSM_Error error;
87 unsigned char req[] = {0x00,0x01,0x8f, 96 unsigned char req[] = {0x00,0x01,0x8f,
88 0x00, /* Volume */ 97 0x00, /* Volume */
89 0x00, /* HerzLo */ 98 0x00, /* HerzLo */
90 0x00}; /* HerzHi */ 99 0x00}; /* HerzHi */
91 100
92 if (start) { 101 if (start) {
93 error=DCT3_EnableSecurity (s, 0x01); 102 error=DCT3_EnableSecurity (s, 0x01);
94 if (error!=ERR_NONE) return error; 103 if (error!=ERR_NONE) return error;
95 } 104 }
96 105
97 /* For Herz==255*255 we have silent */ 106 /* For Herz==255*255 we have silent */
98 if (Herz!=255*255) { 107 if (Herz!=255*255) {
99 req[3]=Volume; 108 req[3]=Volume;
100 req[5]=Herz%256; 109 req[5]=Herz%256;
101 req[4]=Herz/256; 110 req[4]=Herz/256;
102 } else { 111 } else {
103 req[3]=0; 112 req[3]=0;
104 req[5]=0; 113 req[5]=0;
105 req[4]=0; 114 req[4]=0;
106 } 115 }
107 116
108 return GSM_WaitFor (s, req, 6, 0x40, 4, ID_PlayTone); 117 return GSM_WaitFor (s, req, 6, 0x40, 4, ID_PlayTone);
109} 118}
110 119
111#ifdef GSM_ENABLE_CELLBROADCAST 120#ifdef GSM_ENABLE_CELLBROADCAST
112 121
113GSM_Error DCT3_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s) 122GSM_Error DCT3_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
114{ 123{
115 GSM_CBMessage CB; 124 GSM_CBMessage CB;
116 int i; 125 int i;
117 char Buffer[300]; 126 char Buffer[300];
118 127
119 smprintf(s, "CB received\n"); 128 smprintf(s, "CB received\n");
120 CB.Channel = msg.Buffer[7]; 129 CB.Channel = msg.Buffer[7];
121 i = GSM_UnpackEightBitsToSeven(0, msg.Buffer[9], msg.Buffer[9], msg.Buffer+10, Buffer); 130 i = GSM_UnpackEightBitsToSeven(0, msg.Buffer[9], msg.Buffer[9], msg.Buffer+10, Buffer);
122 i = msg.Buffer[9] - 1; 131 i = msg.Buffer[9] - 1;
123 while (i!=0) { 132 while (i!=0) {
124 if (Buffer[i] == 13) i = i - 1; else break; 133 if (Buffer[i] == 13) i = i - 1; else break;
125 } 134 }
126 DecodeDefault(CB.Text, Buffer, i + 1, false, NULL); 135 DecodeDefault(CB.Text, Buffer, i + 1, false, NULL);
127 smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text)); 136 smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text));
128 if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) { 137 if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) {
129 s->User.IncomingCB(s->CurrentConfig->Device,CB); 138 s->User.IncomingCB(s->CurrentConfig->Device,CB);
130 } 139 }
131 return ERR_NONE; 140 return ERR_NONE;
132} 141}
133 142
134GSM_Error DCT3_ReplySetIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s) 143GSM_Error DCT3_ReplySetIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
135{ 144{
136 switch (msg.Buffer[3]) { 145 switch (msg.Buffer[3]) {
137 case 0x21: 146 case 0x21:
138 smprintf(s, "CB set\n"); 147 smprintf(s, "CB set\n");
139 return ERR_NONE; 148 return ERR_NONE;
140 case 0x22: 149 case 0x22:
141 smprintf(s, "CB not set\n"); 150 smprintf(s, "CB not set\n");
142 return ERR_UNKNOWN; 151 return ERR_UNKNOWN;
143 case 0xCA: 152 case 0xCA:
144 smprintf(s, "No network and no CB\n"); 153 smprintf(s, "No network and no CB\n");
145 return ERR_SECURITYERROR; 154 return ERR_SECURITYERROR;
146 } 155 }
147 return ERR_UNKNOWNRESPONSE; 156 return ERR_UNKNOWNRESPONSE;
148} 157}
149 158
150#endif 159#endif
151 160
152GSM_Error DCT3_SetIncomingCB(GSM_StateMachine *s, bool enable) 161GSM_Error DCT3_SetIncomingCB(GSM_StateMachine *s, bool enable)
153{ 162{
154#ifdef GSM_ENABLE_CELLBROADCAST 163#ifdef GSM_ENABLE_CELLBROADCAST
155 unsigned char reqOn[] = {N6110_FRAME_HEADER, 0x20, 0x01, 164 unsigned char reqOn[] = {N6110_FRAME_HEADER, 0x20, 0x01,
156 0x01, 0x00, 0x00, 0x01, 0x01}; 165 0x01, 0x00, 0x00, 0x01, 0x01};
157 unsigned char reqOff[] = {N6110_FRAME_HEADER, 0x20, 0x00, 166 unsigned char reqOff[] = {N6110_FRAME_HEADER, 0x20, 0x00,
158 0x00, 0x00, 0x00, 0x00, 0x00}; 167 0x00, 0x00, 0x00, 0x00, 0x00};
159 168
160 if (s->Phone.Data.EnableIncomingCB!=enable) { 169 if (s->Phone.Data.EnableIncomingCB!=enable) {
161 s->Phone.Data.EnableIncomingCB = enable; 170 s->Phone.Data.EnableIncomingCB = enable;
162 if (enable) { 171 if (enable) {
163 smprintf(s, "Enabling incoming CB\n"); 172 smprintf(s, "Enabling incoming CB\n");
164 return GSM_WaitFor(s, reqOn, 10, 0x02, 4, ID_SetIncomingCB); 173 return GSM_WaitFor(s, reqOn, 10, 0x02, 4, ID_SetIncomingCB);
165 } else { 174 } else {
166 smprintf(s, "Disabling incoming CB\n"); 175 smprintf(s, "Disabling incoming CB\n");
167 return GSM_WaitFor(s, reqOff, 10, 0x02, 4, ID_SetIncomingCB); 176 return GSM_WaitFor(s, reqOff, 10, 0x02, 4, ID_SetIncomingCB);
168 } 177 }
169 } 178 }
170 return ERR_NONE; 179 return ERR_NONE;
171#else 180#else
172 return ERR_SOURCENOTAVAILABLE; 181 return ERR_SOURCENOTAVAILABLE;
173#endif 182#endif
174} 183}
175 184
176GSM_Error DCT3_ReplySetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 185GSM_Error DCT3_ReplySetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
177{ 186{
178 smprintf(s, "SMSC set\n"); 187 smprintf(s, "SMSC set\n");
179 return ERR_NONE; 188 return ERR_NONE;
180} 189}
181 190
182GSM_Error DCT3_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 191GSM_Error DCT3_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
183{ 192{
184 unsigned char req[100] = {N6110_FRAME_HEADER, 0x30, 0x64}; 193 unsigned char req[100] = {N6110_FRAME_HEADER, 0x30, 0x64};
185 194
186 memset(req+6,100-6,0); 195 memset(req+6,100-6,0);
187 196
188 /* SMSC location */ 197 /* SMSC location */
189 req[5] = smsc->Location; 198 req[5] = smsc->Location;
190 199
191 /* SMSC format */ 200 /* SMSC format */
192 switch (smsc->Format) { 201 switch (smsc->Format) {
193 case SMS_FORMAT_Text : req[7] = 0x00; break; 202 case SMS_FORMAT_Text : req[7] = 0x00; break;
194 case SMS_FORMAT_Fax : req[7] = 0x22; break; 203 case SMS_FORMAT_Fax : req[7] = 0x22; break;
195 case SMS_FORMAT_Pager : req[7] = 0x26; break; 204 case SMS_FORMAT_Pager : req[7] = 0x26; break;
196 case SMS_FORMAT_Email : req[7] = 0x32; break; 205 case SMS_FORMAT_Email : req[7] = 0x32; break;
197 } 206 }
198 207
199 /* SMS validity */ 208 /* SMS validity */
200 req[9] = smsc->Validity.Relative; 209 req[9] = smsc->Validity.Relative;
201 210
202 /* Default number for SMS messages */ 211 /* Default number for SMS messages */
203 req[10] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+11, true); 212 req[10] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+11, true);
204 213
205 /* SMSC number */ 214 /* SMSC number */
206 req[22] = GSM_PackSemiOctetNumber(smsc->Number, req+23, false); 215 req[22] = GSM_PackSemiOctetNumber(smsc->Number, req+23, false);
207 216
208 /* SMSC name */ 217 /* SMSC name */
209 memcpy(req + 34, DecodeUnicodeString(smsc->Name),UnicodeLength(smsc->Name)); 218 memcpy(req + 34, DecodeUnicodeString(smsc->Name),UnicodeLength(smsc->Name));
210 219
211 smprintf(s, "Setting SMSC\n"); 220 smprintf(s, "Setting SMSC\n");
212 return GSM_WaitFor (s, req, 35+UnicodeLength(smsc->Name), 0x02, 4, ID_SetSMSC); 221 return GSM_WaitFor (s, req, 35+UnicodeLength(smsc->Name), 0x02, 4, ID_SetSMSC);
213} 222}
214 223
215GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s) 224GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s)
216{ 225{
217 smprintf(s, "State of security commands set\n"); 226 smprintf(s, "State of security commands set\n");
218 return ERR_NONE; 227 return ERR_NONE;
219} 228}
220 229
221/* If you set make some things (for example, change Security Code from 230/* If you set make some things (for example, change Security Code from
222 * phone's menu, disable and enable phone), it won't answer for 0x40 frames 231 * phone's menu, disable and enable phone), it won't answer for 0x40 frames
223 * and you won't be able to play tones, get netmonitor, etc. 232 * and you won't be able to play tones, get netmonitor, etc.
224 * This function do thing called "Enabling extended security commands" 233 * This function do thing called "Enabling extended security commands"
225 * and it enables 0x40 frame functions. 234 * and it enables 0x40 frame functions.
226 * This frame can also some other things - see below 235 * This frame can also some other things - see below
227 */ 236 */
228GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status) 237GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status)
229{ 238{
230 unsigned char req[] = {0x00, 0x01, 0x64, 239 unsigned char req[] = {0x00, 0x01, 0x64,
231 0x01};/* 0x00/0x01 - off/on, 240 0x01};/* 0x00/0x01 - off/on,
232 * 0x03/0x04 - soft/hard reset, 241 * 0x03/0x04 - soft/hard reset,
233 * 0x06 - CONTACT SERVICE 242 * 0x06 - CONTACT SERVICE
234 */ 243 */
235 244
236 /* 0x06 MAKES CONTACT SERVICE! BE CAREFULL! */ 245 /* 0x06 MAKES CONTACT SERVICE! BE CAREFULL! */
237 /* When use 0x03 and had during session changed time & date 246 /* When use 0x03 and had during session changed time & date
238 * some phones (like 6150 or 6210) can ask for time & date after reset 247 * some phones (like 6150 or 6210) can ask for time & date after reset
239 * or disable clock on the screen 248 * or disable clock on the screen
240 */ 249 */
241 if (status!=0x06) req[3] = status; 250 if (status!=0x06) req[3] = status;
242 smprintf(s, "Setting state of security commands\n"); 251 smprintf(s, "Setting state of security commands\n");
243 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_EnableSecurity); 252 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_EnableSecurity);
244} 253}
245 254
246GSM_Error DCT3_ReplyGetIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s) 255GSM_Error DCT3_ReplyGetIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s)
247{ 256{
248 memcpy(s->Phone.Data.IMEI,msg.Buffer + 4, 16); 257 memcpy(s->Phone.Data.IMEI,msg.Buffer + 4, 16);
249 smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI); 258 smprintf(s, "Received IMEI %s\n",s->Phone.Data.IMEI);
250 return ERR_NONE; 259 return ERR_NONE;
251} 260}
252 261
253GSM_Error DCT3_GetIMEI (GSM_StateMachine *s) 262GSM_Error DCT3_GetIMEI (GSM_StateMachine *s)
254{ 263{
255 unsigned char req[] = {0x00, 0x01, 0x66, 0x00}; 264 unsigned char req[] = {0x00, 0x01, 0x66, 0x00};
256 GSM_Error error; 265 GSM_Error error;
257 266
258 if (strlen(s->Phone.Data.IMEI)!=0) return ERR_NONE; 267 if (strlen(s->Phone.Data.IMEI)!=0) return ERR_NONE;
259 268
260 error=DCT3_EnableSecurity (s, 0x01); 269 error=DCT3_EnableSecurity (s, 0x01);
261 if (error!=ERR_NONE) return error; 270 if (error!=ERR_NONE) return error;
262 271
263 smprintf(s, "Getting IMEI\n"); 272 smprintf(s, "Getting IMEI\n");
264 return GSM_WaitFor (s, req, 4, 0x40, 2, ID_GetIMEI); 273 return GSM_WaitFor (s, req, 4, 0x40, 2, ID_GetIMEI);
265} 274}
266 275
267GSM_Error DCT3_ReplySIMLogin(GSM_Protocol_Message msg, GSM_StateMachine *s) 276GSM_Error DCT3_ReplySIMLogin(GSM_Protocol_Message msg, GSM_StateMachine *s)
268{ 277{
269 smprintf(s, "Login for SIM card\n"); 278 smprintf(s, "Login for SIM card\n");
270 return ERR_NONE; 279 return ERR_NONE;
271} 280}
272 281
273GSM_Error DCT3_ReplySIMLogout(GSM_Protocol_Message msg, GSM_StateMachine *s) 282GSM_Error DCT3_ReplySIMLogout(GSM_Protocol_Message msg, GSM_StateMachine *s)
274{ 283{
275 smprintf(s, "Logout for SIM card\n"); 284 smprintf(s, "Logout for SIM card\n");
276 return ERR_NONE; 285 return ERR_NONE;
277} 286}
278 287
279GSM_Error DCT3_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s) 288GSM_Error DCT3_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
280{ 289{
281 smprintf(s, "Date & time received\n"); 290 smprintf(s, "Date & time received\n");
282 if (msg.Buffer[4]==0x01) { 291 if (msg.Buffer[4]==0x01) {
283 NOKIA_DecodeDateTime(s, msg.Buffer+8, s->Phone.Data.DateTime); 292 NOKIA_DecodeDateTime(s, msg.Buffer+8, s->Phone.Data.DateTime);
284 return ERR_NONE; 293 return ERR_NONE;
285 } 294 }
286 smprintf(s, "Not set in phone\n"); 295 smprintf(s, "Not set in phone\n");
287 return ERR_EMPTY; 296 return ERR_EMPTY;
288} 297}
289 298
290GSM_Error DCT3_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype) 299GSM_Error DCT3_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype)
291{ 300{
292 unsigned char req[] = {N6110_FRAME_HEADER, 0x62}; 301 unsigned char req[] = {N6110_FRAME_HEADER, 0x62};
293 302
294 s->Phone.Data.DateTime=date_time; 303 s->Phone.Data.DateTime=date_time;
295 smprintf(s, "Getting date & time\n"); 304 smprintf(s, "Getting date & time\n");
296 return GSM_WaitFor (s, req, 4, msgtype, 4, ID_GetDateTime); 305 return GSM_WaitFor (s, req, 4, msgtype, 4, ID_GetDateTime);
297} 306}
298 307
299GSM_Error DCT3_ReplyGetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) 308GSM_Error DCT3_ReplyGetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
300{ 309{
301 GSM_Phone_Data*Data = &s->Phone.Data; 310 GSM_Phone_Data*Data = &s->Phone.Data;
302 311
303 smprintf(s, "Alarm: "); 312 smprintf(s, "Alarm: ");
304 if (msg.Buffer[8]==0x02) { 313 if (msg.Buffer[8]==0x02) {
305 smprintf(s, "set to %02i:%02i\n", msg.Buffer[9], msg.Buffer[10]); 314 smprintf(s, "set to %02i:%02i\n", msg.Buffer[9], msg.Buffer[10]);
306 Data->Alarm->Repeating = true; 315 Data->Alarm->Repeating = true;
307 Data->Alarm->Text[0] = 0; 316 Data->Alarm->Text[0] = 0;
308 Data->Alarm->Text[1] = 0; 317 Data->Alarm->Text[1] = 0;
309 Data->Alarm->DateTime.Hour= msg.Buffer[9]; 318 Data->Alarm->DateTime.Hour= msg.Buffer[9];
310 Data->Alarm->DateTime.Minute= msg.Buffer[10]; 319 Data->Alarm->DateTime.Minute= msg.Buffer[10];
311 Data->Alarm->DateTime.Second= 0; 320 Data->Alarm->DateTime.Second= 0;
312 return ERR_NONE; 321 return ERR_NONE;
313 } 322 }
314 smprintf(s, "not set\n"); 323 smprintf(s, "not set\n");
315 return ERR_EMPTY; 324 return ERR_EMPTY;
316} 325}
317 326
318GSM_Error DCT3_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype) 327GSM_Error DCT3_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype)
319{ 328{
320 unsigned char req[] = {N6110_FRAME_HEADER, 0x6d}; 329 unsigned char req[] = {N6110_FRAME_HEADER, 0x6d};
321 330
322 if (alarm->Location!=1) return ERR_NOTSUPPORTED; 331 if (alarm->Location!=1) return ERR_NOTSUPPORTED;
323 332
324 s->Phone.Data.Alarm=alarm; 333 s->Phone.Data.Alarm=alarm;
325 smprintf(s, "Getting alarm\n"); 334 smprintf(s, "Getting alarm\n");
326 return GSM_WaitFor (s, req, 4, msgtype, 4, ID_GetAlarm); 335 return GSM_WaitFor (s, req, 4, msgtype, 4, ID_GetAlarm);
327} 336}
328 337
329GSM_Error DCT3_ReplySetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s) 338GSM_Error DCT3_ReplySetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
330{ 339{
331 smprintf(s, "Date & time: "); 340 smprintf(s, "Date & time: ");
332 if (msg.Buffer[4]==0x01) { 341 if (msg.Buffer[4]==0x01) {
333 smprintf(s, "set OK\n"); 342 smprintf(s, "set OK\n");
334 return ERR_NONE; 343 return ERR_NONE;
335 } 344 }
336 smprintf(s, "error setting\n"); 345 smprintf(s, "error setting\n");
337 return ERR_UNKNOWN; 346 return ERR_UNKNOWN;
338} 347}
339 348
340GSM_Error DCT3_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype) 349GSM_Error DCT3_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype)
341{ 350{
342 unsigned char req[] = {N6110_FRAME_HEADER, 0x60, 0x01, 0x01, 0x07, 351 unsigned char req[] = {N6110_FRAME_HEADER, 0x60, 0x01, 0x01, 0x07,
343 0x00, 0x00, /* Year */ 352 0x00, 0x00, /* Year */
344 0x00, /* Month */ 353 0x00, /* Month */
345 0x00, /* Day */ 354 0x00, /* Day */
346 0x00, /* Hour */ 355 0x00, /* Hour */
347 0x00, /* Minute */ 356 0x00, /* Minute */
348 0x00}; /* Unknown. Not seconds */ 357 0x00}; /* Unknown. Not seconds */
349 358
350 NOKIA_EncodeDateTime(s, req+7, date_time); 359 NOKIA_EncodeDateTime(s, req+7, date_time);
351 smprintf(s, "Setting date & time\n"); 360 smprintf(s, "Setting date & time\n");
352 return GSM_WaitFor (s, req, 14, msgtype, 4, ID_SetDateTime); 361 return GSM_WaitFor (s, req, 14, msgtype, 4, ID_SetDateTime);
353} 362}
354 363
355GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) 364GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
356{ 365{
357 smprintf(s, "Alarm: "); 366 smprintf(s, "Alarm: ");
358 if (msg.Buffer[4]==0x01) { 367 if (msg.Buffer[4]==0x01) {
359 smprintf(s, "set OK\n"); 368 smprintf(s, "set OK\n");
360 return ERR_NONE; 369 return ERR_NONE;
361 } 370 }
362 smprintf(s, "error setting\n"); 371 smprintf(s, "error setting\n");
363 return ERR_UNKNOWN; 372 return ERR_UNKNOWN;
364} 373}
365 374
366GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype) 375GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype)
367{ 376{
368 unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03, 377 unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03,
369 0x02, /* Unknown. Not for enabling/disabling */ 378 0x02, /* Unknown. Not for enabling/disabling */
370 0x00, /* Hour */ 379 0x00, /* Hour */
371 0x00, /* Minute */ 380 0x00, /* Minute */
372 0x00}; /* Unknown. Not seconds */ 381 0x00}; /* Unknown. Not seconds */
373 382
374 if (alarm->Location != 1) return ERR_NOTSUPPORTED; 383 if (alarm->Location != 1) return ERR_NOTSUPPORTED;
375 384
376 req[8] = alarm->DateTime.Hour; 385 req[8] = alarm->DateTime.Hour;
377 req[9] = alarm->DateTime.Minute; 386 req[9] = alarm->DateTime.Minute;
378 387
379 smprintf(s, "Setting alarm\n"); 388 smprintf(s, "Setting alarm\n");
380 return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm); 389 return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm);
381} 390}
382 391
383GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 392GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
384{ 393{
385 int i; 394 int i;
386 GSM_Phone_Data*Data = &s->Phone.Data; 395 GSM_Phone_Data*Data = &s->Phone.Data;
387 396
388 switch (msg.Buffer[3]) { 397 switch (msg.Buffer[3]) {
389 case 0x34: 398 case 0x34:
390 smprintf(s, "SMSC received\n"); 399 smprintf(s, "SMSC received\n");
391 Data->SMSC->Format = SMS_FORMAT_Text; 400 Data->SMSC->Format = SMS_FORMAT_Text;
392 switch (msg.Buffer[6]) { 401 switch (msg.Buffer[6]) {
393 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; 402 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
394 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; 403 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
395 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; 404 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break;
396 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; 405 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break;
397 } 406 }
398 Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; 407 Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat;
399 Data->SMSC->Validity.Relative= msg.Buffer[8]; 408 Data->SMSC->Validity.Relative= msg.Buffer[8];
400 if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time; 409 if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
401 410
402 i=33; 411 i=33;
403 while (msg.Buffer[i]!=0) {i++;} 412 while (msg.Buffer[i]!=0) {i++;}
404 i=i-33; 413 i=i-33;
405 if (i>GSM_MAX_SMSC_NAME_LENGTH) { 414 if (i>GSM_MAX_SMSC_NAME_LENGTH) {
406 smprintf(s, "Too long name\n"); 415 smprintf(s, "Too long name\n");
407 return ERR_UNKNOWNRESPONSE; 416 return ERR_UNKNOWNRESPONSE;
408 } 417 }
409 EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i); 418 EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i);
410 smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); 419 smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
411 420
412 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true); 421 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true);
413 smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); 422 smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
414 423
415 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false); 424 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false);
416 smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); 425 smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
417 426
418 return ERR_NONE; 427 return ERR_NONE;
419 case 0x35: 428 case 0x35:
420 smprintf(s, "Getting SMSC failed\n"); 429 smprintf(s, "Getting SMSC failed\n");
421 return ERR_INVALIDLOCATION; 430 return ERR_INVALIDLOCATION;
422 } 431 }
423 return ERR_UNKNOWNRESPONSE; 432 return ERR_UNKNOWNRESPONSE;
424} 433}
425 434
426GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 435GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
427{ 436{
428 unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64, 437 unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64,
429 0x00}; /* Location */ 438 0x00}; /* Location */
430 439
431 if (smsc->Location==0x00) return ERR_INVALIDLOCATION; 440 if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
432 441
433 req[5]=smsc->Location; 442 req[5]=smsc->Location;
434 443
435 s->Phone.Data.SMSC=smsc; 444 s->Phone.Data.SMSC=smsc;
436 smprintf(s, "Getting SMSC\n"); 445 smprintf(s, "Getting SMSC\n");
437 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); 446 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC);
438} 447}
439 448
440GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 449GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
441{ 450{
442 int count; 451 int count;
443 GSM_Phone_Data*Data = &s->Phone.Data; 452 GSM_Phone_Data*Data = &s->Phone.Data;
444#ifdef DEBUG 453#ifdef DEBUG
445 GSM_NetworkInfo NetInfo; 454 GSM_NetworkInfo NetInfo;
446 char name[100]; 455 char name[100];
447 456
448 smprintf(s, "Network info received\n"); 457 smprintf(s, "Network info received\n");
449 smprintf(s, "Status : "); 458 smprintf(s, "Status : ");
450 switch (msg.Buffer[8]) { 459 switch (msg.Buffer[8]) {
451 case 0x01: smprintf(s, "home network"); break; 460 case 0x01: smprintf(s, "home network"); break;
452 case 0x02: smprintf(s, "roaming network"); break; 461 case 0x02: smprintf(s, "roaming network"); break;
453 case 0x03: smprintf(s, "requesting network"); break; 462 case 0x03: smprintf(s, "requesting network"); break;
454 case 0x04: smprintf(s, "not registered in the network");break; 463 case 0x04: smprintf(s, "not registered in the network");break;
455 default : smprintf(s, "unknown"); 464 default : smprintf(s, "unknown");
456 } 465 }
457 smprintf(s, "\n"); 466 smprintf(s, "\n");
458 smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); 467 smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
459 if (msg.Buffer[8]<0x03) { 468 if (msg.Buffer[8]<0x03) {
460 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); 469 sprintf(NetInfo.CID, "%02X%02X", msg.Buffer[10], msg.Buffer[11]);
461 smprintf(s, "CID : %s\n", NetInfo.CID); 470 smprintf(s, "CID : %s\n", NetInfo.CID);
462 471
463 sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); 472 sprintf(NetInfo.LAC, "%02X%02X", msg.Buffer[12], msg.Buffer[13]);
464 smprintf(s, "LAC : %s\n", NetInfo.LAC); 473 smprintf(s, "LAC : %s\n", NetInfo.LAC);
465 474
466 NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode); 475 NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode);
467 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); 476 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
468 smprintf(s, "Network name for Gammu : %s ", 477 smprintf(s, "Network name for Gammu : %s ",
469 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); 478 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
470 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); 479 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
471 480
472 if (msg.Length>18) { 481 if (msg.Length>18) {
473 if (msg.Buffer[18]==0x00) { 482 if (msg.Buffer[18]==0x00) {
474 /* In 6210 name is in "normal" Unicode */ 483 /* In 6210 name is in "normal" Unicode */
475 memcpy(name,msg.Buffer+18,msg.Buffer[17]*2); 484 memcpy(name,msg.Buffer+18,msg.Buffer[17]*2);
476 name[msg.Buffer[17]*2]=0x00; 485 name[msg.Buffer[17]*2]=0x00;
477 name[msg.Buffer[17]*2+1]=0x00; 486 name[msg.Buffer[17]*2+1]=0x00;
478 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 487 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
479 } else { 488 } else {
480 /* In 9210 first 0x00 is cut from Unicode string */ 489 /* In 9210 first 0x00 is cut from Unicode string */
481 name[0] = 0; 490 name[0] = 0;
482 memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2); 491 memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2);
483 name[msg.Buffer[17]*2+1]=0x00; 492 name[msg.Buffer[17]*2+1]=0x00;
484 name[msg.Buffer[17]*2+2]=0x00; 493 name[msg.Buffer[17]*2+2]=0x00;
485 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 494 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
486 } 495 }
487 } 496 }
488 } 497 }
489#endif 498#endif
490 if (Data->RequestID==ID_GetNetworkInfo) { 499 if (Data->RequestID==ID_GetNetworkInfo) {
491 Data->NetworkInfo->NetworkName[0] = 0x00; 500 Data->NetworkInfo->NetworkName[0] = 0x00;
492 Data->NetworkInfo->NetworkName[1] = 0x00; 501 Data->NetworkInfo->NetworkName[1] = 0x00;
493 Data->NetworkInfo->State = 0; 502 Data->NetworkInfo->State = 0;
494 switch (msg.Buffer[8]) { 503 switch (msg.Buffer[8]) {
495 case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break; 504 case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break;
496 case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork;break; 505 case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork;break;
497 case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork;break; 506 case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork;break;
498 case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break; 507 case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break;
499 } 508 }
500 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { 509 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) {
501 if (msg.Buffer[18]==0x00) { 510 if (msg.Buffer[18]==0x00) {
502 /* In 6210 name is in "normal" Unicode */ 511 /* In 6210 name is in "normal" Unicode */
503 memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2); 512 memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2);
504 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00; 513 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00;
505 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00; 514 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00;
506 } else { 515 } else {
507 /* In 9210 first 0x00 is cut from Unicode string */ 516 /* In 9210 first 0x00 is cut from Unicode string */
508 Data->NetworkInfo->NetworkName[0] = 0; 517 Data->NetworkInfo->NetworkName[0] = 0;
509 memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2); 518 memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2);
510 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00; 519 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00;
511 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00; 520 Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00;
512 } 521 }
513 NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode); 522 NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode);
514 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); 523 sprintf(Data->NetworkInfo->CID, "%02X%02X", msg.Buffer[10], msg.Buffer[11]);
515 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); 524 sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg.Buffer[12], msg.Buffer[13]);
516 } 525 }
517 } 526 }
518 /* 6210/6250/7110 */ 527 /* 6210/6250/7110 */
519 if (Data->RequestID==ID_GetBitmap) { 528 if (Data->RequestID==ID_GetBitmap) {
520 if (msg.Buffer[4]==0x02) { 529 if (msg.Buffer[4]==0x02) {
521 smprintf(s, "Operator logo available\n"); 530 smprintf(s, "Operator logo available\n");
522 count = 7; 531 count = 7;
523 /* skip network info */ 532 /* skip network info */
524 count += msg.Buffer[count]; 533 count += msg.Buffer[count];
525 count ++; 534 count ++;
526 Data->Bitmap->BitmapWidth= msg.Buffer[count++]; 535 Data->Bitmap->BitmapWidth= msg.Buffer[count++];
527 Data->Bitmap->BitmapHeight= msg.Buffer[count++]; 536 Data->Bitmap->BitmapHeight= msg.Buffer[count++];
528 count+=4; 537 count+=4;
529 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo,msg.Buffer+count,Data->Bitmap); 538 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo,msg.Buffer+count,Data->Bitmap);
530 NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->Bitmap->NetworkCode); 539 NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->Bitmap->NetworkCode);
531 } else { 540 } else {
532 Data->Bitmap->BitmapWidth= 78; 541 Data->Bitmap->BitmapWidth= 78;
533 Data->Bitmap->BitmapHeight= 21; 542 Data->Bitmap->BitmapHeight= 21;
534 GSM_ClearBitmap(Data->Bitmap); 543 GSM_ClearBitmap(Data->Bitmap);
535 strcpy(Data->Bitmap->NetworkCode,"000 00"); 544 strcpy(Data->Bitmap->NetworkCode,"000 00");
536 } 545 }
537 } 546 }
538 return ERR_NONE; 547 return ERR_NONE;
539} 548}
540 549
541GSM_Error DCT3_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) 550GSM_Error DCT3_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo)
542{ 551{
543 unsigned char req[] = {N6110_FRAME_HEADER, 0x70}; 552 unsigned char req[] = {N6110_FRAME_HEADER, 0x70};
544 553
545 s->Phone.Data.NetworkInfo=netinfo; 554 s->Phone.Data.NetworkInfo=netinfo;
546 smprintf(s, "Getting network info\n"); 555 smprintf(s, "Getting network info\n");
547 return GSM_WaitFor (s, req, 4, 0x0a, 4, ID_GetNetworkInfo); 556 return GSM_WaitFor (s, req, 4, 0x0a, 4, ID_GetNetworkInfo);
548} 557}
549 558
550GSM_Error DCT3_ReplyDialCommand(GSM_Protocol_Message msg, GSM_StateMachine *s) 559GSM_Error DCT3_ReplyDialCommand(GSM_Protocol_Message msg, GSM_StateMachine *s)
551{ 560{
552 smprintf(s, "Answer for call commands\n"); 561 smprintf(s, "Answer for call commands\n");
553 return ERR_NONE; 562 return ERR_NONE;
554} 563}
555 564
556GSM_Error DCT3_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 565GSM_Error DCT3_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
557{ 566{
558 unsigned inti = 0; 567 unsigned inti = 0;
559 GSM_Errorerror; 568 GSM_Errorerror;
560 unsigned char req[100] = {0x00, 0x01, 0x7c, 569 unsigned char req[100] = {0x00, 0x01, 0x7c,
561 0x01}; /* call command */ 570 0x01}; /* call command */
562 571
563 if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED; 572 if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
564 573
565 error=DCT3_EnableSecurity (s, 0x01); 574 error=DCT3_EnableSecurity (s, 0x01);
566 if (error!=ERR_NONE) return error; 575 if (error!=ERR_NONE) return error;
567 576
568 for (i=0; i < strlen(number); i++) req[4+i]=number[i]; 577 for (i=0; i < strlen(number); i++) req[4+i]=number[i];
569 req[4+i+1]=0; 578 req[4+i+1]=0;
570 579
571 smprintf(s, "Making voice call\n"); 580 smprintf(s, "Making voice call\n");
572 return GSM_WaitFor (s, req, 4+strlen(number)+1, 0x40, 4, ID_DialVoice); 581 return GSM_WaitFor (s, req, 4+strlen(number)+1, 0x40, 4, ID_DialVoice);
573} 582}
574 583
575static GSM_Error DCT3_CancelAllCalls(GSM_StateMachine *s) 584static GSM_Error DCT3_CancelAllCalls(GSM_StateMachine *s)
576{ 585{
577 GSM_Errorerror; 586 GSM_Errorerror;
578 unsigned char req[] = {0x00, 0x01, 0x7c, 587 unsigned char req[] = {0x00, 0x01, 0x7c,
579 0x03}; /* call command */ 588 0x03}; /* call command */
580 589
581 error=DCT3_EnableSecurity (s, 0x01); 590 error=DCT3_EnableSecurity (s, 0x01);
582 if (error!=ERR_NONE) return error; 591 if (error!=ERR_NONE) return error;
583 592
584 smprintf(s, "Canceling calls\n"); 593 smprintf(s, "Canceling calls\n");
585 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_CancelCall); 594 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_CancelCall);
586} 595}
587 596
588GSM_Error DCT3_CancelCall(GSM_StateMachine *s, int ID, bool all) 597GSM_Error DCT3_CancelCall(GSM_StateMachine *s, int ID, bool all)
589{ 598{
590 if (!all) return DCT3DCT4_CancelCall(s,ID); 599 if (!all) return DCT3DCT4_CancelCall(s,ID);
591 return DCT3_CancelAllCalls(s); 600 return DCT3_CancelAllCalls(s);
592} 601}
593 602
594GSM_Error DCT3_AnswerAllCalls(GSM_StateMachine *s) 603GSM_Error DCT3_AnswerAllCalls(GSM_StateMachine *s)
595{ 604{
596 GSM_Errorerror; 605 GSM_Errorerror;
597 unsigned char req[] = {0x00, 0x01, 0x7c, 606 unsigned char req[] = {0x00, 0x01, 0x7c,
598 0x02}; /* call command */ 607 0x02}; /* call command */
599 608
600 error=DCT3_EnableSecurity (s, 0x01); 609 error=DCT3_EnableSecurity (s, 0x01);
601 if (error!=ERR_NONE) return error; 610 if (error!=ERR_NONE) return error;
602 611
603 smprintf(s, "Answering calls\n"); 612 smprintf(s, "Answering calls\n");
604 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_AnswerCall); 613 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_AnswerCall);
605} 614}
606 615
607GSM_Error DCT3_Reset(GSM_StateMachine *s, bool hard) 616GSM_Error DCT3_Reset(GSM_StateMachine *s, bool hard)
608{ 617{
609 GSM_Error error; 618 GSM_Error error;
610 619
611 if (hard) { 620 if (hard) {
612 error=DCT3_EnableSecurity(s, 0x04); 621 error=DCT3_EnableSecurity(s, 0x04);
613 } else { 622 } else {
614 error=DCT3_EnableSecurity(s, 0x03); 623 error=DCT3_EnableSecurity(s, 0x03);
615 } 624 }
616 if (error == ERR_NONE) { 625 if (error == ERR_NONE) {
617 s->Phone.Data.EnableIncomingSMS = false; 626 s->Phone.Data.EnableIncomingSMS = false;
618 s->Phone.Data.EnableIncomingCB = false; 627 s->Phone.Data.EnableIncomingCB = false;
619 } 628 }
620 return error; 629 return error;
621} 630}
622 631
623GSM_Error DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s) 632GSM_Error DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s)
624{ 633{
625 return DCT3DCT4_ReplyGetWAPBookmark (msg,s,false); 634 return DCT3DCT4_ReplyGetWAPBookmark (msg,s,false);
626} 635}
627 636
628GSM_Error DCT3_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 637GSM_Error DCT3_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
629{ 638{
630 GSM_Error error; 639 GSM_Error error;
631 int count = 4, location; 640 int count = 4, location;
632 unsigned char req[600] = {N6110_FRAME_HEADER, 0x09}; 641 unsigned char req[600] = {N6110_FRAME_HEADER, 0x09};
633 642
634 /* We have to enable WAP frames in phone */ 643 /* We have to enable WAP frames in phone */
635 error=DCT3DCT4_EnableWAPFunctions(s); 644 error=DCT3DCT4_EnableWAPFunctions(s);
636 if (error!=ERR_NONE) return error; 645 if (error!=ERR_NONE) return error;
637 646
638 location = bookmark->Location - 1; 647 location = bookmark->Location - 1;
639 if (bookmark->Location == 0) location = 0xffff; 648 if (bookmark->Location == 0) location = 0xffff;
640 req[count++] = (location & 0xff00) >> 8; 649 req[count++] = (location & 0xff00) >> 8;
641 req[count++] = location & 0x00ff; 650 req[count++] = location & 0x00ff;
642 651
643 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Title, false); 652 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Title, false);
644 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Address, false); 653 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Address, false);
645 654
646 /* unknown */ 655 /* unknown */
647 req[count++] = 0x01; req[count++] = 0x80; req[count++] = 0x00; 656 req[count++] = 0x01; req[count++] = 0x80; req[count++] = 0x00;
648 req[count++] = 0x00; req[count++] = 0x00; req[count++] = 0x00; 657 req[count++] = 0x00; req[count++] = 0x00; req[count++] = 0x00;
649 req[count++] = 0x00; req[count++] = 0x00; req[count++] = 0x00; 658 req[count++] = 0x00; req[count++] = 0x00; req[count++] = 0x00;
650 659
651 smprintf(s, "Setting WAP bookmark\n"); 660 smprintf(s, "Setting WAP bookmark\n");
652 error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark); 661 error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark);
653 if (error != ERR_NONE) { 662 if (error != ERR_NONE) {
654 if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) { 663 if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) {
655 DCT3DCT4_DisableConnectionFunctions(s); 664 DCT3DCT4_DisableConnectionFunctions(s);
656 } 665 }
657 return error; 666 return error;
658 } 667 }
659 668
660 return DCT3DCT4_DisableConnectionFunctions(s); 669 return DCT3DCT4_DisableConnectionFunctions(s);
661} 670}
662 671
663GSM_Error DCT3_ReplyGetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s) 672GSM_Error DCT3_ReplyGetWAPSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
664{ 673{
665 int tmp,Number; 674 int tmp,Number;
666 // int tmp2; 675 // int tmp2;
667 GSM_Phone_Data *Data = &s->Phone.Data; 676 GSM_Phone_Data *Data = &s->Phone.Data;
668#ifdef GSM_ENABLE_NOKIA6110 677#ifdef GSM_ENABLE_NOKIA6110
669 GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110; 678 GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110;
670#endif 679#endif
671#ifdef GSM_ENABLE_NOKIA7110 680#ifdef GSM_ENABLE_NOKIA7110
672 GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110; 681 GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110;
673#endif 682#endif
674 683
675 switch(msg.Buffer[3]) { 684 switch(msg.Buffer[3]) {
676 case 0x16: 685 case 0x16:
677 smprintf(s, "WAP settings part 1 received OK\n"); 686 smprintf(s, "WAP settings part 1 received OK\n");
678 687
679 tmp = 4; 688 tmp = 4;
680 689
681 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Title,false); 690 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Title,false);
682 smprintf(s, "Title: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Title)); 691 smprintf(s, "Title: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Title));
683 692
684 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].HomePage,false); 693 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].HomePage,false);
685 smprintf(s, "Homepage: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].HomePage)); 694 smprintf(s, "Homepage: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].HomePage));
686#ifdef DEBUG 695#ifdef DEBUG
687 smprintf(s, "Connection type: "); 696 smprintf(s, "Connection type: ");
688 switch (msg.Buffer[tmp]) { 697 switch (msg.Buffer[tmp]) {
689 case 0x00: smprintf(s, "temporary\n"); break; 698 case 0x00: smprintf(s, "temporary\n"); break;
690 case 0x01: smprintf(s, "continuous\n"); break; 699 case 0x01: smprintf(s, "continuous\n"); break;
691 default: smprintf(s, "unknown\n"); 700 default: smprintf(s, "unknown\n");
692 } 701 }
693 smprintf(s, "Connection security: "); 702 smprintf(s, "Connection security: ");
694 switch (msg.Buffer[tmp+13]) { 703 switch (msg.Buffer[tmp+13]) {
695 case 0x00: smprintf(s, "off\n");break; 704 case 0x00: smprintf(s, "off\n");break;
696 case 0x01: smprintf(s, "on\n"); break; 705 case 0x01: smprintf(s, "on\n"); break;
697 default: smprintf(s, "unknown\n"); 706 default: smprintf(s, "unknown\n");
698 } 707 }
699#endif 708#endif
700 Data->WAPSettings->Settings[0].IsContinuous = false; 709 Data->WAPSettings->Settings[0].IsContinuous = false;
701 if (msg.Buffer[tmp] == 0x01) Data->WAPSettings->Settings[0].IsContinuous = true; 710 if (msg.Buffer[tmp] == 0x01) Data->WAPSettings->Settings[0].IsContinuous = true;
702 Data->WAPSettings->Settings[0].IsSecurity = false; 711 Data->WAPSettings->Settings[0].IsSecurity = false;
703 if (msg.Buffer[tmp+13] == 0x01) Data->WAPSettings->Settings[0].IsSecurity = true; 712 if (msg.Buffer[tmp+13] == 0x01) Data->WAPSettings->Settings[0].IsSecurity = true;
704 713
705 /* I'm not sure here. Experimental values from 6210 5.56 */ 714 /* I'm not sure here. Experimental values from 6210 5.56 */
706 // tmp2 = DecodeUnicodeLength(Data->WAPSettings->Settings[0].Title); 715 // tmp2 = DecodeUnicodeLength(Data->WAPSettings->Settings[0].Title);
707 // if (tmp2 != 0) tmp2 --; 716 // if (tmp2 != 0) tmp2 --;
708 // tmp2 += tmp; 717 // tmp2 += tmp;
709 if (!(UnicodeLength(Data->WAPSettings->Settings[0].Title)) % 2) tmp++; 718 if (!(UnicodeLength(Data->WAPSettings->Settings[0].Title)) % 2) tmp++;
710 if (UnicodeLength(Data->WAPSettings->Settings[0].HomePage)!=0) tmp++; 719 if (UnicodeLength(Data->WAPSettings->Settings[0].HomePage)!=0) tmp++;
711 720
712 smprintf(s, "ID for writing %i\n",msg.Buffer[tmp+5]); 721 smprintf(s, "ID for writing %i\n",msg.Buffer[tmp+5]);
713 722
714 smprintf(s, "Current set location in phone %i\n",msg.Buffer[tmp+6]); 723 smprintf(s, "Current set location in phone %i\n",msg.Buffer[tmp+6]);
715 724
716 smprintf(s, "1 location %i\n",msg.Buffer[tmp+8]); 725 smprintf(s, "1 location %i\n",msg.Buffer[tmp+8]);
717 smprintf(s, "2 location %i\n",msg.Buffer[tmp+9]); 726 smprintf(s, "2 location %i\n",msg.Buffer[tmp+9]);
718 smprintf(s, "3 location %i\n",msg.Buffer[tmp+10]); 727 smprintf(s, "3 location %i\n",msg.Buffer[tmp+10]);
719 smprintf(s, "4 location %i\n",msg.Buffer[tmp+11]); 728 smprintf(s, "4 location %i\n",msg.Buffer[tmp+11]);
720#ifdef GSM_ENABLE_NOKIA7110 729#ifdef GSM_ENABLE_NOKIA7110
721 if (strstr(N7110Phone.models, Data->ModelInfo->model) != NULL) { 730 if (strstr(N7110Phone.models, Data->ModelInfo->model) != NULL) {
722 Priv7110->WAPLocations.ID = msg.Buffer[tmp+5]; 731 Priv7110->WAPLocations.ID = msg.Buffer[tmp+5];
723 Priv7110->WAPLocations.CurrentLocation= msg.Buffer[tmp+6]; 732 Priv7110->WAPLocations.CurrentLocation= msg.Buffer[tmp+6];
724 Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp+8]; 733 Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp+8];
725 Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp+9]; 734 Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp+9];
726 Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp+10]; 735 Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp+10];
727 Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp+11]; 736 Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp+11];
728 737
729 // Priv7110->WAPLocations.CurrentLocation= msg.Buffer[tmp2+1]; 738 // Priv7110->WAPLocations.CurrentLocation= msg.Buffer[tmp2+1];
730 // Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp2+3]; 739 // Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp2+3];
731 // Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp2+4]; 740 // Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp2+4];
732 // Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp2+5]; 741 // Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp2+5];
733 // Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp2+6]; 742 // Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp2+6];
734 } 743 }
735#endif 744#endif
736#ifdef GSM_ENABLE_NOKIA6110 745#ifdef GSM_ENABLE_NOKIA6110
737 if (strstr(N6110Phone.models, Data->ModelInfo->model) != NULL) { 746 if (strstr(N6110Phone.models, Data->ModelInfo->model) != NULL) {
738 Priv6110->WAPLocations.ID = msg.Buffer[tmp+5]; 747 Priv6110->WAPLocations.ID = msg.Buffer[tmp+5];
739 Priv6110->WAPLocations.CurrentLocation= msg.Buffer[tmp+6]; 748 Priv6110->WAPLocations.CurrentLocation= msg.Buffer[tmp+6];
740 Priv6110->WAPLocations.Locations[0] = msg.Buffer[tmp+8]; 749 Priv6110->WAPLocations.Locations[0] = msg.Buffer[tmp+8];
741 Priv6110->WAPLocations.Locations[1] = msg.Buffer[tmp+9]; 750 Priv6110->WAPLocations.Locations[1] = msg.Buffer[tmp+9];
742 Priv6110->WAPLocations.Locations[2] = msg.Buffer[tmp+10]; 751 Priv6110->WAPLocations.Locations[2] = msg.Buffer[tmp+10];
743 Priv6110->WAPLocations.Locations[3] = msg.Buffer[tmp+11]; 752 Priv6110->WAPLocations.Locations[3] = msg.Buffer[tmp+11];
744 } 753 }
745#endif 754#endif
746 return ERR_NONE; 755 return ERR_NONE;
747 case 0x17: 756 case 0x17:
748 smprintf(s, "WAP settings part 1 receiving error\n"); 757 smprintf(s, "WAP settings part 1 receiving error\n");
749 switch (msg.Buffer[4]) { 758 switch (msg.Buffer[4]) {
750 case 0x01: 759 case 0x01:
751 smprintf(s, "Security error. Inside WAP settings menu\n"); 760 smprintf(s, "Security error. Inside WAP settings menu\n");
752 return ERR_INSIDEPHONEMENU; 761 return ERR_INSIDEPHONEMENU;
753 case 0x02: 762 case 0x02:
754 smprintf(s, "Invalid or empty\n"); 763 smprintf(s, "Invalid or empty\n");
755 return ERR_INVALIDLOCATION; 764 return ERR_INVALIDLOCATION;
756 default: 765 default:
757 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 766 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
758 return ERR_UNKNOWNRESPONSE; 767 return ERR_UNKNOWNRESPONSE;
759 } 768 }
760 break; 769 break;
761 case 0x1c: 770 case 0x1c:
762 smprintf(s, "WAP settings part 2 received OK\n"); 771 smprintf(s, "WAP settings part 2 received OK\n");
763 Number = Data->WAPSettings->Number; 772 Number = Data->WAPSettings->Number;
764 switch (msg.Buffer[5]) { 773 switch (msg.Buffer[5]) {
765 case 0x00: 774 case 0x00:
766 Data->WAPSettings->Settings[Number].Bearer = WAPSETTINGS_BEARER_SMS; 775 Data->WAPSettings->Settings[Number].Bearer = WAPSETTINGS_BEARER_SMS;
767 smprintf(s, "Settings for SMS bearer:\n"); 776 smprintf(s, "Settings for SMS bearer:\n");
768 tmp = 6; 777 tmp = 6;
769 778
770 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Service,false); 779 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Service,false);
771 smprintf(s, "Service number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service)); 780 smprintf(s, "Service number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service));
772 781
773 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Server,false); 782 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Server,false);
774 smprintf(s, "Server number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Server)); 783 smprintf(s, "Server number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Server));
775 break; 784 break;
776 case 0x01: 785 case 0x01:
777 Data->WAPSettings->Settings[Number].Bearer = WAPSETTINGS_BEARER_DATA; 786 Data->WAPSettings->Settings[Number].Bearer = WAPSETTINGS_BEARER_DATA;
778 smprintf(s, "Settings for data bearer:\n"); 787 smprintf(s, "Settings for data bearer:\n");
779 Data->WAPSettings->Settings[Number].ManualLogin = false; 788 Data->WAPSettings->Settings[Number].ManualLogin = false;
780 tmp = 10; 789 tmp = 10;
781 790
782 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].IPAddress,false); 791 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].IPAddress,false);
783 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].IPAddress)); 792 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].IPAddress));
784 793
785 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].DialUp,false); 794 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].DialUp,false);
786 smprintf(s, "Dial-up number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].DialUp)); 795 smprintf(s, "Dial-up number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].DialUp));
787 796
788 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].User,false); 797 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].User,false);
789 smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].User)); 798 smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].User));
790 799
791 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Password,false); 800 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Password,false);
792 smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Password)); 801 smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Password));
793#ifdef DEBUG 802#ifdef DEBUG
794 smprintf(s, "Authentication type: "); 803 smprintf(s, "Authentication type: ");
795 switch (msg.Buffer[6]) { 804 switch (msg.Buffer[6]) {
796 case 0x00: smprintf(s, "normal\n"); break; 805 case 0x00: smprintf(s, "normal\n"); break;
797 case 0x01: smprintf(s, "secure\n"); break; 806 case 0x01: smprintf(s, "secure\n"); break;
798 default: smprintf(s, "unknown\n"); break; 807 default: smprintf(s, "unknown\n"); break;
799 } 808 }
800 smprintf(s, "Data call type: "); 809 smprintf(s, "Data call type: ");
801 switch (msg.Buffer[7]) { 810 switch (msg.Buffer[7]) {
802 case 0x00: smprintf(s, "analogue\n"); break; 811 case 0x00: smprintf(s, "analogue\n"); break;
803 case 0x01: smprintf(s, "ISDN\n"); break; 812 case 0x01: smprintf(s, "ISDN\n"); break;
804 default: smprintf(s, "unknown\n"); break; 813 default: smprintf(s, "unknown\n"); break;
805 } 814 }
806 smprintf(s, "Data call speed: "); 815 smprintf(s, "Data call speed: ");
807 switch (msg.Buffer[9]) { 816 switch (msg.Buffer[9]) {
808 case 0x01: smprintf(s, "9600\n"); break; 817 case 0x01: smprintf(s, "9600\n"); break;
809 case 0x02: smprintf(s, "14400\n"); break; 818 case 0x02: smprintf(s, "14400\n"); break;
810 default: smprintf(s, "unknown\n"); break; 819 default: smprintf(s, "unknown\n"); break;
811 } 820 }
812#endif 821#endif
813 Data->WAPSettings->Settings[Number].IsNormalAuthentication=true; 822 Data->WAPSettings->Settings[Number].IsNormalAuthentication=true;
814 if (msg.Buffer[6]==0x01) Data->WAPSettings->Settings[Number].IsNormalAuthentication=false; 823 if (msg.Buffer[6]==0x01) Data->WAPSettings->Settings[Number].IsNormalAuthentication=false;
815 Data->WAPSettings->Settings[Number].IsISDNCall=false; 824 Data->WAPSettings->Settings[Number].IsISDNCall=false;
816 if (msg.Buffer[7]==0x01) Data->WAPSettings->Settings[Number].IsISDNCall=true; 825 if (msg.Buffer[7]==0x01) Data->WAPSettings->Settings[Number].IsISDNCall=true;
817 Data->WAPSettings->Settings[Number].Speed = WAPSETTINGS_SPEED_9600; 826 Data->WAPSettings->Settings[Number].Speed = WAPSETTINGS_SPEED_9600;
818 if (msg.Buffer[9]==0x02) Data->WAPSettings->Settings[Number].Speed = WAPSETTINGS_SPEED_14400; 827 if (msg.Buffer[9]==0x02) Data->WAPSettings->Settings[Number].Speed = WAPSETTINGS_SPEED_14400;
819 break; 828 break;
820 case 0x02: 829 case 0x02:
821 Data->WAPSettings->Settings[Number].Bearer=WAPSETTINGS_BEARER_USSD; 830 Data->WAPSettings->Settings[Number].Bearer=WAPSETTINGS_BEARER_USSD;
822 smprintf(s, "Settings for USSD bearer:\n"); 831 smprintf(s, "Settings for USSD bearer:\n");
823 tmp = 7; 832 tmp = 7;
824 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Service,false); 833 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Service,false);
825#ifdef DEBUG 834#ifdef DEBUG
826 if (msg.Buffer[6]==0x01) 835 if (msg.Buffer[6]==0x01)
827 smprintf(s, "Service number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service)); 836 smprintf(s, "Service number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service));
828 else 837 else
829 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service)); 838 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Service));
830#endif 839#endif
831 Data->WAPSettings->Settings[Number].IsIP=true; 840 Data->WAPSettings->Settings[Number].IsIP=true;
832 if (msg.Buffer[6]==0x01) Data->WAPSettings->Settings[Number].IsIP=false; 841 if (msg.Buffer[6]==0x01) Data->WAPSettings->Settings[Number].IsIP=false;
833 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Code,false); 842 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[Number].Code,false);
834 smprintf(s, "Service code: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Code)); 843 smprintf(s, "Service code: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[Number].Code));
835 } 844 }
836 Data->WAPSettings->Number++; 845 Data->WAPSettings->Number++;
837 return ERR_NONE; 846 return ERR_NONE;
838 case 0x1d: 847 case 0x1d:
839 smprintf(s, "Incorrect WAP settings location\n"); 848 smprintf(s, "Incorrect WAP settings location\n");
840 return ERR_NONE; 849 return ERR_NONE;
841 } 850 }
842 return ERR_UNKNOWNRESPONSE; 851 return ERR_UNKNOWNRESPONSE;
843} 852}
844 853
845GSM_Error DCT3_GetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings) 854GSM_Error DCT3_GetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
846{ 855{
847#ifdef GSM_ENABLE_NOKIA6110 856#ifdef GSM_ENABLE_NOKIA6110
848 GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110; 857 GSM_Phone_N6110Data *Priv6110 = &s->Phone.Data.Priv.N6110;
849#endif 858#endif
850#ifdef GSM_ENABLE_NOKIA7110 859#ifdef GSM_ENABLE_NOKIA7110
851 GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110; 860 GSM_Phone_N7110Data *Priv7110 = &s->Phone.Data.Priv.N7110;
852#endif 861#endif
853 GSM_Error error; 862 GSM_Error error;
854 int i; 863 int i;
855 unsigned char req[] = {N6110_FRAME_HEADER,0x15, 864 unsigned char req[] = {N6110_FRAME_HEADER,0x15,
856 0x00}; /* Location */ 865 0x00}; /* Location */
857 unsigned char req2[] = {N6110_FRAME_HEADER,0x1b, 866 unsigned char req2[] = {N6110_FRAME_HEADER,0x1b,
858 0x00}; /* Location */ 867 0x00}; /* Location */
859 868
860 /* We have to enable WAP frames in phone */ 869 /* We have to enable WAP frames in phone */
861 error=DCT3DCT4_EnableWAPFunctions(s); 870 error=DCT3DCT4_EnableWAPFunctions(s);
862 if (error!=ERR_NONE) return error; 871 if (error!=ERR_NONE) return error;
863 872
864 s->Phone.Data.WAPSettings = settings; 873 s->Phone.Data.WAPSettings = settings;
865 settings->Number = 0; 874 settings->Number = 0;
866 settings->ReadOnly = false; 875 settings->ReadOnly = false;
867 876
868 req[4] = settings->Location-1; 877 req[4] = settings->Location-1;
869 smprintf(s, "Getting WAP settings part 1\n"); 878 smprintf(s, "Getting WAP settings part 1\n");
870 error = GSM_WaitFor (s, req, 5, 0x3f, 4, ID_GetConnectSet); 879 error = GSM_WaitFor (s, req, 5, 0x3f, 4, ID_GetConnectSet);
871 if (error != ERR_NONE) return error; 880 if (error != ERR_NONE) return error;
872 881
873#ifdef GSM_ENABLE_NOKIA7110 882#ifdef GSM_ENABLE_NOKIA7110
874 if (strstr(N7110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) { 883 if (strstr(N7110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) {
875 for (i=0;i<4;i++) { 884 for (i=0;i<4;i++) {
876 req2[4] = Priv7110->WAPLocations.Locations[i]; 885 req2[4] = Priv7110->WAPLocations.Locations[i];
877 smprintf(s, "Getting WAP settings part 2\n"); 886 smprintf(s, "Getting WAP settings part 2\n");
878 error=GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_GetConnectSet); 887 error=GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_GetConnectSet);
879 if (error != ERR_NONE) return error; 888 if (error != ERR_NONE) return error;
880 if (Priv7110->WAPLocations.Locations[i] == Priv7110->WAPLocations.CurrentLocation) { 889 if (Priv7110->WAPLocations.Locations[i] == Priv7110->WAPLocations.CurrentLocation) {
881 settings->ActiveBearer = settings->Settings[settings->Number-1].Bearer; 890 settings->ActiveBearer = settings->Settings[settings->Number-1].Bearer;
882 } 891 }
883 } 892 }
884 } 893 }
885#endif 894#endif
886#ifdef GSM_ENABLE_NOKIA6110 895#ifdef GSM_ENABLE_NOKIA6110
887 if (strstr(N6110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) { 896 if (strstr(N6110Phone.models, s->Phone.Data.ModelInfo->model) != NULL) {
888 for (i=0;i<4;i++) { 897 for (i=0;i<4;i++) {
889 req2[4] = Priv6110->WAPLocations.Locations[i]; 898 req2[4] = Priv6110->WAPLocations.Locations[i];
890 smprintf(s, "Getting WAP settings part 2\n"); 899 smprintf(s, "Getting WAP settings part 2\n");
891 error=GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_GetConnectSet); 900 error=GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_GetConnectSet);
892 if (error != ERR_NONE) return error; 901 if (error != ERR_NONE) return error;
893 if (Priv6110->WAPLocations.Locations[i] == Priv6110->WAPLocations.CurrentLocation) { 902 if (Priv6110->WAPLocations.Locations[i] == Priv6110->WAPLocations.CurrentLocation) {
894 settings->ActiveBearer = settings->Settings[settings->Number-1].Bearer; 903 settings->ActiveBearer = settings->Settings[settings->Number-1].Bearer;
895 } 904 }
896 } 905 }
897 } 906 }
898#endif 907#endif
899 if (error == ERR_NONE) { 908 if (error == ERR_NONE) {
diff --git a/gammu/emb/common/phone/nokia/dct3/n0650.c b/gammu/emb/common/phone/nokia/dct3/n0650.c
new file mode 100644
index 0000000..3899a16
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n0650.c
@@ -0,0 +1,150 @@
1/* (c) 2004 by Marcin Wiacek */
2
3#include <string.h>
4#include <time.h>
5
6#include "../../../gsmcomon.h"
7#include "../../../gsmstate.h"
8#include "../nfunc.h"
9
10#ifdef GSM_ENABLE_NOKIA650
11
12static GSM_Reply_Function N650ReplyFunctions[] = {
13 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel },
14 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware },
15
16 {NULL, "\x00",0x00,0x00,ID_None }
17};
18
19GSM_Phone_Functions N650Phone = {
20 "0650",
21 N650ReplyFunctions,
22 NONEFUNCTION, /* Initialise */
23 NONEFUNCTION, /* Terminate */
24 GSM_DispatchMessage,
25 NOTSUPPORTED, /* ShowStartInfo */
26 NOKIA_GetManufacturer,
27 DCT3DCT4_GetModel,
28 DCT3DCT4_GetFirmware,
29 NOTSUPPORTED, /* GetIMEI */
30 NOTSUPPORTED, /* GetOriginalIMEI */
31 NOTSUPPORTED, /* GetManufactureMonth*/
32 NOTSUPPORTED, /* GetProductCode */
33 NOTSUPPORTED, /* GetHardware */
34 NOTSUPPORTED, /* GetPPM */
35 NOTSUPPORTED, /* GetSIMIMSI */
36 NOTSUPPORTED, /* GetDateTime */
37 NOTSUPPORTED, /* SetDateTime */
38 NOTSUPPORTED, /* GetAlarm */
39 NOTSUPPORTED, /* SetAlarm */
40 NOTSUPPORTED, /* GetLocale */
41 NOTSUPPORTED, /* SetLocale */
42 NOTSUPPORTED, /* PressKey */
43 NOTSUPPORTED, /* Reset */
44 NOTSUPPORTED, /* ResetPhoneSettings*/
45 NOTSUPPORTED, /* EnterSecurityCode*/
46 NOTSUPPORTED, /* GetSecurityStatus*/
47 NOTSUPPORTED, /* GetDisplayStatus*/
48 NOTSUPPORTED, /* SetAutoNetworkLogin*/
49 NOTSUPPORTED, /* GetBatteryCharge*/
50 NOTSUPPORTED, /* GetSignalQuality*/
51 NOTSUPPORTED, /* GetNetworkInfo */
52 NOTSUPPORTED, /* GetCategory */
53 NOTSUPPORTED, /* AddCategory */
54 NOTSUPPORTED, /* GetCategoryStatus */
55 NOTSUPPORTED, /* GetMemoryStatus */
56 NOTSUPPORTED, /* GetMemory */
57 NOTSUPPORTED, /* GetNextMemory */
58 NOTSUPPORTED, /* SetMemory */
59 NOTSUPPORTED, /* AddMemory */
60 NOTSUPPORTED, /* DeleteMemory */
61 NOTIMPLEMENTED, /* DeleteAllMemory */
62 NOTSUPPORTED, /* GetSpeedDial */
63 NOTSUPPORTED, /* SetSpeedDial */
64 NOTSUPPORTED, /* GetSMSC */
65 NOTSUPPORTED, /* SetSMSC */
66 NOTSUPPORTED, /* GetSMSStatus */
67 NOTSUPPORTED, /* GetSMS */
68 NOTSUPPORTED, /* GetNextSMS */
69 NOTSUPPORTED, /* SetSMS */
70 NOTSUPPORTED, /* AddSMS */
71 NOTSUPPORTED, /* DeleteSMS */
72 NOTSUPPORTED, /* SendSMSMessage */
73 NOTSUPPORTED, /* SendSavedSMS */
74 NOTSUPPORTED, /* SetIncomingSMS */
75 NOTSUPPORTED, /* SetIncomingCB */
76 NOTSUPPORTED, /* GetSMSFolders */
77 NOTSUPPORTED, /* AddSMSFolder */
78 NOTSUPPORTED, /* DeleteSMSFolder */
79 NOTSUPPORTED, /* DialVoice */
80 NOTSUPPORTED, /* AnswerCall */
81 NOTSUPPORTED, /* CancelCall */
82 NOTSUPPORTED, /* HoldCall */
83 NOTSUPPORTED, /* UnholdCall */
84 NOTSUPPORTED, /* ConferenceCall */
85 NOTSUPPORTED, /* SplitCall */
86 NOTSUPPORTED, /* TransferCall */
87 NOTSUPPORTED, /* SwitchCall */
88 NOTSUPPORTED, /* GetCallDivert */
89 NOTSUPPORTED, /* SetCallDivert */
90 NOTSUPPORTED, /* CancelAllDiverts*/
91 NOTSUPPORTED, /* SetIncomingCall */
92 NOTSUPPORTED, /* SetIncomingUSSD */
93 NOTSUPPORTED, /* SendDTMF */
94 NOTSUPPORTED, /* GetRingtone */
95 NOTSUPPORTED, /* SetRingtone */
96 NOTSUPPORTED, /* GetRingtonesInfo*/
97 NOTSUPPORTED, /* DeleteUserRingtones*/
98 NOTSUPPORTED, /* PlayTone */
99 NOTSUPPORTED, /* GetWAPBookmark */
100 NOTSUPPORTED, /* SetWAPBookmark */
101 NOTSUPPORTED, /* DeleteWAPBookmark */
102 NOTSUPPORTED, /* GetWAPSettings */
103 NOTSUPPORTED, /* SetWAPSettings */
104 NOTSUPPORTED, /* GetMMSSettings */
105 NOTSUPPORTED, /* SetMMSSettings */
106 NOTSUPPORTED, /* GetBitmap */
107 NOTSUPPORTED, /* SetBitmap */
108 NOTSUPPORTED, /* GetToDoStatus */
109 NOTSUPPORTED, /* GetToDo */
110 NOTSUPPORTED, /* GetNextToDo */
111 NOTSUPPORTED, /* SetToDo */
112 NOTSUPPORTED, /* AddToDo */
113 NOTSUPPORTED, /* DeleteToDo */
114 NOTSUPPORTED, /* DeleteAllToDo */
115 NOTSUPPORTED, /* GetCalendarStatus*/
116 NOTSUPPORTED, /* GetCalendar */
117 NOTSUPPORTED, /* GetNextCalendar */
118 NOTSUPPORTED, /* SetCalendar */
119 NOTSUPPORTED, /* AddCalendar */
120 NOTSUPPORTED, /* DeleteCalendar */
121 NOTSUPPORTED, /* DeleteAllCalendar*/
122 NOTSUPPORTED, /* GetCalendarSettings*/
123 NOTSUPPORTED, /* SetCalendarSettings*/
124 NOTSUPPORTED, /* GetNoteStatus */
125 NOTSUPPORTED, /* GetNote */
126 NOTSUPPORTED, /* GetNextNote */
127 NOTSUPPORTED, /* SetNote */
128 NOTSUPPORTED, /* AddNote */
129 NOTSUPPORTED, /* DeleteNote */
130 NOTSUPPORTED, /* DeleteAllNotes */
131 NOTSUPPORTED, /* GetProfile */
132 NOTSUPPORTED, /* SetProfile */
133 NOTSUPPORTED, /* GetFMStation */
134 NOTSUPPORTED, /* SetFMStation */
135 NOTSUPPORTED, /* ClearFMStations */
136 NOTSUPPORTED, /* GetNextFileFolder*/
137 NOTSUPPORTED, /* GetFilePart */
138 NOTSUPPORTED, /* AddFilePart */
139 NOTSUPPORTED, /* GetFileSystemStatus*/
140 NOTSUPPORTED, /* DeleteFile */
141 NOTSUPPORTED, /* AddFolder */
142 NOTSUPPORTED, /* GetGPRSAccessPoint*/
143 NOTSUPPORTED /* SetGPRSAccessPoint*/
144};
145
146#endif
147
148/* How should editor hadle tabs in this file? Add editor commands here.
149 * vim: noexpandtab sw=8 ts=8 sts=8:
150 */
diff --git a/gammu/emb/common/phone/nokia/dct3/n0650.h b/gammu/emb/common/phone/nokia/dct3/n0650.h
new file mode 100644
index 0000000..be491eb
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n0650.h
@@ -0,0 +1,18 @@
1/* (c) 2004 by Marcin Wiacek */
2
3#ifndef n650_h
4#define n650_h
5
6typedef struct {
7 int fake;
8} GSM_Phone_N650Data;
9
10#ifndef GSM_USED_MBUS2
11# define GSM_USED_MBUS2
12#endif
13
14#endif
15
16/* How should editor hadle tabs in this file? Add editor commands here.
17 * vim: noexpandtab sw=8 ts=8 sts=8:
18 */
diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c
index dac6c12..c3ddfb6 100644
--- a/gammu/emb/common/phone/nokia/dct3/n6110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n6110.c
@@ -1,390 +1,399 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* 5210 calendar IDs by Frederick Ros */ 2/* 5210 calendar IDs by Frederick Ros */
3/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org) 3/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later 5 * GNU GPL version 2 or later
6 */ 6 */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#include "../../../gsmstate.h" 17#include "../../../gsmstate.h"
9 18
10#ifdef GSM_ENABLE_NOKIA6110 19#ifdef GSM_ENABLE_NOKIA6110
11 20
12#include <string.h> 21#include <string.h>
13 22
14#include "../../../../cfg/config.h" 23#include "../../../../cfg/config.h"
15#include "../../../misc/coding/coding.h" 24#include "../../../misc/coding/coding.h"
16#include "../../../service/sms/gsmsms.h" 25#include "../../../service/sms/gsmsms.h"
17#include "../../../gsmcomon.h" 26#include "../../../gsmcomon.h"
18#include "../../pfunc.h" 27#include "../../pfunc.h"
19#include "../nfunc.h" 28#include "../nfunc.h"
20#include "n6110.h" 29#include "n6110.h"
21#include "dct3func.h" 30#include "dct3func.h"
22 31
23static unsigned char N6110_MEMORY_TYPES[] = { 32static unsigned char N6110_MEMORY_TYPES[] = {
24 MEM_ME, 0x02, 33 MEM_ME, 0x02,
25 MEM_SM, 0x03, 34 MEM_SM, 0x03,
26 MEM_ON, 0x05, 35 MEM_ON, 0x05,
27 MEM_DC, 0x07, 36 MEM_DC, 0x07,
28 MEM_RC, 0x08, 37 MEM_RC, 0x08,
29 MEM_MC, 0x09, 38 MEM_MC, 0x09,
30 MEM_VM, 0x0b, 39 MEM_VM, 0x0b,
31 0x00, 0x00 40 0x00, 0x00
32}; 41};
33 42
34static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s) 43static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s)
35{ 44{
36 N6110_Language lang = N6110_Auto; 45 N6110_Language lang = N6110_Auto;
37 46
38 if (msg.Buffer[3] == 0x15) return ERR_NONE; 47 if (msg.Buffer[3] == 0x15) return ERR_NONE;
39 48
40 smprintf(s, "Phone language is %02x\n",msg.Buffer[6]); 49 smprintf(s, "Phone language is %02x\n",msg.Buffer[6]);
41 switch (msg.Buffer[6]) { 50 switch (msg.Buffer[6]) {
42 case 0x21: lang = N6110_Europe; break; //Polish 51 case 0x21: lang = N6110_Europe; break; //Polish
43 } 52 }
44 s->Phone.Data.Priv.N6110.PhoneLanguage = lang; 53 s->Phone.Data.Priv.N6110.PhoneLanguage = lang;
45 return ERR_NONE; 54 return ERR_NONE;
46} 55}
47 56
48static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s) 57static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s)
49{ 58{
50 unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01, 59 unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01,
51 0x00, /* Profile location */ 60 0x00, /* Profile location */
52 0x00}; /* Feature number */ 61 0x00}; /* Feature number */
53 62
54 s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto; 63 s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto;
55 64
56 feat_req[5] = 0; 65 feat_req[5] = 0;
57 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) { 66 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) {
58 feat_req[6] = 0x1E; 67 feat_req[6] = 0x1E;
59 } else { 68 } else {
60 feat_req[6] = 0x21; 69 feat_req[6] = 0x21;
61 } 70 }
62 smprintf(s, "Getting profile feature\n"); 71 smprintf(s, "Getting profile feature\n");
63 return GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetLanguage); 72 return GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetLanguage);
64} 73}
65 74
66struct N6110_Lang_Char { 75struct N6110_Lang_Char {
67 N6110_Language Lang; 76 N6110_Language Lang;
68 unsigned char Phone; 77 unsigned char Phone;
69 unsigned char Unicode1; 78 unsigned char Unicode1;
70 unsigned char Unicode2; 79 unsigned char Unicode2;
71}; 80};
72 81
73static struct N6110_Lang_Char N6110_Lang_Table[] = { 82static struct N6110_Lang_Char N6110_Lang_Table[] = {
74{N6110_Europe,0x13,0x01,0x04},//Latin capital letter a with ogonek 83{N6110_Europe,0x13,0x01,0x04},//Latin capital letter a with ogonek
75{N6110_Europe,0x14,0x01,0x05},//Latin small letter a with ogonek 84{N6110_Europe,0x14,0x01,0x05},//Latin small letter a with ogonek
76{N6110_Europe,0x15,0x01,0x06},//Latin capital letter c with acute 85{N6110_Europe,0x15,0x01,0x06},//Latin capital letter c with acute
77{N6110_Europe,0x17,0x01,0x07},//Latin small letter c with acute 86{N6110_Europe,0x17,0x01,0x07},//Latin small letter c with acute
78{N6110_Europe,0x1D,0x01,0x18},//Latin capital letter e with ogonek 87{N6110_Europe,0x1D,0x01,0x18},//Latin capital letter e with ogonek
79{N6110_Europe,0x1E,0x01,0x19},//Latin small letter e with ogonek 88{N6110_Europe,0x1E,0x01,0x19},//Latin small letter e with ogonek
80{N6110_Europe,0x83,0x00,0xD3},//Latin capital letter o with acute 89{N6110_Europe,0x83,0x00,0xD3},//Latin capital letter o with acute
81{N6110_Europe,0x8E,0x01,0x41},//Latin capital letter l with stroke 90{N6110_Europe,0x8E,0x01,0x41},//Latin capital letter l with stroke
82{N6110_Europe,0x90,0x01,0x42},//Latin small letter l with stroke 91{N6110_Europe,0x90,0x01,0x42},//Latin small letter l with stroke
83{N6110_Europe,0x92,0x01,0x43},//Latin capital letter n with acute 92{N6110_Europe,0x92,0x01,0x43},//Latin capital letter n with acute
84{N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute 93{N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute
85{N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute 94{N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute
86{N6110_Europe,0xB2,0x20,0xAC},//euro 95{N6110_Europe,0xB2,0x20,0xAC},//euro
87{N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute 96{N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute
88{N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute 97{N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute
89{N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute 98{N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute
90{N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute 99{N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute
91{N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above 100{N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above
92{N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above 101{N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above
93{0,0,0,0} 102{0,0,0,0}
94}; 103};
95 104
96static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len) 105static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len)
97{ 106{
98 int i_len = 0, o_len, i; 107 int i_len = 0, o_len, i;
99 wchar_t wc; 108 wchar_t wc;
100 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; 109 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
101 bool found; 110 bool found;
102 111
103 for (o_len = 0; i_len < len; o_len++) { 112 for (o_len = 0; i_len < len; o_len++) {
104 found = false; 113 found = false;
105 if (Priv->PhoneLanguage != N6110_Auto) { 114 if (Priv->PhoneLanguage != N6110_Auto) {
106 i = 0; 115 i = 0;
107 while(1) { 116 while(1) {
108 if (N6110_Lang_Table[i].Lang == 0) break; 117 if (N6110_Lang_Table[i].Lang == 0) break;
109 if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage && 118 if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage &&
110 N6110_Lang_Table[i].Phone == src[i_len]) { 119 N6110_Lang_Table[i].Phone == src[i_len]) {
111 dest[o_len*2] = N6110_Lang_Table[i].Unicode1; 120 dest[o_len*2] = N6110_Lang_Table[i].Unicode1;
112 dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2; 121 dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2;
113 i_len++; 122 i_len++;
114 found = true; 123 found = true;
115 break; 124 break;
116 } 125 }
117 i++; 126 i++;
118 } 127 }
119 } 128 }
120 if (!found) { 129 if (!found) {
121 i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc); 130 i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc);
122 dest[o_len*2] = (wc >> 8) & 0xff; 131 dest[o_len*2] = (wc >> 8) & 0xff;
123 dest[(o_len*2)+1] = wc & 0xff; 132 dest[(o_len*2)+1] = wc & 0xff;
124 } 133 }
125 } 134 }
126 dest[o_len*2] = 0; 135 dest[o_len*2] = 0;
127 dest[(o_len*2)+1] = 0; 136 dest[(o_len*2)+1] = 0;
128} 137}
129 138
130#ifndef ENABLE_LGPL 139#ifndef ENABLE_LGPL
131 140
132/* Pavel Janik */ 141/* Pavel Janik */
133/* This function provides Nokia authentication protocol. 142/* This function provides Nokia authentication protocol.
134 * Nokia authentication protocol is used in the communication between Nokia 143 * Nokia authentication protocol is used in the communication between Nokia
135 * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software, 144 * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
136 * commercially sold by Nokia Corp. 145 * commercially sold by Nokia Corp.
137 * The authentication scheme is based on the token send by the phone to the 146 * The authentication scheme is based on the token send by the phone to the
138 * software. The software does it's magic (see the function 147 * software. The software does it's magic (see the function
139 * N6110_GetNokiaAuthentication) and returns the result back to the phone. 148 * N6110_GetNokiaAuthentication) and returns the result back to the phone.
140 * If the result is correct the phone responds with the message "Accessory 149 * If the result is correct the phone responds with the message "Accessory
141 * connected!" displayed on the LCD. Otherwise it will display "Accessory not 150 * connected!" displayed on the LCD. Otherwise it will display "Accessory not
142 * supported" and some functions will not be available for use (?). 151 * supported" and some functions will not be available for use (?).
143 * The specification of the protocol is not publicly available, no comment. 152 * The specification of the protocol is not publicly available, no comment.
144 */ 153 */
145static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse) 154static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)
146{ 155{
147 int i, j, CRC=0; 156 int i, j, CRC=0;
148 unsigned char Temp[16]; /* This is our temporary working area. */ 157 unsigned char Temp[16]; /* This is our temporary working area. */
149 158
150 /* Here we put FAC (Final Assembly Code) and serial number into our area. */ 159 /* Here we put FAC (Final Assembly Code) and serial number into our area. */
151 Temp[0] = Imei[6]; Temp[1] = Imei[7]; 160 Temp[0] = Imei[6]; Temp[1] = Imei[7];
152 Temp[2] = Imei[8]; Temp[3] = Imei[9]; 161 Temp[2] = Imei[8]; Temp[3] = Imei[9];
153 Temp[4] = Imei[10]; Temp[5] = Imei[11]; 162 Temp[4] = Imei[10]; Temp[5] = Imei[11];
154 Temp[6] = Imei[12]; Temp[7] = Imei[13]; 163 Temp[6] = Imei[12]; Temp[7] = Imei[13];
155 164
156 /* And now the TAC (Type Approval Code). */ 165 /* And now the TAC (Type Approval Code). */
157 Temp[8] = Imei[2]; Temp[9] = Imei[3]; 166 Temp[8] = Imei[2]; Temp[9] = Imei[3];
158 Temp[10] = Imei[4]; Temp[11] = Imei[5]; 167 Temp[10] = Imei[4]; Temp[11] = Imei[5];
159 168
160 /* And now we pack magic bytes from the phone. */ 169 /* And now we pack magic bytes from the phone. */
161 Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1]; 170 Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1];
162 Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3]; 171 Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3];
163 172
164 for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1; 173 for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1;
165 switch (Temp[15] & 0x03) { 174 switch (Temp[15] & 0x03) {
166 case 1: 175 case 1:
167 case 2: j = Temp[13] & 0x07; 176 case 2: j = Temp[13] & 0x07;
168 for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12]; 177 for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12];
169 break; 178 break;
170 default: j = Temp[14] & 0x07; 179 default: j = Temp[14] & 0x07;
171 for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12]; 180 for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12];
172 } 181 }
173 for (i=0; i<=15; i++) CRC ^= Temp[i]; 182 for (i=0; i<=15; i++) CRC ^= Temp[i];
174 for (i=0; i<=15; i++) { 183 for (i=0; i<=15; i++) {
175 switch (Temp[15 - i] & 0x06) { 184 switch (Temp[15 - i] & 0x06) {
176 case 0: j = Temp[i] | CRC; break; 185 case 0: j = Temp[i] | CRC; break;
177 case 2: 186 case 2:
178 case 4: j = Temp[i] ^ CRC; break; 187 case 4: j = Temp[i] ^ CRC; break;
179 case 6: j = Temp[i] & CRC; break; 188 case 6: j = Temp[i] & CRC; break;
180 } 189 }
181 if (j == CRC) j = 0x2c; 190 if (j == CRC) j = 0x2c;
182 if (Temp[i] == 0) j = 0; 191 if (Temp[i] == 0) j = 0;
183 MagicResponse[i] = j; 192 MagicResponse[i] = j;
184 } 193 }
185} 194}
186 195
187static GSM_Error N6110_ReplyGetMagicBytes(GSM_Protocol_Message msg, GSM_StateMachine *s) 196static GSM_Error N6110_ReplyGetMagicBytes(GSM_Protocol_Message msg, GSM_StateMachine *s)
188{ 197{
189 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; 198 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
190 GSM_Phone_Data *Data = &s->Phone.Data; 199 GSM_Phone_Data *Data = &s->Phone.Data;
191 200
192 sprintf(Data->IMEI, "%s", msg.Buffer+9); 201 sprintf(Data->IMEI, "%s", msg.Buffer+9);
193 sprintf(Data->HardwareCache, "%s", msg.Buffer+39); 202 sprintf(Data->HardwareCache, "%s", msg.Buffer+39);
194 sprintf(Data->ProductCodeCache, "%s", msg.Buffer+31); 203 sprintf(Data->ProductCodeCache, "%s", msg.Buffer+31);
195 204
196 smprintf(s, "Message: Mobile phone identification received:\n"); 205 smprintf(s, "Message: Mobile phone identification received:\n");
197 smprintf(s, "IMEI : %s\n", msg.Buffer+9); 206 smprintf(s, "IMEI : %s\n", msg.Buffer+9);
198 smprintf(s, "Model : %s\n", msg.Buffer+25); 207 smprintf(s, "Model : %s\n", msg.Buffer+25);
199 smprintf(s, "Production Code : %s\n", msg.Buffer+31); 208 smprintf(s, "Production Code : %s\n", msg.Buffer+31);
200 smprintf(s, "HW : %s\n", msg.Buffer+39); 209 smprintf(s, "HW : %s\n", msg.Buffer+39);
201 smprintf(s, "Firmware : %s\n", msg.Buffer+44); 210 smprintf(s, "Firmware : %s\n", msg.Buffer+44);
202 211
203 /* These bytes are probably the source of the "Accessory not connected" 212 /* These bytes are probably the source of the "Accessory not connected"
204 * messages on the phone when trying to emulate NCDS... I hope.... 213 * messages on the phone when trying to emulate NCDS... I hope....
205 * UPDATE: of course, now we have the authentication algorithm. 214 * UPDATE: of course, now we have the authentication algorithm.
206 */ 215 */
207 smprintf(s, " Magic bytes : %02x %02x %02x %02x\n", msg.Buffer[50], msg.Buffer[51], msg.Buffer[52], msg.Buffer[53]); 216 smprintf(s, " Magic bytes : %02x %02x %02x %02x\n", msg.Buffer[50], msg.Buffer[51], msg.Buffer[52], msg.Buffer[53]);
208 217
209 Priv->MagicBytes[0]=msg.Buffer[50]; 218 Priv->MagicBytes[0]=msg.Buffer[50];
210 Priv->MagicBytes[1]=msg.Buffer[51]; 219 Priv->MagicBytes[1]=msg.Buffer[51];
211 Priv->MagicBytes[2]=msg.Buffer[52]; 220 Priv->MagicBytes[2]=msg.Buffer[52];
212 Priv->MagicBytes[3]=msg.Buffer[53]; 221 Priv->MagicBytes[3]=msg.Buffer[53];
213 222
214 return ERR_NONE; 223 return ERR_NONE;
215} 224}
216 225
217static GSM_Error N6110_MakeAuthentication(GSM_StateMachine *s) 226static GSM_Error N6110_MakeAuthentication(GSM_StateMachine *s)
218{ 227{
219 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; 228 GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
220 GSM_Error error; 229 GSM_Error error;
221 unsigned char connect4[] = {N6110_FRAME_HEADER, 0x10}; 230 unsigned char connect4[] = {N6110_FRAME_HEADER, 0x10};
222 unsigned char magic_connect[] = { 231 unsigned char magic_connect[] = {
223 N6110_FRAME_HEADER, 0x12, 232 N6110_FRAME_HEADER, 0x12,
224 /* The real magic goes here ... These bytes are filled in 233 /* The real magic goes here ... These bytes are filled in
225 * with the function N6110_GetNokiaAuthentication. */ 234 * with the function N6110_GetNokiaAuthentication. */
226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
228 /* NOKIA&GNOKII Accessory */ 237 /* NOKIA&GNOKII Accessory */
229 'N', 'O', 'K', 'I', 'A', '&', 'N', 'O', 'K', 'I', 'A', 238 'N', 'O', 'K', 'I', 'A', '&', 'N', 'O', 'K', 'I', 'A',
230 'a', 'c', 'c', 'e', 's', 's', 'o', 'r', 'y', 239 'a', 'c', 'c', 'e', 's', 's', 'o', 'r', 'y',
231 0x00, 0x00, 0x00, 0x00}; 240 0x00, 0x00, 0x00, 0x00};
232 241
233 smprintf(s, "Getting magic bytes for authentication\n"); 242 smprintf(s, "Getting magic bytes for authentication\n");
234 error=GSM_WaitFor (s, connect4, 4, 0x64, 4, ID_MakeAuthentication); 243 error=GSM_WaitFor (s, connect4, 4, 0x64, 4, ID_MakeAuthentication);
235 if (error!=ERR_NONE) return error; 244 if (error!=ERR_NONE) return error;
236 245
237 N6110_GetNokiaAuthentication(s->Phone.Data.IMEI, Priv->MagicBytes, magic_connect+4); 246 N6110_GetNokiaAuthentication(s->Phone.Data.IMEI, Priv->MagicBytes, magic_connect+4);
238 smprintf(s, "Sending authentication bytes\n"); 247 smprintf(s, "Sending authentication bytes\n");
239 return s->Protocol.Functions->WriteMessage(s, magic_connect, 45, 0x64); 248 return s->Protocol.Functions->WriteMessage(s, magic_connect, 45, 0x64);
240} 249}
241 250
242#endif 251#endif
243 252
244static GSM_Error N6110_ShowStartInfo(GSM_StateMachine *s, bool enable) 253static GSM_Error N6110_ShowStartInfo(GSM_StateMachine *s, bool enable)
245{ 254{
246#ifdef ENABLE_LGPL 255#ifdef ENABLE_LGPL
247 return ERR_NONE; 256 return ERR_NONE;
248#else 257#else
249 GSM_Error error=ERR_NONE; 258 GSM_Error error=ERR_NONE;
250 259
251 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_MAGICBYTES)) { 260 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_MAGICBYTES)) {
252 if (s->ConnectionType == GCT_FBUS2 || 261 if (s->ConnectionType == GCT_FBUS2 ||
253 s->ConnectionType == GCT_FBUS2IRDA) { 262 s->ConnectionType == GCT_FBUS2IRDA) {
254 error=N6110_MakeAuthentication(s); 263 error=N6110_MakeAuthentication(s);
255 } 264 }
256 } 265 }
257 return error; 266 return error;
258#endif 267#endif
259} 268}
260 269
261static GSM_Error N6110_Initialise (GSM_StateMachine *s) 270static GSM_Error N6110_Initialise (GSM_StateMachine *s)
262{ 271{
263#ifdef DEBUG 272#ifdef DEBUG
264 DCT3_SetIncomingCB(s,true); 273 DCT3_SetIncomingCB(s,true);
265#endif 274#endif
266 N6110_GetPhoneLanguage(s); 275 N6110_GetPhoneLanguage(s);
267 return ERR_NONE; 276 return ERR_NONE;
268} 277}
269 278
270static GSM_Error N6110_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 279static GSM_Error N6110_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
271{ 280{
272 return DCT3_GetDateTime(s, date_time, 0x11); 281 return DCT3_GetDateTime(s, date_time, 0x11);
273} 282}
274 283
275static GSM_Error N6110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 284static GSM_Error N6110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
276{ 285{
277 return DCT3_GetAlarm(s, alarm, 0x11); 286 return DCT3_GetAlarm(s, alarm, 0x11);
278} 287}
279 288
280static GSM_Error N6110_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 289static GSM_Error N6110_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
281{ 290{
282 return DCT3_SetDateTime(s, date_time, 0x11); 291 return DCT3_SetDateTime(s, date_time, 0x11);
283} 292}
284 293
285static GSM_Error N6110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 294static GSM_Error N6110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
286{ 295{
287 return DCT3_SetAlarm(s, alarm, 0x11); 296 return DCT3_SetAlarm(s, alarm, 0x11);
288} 297}
289 298
290static GSM_Error N6110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 299static GSM_Error N6110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
291{ 300{
292 int count; 301 int count;
293 GSM_Phone_Data *Data = &s->Phone.Data; 302 GSM_Phone_Data *Data = &s->Phone.Data;
294 303
295 smprintf(s, "Phonebook entry received\n"); 304 smprintf(s, "Phonebook entry received\n");
296 switch (msg.Buffer[3]) { 305 switch (msg.Buffer[3]) {
297 case 0x02: 306 case 0x02:
298 Data->Memory->EntriesNum = 0; 307 Data->Memory->EntriesNum = 0;
299 count=5; 308 count=5;
300 /* If name is not empty */ 309 /* If name is not empty */
301 if (msg.Buffer[count]!=0x00) { 310 if (msg.Buffer[count]!=0x00) {
302 if (msg.Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) { 311 if (msg.Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) {
303 smprintf(s, "Too long text\n"); 312 smprintf(s, "Too long text\n");
304 return ERR_UNKNOWNRESPONSE; 313 return ERR_UNKNOWNRESPONSE;
305 } 314 }
306 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Text_Name; 315 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Text_Name;
307 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOPBKUNICODE)) { 316 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOPBKUNICODE)) {
308 if (Data->Memory->MemoryType==MEM_DC || 317 if (Data->Memory->MemoryType==MEM_DC ||
309 Data->Memory->MemoryType==MEM_RC || 318 Data->Memory->MemoryType==MEM_RC ||
310 Data->Memory->MemoryType==MEM_MC || 319 Data->Memory->MemoryType==MEM_MC ||
311 Data->Memory->MemoryType==MEM_ME) { 320 Data->Memory->MemoryType==MEM_ME) {
312 N6110_EncodeUnicode(s,Data->Memory->Entries[Data->Memory->EntriesNum].Text, 321 N6110_EncodeUnicode(s,Data->Memory->Entries[Data->Memory->EntriesNum].Text,
313 msg.Buffer+count+1,msg.Buffer[count]); 322 msg.Buffer+count+1,msg.Buffer[count]);
314 } else { 323 } else {
315 EncodeUnicode(Data->Memory->Entries[Data->Memory->EntriesNum].Text, 324 EncodeUnicode(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
316 msg.Buffer+count+1,msg.Buffer[count]); 325 msg.Buffer+count+1,msg.Buffer[count]);
317 } 326 }
318 } else { 327 } else {
319 memcpy(Data->Memory->Entries[Data->Memory->EntriesNum].Text, 328 memcpy(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
320 msg.Buffer+count+1,msg.Buffer[count]); 329 msg.Buffer+count+1,msg.Buffer[count]);
321 Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg.Buffer[count]]=0x00; 330 Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg.Buffer[count]]=0x00;
322 Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg.Buffer[count]+1]=0x00; 331 Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg.Buffer[count]+1]=0x00;
323 } 332 }
324 smprintf(s, "Name \"%s\"\n", 333 smprintf(s, "Name \"%s\"\n",
325 DecodeUnicodeString(Data->Memory->Entries[Data->Memory->EntriesNum].Text)); 334 DecodeUnicodeString(Data->Memory->Entries[Data->Memory->EntriesNum].Text));
326 Data->Memory->EntriesNum++; 335 Data->Memory->EntriesNum++;
327 } 336 }
328 count=count+msg.Buffer[count]+1; 337 count=count+msg.Buffer[count]+1;
329 338
330 /* If number is empty */ 339 /* If number is empty */
331 if (msg.Buffer[count]==0x00) return ERR_EMPTY; 340 if (msg.Buffer[count]==0x00) return ERR_EMPTY;
332 341
333 if (msg.Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) { 342 if (msg.Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) {
334 smprintf(s, "Too long text\n"); 343 smprintf(s, "Too long text\n");
335 return ERR_UNKNOWNRESPONSE; 344 return ERR_UNKNOWNRESPONSE;
336 } 345 }
337 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType = PBK_Number_General; 346 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType = PBK_Number_General;
338 Data->Memory->Entries[Data->Memory->EntriesNum].VoiceTag = 0; 347 Data->Memory->Entries[Data->Memory->EntriesNum].VoiceTag = 0;
339 Data->Memory->Entries[Data->Memory->EntriesNum].SMSList[0] = 0; 348 Data->Memory->Entries[Data->Memory->EntriesNum].SMSList[0] = 0;
340 EncodeUnicode(Data->Memory->Entries[Data->Memory->EntriesNum].Text, 349 EncodeUnicode(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
341 msg.Buffer+count+1,msg.Buffer[count]); 350 msg.Buffer+count+1,msg.Buffer[count]);
342 smprintf(s, "Number \"%s\"\n", 351 smprintf(s, "Number \"%s\"\n",
343 DecodeUnicodeString(Data->Memory->Entries[Data->Memory->EntriesNum].Text)); 352 DecodeUnicodeString(Data->Memory->Entries[Data->Memory->EntriesNum].Text));
344 Data->Memory->EntriesNum++; 353 Data->Memory->EntriesNum++;
345 count=count+msg.Buffer[count]+1; 354 count=count+msg.Buffer[count]+1;
346 355
347 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALLER)) { 356 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALLER)) {
348 if (msg.Buffer[count]<5) { 357 if (msg.Buffer[count]<5) {
349 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Caller_Group; 358 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Caller_Group;
350 smprintf(s, "Caller group \"%i\"\n",msg.Buffer[count]); 359 smprintf(s, "Caller group \"%i\"\n",msg.Buffer[count]);
351 Data->Memory->Entries[Data->Memory->EntriesNum].Number=msg.Buffer[count]+1; 360 Data->Memory->Entries[Data->Memory->EntriesNum].Number=msg.Buffer[count]+1;
352 Data->Memory->EntriesNum++; 361 Data->Memory->EntriesNum++;
353 } 362 }
354 } 363 }
355 count++; 364 count++;
356 365
357 if (Data->Memory->MemoryType==MEM_DC || 366 if (Data->Memory->MemoryType==MEM_DC ||
358 Data->Memory->MemoryType==MEM_RC || 367 Data->Memory->MemoryType==MEM_RC ||
359 Data->Memory->MemoryType==MEM_MC) { 368 Data->Memory->MemoryType==MEM_MC) {
360 NOKIA_DecodeDateTime(s, msg.Buffer+count+1,&Data->Memory->Entries[Data->Memory->EntriesNum].Date); 369 NOKIA_DecodeDateTime(s, msg.Buffer+count+1,&Data->Memory->Entries[Data->Memory->EntriesNum].Date);
361 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Date; 370 Data->Memory->Entries[Data->Memory->EntriesNum].EntryType=PBK_Date;
362 371
363 /* These values are set, when date and time unavailable in phone. 372 /* These values are set, when date and time unavailable in phone.
364 * Values from 3310 - in other can be different */ 373 * Values from 3310 - in other can be different */
365 if (Data->Memory->Entries[2].Date.Day !=20 || 374 if (Data->Memory->Entries[2].Date.Day !=20 ||
366 Data->Memory->Entries[2].Date.Month !=1 || 375 Data->Memory->Entries[2].Date.Month !=1 ||
367 Data->Memory->Entries[2].Date.Year !=2118|| 376 Data->Memory->Entries[2].Date.Year !=2118||
368 Data->Memory->Entries[2].Date.Hour !=3 || 377 Data->Memory->Entries[2].Date.Hour !=3 ||
369 Data->Memory->Entries[2].Date.Minute!=14 || 378 Data->Memory->Entries[2].Date.Minute!=14 ||
370 Data->Memory->Entries[2].Date.Second!=7) 379 Data->Memory->Entries[2].Date.Second!=7)
371 Data->Memory->EntriesNum++; 380 Data->Memory->EntriesNum++;
372 } 381 }
373 382
374 return ERR_NONE; 383 return ERR_NONE;
375 default: 384 default:
376 switch (msg.Buffer[4]) { 385 switch (msg.Buffer[4]) {
377 case 0x6f: 386 case 0x6f:
378 smprintf(s, "Phone is OFF\n"); 387 smprintf(s, "Phone is OFF\n");
379 return ERR_PHONEOFF; 388 return ERR_PHONEOFF;
380 case 0x74: 389 case 0x74:
381 /* TODO: check if not too high */ 390 /* TODO: check if not too high */
382 smprintf(s, "ERROR: Empty ????\n"); 391 smprintf(s, "ERROR: Empty ????\n");
383 Data->Memory->EntriesNum = 0; 392 Data->Memory->EntriesNum = 0;
384 return ERR_EMPTY; 393 return ERR_EMPTY;
385 case 0x7d: 394 case 0x7d:
386 smprintf(s, "ERROR: Invalid memory type\n"); 395 smprintf(s, "ERROR: Invalid memory type\n");
387 return ERR_NOTSUPPORTED; 396 return ERR_NOTSUPPORTED;
388 case 0x8d: 397 case 0x8d:
389 smprintf(s, "ERROR: no PIN\n"); 398 smprintf(s, "ERROR: no PIN\n");
390 return ERR_SECURITYERROR; 399 return ERR_SECURITYERROR;
@@ -2487,405 +2496,411 @@ static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShow
2487 0x0c}; /* Length of number */ 2496 0x0c}; /* Length of number */
2488 2497
2489 if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber); 2498 if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber);
2490 2499
2491 req[pos++] = strlen(number); 2500 req[pos++] = strlen(number);
2492 memcpy(req+pos,number,strlen(number)); 2501 memcpy(req+pos,number,strlen(number));
2493 pos += strlen(number); 2502 pos += strlen(number);
2494 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ 2503 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
2495 req[pos++] = 0x01; 2504 req[pos++] = 0x01;
2496 req[pos++] = 0x01; 2505 req[pos++] = 0x01;
2497 req[pos++] = 0x05; 2506 req[pos++] = 0x05;
2498 req[pos++] = 0x81; 2507 req[pos++] = 0x81;
2499 switch (ShowNumber) { 2508 switch (ShowNumber) {
2500 case GSM_CALL_HideNumber: 2509 case GSM_CALL_HideNumber:
2501 req[pos++] = 0x02; 2510 req[pos++] = 0x02;
2502 break; 2511 break;
2503 case GSM_CALL_ShowNumber: 2512 case GSM_CALL_ShowNumber:
2504 req[pos++] = 0x03; 2513 req[pos++] = 0x03;
2505 break; 2514 break;
2506 case GSM_CALL_DefaultNumberPresence: 2515 case GSM_CALL_DefaultNumberPresence:
2507 req[pos++] = 0x01; 2516 req[pos++] = 0x01;
2508 break; 2517 break;
2509 } 2518 }
2510 req[pos++] = 0x00; 2519 req[pos++] = 0x00;
2511 req[pos++] = 0x00; 2520 req[pos++] = 0x00;
2512 2521
2513 smprintf(s, "Making voice call\n"); 2522 smprintf(s, "Making voice call\n");
2514 return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice); 2523 return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
2515} 2524}
2516 2525
2517GSM_Error N6110_UnholdCall(GSM_StateMachine *s, int ID) 2526GSM_Error N6110_UnholdCall(GSM_StateMachine *s, int ID)
2518{ 2527{
2519 unsigned char req[] = {N6110_FRAME_HEADER, 0x24, 0x00, 0x02}; 2528 unsigned char req[] = {N6110_FRAME_HEADER, 0x24, 0x00, 0x02};
2520 2529
2521 req[4] = (unsigned char)ID; 2530 req[4] = (unsigned char)ID;
2522 s->Phone.Data.CallID = ID; 2531 s->Phone.Data.CallID = ID;
2523 2532
2524 smprintf(s, "Unholding call\n"); 2533 smprintf(s, "Unholding call\n");
2525 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_UnholdCall); 2534 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_UnholdCall);
2526} 2535}
2527 2536
2528GSM_Error N6110_HoldCall(GSM_StateMachine *s, int ID) 2537GSM_Error N6110_HoldCall(GSM_StateMachine *s, int ID)
2529{ 2538{
2530 unsigned char req[] = {N6110_FRAME_HEADER, 0x22, 0x00, 0x00}; 2539 unsigned char req[] = {N6110_FRAME_HEADER, 0x22, 0x00, 0x00};
2531 2540
2532 req[4] = (unsigned char)ID; 2541 req[4] = (unsigned char)ID;
2533 s->Phone.Data.CallID = ID; 2542 s->Phone.Data.CallID = ID;
2534 2543
2535 smprintf(s, "Unholding call\n"); 2544 smprintf(s, "Unholding call\n");
2536 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_HoldCall); 2545 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_HoldCall);
2537} 2546}
2538 2547
2539/* Joining selected call to current (and making conference) */ 2548/* Joining selected call to current (and making conference) */
2540GSM_Error N6110_ConferenceCall(GSM_StateMachine *s, int ID) 2549GSM_Error N6110_ConferenceCall(GSM_StateMachine *s, int ID)
2541{ 2550{
2542 unsigned char req[] = {N6110_FRAME_HEADER, 0x28, 0x00, 0x01}; 2551 unsigned char req[] = {N6110_FRAME_HEADER, 0x28, 0x00, 0x01};
2543 2552
2544 req[4] = (unsigned char)ID; 2553 req[4] = (unsigned char)ID;
2545 s->Phone.Data.CallID = ID; 2554 s->Phone.Data.CallID = ID;
2546 2555
2547 smprintf(s, "Conference call\n"); 2556 smprintf(s, "Conference call\n");
2548 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_ConferenceCall); 2557 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_ConferenceCall);
2549} 2558}
2550 2559
2551/* Removing selected call from conference and making private call with it 2560/* Removing selected call from conference and making private call with it
2552 * (conference call is on hold) */ 2561 * (conference call is on hold) */
2553GSM_Error N6110_SplitCall(GSM_StateMachine *s, int ID) 2562GSM_Error N6110_SplitCall(GSM_StateMachine *s, int ID)
2554{ 2563{
2555 unsigned char req[] = {N6110_FRAME_HEADER, 0x2A, 0x00, 0x01}; 2564 unsigned char req[] = {N6110_FRAME_HEADER, 0x2A, 0x00, 0x01};
2556 2565
2557 req[4] = (unsigned char)ID; 2566 req[4] = (unsigned char)ID;
2558 s->Phone.Data.CallID = ID; 2567 s->Phone.Data.CallID = ID;
2559 2568
2560 smprintf(s, "Split call\n"); 2569 smprintf(s, "Split call\n");
2561 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_SplitCall); 2570 return GSM_WaitFor (s, req, 6, 0x01, 4, ID_SplitCall);
2562} 2571}
2563 2572
2564/* This probably need more investigation */ 2573/* This probably need more investigation */
2565GSM_Error N6110_SwitchCall(GSM_StateMachine *s, int ID, bool next) 2574GSM_Error N6110_SwitchCall(GSM_StateMachine *s, int ID, bool next)
2566{ 2575{
2567// unsigned char req[] = {N6110_FRAME_HEADER, 0x20}; calls info 2576// unsigned char req[] = {N6110_FRAME_HEADER, 0x20}; calls info
2568 unsigned char req[] = {N6110_FRAME_HEADER, 0x26, 0x00}; 2577 unsigned char req[] = {N6110_FRAME_HEADER, 0x26, 0x00};
2569 2578
2570 s->Phone.Data.CallID = ID; 2579 s->Phone.Data.CallID = ID;
2571 2580
2572 if (next) { 2581 if (next) {
2573 smprintf(s, "Switch call\n"); 2582 smprintf(s, "Switch call\n");
2574 return GSM_WaitFor (s, req, 4, 0x01, 4, ID_SwitchCall); 2583 return GSM_WaitFor (s, req, 4, 0x01, 4, ID_SwitchCall);
2575 } else { 2584 } else {
2576 req[4] = (unsigned char)ID; 2585 req[4] = (unsigned char)ID;
2577 2586
2578 smprintf(s, "Switch call\n"); 2587 smprintf(s, "Switch call\n");
2579 return GSM_WaitFor (s, req, 5, 0x01, 4, ID_SwitchCall); 2588 return GSM_WaitFor (s, req, 5, 0x01, 4, ID_SwitchCall);
2580 } 2589 }
2581} 2590}
2582 2591
2583/* This probably need more investigation */ 2592/* This probably need more investigation */
2584GSM_Error N6110_TransferCall(GSM_StateMachine *s, int ID, bool next) 2593GSM_Error N6110_TransferCall(GSM_StateMachine *s, int ID, bool next)
2585{ 2594{
2586 unsigned char req[] = {N6110_FRAME_HEADER, 0x2C, 0x00}; 2595 unsigned char req[] = {N6110_FRAME_HEADER, 0x2C, 0x00};
2587 2596
2588 s->Phone.Data.CallID = ID; 2597 s->Phone.Data.CallID = ID;
2589 2598
2590 if (next) { 2599 if (next) {
2591 smprintf(s, "Transfer call\n"); 2600 smprintf(s, "Transfer call\n");
2592 return GSM_WaitFor (s, req, 4, 0x01, 4, ID_TransferCall); 2601 return GSM_WaitFor (s, req, 4, 0x01, 4, ID_TransferCall);
2593 } else { 2602 } else {
2594 req[4] = (unsigned char)ID; 2603 req[4] = (unsigned char)ID;
2595 2604
2596 smprintf(s, "Transfer call\n"); 2605 smprintf(s, "Transfer call\n");
2597 return GSM_WaitFor (s, req, 5, 0x01, 4, ID_TransferCall); 2606 return GSM_WaitFor (s, req, 5, 0x01, 4, ID_TransferCall);
2598 } 2607 }
2599} 2608}
2600 2609
2601static GSM_Reply_Function N6110ReplyFunctions[] = { 2610static GSM_Reply_Function N6110ReplyFunctions[] = {
2602 {N6110_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame }, 2611 {N6110_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
2603 {N6110_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame }, 2612 {N6110_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
2604 {N6110_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame }, 2613 {N6110_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
2605 {N6110_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame }, 2614 {N6110_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
2606 {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall }, 2615 {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
2607 {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame }, 2616 {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
2608 {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall }, 2617 {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
2609 {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame }, 2618 {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
2610 {N6110_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame }, 2619 {N6110_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
2611 {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_HoldCall }, 2620 {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_HoldCall },
2612 {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame }, 2621 {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
2613 {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_UnholdCall }, 2622 {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_UnholdCall },
2614 {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame }, 2623 {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
2615 {N6110_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame }, 2624 {N6110_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
2616 {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_ConferenceCall }, 2625 {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_ConferenceCall },
2617 {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_IncomingFrame }, 2626 {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_IncomingFrame },
2618 {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_SplitCall }, 2627 {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_SplitCall },
2619 {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_IncomingFrame }, 2628 {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_IncomingFrame },
2620 {N6110_ReplySendDTMF, "\x01",0x03,0x40,ID_SendDTMF }, 2629 {N6110_ReplySendDTMF, "\x01",0x03,0x40,ID_SendDTMF },
2621 {NoneReply, "\x01",0x03,0x40,ID_DialVoice }, 2630 {NoneReply, "\x01",0x03,0x40,ID_DialVoice },
2622 {NoneReply, "\x01",0x03,0x40,ID_IncomingFrame }, 2631 {NoneReply, "\x01",0x03,0x40,ID_IncomingFrame },
2623 {NoneReply, "\x01",0x03,0x43,ID_AnswerCall }, 2632 {NoneReply, "\x01",0x03,0x43,ID_AnswerCall },
2624 {N6110_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF }, 2633 {N6110_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
2625 2634
2626 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame }, 2635 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
2627 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame }, 2636 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
2628 {N6110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame }, 2637 {N6110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
2629#ifdef GSM_ENABLE_CELLBROADCAST 2638#ifdef GSM_ENABLE_CELLBROADCAST
2630 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB }, 2639 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
2631 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB }, 2640 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
2632 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame }, 2641 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
2633#endif 2642#endif
2634 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC }, 2643 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
2635 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC }, 2644 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
2636 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC }, 2645 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
2637 2646
2638 {N6110_ReplyGetMemory, "\x03",0x03,0x02,ID_GetMemory }, 2647 {N6110_ReplyGetMemory, "\x03",0x03,0x02,ID_GetMemory },
2639 {N6110_ReplyGetMemory, "\x03",0x03,0x03,ID_GetMemory }, 2648 {N6110_ReplyGetMemory, "\x03",0x03,0x03,ID_GetMemory },
2640 {N6110_ReplySetMemory, "\x03",0x03,0x05,ID_SetMemory }, 2649 {N6110_ReplySetMemory, "\x03",0x03,0x05,ID_SetMemory },
2641 {N6110_ReplySetMemory, "\x03",0x03,0x06,ID_SetMemory }, 2650 {N6110_ReplySetMemory, "\x03",0x03,0x06,ID_SetMemory },
2642 {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x08,ID_GetMemoryStatus }, 2651 {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x08,ID_GetMemoryStatus },
2643 {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x09,ID_GetMemoryStatus }, 2652 {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x09,ID_GetMemoryStatus },
2644 {N6110_ReplyGetCallerLogo, "\x03",0x03,0x11,ID_GetBitmap }, 2653 {N6110_ReplyGetCallerLogo, "\x03",0x03,0x11,ID_GetBitmap },
2645 {N6110_ReplyGetCallerLogo, "\x03",0x03,0x12,ID_GetBitmap }, 2654 {N6110_ReplyGetCallerLogo, "\x03",0x03,0x12,ID_GetBitmap },
2646 {N6110_ReplySetCallerLogo, "\x03",0x03,0x14,ID_SetBitmap }, 2655 {N6110_ReplySetCallerLogo, "\x03",0x03,0x14,ID_SetBitmap },
2647 {N6110_ReplySetCallerLogo, "\x03",0x03,0x15,ID_SetBitmap }, 2656 {N6110_ReplySetCallerLogo, "\x03",0x03,0x15,ID_SetBitmap },
2648 {N6110_ReplyGetSpeedDial, "\x03",0x03,0x17,ID_GetSpeedDial }, 2657 {N6110_ReplyGetSpeedDial, "\x03",0x03,0x17,ID_GetSpeedDial },
2649 {N6110_ReplyGetSpeedDial, "\x03",0x03,0x18,ID_GetSpeedDial }, 2658 {N6110_ReplyGetSpeedDial, "\x03",0x03,0x18,ID_GetSpeedDial },
2650 /* 0x1A, 0x1B - reply set speed dial */ 2659 /* 0x1A, 0x1B - reply set speed dial */
2651 2660
2652 {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetSignalQuality }, 2661 {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetSignalQuality },
2653 {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetBatteryCharge }, 2662 {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetBatteryCharge },
2654 2663
2655 {N6110_ReplySetProfileFeature, "\x05",0x03,0x11,ID_SetProfile }, 2664 {N6110_ReplySetProfileFeature, "\x05",0x03,0x11,ID_SetProfile },
2656 {N6110_ReplySetProfileFeature, "\x05",0x03,0x12,ID_SetProfile }, 2665 {N6110_ReplySetProfileFeature, "\x05",0x03,0x12,ID_SetProfile },
2657 {N6110_ReplyGetProfileFeature, "\x05",0x03,0x14,ID_GetProfile }, 2666 {N6110_ReplyGetProfileFeature, "\x05",0x03,0x14,ID_GetProfile },
2658 {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x14,ID_GetLanguage }, 2667 {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x14,ID_GetLanguage },
2659 {N6110_ReplyGetProfileFeature, "\x05",0x03,0x15,ID_GetProfile }, 2668 {N6110_ReplyGetProfileFeature, "\x05",0x03,0x15,ID_GetProfile },
2660 {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x15,ID_GetLanguage }, 2669 {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x15,ID_GetLanguage },
2661 {N6110_ReplyGetStartup, "\x05",0x03,0x17,ID_GetBitmap }, 2670 {N6110_ReplyGetStartup, "\x05",0x03,0x17,ID_GetBitmap },
2662 {N6110_ReplySetStartup, "\x05",0x03,0x19,ID_SetBitmap }, 2671 {N6110_ReplySetStartup, "\x05",0x03,0x19,ID_SetBitmap },
2663 {N6110_ReplyGetProfileFeature, "\x05",0x03,0x1b,ID_GetProfile }, 2672 {N6110_ReplyGetProfileFeature, "\x05",0x03,0x1b,ID_GetProfile },
2664 {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap }, 2673 {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap },
2665 {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap }, 2674 {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap },
2666 {N6110_ReplyGetOpLogo, "\x05",0x03,0x34,ID_GetBitmap }, 2675 {N6110_ReplyGetOpLogo, "\x05",0x03,0x34,ID_GetBitmap },
2667 {N6110_ReplySetRingtone, "\x05",0x03,0x37,ID_SetRingtone }, 2676 {N6110_ReplySetRingtone, "\x05",0x03,0x37,ID_SetRingtone },
2668 {N6110_ReplySetRingtone, "\x05",0x03,0x38,ID_SetRingtone }, 2677 {N6110_ReplySetRingtone, "\x05",0x03,0x38,ID_SetRingtone },
2669 2678
2670 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert }, 2679 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert },
2671 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x03,ID_Divert }, 2680 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x03,ID_Divert },
2672 {N6110_ReplyUSSDInfo, "\x06",0x03,0x05,ID_IncomingFrame }, 2681 {N6110_ReplyUSSDInfo, "\x06",0x03,0x05,ID_IncomingFrame },
2673 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },//incoming call divert info 2682 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },//incoming call divert info
2674 2683
2675 {N6110_ReplyGetSecurityStatus, "\x08",0x03,0x08,ID_GetSecurityStatus }, 2684 {N6110_ReplyGetSecurityStatus, "\x08",0x03,0x08,ID_GetSecurityStatus },
2676 {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0b,ID_EnterSecurityCode }, 2685 {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0b,ID_EnterSecurityCode },
2677 {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0c,ID_EnterSecurityCode }, 2686 {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0c,ID_EnterSecurityCode },
2678 2687
2679 {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame }, 2688 {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
2680 {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame }, 2689 {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
2681 2690
2682 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo }, 2691 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
2683 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame }, 2692 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
2684 2693
2685 {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_GetDisplayStatus }, 2694 {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_GetDisplayStatus },
2686 {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_IncomingFrame }, 2695 {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_IncomingFrame },
2687 2696
2688 {DCT3_ReplySetDateTime, "\x11",0x03,0x61,ID_SetDateTime }, 2697 {DCT3_ReplySetDateTime, "\x11",0x03,0x61,ID_SetDateTime },
2689 {DCT3_ReplyGetDateTime, "\x11",0x03,0x63,ID_GetDateTime }, 2698 {DCT3_ReplyGetDateTime, "\x11",0x03,0x63,ID_GetDateTime },
2690 {DCT3_ReplySetAlarm, "\x11",0x03,0x6C,ID_SetAlarm }, 2699 {DCT3_ReplySetAlarm, "\x11",0x03,0x6C,ID_SetAlarm },
2691 {DCT3_ReplyGetAlarm, "\x11",0x03,0x6E,ID_GetAlarm }, 2700 {DCT3_ReplyGetAlarm, "\x11",0x03,0x6E,ID_GetAlarm },
2692 2701
2693 {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_SetCalendarNote }, 2702 {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_SetCalendarNote },
2694 {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_IncomingFrame }, 2703 {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_IncomingFrame },
2695 {N6110_ReplyGetNextCalendar, "\x13",0x03,0x67,ID_GetCalendarNote }, 2704 {N6110_ReplyGetNextCalendar, "\x13",0x03,0x67,ID_GetCalendarNote },
2696 {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_DeleteCalendarNote }, 2705 {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_DeleteCalendarNote },
2697 {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_IncomingFrame }, 2706 {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_IncomingFrame },
2698 2707
2699 {N6110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage }, 2708 {N6110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
2700 {N6110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage }, 2709 {N6110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
2701 {N6110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage }, 2710 {N6110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
2702 {N6110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage }, 2711 {N6110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
2703 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage }, 2712 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
2704 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage }, 2713 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
2705 {N6110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus }, 2714 {N6110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
2706 {N6110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus }, 2715 {N6110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
2707 2716
2708 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc }, 2717 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc },
2709 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc }, 2718 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
2710 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc }, 2719 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc },
2711 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc }, 2720 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
2712 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark }, 2721 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
2713 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark }, 2722 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
2714 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark }, 2723 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
2715 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark }, 2724 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
2716 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark }, 2725 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
2717 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark }, 2726 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
2718 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet }, 2727 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet },
2719 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet }, 2728 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet },
2720 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet }, 2729 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet },
2721 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet }, 2730 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet },
2722 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet }, 2731 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet },
2723 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet }, 2732 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet },
2724 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet }, 2733 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet },
2725 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet }, 2734 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet },
2726 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet }, 2735 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet },
2727 2736
2728 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity }, 2737 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
2729 {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings }, 2738 {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings },
2730 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI }, 2739 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
2731 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice }, 2740 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
2732 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall }, 2741 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
2733 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall }, 2742 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
2734 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor }, 2743 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
2735 {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone }, 2744 {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
2736 {N6110_ReplyGetRingtone, "\x40",0x02,0x9E,ID_GetRingtone }, 2745 {N6110_ReplyGetRingtone, "\x40",0x02,0x9E,ID_GetRingtone },
2737 {N6110_ReplySetBinRingtone, "\x40",0x02,0xA0,ID_SetRingtone }, 2746 {N6110_ReplySetBinRingtone, "\x40",0x02,0xA0,ID_SetRingtone },
2738 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware }, 2747 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
2739 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM }, 2748 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
2740 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode }, 2749 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
2741 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth}, 2750 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth},
2742 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI }, 2751 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
2743 2752
2744 {N6110_ReplyGetSetPicture, "\x47",0x03,0x02,ID_GetBitmap }, 2753 {N6110_ReplyGetSetPicture, "\x47",0x03,0x02,ID_GetBitmap },
2745 {N6110_ReplyGetSetPicture, "\x47",0x03,0x04,ID_SetBitmap }, 2754 {N6110_ReplyGetSetPicture, "\x47",0x03,0x04,ID_SetBitmap },
2746 {N6110_ReplyGetSetPicture, "\x47",0x03,0x05,ID_SetBitmap }, 2755 {N6110_ReplyGetSetPicture, "\x47",0x03,0x05,ID_SetBitmap },
2747 {N6110_ReplyGetSetPicture, "\x47",0x03,0x06,ID_GetBitmap }, 2756 {N6110_ReplyGetSetPicture, "\x47",0x03,0x06,ID_GetBitmap },
2748 2757
2749#ifndef ENABLE_LGPL 2758#ifndef ENABLE_LGPL
2750 {N6110_ReplyGetMagicBytes, "\x64",0x00,0x00,ID_MakeAuthentication }, 2759 {N6110_ReplyGetMagicBytes, "\x64",0x00,0x00,ID_MakeAuthentication },
2751#endif 2760#endif
2752 2761
2753 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, 2762 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
2754 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, 2763 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
2755 {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey }, 2764 {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
2756 {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey }, 2765 {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
2757 2766
2758 {NULL, "\x00",0x00,0x00,ID_None } 2767 {NULL, "\x00",0x00,0x00,ID_None }
2759}; 2768};
2760 2769
2761GSM_Phone_Functions N6110Phone = { 2770GSM_Phone_Functions N6110Phone = {
2762 "2100|3210|3310|3330|3390|3410|3610|5110|5110i|5130|5190|5210|5510|6110|6130|6150|6190|8210|8250|8290|8850|8855|8890", 2771 "2100|3210|3310|3330|3390|3410|3610|5110|5110i|5130|5190|5210|5510|6110|6130|6150|6190|8210|8250|8290|8850|8855|8890",
2763 N6110ReplyFunctions, 2772 N6110ReplyFunctions,
2764 N6110_Initialise, 2773 N6110_Initialise,
2765 PHONE_Terminate, 2774 PHONE_Terminate,
2766 GSM_DispatchMessage, 2775 GSM_DispatchMessage,
2767 N6110_ShowStartInfo, 2776 N6110_ShowStartInfo,
2768 NOKIA_GetManufacturer, 2777 NOKIA_GetManufacturer,
2769 DCT3DCT4_GetModel, 2778 DCT3DCT4_GetModel,
2770 DCT3DCT4_GetFirmware, 2779 DCT3DCT4_GetFirmware,
2771 DCT3_GetIMEI, 2780 DCT3_GetIMEI,
2772 DCT3_GetOriginalIMEI, 2781 DCT3_GetOriginalIMEI,
2773 DCT3_GetManufactureMonth, 2782 DCT3_GetManufactureMonth,
2774 DCT3_GetProductCode, 2783 DCT3_GetProductCode,
2775 DCT3_GetHardware, 2784 DCT3_GetHardware,
2776 DCT3_GetPPM, 2785 DCT3_GetPPM,
2777 NOTSUPPORTED, /* GetSIMIMSI */ 2786 NOTSUPPORTED, /* GetSIMIMSI */
2778 N6110_GetDateTime, 2787 N6110_GetDateTime,
2779 N6110_SetDateTime, 2788 N6110_SetDateTime,
2780 N6110_GetAlarm, 2789 N6110_GetAlarm,
2781 N6110_SetAlarm, 2790 N6110_SetAlarm,
2782 NOTSUPPORTED, /* GetLocale */ 2791 NOTSUPPORTED, /* GetLocale */
2783 NOTSUPPORTED, /* SetLocale */ 2792 NOTSUPPORTED, /* SetLocale */
2784 DCT3_PressKey, 2793 DCT3_PressKey,
2785 DCT3_Reset, 2794 DCT3_Reset,
2786 N61_71_ResetPhoneSettings, 2795 N61_71_ResetPhoneSettings,
2787 N6110_EnterSecurityCode, 2796 N6110_EnterSecurityCode,
2788 N6110_GetSecurityStatus, 2797 N6110_GetSecurityStatus,
2789 N6110_GetDisplayStatus, 2798 N6110_GetDisplayStatus,
2790 NOTIMPLEMENTED, /* SetAutoNetworkLogin */ 2799 NOTIMPLEMENTED, /* SetAutoNetworkLogin */
2791 N6110_GetBatteryCharge, 2800 N6110_GetBatteryCharge,
2792 N6110_GetSignalQuality, 2801 N6110_GetSignalQuality,
2793 DCT3_GetNetworkInfo, 2802 DCT3_GetNetworkInfo,
2794 NOTSUPPORTED, /* GetCategory */ 2803 NOTSUPPORTED, /* GetCategory */
2795 NOTSUPPORTED, /* AddCategory */ 2804 NOTSUPPORTED, /* AddCategory */
2796 NOTSUPPORTED, /* GetCategoryStatus */ 2805 NOTSUPPORTED, /* GetCategoryStatus */
2797 N6110_GetMemoryStatus, 2806 N6110_GetMemoryStatus,
2798 N6110_GetMemory, 2807 N6110_GetMemory,
2799 NOTIMPLEMENTED, /* GetNextMemory */ 2808 NOTIMPLEMENTED, /* GetNextMemory */
2800 N6110_SetMemory, 2809 N6110_SetMemory,
2801 NOTIMPLEMENTED, /* AddMemory */ 2810 NOTIMPLEMENTED, /* AddMemory */
2802 N6110_DeleteMemory, 2811 N6110_DeleteMemory,
2803 NOTIMPLEMENTED, /* DeleteAllMemory */ 2812 NOTIMPLEMENTED, /* DeleteAllMemory */
2804 N6110_GetSpeedDial, 2813 N6110_GetSpeedDial,
2805 NOTIMPLEMENTED, /* SetSpeedDial */ 2814 NOTIMPLEMENTED, /* SetSpeedDial */
2806 DCT3_GetSMSC, 2815 DCT3_GetSMSC,
2807 DCT3_SetSMSC, 2816 DCT3_SetSMSC,
2808 DCT3_GetSMSStatus, 2817 DCT3_GetSMSStatus,
2809 N6110_GetSMSMessage, 2818 N6110_GetSMSMessage,
2810 N6110_GetNextSMSMessage, 2819 N6110_GetNextSMSMessage,
2811 N6110_SetSMS, 2820 N6110_SetSMS,
2812 N6110_AddSMS, 2821 N6110_AddSMS,
2813 N6110_DeleteSMSMessage, 2822 N6110_DeleteSMSMessage,
2814 DCT3_SendSMSMessage, 2823 DCT3_SendSMSMessage,
2815 NOTSUPPORTED, /* SendSavedSMS */ 2824 NOTSUPPORTED, /* SendSavedSMS */
2816 NOTSUPPORTED, /* SetFastSMSSending*/ 2825 NOTSUPPORTED, /* SetFastSMSSending*/
2817 NOKIA_SetIncomingSMS, 2826 NOKIA_SetIncomingSMS,
2818 DCT3_SetIncomingCB, 2827 DCT3_SetIncomingCB,
2819 PHONE_GetSMSFolders, 2828 PHONE_GetSMSFolders,
2820 NOTSUPPORTED, /* AddSMSFolder */ 2829 NOTSUPPORTED, /* AddSMSFolder */
2821 NOTSUPPORTED, /* DeleteSMSFolder */ 2830 NOTSUPPORTED, /* DeleteSMSFolder */
2822 N6110_DialVoice, 2831 N6110_DialVoice,
2823 N6110_AnswerCall, 2832 N6110_AnswerCall,
2824 DCT3_CancelCall, 2833 DCT3_CancelCall,
2825 N6110_HoldCall, 2834 N6110_HoldCall,
2826 N6110_UnholdCall, 2835 N6110_UnholdCall,
2827 N6110_ConferenceCall, 2836 N6110_ConferenceCall,
2828 N6110_SplitCall, 2837 N6110_SplitCall,
2829 N6110_TransferCall, 2838 N6110_TransferCall,
2830 N6110_SwitchCall, 2839 N6110_SwitchCall,
2831 DCT3DCT4_GetCallDivert, 2840 DCT3DCT4_GetCallDivert,
2832 DCT3DCT4_SetCallDivert, 2841 DCT3DCT4_SetCallDivert,
2833 DCT3DCT4_CancelAllDiverts, 2842 DCT3DCT4_CancelAllDiverts,
2834 NOKIA_SetIncomingCall, 2843 NOKIA_SetIncomingCall,
2835 NOKIA_SetIncomingUSSD, 2844 NOKIA_SetIncomingUSSD,
2836 DCT3DCT4_SendDTMF, 2845 DCT3DCT4_SendDTMF,
2837 N6110_GetRingtone, 2846 N6110_GetRingtone,
2838 N6110_SetRingtone, 2847 N6110_SetRingtone,
2839 NOTSUPPORTED, /* GetRingtonesInfo */ 2848 NOTSUPPORTED, /* GetRingtonesInfo */
2840 NOTSUPPORTED, /* DeleteUserRingtones */ 2849 NOTSUPPORTED, /* DeleteUserRingtones */
2841 DCT3_PlayTone, 2850 DCT3_PlayTone,
2842 DCT3_GetWAPBookmark, 2851 DCT3_GetWAPBookmark,
2843 DCT3_SetWAPBookmark, 2852 DCT3_SetWAPBookmark,
2844 DCT3_DeleteWAPBookmark, 2853 DCT3_DeleteWAPBookmark,
2845 DCT3_GetWAPSettings, 2854 DCT3_GetWAPSettings,
2846 DCT3_SetWAPSettings, 2855 DCT3_SetWAPSettings,
2847 NOTSUPPORTED, /* GetMMSSettings */ 2856 NOTSUPPORTED, /* GetMMSSettings */
2848 NOTSUPPORTED, /* SetMMSSettings */ 2857 NOTSUPPORTED, /* SetMMSSettings */
2849 NOTSUPPORTED, /* GetSyncMLSettings*/ 2858 NOTSUPPORTED, /* GetSyncMLSettings*/
2850 NOTSUPPORTED, /* SetSyncMLSettings*/ 2859 NOTSUPPORTED, /* SetSyncMLSettings*/
2851 NOTSUPPORTED, /* GetChatSettings */ 2860 NOTSUPPORTED, /* GetChatSettings */
2852 NOTSUPPORTED, /* SetChatSettings */ 2861 NOTSUPPORTED, /* SetChatSettings */
2853 N6110_GetBitmap, 2862 N6110_GetBitmap,
2854 N6110_SetBitmap, 2863 N6110_SetBitmap,
2855 NOTSUPPORTED, /* GetToDoStatus */ 2864 NOTSUPPORTED, /* GetToDoStatus */
2856 NOTSUPPORTED, /* GetToDo */ 2865 NOTSUPPORTED, /* GetToDo */
2857 NOTSUPPORTED, /* GetNextToDo */ 2866 NOTSUPPORTED, /* GetNextToDo */
2858 NOTSUPPORTED, /* SetToDo */ 2867 NOTSUPPORTED, /* SetToDo */
2859 NOTSUPPORTED, /* AddToDo */ 2868 NOTSUPPORTED, /* AddToDo */
2860 NOTSUPPORTED, /* DeleteToDo */ 2869 NOTSUPPORTED, /* DeleteToDo */
2861 NOTSUPPORTED, /* DeleteAllToDo */ 2870 NOTSUPPORTED, /* DeleteAllToDo */
2862 NOTIMPLEMENTED, /* GetCalendarStatus */ 2871 NOTIMPLEMENTED, /* GetCalendarStatus */
2863 NOTIMPLEMENTED, /* GetCalendar */ 2872 NOTIMPLEMENTED, /* GetCalendar */
2864 N6110_GetNextCalendarNote, 2873 N6110_GetNextCalendarNote,
2865 NOTIMPLEMENTED, /* SetCalendar */ 2874 NOTIMPLEMENTED, /* SetCalendar */
2866 N6110_AddCalendarNote, 2875 N6110_AddCalendarNote,
2867 N6110_DeleteCalendarNote, 2876 N6110_DeleteCalendarNote,
2868 NOTIMPLEMENTED, /* DeleteAllCalendar */ 2877 NOTIMPLEMENTED, /* DeleteAllCalendar */
2869 NOTSUPPORTED, /* GetCalendarSettings */ 2878 NOTSUPPORTED, /* GetCalendarSettings */
2870 NOTSUPPORTED, /* SetCalendarSettings */ 2879 NOTSUPPORTED, /* SetCalendarSettings */
2871 NOTSUPPORTED, /* GetNextNote */ 2880 NOTSUPPORTED, /* GetNoteStatus */
2881 NOTSUPPORTED, /* GetNote */
2882 NOTSUPPORTED, /* GetNextNote */
2883 NOTSUPPORTED, /* SetNote */
2884 NOTSUPPORTED, /* AddNote */
2885 NOTSUPPORTED, /* DeleteNote */
2886 NOTSUPPORTED, /* DeleteAllNotes */
2872 N6110_GetProfile, 2887 N6110_GetProfile,
2873 N6110_SetProfile, 2888 N6110_SetProfile,
2874 NOTSUPPORTED, /* GetFMStation */ 2889 NOTSUPPORTED, /* GetFMStation */
2875 NOTSUPPORTED, /* SetFMStation */ 2890 NOTSUPPORTED, /* SetFMStation */
2876 NOTSUPPORTED, /* ClearFMStations */ 2891 NOTSUPPORTED, /* ClearFMStations */
2877 NOTSUPPORTED, /* GetNextFileFolder */ 2892 NOTSUPPORTED, /* GetNextFileFolder */
2878 NOTSUPPORTED, /* GetFilePart */ 2893 NOTSUPPORTED, /* GetFilePart */
2879 NOTSUPPORTED, /* AddFile */ 2894 NOTSUPPORTED, /* AddFile */
2880 NOTSUPPORTED, /* GetFileSystemStatus */ 2895 NOTSUPPORTED, /* GetFileSystemStatus */
2881 NOTSUPPORTED, /* DeleteFile */ 2896 NOTSUPPORTED, /* DeleteFile */
2882 NOTSUPPORTED, /* AddFolder */ 2897 NOTSUPPORTED, /* AddFolder */
2883 NOTSUPPORTED, /* GetGPRSAccessPoint */ 2898 NOTSUPPORTED, /* GetGPRSAccessPoint */
2884 NOTSUPPORTED /* SetGPRSAccessPoint */ 2899 NOTSUPPORTED /* SetGPRSAccessPoint */
2885}; 2900};
2886 2901
2887#endif 2902#endif
2888 2903
2889/* How should editor hadle tabs in this file? Add editor commands here. 2904/* How should editor hadle tabs in this file? Add editor commands here.
2890 * vim: noexpandtab sw=8 ts=8 sts=8: 2905 * vim: noexpandtab sw=8 ts=8 sts=8:
2891 */ 2906 */
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c
index b597f9b..a8e0545 100644
--- a/gammu/emb/common/phone/nokia/dct3/n7110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.c
@@ -1,389 +1,398 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some Markus Plail work from Gnokii (www.gnokii.org) 2/* based on some Markus Plail work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later 4 * GNU GPL version 2 or later
5 */ 5 */
6/* Due to a problem in the source code management, the names of some of
7 * the authors have unfortunately been lost. We do not mean to belittle
8 * their efforts and hope they will contact us to see their names
9 * properly added to the Copyright notice above.
10 * Having published their contributions under the terms of the GNU
11 * General Public License (GPL) [version 2], the Copyright of these
12 * authors will remain respected by adhering to the license they chose
13 * to publish their code under.
14 */
6 15
7#include "../../../gsmstate.h" 16#include "../../../gsmstate.h"
8 17
9#ifdef GSM_ENABLE_NOKIA7110 18#ifdef GSM_ENABLE_NOKIA7110
10 19
11#include <string.h> 20#include <string.h>
12#include <time.h> 21#include <time.h>
13 22
14#include "../../../misc/coding/coding.h" 23#include "../../../misc/coding/coding.h"
15#include "../../../gsmcomon.h" 24#include "../../../gsmcomon.h"
16#include "../../../service/gsmlogo.h" 25#include "../../../service/gsmlogo.h"
17#include "../../pfunc.h" 26#include "../../pfunc.h"
18#include "../nfunc.h" 27#include "../nfunc.h"
19#include "../nfuncold.h" 28#include "../nfuncold.h"
20#include "n7110.h" 29#include "n7110.h"
21#include "dct3func.h" 30#include "dct3func.h"
22 31
23static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 32static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
24{ 33{
25 return DCT3_GetAlarm(s, alarm, 0x19); 34 return DCT3_GetAlarm(s, alarm, 0x19);
26} 35}
27 36
28static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 37static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
29{ 38{
30 return DCT3_SetAlarm(s, alarm, 0x19); 39 return DCT3_SetAlarm(s, alarm, 0x19);
31} 40}
32 41
33static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 42static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
34{ 43{
35 GSM_Phone_Data *Data = &s->Phone.Data; 44 GSM_Phone_Data *Data = &s->Phone.Data;
36 45
37 smprintf(s, "Phonebook entry received\n"); 46 smprintf(s, "Phonebook entry received\n");
38 switch (msg.Buffer[6]) { 47 switch (msg.Buffer[6]) {
39 case 0x0f: 48 case 0x0f:
40 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); 49 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
41 default: 50 default:
42 return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false); 51 return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false);
43 } 52 }
44 return ERR_UNKNOWN; 53 return ERR_UNKNOWN;
45} 54}
46 55
47static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) 56static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
48{ 57{
49 unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 58 unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
50 0x02, /* memory type */ 59 0x02, /* memory type */
51 0x05, 60 0x05,
52 0x00, 0x00,/* location */ 61 0x00, 0x00,/* location */
53 0x00, 0x00}; 62 0x00, 0x00};
54 63
55 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 64 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
56 if (req[9]==0xff) return ERR_NOTSUPPORTED; 65 if (req[9]==0xff) return ERR_NOTSUPPORTED;
57 66
58 if (entry->Location==0x00) return ERR_INVALIDLOCATION; 67 if (entry->Location==0x00) return ERR_INVALIDLOCATION;
59 68
60 req[10] = entry->Location / 256; 69 req[10] = entry->Location / 256;
61 req[11] = entry->Location % 256; 70 req[11] = entry->Location % 256;
62 71
63 s->Phone.Data.Memory=entry; 72 s->Phone.Data.Memory=entry;
64 smprintf(s, "Getting phonebook entry\n"); 73 smprintf(s, "Getting phonebook entry\n");
65 return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory); 74 return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory);
66} 75}
67 76
68static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 77static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
69{ 78{
70 GSM_Phone_Data *Data = &s->Phone.Data; 79 GSM_Phone_Data *Data = &s->Phone.Data;
71 80
72 smprintf(s, "Memory status received\n"); 81 smprintf(s, "Memory status received\n");
73 /* Quess ;-)) */ 82 /* Quess ;-)) */
74 if (msg.Buffer[10]==0x10) { 83 if (msg.Buffer[10]==0x10) {
75 Data->MemoryStatus->MemoryFree = msg.Buffer[14]*256 + msg.Buffer[15]; 84 Data->MemoryStatus->MemoryFree = msg.Buffer[14]*256 + msg.Buffer[15];
76 } else { 85 } else {
77 Data->MemoryStatus->MemoryFree = msg.Buffer[18]; 86 Data->MemoryStatus->MemoryFree = msg.Buffer[18];
78 } 87 }
79 smprintf(s, " Size : %i\n",Data->MemoryStatus->MemoryFree); 88 smprintf(s, " Size : %i\n",Data->MemoryStatus->MemoryFree);
80 Data->MemoryStatus->MemoryUsed = msg.Buffer[16]*256 + msg.Buffer[17]; 89 Data->MemoryStatus->MemoryUsed = msg.Buffer[16]*256 + msg.Buffer[17];
81 smprintf(s, " Used : %i\n",Data->MemoryStatus->MemoryUsed); 90 smprintf(s, " Used : %i\n",Data->MemoryStatus->MemoryUsed);
82 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; 91 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed;
83 smprintf(s, " Free : %i\n",Data->MemoryStatus->MemoryFree); 92 smprintf(s, " Free : %i\n",Data->MemoryStatus->MemoryFree);
84 return ERR_NONE; 93 return ERR_NONE;
85} 94}
86 95
87static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) 96static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
88{ 97{
89 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 98 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
90 0x05}; /* Memory type */ 99 0x05}; /* Memory type */
91 100
92 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); 101 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
93 if (req[5]==0xff) return ERR_NOTSUPPORTED; 102 if (req[5]==0xff) return ERR_NOTSUPPORTED;
94 103
95 s->Phone.Data.MemoryStatus=Status; 104 s->Phone.Data.MemoryStatus=Status;
96 smprintf(s, "Getting memory status\n"); 105 smprintf(s, "Getting memory status\n");
97 return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus); 106 return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus);
98} 107}
99 108
100static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location) 109static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location)
101{ 110{
102 int ifolderid; 111 int ifolderid;
103 112
104 /* simulate flat SMS memory */ 113 /* simulate flat SMS memory */
105 if (sms->Folder==0x00) { 114 if (sms->Folder==0x00) {
106 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER; 115 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER;
107 *folderid = (ifolderid + 1) * 0x08; 116 *folderid = (ifolderid + 1) * 0x08;
108 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER; 117 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER;
109 } else { 118 } else {
110 *folderid = sms->Folder * 0x08; 119 *folderid = sms->Folder * 0x08;
111 *location = sms->Location; 120 *location = sms->Location;
112 } 121 }
113 smprintf(s, "SMS folder %i & location %i -> 7110 folder %i & location %i\n", 122 smprintf(s, "SMS folder %i & location %i -> 7110 folder %i & location %i\n",
114 sms->Folder,sms->Location,*folderid,*location); 123 sms->Folder,sms->Location,*folderid,*location);
115} 124}
116 125
117static void N7110_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location) 126static void N7110_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
118{ 127{
119 sms->Folder= 0; 128 sms->Folder= 0;
120 sms->Location= (folderid / 0x08 - 1) * PHONE_MAXSMSINFOLDER + location; 129 sms->Location= (folderid / 0x08 - 1) * PHONE_MAXSMSINFOLDER + location;
121 smprintf(s, "7110 folder %i & location %i -> SMS folder %i & location %i\n", 130 smprintf(s, "7110 folder %i & location %i -> SMS folder %i & location %i\n",
122 folderid,location,sms->Folder,sms->Location); 131 folderid,location,sms->Folder,sms->Location);
123} 132}
124 133
125static GSM_Error N7110_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s) 134static GSM_Error N7110_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s)
126{ 135{
127 int j,current=5; 136 int j,current=5;
128 unsigned char buffer[200]; 137 unsigned char buffer[200];
129 GSM_Phone_Data*Data = &s->Phone.Data; 138 GSM_Phone_Data*Data = &s->Phone.Data;
130 139
131 switch (msg.Buffer[3]) { 140 switch (msg.Buffer[3]) {
132 case 0x7B: 141 case 0x7B:
133 smprintf(s, "Names for SMS folders received\n"); 142 smprintf(s, "Names for SMS folders received\n");
134 Data->SMSFolders->Number=msg.Buffer[4]; 143 Data->SMSFolders->Number=msg.Buffer[4];
135 for (j=0;j<msg.Buffer[4];j++) { 144 for (j=0;j<msg.Buffer[4];j++) {
136 smprintf(s, "Folder index: %02x",msg.Buffer[current]); 145 smprintf(s, "Folder index: %02x",msg.Buffer[current]);
137 current++; 146 current++;
138 smprintf(s, ", folder name: \""); 147 smprintf(s, ", folder name: \"");
139 CopyUnicodeString(buffer,msg.Buffer+current); 148 CopyUnicodeString(buffer,msg.Buffer+current);
140 if ((UnicodeLength(buffer))>GSM_MAX_SMS_FOLDER_NAME_LEN) { 149 if ((UnicodeLength(buffer))>GSM_MAX_SMS_FOLDER_NAME_LEN) {
141 smprintf(s, "Too long text\n"); 150 smprintf(s, "Too long text\n");
142 return ERR_UNKNOWNRESPONSE; 151 return ERR_UNKNOWNRESPONSE;
143 } 152 }
144 CopyUnicodeString(Data->SMSFolders->Folder[j].Name,buffer); 153 CopyUnicodeString(Data->SMSFolders->Folder[j].Name,buffer);
145 smprintf(s, "%s\"\n",DecodeUnicodeString(buffer)); 154 smprintf(s, "%s\"\n",DecodeUnicodeString(buffer));
146 current=current+2+UnicodeLength(buffer)*2; 155 current=current+2+UnicodeLength(buffer)*2;
147 Data->SMSFolders->Folder[j].InboxFolder = false; 156 Data->SMSFolders->Folder[j].InboxFolder = false;
148 if (j==0) Data->SMSFolders->Folder[j].InboxFolder = true; 157 if (j==0) Data->SMSFolders->Folder[j].InboxFolder = true;
149 Data->SMSFolders->Folder[j].Memory = MEM_ME; 158 Data->SMSFolders->Folder[j].Memory = MEM_ME;
150 if (j==0 || j==1) Data->SMSFolders->Folder[j].InboxFolder = MEM_MT; 159 if (j==0 || j==1) Data->SMSFolders->Folder[j].InboxFolder = MEM_MT;
151 } 160 }
152 return ERR_NONE; 161 return ERR_NONE;
153 case 0x7C: 162 case 0x7C:
154 smprintf(s, "Security error ? No PIN ?\n"); 163 smprintf(s, "Security error ? No PIN ?\n");
155 return ERR_SECURITYERROR; 164 return ERR_SECURITYERROR;
156 case 0xCA: 165 case 0xCA:
157 smprintf(s, "Wait a moment. Phone is during power on and busy now\n"); 166 smprintf(s, "Wait a moment. Phone is during power on and busy now\n");
158 return ERR_SECURITYERROR; 167 return ERR_SECURITYERROR;
159 } 168 }
160 return ERR_UNKNOWNRESPONSE; 169 return ERR_UNKNOWNRESPONSE;
161} 170}
162 171
163static GSM_Error N7110_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders) 172static GSM_Error N7110_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
164{ 173{
165 unsigned char req[] = {N6110_FRAME_HEADER, 0x7A, 0x00, 0x00}; 174 unsigned char req[] = {N6110_FRAME_HEADER, 0x7A, 0x00, 0x00};
166 175
167 s->Phone.Data.SMSFolders=folders; 176 s->Phone.Data.SMSFolders=folders;
168 smprintf(s, "Getting SMS folders\n"); 177 smprintf(s, "Getting SMS folders\n");
169 return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders); 178 return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders);
170} 179}
171 180
172static GSM_Error N7110_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 181static GSM_Error N7110_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
173{ 182{
174 int i; 183 int i;
175 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110; 184 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
176 185
177 smprintf(s, "SMS folder status received\n"); 186 smprintf(s, "SMS folder status received\n");
178 Priv->LastSMSFolder.Number=msg.Buffer[4]*256+msg.Buffer[5]; 187 Priv->LastSMSFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
179 smprintf(s, "Number of Entries: %i\n",Priv->LastSMSFolder.Number); 188 smprintf(s, "Number of Entries: %i\n",Priv->LastSMSFolder.Number);
180 smprintf(s, "Locations: "); 189 smprintf(s, "Locations: ");
181 for (i=0;i<Priv->LastSMSFolder.Number;i++) { 190 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
182 Priv->LastSMSFolder.Location[i]=msg.Buffer[6+(i*2)]*256+msg.Buffer[(i*2)+7]; 191 Priv->LastSMSFolder.Location[i]=msg.Buffer[6+(i*2)]*256+msg.Buffer[(i*2)+7];
183 if (Priv->LastSMSFolder.Location[i] > PHONE_MAXSMSINFOLDER) { 192 if (Priv->LastSMSFolder.Location[i] > PHONE_MAXSMSINFOLDER) {
184 smprintf(s, "Increase PHONE_MAXSMSINFOLDER\n"); 193 smprintf(s, "Increase PHONE_MAXSMSINFOLDER\n");
185 return ERR_UNKNOWNRESPONSE; 194 return ERR_UNKNOWNRESPONSE;
186 } 195 }
187 smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]); 196 smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]);
188 } 197 }
189 smprintf(s, "\n"); 198 smprintf(s, "\n");
190 NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder); 199 NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder);
191 return ERR_NONE; 200 return ERR_NONE;
192} 201}
193 202
194static GSM_Error N7110_PrivGetSMSFolderStatus(GSM_StateMachine *s, int folderid) 203static GSM_Error N7110_PrivGetSMSFolderStatus(GSM_StateMachine *s, int folderid)
195{ 204{
196 unsigned char req[] = {N7110_FRAME_HEADER, 0x6b, 205 unsigned char req[] = {N7110_FRAME_HEADER, 0x6b,
197 0x08, /* folderID */ 206 0x08, /* folderID */
198 0x0F, 0x01}; 207 0x0F, 0x01};
199 208
200 req[4] = folderid; 209 req[4] = folderid;
201 210
202 smprintf(s, "Getting SMS folder status\n"); 211 smprintf(s, "Getting SMS folder status\n");
203 return GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetSMSFolderStatus); 212 return GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetSMSFolderStatus);
204} 213}
205 214
206static GSM_Error N7110_GetSMSFolderStatus(GSM_StateMachine *s, int folderid) 215static GSM_Error N7110_GetSMSFolderStatus(GSM_StateMachine *s, int folderid)
207{ 216{
208 GSM_Error error; 217 GSM_Error error;
209 int i; 218 int i;
210 GSM_NOKIASMSFolderfolder; 219 GSM_NOKIASMSFolderfolder;
211 220
212 error = N7110_PrivGetSMSFolderStatus(s,folderid); 221 error = N7110_PrivGetSMSFolderStatus(s,folderid);
213 /* 0x08 contais read Inbox, 0xf8 unread Inbox. 222 /* 0x08 contais read Inbox, 0xf8 unread Inbox.
214 * we want all msg from Inbox, so read both 0x08 and 0xf8 */ 223 * we want all msg from Inbox, so read both 0x08 and 0xf8 */
215 if (folderid==0x08 && error==ERR_NONE) { 224 if (folderid==0x08 && error==ERR_NONE) {
216 folder=s->Phone.Data.Priv.N7110.LastSMSFolder; 225 folder=s->Phone.Data.Priv.N7110.LastSMSFolder;
217 error = N7110_PrivGetSMSFolderStatus(s,0xf8); 226 error = N7110_PrivGetSMSFolderStatus(s,0xf8);
218 if (error==ERR_NONE) { 227 if (error==ERR_NONE) {
219 for (i=0;i<folder.Number;i++) { 228 for (i=0;i<folder.Number;i++) {
220 s->Phone.Data.Priv.N7110.LastSMSFolder.Location[s->Phone.Data.Priv.N7110.LastSMSFolder.Number++]=folder.Location[i]; 229 s->Phone.Data.Priv.N7110.LastSMSFolder.Location[s->Phone.Data.Priv.N7110.LastSMSFolder.Number++]=folder.Location[i];
221 } 230 }
222 } 231 }
223 } 232 }
224 return error; 233 return error;
225} 234}
226 235
227static GSM_SMSMessageLayout N7110_SMSTemplate = { 236static GSM_SMSMessageLayout N7110_SMSTemplate = {
228 36 /* SMS Text */, 17 /* Phone number*/, 237 36 /* SMS Text */, 17 /* Phone number*/,
229 255 /* SMSC Number */, 15 /* TPDCS */, 238 255 /* SMSC Number */, 15 /* TPDCS */,
230 255 /* SendingDateTime */, 255 /* SMSCDateTime*/, 239 255 /* SendingDateTime */, 255 /* SMSCDateTime*/,
231 255 /* TPStatus */, 16 /* TPUDL */, 240 255 /* TPStatus */, 16 /* TPUDL */,
232 255 /* TPVP */, 12 /* firstbyte*/, 241 255 /* TPVP */, 12 /* firstbyte*/,
233 13 /* TPMR */, 255 /* TPPID?? */}; 242 13 /* TPMR */, 255 /* TPPID?? */};
234 243
235static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 244static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
236{ 245{
237 int i; 246 int i;
238 int Width, Height; 247 int Width, Height;
239 unsigned char output[500], output2[500]; 248 unsigned char output[500], output2[500];
240 GSM_Phone_Data *Data = &s->Phone.Data; 249 GSM_Phone_Data *Data = &s->Phone.Data;
241 250
242 switch(msg.Buffer[3]) { 251 switch(msg.Buffer[3]) {
243 case 0x08: 252 case 0x08:
244 switch (msg.Buffer[8]) { 253 switch (msg.Buffer[8]) {
245 case 0x00: 254 case 0x00:
246 case 0x01: 255 case 0x01:
247 smprintf(s, "SMS message\n"); 256 smprintf(s, "SMS message\n");
248 if (Data->RequestID == ID_GetSMSMessage) { 257 if (Data->RequestID == ID_GetSMSMessage) {
249 Data->GetSMSMessage->Number=1; 258 Data->GetSMSMessage->Number=1;
250 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]); 259 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
251 DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+9); 260 DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+9);
252 return ERR_NONE; 261 return ERR_NONE;
253 } 262 }
254 case 0x02: 263 case 0x02:
255 smprintf(s, "SMS template\n"); 264 smprintf(s, "SMS template\n");
256 if (Data->RequestID == ID_GetSMSMessage) { 265 if (Data->RequestID == ID_GetSMSMessage) {
257 Data->GetSMSMessage->Number=1; 266 Data->GetSMSMessage->Number=1;
258 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]); 267 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
259 Data->GetSMSMessage->SMS[0].PDU=SMS_Submit; 268 Data->GetSMSMessage->SMS[0].PDU=SMS_Submit;
260 GSM_DecodeSMSFrame(&Data->GetSMSMessage->SMS[0],msg.Buffer+9,N7110_SMSTemplate); 269 GSM_DecodeSMSFrame(&Data->GetSMSMessage->SMS[0],msg.Buffer+9,N7110_SMSTemplate);
261 return ERR_NONE; 270 return ERR_NONE;
262 } 271 }
263 case 0x07: 272 case 0x07:
264 smprintf(s, "Picture Image\n"); 273 smprintf(s, "Picture Image\n");
265 switch (Data->RequestID) { 274 switch (Data->RequestID) {
266 case ID_GetBitmap: 275 case ID_GetBitmap:
267 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height); 276 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
268 Data->Bitmap->BitmapWidth= Width; 277 Data->Bitmap->BitmapWidth= Width;
269 Data->Bitmap->BitmapHeight= Height; 278 Data->Bitmap->BitmapHeight= Height;
270 PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 51, Data->Bitmap); 279 PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 51, Data->Bitmap);
271 GSM_UnpackSemiOctetNumber(Data->Bitmap->Sender,msg.Buffer+22,true); 280 GSM_UnpackSemiOctetNumber(Data->Bitmap->Sender,msg.Buffer+22,true);
272#ifdef DEBUG 281#ifdef DEBUG
273 GSM_UnpackSemiOctetNumber(output,msg.Buffer+9,true); 282 GSM_UnpackSemiOctetNumber(output,msg.Buffer+9,true);
274 smprintf(s, "SMSC : %s\n",DecodeUnicodeString(output)); 283 smprintf(s, "SMSC : %s\n",DecodeUnicodeString(output));
275#endif 284#endif
276 Data->Bitmap->Text[0] = 0; 285 Data->Bitmap->Text[0] = 0;
277 Data->Bitmap->Text[1] = 0; 286 Data->Bitmap->Text[1] = 0;
278 if (msg.Length!=304) { 287 if (msg.Length!=304) {
279 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output); 288 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output);
280 DecodeDefault(Data->Bitmap->Text, output, msg.Length - 304, true, NULL); 289 DecodeDefault(Data->Bitmap->Text, output, msg.Length - 304, true, NULL);
281 } 290 }
282 return ERR_NONE; 291 return ERR_NONE;
283 case ID_GetSMSMessage: 292 case ID_GetSMSMessage:
284 Data->GetSMSMessage->Number = 0; 293 Data->GetSMSMessage->Number = 0;
285 i = 0; 294 i = 0;
286 output[i++] = 0x30; /* Smart Messaging 3.0 */ 295 output[i++] = 0x30; /* Smart Messaging 3.0 */
287 output[i++] = SM30_OTA; 296 output[i++] = SM30_OTA;
288 output[i++] = 0x01; /* Length */ 297 output[i++] = 0x01; /* Length */
289 output[i++] = 0x00; /* Length */ 298 output[i++] = 0x00; /* Length */
290 output[i++] = 0x00; 299 output[i++] = 0x00;
291 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height); 300 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
292 output[i++] = Width; 301 output[i++] = Width;
293 output[i++] = Height; 302 output[i++] = Height;
294 output[i++] = 0x01; 303 output[i++] = 0x01;
295 memcpy(output+i,msg.Buffer+51,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0)); 304 memcpy(output+i,msg.Buffer+51,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0));
296 i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0); 305 i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0);
297 if (msg.Length!=304) { 306 if (msg.Length!=304) {
298 output[i++] = SM30_UNICODETEXT; 307 output[i++] = SM30_UNICODETEXT;
299 output[i++] = 0; 308 output[i++] = 0;
300 output[i++] = 0; /* Length - later changed */ 309 output[i++] = 0; /* Length - later changed */
301 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output2); 310 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output2);
302 DecodeDefault(output+i, output2, msg.Length - 304, true, NULL); 311 DecodeDefault(output+i, output2, msg.Length - 304, true, NULL);
303 output[i - 1] = UnicodeLength(output+i) * 2; 312 output[i - 1] = UnicodeLength(output+i) * 2;
304 i = i + output[i-1]; 313 i = i + output[i-1];
305 } 314 }
306 GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,SMS_Coding_8bit,1,0); 315 GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,SMS_Coding_8bit,1,0);
307 for (i=0;i<3;i++) { 316 for (i=0;i<3;i++) {
308 Data->GetSMSMessage->SMS[i].Number[0]=0; 317 Data->GetSMSMessage->SMS[i].Number[0]=0;
309 Data->GetSMSMessage->SMS[i].Number[1]=0; 318 Data->GetSMSMessage->SMS[i].Number[1]=0;
310 } 319 }
311 return ERR_NONE; 320 return ERR_NONE;
312 default: 321 default:
313 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]); 322 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
314 return ERR_UNKNOWNRESPONSE; 323 return ERR_UNKNOWNRESPONSE;
315 } 324 }
316 default: 325 default:
317 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]); 326 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
318 } 327 }
319 break; 328 break;
320 case 0x09: 329 case 0x09:
321 switch (msg.Buffer[4]) { 330 switch (msg.Buffer[4]) {
322 case 0x02: 331 case 0x02:
323 smprintf(s, "Too high location ?\n"); 332 smprintf(s, "Too high location ?\n");
324 return ERR_INVALIDLOCATION; 333 return ERR_INVALIDLOCATION;
325 case 0x07: 334 case 0x07:
326 smprintf(s, "Empty\n"); 335 smprintf(s, "Empty\n");
327 return ERR_EMPTY; 336 return ERR_EMPTY;
328 default: 337 default:
329 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 338 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
330 } 339 }
331 case 0x6F: 340 case 0x6F:
332 smprintf(s, "SMS message info received\n"); 341 smprintf(s, "SMS message info received\n");
333 if (msg.Length == 43) { 342 if (msg.Length == 43) {
334 Data->GetSMSMessage->SMS[0].Name[0] = 0; 343 Data->GetSMSMessage->SMS[0].Name[0] = 0;
335 Data->GetSMSMessage->SMS[0].Name[1] = 0; 344 Data->GetSMSMessage->SMS[0].Name[1] = 0;
336 } else { 345 } else {
337 CopyUnicodeString(Data->GetSMSMessage->SMS[0].Name,msg.Buffer+43); 346 CopyUnicodeString(Data->GetSMSMessage->SMS[0].Name,msg.Buffer+43);
338 } 347 }
339 smprintf(s, "Name: \"%s\"\n",DecodeUnicodeString(Data->GetSMSMessage->SMS[0].Name)); 348 smprintf(s, "Name: \"%s\"\n",DecodeUnicodeString(Data->GetSMSMessage->SMS[0].Name));
340 return ERR_NONE; 349 return ERR_NONE;
341 } 350 }
342 return ERR_UNKNOWNRESPONSE; 351 return ERR_UNKNOWNRESPONSE;
343} 352}
344 353
345static GSM_Error N7110_PrivGetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms) 354static GSM_Error N7110_PrivGetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
346{ 355{
347 GSM_Error error; 356 GSM_Error error;
348 unsigned char folderid; 357 unsigned char folderid;
349 int location; 358 int location;
350 int i; 359 int i;
351 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 360 unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
352 0x08, /* folder ID */ 361 0x08, /* folder ID */
353 0x00, 0x05, /* location */ 362 0x00, 0x05, /* location */
354 0x01, 0x65, 0x01}; 363 0x01, 0x65, 0x01};
355 unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x6E, 364 unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x6E,
356 0x08, /* folder ID */ 365 0x08, /* folder ID */
357 0x00, 0x05}; /* location */ 366 0x00, 0x05}; /* location */
358 367
359 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location); 368 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
360 369
361 req[4]=folderid; 370 req[4]=folderid;
362 req[5]=location / 256; 371 req[5]=location / 256;
363 req[6]=location; 372 req[6]=location;
364 373
365 s->Phone.Data.GetSMSMessage=sms; 374 s->Phone.Data.GetSMSMessage=sms;
366 smprintf(s, "Getting sms\n"); 375 smprintf(s, "Getting sms\n");
367 error=GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSMessage); 376 error=GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSMessage);
368 if (error==ERR_NONE) { 377 if (error==ERR_NONE) {
369 NameReq[4] = folderid; 378 NameReq[4] = folderid;
370 NameReq[5] = location / 256; 379 NameReq[5] = location / 256;
371 NameReq[6] = location; 380 NameReq[6] = location;
372 smprintf(s, "Getting sms info\n"); 381 smprintf(s, "Getting sms info\n");
373 error=GSM_WaitFor (s, NameReq, 7, 0x14, 4, ID_GetSMSMessage); 382 error=GSM_WaitFor (s, NameReq, 7, 0x14, 4, ID_GetSMSMessage);
374 if (error != ERR_NONE) return error; 383 if (error != ERR_NONE) return error;
375 for (i=0;i<sms->Number;i++) { 384 for (i=0;i<sms->Number;i++) {
376 N7110_SetSMSLocation(s, &sms->SMS[i], folderid, location); 385 N7110_SetSMSLocation(s, &sms->SMS[i], folderid, location);
377 sms->SMS[i].Folder = folderid/0x08; 386 sms->SMS[i].Folder = folderid/0x08;
378 sms->SMS[i].InboxFolder = true; 387 sms->SMS[i].InboxFolder = true;
379 if (folderid/0x08 != 0x01) sms->SMS[i].InboxFolder = false; 388 if (folderid/0x08 != 0x01) sms->SMS[i].InboxFolder = false;
380 CopyUnicodeString(sms->SMS[i].Name,sms->SMS[0].Name); 389 CopyUnicodeString(sms->SMS[i].Name,sms->SMS[0].Name);
381 sms->SMS[i].Memory = MEM_ME; 390 sms->SMS[i].Memory = MEM_ME;
382 if (folderid/0x08 == 0x01 || folderid/0x08 == 0x02) { 391 if (folderid/0x08 == 0x01 || folderid/0x08 == 0x02) {
383 sms->SMS[i].Memory = MEM_MT; 392 sms->SMS[i].Memory = MEM_MT;
384 if (folderid/0x08 == 0x01) { /* Inbox */ 393 if (folderid/0x08 == 0x01) { /* Inbox */
385 if (sms->SMS[i].State == SMS_Sent) sms->SMS[i].Memory = MEM_ME; 394 if (sms->SMS[i].State == SMS_Sent) sms->SMS[i].Memory = MEM_ME;
386 if (sms->SMS[i].State == SMS_UnSent) sms->SMS[i].Memory = MEM_ME; 395 if (sms->SMS[i].State == SMS_UnSent) sms->SMS[i].Memory = MEM_ME;
387 if (sms->SMS[i].State == SMS_Read) sms->SMS[i].Memory = MEM_SM; 396 if (sms->SMS[i].State == SMS_Read) sms->SMS[i].Memory = MEM_SM;
388 if (sms->SMS[i].State == SMS_UnRead) sms->SMS[i].Memory = MEM_SM; 397 if (sms->SMS[i].State == SMS_UnRead) sms->SMS[i].Memory = MEM_SM;
389 } 398 }
@@ -1325,405 +1334,411 @@ static GSM_Error N7110_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachi
1325 sms.InboxFolder = true; 1334 sms.InboxFolder = true;
1326 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8); 1335 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
1327 1336
1328 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 1337 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
1329 } 1338 }
1330 return ERR_NONE; 1339 return ERR_NONE;
1331} 1340}
1332 1341
1333static GSM_Error N7110_Initialise (GSM_StateMachine *s) 1342static GSM_Error N7110_Initialise (GSM_StateMachine *s)
1334{ 1343{
1335#ifdef DEBUG 1344#ifdef DEBUG
1336 DCT3_SetIncomingCB(s,true); 1345 DCT3_SetIncomingCB(s,true);
1337#endif 1346#endif
1338#ifdef GSM_ENABLE_N71_92INCOMINGINFO 1347#ifdef GSM_ENABLE_N71_92INCOMINGINFO
1339 /* Enables various things like incoming SMS, call info, etc. */ 1348 /* Enables various things like incoming SMS, call info, etc. */
1340 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17", 6); 1349 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17", 6);
1341#endif 1350#endif
1342 return ERR_NONE; 1351 return ERR_NONE;
1343} 1352}
1344 1353
1345static GSM_Error N7110_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 1354static GSM_Error N7110_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1346{ 1355{
1347 /* Old method 1 for accessing calendar */ 1356 /* Old method 1 for accessing calendar */
1348 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N7110.LastCalendar); 1357 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N7110.LastCalendar);
1349} 1358}
1350 1359
1351#ifdef DEBUG 1360#ifdef DEBUG
1352static GSM_Error N7110_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s) 1361static GSM_Error N7110_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s)
1353{ 1362{
1354 /* Old method 1 for accessing calendar */ 1363 /* Old method 1 for accessing calendar */
1355 return N71_65_ReplyGetCalendarNotePos1(msg, s, &s->Phone.Data.Priv.N7110.FirstCalendarPos); 1364 return N71_65_ReplyGetCalendarNotePos1(msg, s, &s->Phone.Data.Priv.N7110.FirstCalendarPos);
1356} 1365}
1357#endif 1366#endif
1358 1367
1359static GSM_Error N7110_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 1368static GSM_Error N7110_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
1360{ 1369{
1361 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendar,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos); 1370 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendar,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
1362 //return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos); 1371 //return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
1363} 1372}
1364 1373
1365static GSM_Error N7110_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 1374static GSM_Error N7110_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
1366{ 1375{
1367 GSM_Error error; 1376 GSM_Error error;
1368 1377
1369 /* Method 1 */ 1378 /* Method 1 */
1370 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N7110.LastCalendar); 1379 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N7110.LastCalendar);
1371 if (error!=ERR_NONE) return error; 1380 if (error!=ERR_NONE) return error;
1372 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 1381 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
1373 return ERR_NONE; 1382 return ERR_NONE;
1374 1383
1375 /* Method 2 */ 1384 /* Method 2 */
1376 // return GE_NOTSUPPORTED; 1385 // return GE_NOTSUPPORTED;
1377} 1386}
1378 1387
1379static GSM_Error N7110_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 1388static GSM_Error N7110_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
1380{ 1389{
1381 //return N71_65_AddCalendar1(s, Note, NULL); 1390 //return N71_65_AddCalendar1(s, Note, NULL);
1382 return N71_65_AddCalendar2(s,Note); 1391 return N71_65_AddCalendar2(s,Note);
1383} 1392}
1384 1393
1385static GSM_Error N7110_ReplyGetNetworkInfoError(GSM_Protocol_Message msg, GSM_StateMachine *s) 1394static GSM_Error N7110_ReplyGetNetworkInfoError(GSM_Protocol_Message msg, GSM_StateMachine *s)
1386{ 1395{
1387 smprintf(s, "Probably means no PIN\n"); 1396 smprintf(s, "Probably means no PIN\n");
1388 return ERR_SECURITYERROR; 1397 return ERR_SECURITYERROR;
1389} 1398}
1390 1399
1391static GSM_Error N7110_SetIncomingCall(GSM_StateMachine *s, bool enable) 1400static GSM_Error N7110_SetIncomingCall(GSM_StateMachine *s, bool enable)
1392{ 1401{
1393#ifndef GSM_ENABLE_N71_92INCOMINGINFO 1402#ifndef GSM_ENABLE_N71_92INCOMINGINFO
1394 return ERR_SOURCENOTAVAILABLE; 1403 return ERR_SOURCENOTAVAILABLE;
1395#endif 1404#endif
1396 return NOKIA_SetIncomingCall(s,enable); 1405 return NOKIA_SetIncomingCall(s,enable);
1397} 1406}
1398 1407
1399static GSM_Error N7110_SetIncomingUSSD(GSM_StateMachine *s, bool enable) 1408static GSM_Error N7110_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
1400{ 1409{
1401#ifndef GSM_ENABLE_N71_92INCOMINGINFO 1410#ifndef GSM_ENABLE_N71_92INCOMINGINFO
1402 return ERR_SOURCENOTAVAILABLE; 1411 return ERR_SOURCENOTAVAILABLE;
1403#endif 1412#endif
1404 return NOKIA_SetIncomingUSSD(s,enable); 1413 return NOKIA_SetIncomingUSSD(s,enable);
1405} 1414}
1406 1415
1407static GSM_Error N7110_SetIncomingSMS(GSM_StateMachine *s, bool enable) 1416static GSM_Error N7110_SetIncomingSMS(GSM_StateMachine *s, bool enable)
1408{ 1417{
1409#ifndef GSM_ENABLE_N71_92INCOMINGINFO 1418#ifndef GSM_ENABLE_N71_92INCOMINGINFO
1410 return ERR_SOURCENOTAVAILABLE; 1419 return ERR_SOURCENOTAVAILABLE;
1411#endif 1420#endif
1412 return NOKIA_SetIncomingSMS(s,enable); 1421 return NOKIA_SetIncomingSMS(s,enable);
1413} 1422}
1414 1423
1415GSM_Error N7110_AnswerCall(GSM_StateMachine *s, int ID, bool all) 1424GSM_Error N7110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
1416{ 1425{
1417 if (!all) return DCT3DCT4_AnswerCall(s,ID); 1426 if (!all) return DCT3DCT4_AnswerCall(s,ID);
1418 return DCT3_AnswerAllCalls(s); 1427 return DCT3_AnswerAllCalls(s);
1419} 1428}
1420 1429
1421GSM_Error N7110_SetCallDivert(GSM_StateMachine *s, GSM_MultiCallDivert *divert) 1430GSM_Error N7110_SetCallDivert(GSM_StateMachine *s, GSM_MultiCallDivert *divert)
1422{ 1431{
1423 GSM_Errorerror; 1432 GSM_Errorerror;
1424 int i; 1433 int i;
1425 1434
1426 /* No answer from phone side */ 1435 /* No answer from phone side */
1427 i = s->ReplyNum; 1436 i = s->ReplyNum;
1428 s->ReplyNum = 1; 1437 s->ReplyNum = 1;
1429 error = DCT3DCT4_SetCallDivert(s,divert); 1438 error = DCT3DCT4_SetCallDivert(s,divert);
1430 s->ReplyNum = i; 1439 s->ReplyNum = i;
1431 return error; 1440 return error;
1432} 1441}
1433 1442
1434GSM_Error N7110_CancelAllDiverts(GSM_StateMachine *s) 1443GSM_Error N7110_CancelAllDiverts(GSM_StateMachine *s)
1435{ 1444{
1436 GSM_Errorerror; 1445 GSM_Errorerror;
1437 int i; 1446 int i;
1438 1447
1439 /* No answer from phone side */ 1448 /* No answer from phone side */
1440 i = s->ReplyNum; 1449 i = s->ReplyNum;
1441 s->ReplyNum = 1; 1450 s->ReplyNum = 1;
1442 error = DCT3DCT4_CancelAllDiverts(s); 1451 error = DCT3DCT4_CancelAllDiverts(s);
1443 s->ReplyNum = i; 1452 s->ReplyNum = i;
1444 return error; 1453 return error;
1445} 1454}
1446 1455
1447static GSM_Reply_Function N7110ReplyFunctions[] = { 1456static GSM_Reply_Function N7110ReplyFunctions[] = {
1448 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame }, 1457 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
1449 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame }, 1458 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
1450 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame }, 1459 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
1451 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame }, 1460 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
1452 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall }, 1461 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
1453 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame }, 1462 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
1454 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall }, 1463 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
1455 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame }, 1464 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
1456 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame }, 1465 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
1457 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame }, 1466 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
1458 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame }, 1467 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
1459 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF }, 1468 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
1460 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame }, 1469 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
1461 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF }, 1470 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
1462 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF }, 1471 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
1463 1472
1464 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame }, 1473 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
1465 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame }, 1474 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
1466 {N7110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame }, 1475 {N7110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
1467#ifdef GSM_ENABLE_CELLBROADCAST 1476#ifdef GSM_ENABLE_CELLBROADCAST
1468 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB }, 1477 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
1469 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB }, 1478 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
1470 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame }, 1479 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
1471#endif 1480#endif
1472 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC }, 1481 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
1473 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC }, 1482 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
1474 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC }, 1483 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
1475#ifdef GSM_ENABLE_CELLBROADCAST 1484#ifdef GSM_ENABLE_CELLBROADCAST
1476 {DCT3_ReplySetIncomingCB, "\x02",0x03,0xCA,ID_SetIncomingCB }, 1485 {DCT3_ReplySetIncomingCB, "\x02",0x03,0xCA,ID_SetIncomingCB },
1477#endif 1486#endif
1478 1487
1479 {N7110_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, 1488 {N7110_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
1480 {N7110_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, 1489 {N7110_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
1481 {N7110_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory }, 1490 {N7110_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
1482 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap }, 1491 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
1483 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory }, 1492 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
1484 1493
1485 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame }, 1494 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
1486 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame }, 1495 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
1487 1496
1488 {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame }, 1497 {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
1489 {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame }, 1498 {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
1490 1499
1491 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo }, 1500 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
1492 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetBitmap }, 1501 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetBitmap },
1493 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame }, 1502 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
1494 {N7110_ReplyGetNetworkInfoError, "\x0A",0x03,0x72,ID_GetNetworkInfo }, 1503 {N7110_ReplyGetNetworkInfoError, "\x0A",0x03,0x72,ID_GetNetworkInfo },
1495 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x73,ID_IncomingFrame }, 1504 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x73,ID_IncomingFrame },
1496 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality }, 1505 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality },
1497 {N7110_ReplySetOperatorLogo, "\x0A",0x03,0xA4,ID_SetBitmap }, 1506 {N7110_ReplySetOperatorLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
1498 {N7110_ReplyClearOperatorLogo, "\x0A",0x03,0xB0,ID_SetBitmap }, 1507 {N7110_ReplyClearOperatorLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
1499 {NoneReply, "\x0A",0x03,0xB5,ID_IncomingFrame }, 1508 {NoneReply, "\x0A",0x03,0xB5,ID_IncomingFrame },
1500 1509
1501#ifdef DEBUG 1510#ifdef DEBUG
1502 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },/*method 1*/ 1511 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },/*method 1*/
1503 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },/*method 1*/ 1512 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },/*method 1*/
1504 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },/*method 1*/ 1513 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },/*method 1*/
1505 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },/*method 1*/ 1514 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },/*method 1*/
1506#endif 1515#endif
1507 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote }, 1516 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
1508 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ 1517 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
1509#ifdef DEBUG 1518#ifdef DEBUG
1510 {N7110_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/ 1519 {N7110_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
1511#endif 1520#endif
1512 {N7110_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ 1521 {N7110_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
1513#ifdef DEBUG 1522#ifdef DEBUG
1514 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },/*method 2*/ 1523 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },/*method 2*/
1515#endif 1524#endif
1516 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/ 1525 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
1517 1526
1518 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage }, 1527 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
1519 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage }, 1528 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
1520 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage }, 1529 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
1521 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetBitmap }, 1530 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetBitmap },
1522 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage }, 1531 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
1523 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage }, 1532 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
1524 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage }, 1533 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
1525 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus }, 1534 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
1526 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus }, 1535 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
1527 {N7110_ReplySetPicture, "\x14",0x03,0x51,ID_SetBitmap }, 1536 {N7110_ReplySetPicture, "\x14",0x03,0x51,ID_SetBitmap },
1528 {N7110_ReplyGetSMSFolderStatus, "\x14",0x03,0x6C,ID_GetSMSFolderStatus }, 1537 {N7110_ReplyGetSMSFolderStatus, "\x14",0x03,0x6C,ID_GetSMSFolderStatus },
1529 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x6F,ID_GetSMSMessage }, 1538 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x6F,ID_GetSMSMessage },
1530 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7B,ID_GetSMSFolders }, 1539 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7B,ID_GetSMSFolders },
1531 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7C,ID_GetSMSFolders }, 1540 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7C,ID_GetSMSFolders },
1532 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x84,ID_SaveSMSMessage }, 1541 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x84,ID_SaveSMSMessage },
1533 {N7110_ReplyGetPictureImageInfo, "\x14",0x03,0x97,ID_GetBitmap }, 1542 {N7110_ReplyGetPictureImageInfo, "\x14",0x03,0x97,ID_GetBitmap },
1534 {N7110_ReplyGetSMSFolders, "\x14",0x03,0xCA,ID_GetSMSFolders }, 1543 {N7110_ReplyGetSMSFolders, "\x14",0x03,0xCA,ID_GetSMSFolders },
1535 1544
1536 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge }, 1545 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge },
1537 1546
1538 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime }, 1547 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
1539 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime }, 1548 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
1540 {DCT3_ReplySetAlarm, "\x19",0x03,0x6C,ID_SetAlarm }, 1549 {DCT3_ReplySetAlarm, "\x19",0x03,0x6C,ID_SetAlarm },
1541 {DCT3_ReplyGetAlarm, "\x19",0x03,0x6E,ID_GetAlarm }, 1550 {DCT3_ReplyGetAlarm, "\x19",0x03,0x6E,ID_GetAlarm },
1542 1551
1543 {N7110_ReplyGetRingtone, "\x1f",0x03,0x23,ID_GetRingtone }, 1552 {N7110_ReplyGetRingtone, "\x1f",0x03,0x23,ID_GetRingtone },
1544 {N7110_ReplyGetRingtone, "\x1f",0x03,0x24,ID_GetRingtone }, 1553 {N7110_ReplyGetRingtone, "\x1f",0x03,0x24,ID_GetRingtone },
1545 1554
1546 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc }, 1555 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc },
1547 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc }, 1556 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
1548 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc }, 1557 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc },
1549 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc }, 1558 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
1550 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark }, 1559 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
1551 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark }, 1560 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
1552 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark }, 1561 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
1553 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark }, 1562 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
1554 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark }, 1563 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
1555 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark }, 1564 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
1556 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet }, 1565 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet },
1557 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet }, 1566 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet },
1558 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet }, 1567 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet },
1559 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet }, 1568 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet },
1560 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet }, 1569 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet },
1561 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet }, 1570 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet },
1562 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet }, 1571 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet },
1563 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet }, 1572 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet },
1564 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet }, 1573 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet },
1565 1574
1566 {N7110_ReplyGetProfileFeature, "\x39",0x03,0x02,ID_GetProfile }, 1575 {N7110_ReplyGetProfileFeature, "\x39",0x03,0x02,ID_GetProfile },
1567 {N7110_ReplySetProfileFeature, "\x39",0x03,0x04,ID_SetProfile }, 1576 {N7110_ReplySetProfileFeature, "\x39",0x03,0x04,ID_SetProfile },
1568 1577
1569 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity }, 1578 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
1570 {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings }, 1579 {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings },
1571 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI }, 1580 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
1572 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice }, 1581 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
1573 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall }, 1582 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
1574 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall }, 1583 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
1575 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor }, 1584 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
1576 {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone }, 1585 {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
1577 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware }, 1586 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
1578 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM }, 1587 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
1579 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode }, 1588 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
1580 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth }, 1589 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth },
1581 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI }, 1590 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
1582 {NoneReply, "\x40",0x02,0xFF,ID_IncomingFrame }, 1591 {NoneReply, "\x40",0x02,0xFF,ID_IncomingFrame },
1583 1592
1584 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap }, 1593 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
1585 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap }, 1594 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
1586 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap }, 1595 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
1587 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap }, 1596 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
1588 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_GetBitmap }, 1597 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_GetBitmap },
1589 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_SetBitmap }, 1598 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_SetBitmap },
1590 1599
1591 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, 1600 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
1592 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, 1601 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
1593 {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey }, 1602 {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
1594 {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey }, 1603 {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
1595 1604
1596 {NULL, "\x00",0x00,0x00,ID_None } 1605 {NULL, "\x00",0x00,0x00,ID_None }
1597}; 1606};
1598 1607
1599GSM_Phone_Functions N7110Phone = { 1608GSM_Phone_Functions N7110Phone = {
1600 "6210|6250|7110|7190", 1609 "6210|6250|7110|7190",
1601 N7110ReplyFunctions, 1610 N7110ReplyFunctions,
1602 N7110_Initialise, 1611 N7110_Initialise,
1603 PHONE_Terminate, 1612 PHONE_Terminate,
1604 GSM_DispatchMessage, 1613 GSM_DispatchMessage,
1605 NOTSUPPORTED, /* ShowStartInfo */ 1614 NOTSUPPORTED, /* ShowStartInfo */
1606 NOKIA_GetManufacturer, 1615 NOKIA_GetManufacturer,
1607 DCT3DCT4_GetModel, 1616 DCT3DCT4_GetModel,
1608 DCT3DCT4_GetFirmware, 1617 DCT3DCT4_GetFirmware,
1609 DCT3_GetIMEI, 1618 DCT3_GetIMEI,
1610 DCT3_GetOriginalIMEI, 1619 DCT3_GetOriginalIMEI,
1611 DCT3_GetManufactureMonth, 1620 DCT3_GetManufactureMonth,
1612 DCT3_GetProductCode, 1621 DCT3_GetProductCode,
1613 DCT3_GetHardware, 1622 DCT3_GetHardware,
1614 DCT3_GetPPM, 1623 DCT3_GetPPM,
1615 NOTSUPPORTED, /* GetSIMIMSI */ 1624 NOTSUPPORTED, /* GetSIMIMSI */
1616 N71_92_GetDateTime, 1625 N71_92_GetDateTime,
1617 N71_92_SetDateTime, 1626 N71_92_SetDateTime,
1618 N7110_GetAlarm, 1627 N7110_GetAlarm,
1619 N7110_SetAlarm, 1628 N7110_SetAlarm,
1620 NOTSUPPORTED, /* GetLocale */ 1629 NOTSUPPORTED, /* GetLocale */
1621 NOTSUPPORTED, /* SetLocale */ 1630 NOTSUPPORTED, /* SetLocale */
1622 DCT3_PressKey, 1631 DCT3_PressKey,
1623 DCT3_Reset, 1632 DCT3_Reset,
1624 N61_71_ResetPhoneSettings, 1633 N61_71_ResetPhoneSettings,
1625 NOTSUPPORTED, /* EnterSecurityCode*/ 1634 NOTSUPPORTED, /* EnterSecurityCode*/
1626 NOTSUPPORTED, /* GetSecurityStatus*/ 1635 NOTSUPPORTED, /* GetSecurityStatus*/
1627 NOTSUPPORTED, /* GetDisplayStatus*/ 1636 NOTSUPPORTED, /* GetDisplayStatus*/
1628 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 1637 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
1629 N71_92_GetBatteryCharge, 1638 N71_92_GetBatteryCharge,
1630 N71_92_GetSignalQuality, 1639 N71_92_GetSignalQuality,
1631 DCT3_GetNetworkInfo, 1640 DCT3_GetNetworkInfo,
1632 NOTSUPPORTED, /* GetCategory */ 1641 NOTSUPPORTED, /* GetCategory */
1633 NOTSUPPORTED, /* AddCategory */ 1642 NOTSUPPORTED, /* AddCategory */
1634 NOTSUPPORTED, /* GetCategoryStatus */ 1643 NOTSUPPORTED, /* GetCategoryStatus */
1635 N7110_GetMemoryStatus, 1644 N7110_GetMemoryStatus,
1636 N7110_GetMemory, 1645 N7110_GetMemory,
1637 NOTIMPLEMENTED, /* GetNextMemory */ 1646 NOTIMPLEMENTED, /* GetNextMemory */
1638 N7110_SetMemory, 1647 N7110_SetMemory,
1639 NOTIMPLEMENTED, /* AddMemory */ 1648 NOTIMPLEMENTED, /* AddMemory */
1640 N7110_DeleteMemory, 1649 N7110_DeleteMemory,
1641 NOTIMPLEMENTED, /* DeleteAllMemory */ 1650 NOTIMPLEMENTED, /* DeleteAllMemory */
1642 N7110_GetSpeedDial, 1651 N7110_GetSpeedDial,
1643 NOTIMPLEMENTED, /* SetSpeedDial */ 1652 NOTIMPLEMENTED, /* SetSpeedDial */
1644 DCT3_GetSMSC, 1653 DCT3_GetSMSC,
1645 DCT3_SetSMSC, 1654 DCT3_SetSMSC,
1646 N7110_GetSMSStatus, 1655 N7110_GetSMSStatus,
1647 N7110_GetSMSMessage, 1656 N7110_GetSMSMessage,
1648 N7110_GetNextSMSMessage, 1657 N7110_GetNextSMSMessage,
1649 N7110_SetSMS, 1658 N7110_SetSMS,
1650 N7110_AddSMS, 1659 N7110_AddSMS,
1651 N7110_DeleteSMS, 1660 N7110_DeleteSMS,
1652 DCT3_SendSMSMessage, 1661 DCT3_SendSMSMessage,
1653 NOTSUPPORTED, /* SendSavedSMS */ 1662 NOTSUPPORTED, /* SendSavedSMS */
1654 NOTSUPPORTED, /* SetFastSMSSending*/ 1663 NOTSUPPORTED, /* SetFastSMSSending*/
1655 N7110_SetIncomingSMS, 1664 N7110_SetIncomingSMS,
1656 DCT3_SetIncomingCB, 1665 DCT3_SetIncomingCB,
1657 N7110_GetSMSFolders, 1666 N7110_GetSMSFolders,
1658 NOTIMPLEMENTED, /* AddSMSFolder */ 1667 NOTIMPLEMENTED, /* AddSMSFolder */
1659 NOTIMPLEMENTED, /* DeleteSMSFolder */ 1668 NOTIMPLEMENTED, /* DeleteSMSFolder */
1660 DCT3_DialVoice, 1669 DCT3_DialVoice,
1661 N7110_AnswerCall, 1670 N7110_AnswerCall,
1662 DCT3_CancelCall, 1671 DCT3_CancelCall,
1663 NOTIMPLEMENTED, /* HoldCall */ 1672 NOTIMPLEMENTED, /* HoldCall */
1664 NOTIMPLEMENTED, /* UnholdCall */ 1673 NOTIMPLEMENTED, /* UnholdCall */
1665 NOTIMPLEMENTED, /* ConferenceCall */ 1674 NOTIMPLEMENTED, /* ConferenceCall */
1666 NOTIMPLEMENTED, /* SplitCall */ 1675 NOTIMPLEMENTED, /* SplitCall */
1667 NOTIMPLEMENTED, /* TransferCall */ 1676 NOTIMPLEMENTED, /* TransferCall */
1668 NOTIMPLEMENTED, /* SwitchCall */ 1677 NOTIMPLEMENTED, /* SwitchCall */
1669 NOTSUPPORTED, /* GetCallDivert */ 1678 NOTSUPPORTED, /* GetCallDivert */
1670 N7110_SetCallDivert, 1679 N7110_SetCallDivert,
1671 N7110_CancelAllDiverts, 1680 N7110_CancelAllDiverts,
1672 N7110_SetIncomingCall, 1681 N7110_SetIncomingCall,
1673 N7110_SetIncomingUSSD, 1682 N7110_SetIncomingUSSD,
1674 DCT3DCT4_SendDTMF, 1683 DCT3DCT4_SendDTMF,
1675 N7110_GetRingtone, 1684 N7110_GetRingtone,
1676 N7110_SetRingtone, 1685 N7110_SetRingtone,
1677 NOTSUPPORTED, /* GetRingtonesInfo*/ 1686 NOTSUPPORTED, /* GetRingtonesInfo*/
1678 NOTSUPPORTED, /* DeleteUserRingtones*/ 1687 NOTSUPPORTED, /* DeleteUserRingtones*/
1679 DCT3_PlayTone, 1688 DCT3_PlayTone,
1680 DCT3_GetWAPBookmark, 1689 DCT3_GetWAPBookmark,
1681 DCT3_SetWAPBookmark, 1690 DCT3_SetWAPBookmark,
1682 DCT3_DeleteWAPBookmark, 1691 DCT3_DeleteWAPBookmark,
1683 DCT3_GetWAPSettings, 1692 DCT3_GetWAPSettings,
1684 DCT3_SetWAPSettings, 1693 DCT3_SetWAPSettings,
1685 NOTSUPPORTED, /* GetMMSSettings */ 1694 NOTSUPPORTED, /* GetMMSSettings */
1686 NOTSUPPORTED, /* SetMMSSettings */ 1695 NOTSUPPORTED, /* SetMMSSettings */
1687 NOTSUPPORTED, /* GetSyncMLSettings*/ 1696 NOTSUPPORTED, /* GetSyncMLSettings*/
1688 NOTSUPPORTED, /* SetSyncMLSettings*/ 1697 NOTSUPPORTED, /* SetSyncMLSettings*/
1689 NOTSUPPORTED, /* GetChatSettings */ 1698 NOTSUPPORTED, /* GetChatSettings */
1690 NOTSUPPORTED, /* SetChatSettings */ 1699 NOTSUPPORTED, /* SetChatSettings */
1691 N7110_GetBitmap, 1700 N7110_GetBitmap,
1692 N7110_SetBitmap, 1701 N7110_SetBitmap,
1693 NOTSUPPORTED, /* GetToDoStatus */ 1702 NOTSUPPORTED, /* GetToDoStatus */
1694 NOTSUPPORTED, /* GetToDo */ 1703 NOTSUPPORTED, /* GetToDo */
1695 NOTSUPPORTED, /* GetNextToDo */ 1704 NOTSUPPORTED, /* GetNextToDo */
1696 NOTSUPPORTED, /* SetToDo */ 1705 NOTSUPPORTED, /* SetToDo */
1697 NOTSUPPORTED, /* AddToDo */ 1706 NOTSUPPORTED, /* AddToDo */
1698 NOTSUPPORTED, /* DeleteToDo */ 1707 NOTSUPPORTED, /* DeleteToDo */
1699 NOTSUPPORTED, /* DeleteAllToDo */ 1708 NOTSUPPORTED, /* DeleteAllToDo */
1700 N7110_GetCalendarStatus, 1709 N7110_GetCalendarStatus,
1701 NOTIMPLEMENTED, /* GetCalendar */ 1710 NOTIMPLEMENTED, /* GetCalendar */
1702 N7110_GetNextCalendar, 1711 N7110_GetNextCalendar,
1703 NOTIMPLEMENTED, /* SetCalendar */ 1712 NOTIMPLEMENTED, /* SetCalendar */
1704 N7110_AddCalendar, 1713 N7110_AddCalendar,
1705 N71_65_DelCalendar, 1714 N71_65_DelCalendar,
1706 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 1715 NOTIMPLEMENTED, /* DeleteAllCalendar*/
1707 NOTSUPPORTED, /* GetCalendarSettings*/ 1716 NOTSUPPORTED, /* GetCalendarSettings*/
1708 NOTSUPPORTED, /* SetCalendarSettings*/ 1717 NOTSUPPORTED, /* SetCalendarSettings*/
1718 NOTSUPPORTED, /* GetNoteStatus */
1719 NOTSUPPORTED, /* GetNote */
1709 NOTSUPPORTED, /* GetNextNote */ 1720 NOTSUPPORTED, /* GetNextNote */
1721 NOTSUPPORTED, /* SetNote */
1722 NOTSUPPORTED, /* AddNote */
1723 NOTSUPPORTED, /* DeleteNote */
1724 NOTSUPPORTED, /* DeleteAllNotes */
1710 N7110_GetProfile, 1725 N7110_GetProfile,
1711 N7110_SetProfile, 1726 N7110_SetProfile,
1712 NOTSUPPORTED, /* GetFMStation */ 1727 NOTSUPPORTED, /* GetFMStation */
1713 NOTSUPPORTED, /* SetFMStation */ 1728 NOTSUPPORTED, /* SetFMStation */
1714 NOTSUPPORTED, /* ClearFMStations */ 1729 NOTSUPPORTED, /* ClearFMStations */
1715 NOTSUPPORTED, /* GetNextFileFolder*/ 1730 NOTSUPPORTED, /* GetNextFileFolder*/
1716 NOTSUPPORTED, /* GetFilePart */ 1731 NOTSUPPORTED, /* GetFilePart */
1717 NOTSUPPORTED, /* AddFile */ 1732 NOTSUPPORTED, /* AddFile */
1718 NOTSUPPORTED, /* GetFileSystemStatus*/ 1733 NOTSUPPORTED, /* GetFileSystemStatus*/
1719 NOTSUPPORTED, /* DeleteFile */ 1734 NOTSUPPORTED, /* DeleteFile */
1720 NOTSUPPORTED, /* AddFolder */ 1735 NOTSUPPORTED, /* AddFolder */
1721 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 1736 NOTSUPPORTED, /* GetGPRSAccessPoint*/
1722 NOTSUPPORTED /* SetGPRSAccessPoint*/ 1737 NOTSUPPORTED /* SetGPRSAccessPoint*/
1723}; 1738};
1724 1739
1725#endif 1740#endif
1726 1741
1727/* How should editor hadle tabs in this file? Add editor commands here. 1742/* How should editor hadle tabs in this file? Add editor commands here.
1728 * vim: noexpandtab sw=8 ts=8 sts=8: 1743 * vim: noexpandtab sw=8 ts=8 sts=8:
1729 */ 1744 */
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c
index ff71ad3..f535c2a 100644
--- a/gammu/emb/common/phone/nokia/dct3/n9210.c
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.c
@@ -1,397 +1,403 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2 2
3#include "../../../gsmstate.h" 3#include "../../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_NOKIA9210 5#ifdef GSM_ENABLE_NOKIA9210
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9 9
10#include "../../../misc/coding/coding.h" 10#include "../../../misc/coding/coding.h"
11#include "../../../gsmcomon.h" 11#include "../../../gsmcomon.h"
12#include "../../../service/gsmlogo.h" 12#include "../../../service/gsmlogo.h"
13#include "../../pfunc.h" 13#include "../../pfunc.h"
14#include "../nfunc.h" 14#include "../nfunc.h"
15#include "n9210.h" 15#include "n9210.h"
16#include "dct3func.h" 16#include "dct3func.h"
17 17
18static GSM_Error N9210_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 18static GSM_Error N9210_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
19{ 19{
20 unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70}; 20 unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70};
21 21
22 s->Phone.Data.Bitmap=Bitmap; 22 s->Phone.Data.Bitmap=Bitmap;
23 switch (Bitmap->Type) { 23 switch (Bitmap->Type) {
24 case GSM_OperatorLogo: 24 case GSM_OperatorLogo:
25 smprintf(s, "Getting operator logo\n"); 25 smprintf(s, "Getting operator logo\n");
26 /* This is like DCT3_GetNetworkInfo */ 26 /* This is like DCT3_GetNetworkInfo */
27 return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap); 27 return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap);
28 case GSM_StartupLogo: 28 case GSM_StartupLogo:
29 smprintf(s, "Getting startup logo\n"); 29 smprintf(s, "Getting startup logo\n");
30 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15); 30 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15);
31 case GSM_WelcomeNote_Text: 31 case GSM_WelcomeNote_Text:
32 smprintf(s, "Getting welcome note\n"); 32 smprintf(s, "Getting welcome note\n");
33 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02); 33 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02);
34 default: 34 default:
35 break; 35 break;
36 } 36 }
37 return ERR_NOTSUPPORTED; 37 return ERR_NOTSUPPORTED;
38} 38}
39 39
40static GSM_Error N9210_ReplySetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 40static GSM_Error N9210_ReplySetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
41{ 41{
42 smprintf(s, "Operator logo clear/set\n"); 42 smprintf(s, "Operator logo clear/set\n");
43 return ERR_NONE; 43 return ERR_NONE;
44} 44}
45 45
46static GSM_Error N9210_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 46static GSM_Error N9210_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
47{ 47{
48 GSM_Error error; 48 GSM_Error error;
49 GSM_Phone_Bitmap_TypesType; 49 GSM_Phone_Bitmap_TypesType;
50 int Width, Height, i,count=3; 50 int Width, Height, i,count=3;
51 unsigned char req[600] = { N7110_FRAME_HEADER }; 51 unsigned char req[600] = { N7110_FRAME_HEADER };
52 unsigned char reqStartup[1000] = { 52 unsigned char reqStartup[1000] = {
53 N6110_FRAME_HEADER, 0xec, 53 N6110_FRAME_HEADER, 0xec,
54 0x15, /* Startup Logo setting */ 54 0x15, /* Startup Logo setting */
55 0x04, 0x00, 0x00, 0x00, 0x30, 0x00, 55 0x04, 0x00, 0x00, 0x00, 0x30, 0x00,
56 0x02, 0xc0, 0x54, 0x00, 0x03, 0xc0, 56 0x02, 0xc0, 0x54, 0x00, 0x03, 0xc0,
57 0xf8, 0xf8, 0x01, 0x04}; 57 0xf8, 0xf8, 0x01, 0x04};
58 unsigned char reqStartupText[500] = { 58 unsigned char reqStartupText[500] = {
59 N7110_FRAME_HEADER, 0xec, 59 N7110_FRAME_HEADER, 0xec,
60 0x02}; /* Startup Text setting */ 60 0x02}; /* Startup Text setting */
61 unsigned char reqClrOp[] = { 61 unsigned char reqClrOp[] = {
62 N7110_FRAME_HEADER, 0xAF, 62 N7110_FRAME_HEADER, 0xAF,
63 0x02}; /* Number of logo = 0 - 0x04 */ 63 0x02}; /* Number of logo = 0 - 0x04 */
64 64
65 switch (Bitmap->Type) { 65 switch (Bitmap->Type) {
66 case GSM_StartupLogo: 66 case GSM_StartupLogo:
67 if (Bitmap->Location!=1) return ERR_NOTSUPPORTED; 67 if (Bitmap->Location!=1) return ERR_NOTSUPPORTED;
68 Type=GSM_NokiaStartupLogo; 68 Type=GSM_NokiaStartupLogo;
69 PHONE_GetBitmapWidthHeight(Type, &Width, &Height); 69 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
70 PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap); 70 PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap);
71 smprintf(s, "Setting startup logo\n"); 71 smprintf(s, "Setting startup logo\n");
72 return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap); 72 return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
73 case GSM_WelcomeNote_Text: 73 case GSM_WelcomeNote_Text:
74 /* Nokia bug: Unicode text is moved one char to left */ 74 /* Nokia bug: Unicode text is moved one char to left */
75 CopyUnicodeString(reqStartupText + 4, Bitmap->Text); 75 CopyUnicodeString(reqStartupText + 4, Bitmap->Text);
76 reqStartupText[4] = 0x02; 76 reqStartupText[4] = 0x02;
77 i = 5 + UnicodeLength(Bitmap->Text) * 2; 77 i = 5 + UnicodeLength(Bitmap->Text) * 2;
78 reqStartupText[i++] = 0; 78 reqStartupText[i++] = 0;
79 reqStartupText[i++] = 0; 79 reqStartupText[i++] = 0;
80 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap); 80 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
81 case GSM_OperatorLogo: 81 case GSM_OperatorLogo:
82 /* First part for clearing logo */ 82 /* First part for clearing logo */
83 if (!strcmp(Bitmap->NetworkCode,"000 00")) { 83 if (!strcmp(Bitmap->NetworkCode,"000 00")) {
84 for (i=0;i<5;i++) { 84 for (i=0;i<5;i++) {
85 reqClrOp[4] = i; 85 reqClrOp[4] = i;
86 error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap); 86 error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap);
87 if (error != ERR_NONE) return error; 87 if (error != ERR_NONE) return error;
88 } 88 }
89 } 89 }
90 Type=GSM_NokiaOperatorLogo; 90 Type=GSM_NokiaOperatorLogo;
91 req[count++] = 0xA3; 91 req[count++] = 0xA3;
92 req[count++] = 0x01; 92 req[count++] = 0x01;
93 req[count++] = 0x00; /* Logo removed */ 93 req[count++] = 0x00; /* Logo removed */
94 NOKIA_EncodeNetworkCode(req+count, "000 00"); 94 NOKIA_EncodeNetworkCode(req+count, "000 00");
95 count = count + 3; 95 count = count + 3;
96 req[count++] = 0x00; 96 req[count++] = 0x00;
97 req[count++] = 0x04; 97 req[count++] = 0x04;
98 req[count++] = 0x08; /* Length of rest + 2 */ 98 req[count++] = 0x08; /* Length of rest + 2 */
99 memcpy(req+count, "\x00\x00\x00\x00\x00\x00", 6); 99 memcpy(req+count, "\x00\x00\x00\x00\x00\x00", 6);
100 count += 6; 100 count += 6;
101 error=GSM_WaitFor (s, req, count, 0x0A, 4, ID_SetBitmap); 101 error=GSM_WaitFor (s, req, count, 0x0A, 4, ID_SetBitmap);
102 if (error != ERR_NONE) return error; 102 if (error != ERR_NONE) return error;
103 /* We wanted only clear - now exit */ 103 /* We wanted only clear - now exit */
104 if (!strcmp(Bitmap->NetworkCode,"000 00")) return error; 104 if (!strcmp(Bitmap->NetworkCode,"000 00")) return error;
105 105
106 /* Now setting logo */ 106 /* Now setting logo */
107 count=3; 107 count=3;
108 req[count++] = 0xA3; 108 req[count++] = 0xA3;
109 req[count++] = 0x01; 109 req[count++] = 0x01;
110 req[count++] = 0x01; /* Logo set */ 110 req[count++] = 0x01; /* Logo set */
111 NOKIA_EncodeNetworkCode(req+count, Bitmap->NetworkCode); 111 NOKIA_EncodeNetworkCode(req+count, Bitmap->NetworkCode);
112 count = count + 3; 112 count = count + 3;
113 req[count++] = 0x00; 113 req[count++] = 0x00;
114 req[count++] = 0x04; 114 req[count++] = 0x04;
115 req[count++] = PHONE_GetBitmapSize(Type,0,0)+8; 115 req[count++] = PHONE_GetBitmapSize(Type,0,0)+8;
116 PHONE_GetBitmapWidthHeight(Type, &Width, &Height); 116 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
117 req[count++] = Width; 117 req[count++] = Width;
118 req[count++] = Height; 118 req[count++] = Height;
119 req[count++] = PHONE_GetBitmapSize(Type,0,0); 119 req[count++] = PHONE_GetBitmapSize(Type,0,0);
120 req[count++] = 0x00; 120 req[count++] = 0x00;
121 req[count++] = 0x00; 121 req[count++] = 0x00;
122 req[count++] = 0x00; 122 req[count++] = 0x00;
123 PHONE_EncodeBitmap(Type, req+count, Bitmap); 123 PHONE_EncodeBitmap(Type, req+count, Bitmap);
124 return GSM_WaitFor (s, req, count+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap); 124 return GSM_WaitFor (s, req, count+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap);
125 default: 125 default:
126 break; 126 break;
127 } 127 }
128 return ERR_NOTSUPPORTED; 128 return ERR_NOTSUPPORTED;
129} 129}
130 130
131static GSM_Error N9210_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) 131static GSM_Error N9210_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
132{ 132{
133 GSM_SMSMessage sms; 133 GSM_SMSMessage sms;
134 GSM_Phone_Data *Data = &s->Phone.Data; 134 GSM_Phone_Data *Data = &s->Phone.Data;
135 135
136#ifdef DEBUG 136#ifdef DEBUG
137 smprintf(s, "SMS message received\n"); 137 smprintf(s, "SMS message received\n");
138 sms.State = SMS_UnRead; 138 sms.State = SMS_UnRead;
139 sms.InboxFolder = true; 139 sms.InboxFolder = true;
140 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5); 140 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5);
141#endif 141#endif
142 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) { 142 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
143 sms.State = SMS_UnRead; 143 sms.State = SMS_UnRead;
144 sms.InboxFolder = true; 144 sms.InboxFolder = true;
145 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5); 145 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+5);
146 146
147 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 147 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
148 } 148 }
149 return ERR_NONE; 149 return ERR_NONE;
150} 150}
151 151
152#ifdef GSM_ENABLE_N71_92INCOMINGINFO 152#ifdef GSM_ENABLE_N71_92INCOMINGINFO
153static GSM_Error N9210_ReplySetIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) 153static GSM_Error N9210_ReplySetIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
154{ 154{
155 switch (msg.Buffer[3]) { 155 switch (msg.Buffer[3]) {
156 case 0x0e: 156 case 0x0e:
157 s->Phone.Data.EnableIncomingSMS = true; 157 s->Phone.Data.EnableIncomingSMS = true;
158 smprintf(s, "Incoming SMS enabled\n"); 158 smprintf(s, "Incoming SMS enabled\n");
159 return ERR_NONE; 159 return ERR_NONE;
160 case 0x0f: 160 case 0x0f:
161 smprintf(s, "Error enabling incoming SMS\n"); 161 smprintf(s, "Error enabling incoming SMS\n");
162 switch (msg.Buffer[4]) { 162 switch (msg.Buffer[4]) {
163 case 0x0c: 163 case 0x0c:
164 smprintf(s, "No PIN ?\n"); 164 smprintf(s, "No PIN ?\n");
165 return ERR_SECURITYERROR; 165 return ERR_SECURITYERROR;
166 default: 166 default:
167 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 167 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
168 } 168 }
169 } 169 }
170 return ERR_UNKNOWNRESPONSE; 170 return ERR_UNKNOWNRESPONSE;
171} 171}
172#endif 172#endif
173 173
174static GSM_Error N9210_SetIncomingSMS(GSM_StateMachine *s, bool enable) 174static GSM_Error N9210_SetIncomingSMS(GSM_StateMachine *s, bool enable)
175{ 175{
176#ifdef GSM_ENABLE_N71_92INCOMINGINFO 176#ifdef GSM_ENABLE_N71_92INCOMINGINFO
177 unsigned char req[] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x02}; 177 unsigned char req[] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x02};
178 178
179 if (enable!=s->Phone.Data.EnableIncomingSMS) { 179 if (enable!=s->Phone.Data.EnableIncomingSMS) {
180 if (enable) { 180 if (enable) {
181 smprintf(s, "Enabling incoming SMS\n"); 181 smprintf(s, "Enabling incoming SMS\n");
182 return GSM_WaitFor (s, req, 7, 0x02, 4, ID_SetIncomingSMS); 182 return GSM_WaitFor (s, req, 7, 0x02, 4, ID_SetIncomingSMS);
183 } else { 183 } else {
184 s->Phone.Data.EnableIncomingSMS = false; 184 s->Phone.Data.EnableIncomingSMS = false;
185 smprintf(s, "Disabling incoming SMS\n"); 185 smprintf(s, "Disabling incoming SMS\n");
186 } 186 }
187 } 187 }
188 return ERR_NONE; 188 return ERR_NONE;
189#else 189#else
190 return ERR_SOURCENOTAVAILABLE; 190 return ERR_SOURCENOTAVAILABLE;
191#endif 191#endif
192} 192}
193 193
194static GSM_Error N9210_Initialise (GSM_StateMachine *s) 194static GSM_Error N9210_Initialise (GSM_StateMachine *s)
195{ 195{
196#ifdef DEBUG 196#ifdef DEBUG
197 DCT3_SetIncomingCB(s,true); 197 DCT3_SetIncomingCB(s,true);
198 198
199#ifdef GSM_ENABLE_N71_92INCOMINGINFO 199#ifdef GSM_ENABLE_N71_92INCOMINGINFO
200 N9210_SetIncomingSMS(s,true); 200 N9210_SetIncomingSMS(s,true);
201#endif 201#endif
202 202
203#endif 203#endif
204 return ERR_NONE; 204 return ERR_NONE;
205} 205}
206 206
207GSM_Error N9210_AnswerCall(GSM_StateMachine *s, int ID, bool all) 207GSM_Error N9210_AnswerCall(GSM_StateMachine *s, int ID, bool all)
208{ 208{
209 if (!all) return DCT3DCT4_AnswerCall(s,ID); 209 if (!all) return DCT3DCT4_AnswerCall(s,ID);
210 return DCT3_AnswerAllCalls(s); 210 return DCT3_AnswerAllCalls(s);
211} 211}
212 212
213static GSM_Reply_Function N9210ReplyFunctions[] = { 213static GSM_Reply_Function N9210ReplyFunctions[] = {
214 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame}, 214 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame},
215 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame}, 215 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame},
216#ifdef GSM_ENABLE_N71_92INCOMINGINFO 216#ifdef GSM_ENABLE_N71_92INCOMINGINFO
217 {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0E,ID_SetIncomingSMS}, 217 {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0E,ID_SetIncomingSMS},
218 {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0F,ID_SetIncomingSMS}, 218 {N9210_ReplySetIncomingSMS, "\x02",0x03,0x0F,ID_SetIncomingSMS},
219#endif 219#endif
220 {N9210_ReplyIncomingSMS, "\x02",0x03,0x11,ID_IncomingFrame}, 220 {N9210_ReplyIncomingSMS, "\x02",0x03,0x11,ID_IncomingFrame},
221#ifdef GSM_ENABLE_CELLBROADCAST 221#ifdef GSM_ENABLE_CELLBROADCAST
222 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB}, 222 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB},
223 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB}, 223 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB},
224 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame}, 224 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame},
225#endif 225#endif
226 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC }, 226 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
227 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC }, 227 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
228 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC }, 228 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
229 229
230 {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap }, 230 {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap },
231 {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap }, 231 {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap },
232 232
233 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo}, 233 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo},
234 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame}, 234 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame},
235 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality}, 235 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality},
236 {N9210_ReplySetOpLogo, "\x0A",0x03,0xA4,ID_SetBitmap }, 236 {N9210_ReplySetOpLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
237 {N9210_ReplySetOpLogo, "\x0A",0x03,0xB0,ID_SetBitmap }, 237 {N9210_ReplySetOpLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
238 238
239 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge}, 239 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge},
240 240
241 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime }, 241 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
242 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime }, 242 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
243 243
244 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity}, 244 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity},
245 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI }, 245 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
246 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice }, 246 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
247 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall }, 247 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
248 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall }, 248 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
249 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor }, 249 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
250 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware }, 250 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
251 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM }, 251 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
252 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode}, 252 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode},
253 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth}, 253 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth},
254 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI}, 254 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI},
255 255
256 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap }, 256 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
257 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap }, 257 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
258 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap }, 258 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
259 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap }, 259 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
260 260
261 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel }, 261 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel },
262 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware }, 262 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware },
263 263
264 {NULL, "\x00",0x00,0x00,ID_None } 264 {NULL, "\x00",0x00,0x00,ID_None }
265}; 265};
266 266
267GSM_Phone_Functions N9210Phone = { 267GSM_Phone_Functions N9210Phone = {
268 "9210|9210i", 268 "9210|9210i",
269 N9210ReplyFunctions, 269 N9210ReplyFunctions,
270 N9210_Initialise, 270 N9210_Initialise,
271 PHONE_Terminate, 271 PHONE_Terminate,
272 GSM_DispatchMessage, 272 GSM_DispatchMessage,
273 NOTSUPPORTED, /* ShowStartInfo */ 273 NOTSUPPORTED, /* ShowStartInfo */
274 NOKIA_GetManufacturer, 274 NOKIA_GetManufacturer,
275 DCT3DCT4_GetModel, 275 DCT3DCT4_GetModel,
276 DCT3DCT4_GetFirmware, 276 DCT3DCT4_GetFirmware,
277 DCT3_GetIMEI, 277 DCT3_GetIMEI,
278 DCT3_GetOriginalIMEI, 278 DCT3_GetOriginalIMEI,
279 DCT3_GetManufactureMonth, 279 DCT3_GetManufactureMonth,
280 DCT3_GetProductCode, 280 DCT3_GetProductCode,
281 DCT3_GetHardware, 281 DCT3_GetHardware,
282 DCT3_GetPPM, 282 DCT3_GetPPM,
283 NOTSUPPORTED, /* GetSIMIMSI */ 283 NOTSUPPORTED, /* GetSIMIMSI */
284 N71_92_GetDateTime, 284 N71_92_GetDateTime,
285 N71_92_SetDateTime, 285 N71_92_SetDateTime,
286 NOTIMPLEMENTED, /* GetAlarm */ 286 NOTIMPLEMENTED, /* GetAlarm */
287 NOTIMPLEMENTED, /* SetAlarm */ 287 NOTIMPLEMENTED, /* SetAlarm */
288 NOTSUPPORTED, /* GetLocale */ 288 NOTSUPPORTED, /* GetLocale */
289 NOTSUPPORTED, /* SetLocale */ 289 NOTSUPPORTED, /* SetLocale */
290 NOTIMPLEMENTED, /* PressKey */ 290 NOTIMPLEMENTED, /* PressKey */
291 NOTIMPLEMENTED, /* Reset */ 291 NOTIMPLEMENTED, /* Reset */
292 NOTIMPLEMENTED, /* ResetPhoneSettings*/ 292 NOTIMPLEMENTED, /* ResetPhoneSettings*/
293 NOTSUPPORTED, /* EnterSecurityCode*/ 293 NOTSUPPORTED, /* EnterSecurityCode*/
294 NOTSUPPORTED, /* GetSecurityStatus*/ 294 NOTSUPPORTED, /* GetSecurityStatus*/
295 NOTSUPPORTED, /* GetDisplayStatus*/ 295 NOTSUPPORTED, /* GetDisplayStatus*/
296 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 296 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
297 N71_92_GetBatteryCharge, 297 N71_92_GetBatteryCharge,
298 N71_92_GetSignalQuality, 298 N71_92_GetSignalQuality,
299 DCT3_GetNetworkInfo, 299 DCT3_GetNetworkInfo,
300 NOTSUPPORTED, /* GetCategory */ 300 NOTSUPPORTED, /* GetCategory */
301 NOTSUPPORTED, /* AddCategory */ 301 NOTSUPPORTED, /* AddCategory */
302 NOTSUPPORTED, /* GetCategoryStatus */ 302 NOTSUPPORTED, /* GetCategoryStatus */
303 NOTIMPLEMENTED, /* GetMemoryStatus */ 303 NOTIMPLEMENTED, /* GetMemoryStatus */
304 NOTIMPLEMENTED, /* GetMemory */ 304 NOTIMPLEMENTED, /* GetMemory */
305 NOTIMPLEMENTED, /* GetNextMemory */ 305 NOTIMPLEMENTED, /* GetNextMemory */
306 NOTIMPLEMENTED, /* SetMemory */ 306 NOTIMPLEMENTED, /* SetMemory */
307 NOTIMPLEMENTED, /* AddMemory */ 307 NOTIMPLEMENTED, /* AddMemory */
308 NOTIMPLEMENTED, /* DeleteMemory */ 308 NOTIMPLEMENTED, /* DeleteMemory */
309 NOTIMPLEMENTED, /* DeleteAllMemory */ 309 NOTIMPLEMENTED, /* DeleteAllMemory */
310 NOTIMPLEMENTED, /* GetSpeedDial */ 310 NOTIMPLEMENTED, /* GetSpeedDial */
311 NOTIMPLEMENTED, /* SetSpeedDial */ 311 NOTIMPLEMENTED, /* SetSpeedDial */
312 DCT3_GetSMSC, 312 DCT3_GetSMSC,
313 DCT3_SetSMSC, /* FIXME: test it */ 313 DCT3_SetSMSC, /* FIXME: test it */
314 NOTIMPLEMENTED, /* GetSMSStatus */ 314 NOTIMPLEMENTED, /* GetSMSStatus */
315 NOTIMPLEMENTED, /* GetSMS */ 315 NOTIMPLEMENTED, /* GetSMS */
316 NOTIMPLEMENTED, /* GetNextSMS */ 316 NOTIMPLEMENTED, /* GetNextSMS */
317 NOTIMPLEMENTED, /* SetSMS */ 317 NOTIMPLEMENTED, /* SetSMS */
318 NOTIMPLEMENTED, /* AddSMS */ 318 NOTIMPLEMENTED, /* AddSMS */
319 NOTIMPLEMENTED, /* DeleteSMS */ 319 NOTIMPLEMENTED, /* DeleteSMS */
320 DCT3_SendSMSMessage, 320 DCT3_SendSMSMessage,
321 NOTSUPPORTED, /* SendSavedSMS */ 321 NOTSUPPORTED, /* SendSavedSMS */
322 NOTSUPPORTED, /* SetFastSMSSending*/ 322 NOTSUPPORTED, /* SetFastSMSSending*/
323 N9210_SetIncomingSMS, 323 N9210_SetIncomingSMS,
324 DCT3_SetIncomingCB, 324 DCT3_SetIncomingCB,
325 NOTIMPLEMENTED, /* GetSMSFolders */ 325 NOTIMPLEMENTED, /* GetSMSFolders */
326 NOTSUPPORTED, /* AddSMSFolder */ 326 NOTSUPPORTED, /* AddSMSFolder */
327 NOTSUPPORTED, /* DeleteSMSFolder */ 327 NOTSUPPORTED, /* DeleteSMSFolder */
328 DCT3_DialVoice, 328 DCT3_DialVoice,
329 N9210_AnswerCall, 329 N9210_AnswerCall,
330 DCT3_CancelCall, 330 DCT3_CancelCall,
331 NOTSUPPORTED, /* HoldCall */ 331 NOTSUPPORTED, /* HoldCall */
332 NOTSUPPORTED, /* UnholdCall */ 332 NOTSUPPORTED, /* UnholdCall */
333 NOTSUPPORTED, /* ConferenceCall */ 333 NOTSUPPORTED, /* ConferenceCall */
334 NOTSUPPORTED, /* SplitCall */ 334 NOTSUPPORTED, /* SplitCall */
335 NOTSUPPORTED, /* TransferCall */ 335 NOTSUPPORTED, /* TransferCall */
336 NOTSUPPORTED, /* SwitchCall */ 336 NOTSUPPORTED, /* SwitchCall */
337 NOTSUPPORTED, /* GetCallDivert */ 337 NOTSUPPORTED, /* GetCallDivert */
338 NOTSUPPORTED, /* SetCallDivert */ 338 NOTSUPPORTED, /* SetCallDivert */
339 NOTSUPPORTED, /* CancelAllDiverts*/ 339 NOTSUPPORTED, /* CancelAllDiverts*/
340 NOTSUPPORTED, /* SetIncomingCall */ 340 NOTSUPPORTED, /* SetIncomingCall */
341 NOTIMPLEMENTED, /* SetIncomingUSSD */ 341 NOTIMPLEMENTED, /* SetIncomingUSSD */
342 NOTSUPPORTED, /* SendDTMF */ 342 NOTSUPPORTED, /* SendDTMF */
343 NOTIMPLEMENTED, /* GetRingtone */ 343 NOTIMPLEMENTED, /* GetRingtone */
344 NOTIMPLEMENTED, /* SetRingtone */ 344 NOTIMPLEMENTED, /* SetRingtone */
345 NOTSUPPORTED, /* GetRingtonesInfo*/ 345 NOTSUPPORTED, /* GetRingtonesInfo*/
346 NOTSUPPORTED, /* DeleteUserRingtones*/ 346 NOTSUPPORTED, /* DeleteUserRingtones*/
347 NOTSUPPORTED, /* PlayTone */ 347 NOTSUPPORTED, /* PlayTone */
348 NOTIMPLEMENTED, /* GetWAPBookmark */ 348 NOTIMPLEMENTED, /* GetWAPBookmark */
349 NOTIMPLEMENTED, /* SetWAPBookmark */ 349 NOTIMPLEMENTED, /* SetWAPBookmark */
350 NOTIMPLEMENTED, /* DeleteWAPBookmark */ 350 NOTIMPLEMENTED, /* DeleteWAPBookmark */
351 NOTIMPLEMENTED, /* GetWAPSettings */ 351 NOTIMPLEMENTED, /* GetWAPSettings */
352 NOTSUPPORTED, /* SetWAPSettings */ 352 NOTSUPPORTED, /* SetWAPSettings */
353 NOTSUPPORTED, /* GetMMSSettings */ 353 NOTSUPPORTED, /* GetMMSSettings */
354 NOTSUPPORTED, /* SetMMSSettings */ 354 NOTSUPPORTED, /* SetMMSSettings */
355 NOTSUPPORTED, /* GetSyncMLSettings*/ 355 NOTSUPPORTED, /* GetSyncMLSettings*/
356 NOTSUPPORTED, /* SetSyncMLSettings*/ 356 NOTSUPPORTED, /* SetSyncMLSettings*/
357 NOTSUPPORTED, /* GetChatSettings */ 357 NOTSUPPORTED, /* GetChatSettings */
358 NOTSUPPORTED, /* SetChatSettings */ 358 NOTSUPPORTED, /* SetChatSettings */
359 N9210_GetBitmap, 359 N9210_GetBitmap,
360 N9210_SetBitmap, 360 N9210_SetBitmap,
361 NOTSUPPORTED, /* GetToDoStatus */ 361 NOTSUPPORTED, /* GetToDoStatus */
362 NOTSUPPORTED, /* GetToDo */ 362 NOTSUPPORTED, /* GetToDo */
363 NOTSUPPORTED, /* GetNextToDo */ 363 NOTSUPPORTED, /* GetNextToDo */
364 NOTSUPPORTED, /* SetToDo */ 364 NOTSUPPORTED, /* SetToDo */
365 NOTSUPPORTED, /* AddToDo */ 365 NOTSUPPORTED, /* AddToDo */
366 NOTSUPPORTED, /* DeleteToDo */ 366 NOTSUPPORTED, /* DeleteToDo */
367 NOTSUPPORTED, /* DeleteAllToDo */ 367 NOTSUPPORTED, /* DeleteAllToDo */
368 NOTSUPPORTED, /* GetCalendarStatus*/ 368 NOTSUPPORTED, /* GetCalendarStatus*/
369 NOTSUPPORTED, /* GetCalendar */ 369 NOTSUPPORTED, /* GetCalendar */
370 NOTSUPPORTED, /* GetNextCalendar */ 370 NOTSUPPORTED, /* GetNextCalendar */
371 NOTSUPPORTED, /* SetCalendar */ 371 NOTSUPPORTED, /* SetCalendar */
372 NOTSUPPORTED, /* AddCalendar */ 372 NOTSUPPORTED, /* AddCalendar */
373 NOTSUPPORTED, /* DeleteCalendar */ 373 NOTSUPPORTED, /* DeleteCalendar */
374 NOTSUPPORTED, /* DeleteAllCalendar*/ 374 NOTSUPPORTED, /* DeleteAllCalendar*/
375 NOTSUPPORTED, /* GetCalendarSettings*/ 375 NOTSUPPORTED, /* GetCalendarSettings*/
376 NOTSUPPORTED, /* SetCalendarSettings*/ 376 NOTSUPPORTED, /* SetCalendarSettings*/
377 NOTSUPPORTED, /* GetNoteStatus */
378 NOTSUPPORTED, /* GetNote */
377 NOTSUPPORTED, /* GetNextNote */ 379 NOTSUPPORTED, /* GetNextNote */
380 NOTSUPPORTED, /* SetNote */
381 NOTSUPPORTED, /* AddNote */
382 NOTSUPPORTED, /* DeleteNote */
383 NOTSUPPORTED, /* DeleteAllNotes */
378 NOTIMPLEMENTED, /* GetProfile */ 384 NOTIMPLEMENTED, /* GetProfile */
379 NOTSUPPORTED, /* SetProfile */ 385 NOTSUPPORTED, /* SetProfile */
380 NOTSUPPORTED, /* GetFMStation */ 386 NOTSUPPORTED, /* GetFMStation */
381 NOTSUPPORTED, /* SetFMStation */ 387 NOTSUPPORTED, /* SetFMStation */
382 NOTSUPPORTED, /* ClearFMStations */ 388 NOTSUPPORTED, /* ClearFMStations */
383 NOTSUPPORTED, /* GetNextFileFolder*/ 389 NOTSUPPORTED, /* GetNextFileFolder*/
384 NOTSUPPORTED, /* GetFilePart */ 390 NOTSUPPORTED, /* GetFilePart */
385 NOTSUPPORTED, /* AddFile */ 391 NOTSUPPORTED, /* AddFile */
386 NOTSUPPORTED, /* GetFileSystemStatus*/ 392 NOTSUPPORTED, /* GetFileSystemStatus*/
387 NOTSUPPORTED, /* DeleteFile */ 393 NOTSUPPORTED, /* DeleteFile */
388 NOTSUPPORTED, /* AddFolder */ 394 NOTSUPPORTED, /* AddFolder */
389 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 395 NOTSUPPORTED, /* GetGPRSAccessPoint*/
390 NOTSUPPORTED /* SetGPRSAccessPoint*/ 396 NOTSUPPORTED /* SetGPRSAccessPoint*/
391}; 397};
392 398
393#endif 399#endif
394 400
395/* How should editor hadle tabs in this file? Add editor commands here. 401/* How should editor hadle tabs in this file? Add editor commands here.
396 * vim: noexpandtab sw=8 ts=8 sts=8: 402 * vim: noexpandtab sw=8 ts=8 sts=8:
397 */ 403 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3320.c b/gammu/emb/common/phone/nokia/dct4/n3320.c
index 9b1d6cd..9dd9ffb 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3320.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3320.c
@@ -1,272 +1,278 @@
1/* (c) 2004 by Marcin Wiacek */ 1/* (c) 2004 by Marcin Wiacek */
2 2
3#include "../../../gsmstate.h" 3#include "../../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_NOKIA3320 5#ifdef GSM_ENABLE_NOKIA3320
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9 9
10#include "../../../gsmcomon.h" 10#include "../../../gsmcomon.h"
11#include "../../../misc/coding/coding.h" 11#include "../../../misc/coding/coding.h"
12#include "../../../service/gsmlogo.h" 12#include "../../../service/gsmlogo.h"
13#include "../nfunc.h" 13#include "../nfunc.h"
14#include "../nfuncold.h" 14#include "../nfuncold.h"
15#include "../../pfunc.h" 15#include "../../pfunc.h"
16#include "n3320.h" 16#include "n3320.h"
17 17
18static GSM_Error N3320_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 18static GSM_Error N3320_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
19{ 19{
20 smprintf(s, "Phonebook entry received\n"); 20 smprintf(s, "Phonebook entry received\n");
21 switch (msg.Buffer[6]) { 21 switch (msg.Buffer[6]) {
22 case 0x0f: 22 case 0x0f:
23 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); 23 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
24 default: 24 default:
25 return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,true); 25 return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,true);
26 } 26 }
27 return ERR_UNKNOWN; 27 return ERR_UNKNOWN;
28} 28}
29 29
30static GSM_Error N3320_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) 30static GSM_Error N3320_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
31{ 31{
32 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 32 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
33 0xfe, 0x10, /* memory type */ 33 0xfe, 0x10, /* memory type */
34 0x00, 0x00, 0x00, 0x00, 34 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x01, /* location */ 35 0x00, 0x01, /* location */
36 0x00, 0x00, 0x01}; 36 0x00, 0x00, 0x01};
37 37
38 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 38 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
39 if (entry->MemoryType == MEM_SM) return ERR_NOTSUPPORTED; 39 if (entry->MemoryType == MEM_SM) return ERR_NOTSUPPORTED;
40 if (req[9]==0xff) return ERR_NOTSUPPORTED; 40 if (req[9]==0xff) return ERR_NOTSUPPORTED;
41 41
42 if (entry->Location==0x00) return ERR_INVALIDLOCATION; 42 if (entry->Location==0x00) return ERR_INVALIDLOCATION;
43 43
44 req[14] = entry->Location / 256; 44 req[14] = entry->Location / 256;
45 req[15] = entry->Location % 256; 45 req[15] = entry->Location % 256;
46 46
47 s->Phone.Data.Memory=entry; 47 s->Phone.Data.Memory=entry;
48 smprintf(s, "Getting phonebook entry\n"); 48 smprintf(s, "Getting phonebook entry\n");
49 return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory); 49 return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory);
50} 50}
51 51
52static GSM_Error N3320_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 52static GSM_Error N3320_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
53{ 53{
54 GSM_Phone_Data *Data = &s->Phone.Data; 54 GSM_Phone_Data *Data = &s->Phone.Data;
55 55
56 smprintf(s, "Memory status received\n"); 56 smprintf(s, "Memory status received\n");
57 /* Quess ;-)) */ 57 /* Quess ;-)) */
58 if (msg.Buffer[14]==0x10) { 58 if (msg.Buffer[14]==0x10) {
59 Data->MemoryStatus->MemoryFree = msg.Buffer[18]*256 + msg.Buffer[19]; 59 Data->MemoryStatus->MemoryFree = msg.Buffer[18]*256 + msg.Buffer[19];
60 } else { 60 } else {
61 Data->MemoryStatus->MemoryFree = msg.Buffer[17]; 61 Data->MemoryStatus->MemoryFree = msg.Buffer[17];
62 } 62 }
63 smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree); 63 smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree);
64 Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21]; 64 Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21];
65 smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed); 65 smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed);
66 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; 66 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed;
67 smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree); 67 smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree);
68 return ERR_NONE; 68 return ERR_NONE;
69} 69}
70 70
71static GSM_Error N3320_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) 71static GSM_Error N3320_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
72{ 72{
73 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 73 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
74 0x00, /* memory type */ 74 0x00, /* memory type */
75 0x55, 0x55, 0x55, 0x00}; 75 0x55, 0x55, 0x55, 0x00};
76 76
77 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); 77 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
78 if (Status->MemoryType == MEM_SM) return ERR_NOTSUPPORTED; 78 if (Status->MemoryType == MEM_SM) return ERR_NOTSUPPORTED;
79 if (req[5]==0xff) return ERR_NOTSUPPORTED; 79 if (req[5]==0xff) return ERR_NOTSUPPORTED;
80 80
81 s->Phone.Data.MemoryStatus=Status; 81 s->Phone.Data.MemoryStatus=Status;
82 smprintf(s, "Getting memory status\n"); 82 smprintf(s, "Getting memory status\n");
83 return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus); 83 return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus);
84} 84}
85 85
86static GSM_Error N3320_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s) 86static GSM_Error N3320_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
87{ 87{
88 smprintf(s, "Date & time received\n"); 88 smprintf(s, "Date & time received\n");
89 if (msg.Buffer[4]==0x01) { 89 if (msg.Buffer[4]==0x01) {
90 NOKIA_DecodeDateTime(s, msg.Buffer+10, s->Phone.Data.DateTime); 90 NOKIA_DecodeDateTime(s, msg.Buffer+10, s->Phone.Data.DateTime);
91 return ERR_NONE; 91 return ERR_NONE;
92 } 92 }
93 smprintf(s, "Not set in phone\n"); 93 smprintf(s, "Not set in phone\n");
94 return ERR_EMPTY; 94 return ERR_EMPTY;
95} 95}
96 96
97static GSM_Error N3320_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 97static GSM_Error N3320_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
98{ 98{
99 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x00, 0x00}; 99 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x00, 0x00};
100 100
101 s->Phone.Data.DateTime=date_time; 101 s->Phone.Data.DateTime=date_time;
102 smprintf(s, "Getting date & time\n"); 102 smprintf(s, "Getting date & time\n");
103 return GSM_WaitFor (s, req, 6, 0x19, 4, ID_GetDateTime); 103 return GSM_WaitFor (s, req, 6, 0x19, 4, ID_GetDateTime);
104} 104}
105 105
106static GSM_Error N3320_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 106static GSM_Error N3320_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
107{ 107{
108 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N3320.LastCalendar,&s->Phone.Data.Priv.N3320.LastCalendarYear,&s->Phone.Data.Priv.N3320.LastCalendarPos); 108 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N3320.LastCalendar,&s->Phone.Data.Priv.N3320.LastCalendarYear,&s->Phone.Data.Priv.N3320.LastCalendarPos);
109} 109}
110 110
111static GSM_Error N3320_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 111static GSM_Error N3320_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
112{ 112{
113 GSM_Error error; 113 GSM_Error error;
114 114
115 /* Method 1 */ 115 /* Method 1 */
116 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N3320.LastCalendar); 116 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N3320.LastCalendar);
117 if (error!=ERR_NONE) return error; 117 if (error!=ERR_NONE) return error;
118 Status->Used = s->Phone.Data.Priv.N3320.LastCalendar.Number; 118 Status->Used = s->Phone.Data.Priv.N3320.LastCalendar.Number;
119 return ERR_NONE; 119 return ERR_NONE;
120} 120}
121 121
122static GSM_Error N3320_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 122static GSM_Error N3320_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
123{ 123{
124 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N3320.LastCalendar); 124 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N3320.LastCalendar);
125} 125}
126 126
127static GSM_Reply_Function N3320ReplyFunctions[] = { 127static GSM_Reply_Function N3320ReplyFunctions[] = {
128 {N3320_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, 128 {N3320_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
129 {N3320_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, 129 {N3320_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
130 130
131 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ 131 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
132 {N3320_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ 132 {N3320_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
133 133
134 {N3320_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime }, 134 {N3320_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime },
135 135
136 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, 136 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
137 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, 137 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
138 138
139 {NULL, "\x00",0x00,0x00,ID_None } 139 {NULL, "\x00",0x00,0x00,ID_None }
140}; 140};
141 141
142GSM_Phone_Functions N3320Phone = { 142GSM_Phone_Functions N3320Phone = {
143 "3320", 143 "3320",
144 N3320ReplyFunctions, 144 N3320ReplyFunctions,
145 NONEFUNCTION, /* Initialise */ 145 NONEFUNCTION, /* Initialise */
146 NONEFUNCTION, /* Terminate */ 146 NONEFUNCTION, /* Terminate */
147 GSM_DispatchMessage, 147 GSM_DispatchMessage,
148 NOTSUPPORTED, /* ShowStartInfo */ 148 NOTSUPPORTED, /* ShowStartInfo */
149 NOKIA_GetManufacturer, 149 NOKIA_GetManufacturer,
150 DCT3DCT4_GetModel, 150 DCT3DCT4_GetModel,
151 DCT3DCT4_GetFirmware, 151 DCT3DCT4_GetFirmware,
152 NOTSUPPORTED, /* GetIMEI */ 152 NOTSUPPORTED, /* GetIMEI */
153 NOTSUPPORTED, /* GetOriginalIMEI */ 153 NOTSUPPORTED, /* GetOriginalIMEI */
154 NOTSUPPORTED, /* GetManufactureMonth*/ 154 NOTSUPPORTED, /* GetManufactureMonth*/
155 NOTSUPPORTED, /* GetProductCode */ 155 NOTSUPPORTED, /* GetProductCode */
156 NOTSUPPORTED, /* GetHardware */ 156 NOTSUPPORTED, /* GetHardware */
157 NOTSUPPORTED, /* GetPPM */ 157 NOTSUPPORTED, /* GetPPM */
158 NOTSUPPORTED, /* GetSIMIMSI */ 158 NOTSUPPORTED, /* GetSIMIMSI */
159 N3320_GetDateTime, 159 N3320_GetDateTime,
160 NOTSUPPORTED, /* SetDateTime */ 160 NOTSUPPORTED, /* SetDateTime */
161 NOTSUPPORTED, /* GetAlarm */ 161 NOTSUPPORTED, /* GetAlarm */
162 NOTSUPPORTED, /* SetAlarm */ 162 NOTSUPPORTED, /* SetAlarm */
163 NOTSUPPORTED, /* GetLocale */ 163 NOTSUPPORTED, /* GetLocale */
164 NOTSUPPORTED, /* SetLocale */ 164 NOTSUPPORTED, /* SetLocale */
165 NOTSUPPORTED, /* PressKey */ 165 NOTSUPPORTED, /* PressKey */
166 NOTSUPPORTED, /* Reset */ 166 NOTSUPPORTED, /* Reset */
167 NOTSUPPORTED, /* ResetPhoneSettings*/ 167 NOTSUPPORTED, /* ResetPhoneSettings*/
168 NOTSUPPORTED, /* EnterSecurityCode*/ 168 NOTSUPPORTED, /* EnterSecurityCode*/
169 NOTSUPPORTED, /* GetSecurityStatus*/ 169 NOTSUPPORTED, /* GetSecurityStatus*/
170 NOTSUPPORTED, /* GetDisplayStatus*/ 170 NOTSUPPORTED, /* GetDisplayStatus*/
171 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 171 NOTSUPPORTED, /* SetAutoNetworkLogin*/
172 NOTSUPPORTED, /* GetBatteryCharge*/ 172 NOTSUPPORTED, /* GetBatteryCharge*/
173 NOTSUPPORTED, /* GetSignalQuality*/ 173 NOTSUPPORTED, /* GetSignalQuality*/
174 NOTSUPPORTED, /* GetNetworkInfo */ 174 NOTSUPPORTED, /* GetNetworkInfo */
175 NOTSUPPORTED, /* GetCategory */ 175 NOTSUPPORTED, /* GetCategory */
176 NOTSUPPORTED, /* AddCategory */ 176 NOTSUPPORTED, /* AddCategory */
177 NOTSUPPORTED, /* GetCategoryStatus */ 177 NOTSUPPORTED, /* GetCategoryStatus */
178 N3320_GetMemoryStatus, 178 N3320_GetMemoryStatus,
179 N3320_GetMemory, 179 N3320_GetMemory,
180 NOTSUPPORTED, /* GetNextMemory */ 180 NOTSUPPORTED, /* GetNextMemory */
181 NOTSUPPORTED, /* SetMemory */ 181 NOTSUPPORTED, /* SetMemory */
182 NOTSUPPORTED, /* AddMemory */ 182 NOTSUPPORTED, /* AddMemory */
183 NOTSUPPORTED, /* DeleteMemory */ 183 NOTSUPPORTED, /* DeleteMemory */
184 NOTIMPLEMENTED, /* DeleteAllMemory */ 184 NOTIMPLEMENTED, /* DeleteAllMemory */
185 NOTSUPPORTED, /* GetSpeedDial */ 185 NOTSUPPORTED, /* GetSpeedDial */
186 NOTSUPPORTED, /* SetSpeedDial */ 186 NOTSUPPORTED, /* SetSpeedDial */
187 NOTSUPPORTED, /* GetSMSC */ 187 NOTSUPPORTED, /* GetSMSC */
188 NOTSUPPORTED, /* SetSMSC */ 188 NOTSUPPORTED, /* SetSMSC */
189 NOTSUPPORTED, /* GetSMSStatus */ 189 NOTSUPPORTED, /* GetSMSStatus */
190 NOTSUPPORTED, /* GetSMS */ 190 NOTSUPPORTED, /* GetSMS */
191 NOTSUPPORTED, /* GetNextSMS */ 191 NOTSUPPORTED, /* GetNextSMS */
192 NOTSUPPORTED, /* SetSMS */ 192 NOTSUPPORTED, /* SetSMS */
193 NOTSUPPORTED, /* AddSMS */ 193 NOTSUPPORTED, /* AddSMS */
194 NOTSUPPORTED, /* DeleteSMS */ 194 NOTSUPPORTED, /* DeleteSMS */
195 NOTSUPPORTED, /* SendSMS */ 195 NOTSUPPORTED, /* SendSMS */
196 NOTSUPPORTED, /* SendSavedSMS */ 196 NOTSUPPORTED, /* SendSavedSMS */
197 NOTSUPPORTED, /* SetFastSMSSending*/ 197 NOTSUPPORTED, /* SetFastSMSSending*/
198 NOTSUPPORTED, /* SetIncomingSMS */ 198 NOTSUPPORTED, /* SetIncomingSMS */
199 NOTSUPPORTED, /* SetIncomingCB */ 199 NOTSUPPORTED, /* SetIncomingCB */
200 NOTSUPPORTED, /* GetSMSFolders */ 200 NOTSUPPORTED, /* GetSMSFolders */
201 NOTSUPPORTED, /* AddSMSFolder */ 201 NOTSUPPORTED, /* AddSMSFolder */
202 NOTSUPPORTED, /* DeleteSMSFolder */ 202 NOTSUPPORTED, /* DeleteSMSFolder */
203 NOTIMPLEMENTED, /* DialVoice */ 203 NOTIMPLEMENTED, /* DialVoice */
204 NOTIMPLEMENTED, /* AnswerCall */ 204 NOTIMPLEMENTED, /* AnswerCall */
205 NOTIMPLEMENTED, /* CancelCall */ 205 NOTIMPLEMENTED, /* CancelCall */
206 NOTIMPLEMENTED, /* HoldCall */ 206 NOTIMPLEMENTED, /* HoldCall */
207 NOTIMPLEMENTED, /* UnholdCall */ 207 NOTIMPLEMENTED, /* UnholdCall */
208 NOTIMPLEMENTED, /* ConferenceCall */ 208 NOTIMPLEMENTED, /* ConferenceCall */
209 NOTIMPLEMENTED, /* SplitCall */ 209 NOTIMPLEMENTED, /* SplitCall */
210 NOTIMPLEMENTED, /* TransferCall */ 210 NOTIMPLEMENTED, /* TransferCall */
211 NOTIMPLEMENTED, /* SwitchCall */ 211 NOTIMPLEMENTED, /* SwitchCall */
212 NOTSUPPORTED, /* GetCallDivert */ 212 NOTSUPPORTED, /* GetCallDivert */
213 NOTSUPPORTED, /* SetCallDivert */ 213 NOTSUPPORTED, /* SetCallDivert */
214 NOTSUPPORTED, /* CancelAllDiverts*/ 214 NOTSUPPORTED, /* CancelAllDiverts*/
215 NOTIMPLEMENTED, /* SetIncomingCall */ 215 NOTIMPLEMENTED, /* SetIncomingCall */
216 NOTIMPLEMENTED, /* SetIncomingUSSD */ 216 NOTIMPLEMENTED, /* SetIncomingUSSD */
217 NOTSUPPORTED, /* SendDTMF */ 217 NOTSUPPORTED, /* SendDTMF */
218 NOTSUPPORTED, /* GetRingtone */ 218 NOTSUPPORTED, /* GetRingtone */
219 NOTSUPPORTED, /* SetRingtone */ 219 NOTSUPPORTED, /* SetRingtone */
220 NOTSUPPORTED, /* GetRingtonesInfo*/ 220 NOTSUPPORTED, /* GetRingtonesInfo*/
221 NOTIMPLEMENTED, /* DeleteUserRingtones*/ 221 NOTIMPLEMENTED, /* DeleteUserRingtones*/
222 NOTSUPPORTED, /* PlayTone */ 222 NOTSUPPORTED, /* PlayTone */
223 NOTSUPPORTED, /* GetWAPBookmark */ 223 NOTSUPPORTED, /* GetWAPBookmark */
224 NOTSUPPORTED, /* SetWAPBookmark */ 224 NOTSUPPORTED, /* SetWAPBookmark */
225 NOTSUPPORTED, /* DeleteWAPBookmark */ 225 NOTSUPPORTED, /* DeleteWAPBookmark */
226 NOTSUPPORTED, /* GetWAPSettings */ 226 NOTSUPPORTED, /* GetWAPSettings */
227 NOTSUPPORTED, /* SetWAPSettings */ 227 NOTSUPPORTED, /* SetWAPSettings */
228 NOTSUPPORTED, /* GetMMSSettings */ 228 NOTSUPPORTED, /* GetMMSSettings */
229 NOTSUPPORTED, /* SetMMSSettings */ 229 NOTSUPPORTED, /* SetMMSSettings */
230 NOTSUPPORTED, /* GetSyncMLSettings*/ 230 NOTSUPPORTED, /* GetSyncMLSettings*/
231 NOTSUPPORTED, /* SetSyncMLSettings*/ 231 NOTSUPPORTED, /* SetSyncMLSettings*/
232 NOTSUPPORTED, /* GetChatSettings */ 232 NOTSUPPORTED, /* GetChatSettings */
233 NOTSUPPORTED, /* SetChatSettings */ 233 NOTSUPPORTED, /* SetChatSettings */
234 NOTSUPPORTED, /* GetBitmap */ 234 NOTSUPPORTED, /* GetBitmap */
235 NOTSUPPORTED, /* SetBitmap */ 235 NOTSUPPORTED, /* SetBitmap */
236 NOTSUPPORTED, /* GetToDoStatus */ 236 NOTSUPPORTED, /* GetToDoStatus */
237 NOTSUPPORTED, /* GetToDo */ 237 NOTSUPPORTED, /* GetToDo */
238 NOTSUPPORTED, /* GetNextToDo */ 238 NOTSUPPORTED, /* GetNextToDo */
239 NOTSUPPORTED, /* SetToDo */ 239 NOTSUPPORTED, /* SetToDo */
240 NOTSUPPORTED, /* AddToDo */ 240 NOTSUPPORTED, /* AddToDo */
241 NOTSUPPORTED, /* DeleteToDo */ 241 NOTSUPPORTED, /* DeleteToDo */
242 NOTSUPPORTED, /* DeleteAllToDo */ 242 NOTSUPPORTED, /* DeleteAllToDo */
243 N3320_GetCalendarStatus, 243 N3320_GetCalendarStatus,
244 NOTIMPLEMENTED, /* GetCalendar */ 244 NOTIMPLEMENTED, /* GetCalendar */
245 N3320_GetNextCalendar, 245 N3320_GetNextCalendar,
246 NOTIMPLEMENTED, /* SetCalendar */ 246 NOTIMPLEMENTED, /* SetCalendar */
247 NOTSUPPORTED, /* AddCalendar */ 247 NOTSUPPORTED, /* AddCalendar */
248 NOTSUPPORTED, /* DeleteCalendar */ 248 NOTSUPPORTED, /* DeleteCalendar */
249 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 249 NOTIMPLEMENTED, /* DeleteAllCalendar*/
250 NOTSUPPORTED, /* GetCalendarSettings*/ 250 NOTSUPPORTED, /* GetCalendarSettings*/
251 NOTSUPPORTED, /* SetCalendarSettings*/ 251 NOTSUPPORTED, /* SetCalendarSettings*/
252 NOTSUPPORTED, /* GetNoteStatus */
253 NOTSUPPORTED, /* GetNote */
252 NOTSUPPORTED, /* GetNextNote */ 254 NOTSUPPORTED, /* GetNextNote */
255 NOTSUPPORTED, /* SetNote */
256 NOTSUPPORTED, /* AddNote */
257 NOTSUPPORTED, /* DeleteNote */
258 NOTSUPPORTED, /* DeleteAllNotes */
253 NOTSUPPORTED, /* GetProfile */ 259 NOTSUPPORTED, /* GetProfile */
254 NOTSUPPORTED, /* SetProfile */ 260 NOTSUPPORTED, /* SetProfile */
255 NOTSUPPORTED, /* GetFMStation */ 261 NOTSUPPORTED, /* GetFMStation */
256 NOTSUPPORTED, /* SetFMStation */ 262 NOTSUPPORTED, /* SetFMStation */
257 NOTSUPPORTED, /* ClearFMStations */ 263 NOTSUPPORTED, /* ClearFMStations */
258 NOTSUPPORTED, /* GetNextFileFolder*/ 264 NOTSUPPORTED, /* GetNextFileFolder*/
259 NOTSUPPORTED, /* GetFilePart */ 265 NOTSUPPORTED, /* GetFilePart */
260 NOTIMPLEMENTED, /* AddFilePart */ 266 NOTIMPLEMENTED, /* AddFilePart */
261 NOTSUPPORTED, /* GetFileSystemStatus*/ 267 NOTSUPPORTED, /* GetFileSystemStatus*/
262 NOTIMPLEMENTED, /* DeleteFile */ 268 NOTIMPLEMENTED, /* DeleteFile */
263 NOTIMPLEMENTED, /* AddFolder */ 269 NOTIMPLEMENTED, /* AddFolder */
264 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 270 NOTSUPPORTED, /* GetGPRSAccessPoint*/
265 NOTSUPPORTED /* SetGPRSAccessPoint*/ 271 NOTSUPPORTED /* SetGPRSAccessPoint*/
266}; 272};
267 273
268#endif 274#endif
269 275
270/* How should editor hadle tabs in this file? Add editor commands here. 276/* How should editor hadle tabs in this file? Add editor commands here.
271 * vim: noexpandtab sw=8 ts=8 sts=8: 277 * vim: noexpandtab sw=8 ts=8 sts=8:
272 */ 278 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3650.c b/gammu/emb/common/phone/nokia/dct4/n3650.c
index d4746a7..f1fa826 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3650.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3650.c
@@ -1,393 +1,399 @@
1/* (c) 2003 by Marcin Wiacek */ 1/* (c) 2003 by Marcin Wiacek */
2 2
3#include "../../../gsmstate.h" 3#include "../../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_NOKIA3650 5#ifdef GSM_ENABLE_NOKIA3650
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9 9
10#include "../../../gsmcomon.h" 10#include "../../../gsmcomon.h"
11#include "../../../misc/coding/coding.h" 11#include "../../../misc/coding/coding.h"
12#include "../../../service/gsmlogo.h" 12#include "../../../service/gsmlogo.h"
13#include "../nfunc.h" 13#include "../nfunc.h"
14#include "../nfuncold.h" 14#include "../nfuncold.h"
15#include "../../pfunc.h" 15#include "../../pfunc.h"
16#include "dct4func.h" 16#include "dct4func.h"
17#include "n3650.h" 17#include "n3650.h"
18 18
19static GSM_Error N3650_ReplyGetFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s) 19static GSM_Error N3650_ReplyGetFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s)
20{ 20{
21 int old; 21 int old;
22 22
23 smprintf(s,"File part received\n"); 23 smprintf(s,"File part received\n");
24 old = s->Phone.Data.File->Used; 24 old = s->Phone.Data.File->Used;
25 25
26 if (msg.Length < 10) { 26 if (msg.Length < 10) {
27 if (old == 0) return ERR_UNKNOWN; 27 if (old == 0) return ERR_UNKNOWN;
28 return ERR_EMPTY; 28 return ERR_EMPTY;
29 } 29 }
30 30
31 s->Phone.Data.File->Used += msg.Buffer[10]*256*256*256+ 31 s->Phone.Data.File->Used += msg.Buffer[10]*256*256*256+
32 msg.Buffer[11]*256*256+ 32 msg.Buffer[11]*256*256+
33 msg.Buffer[12]*256+ 33 msg.Buffer[12]*256+
34 msg.Buffer[13]; 34 msg.Buffer[13];
35 smprintf(s,"Length: %i\n", 35 smprintf(s,"Length: %i\n",
36 msg.Buffer[10]*256*256*256+ 36 msg.Buffer[10]*256*256*256+
37 msg.Buffer[11]*256*256+ 37 msg.Buffer[11]*256*256+
38 msg.Buffer[12]*256+ 38 msg.Buffer[12]*256+
39 msg.Buffer[13]); 39 msg.Buffer[13]);
40 s->Phone.Data.File->Buffer = (unsigned char *)realloc(s->Phone.Data.File->Buffer,s->Phone.Data.File->Used); 40 s->Phone.Data.File->Buffer = (unsigned char *)realloc(s->Phone.Data.File->Buffer,s->Phone.Data.File->Used);
41 memcpy(s->Phone.Data.File->Buffer+old,msg.Buffer+18,s->Phone.Data.File->Used-old); 41 memcpy(s->Phone.Data.File->Buffer+old,msg.Buffer+18,s->Phone.Data.File->Used-old);
42 if (s->Phone.Data.File->Used-old < 0x03 * 256 + 0xD4) return ERR_EMPTY; 42 if (s->Phone.Data.File->Used-old < 0x03 * 256 + 0xD4) return ERR_EMPTY;
43 return ERR_NONE; 43 return ERR_NONE;
44} 44}
45 45
46static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File) 46static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File)
47{ 47{
48 unsigned int len=10,i; 48 unsigned int len=10,i;
49 GSM_Error error; 49 GSM_Error error;
50 unsigned char StartReq[500] = { 50 unsigned char StartReq[500] = {
51 N7110_FRAME_HEADER, 0x0D, 0x10, 0x01, 0x07, 51 N7110_FRAME_HEADER, 0x0D, 0x10, 0x01, 0x07,
52 0x24, /* len1 */ 52 0x24, /* len1 */
53 0x12, /* len2 */ 53 0x12, /* len2 */
54 0x0E, /* len3 */ 54 0x0E, /* len3 */
55 0x00}; /* File name */ 55 0x00}; /* File name */
56 unsigned char ContinueReq[] = { 56 unsigned char ContinueReq[] = {
57 N7110_FRAME_HEADER, 0x0D, 0x20, 0x01, 0xF0, 57 N7110_FRAME_HEADER, 0x0D, 0x20, 0x01, 0xF0,
58 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00}; 58 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00};
59 59
60 if (File->Used == 0) { 60 if (File->Used == 0) {
61 sprintf(StartReq+10,"%s",File->ID_FullName); 61 sprintf(StartReq+10,"%s",File->ID_FullName);
62 len+=strlen(File->ID_FullName)-1; 62 len+=strlen(File->ID_FullName)-1;
63 StartReq[7] = strlen(File->ID_FullName) + 3; 63 StartReq[7] = strlen(File->ID_FullName) + 3;
64 64
65 StartReq[8] = strlen(File->ID_FullName); 65 StartReq[8] = strlen(File->ID_FullName);
66 StartReq[9] = 0; 66 StartReq[9] = 0;
67 while (File->ID_FullName[StartReq[8]] != '\\') { 67 while (File->ID_FullName[StartReq[8]] != '\\') {
68 StartReq[8]--; 68 StartReq[8]--;
69 StartReq[9]++; 69 StartReq[9]++;
70 } 70 }
71 for (i=StartReq[8];i<strlen(File->ID_FullName);i++) { 71 for (i=StartReq[8];i<strlen(File->ID_FullName);i++) {
72 StartReq[i+10] = StartReq[i+1+10]; 72 StartReq[i+10] = StartReq[i+1+10];
73 } 73 }
74 StartReq[9]--; 74 StartReq[9]--;
75 75
76 EncodeUnicode(File->Name,File->ID_FullName+StartReq[8]+1,StartReq[9]); 76 EncodeUnicode(File->Name,File->ID_FullName+StartReq[8]+1,StartReq[9]);
77 File->Folder = false; 77 File->Folder = false;
78 78
79 error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST); 79 error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST);
80 if (error != ERR_NONE) return error; 80 if (error != ERR_NONE) return error;
81 81
82 s->Phone.Data.File = File; 82 s->Phone.Data.File = File;
83 return GSM_WaitFor (s, StartReq, len, 0x58, 4, ID_GetFile); 83 return GSM_WaitFor (s, StartReq, len, 0x58, 4, ID_GetFile);
84 } 84 }
85 85
86 s->Phone.Data.File = File; 86 s->Phone.Data.File = File;
87 error = GSM_WaitFor (s, ContinueReq, 14, 0x58, 4, ID_GetFile); 87 error = GSM_WaitFor (s, ContinueReq, 14, 0x58, 4, ID_GetFile);
88 88
89 //if (error == GE_EMPTY) { 89 //if (error == GE_EMPTY) {
90 // error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL); 90 // error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL);
91 // if (error != ERR_NONE) return error; 91 // if (error != ERR_NONE) return error;
92 // return GE_EMPTY; 92 // return GE_EMPTY;
93 //} 93 //}
94 94
95 return error; 95 return error;
96} 96}
97 97
98static GSM_Error N3650_ReplyGetFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 98static GSM_Error N3650_ReplyGetFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
99{ 99{
100 GSM_File *File = s->Phone.Data.FileInfo; 100 GSM_File *File = s->Phone.Data.FileInfo;
101 GSM_Phone_N3650Data*Priv = &s->Phone.Data.Priv.N3650; 101 GSM_Phone_N3650Data*Priv = &s->Phone.Data.Priv.N3650;
102 int i,pos = 6; 102 int i,pos = 6;
103 103
104 i = Priv->FilesLocationsUsed-1; 104 i = Priv->FilesLocationsUsed-1;
105 while (1) { 105 while (1) {
106 if (i==Priv->FilesLocationsCurrent-1) break; 106 if (i==Priv->FilesLocationsCurrent-1) break;
107 dbgprintf("Copying %i to %i, max %i, current %i\n", 107 dbgprintf("Copying %i to %i, max %i, current %i\n",
108 i,i+msg.Buffer[5], 108 i,i+msg.Buffer[5],
109 Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent); 109 Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent);
110 memcpy(Priv->Files[i+msg.Buffer[5]],Priv->Files[i],sizeof(GSM_File)); 110 memcpy(Priv->Files[i+msg.Buffer[5]],Priv->Files[i],sizeof(GSM_File));
111 i--; 111 i--;
112 } 112 }
113 Priv->FileEntries = msg.Buffer[5]; 113 Priv->FileEntries = msg.Buffer[5];
114 Priv->FilesLocationsUsed += msg.Buffer[5]; 114 Priv->FilesLocationsUsed += msg.Buffer[5];
115 for (i=0;i<msg.Buffer[5];i++) { 115 for (i=0;i<msg.Buffer[5];i++) {
116 Priv->Files[Priv->FilesLocationsCurrent+i]->Folder = true; 116 Priv->Files[Priv->FilesLocationsCurrent+i]->Folder = true;
117 if (msg.Buffer[pos+2] == 0x01) { 117 if (msg.Buffer[pos+2] == 0x01) {
118 Priv->Files[Priv->FilesLocationsCurrent+i]->Folder = false; 118 Priv->Files[Priv->FilesLocationsCurrent+i]->Folder = false;
119 smprintf(s,"File "); 119 smprintf(s,"File ");
120 } 120 }
121 EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+i]->Name,msg.Buffer+pos+9,msg.Buffer[pos+8]); 121 EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+i]->Name,msg.Buffer+pos+9,msg.Buffer[pos+8]);
122 smprintf(s,"%s\n",DecodeUnicodeString(Priv->Files[Priv->FilesLocationsCurrent+i]->Name)); 122 smprintf(s,"%s\n",DecodeUnicodeString(Priv->Files[Priv->FilesLocationsCurrent+i]->Name));
123 Priv->Files[Priv->FilesLocationsCurrent+i]->Level = File->Level+1; 123 Priv->Files[Priv->FilesLocationsCurrent+i]->Level = File->Level+1;
124 sprintf(Priv->Files[Priv->FilesLocationsCurrent+i]->ID_FullName,"%s\\%s",File->ID_FullName,msg.Buffer+pos+9); 124 sprintf(Priv->Files[Priv->FilesLocationsCurrent+i]->ID_FullName,"%s\\%s",File->ID_FullName,msg.Buffer+pos+9);
125 pos+=msg.Buffer[pos+1]; 125 pos+=msg.Buffer[pos+1];
126 } 126 }
127 dbgprintf("\n"); 127 dbgprintf("\n");
128 return ERR_NONE; 128 return ERR_NONE;
129} 129}
130 130
131static GSM_Error N3650_GetFolderInfo(GSM_StateMachine *s, GSM_File *File) 131static GSM_Error N3650_GetFolderInfo(GSM_StateMachine *s, GSM_File *File)
132{ 132{
133 int len=10; 133 int len=10;
134 unsigned char req[500] = { 134 unsigned char req[500] = {
135 N7110_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x07, 135 N7110_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x07,
136 0x18, /* folder name length + 6 */ 136 0x18, /* folder name length + 6 */
137 0x12, /* folder name length */ 137 0x12, /* folder name length */
138 0x00, 138 0x00,
139 0x00}; /* folder name */ 139 0x00}; /* folder name */
140 140
141 sprintf(req+10,File->ID_FullName); 141 sprintf(req+10,File->ID_FullName);
142 len +=strlen(File->ID_FullName); 142 len +=strlen(File->ID_FullName);
143 req[7] = strlen(File->ID_FullName) + 6; 143 req[7] = strlen(File->ID_FullName) + 6;
144 req[8] = strlen(File->ID_FullName); 144 req[8] = strlen(File->ID_FullName);
145 req[len++] = 0x00; 145 req[len++] = 0x00;
146 req[len++] = 0x00; 146 req[len++] = 0x00;
147 147
148 s->Phone.Data.FileInfo = File; 148 s->Phone.Data.FileInfo = File;
149 return GSM_WaitFor (s, req, len, 0x58, 4, ID_GetFile); 149 return GSM_WaitFor (s, req, len, 0x58, 4, ID_GetFile);
150} 150}
151 151
152static GSM_Error N3650_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, bool start) 152static GSM_Error N3650_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, bool start)
153{ 153{
154 GSM_Error error; 154 GSM_Error error;
155 GSM_Phone_N3650Data*Priv = &s->Phone.Data.Priv.N3650; 155 GSM_Phone_N3650Data*Priv = &s->Phone.Data.Priv.N3650;
156 156
157 if (start) { 157 if (start) {
158 error = DCT4_SetPhoneMode(s, DCT4_MODE_LOCAL); 158 error = DCT4_SetPhoneMode(s, DCT4_MODE_LOCAL);
159 if (error != ERR_NONE) return error; 159 if (error != ERR_NONE) return error;
160 160
161 Priv->Files[0]->Folder = true; 161 Priv->Files[0]->Folder = true;
162 Priv->Files[0]->Level = 1; 162 Priv->Files[0]->Level = 1;
163 Priv->Files[0]->Name[0] = 0; 163 Priv->Files[0]->Name[0] = 0;
164 Priv->Files[0]->Name[1] = 0; 164 Priv->Files[0]->Name[1] = 0;
165 Priv->Files[0]->ID_FullName[0]= 'Z'; 165 Priv->Files[0]->ID_FullName[0]= 'Z';
166 Priv->Files[0]->ID_FullName[1]= ':'; 166 Priv->Files[0]->ID_FullName[1]= ':';
167 Priv->Files[0]->ID_FullName[2]= 0; 167 Priv->Files[0]->ID_FullName[2]= 0;
168 168
169 Priv->Files[1]->Folder = true; 169 Priv->Files[1]->Folder = true;
170 Priv->Files[1]->Level = 1; 170 Priv->Files[1]->Level = 1;
171 Priv->Files[1]->Name[0] = 0; 171 Priv->Files[1]->Name[0] = 0;
172 Priv->Files[1]->Name[1] = 0; 172 Priv->Files[1]->Name[1] = 0;
173 Priv->Files[1]->ID_FullName[0]= 'E'; 173 Priv->Files[1]->ID_FullName[0]= 'E';
174 Priv->Files[1]->ID_FullName[1]= ':'; 174 Priv->Files[1]->ID_FullName[1]= ':';
175 Priv->Files[1]->ID_FullName[2]= 0; 175 Priv->Files[1]->ID_FullName[2]= 0;
176 176
177 Priv->Files[2]->Folder = true; 177 Priv->Files[2]->Folder = true;
178 Priv->Files[2]->Level = 1; 178 Priv->Files[2]->Level = 1;
179 Priv->Files[2]->Name[0] = 0; 179 Priv->Files[2]->Name[0] = 0;
180 Priv->Files[2]->Name[1] = 0; 180 Priv->Files[2]->Name[1] = 0;
181 Priv->Files[2]->ID_FullName[0]= 'C'; 181 Priv->Files[2]->ID_FullName[0]= 'C';
182 Priv->Files[2]->ID_FullName[1]= ':'; 182 Priv->Files[2]->ID_FullName[1]= ':';
183 Priv->Files[2]->ID_FullName[2]= 0; 183 Priv->Files[2]->ID_FullName[2]= 0;
184 184
185 Priv->FilesLocationsUsed = 3; 185 Priv->FilesLocationsUsed = 3;
186 Priv->FilesLocationsCurrent = 0; 186 Priv->FilesLocationsCurrent = 0;
187 Priv->FileLev = 1; 187 Priv->FileLev = 1;
188 } 188 }
189 189
190 if (Priv->FilesLocationsCurrent == Priv->FilesLocationsUsed) { 190 if (Priv->FilesLocationsCurrent == Priv->FilesLocationsUsed) {
191 // error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL); 191 // error = DCT4_SetPhoneMode(s, DCT4_MODE_NORMAL);
192 // if (error != ERR_NONE) return error; 192 // if (error != ERR_NONE) return error;
193 193
194 return ERR_EMPTY; 194 return ERR_EMPTY;
195 } 195 }
196 196
197 strcpy(File->ID_FullName,Priv->Files[Priv->FilesLocationsCurrent]->ID_FullName); 197 strcpy(File->ID_FullName,Priv->Files[Priv->FilesLocationsCurrent]->ID_FullName);
198 File->Level= Priv->Files[Priv->FilesLocationsCurrent]->Level; 198 File->Level= Priv->Files[Priv->FilesLocationsCurrent]->Level;
199 File->Folder= Priv->Files[Priv->FilesLocationsCurrent]->Folder; 199 File->Folder= Priv->Files[Priv->FilesLocationsCurrent]->Folder;
200 CopyUnicodeString(File->Name,Priv->Files[Priv->FilesLocationsCurrent]->Name); 200 CopyUnicodeString(File->Name,Priv->Files[Priv->FilesLocationsCurrent]->Name);
201 Priv->FilesLocationsCurrent++; 201 Priv->FilesLocationsCurrent++;
202 202
203 if (!File->Folder) return ERR_NONE; 203 if (!File->Folder) return ERR_NONE;
204 204
205 if (Priv->FilesLocationsCurrent > 1) { 205 if (Priv->FilesLocationsCurrent > 1) {
206 if (File->ID_FullName[0]!=Priv->Files[Priv->FilesLocationsCurrent-2]->ID_FullName[0]) { 206 if (File->ID_FullName[0]!=Priv->Files[Priv->FilesLocationsCurrent-2]->ID_FullName[0]) {
207 if (File->ID_FullName[0] == 'E') { 207 if (File->ID_FullName[0] == 'E') {
208 error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST); 208 error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST);
209 error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST); 209 error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST);
210 } 210 }
211 if (File->ID_FullName[0] == 'C') { 211 if (File->ID_FullName[0] == 'C') {
212 error = DCT4_SetPhoneMode(s, DCT4_MODE_LOCAL); 212 error = DCT4_SetPhoneMode(s, DCT4_MODE_LOCAL);
213 error = DCT4_SetPhoneMode(s, DCT4_MODE_LOCAL); 213 error = DCT4_SetPhoneMode(s, DCT4_MODE_LOCAL);
214 } 214 }
215 // if (error != ERR_NONE) return error; 215 // if (error != ERR_NONE) return error;
216 } 216 }
217 } 217 }
218 218
219 File->ReadOnly = false; 219 File->ReadOnly = false;
220 File->System = false; 220 File->System = false;
221 File->Protected = false; 221 File->Protected = false;
222 File->Hidden = false; 222 File->Hidden = false;
223 223
224 return N3650_GetFolderInfo(s, File); 224 return N3650_GetFolderInfo(s, File);
225} 225}
226 226
227static GSM_Error N3650_Initialise (GSM_StateMachine *s) 227static GSM_Error N3650_Initialise (GSM_StateMachine *s)
228{ 228{
229 GSM_Phone_N3650Data *Priv = &s->Phone.Data.Priv.N3650; 229 GSM_Phone_N3650Data *Priv = &s->Phone.Data.Priv.N3650;
230 int i; 230 int i;
231 231
232 for (i=0;i<10000;i++) { 232 for (i=0;i<10000;i++) {
233 Priv->Files[i] = malloc(sizeof(GSM_File)); 233 Priv->Files[i] = malloc(sizeof(GSM_File));
234 if (Priv->Files[i] == NULL) return ERR_MOREMEMORY; 234 if (Priv->Files[i] == NULL) return ERR_MOREMEMORY;
235 } 235 }
236 return ERR_NONE; 236 return ERR_NONE;
237} 237}
238 238
239static GSM_Error N3650_Terminate(GSM_StateMachine *s) 239static GSM_Error N3650_Terminate(GSM_StateMachine *s)
240{ 240{
241 GSM_Phone_N3650Data *Priv = &s->Phone.Data.Priv.N3650; 241 GSM_Phone_N3650Data *Priv = &s->Phone.Data.Priv.N3650;
242 int i; 242 int i;
243 243
244 for (i=0;i<10000;i++) free(Priv->Files[i]); 244 for (i=0;i<10000;i++) free(Priv->Files[i]);
245 return ERR_NONE; 245 return ERR_NONE;
246} 246}
247 247
248static GSM_Reply_Function N3650ReplyFunctions[] = { 248static GSM_Reply_Function N3650ReplyFunctions[] = {
249 {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset }, 249 {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset },
250 {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset }, 250 {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset },
251 {NoneReply, "\x15",0x03,0x68,ID_Reset }, 251 {NoneReply, "\x15",0x03,0x68,ID_Reset },
252 252
253 {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI }, 253 {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI },
254 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware }, 254 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware },
255 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode }, 255 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode },
256 256
257 {N3650_ReplyGetFolderInfo, "\x58",0x03,0x0C,ID_GetFile }, 257 {N3650_ReplyGetFolderInfo, "\x58",0x03,0x0C,ID_GetFile },
258 {N3650_ReplyGetFilePart, "\x58",0x03,0x0E,ID_GetFile }, 258 {N3650_ReplyGetFilePart, "\x58",0x03,0x0E,ID_GetFile },
259 259
260 {NULL, "\x00",0x00,0x00,ID_None } 260 {NULL, "\x00",0x00,0x00,ID_None }
261}; 261};
262 262
263GSM_Phone_Functions N3650Phone = { 263GSM_Phone_Functions N3650Phone = {
264 "3650|NGAGE", 264 "3650|NGAGE",
265 N3650ReplyFunctions, 265 N3650ReplyFunctions,
266 N3650_Initialise, 266 N3650_Initialise,
267 N3650_Terminate, 267 N3650_Terminate,
268 GSM_DispatchMessage, 268 GSM_DispatchMessage,
269 NOTSUPPORTED, /* ShowStartInfo */ 269 NOTSUPPORTED, /* ShowStartInfo */
270 NOKIA_GetManufacturer, 270 NOKIA_GetManufacturer,
271 DCT3DCT4_GetModel, 271 DCT3DCT4_GetModel,
272 DCT3DCT4_GetFirmware, 272 DCT3DCT4_GetFirmware,
273 DCT4_GetIMEI, 273 DCT4_GetIMEI,
274 NOTSUPPORTED, /* GetOriginalIMEI */ 274 NOTSUPPORTED, /* GetOriginalIMEI */
275 NOTSUPPORTED, /* GetManufactureMonth*/ 275 NOTSUPPORTED, /* GetManufactureMonth*/
276 DCT4_GetProductCode, 276 DCT4_GetProductCode,
277 DCT4_GetHardware, 277 DCT4_GetHardware,
278 NOTSUPPORTED, /* GetPPM */ 278 NOTSUPPORTED, /* GetPPM */
279 NOTSUPPORTED, /* GetSIMIMSI */ 279 NOTSUPPORTED, /* GetSIMIMSI */
280 NOTSUPPORTED, /* GetDateTime */ 280 NOTSUPPORTED, /* GetDateTime */
281 NOTSUPPORTED, /* SetDateTime */ 281 NOTSUPPORTED, /* SetDateTime */
282 NOTSUPPORTED, /* GetAlarm */ 282 NOTSUPPORTED, /* GetAlarm */
283 NOTSUPPORTED, /* SetAlarm */ 283 NOTSUPPORTED, /* SetAlarm */
284 NOTSUPPORTED, /* GetLocale */ 284 NOTSUPPORTED, /* GetLocale */
285 NOTSUPPORTED, /* SetLocale */ 285 NOTSUPPORTED, /* SetLocale */
286 NOTSUPPORTED, /* PressKey */ 286 NOTSUPPORTED, /* PressKey */
287 DCT4_Reset, 287 DCT4_Reset,
288 NOTSUPPORTED, /* ResetPhoneSettings*/ 288 NOTSUPPORTED, /* ResetPhoneSettings*/
289 NOTSUPPORTED, /* EnterSecurityCode*/ 289 NOTSUPPORTED, /* EnterSecurityCode*/
290 NOTSUPPORTED, /* GetSecurityStatus*/ 290 NOTSUPPORTED, /* GetSecurityStatus*/
291 NOTSUPPORTED, /* GetDisplayStatus*/ 291 NOTSUPPORTED, /* GetDisplayStatus*/
292 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 292 NOTSUPPORTED, /* SetAutoNetworkLogin*/
293 NOTSUPPORTED, /* GetBatteryCharge*/ 293 NOTSUPPORTED, /* GetBatteryCharge*/
294 NOTSUPPORTED, /* GetSignalQuality*/ 294 NOTSUPPORTED, /* GetSignalQuality*/
295 NOTSUPPORTED, /* GetNetworkInfo */ 295 NOTSUPPORTED, /* GetNetworkInfo */
296 NOTSUPPORTED, /* GetCategory */ 296 NOTSUPPORTED, /* GetCategory */
297 NOTSUPPORTED, /* AddCategory */ 297 NOTSUPPORTED, /* AddCategory */
298 NOTSUPPORTED, /* GetCategoryStatus */ 298 NOTSUPPORTED, /* GetCategoryStatus */
299 NOTSUPPORTED, /* GetMemoryStatus */ 299 NOTSUPPORTED, /* GetMemoryStatus */
300 NOTSUPPORTED, /* GetMemory */ 300 NOTSUPPORTED, /* GetMemory */
301 NOTSUPPORTED, /* GetNextMemory */ 301 NOTSUPPORTED, /* GetNextMemory */
302 NOTSUPPORTED, /* SetMemory */ 302 NOTSUPPORTED, /* SetMemory */
303 NOTSUPPORTED, /* AddMemory */ 303 NOTSUPPORTED, /* AddMemory */
304 NOTSUPPORTED, /* DeleteMemory */ 304 NOTSUPPORTED, /* DeleteMemory */
305 NOTIMPLEMENTED, /* DeleteAllMemory */ 305 NOTIMPLEMENTED, /* DeleteAllMemory */
306 NOTSUPPORTED, /* GetSpeedDial */ 306 NOTSUPPORTED, /* GetSpeedDial */
307 NOTSUPPORTED, /* SetSpeedDial */ 307 NOTSUPPORTED, /* SetSpeedDial */
308 NOTSUPPORTED, /* GetSMSC */ 308 NOTSUPPORTED, /* GetSMSC */
309 NOTSUPPORTED, /* SetSMSC */ 309 NOTSUPPORTED, /* SetSMSC */
310 NOTSUPPORTED, /* GetSMSStatus */ 310 NOTSUPPORTED, /* GetSMSStatus */
311 NOTSUPPORTED, /* GetSMS */ 311 NOTSUPPORTED, /* GetSMS */
312 NOTSUPPORTED, /* GetNextSMS */ 312 NOTSUPPORTED, /* GetNextSMS */
313 NOTSUPPORTED, /* SetSMS */ 313 NOTSUPPORTED, /* SetSMS */
314 NOTSUPPORTED, /* AddSMS */ 314 NOTSUPPORTED, /* AddSMS */
315 NOTSUPPORTED, /* DeleteSMS */ 315 NOTSUPPORTED, /* DeleteSMS */
316 NOTSUPPORTED, /* SendSMS */ 316 NOTSUPPORTED, /* SendSMS */
317 NOTSUPPORTED, /* SendSavedSMS */ 317 NOTSUPPORTED, /* SendSavedSMS */
318 NOTSUPPORTED, /* SetFastSMSSending*/ 318 NOTSUPPORTED, /* SetFastSMSSending*/
319 NOTSUPPORTED, /* SetIncomingSMS */ 319 NOTSUPPORTED, /* SetIncomingSMS */
320 NOTSUPPORTED, /* SetIncomingCB */ 320 NOTSUPPORTED, /* SetIncomingCB */
321 NOTSUPPORTED, /* GetSMSFolders */ 321 NOTSUPPORTED, /* GetSMSFolders */
322 NOTSUPPORTED, /* AddSMSFolder */ 322 NOTSUPPORTED, /* AddSMSFolder */
323 NOTSUPPORTED, /* DeleteSMSFolder */ 323 NOTSUPPORTED, /* DeleteSMSFolder */
324 NOTIMPLEMENTED, /* DialVoice */ 324 NOTIMPLEMENTED, /* DialVoice */
325 NOTIMPLEMENTED, /* AnswerCall */ 325 NOTIMPLEMENTED, /* AnswerCall */
326 NOTIMPLEMENTED, /* CancelCall */ 326 NOTIMPLEMENTED, /* CancelCall */
327 NOTIMPLEMENTED, /* HoldCall */ 327 NOTIMPLEMENTED, /* HoldCall */
328 NOTIMPLEMENTED, /* UnholdCall */ 328 NOTIMPLEMENTED, /* UnholdCall */
329 NOTIMPLEMENTED, /* ConferenceCall */ 329 NOTIMPLEMENTED, /* ConferenceCall */
330 NOTIMPLEMENTED, /* SplitCall */ 330 NOTIMPLEMENTED, /* SplitCall */
331 NOTIMPLEMENTED, /* TransferCall */ 331 NOTIMPLEMENTED, /* TransferCall */
332 NOTIMPLEMENTED, /* SwitchCall */ 332 NOTIMPLEMENTED, /* SwitchCall */
333 NOTSUPPORTED, /* GetCallDivert */ 333 NOTSUPPORTED, /* GetCallDivert */
334 NOTSUPPORTED, /* SetCallDivert */ 334 NOTSUPPORTED, /* SetCallDivert */
335 NOTSUPPORTED, /* CancelAllDiverts*/ 335 NOTSUPPORTED, /* CancelAllDiverts*/
336 NOTIMPLEMENTED, /* SetIncomingCall */ 336 NOTIMPLEMENTED, /* SetIncomingCall */
337 NOTIMPLEMENTED, /* SetIncomingUSSD */ 337 NOTIMPLEMENTED, /* SetIncomingUSSD */
338 NOTSUPPORTED, /* SendDTMF */ 338 NOTSUPPORTED, /* SendDTMF */
339 NOTSUPPORTED, /* GetRingtone */ 339 NOTSUPPORTED, /* GetRingtone */
340 NOTSUPPORTED, /* SetRingtone */ 340 NOTSUPPORTED, /* SetRingtone */
341 NOTSUPPORTED, /* GetRingtonesInfo*/ 341 NOTSUPPORTED, /* GetRingtonesInfo*/
342 NOTIMPLEMENTED, /* DeleteUserRingtones*/ 342 NOTIMPLEMENTED, /* DeleteUserRingtones*/
343 NOTSUPPORTED, /* PlayTone */ 343 NOTSUPPORTED, /* PlayTone */
344 NOTSUPPORTED, /* GetWAPBookmark */ 344 NOTSUPPORTED, /* GetWAPBookmark */
345 NOTSUPPORTED, /* SetWAPBookmark */ 345 NOTSUPPORTED, /* SetWAPBookmark */
346 NOTSUPPORTED, /* DeleteWAPBookmark */ 346 NOTSUPPORTED, /* DeleteWAPBookmark */
347 NOTSUPPORTED, /* GetWAPSettings */ 347 NOTSUPPORTED, /* GetWAPSettings */
348 NOTSUPPORTED, /* SetWAPSettings */ 348 NOTSUPPORTED, /* SetWAPSettings */
349 NOTSUPPORTED, /* GetMMSSettings */ 349 NOTSUPPORTED, /* GetMMSSettings */
350 NOTSUPPORTED, /* SetMMSSettings */ 350 NOTSUPPORTED, /* SetMMSSettings */
351 NOTSUPPORTED, /* GetSyncMLSettings*/ 351 NOTSUPPORTED, /* GetSyncMLSettings*/
352 NOTSUPPORTED, /* SetSyncMLSettings*/ 352 NOTSUPPORTED, /* SetSyncMLSettings*/
353 NOTSUPPORTED, /* GetChatSettings */ 353 NOTSUPPORTED, /* GetChatSettings */
354 NOTSUPPORTED, /* SetChatSettings */ 354 NOTSUPPORTED, /* SetChatSettings */
355 NOTSUPPORTED, /* GetBitmap */ 355 NOTSUPPORTED, /* GetBitmap */
356 NOTSUPPORTED, /* SetBitmap */ 356 NOTSUPPORTED, /* SetBitmap */
357 NOTSUPPORTED, /* GetToDoStatus */ 357 NOTSUPPORTED, /* GetToDoStatus */
358 NOTSUPPORTED, /* GetToDo */ 358 NOTSUPPORTED, /* GetToDo */
359 NOTSUPPORTED, /* GetNextToDo */ 359 NOTSUPPORTED, /* GetNextToDo */
360 NOTSUPPORTED, /* SetToDo */ 360 NOTSUPPORTED, /* SetToDo */
361 NOTSUPPORTED, /* AddToDo */ 361 NOTSUPPORTED, /* AddToDo */
362 NOTSUPPORTED, /* DeleteToDo */ 362 NOTSUPPORTED, /* DeleteToDo */
363 NOTSUPPORTED, /* DeleteAllToDo */ 363 NOTSUPPORTED, /* DeleteAllToDo */
364 NOTIMPLEMENTED, /* GetCalendarStatus*/ 364 NOTIMPLEMENTED, /* GetCalendarStatus*/
365 NOTIMPLEMENTED, /* GetCalendar */ 365 NOTIMPLEMENTED, /* GetCalendar */
366 NOTSUPPORTED, /* GetNextCalendar */ 366 NOTSUPPORTED, /* GetNextCalendar */
367 NOTIMPLEMENTED, /* SetCalendar */ 367 NOTIMPLEMENTED, /* SetCalendar */
368 NOTSUPPORTED, /* AddCalendar */ 368 NOTSUPPORTED, /* AddCalendar */
369 NOTSUPPORTED, /* DeleteCalendar */ 369 NOTSUPPORTED, /* DeleteCalendar */
370 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 370 NOTIMPLEMENTED, /* DeleteAllCalendar*/
371 NOTSUPPORTED, /* GetCalendarSettings*/ 371 NOTSUPPORTED, /* GetCalendarSettings*/
372 NOTSUPPORTED, /* SetCalendarSettings*/ 372 NOTSUPPORTED, /* SetCalendarSettings*/
373 NOTSUPPORTED, /* GetNoteStatus */
374 NOTSUPPORTED, /* GetNote */
373 NOTSUPPORTED, /* GetNextNote */ 375 NOTSUPPORTED, /* GetNextNote */
376 NOTSUPPORTED, /* SetNote */
377 NOTSUPPORTED, /* AddNote */
378 NOTSUPPORTED, /* DeleteNote */
379 NOTSUPPORTED, /* DeleteAllNotes */
374 NOTSUPPORTED, /* GetProfile */ 380 NOTSUPPORTED, /* GetProfile */
375 NOTSUPPORTED, /* SetProfile */ 381 NOTSUPPORTED, /* SetProfile */
376 NOTSUPPORTED, /* GetFMStation */ 382 NOTSUPPORTED, /* GetFMStation */
377 NOTSUPPORTED, /* SetFMStation */ 383 NOTSUPPORTED, /* SetFMStation */
378 NOTSUPPORTED, /* ClearFMStations */ 384 NOTSUPPORTED, /* ClearFMStations */
379 N3650_GetNextFileFolder, 385 N3650_GetNextFileFolder,
380 N3650_GetFilePart, 386 N3650_GetFilePart,
381 NOTIMPLEMENTED, /* AddFilePart */ 387 NOTIMPLEMENTED, /* AddFilePart */
382 NOTSUPPORTED, /* GetFileSystemStatus*/ 388 NOTSUPPORTED, /* GetFileSystemStatus*/
383 NOTIMPLEMENTED, /* DeleteFile */ 389 NOTIMPLEMENTED, /* DeleteFile */
384 NOTIMPLEMENTED, /* AddFolder */ 390 NOTIMPLEMENTED, /* AddFolder */
385 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 391 NOTSUPPORTED, /* GetGPRSAccessPoint*/
386 NOTSUPPORTED /* SetGPRSAccessPoint*/ 392 NOTSUPPORTED /* SetGPRSAccessPoint*/
387}; 393};
388 394
389#endif 395#endif
390 396
391/* How should editor hadle tabs in this file? Add editor commands here. 397/* How should editor hadle tabs in this file? Add editor commands here.
392 * vim: noexpandtab sw=8 ts=8 sts=8: 398 * vim: noexpandtab sw=8 ts=8 sts=8:
393 */ 399 */
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.c b/gammu/emb/common/phone/nokia/dct4/n6510.c
index 2208def..c481863 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.c
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.c
@@ -1,699 +1,708 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* based on some Markus Plail, Pawel Kot work from Gnokii (www.gnokii.org) 2/* based on some Markus Plail, Pawel Kot work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later 4 * GNU GPL version 2 or later
5 */ 5 */
6/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */ 6/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#include "../../../gsmstate.h" 17#include "../../../gsmstate.h"
9 18
10#ifdef GSM_ENABLE_NOKIA6510 19#ifdef GSM_ENABLE_NOKIA6510
11 20
12#include <string.h> 21#include <string.h>
13#include <time.h> 22#include <time.h>
14 23
15#include "../../../misc/coding/coding.h" 24#include "../../../misc/coding/coding.h"
16#include "../../../gsmcomon.h" 25#include "../../../gsmcomon.h"
17#include "../../../service/gsmlogo.h" 26#include "../../../service/gsmlogo.h"
18#include "../nfunc.h" 27#include "../nfunc.h"
19#include "../nfuncold.h" 28#include "../nfuncold.h"
20#include "../../pfunc.h" 29#include "../../pfunc.h"
21#include "dct4func.h" 30#include "dct4func.h"
22#include "n6510.h" 31#include "n6510.h"
23 32
24static GSM_Error N6510_Initialise (GSM_StateMachine *s) 33static GSM_Error N6510_Initialise (GSM_StateMachine *s)
25{ 34{
26 s->Phone.Data.Priv.N6510.CalendarIconsNum = 0; 35 s->Phone.Data.Priv.N6510.CalendarIconsNum = 0;
27 36
28 /* Enables various things like incoming SMS, call info, etc. */ 37 /* Enables various things like incoming SMS, call info, etc. */
29 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17\x39", 7); 38 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17\x39", 7);
30} 39}
31 40
32static GSM_Error N6510_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 41static GSM_Error N6510_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
33{ 42{
34 smprintf(s, "Phonebook entry received\n"); 43 smprintf(s, "Phonebook entry received\n");
35 switch (msg.Buffer[6]) { 44 switch (msg.Buffer[6]) {
36 case 0x0f: 45 case 0x0f:
37 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); 46 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
38 default: 47 default:
39 return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,false); 48 return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,false);
40 } 49 }
41 return ERR_UNKNOWN; 50 return ERR_UNKNOWN;
42} 51}
43 52
44static GSM_Error N6510_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) 53static GSM_Error N6510_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
45{ 54{
46 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 55 unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
47 0xfe, 0x10, /* memory type */ 56 0xfe, 0x10, /* memory type */
48 0x00, 0x00, 0x00, 0x00, 57 0x00, 0x00, 0x00, 0x00,
49 0x00, 0x01, /* location */ 58 0x00, 0x01, /* location */
50 0x00, 0x00, 0x01}; 59 0x00, 0x00, 0x01};
51 60
52 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 61 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
53 if (req[9]==0xff) return ERR_NOTSUPPORTED; 62 if (req[9]==0xff) return ERR_NOTSUPPORTED;
54 63
55 if (entry->Location==0x00) return ERR_INVALIDLOCATION; 64 if (entry->Location==0x00) return ERR_INVALIDLOCATION;
56 65
57 req[14] = entry->Location / 256; 66 req[14] = entry->Location / 256;
58 req[15] = entry->Location % 256; 67 req[15] = entry->Location % 256;
59 68
60 s->Phone.Data.Memory=entry; 69 s->Phone.Data.Memory=entry;
61 smprintf(s, "Getting phonebook entry\n"); 70 smprintf(s, "Getting phonebook entry\n");
62 return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory); 71 return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory);
63} 72}
64 73
65static GSM_Error N6510_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 74static GSM_Error N6510_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
66{ 75{
67 GSM_Phone_Data *Data = &s->Phone.Data; 76 GSM_Phone_Data *Data = &s->Phone.Data;
68 77
69 smprintf(s, "Memory status received\n"); 78 smprintf(s, "Memory status received\n");
70 /* Quess ;-)) */ 79 /* Quess ;-)) */
71 if (msg.Buffer[14]==0x10) { 80 if (msg.Buffer[14]==0x10) {
72 Data->MemoryStatus->MemoryFree = msg.Buffer[18]*256 + msg.Buffer[19]; 81 Data->MemoryStatus->MemoryFree = msg.Buffer[18]*256 + msg.Buffer[19];
73 } else { 82 } else {
74 Data->MemoryStatus->MemoryFree = msg.Buffer[17]; 83 Data->MemoryStatus->MemoryFree = msg.Buffer[17];
75 } 84 }
76 smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree); 85 smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree);
77 Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21]; 86 Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21];
78 smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed); 87 smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed);
79 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; 88 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed;
80 smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree); 89 smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree);
81 return ERR_NONE; 90 return ERR_NONE;
82} 91}
83 92
84static GSM_Error N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) 93static GSM_Error N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
85{ 94{
86 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 95 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
87 0x00, /* memory type */ 96 0x00, /* memory type */
88 0x55, 0x55, 0x55, 0x00}; 97 0x55, 0x55, 0x55, 0x00};
89 98
90 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); 99 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
91 if (req[5]==0xff) return ERR_NOTSUPPORTED; 100 if (req[5]==0xff) return ERR_NOTSUPPORTED;
92 101
93 s->Phone.Data.MemoryStatus=Status; 102 s->Phone.Data.MemoryStatus=Status;
94 smprintf(s, "Getting memory status\n"); 103 smprintf(s, "Getting memory status\n");
95 return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus); 104 return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus);
96} 105}
97 106
98static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 107static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
99{ 108{
100 int i, current, j; 109 int i, current, j;
101 GSM_Phone_Data *Data = &s->Phone.Data; 110 GSM_Phone_Data *Data = &s->Phone.Data;
102 111
103 switch (msg.Buffer[4]) { 112 switch (msg.Buffer[4]) {
104 case 0x00: 113 case 0x00:
105 smprintf(s, "SMSC received\n"); 114 smprintf(s, "SMSC received\n");
106 break; 115 break;
107 case 0x02: 116 case 0x02:
108 smprintf(s, "SMSC empty\n"); 117 smprintf(s, "SMSC empty\n");
109 return ERR_INVALIDLOCATION; 118 return ERR_INVALIDLOCATION;
110 default: 119 default:
111 smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]); 120 smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]);
112 return ERR_UNKNOWNRESPONSE; 121 return ERR_UNKNOWNRESPONSE;
113 } 122 }
114 memset(Data->SMSC,0,sizeof(GSM_SMSC)); 123 memset(Data->SMSC,0,sizeof(GSM_SMSC));
115 Data->SMSC->Location = msg.Buffer[8]; 124 Data->SMSC->Location = msg.Buffer[8];
116 Data->SMSC->Format = SMS_FORMAT_Text; 125 Data->SMSC->Format = SMS_FORMAT_Text;
117 switch (msg.Buffer[10]) { 126 switch (msg.Buffer[10]) {
118 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; 127 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
119 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; 128 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
120 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; 129 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break;
121 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; 130 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break;
122 } 131 }
123 Data->SMSC->Validity.Format= SMS_Validity_RelativeFormat; 132 Data->SMSC->Validity.Format= SMS_Validity_RelativeFormat;
124 Data->SMSC->Validity.Relative= msg.Buffer[12]; 133 Data->SMSC->Validity.Relative= msg.Buffer[12];
125 if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time; 134 if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
126 135
127 current = 14; 136 current = 14;
128 for (i=0;i<msg.Buffer[13];i++) { 137 for (i=0;i<msg.Buffer[13];i++) {
129 switch (msg.Buffer[current]) { 138 switch (msg.Buffer[current]) {
130 case 0x81: 139 case 0x81:
131 j=current+4; 140 j=current+4;
132 while (msg.Buffer[j]!=0) {j++;} 141 while (msg.Buffer[j]!=0) {j++;}
133 j=j-33; 142 j=j-33;
134 if (j>GSM_MAX_SMSC_NAME_LENGTH) { 143 if (j>GSM_MAX_SMSC_NAME_LENGTH) {
135 smprintf(s, "Too long name\n"); 144 smprintf(s, "Too long name\n");
136 return ERR_UNKNOWNRESPONSE; 145 return ERR_UNKNOWNRESPONSE;
137 } 146 }
138 CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4); 147 CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4);
139 smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); 148 smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
140 break; 149 break;
141 case 0x82: 150 case 0x82:
142 switch (msg.Buffer[current+2]) { 151 switch (msg.Buffer[current+2]) {
143 case 0x01: 152 case 0x01:
144 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+current+4,true); 153 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+current+4,true);
145 smprintf(s, " Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); 154 smprintf(s, " Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
146 break; 155 break;
147 case 0x02: 156 case 0x02:
148 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+current+4,false); 157 GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+current+4,false);
149 smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); 158 smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
150 break; 159 break;
151 default: 160 default:
152 smprintf(s, "Unknown SMSC number: %02x\n",msg.Buffer[current+2]); 161 smprintf(s, "Unknown SMSC number: %02x\n",msg.Buffer[current+2]);
153 return ERR_UNKNOWNRESPONSE; 162 return ERR_UNKNOWNRESPONSE;
154 } 163 }
155 break; 164 break;
156 default: 165 default:
157 smprintf(s, "Unknown SMSC block: %02x\n",msg.Buffer[current]); 166 smprintf(s, "Unknown SMSC block: %02x\n",msg.Buffer[current]);
158 return ERR_UNKNOWNRESPONSE; 167 return ERR_UNKNOWNRESPONSE;
159 } 168 }
160 current = current + msg.Buffer[current+1]; 169 current = current + msg.Buffer[current+1];
161 } 170 }
162 return ERR_NONE; 171 return ERR_NONE;
163} 172}
164 173
165static GSM_Error N6510_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 174static GSM_Error N6510_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
166{ 175{
167 unsigned char req[] = {N6110_FRAME_HEADER, 0x14, 176 unsigned char req[] = {N6110_FRAME_HEADER, 0x14,
168 0x01, /* location */ 177 0x01, /* location */
169 0x00}; 178 0x00};
170 179
171 if (smsc->Location==0x00) return ERR_INVALIDLOCATION; 180 if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
172 181
173 req[4]=smsc->Location; 182 req[4]=smsc->Location;
174 183
175 s->Phone.Data.SMSC=smsc; 184 s->Phone.Data.SMSC=smsc;
176 smprintf(s, "Getting SMSC\n"); 185 smprintf(s, "Getting SMSC\n");
177 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); 186 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC);
178} 187}
179 188
180static GSM_Error N6510_ReplySetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 189static GSM_Error N6510_ReplySetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
181{ 190{
182 switch (msg.Buffer[4]) { 191 switch (msg.Buffer[4]) {
183 case 0x00: 192 case 0x00:
184 smprintf(s, "SMSC set OK\n"); 193 smprintf(s, "SMSC set OK\n");
185 return ERR_NONE; 194 return ERR_NONE;
186 case 0x02: 195 case 0x02:
187 smprintf(s, "Invalid SMSC location\n"); 196 smprintf(s, "Invalid SMSC location\n");
188 return ERR_INVALIDLOCATION; 197 return ERR_INVALIDLOCATION;
189 default: 198 default:
190 smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]); 199 smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]);
191 return ERR_UNKNOWNRESPONSE; 200 return ERR_UNKNOWNRESPONSE;
192 } 201 }
193 return ERR_UNKNOWNRESPONSE; 202 return ERR_UNKNOWNRESPONSE;
194} 203}
195 204
196static GSM_Error N6510_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 205static GSM_Error N6510_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
197{ 206{
198 int count = 13,i; 207 int count = 13,i;
199 unsigned char req[256] = {N6110_FRAME_HEADER, 208 unsigned char req[256] = {N6110_FRAME_HEADER,
200 0x12, 0x55, 0x01, 0x0B, 0x34, 209 0x12, 0x55, 0x01, 0x0B, 0x34,
201 0x05, /* Location */ 210 0x05, /* Location */
202 0x00, 211 0x00,
203 0x00, /* Format */ 212 0x00, /* Format */
204 0x00, 213 0x00,
205 0xFF}; /* Validity*/ 214 0xFF}; /* Validity*/
206 215
207 req[8] = smsc->Location; 216 req[8] = smsc->Location;
208 switch (smsc->Format) { 217 switch (smsc->Format) {
209 case SMS_FORMAT_Text: req[10] = 0x00;break; 218 case SMS_FORMAT_Text: req[10] = 0x00;break;
210 case SMS_FORMAT_Fax: req[10] = 0x22;break; 219 case SMS_FORMAT_Fax: req[10] = 0x22;break;
211 case SMS_FORMAT_Pager: req[10] = 0x26;break; 220 case SMS_FORMAT_Pager: req[10] = 0x26;break;
212 case SMS_FORMAT_Email: req[10] = 0x32;break; 221 case SMS_FORMAT_Email: req[10] = 0x32;break;
213 } 222 }
214 req[12] = smsc->Validity.Relative; 223 req[12] = smsc->Validity.Relative;
215 224
216 /* We have now blocks. Number of blocks = 3 */ 225 /* We have now blocks. Number of blocks = 3 */
217 req[count++] = 0x03; 226 req[count++] = 0x03;
218 227
219 /* -------------- SMSC number ----------------- */ 228 /* -------------- SMSC number ----------------- */
220 /* Block type: number */ 229 /* Block type: number */
221 req[count++] = 0x82; 230 req[count++] = 0x82;
222 /* Offset to next block */ 231 /* Offset to next block */
223 req[count++] = 0x1A; 232 req[count++] = 0x1A;
224 /* Type of number: SMSC number */ 233 /* Type of number: SMSC number */
225 req[count++] = 0x02; 234 req[count++] = 0x02;
226 req[count] = GSM_PackSemiOctetNumber(smsc->Number, req+count+2, false) + 1; 235 req[count] = GSM_PackSemiOctetNumber(smsc->Number, req+count+2, false) + 1;
227 if (req[count]>18) { 236 if (req[count]>18) {
228 smprintf(s, "Too long SMSC number in frame\n"); 237 smprintf(s, "Too long SMSC number in frame\n");
229 return ERR_UNKNOWN; 238 return ERR_UNKNOWN;
230 } 239 }
231 req[count+1] = req[count] - 1; 240 req[count+1] = req[count] - 1;
232 count += 23; 241 count += 23;
233 242
234 /* --------------- Default number ------------- */ 243 /* --------------- Default number ------------- */
235 /* Block type: number */ 244 /* Block type: number */
236 req[count++] = 0x82; 245 req[count++] = 0x82;
237 /* Offset to next block */ 246 /* Offset to next block */
238 req[count++] = 0x14; 247 req[count++] = 0x14;
239 /* Type of number: default number */ 248 /* Type of number: default number */
240 req[count++] = 0x01; 249 req[count++] = 0x01;
241 req[count] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+count+2, true) + 1; 250 req[count] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+count+2, true) + 1;
242 if (req[count]*2>12) { 251 if (req[count]*2>12) {
243 smprintf(s, "Too long SMSC number in frame\n"); 252 smprintf(s, "Too long SMSC number in frame\n");
244 return ERR_UNKNOWN; 253 return ERR_UNKNOWN;
245 } 254 }
246 req[count+1] = req[count] - 1; 255 req[count+1] = req[count] - 1;
247 count += 17; 256 count += 17;
248 257
249 /* -------------- SMSC name ------------------- */ 258 /* -------------- SMSC name ------------------- */
250 req[count++] = 0x81; 259 req[count++] = 0x81;
251 req[count++] = UnicodeLength(smsc->Name)*2 + 2 + 4; 260 req[count++] = UnicodeLength(smsc->Name)*2 + 2 + 4;
252 req[count++] = UnicodeLength(smsc->Name)*2 + 2; 261 req[count++] = UnicodeLength(smsc->Name)*2 + 2;
253 req[count++] = 0x00; 262 req[count++] = 0x00;
254 /* Can't make CopyUnicodeString(req+count,sms->Name) !!!! 263 /* Can't make CopyUnicodeString(req+count,sms->Name) !!!!
255 * with MSVC6 count is changed then 264 * with MSVC6 count is changed then
256 */ 265 */
257 i = count; 266 i = count;
258 CopyUnicodeString(req+i,smsc->Name); 267 CopyUnicodeString(req+i,smsc->Name);
259 count += UnicodeLength(smsc->Name)*2 + 2; 268 count += UnicodeLength(smsc->Name)*2 + 2;
260 269
261 smprintf(s, "Setting SMSC\n"); 270 smprintf(s, "Setting SMSC\n");
262 return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC); 271 return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC);
263} 272}
264 273
265static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 274static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
266{ 275{
267 int current = msg.Buffer[7]+7, tmp; 276 int current = msg.Buffer[7]+7, tmp;
268 GSM_Phone_Data*Data = &s->Phone.Data; 277 GSM_Phone_Data*Data = &s->Phone.Data;
269#ifdef DEBUG 278#ifdef DEBUG
270 char name[100]; 279 char name[100];
271 GSM_NetworkInfo NetInfo; 280 GSM_NetworkInfo NetInfo;
272 281
273 smprintf(s, "Network status : "); 282 smprintf(s, "Network status : ");
274 switch (msg.Buffer[8]) { 283 switch (msg.Buffer[8]) {
275 case 0x00 : smprintf(s, "home network\n"); break; 284 case 0x00 : smprintf(s, "home network\n"); break;
276 case 0x01 : smprintf(s, "roaming network\n"); break; 285 case 0x01 : smprintf(s, "roaming network\n"); break;
277 case 0x04 : smprintf(s, "not logged"); break; 286 case 0x04 : smprintf(s, "not logged"); break;
278 case 0x06 : smprintf(s, "SIM card rejected\n"); break; 287 case 0x06 : smprintf(s, "SIM card rejected\n"); break;
279 case 0x09 : smprintf(s, "not logged"); break; 288 case 0x09 : smprintf(s, "not logged"); break;
280 default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break; 289 default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break;
281 } 290 }
282 if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) { 291 if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) {
283 NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode); 292 NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode);
284 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); 293 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
285 smprintf(s, "Network name for Gammu : %s ", 294 smprintf(s, "Network name for Gammu : %s ",
286 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); 295 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
287 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); 296 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
288 297
289 sprintf(NetInfo.LAC,"%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); 298 sprintf(NetInfo.LAC,"%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]);
290 smprintf(s, "LAC : %s\n", NetInfo.LAC); 299 smprintf(s, "LAC : %s\n", NetInfo.LAC);
291 300
292 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); 301 sprintf(NetInfo.CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]);
293 smprintf(s, "CID : %s\n", NetInfo.CID); 302 smprintf(s, "CID : %s\n", NetInfo.CID);
294 303
295 tmp = 10; 304 tmp = 10;
296 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,name,true); 305 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,name,true);
297 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 306 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
298 } 307 }
299#endif 308#endif
300 if (Data->RequestID==ID_GetNetworkInfo) { 309 if (Data->RequestID==ID_GetNetworkInfo) {
301 Data->NetworkInfo->NetworkName[0] = 0x00; 310 Data->NetworkInfo->NetworkName[0] = 0x00;
302 Data->NetworkInfo->NetworkName[1] = 0x00; 311 Data->NetworkInfo->NetworkName[1] = 0x00;
303 Data->NetworkInfo->State = 0; 312 Data->NetworkInfo->State = 0;
304 switch (msg.Buffer[8]) { 313 switch (msg.Buffer[8]) {
305 case 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break; 314 case 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break;
306 case 0x01: Data->NetworkInfo->State = GSM_RoamingNetwork;break; 315 case 0x01: Data->NetworkInfo->State = GSM_RoamingNetwork;break;
307 case 0x04: 316 case 0x04:
308 case 0x06: 317 case 0x06:
309 case 0x09: Data->NetworkInfo->State = GSM_NoNetwork; break; 318 case 0x09: Data->NetworkInfo->State = GSM_NoNetwork; break;
310 } 319 }
311 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { 320 if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) {
312 tmp = 10; 321 tmp = 10;
313 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true); 322 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true);
314 sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); 323 sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]);
315 sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); 324 sprintf(Data->NetworkInfo->CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]);
316 NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode); 325 NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode);
317 } 326 }
318 } 327 }
319 return ERR_NONE; 328 return ERR_NONE;
320} 329}
321 330
322static GSM_Error N6510_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) 331static GSM_Error N6510_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo)
323{ 332{
324 unsigned char req[] = {N6110_FRAME_HEADER, 0x00, 0x00}; 333 unsigned char req[] = {N6110_FRAME_HEADER, 0x00, 0x00};
325 334
326 s->Phone.Data.NetworkInfo=netinfo; 335 s->Phone.Data.NetworkInfo=netinfo;
327 smprintf(s, "Getting network info\n"); 336 smprintf(s, "Getting network info\n");
328 return GSM_WaitFor (s, req, 5, 0x0a, 4, ID_GetNetworkInfo); 337 return GSM_WaitFor (s, req, 5, 0x0a, 4, ID_GetNetworkInfo);
329} 338}
330 339
331static GSM_Error N6510_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *req, GSM_SMSMessageLayout *Layout, int *length) 340static GSM_Error N6510_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *req, GSM_SMSMessageLayout *Layout, int *length)
332{ 341{
333 int start, count = 0, pos1, pos2, pos3, pos4, pos5; 342 int start, count = 0, pos1, pos2, pos3, pos4, pos5;
334 GSM_Error error; 343 GSM_Error error;
335 344
336 memset(Layout,255,sizeof(GSM_SMSMessageLayout)); 345 memset(Layout,255,sizeof(GSM_SMSMessageLayout));
337 346
338 start = *length; 347 start = *length;
339 348
340 req[count++] = 0x01; 349 req[count++] = 0x01;
341 if (sms->PDU != SMS_Deliver) { 350 if (sms->PDU != SMS_Deliver) {
342 req[count++] = 0x02; 351 req[count++] = 0x02;
343 } else { 352 } else {
344 req[count++] = 0x00; 353 req[count++] = 0x00;
345 } 354 }
346 355
347 pos1 = count; count++; 356 pos1 = count; count++;
348 /* firstbyte set in SMS Layout */ 357 /* firstbyte set in SMS Layout */
349 Layout->firstbyte = count; count++; 358 Layout->firstbyte = count; count++;
350 if (sms->PDU != SMS_Deliver) { 359 if (sms->PDU != SMS_Deliver) {
351 Layout->TPMR = count; count++; 360 Layout->TPMR = count; count++;
352 361
353 Layout->TPPID = count; count++; 362 Layout->TPPID = count; count++;
354 363
355 /* TP.DCS set in SMS layout */ 364 /* TP.DCS set in SMS layout */
356 Layout->TPDCS = count; count++; 365 Layout->TPDCS = count; count++;
357 req[count++] = 0x00; 366 req[count++] = 0x00;
358 } else { 367 } else {
359 Layout->TPPID = count; count++; 368 Layout->TPPID = count; count++;
360 /* TP.DCS set in SMS layout */ 369 /* TP.DCS set in SMS layout */
361 Layout->TPDCS = count; count++; 370 Layout->TPDCS = count; count++;
362 Layout->DateTime = count; count += 7; 371 Layout->DateTime = count; count += 7;
363 req[count++] = 0x55; 372 req[count++] = 0x55;
364 req[count++] = 0x55; 373 req[count++] = 0x55;
365 req[count++] = 0x55; 374 req[count++] = 0x55;
366 } 375 }
367 376
368 /* We have now blocks. Number of blocks = 3 or 4 */ 377 /* We have now blocks. Number of blocks = 3 or 4 */
369 if (sms->PDU != SMS_Deliver) { 378 if (sms->PDU != SMS_Deliver) {
370 req[count++] = 0x04; 379 req[count++] = 0x04;
371 } else { 380 } else {
372 req[count++] = 0x03; 381 req[count++] = 0x03;
373 } 382 }
374 383
375 /* -------------- Phone number ------------- */ 384 /* -------------- Phone number ------------- */
376 /* Block type: number */ 385 /* Block type: number */
377 req[count++] = 0x82; 386 req[count++] = 0x82;
378 /* Offset to next block */ 387 /* Offset to next block */
379 req[count++] = 0x10; 388 req[count++] = 0x10;
380 /* Type of number: default number */ 389 /* Type of number: default number */
381 req[count++] = 0x01; 390 req[count++] = 0x01;
382 pos4 = count; count++; 391 pos4 = count; count++;
383 /* now coded Number in SMS Layout */ 392 /* now coded Number in SMS Layout */
384 Layout->Number = count; count+= 12; 393 Layout->Number = count; count+= 12;
385 394
386 /* -------------- SMSC number -------------- */ 395 /* -------------- SMSC number -------------- */
387 /* Block type: number */ 396 /* Block type: number */
388 req[count++] = 0x82; 397 req[count++] = 0x82;
389 /* Offset to next block */ 398 /* Offset to next block */
390 req[count++] = 0x10; 399 req[count++] = 0x10;
391 /* Type of number: SMSC number */ 400 /* Type of number: SMSC number */
392 req[count++] = 0x02; 401 req[count++] = 0x02;
393 pos5 = count; count++; 402 pos5 = count; count++;
394 /* now coded SMSC number in SMS Layout */ 403 /* now coded SMSC number in SMS Layout */
395 Layout->SMSCNumber = count; count += 12; 404 Layout->SMSCNumber = count; count += 12;
396 405
397 /* -------------- SMS validity ------------- */ 406 /* -------------- SMS validity ------------- */
398 if (sms->PDU != SMS_Deliver) { 407 if (sms->PDU != SMS_Deliver) {
399 /* Block type: validity */ 408 /* Block type: validity */
400 req[count++] = 0x08; 409 req[count++] = 0x08;
401 req[count++] = 0x04; 410 req[count++] = 0x04;
402 /* data length */ 411 /* data length */
403 req[count++] = 0x01; 412 req[count++] = 0x01;
404 Layout->TPVP = count; count++; 413 Layout->TPVP = count; count++;
405 } 414 }
406 415
407 /* --------------- SMS text ---------------- */ 416 /* --------------- SMS text ---------------- */
408 /* Block type: SMS text */ 417 /* Block type: SMS text */
409 req[count++] = 0x80; 418 req[count++] = 0x80;
410 /* this the same as req[11] but starting from req[42] */ 419 /* this the same as req[11] but starting from req[42] */
411 pos2 = count; count++; 420 pos2 = count; count++;
412 pos3 = count; count++; 421 pos3 = count; count++;
413 /* FIXME*/ 422 /* FIXME*/
414 Layout->TPUDL = count; count++; 423 Layout->TPUDL = count; count++;
415 /* SMS text and UDH coded in SMS Layout */ 424 /* SMS text and UDH coded in SMS Layout */
416 Layout->Text = count; 425 Layout->Text = count;
417 426
418 error = PHONE_EncodeSMSFrame(s,sms,req,*Layout,length,false); 427 error = PHONE_EncodeSMSFrame(s,sms,req,*Layout,length,false);
419 if (error != ERR_NONE) return error; 428 if (error != ERR_NONE) return error;
420 429
421 req[pos1] = *length - 1; 430 req[pos1] = *length - 1;
422 req[pos2] = *length - Layout->Text + 6; 431 req[pos2] = *length - Layout->Text + 6;
423 req[pos3] = *length - Layout->Text; 432 req[pos3] = *length - Layout->Text;
424 433
425 /* Convert number of semioctets to number of chars */ 434 /* Convert number of semioctets to number of chars */
426 req[pos4] = req[Layout->Number] + 4; 435 req[pos4] = req[Layout->Number] + 4;
427 if (req[pos4] % 2) req[pos4]++; 436 if (req[pos4] % 2) req[pos4]++;
428 req[pos4] /= 2; 437 req[pos4] /= 2;
429 438
430 req[pos5] = req[Layout->SMSCNumber] + 1; 439 req[pos5] = req[Layout->SMSCNumber] + 1;
431 440
432 if (req[pos4]>12 || req[pos5]>12) { 441 if (req[pos4]>12 || req[pos5]>12) {
433 smprintf(s, "Too long phone number in frame\n"); 442 smprintf(s, "Too long phone number in frame\n");
434 return ERR_UNKNOWN; 443 return ERR_UNKNOWN;
435 } 444 }
436 445
437 return ERR_NONE; 446 return ERR_NONE;
438} 447}
439 448
440static GSM_Error N6510_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s) 449static GSM_Error N6510_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s)
441{ 450{
442 int j, num = 0, pos; 451 int j, num = 0, pos;
443 GSM_Phone_Data *Data = &s->Phone.Data; 452 GSM_Phone_Data *Data = &s->Phone.Data;
444 453
445 switch (msg.Buffer[3]) { 454 switch (msg.Buffer[3]) {
446 case 0x13: 455 case 0x13:
447 smprintf(s, "SMS folders names received\n"); 456 smprintf(s, "SMS folders names received\n");
448 Data->SMSFolders->Number = msg.Buffer[5]+2; 457 Data->SMSFolders->Number = msg.Buffer[5]+2;
449 pos = 6; 458 pos = 6;
450 for (j=0;j<msg.Buffer[5];j++) { 459 for (j=0;j<msg.Buffer[5];j++) {
451 while (true) { 460 while (true) {
452 if (msg.Buffer[pos] == msg.Buffer[6] && 461 if (msg.Buffer[pos] == msg.Buffer[6] &&
453 msg.Buffer[pos+1] == msg.Buffer[7]) break; 462 msg.Buffer[pos+1] == msg.Buffer[7]) break;
454 if (pos+4 > msg.Length) return ERR_UNKNOWNRESPONSE; 463 if (pos+4 > msg.Length) return ERR_UNKNOWNRESPONSE;
455 pos++; 464 pos++;
456 } 465 }
457 pos+=4; 466 pos+=4;
458 smprintf(s, "Folder index: %02x",msg.Buffer[pos - 2]); 467 smprintf(s, "Folder index: %02x",msg.Buffer[pos - 2]);
459 if (msg.Buffer[pos - 1]>GSM_MAX_SMS_FOLDER_NAME_LEN) { 468 if (msg.Buffer[pos - 1]>GSM_MAX_SMS_FOLDER_NAME_LEN) {
460 smprintf(s, "Too long text\n"); 469 smprintf(s, "Too long text\n");
461 return ERR_UNKNOWNRESPONSE; 470 return ERR_UNKNOWNRESPONSE;
462 } 471 }
463 CopyUnicodeString(Data->SMSFolders->Folder[num].Name,msg.Buffer + pos); 472 CopyUnicodeString(Data->SMSFolders->Folder[num].Name,msg.Buffer + pos);
464 smprintf(s, ", folder name: \"%s\"\n",DecodeUnicodeString(Data->SMSFolders->Folder[num].Name)); 473 smprintf(s, ", folder name: \"%s\"\n",DecodeUnicodeString(Data->SMSFolders->Folder[num].Name));
465 Data->SMSFolders->Folder[num].InboxFolder = false; 474 Data->SMSFolders->Folder[num].InboxFolder = false;
466 Data->SMSFolders->Folder[num].Memory = MEM_ME; 475 Data->SMSFolders->Folder[num].Memory = MEM_ME;
467 if (num == 0x01) { /* OUTBOX SIM */ 476 if (num == 0x01) { /* OUTBOX SIM */
468 Data->SMSFolders->Folder[0].Memory = MEM_SM; 477 Data->SMSFolders->Folder[0].Memory = MEM_SM;
469 Data->SMSFolders->Folder[0].InboxFolder = true; 478 Data->SMSFolders->Folder[0].InboxFolder = true;
470 479
471 Data->SMSFolders->Folder[1].Memory = MEM_SM; 480 Data->SMSFolders->Folder[1].Memory = MEM_SM;
472 481
473 CopyUnicodeString(Data->SMSFolders->Folder[2].Name,Data->SMSFolders->Folder[0].Name); 482 CopyUnicodeString(Data->SMSFolders->Folder[2].Name,Data->SMSFolders->Folder[0].Name);
474 Data->SMSFolders->Folder[2].Memory = MEM_ME; 483 Data->SMSFolders->Folder[2].Memory = MEM_ME;
475 Data->SMSFolders->Folder[2].InboxFolder = true; 484 Data->SMSFolders->Folder[2].InboxFolder = true;
476 485
477 CopyUnicodeString(Data->SMSFolders->Folder[3].Name,Data->SMSFolders->Folder[1].Name); 486 CopyUnicodeString(Data->SMSFolders->Folder[3].Name,Data->SMSFolders->Folder[1].Name);
478 Data->SMSFolders->Folder[3].Memory = MEM_ME; 487 Data->SMSFolders->Folder[3].Memory = MEM_ME;
479 Data->SMSFolders->Folder[3].InboxFolder = false; 488 Data->SMSFolders->Folder[3].InboxFolder = false;
480 489
481 num+=2; 490 num+=2;
482 } 491 }
483 num++; 492 num++;
484 } 493 }
485 return ERR_NONE; 494 return ERR_NONE;
486 } 495 }
487 return ERR_UNKNOWNRESPONSE; 496 return ERR_UNKNOWNRESPONSE;
488} 497}
489 498
490static GSM_Error N6510_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders) 499static GSM_Error N6510_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
491{ 500{
492 unsigned char req[] = {N6110_FRAME_HEADER, 0x12, 0x00, 0x00}; 501 unsigned char req[] = {N6110_FRAME_HEADER, 0x12, 0x00, 0x00};
493 502
494 s->Phone.Data.SMSFolders=folders; 503 s->Phone.Data.SMSFolders=folders;
495 smprintf(s, "Getting SMS folders\n"); 504 smprintf(s, "Getting SMS folders\n");
496 return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders); 505 return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders);
497} 506}
498 507
499static GSM_Error N6510_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 508static GSM_Error N6510_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
500{ 509{
501 int i; 510 int i;
502 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 511 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
503 512
504 smprintf(s, "SMS folder status received\n"); 513 smprintf(s, "SMS folder status received\n");
505 Priv->LastSMSFolder.Number=msg.Buffer[6]*256+msg.Buffer[7]; 514 Priv->LastSMSFolder.Number=msg.Buffer[6]*256+msg.Buffer[7];
506 smprintf(s, "Number of Entries: %i\n",Priv->LastSMSFolder.Number); 515 smprintf(s, "Number of Entries: %i\n",Priv->LastSMSFolder.Number);
507 smprintf(s, "Locations: "); 516 smprintf(s, "Locations: ");
508 for (i=0;i<Priv->LastSMSFolder.Number;i++) { 517 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
509 Priv->LastSMSFolder.Location[i]=msg.Buffer[8+(i*2)]*256+msg.Buffer[(i*2)+9]; 518 Priv->LastSMSFolder.Location[i]=msg.Buffer[8+(i*2)]*256+msg.Buffer[(i*2)+9];
510 smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]); 519 smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]);
511 } 520 }
512 smprintf(s, "\n"); 521 smprintf(s, "\n");
513 NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder); 522 NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder);
514 return ERR_NONE; 523 return ERR_NONE;
515} 524}
516 525
517static GSM_Error N6510_GetSMSFolderStatus(GSM_StateMachine *s, int folderid) 526static GSM_Error N6510_GetSMSFolderStatus(GSM_StateMachine *s, int folderid)
518{ 527{
519 unsigned char req[] = {N7110_FRAME_HEADER, 0x0C, 528 unsigned char req[] = {N7110_FRAME_HEADER, 0x0C,
520 0x01, /* 0x01=SIM, 0x02=ME */ 529 0x01, /* 0x01=SIM, 0x02=ME */
521 0x00, /* Folder ID */ 530 0x00, /* Folder ID */
522 0x0f, 0x55, 0x55, 0x55}; 531 0x0f, 0x55, 0x55, 0x55};
523 532
524 switch (folderid) { 533 switch (folderid) {
525 case 0x01: req[5] = 0x02; break; /* INBOX SIM */ 534 case 0x01: req[5] = 0x02; break; /* INBOX SIM */
526 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */ 535 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */
527 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/ 536 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/
528 } 537 }
529 538
530 smprintf(s, "Getting SMS folder status\n"); 539 smprintf(s, "Getting SMS folder status\n");
531 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSFolderStatus); 540 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSFolderStatus);
532} 541}
533 542
534static void N6510_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location) 543static void N6510_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location)
535{ 544{
536 int ifolderid; 545 int ifolderid;
537 546
538 /* simulate flat SMS memory */ 547 /* simulate flat SMS memory */
539 if (sms->Folder==0x00) { 548 if (sms->Folder==0x00) {
540 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER; 549 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER;
541 *folderid = ifolderid + 0x01; 550 *folderid = ifolderid + 0x01;
542 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER; 551 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER;
543 } else { 552 } else {
544 *folderid = sms->Folder; 553 *folderid = sms->Folder;
545 *location = sms->Location; 554 *location = sms->Location;
546 } 555 }
547 smprintf(s, "SMS folder %i & location %i -> 6510 folder %i & location %i\n", 556 smprintf(s, "SMS folder %i & location %i -> 6510 folder %i & location %i\n",
548 sms->Folder,sms->Location,*folderid,*location); 557 sms->Folder,sms->Location,*folderid,*location);
549} 558}
550 559
551static void N6510_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location) 560static void N6510_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
552{ 561{
553 sms->Folder= 0; 562 sms->Folder= 0;
554 sms->Location= (folderid - 0x01) * PHONE_MAXSMSINFOLDER + location; 563 sms->Location= (folderid - 0x01) * PHONE_MAXSMSINFOLDER + location;
555 smprintf(s, "6510 folder %i & location %i -> SMS folder %i & location %i\n", 564 smprintf(s, "6510 folder %i & location %i -> SMS folder %i & location %i\n",
556 folderid,location,sms->Folder,sms->Location); 565 folderid,location,sms->Folder,sms->Location);
557} 566}
558 567
559static GSM_Error N6510_DecodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *buffer) 568static GSM_Error N6510_DecodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *buffer)
560{ 569{
561 int i, current, blocks=0, SMSTemplateDateTime = 0; 570 int i, current, blocks=0, SMSTemplateDateTime = 0;
562 GSM_SMSMessageLayout Layout; 571 GSM_SMSMessageLayout Layout;
563 GSM_Error error; 572 GSM_Error error;
564 573
565 memset(&Layout,255,sizeof(GSM_SMSMessageLayout)); 574 memset(&Layout,255,sizeof(GSM_SMSMessageLayout));
566 Layout.firstbyte = 2; 575 Layout.firstbyte = 2;
567 switch (buffer[0]) { 576 switch (buffer[0]) {
568 case 0x00: 577 case 0x00:
569 smprintf(s, "SMS deliver\n"); 578 smprintf(s, "SMS deliver\n");
570 sms->PDU = SMS_Deliver; 579 sms->PDU = SMS_Deliver;
571 Layout.TPPID = 3; 580 Layout.TPPID = 3;
572 Layout.TPDCS = 4; 581 Layout.TPDCS = 4;
573 Layout.DateTime = 5; 582 Layout.DateTime = 5;
574 blocks = 15; 583 blocks = 15;
575 break; 584 break;
576 case 0x01: 585 case 0x01:
577 smprintf(s, "Delivery report\n"); 586 smprintf(s, "Delivery report\n");
578 sms->PDU = SMS_Status_Report; 587 sms->PDU = SMS_Status_Report;
579 Layout.TPMR= 3; 588 Layout.TPMR= 3;
580 Layout.TPStatus= 4; 589 Layout.TPStatus= 4;
581 Layout.DateTime = 5; 590 Layout.DateTime = 5;
582 Layout.SMSCTime = 12; 591 Layout.SMSCTime = 12;
583 blocks = 19; 592 blocks = 19;
584 break; 593 break;
585 case 0x02: 594 case 0x02:
586 smprintf(s, "SMS template\n"); 595 smprintf(s, "SMS template\n");
587 sms->PDU = SMS_Submit; 596 sms->PDU = SMS_Submit;
588 Layout.TPMR= 3; 597 Layout.TPMR= 3;
589 Layout.TPPID = 4; 598 Layout.TPPID = 4;
590 Layout.TPDCS = 5; 599 Layout.TPDCS = 5;
591 blocks = 7; 600 blocks = 7;
592 break; 601 break;
593 } 602 }
594 current = blocks + 1; 603 current = blocks + 1;
595 for (i=0;i<buffer[blocks];i++) { 604 for (i=0;i<buffer[blocks];i++) {
596 switch (buffer[current]) { 605 switch (buffer[current]) {
597 case 0x80: 606 case 0x80:
598 smprintf(s, "SMS text\n"); 607 smprintf(s, "SMS text\n");
599 if (buffer[current + 2] > buffer[current + 3]) { 608 if (buffer[current + 2] > buffer[current + 3]) {
600 Layout.TPUDL = current + 2; 609 Layout.TPUDL = current + 2;
601 } else { 610 } else {
602 Layout.TPUDL = current + 3; 611 Layout.TPUDL = current + 3;
603 } 612 }
604 Layout.Text = current + 4; 613 Layout.Text = current + 4;
605 break; 614 break;
606 case 0x82: 615 case 0x82:
607 switch (buffer[current+2]) { 616 switch (buffer[current+2]) {
608 case 0x01: 617 case 0x01:
609 smprintf(s, "Phone number\n"); 618 smprintf(s, "Phone number\n");
610 Layout.Number = current + 4; 619 Layout.Number = current + 4;
611 break; 620 break;
612 case 0x02: 621 case 0x02:
613 smprintf(s, "SMSC number\n"); 622 smprintf(s, "SMSC number\n");
614 Layout.SMSCNumber = current + 4; 623 Layout.SMSCNumber = current + 4;
615 break; 624 break;
616 default: 625 default:
617 smprintf(s, "Unknown number\n"); 626 smprintf(s, "Unknown number\n");
618 break; 627 break;
619 } 628 }
620 break; 629 break;
621 case 0x84: 630 case 0x84:
622 smprintf(s, "Date and time of saving for SMS template\n"); 631 smprintf(s, "Date and time of saving for SMS template\n");
623 SMSTemplateDateTime = current + 2; 632 SMSTemplateDateTime = current + 2;
624 break; 633 break;
625 default: 634 default:
626 smprintf(s, "Unknown block %02x\n",buffer[current]); 635 smprintf(s, "Unknown block %02x\n",buffer[current]);
627 } 636 }
628 current = current + buffer[current + 1]; 637 current = current + buffer[current + 1];
629 } 638 }
630 error=GSM_DecodeSMSFrame(sms,buffer,Layout); 639 error=GSM_DecodeSMSFrame(sms,buffer,Layout);
631 if (SMSTemplateDateTime != 0) { 640 if (SMSTemplateDateTime != 0) {
632 sms->PDU = SMS_Deliver; 641 sms->PDU = SMS_Deliver;
633 NOKIA_DecodeDateTime(s, buffer+SMSTemplateDateTime, &sms->DateTime); 642 NOKIA_DecodeDateTime(s, buffer+SMSTemplateDateTime, &sms->DateTime);
634 sms->DateTime.Timezone = 0; 643 sms->DateTime.Timezone = 0;
635 } 644 }
636 return error; 645 return error;
637} 646}
638 647
639static GSM_Error N6510_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 648static GSM_Error N6510_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
640{ 649{
641 int i; 650 int i;
642 int Width, Height; 651 int Width, Height;
643 unsigned char output[500]; //output2[500]; 652 unsigned char output[500]; //output2[500];
644 GSM_Phone_Data *Data = &s->Phone.Data; 653 GSM_Phone_Data *Data = &s->Phone.Data;
645 654
646 switch(msg.Buffer[3]) { 655 switch(msg.Buffer[3]) {
647 case 0x03: 656 case 0x03:
648 smprintf(s, "SMS Message received\n"); 657 smprintf(s, "SMS Message received\n");
649 Data->GetSMSMessage->Number=1; 658 Data->GetSMSMessage->Number=1;
650 NOKIA_DecodeSMSState(s, msg.Buffer[5], &Data->GetSMSMessage->SMS[0]); 659 NOKIA_DecodeSMSState(s, msg.Buffer[5], &Data->GetSMSMessage->SMS[0]);
651 switch (msg.Buffer[14]) { 660 switch (msg.Buffer[14]) {
652 case 0x00: 661 case 0x00:
653 case 0x01: 662 case 0x01:
654 case 0x02: 663 case 0x02:
655 return N6510_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+14); 664 return N6510_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+14);
656 case 0xA0: 665 case 0xA0:
657 smprintf(s, "Picture Image\n"); 666 smprintf(s, "Picture Image\n");
658 Data->GetSMSMessage->Number = 0; 667 Data->GetSMSMessage->Number = 0;
659 i = 0; 668 i = 0;
660 output[i++] = 0x30; /* Smart Messaging 3.0 */ 669 output[i++] = 0x30; /* Smart Messaging 3.0 */
661 output[i++] = SM30_OTA; 670 output[i++] = SM30_OTA;
662 output[i++] = 0x01; /* Length */ 671 output[i++] = 0x01; /* Length */
663 output[i++] = 0x00; /* Length */ 672 output[i++] = 0x00; /* Length */
664 output[i++] = 0x00; 673 output[i++] = 0x00;
665 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height); 674 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
666 output[i++] = Width; 675 output[i++] = Width;
667 output[i++] = Height; 676 output[i++] = Height;
668 output[i++] = 0x01; 677 output[i++] = 0x01;
669 memcpy(output+i,msg.Buffer+30,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0)); 678 memcpy(output+i,msg.Buffer+30,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0));
670 i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0); 679 i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0);
671 // if (msg.Length!=282) { 680 // if (msg.Length!=282) {
672 // output[i++] = SM30_UNICODETEXT; 681 // output[i++] = SM30_UNICODETEXT;
673 // output[i++] = 0; 682 // output[i++] = 0;
674 // output[i++] = 0; /* Length - later changed */ 683 // output[i++] = 0; /* Length - later changed */
675 // GSM_UnpackEightBitsToSeven(0, msg.Length-282, msg.Length-304, msg.Buffer+282,output2); 684 // GSM_UnpackEightBitsToSeven(0, msg.Length-282, msg.Length-304, msg.Buffer+282,output2);
676 // DecodeDefault(output+i, output2, msg.Length - 282, true); 685 // DecodeDefault(output+i, output2, msg.Length - 282, true);
677 // output[i - 1] = UnicodeLength(output+i) * 2; 686 // output[i - 1] = UnicodeLength(output+i) * 2;
678 // i = i + output[i-1]; 687 // i = i + output[i-1];
679 // } 688 // }
680 GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,SMS_Coding_8bit,1,0); 689 GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,SMS_Coding_8bit,1,0);
681 for (i=0;i<3;i++) { 690 for (i=0;i<3;i++) {
682 Data->GetSMSMessage->SMS[i].Number[0]=0; 691 Data->GetSMSMessage->SMS[i].Number[0]=0;
683 Data->GetSMSMessage->SMS[i].Number[1]=0; 692 Data->GetSMSMessage->SMS[i].Number[1]=0;
684 } 693 }
685 if (Data->Bitmap != NULL) { 694 if (Data->Bitmap != NULL) {
686 Data->Bitmap->Location= 0; 695 Data->Bitmap->Location= 0;
687 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height); 696 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
688 Data->Bitmap->BitmapWidth= Width; 697 Data->Bitmap->BitmapWidth= Width;
689 Data->Bitmap->BitmapHeight= Height; 698 Data->Bitmap->BitmapHeight= Height;
690 PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 30, Data->Bitmap); 699 PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 30, Data->Bitmap);
691 Data->Bitmap->Sender[0] = 0x00; 700 Data->Bitmap->Sender[0] = 0x00;
692 Data->Bitmap->Sender[1] = 0x00; 701 Data->Bitmap->Sender[1] = 0x00;
693 Data->Bitmap->Text[0] = 0; 702 Data->Bitmap->Text[0] = 0;
694 Data->Bitmap->Text[1] = 0; 703 Data->Bitmap->Text[1] = 0;
695 } 704 }
696 return ERR_NONE; 705 return ERR_NONE;
697 default: 706 default:
698 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]); 707 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
699 } 708 }
@@ -746,909 +755,903 @@ static GSM_Error N6510_PrivGetSMSMessageBitmap(GSM_StateMachine *s, GSM_MultiSMS
746 for (i=0;i<sms->Number;i++) { 755 for (i=0;i<sms->Number;i++) {
747 N6510_SetSMSLocation(s, &sms->SMS[i], folderid, location); 756 N6510_SetSMSLocation(s, &sms->SMS[i], folderid, location);
748 sms->SMS[i].Folder = folderid; 757 sms->SMS[i].Folder = folderid;
749 sms->SMS[i].InboxFolder = true; 758 sms->SMS[i].InboxFolder = true;
750 if (folderid != 0x01 && folderid != 0x03) sms->SMS[i].InboxFolder = false; 759 if (folderid != 0x01 && folderid != 0x03) sms->SMS[i].InboxFolder = false;
751 sms->SMS[i].Memory= MEM_ME; 760 sms->SMS[i].Memory= MEM_ME;
752 if (folderid == 0x01 || folderid == 0x02) sms->SMS[i].Memory = MEM_SM; 761 if (folderid == 0x01 || folderid == 0x02) sms->SMS[i].Memory = MEM_SM;
753 CopyUnicodeString(sms->SMS[i].Name,namebuffer); 762 CopyUnicodeString(sms->SMS[i].Name,namebuffer);
754 } 763 }
755 } 764 }
756 return error; 765 return error;
757} 766}
758 767
759static GSM_Error N6510_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms) 768static GSM_Error N6510_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
760{ 769{
761 GSM_Error error; 770 GSM_Error error;
762 unsigned char folderid; 771 unsigned char folderid;
763 int location; 772 int location;
764 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 773 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
765 int i; 774 int i;
766 bool found = false; 775 bool found = false;
767 776
768 N6510_GetSMSLocation(s, &sms->SMS[0], &folderid, &location); 777 N6510_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
769 error=N6510_GetSMSFolderStatus(s, folderid); 778 error=N6510_GetSMSFolderStatus(s, folderid);
770 if (error!=ERR_NONE) return error; 779 if (error!=ERR_NONE) return error;
771 for (i=0;i<Priv->LastSMSFolder.Number;i++) { 780 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
772 if (Priv->LastSMSFolder.Location[i]==location) { 781 if (Priv->LastSMSFolder.Location[i]==location) {
773 found = true; 782 found = true;
774 break; 783 break;
775 } 784 }
776 } 785 }
777 if (!found) return ERR_EMPTY; 786 if (!found) return ERR_EMPTY;
778 return N6510_PrivGetSMSMessageBitmap(s,sms,NULL); 787 return N6510_PrivGetSMSMessageBitmap(s,sms,NULL);
779} 788}
780 789
781static GSM_Error N6510_GetNextSMSMessageBitmap(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start, GSM_Bitmap *bitmap) 790static GSM_Error N6510_GetNextSMSMessageBitmap(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start, GSM_Bitmap *bitmap)
782{ 791{
783 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 792 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
784 unsigned char folderid; 793 unsigned char folderid;
785 int location; 794 int location;
786 GSM_Error error; 795 GSM_Error error;
787 int i; 796 int i;
788 bool findnextfolder = false; 797 bool findnextfolder = false;
789 798
790 if (start) { 799 if (start) {
791 folderid= 0x00; 800 folderid= 0x00;
792 findnextfolder= true; 801 findnextfolder= true;
793 error=N6510_GetSMSFolders(s,&Priv->LastSMSFolders); 802 error=N6510_GetSMSFolders(s,&Priv->LastSMSFolders);
794 if (error!=ERR_NONE) return error; 803 if (error!=ERR_NONE) return error;
795 } else { 804 } else {
796 N6510_GetSMSLocation(s, &sms->SMS[0], &folderid, &location); 805 N6510_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
797 for (i=0;i<Priv->LastSMSFolder.Number;i++) { 806 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
798 if (Priv->LastSMSFolder.Location[i]==location) break; 807 if (Priv->LastSMSFolder.Location[i]==location) break;
799 } 808 }
800 /* Is this last location in this folder ? */ 809 /* Is this last location in this folder ? */
801 if (i==Priv->LastSMSFolder.Number-1) { 810 if (i==Priv->LastSMSFolder.Number-1) {
802 findnextfolder=true; 811 findnextfolder=true;
803 } else { 812 } else {
804 location=Priv->LastSMSFolder.Location[i+1]; 813 location=Priv->LastSMSFolder.Location[i+1];
805 } 814 }
806 } 815 }
807 if (findnextfolder) { 816 if (findnextfolder) {
808 Priv->LastSMSFolder.Number=0; 817 Priv->LastSMSFolder.Number=0;
809 while (Priv->LastSMSFolder.Number==0) { 818 while (Priv->LastSMSFolder.Number==0) {
810 folderid++; 819 folderid++;
811 /* Too high folder number */ 820 /* Too high folder number */
812 if ((folderid-1)>Priv->LastSMSFolders.Number) return ERR_EMPTY; 821 if ((folderid-1)>Priv->LastSMSFolders.Number) return ERR_EMPTY;
813 /* Get next folder status */ 822 /* Get next folder status */
814 error=N6510_GetSMSFolderStatus(s, folderid); 823 error=N6510_GetSMSFolderStatus(s, folderid);
815 if (error!=ERR_NONE) return error; 824 if (error!=ERR_NONE) return error;
816 /* First location from this folder */ 825 /* First location from this folder */
817 location=Priv->LastSMSFolder.Location[0]; 826 location=Priv->LastSMSFolder.Location[0];
818 } 827 }
819 } 828 }
820 N6510_SetSMSLocation(s, &sms->SMS[0], folderid, location); 829 N6510_SetSMSLocation(s, &sms->SMS[0], folderid, location);
821 830
822 return N6510_PrivGetSMSMessageBitmap(s, sms, bitmap); 831 return N6510_PrivGetSMSMessageBitmap(s, sms, bitmap);
823} 832}
824 833
825static GSM_Error N6510_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start) 834static GSM_Error N6510_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start)
826{ 835{
827 return N6510_GetNextSMSMessageBitmap(s, sms, start, NULL); 836 return N6510_GetNextSMSMessageBitmap(s, sms, start, NULL);
828} 837}
829 838
830static GSM_Error N6510_ReplyStartupNoteLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 839static GSM_Error N6510_ReplyStartupNoteLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
831{ 840{
832 GSM_Phone_Data *Data = &s->Phone.Data; 841 GSM_Phone_Data *Data = &s->Phone.Data;
833 842
834 if (Data->RequestID == ID_GetBitmap) { 843 if (Data->RequestID == ID_GetBitmap) {
835 switch (msg.Buffer[4]) { 844 switch (msg.Buffer[4]) {
836 case 0x01: 845 case 0x01:
837 smprintf(s, "Welcome note text received\n"); 846 smprintf(s, "Welcome note text received\n");
838 CopyUnicodeString(Data->Bitmap->Text,msg.Buffer+6); 847 CopyUnicodeString(Data->Bitmap->Text,msg.Buffer+6);
839 smprintf(s, "Text is \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text)); 848 smprintf(s, "Text is \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
840 return ERR_NONE; 849 return ERR_NONE;
841 case 0x10: 850 case 0x10:
842 smprintf(s, "Dealer note text received\n"); 851 smprintf(s, "Dealer note text received\n");
843 CopyUnicodeString(Data->Bitmap->Text,msg.Buffer+6); 852 CopyUnicodeString(Data->Bitmap->Text,msg.Buffer+6);
844 smprintf(s, "Text is \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text)); 853 smprintf(s, "Text is \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
845 return ERR_NONE; 854 return ERR_NONE;
846 case 0x0f: 855 case 0x0f:
847 smprintf(s, "Startup logo received\n"); 856 smprintf(s, "Startup logo received\n");
848 PHONE_DecodeBitmap(GSM_Nokia7110StartupLogo, msg.Buffer + 22, Data->Bitmap); 857 PHONE_DecodeBitmap(GSM_Nokia7110StartupLogo, msg.Buffer + 22, Data->Bitmap);
849 return ERR_NONE; 858 return ERR_NONE;
850 } 859 }
851 } 860 }
852 if (Data->RequestID == ID_SetBitmap) { 861 if (Data->RequestID == ID_SetBitmap) {
853 switch (msg.Buffer[4]) { 862 switch (msg.Buffer[4]) {
854 case 0x01: 863 case 0x01:
855 case 0x10: 864 case 0x10:
856 case 0x0f: 865 case 0x0f:
857 case 0x25: 866 case 0x25:
858 return ERR_NONE; 867 return ERR_NONE;
859 } 868 }
860 } 869 }
861 return ERR_UNKNOWN; 870 return ERR_UNKNOWN;
862} 871}
863 872
864static GSM_Error N6510_GetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap, int *location) 873static GSM_Error N6510_GetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap, int *location)
865{ 874{
866 GSM_MultiSMSMessage sms; 875 GSM_MultiSMSMessage sms;
867 int Number; 876 int Number;
868 GSM_Bitmap bitmap; 877 GSM_Bitmap bitmap;
869 GSM_Error error; 878 GSM_Error error;
870 879
871 sms.SMS[0].Folder= 0; 880 sms.SMS[0].Folder= 0;
872 Number = 0; 881 Number = 0;
873 bitmap.Location = 255; 882 bitmap.Location = 255;
874 error=N6510_GetNextSMSMessageBitmap(s, &sms, true, &bitmap); 883 error=N6510_GetNextSMSMessageBitmap(s, &sms, true, &bitmap);
875 while (error == ERR_NONE) { 884 while (error == ERR_NONE) {
876 if (bitmap.Location != 255) { 885 if (bitmap.Location != 255) {
877 Number++; 886 Number++;
878 if (Number == Bitmap->Location) { 887 if (Number == Bitmap->Location) {
879 bitmap.Location = Bitmap->Location; 888 bitmap.Location = Bitmap->Location;
880 memcpy(Bitmap,&bitmap,sizeof(GSM_Bitmap)); 889 memcpy(Bitmap,&bitmap,sizeof(GSM_Bitmap));
881 *location = sms.SMS[0].Location; 890 *location = sms.SMS[0].Location;
882 return ERR_NONE; 891 return ERR_NONE;
883 } 892 }
884 } 893 }
885 bitmap.Location = 255; 894 bitmap.Location = 255;
886 sms.SMS[0].Folder = 0; 895 sms.SMS[0].Folder = 0;
887 error=N6510_GetNextSMSMessageBitmap(s, &sms, false, &bitmap); 896 error=N6510_GetNextSMSMessageBitmap(s, &sms, false, &bitmap);
888 } 897 }
889 return ERR_INVALIDLOCATION; 898 return ERR_INVALIDLOCATION;
890} 899}
891 900
892static GSM_Error N6510_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 901static GSM_Error N6510_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
893{ 902{
894 unsigned char reqOp[] = {N6110_FRAME_HEADER, 0x23, 0x00, 0x00, 0x55, 0x55, 0x55}; 903 unsigned char reqOp[] = {N6110_FRAME_HEADER, 0x23, 0x00, 0x00, 0x55, 0x55, 0x55};
895 unsigned char reqStartup[] = {N6110_FRAME_HEADER, 0x02, 0x0f}; 904 unsigned char reqStartup[] = {N6110_FRAME_HEADER, 0x02, 0x0f};
896 unsigned char reqNote[] = {N6110_FRAME_HEADER, 0x02, 0x01, 0x00}; 905 unsigned char reqNote[] = {N6110_FRAME_HEADER, 0x02, 0x01, 0x00};
897 GSM_MemoryEntrypbk; 906 GSM_MemoryEntrypbk;
898 GSM_Error error; 907 GSM_Error error;
899 int Location; 908 int Location;
900 909
901 s->Phone.Data.Bitmap=Bitmap; 910 s->Phone.Data.Bitmap=Bitmap;
902 switch (Bitmap->Type) { 911 switch (Bitmap->Type) {
903 case GSM_StartupLogo: 912 case GSM_StartupLogo:
904 Bitmap->BitmapWidth = 96; 913 Bitmap->BitmapWidth = 96;
905 Bitmap->BitmapHeight = 65; 914 Bitmap->BitmapHeight = 65;
906 GSM_ClearBitmap(Bitmap); 915 GSM_ClearBitmap(Bitmap);
907 smprintf(s, "Getting startup logo\n"); 916 smprintf(s, "Getting startup logo\n");
908 return GSM_WaitFor (s, reqStartup, 5, 0x7A, 4, ID_GetBitmap); 917 return GSM_WaitFor (s, reqStartup, 5, 0x7A, 4, ID_GetBitmap);
909 case GSM_DealerNote_Text: 918 case GSM_DealerNote_Text:
910 reqNote[4] = 0x10; 919 reqNote[4] = 0x10;
911 smprintf(s, "Getting dealer note\n"); 920 smprintf(s, "Getting dealer note\n");
912 return GSM_WaitFor (s, reqNote, 6, 0x7A, 4, ID_GetBitmap); 921 return GSM_WaitFor (s, reqNote, 6, 0x7A, 4, ID_GetBitmap);
913 case GSM_WelcomeNote_Text: 922 case GSM_WelcomeNote_Text:
914 smprintf(s, "Getting welcome note\n"); 923 smprintf(s, "Getting welcome note\n");
915 return GSM_WaitFor (s, reqNote, 6, 0x7A, 4, ID_GetBitmap); 924 return GSM_WaitFor (s, reqNote, 6, 0x7A, 4, ID_GetBitmap);
916 case GSM_CallerGroupLogo: 925 case GSM_CallerGroupLogo:
917 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PBK35)) return ERR_NOTSUPPORTED; 926 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PBK35)) return ERR_NOTSUPPORTED;
918 Bitmap->BitmapWidth = 72; 927 Bitmap->BitmapWidth = 72;
919 Bitmap->BitmapHeight = 14; 928 Bitmap->BitmapHeight = 14;
920 GSM_ClearBitmap(Bitmap); 929 GSM_ClearBitmap(Bitmap);
921 pbk.MemoryType= MEM7110_CG; 930 pbk.MemoryType= MEM7110_CG;
922 pbk.Location= Bitmap->Location; 931 pbk.Location= Bitmap->Location;
923 smprintf(s, "Getting caller group logo\n"); 932 smprintf(s, "Getting caller group logo\n");
924 error=N6510_GetMemory(s,&pbk); 933 error=N6510_GetMemory(s,&pbk);
925 if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(s, Bitmap); 934 if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(s, Bitmap);
926 return error; 935 return error;
927 case GSM_OperatorLogo: 936 case GSM_OperatorLogo:
928 smprintf(s, "Getting operator logo\n"); 937 smprintf(s, "Getting operator logo\n");
929 return GSM_WaitFor (s, reqOp, 9, 0x0A, 4, ID_GetBitmap); 938 return GSM_WaitFor (s, reqOp, 9, 0x0A, 4, ID_GetBitmap);
930 case GSM_PictureImage: 939 case GSM_PictureImage:
931 return N6510_GetPictureImage(s, Bitmap, &Location); 940 return N6510_GetPictureImage(s, Bitmap, &Location);
932 default: 941 default:
933 break; 942 break;
934 } 943 }
935 return ERR_NOTSUPPORTED; 944 return ERR_NOTSUPPORTED;
936} 945}
937 946
938static GSM_Error N6510_ReplyGetIncSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s) 947static GSM_Error N6510_ReplyGetIncSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s)
939{ 948{
940 smprintf(s, "Network level changed to: %i\n",msg.Buffer[4]); 949 smprintf(s, "Network level changed to: %i\n",msg.Buffer[4]);
941 return ERR_NONE; 950 return ERR_NONE;
942} 951}
943 952
944static GSM_Error N6510_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s) 953static GSM_Error N6510_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_StateMachine *s)
945{ 954{
946 GSM_Phone_Data *Data = &s->Phone.Data; 955 GSM_Phone_Data *Data = &s->Phone.Data;
947 956
948 smprintf(s, "Network level received: %i\n",msg.Buffer[8]); 957 smprintf(s, "Network level received: %i\n",msg.Buffer[8]);
949 Data->SignalQuality->SignalStrength = -1; 958 Data->SignalQuality->SignalStrength = -1;
950 Data->SignalQuality->SignalPercent = ((int)msg.Buffer[8]); 959 Data->SignalQuality->SignalPercent = ((int)msg.Buffer[8]);
951 Data->SignalQuality->BitErrorRate = -1; 960 Data->SignalQuality->BitErrorRate = -1;
952 return ERR_NONE; 961 return ERR_NONE;
953} 962}
954 963
955static GSM_Error N6510_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig) 964static GSM_Error N6510_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig)
956{ 965{
957 unsigned char req[] = {N6110_FRAME_HEADER, 0x0B, 0x00, 0x02, 0x00, 0x00, 0x00}; 966 unsigned char req[] = {N6110_FRAME_HEADER, 0x0B, 0x00, 0x02, 0x00, 0x00, 0x00};
958 967
959 s->Phone.Data.SignalQuality = sig; 968 s->Phone.Data.SignalQuality = sig;
960 smprintf(s, "Getting network level\n"); 969 smprintf(s, "Getting network level\n");
961 return GSM_WaitFor (s, req, 9, 0x0a, 4, ID_GetSignalQuality); 970 return GSM_WaitFor (s, req, 9, 0x0a, 4, ID_GetSignalQuality);
962} 971}
963 972
964static GSM_Error N6510_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s) 973static GSM_Error N6510_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s)
965{ 974{
966 GSM_Phone_Data *Data = &s->Phone.Data; 975 GSM_Phone_Data *Data = &s->Phone.Data;
967 976
968 smprintf(s, "Battery level received: %i\n",msg.Buffer[9]*100/7); 977 smprintf(s, "Battery level received: %i\n",msg.Buffer[9]*100/7);
969 Data->BatteryCharge->BatteryPercent = ((int)(msg.Buffer[9]*100/7)); 978 Data->BatteryCharge->BatteryPercent = ((int)(msg.Buffer[9]*100/7));
970 Data->BatteryCharge->ChargeState = 0; 979 Data->BatteryCharge->ChargeState = 0;
971 return ERR_NONE; 980 return ERR_NONE;
972} 981}
973 982
974static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat) 983static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat)
975{ 984{
976 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x02, 0x00}; 985 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x02, 0x00};
977 986
978 s->Phone.Data.BatteryCharge = bat; 987 s->Phone.Data.BatteryCharge = bat;
979 smprintf(s, "Getting battery level\n"); 988 smprintf(s, "Getting battery level\n");
980 return GSM_WaitFor (s, req, 6, 0x17, 4, ID_GetBatteryCharge); 989 return GSM_WaitFor (s, req, 6, 0x17, 4, ID_GetBatteryCharge);
981} 990}
982 991
983static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s) 992static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s)
984{ 993{
985 return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true); 994 return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true);
986} 995}
987 996
988static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 997static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
989{ 998{
990 GSM_Phone_Data *Data = &s->Phone.Data; 999 GSM_Phone_Data *Data = &s->Phone.Data;
991 1000
992 smprintf(s, "Operator logo received\n"); 1001 smprintf(s, "Operator logo received\n");
993 if (msg.Length == 18) return ERR_EMPTY; 1002 if (msg.Length == 18) return ERR_EMPTY;
994 NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode); 1003 NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode);
995 smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode); 1004 smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode);
996 Data->Bitmap->BitmapWidth= msg.Buffer[20]; 1005 Data->Bitmap->BitmapWidth= msg.Buffer[20];
997 Data->Bitmap->BitmapHeight= msg.Buffer[21]; 1006 Data->Bitmap->BitmapHeight= msg.Buffer[21];
998 PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap); 1007 PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap);
999 return ERR_NONE; 1008 return ERR_NONE;
1000} 1009}
1001 1010
1002GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 1011GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
1003{ 1012{
1004 smprintf(s, "Phonebook entry deleted\n"); 1013 smprintf(s, "Phonebook entry deleted\n");
1005 return ERR_NONE; 1014 return ERR_NONE;
1006} 1015}
1007 1016
1008GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1017GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1009{ 1018{
1010 unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x55, 0x01, 1019 unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x55, 0x01,
1011 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02, 1020 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02,
1012 0x00, 0x01, /* location*/ 1021 0x00, 0x01, /* location*/
1013 0x00, 0x00, 0x00, 0x00, 1022 0x00, 0x00, 0x00, 0x00,
1014 0x05, /* memory type*/ 1023 0x05, /* memory type*/
1015 0x55, 0x55, 0x55}; 1024 0x55, 0x55, 0x55};
1016 1025
1017 req[12] = entry->Location / 256; 1026 req[12] = entry->Location / 256;
1018 req[13] = entry->Location % 256; 1027 req[13] = entry->Location % 256;
1019 1028
1020 req[18] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 1029 req[18] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1021 if (req[18]==0xff) return ERR_NOTSUPPORTED; 1030 if (req[18]==0xff) return ERR_NOTSUPPORTED;
1022 1031
1023 smprintf(s, "Deleting phonebook entry\n"); 1032 smprintf(s, "Deleting phonebook entry\n");
1024 return GSM_WaitFor (s, req, 22, 0x03, 4, ID_SetMemory); 1033 return GSM_WaitFor (s, req, 22, 0x03, 4, ID_SetMemory);
1025} 1034}
1026 1035
1027static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1036static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1028{ 1037{
1029 int count = 22, blocks; 1038 int count = 22, blocks;
1030 unsigned char req[500] = { 1039 unsigned char req[500] = {
1031 N7110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, 1040 N7110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,
1032 0x02, 0x00, /* memory type */ 1041 0x02, 0x00, /* memory type */
1033 0x00, 0x00, /* location */ 1042 0x00, 0x00, /* location */
1034 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 1043 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1035 1044
1036 if (entry->Location == 0) return ERR_NOTSUPPORTED; 1045 if (entry->Location == 0) return ERR_NOTSUPPORTED;
1037 1046
1038 req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); 1047 req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1039 if (req[11]==0xff) return ERR_NOTSUPPORTED; 1048 if (req[11]==0xff) return ERR_NOTSUPPORTED;
1040 1049
1041 req[12] = entry->Location / 256; 1050 req[12] = entry->Location / 256;
1042 req[13] = entry->Location % 256; 1051 req[13] = entry->Location % 256;
1043 1052
1044 count = count + N71_65_EncodePhonebookFrame(s, req+22, *entry, &blocks, true, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS)); 1053 count = count + N71_65_EncodePhonebookFrame(s, req+22, *entry, &blocks, true, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS));
1045 req[21] = blocks; 1054 req[21] = blocks;
1046 1055
1047 smprintf(s, "Writing phonebook entry\n"); 1056 smprintf(s, "Writing phonebook entry\n");
1048 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetMemory); 1057 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetMemory);
1049} 1058}
1050 1059
1051static GSM_Error N6510_ReplySetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 1060static GSM_Error N6510_ReplySetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1052{ 1061{
1053 smprintf(s, "Operator logo set OK\n"); 1062 smprintf(s, "Operator logo set OK\n");
1054 return ERR_NONE; 1063 return ERR_NONE;
1055} 1064}
1056 1065
1057static GSM_Error N6510_SetCallerLogo(GSM_StateMachine *s, GSM_Bitmap *bitmap) 1066static GSM_Error N6510_SetCallerLogo(GSM_StateMachine *s, GSM_Bitmap *bitmap)
1058{ 1067{
1059 char string[500]; 1068 char string[500];
1060 int block=0, i, Width, Height; 1069 int block=0, i, Width, Height;
1061 unsigned int count = 22; 1070 unsigned int count = 22;
1062 unsigned char req[500] = { 1071 unsigned char req[500] = {
1063 N6110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, 1072 N6110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,
1064 0xfe, 0x10, /* memory type */ 1073 0xfe, 0x10, /* memory type */
1065 0x00, 0x00, /* location */ 1074 0x00, 0x00, /* location */
1066 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 1075 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1067 1076
1068 req[13] = bitmap->Location; 1077 req[13] = bitmap->Location;
1069 1078
1070 /* Enabling/disabling logo */ 1079 /* Enabling/disabling logo */
1071 string[0] = bitmap->BitmapEnabled?1:0; 1080 string[0] = bitmap->BitmapEnabled?1:0;
1072 string[1] = 0; 1081 string[1] = 0;
1073 count += N71_65_PackPBKBlock(s, N7110_PBK_LOGOON, 2, block++, string, req + count); 1082 count += N71_65_PackPBKBlock(s, N7110_PBK_LOGOON, 2, block++, string, req + count);
1074 1083
1075 /* Ringtone */ 1084 /* Ringtone */
1076 if (!bitmap->DefaultRingtone) { 1085 if (!bitmap->DefaultRingtone) {
1077 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PBKTONEGAL)) { 1086 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PBKTONEGAL)) {
1078 } else { 1087 } else {
1079 string[0] = 0x00; 1088 string[0] = 0x00;
1080 string[1] = 0x00; 1089 string[1] = 0x00;
1081 string[2] = bitmap->RingtoneID; 1090 string[2] = bitmap->RingtoneID;
1082 count += N71_65_PackPBKBlock(s, N7110_PBK_RINGTONE_ID, 3, block++, string, req + count); 1091 count += N71_65_PackPBKBlock(s, N7110_PBK_RINGTONE_ID, 3, block++, string, req + count);
1083 count --; 1092 count --;
1084 req[count-5] = 8; 1093 req[count-5] = 8;
1085 } 1094 }
1086 } 1095 }
1087 1096
1088 /* Number of group */ 1097 /* Number of group */
1089 string[0] = bitmap->Location; 1098 string[0] = bitmap->Location;
1090 string[1] = 0; 1099 string[1] = 0;
1091 count += N71_65_PackPBKBlock(s, N7110_PBK_GROUP, 2, block++, string, req + count); 1100 count += N71_65_PackPBKBlock(s, N7110_PBK_GROUP, 2, block++, string, req + count);
1092 1101
1093 /* Name */ 1102 /* Name */
1094 if (!bitmap->DefaultName) { 1103 if (!bitmap->DefaultName) {
1095 i = UnicodeLength(bitmap->Text) * 2; 1104 i = UnicodeLength(bitmap->Text) * 2;
1096 string[0] = i + 2; 1105 string[0] = i + 2;
1097 memcpy(string + 1, bitmap->Text, i); 1106 memcpy(string + 1, bitmap->Text, i);
1098 string[i + 1] = 0; 1107 string[i + 1] = 0;
1099 count += N71_65_PackPBKBlock(s, N7110_PBK_NAME, i + 2, block++, string, req + count); 1108 count += N71_65_PackPBKBlock(s, N7110_PBK_NAME, i + 2, block++, string, req + count);
1100 } 1109 }
1101 1110
1102 /* Logo */ 1111 /* Logo */
1103 if (!bitmap->DefaultBitmap) { 1112 if (!bitmap->DefaultBitmap) {
1104 PHONE_GetBitmapWidthHeight(GSM_NokiaCallerLogo, &Width, &Height); 1113 PHONE_GetBitmapWidthHeight(GSM_NokiaCallerLogo, &Width, &Height);
1105 string[0] = Width; 1114 string[0] = Width;
1106 string[1] = Height; 1115 string[1] = Height;
1107 string[2] = 0; 1116 string[2] = 0;
1108 string[3] = 0; 1117 string[3] = 0;
1109 string[4] = PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0); 1118 string[4] = PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0);
1110 PHONE_EncodeBitmap(GSM_NokiaCallerLogo, string + 5, bitmap); 1119 PHONE_EncodeBitmap(GSM_NokiaCallerLogo, string + 5, bitmap);
1111 count += N71_65_PackPBKBlock(s, N7110_PBK_GROUPLOGO, PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 5, block++, string, req + count); 1120 count += N71_65_PackPBKBlock(s, N7110_PBK_GROUPLOGO, PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 5, block++, string, req + count);
1112 } 1121 }
1113 1122
1114 req[21] = block; 1123 req[21] = block;
1115 1124
1116 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap); 1125 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap);
1117} 1126}
1118 1127
1119static GSM_Error N6510_ReplySetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s) 1128static GSM_Error N6510_ReplySetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s)
1120{ 1129{
1121 //smprintf(s, "Picture Image written OK, folder %i, location %i\n",msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]); 1130 //smprintf(s, "Picture Image written OK, folder %i, location %i\n",msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
1122 return ERR_NONE; 1131 return ERR_NONE;
1123} 1132}
1124 1133
1125static GSM_Error N6510_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 1134static GSM_Error N6510_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
1126{ 1135{
1127 GSM_SMSMessage sms; 1136 GSM_SMSMessage sms;
1128 GSM_Phone_Bitmap_TypesType; 1137 GSM_Phone_Bitmap_TypesType;
1129 int Width, Height, i, count; 1138 int Width, Height, i, count;
1130#ifdef DEVELOP
1131 unsigned char folderid; 1139 unsigned char folderid;
1132 int location; 1140 int location;
1133#endif
1134 GSM_NetworkInfo NetInfo; 1141 GSM_NetworkInfo NetInfo;
1135 GSM_Error error; 1142 GSM_Error error;
1136 unsigned char reqStartup[1000] = { 1143 unsigned char reqStartup[1000] = {
1137 N7110_FRAME_HEADER, 0x04, 0x0F, 1144 N7110_FRAME_HEADER, 0x04, 0x0F,
1138 0x00, 0x00, 0x00, 1145 0x00, 0x00, 0x00,
1139 0x04, 0xC0, 0x02, 0x00, 1146 0x04, 0xC0, 0x02, 0x00,
1140 0x41, 0xC0, 0x03, 0x00, 1147 0x41, 0xC0, 0x03, 0x00,
1141 0x60, 0xC0, 0x04}; 1148 0x60, 0xC0, 0x04};
1142 unsigned char reqColourWallPaper[200] = { 1149 unsigned char reqColourWallPaper[200] = {
1143 N6110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0xD5, 1150 N6110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0xD5,
1144 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 1151 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
1145 0x00, 0x00, 0x00, 0x01, 0x00, 1152 0x00, 0x00, 0x00, 0x01, 0x00,
1146 0x18}; /* Bitmap ID */ 1153 0x18}; /* Bitmap ID */
1147 unsigned char reqColourStartup[200] = { 1154 unsigned char reqColourStartup[200] = {
1148 N6110_FRAME_HEADER, 0x04, 0x25, 0x00, 0x01, 0x00, 0x18}; 1155 N6110_FRAME_HEADER, 0x04, 0x25, 0x00, 0x01, 0x00, 0x18};
1149 unsigned char reqOp[1000] = { 1156 unsigned char reqOp[1000] = {
1150 N7110_FRAME_HEADER, 0x25, 0x01, 1157 N7110_FRAME_HEADER, 0x25, 0x01,
1151 0x55, 0x00, 0x00, 0x55, 1158 0x55, 0x00, 0x00, 0x55,
1152 0x01, /* 0x01 - not set, 0x02 - set */ 1159 0x01, /* 0x01 - not set, 0x02 - set */
1153 0x0C, 0x08, 1160 0x0C, 0x08,
1154 0x62, 0xF0, 0x10,/* Network code */ 1161 0x62, 0xF0, 0x10,/* Network code */
1155 0x03, 0x55, 0x55}; 1162 0x03, 0x55, 0x55};
1156 unsigned char reqColourOp[200] = { 1163 unsigned char reqColourOp[200] = {
1157 N6110_FRAME_HEADER, 1164 N6110_FRAME_HEADER,
1158 0x07, 0x00, 0x00, 0x00, 0xE7, 0x00, 0x00, 0x00, 0xF9, 0x00, 1165 0x07, 0x00, 0x00, 0x00, 0xE7, 0x00, 0x00, 0x00, 0xF9, 0x00,
1159 0x08, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 1166 0x08, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00,
1160 0x18, /* File ID */ 1167 0x18, /* File ID */
1161 0x00, 1168 0x00,
1162 0x00, 0x00, 0x00};/* Network code */ 1169 0x00, 0x00, 0x00};/* Network code */
1163 unsigned char reqNote[200] = {N6110_FRAME_HEADER, 0x04, 0x01}; 1170 unsigned char reqNote[200] = {N6110_FRAME_HEADER, 0x04, 0x01};
1164 unsigned char reqPicture[2000] = { 1171 unsigned char reqPicture[2000] = {
1165 N6110_FRAME_HEADER, 0x00, 1172 N6110_FRAME_HEADER, 0x00,
1166 0x02, 0x05, /* SMS folder */ 1173 0x02, 0x05, /* SMS folder */
1167 0x00, 0x00, /* location */ 1174 0x00, 0x00, /* location */
1168 0x01, 0x01, 0xa0, 0x02, 0x01, 0x40, 0x00, 0x34, 1175 0x01, 0x01, 0xa0, 0x02, 0x01, 0x40, 0x00, 0x34,
1169 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1176 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1170 0x00, 0x00, 0x55, 0x55, 0x55, 0x03, 0x82, 0x10, 1177 0x00, 0x00, 0x55, 0x55, 0x55, 0x03, 0x82, 0x10,
1171 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1178 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x10, 1179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x10,
1173 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1180 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 1181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04,
1175 0x00, 0x00, 0xa1, 0x55, 0x01, 0x08, 0x00, 0x00, 1182 0x00, 0x00, 0xa1, 0x55, 0x01, 0x08, 0x00, 0x00,
1176 0x00, 0x01, 0x48, 0x1c, 0x00, 0xfc, 0x00}; 1183 0x00, 0x01, 0x48, 0x1c, 0x00, 0xfc, 0x00};
1177 1184
1178 switch (Bitmap->Type) { 1185 switch (Bitmap->Type) {
1179 case GSM_ColourWallPaper_ID: 1186 case GSM_ColourWallPaper_ID:
1180 reqColourWallPaper[21] = Bitmap->ID; 1187 reqColourWallPaper[21] = Bitmap->ID;
1181 smprintf(s, "Setting colour wall paper\n"); 1188 smprintf(s, "Setting colour wall paper\n");
1182 return GSM_WaitFor (s, reqColourWallPaper, 22, 0x43, 4, ID_SetBitmap); 1189 return GSM_WaitFor (s, reqColourWallPaper, 22, 0x43, 4, ID_SetBitmap);
1183 case GSM_StartupLogo: 1190 case GSM_StartupLogo:
1184 Type = GSM_Nokia7110StartupLogo; 1191 Type = GSM_Nokia7110StartupLogo;
1185 switch (Bitmap->Location) { 1192 switch (Bitmap->Location) {
1186 case 1: PHONE_EncodeBitmap(Type, reqStartup + 22, Bitmap); 1193 case 1: PHONE_EncodeBitmap(Type, reqStartup + 22, Bitmap);
1187 break; 1194 break;
1188 case 2: memset(reqStartup+5,0x00,15); 1195 case 2: memset(reqStartup+5,0x00,15);
1189 PHONE_ClearBitmap(Type, reqStartup + 22,0,0); 1196 PHONE_ClearBitmap(Type, reqStartup + 22,0,0);
1190 break; 1197 break;
1191 default: return ERR_NOTSUPPORTED; 1198 default: return ERR_NOTSUPPORTED;
1192 } 1199 }
1193 smprintf(s, "Setting startup logo\n"); 1200 smprintf(s, "Setting startup logo\n");
1194 return GSM_WaitFor (s, reqStartup, 22+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap); 1201 return GSM_WaitFor (s, reqStartup, 22+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
1195 case GSM_DealerNote_Text: 1202 case GSM_DealerNote_Text:
1196 reqNote[4] = 0x10; 1203 reqNote[4] = 0x10;
1197 CopyUnicodeString(reqNote + 5, Bitmap->Text); 1204 CopyUnicodeString(reqNote + 5, Bitmap->Text);
1198 i = 6 + UnicodeLength(Bitmap->Text) * 2; 1205 i = 6 + UnicodeLength(Bitmap->Text) * 2;
1199 reqNote[i++] = 0; 1206 reqNote[i++] = 0;
1200 reqNote[i] = 0; 1207 reqNote[i] = 0;
1201 return GSM_WaitFor (s, reqNote, i, 0x7A, 4, ID_SetBitmap); 1208 return GSM_WaitFor (s, reqNote, i, 0x7A, 4, ID_SetBitmap);
1202 case GSM_WelcomeNote_Text: 1209 case GSM_WelcomeNote_Text:
1203 CopyUnicodeString(reqNote + 5, Bitmap->Text); 1210 CopyUnicodeString(reqNote + 5, Bitmap->Text);
1204 i = 6 + UnicodeLength(Bitmap->Text) * 2; 1211 i = 6 + UnicodeLength(Bitmap->Text) * 2;
1205 reqNote[i++] = 0; 1212 reqNote[i++] = 0;
1206 reqNote[i] = 0; 1213 reqNote[i] = 0;
1207 return GSM_WaitFor (s, reqNote, i, 0x7A, 4, ID_SetBitmap); 1214 return GSM_WaitFor (s, reqNote, i, 0x7A, 4, ID_SetBitmap);
1208 case GSM_OperatorLogo: 1215 case GSM_OperatorLogo:
1209 /* We want to set operator logo, not clear */ 1216 /* We want to set operator logo, not clear */
1210 if (strcmp(Bitmap->NetworkCode,"000 00")) { 1217 if (strcmp(Bitmap->NetworkCode,"000 00")) {
1211 memset(reqOp + 19, 0, 281); 1218 memset(reqOp + 19, 0, 281);
1212 NOKIA_EncodeNetworkCode(reqOp+12, Bitmap->NetworkCode); 1219 NOKIA_EncodeNetworkCode(reqOp+12, Bitmap->NetworkCode);
1213 Type = GSM_Nokia6510OperatorLogo; 1220 Type = GSM_Nokia6510OperatorLogo;
1214 reqOp[9] = 0x02;/* Logo enabled */ 1221 reqOp[9] = 0x02;/* Logo enabled */
1215 reqOp[18] = 0x1a;/* FIXME */ 1222 reqOp[18] = 0x1a;/* FIXME */
1216 reqOp[19] = PHONE_GetBitmapSize(Type,0,0) + 8 + 29 + 2; 1223 reqOp[19] = PHONE_GetBitmapSize(Type,0,0) + 8 + 29 + 2;
1217 PHONE_GetBitmapWidthHeight(Type, &Width, &Height); 1224 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
1218 reqOp[20] = Width; 1225 reqOp[20] = Width;
1219 reqOp[21] = Height; 1226 reqOp[21] = Height;
1220 reqOp[22] = 0x00; 1227 reqOp[22] = 0x00;
1221 reqOp[23] = PHONE_GetBitmapSize(Type,0,0) + 29; 1228 reqOp[23] = PHONE_GetBitmapSize(Type,0,0) + 29;
1222 reqOp[24] = 0x00; 1229 reqOp[24] = 0x00;
1223 reqOp[25] = PHONE_GetBitmapSize(Type,0,0) + 29; 1230 reqOp[25] = PHONE_GetBitmapSize(Type,0,0) + 29;
1224 PHONE_EncodeBitmap(Type, reqOp + 26, Bitmap); 1231 PHONE_EncodeBitmap(Type, reqOp + 26, Bitmap);
1225 smprintf(s, "Setting operator logo\n"); 1232 smprintf(s, "Setting operator logo\n");
1226 return GSM_WaitFor (s, reqOp, reqOp[19]+reqOp[11]+10, 0x0A, 4, ID_SetBitmap); 1233 return GSM_WaitFor (s, reqOp, reqOp[19]+reqOp[11]+10, 0x0A, 4, ID_SetBitmap);
1227 } else { 1234 } else {
1228 error=N6510_GetNetworkInfo(s,&NetInfo); 1235 error=N6510_GetNetworkInfo(s,&NetInfo);
1229 if (error != ERR_NONE) return error; 1236 if (error != ERR_NONE) return error;
1230 NOKIA_EncodeNetworkCode(reqOp+12, NetInfo.NetworkCode); 1237 NOKIA_EncodeNetworkCode(reqOp+12, NetInfo.NetworkCode);
1231 smprintf(s, "Clearing operator logo\n"); 1238 smprintf(s, "Clearing operator logo\n");
1232 return GSM_WaitFor (s, reqOp, 18, 0x0A, 4, ID_SetBitmap); 1239 return GSM_WaitFor (s, reqOp, 18, 0x0A, 4, ID_SetBitmap);
1233 } 1240 }
1234 case GSM_ColourOperatorLogo_ID: 1241 case GSM_ColourOperatorLogo_ID:
1235 /* We want to set operator logo, not clear */ 1242 /* We want to set operator logo, not clear */
1236 if (strcmp(Bitmap->NetworkCode,"000 00")) { 1243 if (strcmp(Bitmap->NetworkCode,"000 00")) {
1237 EncodeBCD(reqColourOp+23, Bitmap->NetworkCode, 6, false); 1244 EncodeBCD(reqColourOp+23, Bitmap->NetworkCode, 6, false);
1238 reqColourOp[21] = Bitmap->ID; 1245 reqColourOp[21] = Bitmap->ID;
1239 } 1246 }
1240 smprintf(s, "Setting colour operator logo\n"); 1247 smprintf(s, "Setting colour operator logo\n");
1241 return GSM_WaitFor (s, reqColourOp, 26, 0x43, 4, ID_SetBitmap); 1248 return GSM_WaitFor (s, reqColourOp, 26, 0x43, 4, ID_SetBitmap);
1242 case GSM_ColourStartupLogo_ID: 1249 case GSM_ColourStartupLogo_ID:
1243 switch (Bitmap->Location) { 1250 switch (Bitmap->Location) {
1244 case 0: reqColourStartup[6] = 0x00; 1251 case 0: reqColourStartup[6] = 0x00;
1245 reqColourStartup[8] = 0x00; 1252 reqColourStartup[8] = 0x00;
1246 smprintf(s, "Setting colour startup logo\n"); 1253 smprintf(s, "Setting colour startup logo\n");
1247 return GSM_WaitFor (s, reqColourStartup, 9, 0x7A, 4, ID_SetBitmap); 1254 return GSM_WaitFor (s, reqColourStartup, 9, 0x7A, 4, ID_SetBitmap);
1248 case 1: reqColourStartup[8] = Bitmap->ID; 1255 case 1: reqColourStartup[8] = Bitmap->ID;
1249 smprintf(s, "Setting colour startup logo\n"); 1256 smprintf(s, "Setting colour startup logo\n");
1250 return GSM_WaitFor (s, reqColourStartup, 9, 0x7A, 4, ID_SetBitmap); 1257 return GSM_WaitFor (s, reqColourStartup, 9, 0x7A, 4, ID_SetBitmap);
1251 default:return ERR_NOTSUPPORTED; 1258 default:return ERR_NOTSUPPORTED;
1252 } 1259 }
1253 case GSM_CallerGroupLogo: 1260 case GSM_CallerGroupLogo:
1254 return N6510_SetCallerLogo(s,Bitmap); 1261 return N6510_SetCallerLogo(s,Bitmap);
1255 case GSM_PictureImage: 1262 case GSM_PictureImage:
1256 error = N6510_GetPictureImage(s, Bitmap, &sms.Location); 1263 error = N6510_GetPictureImage(s, Bitmap, &sms.Location);
1257 if (error == ERR_NONE) { 1264 if (error == ERR_NONE) {
1258#ifdef DEVELOP
1259 sms.Folder = 0; 1265 sms.Folder = 0;
1260 N6510_GetSMSLocation(s, &sms, &folderid, &location); 1266 N6510_GetSMSLocation(s, &sms, &folderid, &location);
1261 switch (folderid) { 1267 switch (folderid) {
1262 case 0x01: reqPicture[5] = 0x02; break; /* INBOX SIM */ 1268 case 0x01: reqPicture[5] = 0x02; break; /* INBOX SIM */
1263 case 0x02: reqPicture[5] = 0x03; break; /* OUTBOX SIM */ 1269 case 0x02: reqPicture[5] = 0x03; break; /* OUTBOX SIM */
1264 default : reqPicture[5] = folderid - 1; reqPicture[4] = 0x02; break; /* ME folders*/ 1270 default : reqPicture[5] = folderid - 1; reqPicture[4] = 0x02; break; /* ME folders*/
1265 } 1271 }
1266 reqPicture[6]=location / 256; 1272 reqPicture[6]=location / 256;
1267 reqPicture[7]=location; 1273 reqPicture[7]=location;
1268#else
1269 return ERR_NOTSUPPORTED;
1270#endif
1271 } 1274 }
1272 Type = GSM_NokiaPictureImage; 1275 Type = GSM_NokiaPictureImage;
1273 count = 78; 1276 count = 78;
1274 PHONE_EncodeBitmap(Type, reqPicture + count, Bitmap); 1277 PHONE_EncodeBitmap(Type, reqPicture + count, Bitmap);
1275 count += PHONE_GetBitmapSize(Type,0,0); 1278 count += PHONE_GetBitmapSize(Type,0,0);
1276 smprintf(s, "Setting Picture Image\n"); 1279 smprintf(s, "Setting Picture Image\n");
1277 return GSM_WaitFor (s, reqPicture, count, 0x14, 4, ID_SetBitmap); 1280 return GSM_WaitFor (s, reqPicture, count, 0x14, 4, ID_SetBitmap);
1278 default: 1281 default:
1279 break; 1282 break;
1280 } 1283 }
1281 return ERR_NOTSUPPORTED; 1284 return ERR_NOTSUPPORTED;
1282} 1285}
1283 1286
1284static GSM_Error N6510_ReplyGetRingtoneID(GSM_Protocol_Message msg, GSM_StateMachine *s) 1287static GSM_Error N6510_ReplyGetRingtoneID(GSM_Protocol_Message msg, GSM_StateMachine *s)
1285{ 1288{
1286 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; 1289 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
1287 1290
1288 smprintf(s, "Ringtone ID received\n"); 1291 smprintf(s, "Ringtone ID received\n");
1289 Priv->RingtoneID = msg.Buffer[15]; 1292 Priv->RingtoneID = msg.Buffer[15];
1290 return ERR_NONE; 1293 return ERR_NONE;
1291} 1294}
1292 1295
1293static GSM_Error N6510_ReplySetBinRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) 1296static GSM_Error N6510_ReplySetBinRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
1294{ 1297{
1295 smprintf(s, "Binary ringtone set\n"); 1298 smprintf(s, "Binary ringtone set\n");
1296 return ERR_NONE; 1299 return ERR_NONE;
1297} 1300}
1298 1301
1299static GSM_Error N6510_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) 1302static GSM_Error N6510_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
1300{ 1303{
1301 GSM_Error error; 1304 GSM_Error error;
1302 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; 1305 GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
1303 GSM_NetworkInfo NetInfo; 1306 GSM_NetworkInfo NetInfo;
1304 int size=200, current; 1307 int size=200, current;
1305 unsigned char GetIDReq[] = { 1308 unsigned char GetIDReq[] = {
1306 N7110_FRAME_HEADER, 0x01, 0x00, 0x00, 1309 N7110_FRAME_HEADER, 0x01, 0x00, 0x00,
1307 0x00, 0xFF, 0x06, 0xE1, 0x00, 1310 0x00, 0xFF, 0x06, 0xE1, 0x00,
1308 0xFF, 0x06, 0xE1, 0x01, 0x42}; 1311 0xFF, 0x06, 0xE1, 0x01, 0x42};
1309 unsigned char SetPreviewReq[1000] = { 1312 unsigned char SetPreviewReq[1000] = {
1310 0xAE, /* Ringtone ID */ 1313 0xAE, /* Ringtone ID */
1311 0x01, 0x00, 0x0D, 0x00, 1314 0x01, 0x00, 0x0D, 0x00,
1312 0x00, 0x00, 0x00, 0x00, 0x00, 1315 0x00, 0x00, 0x00, 0x00, 0x00,
1313 0x00}; /*Length*/ 1316 0x00}; /*Length*/
1314 unsigned char AddBinaryReq[33000] = { 1317 unsigned char AddBinaryReq[33000] = {
1315 N7110_FRAME_HEADER, 0x0E, 0x7F, 0xFF, 0xFE}; 1318 N7110_FRAME_HEADER, 0x0E, 0x7F, 0xFF, 0xFE};
1316 1319
1317 if (Ringtone->Format == RING_NOTETONE && Ringtone->Location==255) 1320 if (Ringtone->Format == RING_NOTETONE && Ringtone->Location==255)
1318 { 1321 {
1319 smprintf(s, "Getting ringtone ID\n"); 1322 smprintf(s, "Getting ringtone ID\n");
1320 error=GSM_WaitFor (s, GetIDReq, 14, 0xDB, 4, ID_SetRingtone); 1323 error=GSM_WaitFor (s, GetIDReq, 14, 0xDB, 4, ID_SetRingtone);
1321 if (error != ERR_NONE) return error; 1324 if (error != ERR_NONE) return error;
1322 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, SetPreviewReq+11, &size); 1325 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, SetPreviewReq+11, &size);
1323 SetPreviewReq[0] = Priv->RingtoneID; 1326 SetPreviewReq[0] = Priv->RingtoneID;
1324 SetPreviewReq[10] = size; 1327 SetPreviewReq[10] = size;
1325 smprintf(s, "Setting ringtone\n"); 1328 smprintf(s, "Setting ringtone\n");
1326 error = s->Protocol.Functions->WriteMessage(s, SetPreviewReq, size+11, 0x00); 1329 error = s->Protocol.Functions->WriteMessage(s, SetPreviewReq, size+11, 0x00);
1327 if (error!=ERR_NONE) return error; 1330 if (error!=ERR_NONE) return error;
1328 my_sleep(1000); 1331 my_sleep(1000);
1329 /* We have to make something (not important, what) now */ 1332 /* We have to make something (not important, what) now */
1330 /* no answer from phone*/ 1333 /* no answer from phone*/
1331 return s->Phone.Functions->GetNetworkInfo(s,&NetInfo); 1334 return s->Phone.Functions->GetNetworkInfo(s,&NetInfo);
1332 } 1335 }
1333 if (Ringtone->Format == RING_NOKIABINARY) { 1336 if (Ringtone->Format == RING_NOKIABINARY) {
1334 AddBinaryReq[7] = UnicodeLength(Ringtone->Name); 1337 AddBinaryReq[7] = UnicodeLength(Ringtone->Name);
1335 CopyUnicodeString(AddBinaryReq+8,Ringtone->Name); 1338 CopyUnicodeString(AddBinaryReq+8,Ringtone->Name);
1336 current = 8 + UnicodeLength(Ringtone->Name)*2; 1339 current = 8 + UnicodeLength(Ringtone->Name)*2;
1337 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length/256 + 1; 1340 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length/256 + 1;
1338 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length%256 + 1; 1341 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length%256 + 1;
1339 AddBinaryReq[current++] = 0x00; 1342 AddBinaryReq[current++] = 0x00;
1340 memcpy(AddBinaryReq+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); 1343 memcpy(AddBinaryReq+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
1341 current += Ringtone->NokiaBinary.Length; 1344 current += Ringtone->NokiaBinary.Length;
1342 smprintf(s, "Adding binary ringtone\n"); 1345 smprintf(s, "Adding binary ringtone\n");
1343 return GSM_WaitFor (s, AddBinaryReq, current, 0x1F, 4, ID_SetRingtone); 1346 return GSM_WaitFor (s, AddBinaryReq, current, 0x1F, 4, ID_SetRingtone);
1344 } 1347 }
1345 if (Ringtone->Format == RING_MIDI) { 1348 if (Ringtone->Format == RING_MIDI) {
1346 AddBinaryReq[7] = UnicodeLength(Ringtone->Name); 1349 AddBinaryReq[7] = UnicodeLength(Ringtone->Name);
1347 CopyUnicodeString(AddBinaryReq+8,Ringtone->Name); 1350 CopyUnicodeString(AddBinaryReq+8,Ringtone->Name);
1348 current = 8 + UnicodeLength(Ringtone->Name)*2; 1351 current = 8 + UnicodeLength(Ringtone->Name)*2;
1349 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length/256; 1352 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length/256;
1350 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length%256; 1353 AddBinaryReq[current++] = Ringtone->NokiaBinary.Length%256;
1351 memcpy(AddBinaryReq+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); 1354 memcpy(AddBinaryReq+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
1352 current += Ringtone->NokiaBinary.Length; 1355 current += Ringtone->NokiaBinary.Length;
1353 AddBinaryReq[current++] = 0x00; 1356 AddBinaryReq[current++] = 0x00;
1354 AddBinaryReq[current++] = 0x00; 1357 AddBinaryReq[current++] = 0x00;
1355 smprintf(s, "Adding binary or MIDI ringtone\n"); 1358 smprintf(s, "Adding binary or MIDI ringtone\n");
1356 return GSM_WaitFor (s, AddBinaryReq, current, 0x1F, 4, ID_SetRingtone); 1359 return GSM_WaitFor (s, AddBinaryReq, current, 0x1F, 4, ID_SetRingtone);
1357 } 1360 }
1358 return ERR_NOTSUPPORTED; 1361 return ERR_NOTSUPPORTED;
1359} 1362}
1360 1363
1361static GSM_Error N6510_ReplyDeleteRingtones(GSM_Protocol_Message msg, GSM_StateMachine *s) 1364static GSM_Error N6510_ReplyDeleteRingtones(GSM_Protocol_Message msg, GSM_StateMachine *s)
1362{ 1365{
1363 smprintf(s, "Ringtones deleted\n"); 1366 smprintf(s, "Ringtones deleted\n");
1364 return ERR_NONE; 1367 return ERR_NONE;
1365} 1368}
1366 1369
1367static GSM_Error N6510_DeleteUserRingtones(GSM_StateMachine *s) 1370static GSM_Error N6510_DeleteUserRingtones(GSM_StateMachine *s)
1368{ 1371{
1369 unsigned char DelAllRingtoneReq[] = {N7110_FRAME_HEADER, 0x10, 0x7F, 0xFE}; 1372 unsigned char DelAllRingtoneReq[] = {N7110_FRAME_HEADER, 0x10, 0x7F, 0xFE};
1370 1373
1371 smprintf(s, "Deleting all user ringtones\n"); 1374 smprintf(s, "Deleting all user ringtones\n");
1372 return GSM_WaitFor (s, DelAllRingtoneReq, 6, 0x1F, 4, ID_SetRingtone); 1375 return GSM_WaitFor (s, DelAllRingtoneReq, 6, 0x1F, 4, ID_SetRingtone);
1373} 1376}
1374 1377
1375static GSM_Error N6510_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 1378static GSM_Error N6510_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
1376{ 1379{
1377#ifdef DEVELOP 1380#ifdef DEVELOP
1378 unsigned char req[] = {N6110_FRAME_HEADER, 0x11, 0x00, 0x01, 0x00, 0x00, 1381 unsigned char req[] = {N6110_FRAME_HEADER, 0x11, 0x00, 0x01, 0x00, 0x00,
1379 0x00, /* Event */ 1382 0x00, /* Event */
1380 0x01}; /* Number of presses */ 1383 0x01}; /* Number of presses */
1381 1384
1382 //req[7] = Key; 1385 //req[7] = Key;
1383 if (Press) { 1386 if (Press) {
1384 req[8] = NOKIA_PRESSPHONEKEY; 1387 req[8] = NOKIA_PRESSPHONEKEY;
1385 s->Phone.Data.PressKey = true; 1388 s->Phone.Data.PressKey = true;
1386 smprintf(s, "Pressing key\n"); 1389 smprintf(s, "Pressing key\n");
1387 } else { 1390 } else {
1388 req[8] = NOKIA_RELEASEPHONEKEY; 1391 req[8] = NOKIA_RELEASEPHONEKEY;
1389 s->Phone.Data.PressKey = false; 1392 s->Phone.Data.PressKey = false;
1390 smprintf(s, "Releasing key\n"); 1393 smprintf(s, "Releasing key\n");
1391 } 1394 }
1392 return GSM_WaitFor (s, req, 10, 0x0c, 4, ID_PressKey); 1395 return GSM_WaitFor (s, req, 10, 0x0c, 4, ID_PressKey);
1393#else 1396#else
1394 return ERR_NOTSUPPORTED; 1397 return ERR_NOTSUPPORTED;
1395#endif 1398#endif
1396} 1399}
1397 1400
1398static GSM_Error N6510_EnableConnectionFunctions(GSM_StateMachine *s, N6510_Connection_Settings Type) 1401static GSM_Error N6510_EnableConnectionFunctions(GSM_StateMachine *s, N6510_Connection_Settings Type)
1399{ 1402{
1400 GSM_Errorerror; 1403 GSM_Errorerror;
1401 unsigned char req2[] = {N6110_FRAME_HEADER, 0x00, 0x01}; 1404 unsigned char req2[] = {N6110_FRAME_HEADER, 0x00, 0x01};
1402 unsigned char req3[] = {N6110_FRAME_HEADER, 0x00, 0x03}; 1405 unsigned char req3[] = {N6110_FRAME_HEADER, 0x00, 0x03};
1403 unsigned char req4[] = {N6110_FRAME_HEADER, 0x00, 0x04}; 1406 unsigned char req4[] = {N6110_FRAME_HEADER, 0x00, 0x04};
1404 1407
1405 if (Type == N6510_MMS_SETTINGS && IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOMMS)) return ERR_NOTSUPPORTED; 1408 if (Type == N6510_MMS_SETTINGS && IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOMMS)) return ERR_NOTSUPPORTED;
1406 1409
1407 error=DCT3DCT4_DisableConnectionFunctions(s); 1410 error=DCT3DCT4_DisableConnectionFunctions(s);
1408 if (error!=ERR_NONE) return error; 1411 if (error!=ERR_NONE) return error;
1409 1412
1410 switch (Type) { 1413 switch (Type) {
1411 case N6510_WAP_SETTINGS: 1414 case N6510_WAP_SETTINGS:
1412 return DCT3DCT4_EnableWAPFunctions(s); 1415 return DCT3DCT4_EnableWAPFunctions(s);
1413 case N6510_MMS_SETTINGS: 1416 case N6510_MMS_SETTINGS:
1414 dbgprintf("Enabling MMS\n"); 1417 dbgprintf("Enabling MMS\n");
1415 return GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_EnableConnectFunc); 1418 return GSM_WaitFor (s, req2, 5, 0x3f, 4, ID_EnableConnectFunc);
1416 case N6510_SYNCML_SETTINGS: 1419 case N6510_SYNCML_SETTINGS:
1417 dbgprintf("Enabling SyncML\n"); 1420 dbgprintf("Enabling SyncML\n");
1418 return GSM_WaitFor (s, req3, 5, 0x3f, 5, ID_EnableConnectFunc); 1421 return GSM_WaitFor (s, req3, 5, 0x3f, 5, ID_EnableConnectFunc);
1419 case N6510_CHAT_SETTINGS: 1422 case N6510_CHAT_SETTINGS:
1420 dbgprintf("Enabling Chat\n"); 1423 dbgprintf("Enabling Chat\n");
1421 return GSM_WaitFor (s, req4, 5, 0x3f, 5, ID_EnableConnectFunc); 1424 return GSM_WaitFor (s, req4, 5, 0x3f, 5, ID_EnableConnectFunc);
1422 default: 1425 default:
1423 return ERR_UNKNOWN; 1426 return ERR_UNKNOWN;
1424 } 1427 }
1425} 1428}
1426 1429
1427static GSM_Error N6510_ReplyGetConnectionSettings(GSM_Protocol_Message msg, GSM_StateMachine *s) 1430static GSM_Error N6510_ReplyGetConnectionSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
1428{ 1431{
1429 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 1432 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
1430 int tmp,num=0,i; 1433 int tmp,num=0,i;
1431 GSM_Phone_Data *Data = &s->Phone.Data; 1434 GSM_Phone_Data *Data = &s->Phone.Data;
1432 unsigned char buff[2000]; 1435 unsigned char buff[2000];
1433 1436
1434 switch(msg.Buffer[3]) { 1437 switch(msg.Buffer[3]) {
1435 case 0x16: 1438 case 0x16:
1436 smprintf(s, "Connection settings received OK\n"); 1439 smprintf(s, "Connection settings received OK\n");
1437 1440
1438 Data->WAPSettings->Number = Priv->BearerNumber; 1441 Data->WAPSettings->Number = Priv->BearerNumber;
1439 1442
1440 Data->WAPSettings->Proxy[0] = 0x00; 1443 Data->WAPSettings->Proxy[0] = 0x00;
1441 Data->WAPSettings->Proxy[1] = 0x00; 1444 Data->WAPSettings->Proxy[1] = 0x00;
1442 Data->WAPSettings->ProxyPort = 8080; 1445 Data->WAPSettings->ProxyPort = 8080;
1443 1446
1444 Data->WAPSettings->Proxy2[0] = 0x00; 1447 Data->WAPSettings->Proxy2[0] = 0x00;
1445 Data->WAPSettings->Proxy2[1] = 0x00; 1448 Data->WAPSettings->Proxy2[1] = 0x00;
1446 Data->WAPSettings->Proxy2Port = 8080; 1449 Data->WAPSettings->Proxy2Port = 8080;
1447 1450
1448 tmp = 4; 1451 tmp = 4;
1449 1452
1450 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Title,true); 1453 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Title,true);
1451 CopyUnicodeString(Data->WAPSettings->Settings[1].Title,Data->WAPSettings->Settings[0].Title); 1454 CopyUnicodeString(Data->WAPSettings->Settings[1].Title,Data->WAPSettings->Settings[0].Title);
1452 smprintf(s, "Title: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Title)); 1455 smprintf(s, "Title: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Title));
1453 1456
1454 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].HomePage,true); 1457 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].HomePage,true);
1455 CopyUnicodeString(Data->WAPSettings->Settings[1].HomePage,Data->WAPSettings->Settings[0].HomePage); 1458 CopyUnicodeString(Data->WAPSettings->Settings[1].HomePage,Data->WAPSettings->Settings[0].HomePage);
1456 smprintf(s, "Homepage: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].HomePage)); 1459 smprintf(s, "Homepage: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].HomePage));
1457 1460
1458#ifdef DEBUG 1461#ifdef DEBUG
1459 smprintf(s, "Connection type: "); 1462 smprintf(s, "Connection type: ");
1460 switch (msg.Buffer[tmp]) { 1463 switch (msg.Buffer[tmp]) {
1461 case 0x00: smprintf(s, "temporary\n"); break; 1464 case 0x00: smprintf(s, "temporary\n"); break;
1462 case 0x01: smprintf(s, "continuous\n"); break; 1465 case 0x01: smprintf(s, "continuous\n"); break;
1463 default: smprintf(s, "unknown\n"); 1466 default: smprintf(s, "unknown\n");
1464 } 1467 }
1465 smprintf(s, "Connection security: "); 1468 smprintf(s, "Connection security: ");
1466 switch (msg.Buffer[tmp+1]) { 1469 switch (msg.Buffer[tmp+1]) {
1467 case 0x00: smprintf(s, "off\n");break; 1470 case 0x00: smprintf(s, "off\n");break;
1468 case 0x01: smprintf(s, "on\n"); break; 1471 case 0x01: smprintf(s, "on\n"); break;
1469 default: smprintf(s, "unknown\n"); 1472 default: smprintf(s, "unknown\n");
1470 } 1473 }
1471 smprintf(s, "Bearer: "); 1474 smprintf(s, "Bearer: ");
1472 switch (msg.Buffer[tmp+2]) { 1475 switch (msg.Buffer[tmp+2]) {
1473 case 0x01: smprintf(s, "GSM data\n");break; 1476 case 0x01: smprintf(s, "GSM data\n");break;
1474 case 0x03: smprintf(s, "GPRS\n");break; 1477 case 0x03: smprintf(s, "GPRS\n");break;
1475 default: smprintf(s, "unknown\n"); 1478 default: smprintf(s, "unknown\n");
1476 } 1479 }
1477 if (msg.Buffer[tmp+3] == 0x01) smprintf(s, "locked\n"); 1480 if (msg.Buffer[tmp+3] == 0x01) smprintf(s, "locked\n");
1478#endif 1481#endif
1479 Data->WAPSettings->Settings[0].IsContinuous = false; 1482 Data->WAPSettings->Settings[0].IsContinuous = false;
1480 if (msg.Buffer[tmp] == 0x01) Data->WAPSettings->Settings[0].IsContinuous = true; 1483 if (msg.Buffer[tmp] == 0x01) Data->WAPSettings->Settings[0].IsContinuous = true;
1481 Data->WAPSettings->Settings[1].IsContinuous = Data->WAPSettings->Settings[0].IsContinuous; 1484 Data->WAPSettings->Settings[1].IsContinuous = Data->WAPSettings->Settings[0].IsContinuous;
1482 1485
1483 Data->WAPSettings->Settings[0].IsSecurity = false; 1486 Data->WAPSettings->Settings[0].IsSecurity = false;
1484 if (msg.Buffer[tmp+1] == 0x01) Data->WAPSettings->Settings[0].IsSecurity = true; 1487 if (msg.Buffer[tmp+1] == 0x01) Data->WAPSettings->Settings[0].IsSecurity = true;
1485 Data->WAPSettings->Settings[1].IsSecurity = Data->WAPSettings->Settings[0].IsSecurity; 1488 Data->WAPSettings->Settings[1].IsSecurity = Data->WAPSettings->Settings[0].IsSecurity;
1486 1489
1487 Data->WAPSettings->ActiveBearer = WAPSETTINGS_BEARER_DATA; 1490 Data->WAPSettings->ActiveBearer = WAPSETTINGS_BEARER_DATA;
1488 if (msg.Buffer[tmp+2] == 0x03) Data->WAPSettings->ActiveBearer = WAPSETTINGS_BEARER_GPRS; 1491 if (msg.Buffer[tmp+2] == 0x03) Data->WAPSettings->ActiveBearer = WAPSETTINGS_BEARER_GPRS;
1489 1492
1490 Data->WAPSettings->ReadOnly = false; 1493 Data->WAPSettings->ReadOnly = false;
1491 if (msg.Buffer[tmp+3] == 0x01) Data->WAPSettings->ReadOnly = true; 1494 if (msg.Buffer[tmp+3] == 0x01) Data->WAPSettings->ReadOnly = true;
1492 1495
1493 tmp+=3; 1496 tmp+=3;
1494 1497
1495 if (Priv->BearerNumber == 2) { 1498 if (Priv->BearerNumber == 2) {
1496 /* Here starts settings for data bearer */ 1499 /* Here starts settings for data bearer */
1497 Data->WAPSettings->Settings[0].Bearer = WAPSETTINGS_BEARER_DATA; 1500 Data->WAPSettings->Settings[0].Bearer = WAPSETTINGS_BEARER_DATA;
1498 while ((msg.Buffer[tmp] != 0x01) || (msg.Buffer[tmp + 1] != 0x00)) tmp++; 1501 while ((msg.Buffer[tmp] != 0x01) || (msg.Buffer[tmp + 1] != 0x00)) tmp++;
1499 tmp += 4; 1502 tmp += 4;
1500 1503
1501#ifdef DEBUG 1504#ifdef DEBUG
1502 smprintf(s, "Authentication type: "); 1505 smprintf(s, "Authentication type: ");
1503 switch (msg.Buffer[tmp]) { 1506 switch (msg.Buffer[tmp]) {
1504 case 0x00: smprintf(s, "normal\n");break; 1507 case 0x00: smprintf(s, "normal\n");break;
1505 case 0x01: smprintf(s, "secure\n");break; 1508 case 0x01: smprintf(s, "secure\n");break;
1506 default: smprintf(s, "unknown\n");break; 1509 default: smprintf(s, "unknown\n");break;
1507 } 1510 }
1508 smprintf(s, "Data call type: "); 1511 smprintf(s, "Data call type: ");
1509 switch (msg.Buffer[tmp+1]) { 1512 switch (msg.Buffer[tmp+1]) {
1510 case 0x00: smprintf(s, "analogue\n");break; 1513 case 0x00: smprintf(s, "analogue\n");break;
1511 case 0x01: smprintf(s, "ISDN\n");break; 1514 case 0x01: smprintf(s, "ISDN\n");break;
1512 default: smprintf(s, "unknown\n");break; 1515 default: smprintf(s, "unknown\n");break;
1513 } 1516 }
1514 smprintf(s, "Data call speed: "); 1517 smprintf(s, "Data call speed: ");
1515 switch (msg.Buffer[tmp+2]) { 1518 switch (msg.Buffer[tmp+2]) {
1516 case 0x00: smprintf(s, "automatic\n"); break; 1519 case 0x00: smprintf(s, "automatic\n"); break;
1517 case 0x01: smprintf(s, "9600\n");break; 1520 case 0x01: smprintf(s, "9600\n");break;
1518 case 0x02: smprintf(s, "14400\n");break; 1521 case 0x02: smprintf(s, "14400\n");break;
1519 default: smprintf(s, "unknown\n");break; 1522 default: smprintf(s, "unknown\n");break;
1520 } 1523 }
1521 smprintf(s, "Login Type: "); 1524 smprintf(s, "Login Type: ");
1522 switch (msg.Buffer[tmp+4]) { 1525 switch (msg.Buffer[tmp+4]) {
1523 case 0x00: smprintf(s, "manual\n");break; 1526 case 0x00: smprintf(s, "manual\n");break;
1524 case 0x01: smprintf(s, "automatic\n");break; 1527 case 0x01: smprintf(s, "automatic\n");break;
1525 default: smprintf(s, "unknown\n");break; 1528 default: smprintf(s, "unknown\n");break;
1526 } 1529 }
1527#endif 1530#endif
1528 Data->WAPSettings->Settings[0].IsNormalAuthentication=true; 1531 Data->WAPSettings->Settings[0].IsNormalAuthentication=true;
1529 if (msg.Buffer[tmp]==0x01) Data->WAPSettings->Settings[0].IsNormalAuthentication=false; 1532 if (msg.Buffer[tmp]==0x01) Data->WAPSettings->Settings[0].IsNormalAuthentication=false;
1530 1533
1531 Data->WAPSettings->Settings[0].IsISDNCall=false; 1534 Data->WAPSettings->Settings[0].IsISDNCall=false;
1532 if (msg.Buffer[tmp+1]==0x01) Data->WAPSettings->Settings[0].IsISDNCall=true; 1535 if (msg.Buffer[tmp+1]==0x01) Data->WAPSettings->Settings[0].IsISDNCall=true;
1533 1536
1534 switch (msg.Buffer[tmp+2]) { 1537 switch (msg.Buffer[tmp+2]) {
1535 case 0x00: Data->WAPSettings->Settings[0].Speed=WAPSETTINGS_SPEED_AUTO; break; 1538 case 0x00: Data->WAPSettings->Settings[0].Speed=WAPSETTINGS_SPEED_AUTO; break;
1536 case 0x01: Data->WAPSettings->Settings[0].Speed=WAPSETTINGS_SPEED_9600; break; 1539 case 0x01: Data->WAPSettings->Settings[0].Speed=WAPSETTINGS_SPEED_9600; break;
1537 case 0x02: Data->WAPSettings->Settings[0].Speed=WAPSETTINGS_SPEED_14400; break; 1540 case 0x02: Data->WAPSettings->Settings[0].Speed=WAPSETTINGS_SPEED_14400; break;
1538 } 1541 }
1539 1542
1540 Data->WAPSettings->Settings[0].ManualLogin=false; 1543 Data->WAPSettings->Settings[0].ManualLogin=false;
1541 if (msg.Buffer[tmp+4]==0x00) Data->WAPSettings->Settings[0].ManualLogin = true; 1544 if (msg.Buffer[tmp+4]==0x00) Data->WAPSettings->Settings[0].ManualLogin = true;
1542 1545
1543 tmp+=5; 1546 tmp+=5;
1544 1547
1545 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].IPAddress,false); 1548 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].IPAddress,false);
1546 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].IPAddress)); 1549 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].IPAddress));
1547 1550
1548 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].DialUp,true); 1551 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].DialUp,true);
1549 smprintf(s, "Dial-up number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].DialUp)); 1552 smprintf(s, "Dial-up number: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].DialUp));
1550 1553
1551 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].User,true); 1554 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].User,true);
1552 smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].User)); 1555 smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].User));
1553 1556
1554 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Password,true); 1557 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[0].Password,true);
1555 smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Password)); 1558 smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[0].Password));
1556 1559
1557 num = 1; 1560 num = 1;
1558 } else { 1561 } else {
1559 num = 0; 1562 num = 0;
1560 } 1563 }
1561 1564
1562 /* Here starts settings for gprs bearer */ 1565 /* Here starts settings for gprs bearer */
1563 Data->WAPSettings->Settings[num].Bearer = WAPSETTINGS_BEARER_GPRS; 1566 Data->WAPSettings->Settings[num].Bearer = WAPSETTINGS_BEARER_GPRS;
1564 while (msg.Buffer[tmp] != 0x03) tmp++; 1567 while (msg.Buffer[tmp] != 0x03) tmp++;
1565 tmp += 4; 1568 tmp += 4;
1566 1569
1567#ifdef DEBUG 1570#ifdef DEBUG
1568 smprintf(s, "Authentication type: "); 1571 smprintf(s, "Authentication type: ");
1569 switch (msg.Buffer[tmp]) { 1572 switch (msg.Buffer[tmp]) {
1570 case 0x00: smprintf(s, "normal\n");break; 1573 case 0x00: smprintf(s, "normal\n");break;
1571 case 0x01: smprintf(s, "secure\n");break; 1574 case 0x01: smprintf(s, "secure\n");break;
1572 default: smprintf(s, "unknown\n");break; 1575 default: smprintf(s, "unknown\n");break;
1573 } 1576 }
1574 smprintf(s, "GPRS connection: "); 1577 smprintf(s, "GPRS connection: ");
1575 switch (msg.Buffer[tmp+1]) { 1578 switch (msg.Buffer[tmp+1]) {
1576 case 0x00: smprintf(s, "ALWAYS online\n"); break; 1579 case 0x00: smprintf(s, "ALWAYS online\n"); break;
1577 case 0x01: smprintf(s, "when needed\n"); break; 1580 case 0x01: smprintf(s, "when needed\n"); break;
1578 default: smprintf(s, "unknown\n"); break; 1581 default: smprintf(s, "unknown\n"); break;
1579 } 1582 }
1580 smprintf(s, "Login Type: "); 1583 smprintf(s, "Login Type: ");
1581 switch (msg.Buffer[tmp+2]) { 1584 switch (msg.Buffer[tmp+2]) {
1582 case 0x00: smprintf(s, "manual\n");break; 1585 case 0x00: smprintf(s, "manual\n");break;
1583 case 0x01: smprintf(s, "automatic\n");break; 1586 case 0x01: smprintf(s, "automatic\n");break;
1584 default: smprintf(s, "unknown\n");break; 1587 default: smprintf(s, "unknown\n");break;
1585 } 1588 }
1586#endif 1589#endif
1587 Data->WAPSettings->Settings[num].IsNormalAuthentication=true; 1590 Data->WAPSettings->Settings[num].IsNormalAuthentication=true;
1588 if (msg.Buffer[tmp]==0x01) Data->WAPSettings->Settings[num].IsNormalAuthentication=false; 1591 if (msg.Buffer[tmp]==0x01) Data->WAPSettings->Settings[num].IsNormalAuthentication=false;
1589 1592
1590 Data->WAPSettings->Settings[num].IsContinuous = true; 1593 Data->WAPSettings->Settings[num].IsContinuous = true;
1591 if (msg.Buffer[tmp+1] == 0x01) Data->WAPSettings->Settings[num].IsContinuous = false; 1594 if (msg.Buffer[tmp+1] == 0x01) Data->WAPSettings->Settings[num].IsContinuous = false;
1592 1595
1593 Data->WAPSettings->Settings[num].ManualLogin=false; 1596 Data->WAPSettings->Settings[num].ManualLogin=false;
1594 if (msg.Buffer[tmp+2]==0x00) Data->WAPSettings->Settings[num].ManualLogin = true; 1597 if (msg.Buffer[tmp+2]==0x00) Data->WAPSettings->Settings[num].ManualLogin = true;
1595 1598
1596 tmp+=3; 1599 tmp+=3;
1597 1600
1598 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].DialUp,false); 1601 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].DialUp,false);
1599 smprintf(s, "Access point: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].DialUp)); 1602 smprintf(s, "Access point: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].DialUp));
1600 1603
1601 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].IPAddress,true); 1604 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].IPAddress,true);
1602 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].IPAddress)); 1605 smprintf(s, "IP address: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].IPAddress));
1603 1606
1604 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].User,true); 1607 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].User,true);
1605 smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].User)); 1608 smprintf(s, "User name: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].User));
1606 1609
1607 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].Password,true); 1610 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer, Data->WAPSettings->Settings[num].Password,true);
1608 smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].Password)); 1611 smprintf(s, "Password: \"%s\"\n",DecodeUnicodeString(Data->WAPSettings->Settings[num].Password));
1609 1612
1610 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_WAPMMSPROXY)) { 1613 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_WAPMMSPROXY)) {
1611 if (msg.Buffer[tmp] == 0x00 && msg.Buffer[tmp+1] == 0x00) tmp = tmp+2; 1614 if (msg.Buffer[tmp] == 0x00 && msg.Buffer[tmp+1] == 0x00) tmp = tmp+2;
1612 1615
1613 memcpy(buff,msg.Buffer+tmp+10,msg.Buffer[tmp+4]); 1616 memcpy(buff,msg.Buffer+tmp+10,msg.Buffer[tmp+4]);
1614 buff[msg.Buffer[tmp+4]] = 0x00; 1617 buff[msg.Buffer[tmp+4]] = 0x00;
1615 smprintf(s, "Proxy 1: \"%s\", port %i\n",buff,msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7]); 1618 smprintf(s, "Proxy 1: \"%s\", port %i\n",buff,msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7]);
1616 EncodeUnicode(Data->WAPSettings->Proxy,buff,strlen(buff)); 1619 EncodeUnicode(Data->WAPSettings->Proxy,buff,strlen(buff));
1617 Data->WAPSettings->ProxyPort = msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7]; 1620 Data->WAPSettings->ProxyPort = msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7];
1618 1621
1619 memcpy(buff,msg.Buffer+tmp+10+msg.Buffer[tmp+4],msg.Buffer[tmp+5]); 1622 memcpy(buff,msg.Buffer+tmp+10+msg.Buffer[tmp+4],msg.Buffer[tmp+5]);
1620 buff[msg.Buffer[tmp+5]] = 0x00; 1623 buff[msg.Buffer[tmp+5]] = 0x00;
1621 smprintf(s, "Proxy 2: \"%s\", port %i\n",buff,msg.Buffer[tmp+8]*256+msg.Buffer[tmp+9]); 1624 smprintf(s, "Proxy 2: \"%s\", port %i\n",buff,msg.Buffer[tmp+8]*256+msg.Buffer[tmp+9]);
1622 EncodeUnicode(Data->WAPSettings->Proxy2,buff,strlen(buff)); 1625 EncodeUnicode(Data->WAPSettings->Proxy2,buff,strlen(buff));
1623 Data->WAPSettings->Proxy2Port = msg.Buffer[tmp+8]*256+msg.Buffer[tmp+9]; 1626 Data->WAPSettings->Proxy2Port = msg.Buffer[tmp+8]*256+msg.Buffer[tmp+9];
1624 1627
1625 tmp = tmp + msg.Buffer[tmp+3] + 19; 1628 tmp = tmp + msg.Buffer[tmp+3] + 19;
1626 1629
1627 for (i=0;i<4;i++) { 1630 for (i=0;i<4;i++) {
1628#ifdef DEBUG 1631#ifdef DEBUG
1629 smprintf(s, "Proxy data %i\n",i+1); 1632 smprintf(s, "Proxy data %i\n",i+1);
1630 if (msg.Buffer[tmp+2]!=0) memcpy(buff,msg.Buffer+tmp+9,msg.Buffer[tmp+2]*2); 1633 if (msg.Buffer[tmp+2]!=0) memcpy(buff,msg.Buffer+tmp+9,msg.Buffer[tmp+2]*2);
1631 buff[msg.Buffer[tmp+2]*2] =0; 1634 buff[msg.Buffer[tmp+2]*2] =0;
1632 buff[msg.Buffer[tmp+2]*2+1]=0; 1635 buff[msg.Buffer[tmp+2]*2+1]=0;
1633 smprintf(s, "IP: \"%s\"",DecodeUnicodeString(buff)); 1636 smprintf(s, "IP: \"%s\"",DecodeUnicodeString(buff));
1634 smprintf(s, ", port %i\n",msg.Buffer[tmp+3]*256+msg.Buffer[tmp+4]); 1637 smprintf(s, ", port %i\n",msg.Buffer[tmp+3]*256+msg.Buffer[tmp+4]);
1635#endif 1638#endif
1636 tmp = tmp + msg.Buffer[tmp]; 1639 tmp = tmp + msg.Buffer[tmp];
1637 } 1640 }
1638 1641
1639#ifdef DEBUG 1642#ifdef DEBUG
1640 smprintf(s, "%02x %02x\n",msg.Buffer[tmp],msg.Buffer[tmp+1]); 1643 smprintf(s, "%02x %02x\n",msg.Buffer[tmp],msg.Buffer[tmp+1]);
1641 smprintf(s, "Port %i\n",msg.Buffer[tmp+3]*256+msg.Buffer[tmp+4]); 1644 smprintf(s, "Port %i\n",msg.Buffer[tmp+3]*256+msg.Buffer[tmp+4]);
1642 tmp = tmp + msg.Buffer[tmp]; 1645 tmp = tmp + msg.Buffer[tmp];
1643#endif 1646#endif
1644 } 1647 }
1645 1648
1646 return ERR_NONE; 1649 return ERR_NONE;
1647 case 0x17: 1650 case 0x17:
1648 smprintf(s, "Connection settings receiving error\n"); 1651 smprintf(s, "Connection settings receiving error\n");
1649 switch (msg.Buffer[4]) { 1652 switch (msg.Buffer[4]) {
1650 case 0x01: 1653 case 0x01:
1651 smprintf(s, "Security error. Inside phone settings menu\n"); 1654 smprintf(s, "Security error. Inside phone settings menu\n");
1652 return ERR_INSIDEPHONEMENU; 1655 return ERR_INSIDEPHONEMENU;
1653 case 0x02: 1656 case 0x02:
1654 smprintf(s, "Invalid or empty\n"); 1657 smprintf(s, "Invalid or empty\n");
@@ -2038,1124 +2041,1131 @@ static GSM_Error N6510_SetConnectionSettings(GSM_StateMachine *s, GSM_MultiWAPSe
2038 req[pos++] = (UnicodeLength(settings->Proxy)+UnicodeLength(settings->Proxy2)+12)/256; 2041 req[pos++] = (UnicodeLength(settings->Proxy)+UnicodeLength(settings->Proxy2)+12)/256;
2039 req[pos++] = (UnicodeLength(settings->Proxy)+UnicodeLength(settings->Proxy2)+12)%256; 2042 req[pos++] = (UnicodeLength(settings->Proxy)+UnicodeLength(settings->Proxy2)+12)%256;
2040 } 2043 }
2041 req[pos++] = UnicodeLength(settings->Proxy); 2044 req[pos++] = UnicodeLength(settings->Proxy);
2042 req[pos++] = UnicodeLength(settings->Proxy2); 2045 req[pos++] = UnicodeLength(settings->Proxy2);
2043 req[pos++] = settings->ProxyPort/256; 2046 req[pos++] = settings->ProxyPort/256;
2044 req[pos++] = settings->ProxyPort%256; 2047 req[pos++] = settings->ProxyPort%256;
2045 req[pos++] = settings->Proxy2Port/256; 2048 req[pos++] = settings->Proxy2Port/256;
2046 req[pos++] = settings->Proxy2Port%256; 2049 req[pos++] = settings->Proxy2Port%256;
2047 if (UnicodeLength(settings->Proxy)!=0) { 2050 if (UnicodeLength(settings->Proxy)!=0) {
2048 sprintf(req+pos,"%s",DecodeUnicodeString(settings->Proxy)); 2051 sprintf(req+pos,"%s",DecodeUnicodeString(settings->Proxy));
2049 pos+=UnicodeLength(settings->Proxy); 2052 pos+=UnicodeLength(settings->Proxy);
2050 } 2053 }
2051 if (UnicodeLength(settings->Proxy2)!=0) { 2054 if (UnicodeLength(settings->Proxy2)!=0) {
2052 sprintf(req+pos,"%s",DecodeUnicodeString(settings->Proxy2)); 2055 sprintf(req+pos,"%s",DecodeUnicodeString(settings->Proxy2));
2053 pos+=UnicodeLength(settings->Proxy2); 2056 pos+=UnicodeLength(settings->Proxy2);
2054 } 2057 }
2055 if (UnicodeLength(settings->Proxy)!=0 || 2058 if (UnicodeLength(settings->Proxy)!=0 ||
2056 UnicodeLength(settings->Proxy2)!=0) { 2059 UnicodeLength(settings->Proxy2)!=0) {
2057 req[pos++] = 0x00; 2060 req[pos++] = 0x00;
2058 } 2061 }
2059 req[pos++] = 0x00; req[pos++] = 0x00; 2062 req[pos++] = 0x00; req[pos++] = 0x00;
2060 req[pos++] = 0x07; //unknown 2063 req[pos++] = 0x07; //unknown
2061 req[pos++] = 0x00; req[pos++] = 0x00; 2064 req[pos++] = 0x00; req[pos++] = 0x00;
2062 req[pos++] = 0x80; //unknown 2065 req[pos++] = 0x80; //unknown
2063 req[pos++] = 0x01; //unknown 2066 req[pos++] = 0x01; //unknown
2064 req[pos++] = 0x05; //unknown 2067 req[pos++] = 0x05; //unknown
2065 req[pos++] = 0x00; req[pos++] = 0x00; 2068 req[pos++] = 0x00; req[pos++] = 0x00;
2066 2069
2067 /* Proxy data blocks */ 2070 /* Proxy data blocks */
2068 for (i=0;i<4;i++) { 2071 for (i=0;i<4;i++) {
2069 port = 8080; 2072 port = 8080;
2070 Proxy = NULL; 2073 Proxy = NULL;
2071 if (i==0) { 2074 if (i==0) {
2072 port = settings->ProxyPort; 2075 port = settings->ProxyPort;
2073 Proxy = settings->Proxy; 2076 Proxy = settings->Proxy;
2074 } else if (i==1) { 2077 } else if (i==1) {
2075 port = settings->Proxy2Port; 2078 port = settings->Proxy2Port;
2076 Proxy = settings->Proxy2; 2079 Proxy = settings->Proxy2;
2077 } 2080 }
2078 req[pos++] = 0x08; req[pos++] = 0x00; 2081 req[pos++] = 0x08; req[pos++] = 0x00;
2079 if (Proxy != NULL && UnicodeLength(Proxy)!=0) { 2082 if (Proxy != NULL && UnicodeLength(Proxy)!=0) {
2080 if (UnicodeLength(Proxy)%2 != 0) { 2083 if (UnicodeLength(Proxy)%2 != 0) {
2081 req[pos++] = (12 + (UnicodeLength(Proxy)+1)*2)/256; 2084 req[pos++] = (12 + (UnicodeLength(Proxy)+1)*2)/256;
2082 req[pos++] = (12 + (UnicodeLength(Proxy)+1)*2)%256; 2085 req[pos++] = (12 + (UnicodeLength(Proxy)+1)*2)%256;
2083 } else { 2086 } else {
2084 req[pos++] = (12 + UnicodeLength(Proxy)*2)/256; 2087 req[pos++] = (12 + UnicodeLength(Proxy)*2)/256;
2085 req[pos++] = (12 + UnicodeLength(Proxy)*2)%256; 2088 req[pos++] = (12 + UnicodeLength(Proxy)*2)%256;
2086 } 2089 }
2087 } else { 2090 } else {
2088 req[pos++] = 12/256; 2091 req[pos++] = 12/256;
2089 req[pos++] = 12%256; 2092 req[pos++] = 12%256;
2090 } 2093 }
2091 req[pos++] = i+1; 2094 req[pos++] = i+1;
2092 if (Proxy != NULL) { 2095 if (Proxy != NULL) {
2093 req[pos++] = UnicodeLength(Proxy); 2096 req[pos++] = UnicodeLength(Proxy);
2094 } else { 2097 } else {
2095 req[pos++] = 0; 2098 req[pos++] = 0;
2096 } 2099 }
2097 req[pos++] = port/256; 2100 req[pos++] = port/256;
2098 req[pos++] = port%256; 2101 req[pos++] = port%256;
2099 req[pos++] = 0x00; 2102 req[pos++] = 0x00;
2100 2103
2101 req[pos++] = 0x00; 2104 req[pos++] = 0x00;
2102 req[pos++] = 0x01; 2105 req[pos++] = 0x01;
2103 2106
2104 req[pos++] = 0x00; 2107 req[pos++] = 0x00;
2105 if (Proxy != NULL && UnicodeLength(Proxy)!=0) { 2108 if (Proxy != NULL && UnicodeLength(Proxy)!=0) {
2106 CopyUnicodeString(req+pos,Proxy); 2109 CopyUnicodeString(req+pos,Proxy);
2107 pos+=UnicodeLength(Proxy)*2; 2110 pos+=UnicodeLength(Proxy)*2;
2108 if (UnicodeLength(Proxy)%2 != 0) { 2111 if (UnicodeLength(Proxy)%2 != 0) {
2109 req[pos++] = 0x00; 2112 req[pos++] = 0x00;
2110 req[pos++] = 0x00; 2113 req[pos++] = 0x00;
2111 } 2114 }
2112 } 2115 }
2113 } 2116 }
2114 2117
2115 req[pos++] = 0x09; req[pos++] = 0x00; req[pos++] = 0x00; 2118 req[pos++] = 0x09; req[pos++] = 0x00; req[pos++] = 0x00;
2116 req[pos++] = 0x0C; req[pos++] = 0x02; req[pos++] = 0x00; 2119 req[pos++] = 0x0C; req[pos++] = 0x02; req[pos++] = 0x00;
2117 req[pos++] = 0x00; req[pos++] = 0x02; req[pos++] = 0x00; 2120 req[pos++] = 0x00; req[pos++] = 0x02; req[pos++] = 0x00;
2118 req[pos++] = 0x00; req[pos++] = 0x00; req[pos++] = 0x00; 2121 req[pos++] = 0x00; req[pos++] = 0x00; req[pos++] = 0x00;
2119 } else { 2122 } else {
2120 /* end of blocks ? */ 2123 /* end of blocks ? */
2121 memcpy(req + pos, "\x80\x00\x00\x0c", 4);pos += 4; 2124 memcpy(req + pos, "\x80\x00\x00\x0c", 4);pos += 4;
2122 } 2125 }
2123 2126
2124 UnLock[4] = settings->Location-1; 2127 UnLock[4] = settings->Location-1;
2125 smprintf(s, "Making Connection settings read-write\n"); 2128 smprintf(s, "Making Connection settings read-write\n");
2126 error = GSM_WaitFor (s, UnLock, 5, 0x3f, 4, ID_SetConnectSet); 2129 error = GSM_WaitFor (s, UnLock, 5, 0x3f, 4, ID_SetConnectSet);
2127 if (error != ERR_NONE) return error; 2130 if (error != ERR_NONE) return error;
2128 2131
2129 switch (Type) { 2132 switch (Type) {
2130 case N6510_MMS_SETTINGS: 2133 case N6510_MMS_SETTINGS:
2131 smprintf(s, "Setting MMS settings\n"); 2134 smprintf(s, "Setting MMS settings\n");
2132 break; 2135 break;
2133 case N6510_CHAT_SETTINGS: 2136 case N6510_CHAT_SETTINGS:
2134 smprintf(s, "Setting Chat settings\n"); 2137 smprintf(s, "Setting Chat settings\n");
2135 break; 2138 break;
2136 case N6510_WAP_SETTINGS: 2139 case N6510_WAP_SETTINGS:
2137 smprintf(s, "Setting WAP settings\n"); 2140 smprintf(s, "Setting WAP settings\n");
2138 break; 2141 break;
2139 case N6510_SYNCML_SETTINGS: 2142 case N6510_SYNCML_SETTINGS:
2140 smprintf(s, "Setting SyncML settings\n"); 2143 smprintf(s, "Setting SyncML settings\n");
2141 break; 2144 break;
2142 } 2145 }
2143 error = GSM_WaitFor (s, req, pos, 0x3f, 4, ID_SetConnectSet); 2146 error = GSM_WaitFor (s, req, pos, 0x3f, 4, ID_SetConnectSet);
2144 if (error != ERR_NONE) { 2147 if (error != ERR_NONE) {
2145 if (error == ERR_INSIDEPHONEMENU || error == ERR_INVALIDLOCATION) { 2148 if (error == ERR_INSIDEPHONEMENU || error == ERR_INVALIDLOCATION) {
2146 DCT3DCT4_DisableConnectionFunctions(s); 2149 DCT3DCT4_DisableConnectionFunctions(s);
2147 } 2150 }
2148 return error; 2151 return error;
2149 } 2152 }
2150 2153
2151 if (settings->ReadOnly) { 2154 if (settings->ReadOnly) {
2152 Lock[4] = settings->Location-1; 2155 Lock[4] = settings->Location-1;
2153 smprintf(s, "Making Connection settings readonly\n"); 2156 smprintf(s, "Making Connection settings readonly\n");
2154 error = GSM_WaitFor (s, Lock, 5, 0x3f, 4, ID_SetConnectSet); 2157 error = GSM_WaitFor (s, Lock, 5, 0x3f, 4, ID_SetConnectSet);
2155 if (error != ERR_NONE) return error; 2158 if (error != ERR_NONE) return error;
2156 } 2159 }
2157 2160
2158 error = DCT3DCT4_SetActiveConnectSet(s, settings); 2161 error = DCT3DCT4_SetActiveConnectSet(s, settings);
2159 if (error != ERR_NONE) return error; 2162 if (error != ERR_NONE) return error;
2160 2163
2161 return DCT3DCT4_DisableConnectionFunctions(s); 2164 return DCT3DCT4_DisableConnectionFunctions(s);
2162} 2165}
2163 2166
2164static GSM_Error N6510_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings) 2167static GSM_Error N6510_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
2165{ 2168{
2166 return N6510_SetConnectionSettings(s, settings, N6510_WAP_SETTINGS); 2169 return N6510_SetConnectionSettings(s, settings, N6510_WAP_SETTINGS);
2167} 2170}
2168 2171
2169static GSM_Error N6510_SetMMSSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings) 2172static GSM_Error N6510_SetMMSSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
2170{ 2173{
2171 return N6510_SetConnectionSettings(s, settings, N6510_MMS_SETTINGS); 2174 return N6510_SetConnectionSettings(s, settings, N6510_MMS_SETTINGS);
2172} 2175}
2173 2176
2174static GSM_Error N6510_ReplyGetOriginalIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s) 2177static GSM_Error N6510_ReplyGetOriginalIMEI(GSM_Protocol_Message msg, GSM_StateMachine *s)
2175{ 2178{
2176 if (msg.Buffer[7] == 0x00) { 2179 if (msg.Buffer[7] == 0x00) {
2177 smprintf(s, "No SIM card\n"); 2180 smprintf(s, "No SIM card\n");
2178 return ERR_SECURITYERROR; 2181 return ERR_SECURITYERROR;
2179 } else { 2182 } else {
2180 return NOKIA_ReplyGetPhoneString(msg, s); 2183 return NOKIA_ReplyGetPhoneString(msg, s);
2181 } 2184 }
2182} 2185}
2183 2186
2184static GSM_Error N6510_GetOriginalIMEI(GSM_StateMachine *s, char *value) 2187static GSM_Error N6510_GetOriginalIMEI(GSM_StateMachine *s, char *value)
2185{ 2188{
2186 return NOKIA_GetPhoneString(s,"\x00\x07\x02\x01\x00\x01",6,0x42,value,ID_GetOriginalIMEI,14); 2189 return NOKIA_GetPhoneString(s,"\x00\x07\x02\x01\x00\x01",6,0x42,value,ID_GetOriginalIMEI,14);
2187} 2190}
2188 2191
2189static GSM_Error N6510_ReplyGetSMSStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 2192static GSM_Error N6510_ReplyGetSMSStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
2190{ 2193{
2191 GSM_Phone_Data *Data = &s->Phone.Data; 2194 GSM_Phone_Data *Data = &s->Phone.Data;
2192 2195
2193 switch (msg.Buffer[3]) { 2196 switch (msg.Buffer[3]) {
2194 case 0x09: 2197 case 0x09:
2195 switch (msg.Buffer[4]) { 2198 switch (msg.Buffer[4]) {
2196 case 0x00: 2199 case 0x00:
2197 smprintf(s, "Max. in phone memory : %i\n",msg.Buffer[10]*256+msg.Buffer[11]); 2200 smprintf(s, "Max. in phone memory : %i\n",msg.Buffer[10]*256+msg.Buffer[11]);
2198 smprintf(s, "Used in phone memory : %i\n",msg.Buffer[12]*256+msg.Buffer[13]); 2201 smprintf(s, "Used in phone memory : %i\n",msg.Buffer[12]*256+msg.Buffer[13]);
2199 smprintf(s, "Unread in phone memory : %i\n",msg.Buffer[14]*256+msg.Buffer[15]); 2202 smprintf(s, "Unread in phone memory : %i\n",msg.Buffer[14]*256+msg.Buffer[15]);
2200 smprintf(s, "Max. in SIM : %i\n",msg.Buffer[22]*256+msg.Buffer[23]); 2203 smprintf(s, "Max. in SIM : %i\n",msg.Buffer[22]*256+msg.Buffer[23]);
2201 smprintf(s, "Used in SIM : %i\n",msg.Buffer[24]*256+msg.Buffer[25]); 2204 smprintf(s, "Used in SIM : %i\n",msg.Buffer[24]*256+msg.Buffer[25]);
2202 smprintf(s, "Unread in SIM : %i\n",msg.Buffer[26]*256+msg.Buffer[27]); 2205 smprintf(s, "Unread in SIM : %i\n",msg.Buffer[26]*256+msg.Buffer[27]);
2203 Data->SMSStatus->PhoneSize= msg.Buffer[10]*256+msg.Buffer[11]; 2206 Data->SMSStatus->PhoneSize= msg.Buffer[10]*256+msg.Buffer[11];
2204 Data->SMSStatus->PhoneUsed= msg.Buffer[12]*256+msg.Buffer[13]; 2207 Data->SMSStatus->PhoneUsed= msg.Buffer[12]*256+msg.Buffer[13];
2205 Data->SMSStatus->PhoneUnRead = msg.Buffer[14]*256+msg.Buffer[15]; 2208 Data->SMSStatus->PhoneUnRead = msg.Buffer[14]*256+msg.Buffer[15];
2206 Data->SMSStatus->SIMSize= msg.Buffer[22]*256+msg.Buffer[23]; 2209 Data->SMSStatus->SIMSize= msg.Buffer[22]*256+msg.Buffer[23];
2207 Data->SMSStatus->SIMUsed = msg.Buffer[24]*256+msg.Buffer[25]; 2210 Data->SMSStatus->SIMUsed = msg.Buffer[24]*256+msg.Buffer[25];
2208 Data->SMSStatus->SIMUnRead = msg.Buffer[26]*256+msg.Buffer[27]; 2211 Data->SMSStatus->SIMUnRead = msg.Buffer[26]*256+msg.Buffer[27];
2209 return ERR_NONE; 2212 return ERR_NONE;
2210 case 0x0f: 2213 case 0x0f:
2211 smprintf(s, "No PIN\n"); 2214 smprintf(s, "No PIN\n");
2212 return ERR_SECURITYERROR; 2215 return ERR_SECURITYERROR;
2213 default: 2216 default:
2214 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 2217 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
2215 return ERR_UNKNOWNRESPONSE; 2218 return ERR_UNKNOWNRESPONSE;
2216 } 2219 }
2217 case 0x1a: 2220 case 0x1a:
2218 smprintf(s, "Wait a moment. Phone is during power on and busy now\n"); 2221 smprintf(s, "Wait a moment. Phone is during power on and busy now\n");
2219 return ERR_SECURITYERROR; 2222 return ERR_SECURITYERROR;
2220 } 2223 }
2221 return ERR_UNKNOWNRESPONSE; 2224 return ERR_UNKNOWNRESPONSE;
2222} 2225}
2223 2226
2224static GSM_Error N6510_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status) 2227static GSM_Error N6510_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
2225{ 2228{
2226 GSM_Error error; 2229 GSM_Error error;
2227 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 2230 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
2228 unsigned char req[] = {N6110_FRAME_HEADER, 0x08, 0x00, 0x00}; 2231 unsigned char req[] = {N6110_FRAME_HEADER, 0x08, 0x00, 0x00};
2229 2232
2230 s->Phone.Data.SMSStatus=status; 2233 s->Phone.Data.SMSStatus=status;
2231 smprintf(s, "Getting SMS status\n"); 2234 smprintf(s, "Getting SMS status\n");
2232 error = GSM_WaitFor (s, req, 6, 0x14, 2, ID_GetSMSStatus); 2235 error = GSM_WaitFor (s, req, 6, 0x14, 2, ID_GetSMSStatus);
2233 if (error != ERR_NONE) return error; 2236 if (error != ERR_NONE) return error;
2234 2237
2235 /* DCT4 family doesn't show in frame with SMS status info 2238 /* DCT4 family doesn't show in frame with SMS status info
2236 * about Templates. We get separately info about this SMS folder. 2239 * about Templates. We get separately info about this SMS folder.
2237 */ 2240 */
2238 error = N6510_GetSMSFolderStatus(s, 0x06); 2241 error = N6510_GetSMSFolderStatus(s, 0x06);
2239 if (error != ERR_NONE) return error; 2242 if (error != ERR_NONE) return error;
2240 status->TemplatesUsed = Priv->LastSMSFolder.Number; 2243 status->TemplatesUsed = Priv->LastSMSFolder.Number;
2241 2244
2242 return error; 2245 return error;
2243} 2246}
2244 2247
2245static GSM_Error N6510_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 2248static GSM_Error N6510_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
2246{ 2249{
2247 switch (msg.Buffer[3]) { 2250 switch (msg.Buffer[3]) {
2248 case 0x05: 2251 case 0x05:
2249 smprintf(s, "SMS deleted OK\n"); 2252 smprintf(s, "SMS deleted OK\n");
2250 return ERR_NONE; 2253 return ERR_NONE;
2251 case 0x06: 2254 case 0x06:
2252 switch (msg.Buffer[4]) { 2255 switch (msg.Buffer[4]) {
2253 case 0x02: 2256 case 0x02:
2254 smprintf(s, "Invalid location\n"); 2257 smprintf(s, "Invalid location\n");
2255 return ERR_INVALIDLOCATION; 2258 return ERR_INVALIDLOCATION;
2256 default: 2259 default:
2257 smprintf(s, "Unknown error: %02x\n",msg.Buffer[4]); 2260 smprintf(s, "Unknown error: %02x\n",msg.Buffer[4]);
2258 return ERR_UNKNOWNRESPONSE; 2261 return ERR_UNKNOWNRESPONSE;
2259 } 2262 }
2260 } 2263 }
2261 return ERR_UNKNOWNRESPONSE; 2264 return ERR_UNKNOWNRESPONSE;
2262} 2265}
2263 2266
2264static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 2267static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
2265{ 2268{
2266 unsigned char folderid; 2269 unsigned char folderid;
2267 int location; 2270 int location;
2268 unsigned char req[] = {N6110_FRAME_HEADER, 0x04, 2271 unsigned char req[] = {N6110_FRAME_HEADER, 0x04,
2269 0x01, /* 0x01=SM, 0x02=ME */ 2272 0x01, /* 0x01=SM, 0x02=ME */
2270 0x00, /* FolderID */ 2273 0x00, /* FolderID */
2271 0x00, 0x02, /* Location */ 2274 0x00, 0x02, /* Location */
2272 0x0F, 0x55}; 2275 0x0F, 0x55};
2273 2276
2274 N6510_GetSMSLocation(s, sms, &folderid, &location); 2277 N6510_GetSMSLocation(s, sms, &folderid, &location);
2275 2278
2276 switch (folderid) { 2279 switch (folderid) {
2277 case 0x01: req[5] = 0x02; break; /* INBOX SIM */ 2280 case 0x01: req[5] = 0x02; break; /* INBOX SIM */
2278 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */ 2281 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */
2279 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/ 2282 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/
2280 } 2283 }
2281 req[6]=location / 256; 2284 req[6]=location / 256;
2282 req[7]=location; 2285 req[7]=location;
2283 2286
2284 smprintf(s, "Deleting sms\n"); 2287 smprintf(s, "Deleting sms\n");
2285 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage); 2288 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage);
2286} 2289}
2287 2290
2288static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 2291static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
2289{ 2292{
2290 switch (msg.Buffer[8]) { 2293 switch (msg.Buffer[8]) {
2291 case 0x00: 2294 case 0x00:
2292 smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]); 2295 smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]);
2293 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]); 2296 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]);
2294 return ERR_NONE; 2297 return ERR_NONE;
2295 default: 2298 default:
2296 smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]); 2299 smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]);
2297 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]); 2300 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]);
2298 return ERR_NONE; 2301 return ERR_NONE;
2299 } 2302 }
2300} 2303}
2301 2304
2302static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 2305static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
2303{ 2306{
2304 int length = 11; 2307 int length = 11;
2305 GSM_Error error; 2308 GSM_Error error;
2306 GSM_SMSMessageLayout Layout; 2309 GSM_SMSMessageLayout Layout;
2307 unsigned char req [300] = { 2310 unsigned char req [300] = {
2308 N6110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x55, 0x55}; 2311 N6110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x55, 0x55};
2309 2312
2310 if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit; 2313 if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit;
2311 memset(req+9,0x00,sizeof(req) - 9); 2314 memset(req+9,0x00,sizeof(req) - 9);
2312 error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length); 2315 error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length);
2313 if (error != ERR_NONE) return error; 2316 if (error != ERR_NONE) return error;
2314 2317
2315 smprintf(s, "Sending sms\n"); 2318 smprintf(s, "Sending sms\n");
2316 return s->Protocol.Functions->WriteMessage(s, req, length + 9, 0x02); 2319 return s->Protocol.Functions->WriteMessage(s, req, length + 9, 0x02);
2317} 2320}
2318 2321
2319static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 2322static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
2320{ 2323{
2321 GSM_Phone_Data *Data = &s->Phone.Data; 2324 GSM_Phone_Data *Data = &s->Phone.Data;
2322 2325
2323 smprintf(s, "Security Code status received: "); 2326 smprintf(s, "Security Code status received: ");
2324 switch (msg.Buffer[4]) { 2327 switch (msg.Buffer[4]) {
2325 case 0x01 : smprintf(s, "waiting for Security Code.\n"); *Data->SecurityStatus = SEC_SecurityCode;break; 2328 case 0x01 : smprintf(s, "waiting for Security Code.\n"); *Data->SecurityStatus = SEC_SecurityCode;break;
2326 case 0x07 : 2329 case 0x07 :
2327 case 0x02 : smprintf(s, "waiting for PIN.\n"); *Data->SecurityStatus = SEC_Pin; break; 2330 case 0x02 : smprintf(s, "waiting for PIN.\n"); *Data->SecurityStatus = SEC_Pin; break;
2328 case 0x03 : smprintf(s, "waiting for PUK.\n"); *Data->SecurityStatus = SEC_Puk; break; 2331 case 0x03 : smprintf(s, "waiting for PUK.\n"); *Data->SecurityStatus = SEC_Puk; break;
2329 case 0x05 : smprintf(s, "PIN ok, SIM ok\n"); *Data->SecurityStatus = SEC_None; break; 2332 case 0x05 : smprintf(s, "PIN ok, SIM ok\n"); *Data->SecurityStatus = SEC_None; break;
2330 case 0x06 : smprintf(s, "No input status\n"); *Data->SecurityStatus = SEC_None; break; 2333 case 0x06 : smprintf(s, "No input status\n"); *Data->SecurityStatus = SEC_None; break;
2331 case 0x16 : smprintf(s, "No SIM card\n"); *Data->SecurityStatus = SEC_None; break; 2334 case 0x16 : smprintf(s, "No SIM card\n"); *Data->SecurityStatus = SEC_None; break;
2332 case 0x1A : smprintf(s, "SIM card rejected!\n"); *Data->SecurityStatus = SEC_None; break; 2335 case 0x1A : smprintf(s, "SIM card rejected!\n"); *Data->SecurityStatus = SEC_None; break;
2333 default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 2336 default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
2334 return ERR_UNKNOWNRESPONSE; 2337 return ERR_UNKNOWNRESPONSE;
2335 } 2338 }
2336 return ERR_NONE; 2339 return ERR_NONE;
2337} 2340}
2338 2341
2339static GSM_Error N6510_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) 2342static GSM_Error N6510_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status)
2340{ 2343{
2341 unsigned char req[5] = {N6110_FRAME_HEADER, 0x11, 0x00}; 2344 unsigned char req[5] = {N6110_FRAME_HEADER, 0x11, 0x00};
2342 2345
2343 s->Phone.Data.SecurityStatus=Status; 2346 s->Phone.Data.SecurityStatus=Status;
2344 smprintf(s, "Getting security code status\n"); 2347 smprintf(s, "Getting security code status\n");
2345 return GSM_WaitFor (s, req, 5, 0x08, 2, ID_GetSecurityStatus); 2348 return GSM_WaitFor (s, req, 5, 0x08, 2, ID_GetSecurityStatus);
2346} 2349}
2347 2350
2348static GSM_Error N6510_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) 2351static GSM_Error N6510_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
2349{ 2352{
2350 switch (msg.Buffer[3]) { 2353 switch (msg.Buffer[3]) {
2351 case 0x08: 2354 case 0x08:
2352 smprintf(s, "Security code OK\n"); 2355 smprintf(s, "Security code OK\n");
2353 return ERR_NONE; 2356 return ERR_NONE;
2354 case 0x09: 2357 case 0x09:
2355 switch (msg.Buffer[4]) { 2358 switch (msg.Buffer[4]) {
2356 case 0x06: 2359 case 0x06:
2357 smprintf(s, "Wrong PIN\n"); 2360 smprintf(s, "Wrong PIN\n");
2358 return ERR_SECURITYERROR; 2361 return ERR_SECURITYERROR;
2359 case 0x09: 2362 case 0x09:
2360 smprintf(s, "Wrong PUK\n"); 2363 smprintf(s, "Wrong PUK\n");
2361 return ERR_SECURITYERROR; 2364 return ERR_SECURITYERROR;
2362 default: 2365 default:
2363 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 2366 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
2364 } 2367 }
2365 } 2368 }
2366 return ERR_UNKNOWNRESPONSE; 2369 return ERR_UNKNOWNRESPONSE;
2367} 2370}
2368 2371
2369static GSM_Error N6510_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) 2372static GSM_Error N6510_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
2370{ 2373{
2371 int len = 0; 2374 int len = 0;
2372 unsigned char req[15] = {N6110_FRAME_HEADER, 0x07, 2375 unsigned char req[15] = {N6110_FRAME_HEADER, 0x07,
2373 0x00};/* Code type */ 2376 0x00};/* Code type */
2374 2377
2375 switch (Code.Type) { 2378 switch (Code.Type) {
2376 case SEC_Pin: req[4] = 0x02; break; 2379 case SEC_Pin: req[4] = 0x02; break;
2377 case SEC_Puk: req[4] = 0x03; break;/* FIXME */ 2380 case SEC_Puk: req[4] = 0x03; break;/* FIXME */
2378 default : return ERR_NOTSUPPORTED; 2381 default : return ERR_NOTSUPPORTED;
2379 } 2382 }
2380 2383
2381 len = strlen(Code.Code); 2384 len = strlen(Code.Code);
2382 memcpy(req+5,Code.Code,len); 2385 memcpy(req+5,Code.Code,len);
2383 req[5+len]=0x00; 2386 req[5+len]=0x00;
2384 2387
2385 smprintf(s, "Entering security code\n"); 2388 smprintf(s, "Entering security code\n");
2386 return GSM_WaitFor (s, req, 6+len, 0x08, 4, ID_EnterSecurityCode); 2389 return GSM_WaitFor (s, req, 6+len, 0x08, 4, ID_EnterSecurityCode);
2387} 2390}
2388 2391
2389static GSM_Error N6510_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 2392static GSM_Error N6510_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
2390{ 2393{
2391 unsigned char folder; 2394 unsigned char folder;
2392 GSM_Phone_Data *Data = &s->Phone.Data; 2395 GSM_Phone_Data *Data = &s->Phone.Data;
2393 2396
2394 switch (msg.Buffer[3]) { 2397 switch (msg.Buffer[3]) {
2395 case 0x01: 2398 case 0x01:
2396 switch (msg.Buffer[4]) { 2399 switch (msg.Buffer[4]) {
2397 case 0x00: 2400 case 0x00:
2398 smprintf(s, "Done OK\n"); 2401 smprintf(s, "Done OK\n");
2399 smprintf(s, "Folder info: %i %i\n",msg.Buffer[5],msg.Buffer[8]); 2402 smprintf(s, "Folder info: %i %i\n",msg.Buffer[5],msg.Buffer[8]);
2400 switch (msg.Buffer[8]) { 2403 switch (msg.Buffer[8]) {
2401 case 0x02 : if (msg.Buffer[5] == 0x02) { 2404 case 0x02 : if (msg.Buffer[5] == 0x02) {
2402 folder = 0x03; /* INBOX ME */ 2405 folder = 0x03; /* INBOX ME */
2403 } else { 2406 } else {
2404 folder = 0x01; /* INBOX SIM */ 2407 folder = 0x01; /* INBOX SIM */
2405 } 2408 }
2406 break; 2409 break;
2407 case 0x03 : if (msg.Buffer[5] == 0x02) { 2410 case 0x03 : if (msg.Buffer[5] == 0x02) {
2408 folder = 0x04; /* OUTBOX ME */ 2411 folder = 0x04; /* OUTBOX ME */
2409 } else { 2412 } else {
2410 folder = 0x02; /* OUTBOX SIM */ 2413 folder = 0x02; /* OUTBOX SIM */
2411 } 2414 }
2412 break; 2415 break;
2413 default : folder = msg.Buffer[8] + 1; 2416 default : folder = msg.Buffer[8] + 1;
2414 } 2417 }
2415 N6510_SetSMSLocation(s, Data->SaveSMSMessage,folder,msg.Buffer[6]*256+msg.Buffer[7]); 2418 N6510_SetSMSLocation(s, Data->SaveSMSMessage,folder,msg.Buffer[6]*256+msg.Buffer[7]);
2416 smprintf(s, "Saved in folder %i at location %i\n",folder, msg.Buffer[6]*256+msg.Buffer[7]); 2419 smprintf(s, "Saved in folder %i at location %i\n",folder, msg.Buffer[6]*256+msg.Buffer[7]);
2417 Data->SaveSMSMessage->Folder = folder; 2420 Data->SaveSMSMessage->Folder = folder;
2418 return ERR_NONE; 2421 return ERR_NONE;
2419 case 0x02: 2422 case 0x02:
2420 printf("Incorrect location\n"); 2423 printf("Incorrect location\n");
2421 return ERR_INVALIDLOCATION; 2424 return ERR_INVALIDLOCATION;
2425 case 0x03:
2426 printf("Memory full (for example no empty space in SIM)\n");
2427 return ERR_FULL;
2422 case 0x05: 2428 case 0x05:
2423 printf("Incorrect folder\n"); 2429 printf("Incorrect folder\n");
2424 return ERR_INVALIDLOCATION; 2430 return ERR_INVALIDLOCATION;
2425 default: 2431 default:
2426 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); 2432 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
2427 return ERR_UNKNOWNRESPONSE; 2433 return ERR_UNKNOWNRESPONSE;
2428 } 2434 }
2429 case 0x17: 2435 case 0x17:
2430 smprintf(s, "SMS name changed\n"); 2436 smprintf(s, "SMS name changed\n");
2431 return ERR_NONE; 2437 return ERR_NONE;
2432 } 2438 }
2433 return ERR_UNKNOWNRESPONSE; 2439 return ERR_UNKNOWNRESPONSE;
2434} 2440}
2435 2441
2436static GSM_Error N6510_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 2442static GSM_Error N6510_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
2437{ 2443{
2438 int location, length = 11; 2444 int location, length = 11;
2439 unsigned char folderid, folder; 2445 unsigned char folderid, folder;
2440 GSM_SMSMessageLayout Layout; 2446 GSM_SMSMessageLayout Layout;
2441 GSM_Error error; 2447 GSM_Error error;
2442 unsigned char req [300] = { 2448 unsigned char req [300] = {
2443 N6110_FRAME_HEADER, 0x00, 2449 N6110_FRAME_HEADER, 0x00,
2444 0x01, /* 1 = SIM, 2 = ME */ 2450 0x01, /* 1 = SIM, 2 = ME */
2445 0x02, /* Folder */ 2451 0x02, /* Folder */
2446 0x00, 0x01, /* Location */ 2452 0x00, 0x01, /* Location */
2447 0x01}; /* SMS state */ 2453 0x01}; /* SMS state */
2448 unsigned char NameReq[200] = { 2454 unsigned char NameReq[200] = {
2449 N6110_FRAME_HEADER, 0x16, 2455 N6110_FRAME_HEADER, 0x16,
2450 0x01, /* 1 = SIM, 2 = ME */ 2456 0x01, /* 1 = SIM, 2 = ME */
2451 0x02, /* Folder */ 2457 0x02, /* Folder */
2452 0x00, 0x01}; /* Location */ 2458 0x00, 0x01}; /* Location */
2453 2459
2454 N6510_GetSMSLocation(s, sms, &folderid, &location); 2460 N6510_GetSMSLocation(s, sms, &folderid, &location);
2455 switch (folderid) { 2461 switch (folderid) {
2456 case 0x01: req[5] = 0x02; break; /* INBOX SIM */ 2462 case 0x01: req[5] = 0x02; break; /* INBOX SIM */
2457 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */ 2463 case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */
2458 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/ 2464 default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders*/
2459 } 2465 }
2460 req[6]=location / 256; 2466 req[6]=location / 256;
2461 req[7]=location; 2467 req[7]=location;
2462 2468
2463 switch (sms->PDU) { 2469 switch (sms->PDU) {
2464 case SMS_Submit: 2470 case SMS_Submit:
2465 /* Inbox */ 2471 /* Inbox */
2466 if (folderid == 0x01 || folderid == 0x03) sms->PDU = SMS_Deliver; 2472 if (folderid == 0x01 || folderid == 0x03) sms->PDU = SMS_Deliver;
2467 break; 2473 break;
2468 case SMS_Deliver: 2474 case SMS_Deliver:
2469 /* SIM Outbox */ 2475 /* SIM Outbox */
2470 if (folderid == 0x02) sms->PDU = SMS_Submit; 2476 if (folderid == 0x02) sms->PDU = SMS_Submit;
2471 break; 2477 break;
2472 default: 2478 default:
2473 return ERR_UNKNOWN; 2479 return ERR_UNKNOWN;
2474 } 2480 }
2475 if (sms->PDU == SMS_Deliver) { 2481 if (sms->PDU == SMS_Deliver) {
2476 switch (sms->State) { 2482 switch (sms->State) {
2477 case SMS_Sent: /* We use GSM_Read, because phone return error */ 2483 case SMS_Sent: /* We use GSM_Read, because phone return error */
2478 case SMS_Read: req[8] = 0x01; break; 2484 case SMS_Read: req[8] = 0x01; break;
2479 case SMS_UnSent: /* We use GSM_UnRead, because phone return error */ 2485 case SMS_UnSent: /* We use GSM_UnRead, because phone return error */
2480 case SMS_UnRead: req[8] = 0x03; break; 2486 case SMS_UnRead: req[8] = 0x03; break;
2481 } 2487 }
2482 } else { 2488 } else {
2483 switch (sms->State) { 2489 switch (sms->State) {
2484 case SMS_Sent: /* We use GSM_Sent, because phone change folder */ 2490 case SMS_Sent: /* We use GSM_Sent, because phone change folder */
2485 case SMS_Read: req[8] = 0x05; break; 2491 case SMS_Read: req[8] = 0x05; break;
2486 case SMS_UnSent: /* We use GSM_UnSent, because phone change folder */ 2492 case SMS_UnSent: /* We use GSM_UnSent, because phone change folder */
2487 case SMS_UnRead: req[8] = 0x07; break; 2493 case SMS_UnRead: req[8] = 0x07; break;
2488 } 2494 }
2489 } 2495 }
2490 memset(req+9,0x00,sizeof(req) - 9); 2496 memset(req+9,0x00,sizeof(req) - 9);
2491 error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length); 2497 error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length);
2492 if (error != ERR_NONE) return error; 2498 if (error != ERR_NONE) return error;
2493 2499
2494 s->Phone.Data.SaveSMSMessage=sms; 2500 s->Phone.Data.SaveSMSMessage=sms;
2495 smprintf(s, "Saving sms\n"); 2501 smprintf(s, "Saving sms\n");
2496 error=GSM_WaitFor (s, req, length+9, 0x14, 4, ID_SaveSMSMessage); 2502 error=GSM_WaitFor (s, req, length+9, 0x14, 4, ID_SaveSMSMessage);
2497 if (error == ERR_NONE && UnicodeLength(sms->Name)!=0) { 2503 if (error == ERR_NONE && UnicodeLength(sms->Name)!=0) {
2498 folder = sms->Folder; 2504 folder = sms->Folder;
2499 sms->Folder = 0; 2505 sms->Folder = 0;
2500 N6510_GetSMSLocation(s, sms, &folderid, &location); 2506 N6510_GetSMSLocation(s, sms, &folderid, &location);
2501 switch (folderid) { 2507 switch (folderid) {
2502 case 0x01: NameReq[5] = 0x02; break; /* INBOX SIM */ 2508 case 0x01: NameReq[5] = 0x02; break; /* INBOX SIM */
2503 case 0x02: NameReq[5] = 0x03; break; /* OUTBOX SIM */ 2509 case 0x02: NameReq[5] = 0x03; break; /* OUTBOX SIM */
2504 default : NameReq[5] = folderid - 1; NameReq[4] = 0x02; break; /* ME folders*/ 2510 default : NameReq[5] = folderid - 1; NameReq[4] = 0x02; break; /* ME folders*/
2505 } 2511 }
2506 NameReq[6]=location / 256; 2512 NameReq[6]=location / 256;
2507 NameReq[7]=location; 2513 NameReq[7]=location;
2508 length = 8; 2514 length = 8;
2509 CopyUnicodeString(NameReq+length, sms->Name); 2515 CopyUnicodeString(NameReq+length, sms->Name);
2510 length = length+UnicodeLength(sms->Name)*2; 2516 length = length+UnicodeLength(sms->Name)*2;
2511 NameReq[length++] = 0; 2517 NameReq[length++] = 0;
2512 NameReq[length++] = 0; 2518 NameReq[length++] = 0;
2513 error=GSM_WaitFor (s, NameReq, length, 0x14, 4, ID_SaveSMSMessage); 2519 error=GSM_WaitFor (s, NameReq, length, 0x14, 4, ID_SaveSMSMessage);
2514 sms->Folder = folder; 2520 sms->Folder = folder;
2515 } 2521 }
2516 return error; 2522 return error;
2517} 2523}
2518 2524
2519static GSM_Error N6510_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) 2525static GSM_Error N6510_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
2520{ 2526{
2521 int location; 2527 int location;
2522 unsigned char folderid; 2528 unsigned char folderid;
2523 2529
2524 N6510_GetSMSLocation(s, sms, &folderid, &location); 2530 N6510_GetSMSLocation(s, sms, &folderid, &location);
2525 if (location == 0) return ERR_INVALIDLOCATION; 2531 if (location == 0) return ERR_INVALIDLOCATION;
2526 return N6510_PrivSetSMSMessage(s, sms); 2532 return N6510_PrivSetSMSMessage(s, sms);
2527} 2533}
2528 2534
2529static GSM_Error N6510_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) 2535static GSM_Error N6510_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
2530{ 2536{
2531 int location; 2537 int location;
2532 unsigned char folderid; 2538 unsigned char folderid;
2533 2539
2534 N6510_GetSMSLocation(s, sms, &folderid, &location); 2540 N6510_GetSMSLocation(s, sms, &folderid, &location);
2535 location = 0; 2541 location = 0;
2536 N6510_SetSMSLocation(s, sms, folderid, location); 2542 N6510_SetSMSLocation(s, sms, folderid, location);
2537 return N6510_PrivSetSMSMessage(s, sms); 2543 return N6510_PrivSetSMSMessage(s, sms);
2538} 2544}
2539 2545
2540static GSM_Error N6510_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s) 2546static GSM_Error N6510_ReplyGetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
2541{ 2547{
2542 smprintf(s, "Date & time received\n"); 2548 smprintf(s, "Date & time received\n");
2543 if (msg.Buffer[4]==0x01) { 2549 if (msg.Buffer[4]==0x01) {
2544 NOKIA_DecodeDateTime(s, msg.Buffer+10, s->Phone.Data.DateTime); 2550 NOKIA_DecodeDateTime(s, msg.Buffer+10, s->Phone.Data.DateTime);
2545 return ERR_NONE; 2551 return ERR_NONE;
2546 } 2552 }
2547 smprintf(s, "Not set in phone\n"); 2553 smprintf(s, "Not set in phone\n");
2548 return ERR_EMPTY; 2554 return ERR_EMPTY;
2549} 2555}
2550 2556
2551static GSM_Error N6510_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 2557static GSM_Error N6510_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
2552{ 2558{
2553 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x00, 0x00}; 2559 unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x00, 0x00};
2554 2560
2555 s->Phone.Data.DateTime=date_time; 2561 s->Phone.Data.DateTime=date_time;
2556 smprintf(s, "Getting date & time\n"); 2562 smprintf(s, "Getting date & time\n");
2557 return GSM_WaitFor (s, req, 6, 0x19, 4, ID_GetDateTime); 2563 return GSM_WaitFor (s, req, 6, 0x19, 4, ID_GetDateTime);
2558} 2564}
2559 2565
2560static GSM_Error N6510_ReplySetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s) 2566static GSM_Error N6510_ReplySetDateTime(GSM_Protocol_Message msg, GSM_StateMachine *s)
2561{ 2567{
2562 smprintf(s, "Date & time set\n"); 2568 smprintf(s, "Date & time set\n");
2563 return ERR_NONE; 2569 return ERR_NONE;
2564} 2570}
2565 2571
2566static GSM_Error N6510_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) 2572static GSM_Error N6510_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
2567{ 2573{
2568 unsigned char req[] = {N6110_FRAME_HEADER, 2574 unsigned char req[] = {N6110_FRAME_HEADER,
2569 0x01, 0x00, 0x01, 0x01, 0x0c, 0x01, 0x03, 2575 0x01, 0x00, 0x01, 0x01, 0x0c, 0x01, 0x03,
2570 0x00, 0x00,/* Year */ 2576 0x00, 0x00,/* Year */
2571 0x08, 0x01, /* Month & Day */ 2577 0x08, 0x01, /* Month & Day */
2572 0x15, 0x1f,/* Hours & Minutes */ 2578 0x15, 0x1f,/* Hours & Minutes */
2573 0x2b, /* Second ? */ 2579 0x2b, /* Second ? */
2574 0x00}; 2580 0x00};
2575 2581
2576 NOKIA_EncodeDateTime(s, req+10, date_time); 2582 NOKIA_EncodeDateTime(s, req+10, date_time);
2577 req[16] = date_time->Second; 2583 req[16] = date_time->Second;
2578 smprintf(s, "Setting date & time\n"); 2584 smprintf(s, "Setting date & time\n");
2579 return GSM_WaitFor (s, req, 18, 0x19, 4, ID_SetDateTime); 2585 return GSM_WaitFor (s, req, 18, 0x19, 4, ID_SetDateTime);
2580} 2586}
2581 2587
2582static GSM_Error N6510_ReplyGetManufactureMonth(GSM_Protocol_Message msg, GSM_StateMachine *s) 2588static GSM_Error N6510_ReplyGetManufactureMonth(GSM_Protocol_Message msg, GSM_StateMachine *s)
2583{ 2589{
2584 if (msg.Buffer[7] == 0x00) { 2590 if (msg.Buffer[7] == 0x00) {
2585 smprintf(s, "No SIM card\n"); 2591 smprintf(s, "No SIM card\n");
2586 return ERR_SECURITYERROR; 2592 return ERR_SECURITYERROR;
2587 } else { 2593 } else {
2588 sprintf(s->Phone.Data.PhoneString,"%02i/%04i",msg.Buffer[13],msg.Buffer[14]*256+msg.Buffer[15]); 2594 sprintf(s->Phone.Data.PhoneString,"%02i/%04i",msg.Buffer[13],msg.Buffer[14]*256+msg.Buffer[15]);
2589 return ERR_NONE; 2595 return ERR_NONE;
2590 } 2596 }
2591} 2597}
2592 2598
2593static GSM_Error N6510_GetManufactureMonth(GSM_StateMachine *s, char *value) 2599static GSM_Error N6510_GetManufactureMonth(GSM_StateMachine *s, char *value)
2594{ 2600{
2595 unsigned char req[6] = {0x00, 0x05, 0x02, 0x01, 0x00, 0x02}; 2601 unsigned char req[6] = {0x00, 0x05, 0x02, 0x01, 0x00, 0x02};
2596 //unsigned char req[6] = {0x00, 0x03, 0x04, 0x0B, 0x01, 0x00}; 2602 //unsigned char req[6] = {0x00, 0x03, 0x04, 0x0B, 0x01, 0x00};
2597 2603
2598 s->Phone.Data.PhoneString=value; 2604 s->Phone.Data.PhoneString=value;
2599 smprintf(s, "Getting manufacture month\n"); 2605 smprintf(s, "Getting manufacture month\n");
2600 return GSM_WaitFor (s, req, 6, 0x42, 2, ID_GetManufactureMonth); 2606 return GSM_WaitFor (s, req, 6, 0x42, 2, ID_GetManufactureMonth);
2601 //return GSM_WaitFor (s, req, 6, 0x1B, 2, ID_GetManufactureMonth); 2607 //return GSM_WaitFor (s, req, 6, 0x1B, 2, ID_GetManufactureMonth);
2602} 2608}
2603 2609
2604static GSM_Error N6510_ReplyGetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) 2610static GSM_Error N6510_ReplyGetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
2605{ 2611{
2606 GSM_Phone_Data *Data = &s->Phone.Data; 2612 GSM_Phone_Data *Data = &s->Phone.Data;
2607 2613
2608 switch(msg.Buffer[3]) { 2614 switch(msg.Buffer[3]) {
2609 case 0x1A: 2615 case 0x1A:
2610 smprintf(s, " Alarm: %02d:%02d\n", msg.Buffer[14], msg.Buffer[15]); 2616 smprintf(s, " Alarm: %02d:%02d\n", msg.Buffer[14], msg.Buffer[15]);
2611 Data->Alarm->Repeating = true; 2617 Data->Alarm->Repeating = true;
2612 Data->Alarm->Text[0] = 0; 2618 Data->Alarm->Text[0] = 0;
2613 Data->Alarm->Text[1] = 0; 2619 Data->Alarm->Text[1] = 0;
2614 Data->Alarm->DateTime.Hour= msg.Buffer[14]; 2620 Data->Alarm->DateTime.Hour= msg.Buffer[14];
2615 Data->Alarm->DateTime.Minute= msg.Buffer[15]; 2621 Data->Alarm->DateTime.Minute= msg.Buffer[15];
2616 Data->Alarm->DateTime.Second= 0; 2622 Data->Alarm->DateTime.Second= 0;
2617 return ERR_NONE; 2623 return ERR_NONE;
2618 case 0x20: 2624 case 0x20:
2619 smprintf(s, "Alarm state received\n"); 2625 smprintf(s, "Alarm state received\n");
2620 if (msg.Buffer[37] == 0x01) { 2626 if (msg.Buffer[37] == 0x01) {
2621 smprintf(s, " Not set in phone\n"); 2627 smprintf(s, " Not set in phone\n");
2622 return ERR_EMPTY; 2628 return ERR_EMPTY;
2623 } 2629 }
2624 smprintf(s, "Enabled\n"); 2630 smprintf(s, "Enabled\n");
2625 return ERR_NONE; 2631 return ERR_NONE;
2626 } 2632 }
2627 return ERR_UNKNOWNRESPONSE; 2633 return ERR_UNKNOWNRESPONSE;
2628} 2634}
2629 2635
2630static GSM_Error N6510_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 2636static GSM_Error N6510_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
2631{ 2637{
2632 unsigned char StateReq[] = {N6110_FRAME_HEADER, 0x1f, 0x01, 0x00}; 2638 unsigned char StateReq[] = {N6110_FRAME_HEADER, 0x1f, 0x01, 0x00};
2633 unsigned char GetReq [] = {N6110_FRAME_HEADER, 0x19, 0x00, 0x02}; 2639 unsigned char GetReq [] = {N6110_FRAME_HEADER, 0x19, 0x00, 0x02};
2634 GSM_Errorerror; 2640 GSM_Errorerror;
2635 2641
2636 if (alarm->Location != 1) return ERR_NOTSUPPORTED; 2642 if (alarm->Location != 1) return ERR_NOTSUPPORTED;
2637 2643
2638 s->Phone.Data.Alarm=alarm; 2644 s->Phone.Data.Alarm=alarm;
2639 smprintf(s, "Getting alarm state\n"); 2645 smprintf(s, "Getting alarm state\n");
2640 error = GSM_WaitFor (s, StateReq, 6, 0x19, 4, ID_GetAlarm); 2646 error = GSM_WaitFor (s, StateReq, 6, 0x19, 4, ID_GetAlarm);
2641 if (error != ERR_NONE) return error; 2647 if (error != ERR_NONE) return error;
2642 2648
2643 smprintf(s, "Getting alarm\n"); 2649 smprintf(s, "Getting alarm\n");
2644 return GSM_WaitFor (s, GetReq, 6, 0x19, 4, ID_GetAlarm); 2650 return GSM_WaitFor (s, GetReq, 6, 0x19, 4, ID_GetAlarm);
2645} 2651}
2646 2652
2647static GSM_Error N6510_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) 2653static GSM_Error N6510_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s)
2648{ 2654{
2649 smprintf(s, "Alarm set\n"); 2655 smprintf(s, "Alarm set\n");
2650 return ERR_NONE; 2656 return ERR_NONE;
2651} 2657}
2652 2658
2653static GSM_Error N6510_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 2659static GSM_Error N6510_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
2654{ 2660{
2655 unsigned char req[] = {N6110_FRAME_HEADER, 2661 unsigned char req[] = {N6110_FRAME_HEADER,
2656 0x11, 0x00, 0x01, 0x01, 0x0c, 0x02, 2662 0x11, 0x00, 0x01, 0x01, 0x0c, 0x02,
2657 0x01, 0x00, 0x00, 0x00, 0x00, 2663 0x01, 0x00, 0x00, 0x00, 0x00,
2658 0x00, 0x00, /* Hours, Minutes */ 2664 0x00, 0x00, /* Hours, Minutes */
2659 0x00, 0x00, 0x00 }; 2665 0x00, 0x00, 0x00 };
2660 2666
2661 if (alarm->Location != 1) return ERR_NOTSUPPORTED; 2667 if (alarm->Location != 1) return ERR_NOTSUPPORTED;
2662 2668
2663 req[14] = alarm->DateTime.Hour; 2669 req[14] = alarm->DateTime.Hour;
2664 req[15] = alarm->DateTime.Minute; 2670 req[15] = alarm->DateTime.Minute;
2665 2671
2666 smprintf(s, "Setting alarm\n"); 2672 smprintf(s, "Setting alarm\n");
2667 return GSM_WaitFor (s, req, 19, 0x19, 4, ID_SetAlarm); 2673 return GSM_WaitFor (s, req, 19, 0x19, 4, ID_SetAlarm);
2668} 2674}
2669 2675
2670static GSM_Error N6510_ReplyGetRingtonesInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 2676static GSM_Error N6510_ReplyGetRingtonesInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
2671{ 2677{
2672 int tmp,i; 2678 int tmp,i;
2673 GSM_Phone_Data *Data = &s->Phone.Data; 2679 GSM_Phone_Data *Data = &s->Phone.Data;
2674 2680
2675 smprintf(s, "Ringtones info received\n"); 2681 smprintf(s, "Ringtones info received\n");
2676 memset(Data->RingtonesInfo,0,sizeof(GSM_AllRingtonesInfo)); 2682 memset(Data->RingtonesInfo,0,sizeof(GSM_AllRingtonesInfo));
2677 if (msg.Buffer[4] * 256 + msg.Buffer[5] == 0x00) return ERR_EMPTY; 2683 if (msg.Buffer[4] * 256 + msg.Buffer[5] == 0x00) return ERR_EMPTY;
2678 Data->RingtonesInfo->Number = msg.Buffer[4] * 256 + msg.Buffer[5]; 2684 Data->RingtonesInfo->Number = msg.Buffer[4] * 256 + msg.Buffer[5];
2685 // allocate array of ringtones based on number
2686 Data->RingtonesInfo->Ringtone = calloc(Data->RingtonesInfo->Number, sizeof(GSM_RingtoneInfo));
2679 tmp = 6; 2687 tmp = 6;
2680 for (i=0;i<Data->RingtonesInfo->Number;i++) { 2688 for (i=0;i<Data->RingtonesInfo->Number;i++) {
2681 Data->RingtonesInfo->Ringtone[i].Group = msg.Buffer[tmp+4]; 2689 Data->RingtonesInfo->Ringtone[i].Group = msg.Buffer[tmp+4];
2682 Data->RingtonesInfo->Ringtone[i].ID = msg.Buffer[tmp+2] * 256 + msg.Buffer[tmp+3]; 2690 Data->RingtonesInfo->Ringtone[i].ID = msg.Buffer[tmp+2] * 256 + msg.Buffer[tmp+3];
2683 memcpy(Data->RingtonesInfo->Ringtone[i].Name,msg.Buffer+tmp+8,(msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7])*2); 2691 memcpy(Data->RingtonesInfo->Ringtone[i].Name,msg.Buffer+tmp+8,(msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7])*2);
2684 smprintf(s, "%5i (%5i). \"%s\"\n", 2692 smprintf(s, "%5i (%5i). \"%s\"\n",
2685 Data->RingtonesInfo->Ringtone[i].ID, 2693 Data->RingtonesInfo->Ringtone[i].ID,
2686 Data->RingtonesInfo->Ringtone[i].Group, 2694 Data->RingtonesInfo->Ringtone[i].Group,
2687 DecodeUnicodeString(Data->RingtonesInfo->Ringtone[i].Name)); 2695 DecodeUnicodeString(Data->RingtonesInfo->Ringtone[i].Name));
2688 tmp = tmp + (msg.Buffer[tmp]*256+msg.Buffer[tmp+1]); 2696 tmp = tmp + (msg.Buffer[tmp]*256+msg.Buffer[tmp+1]);
2689 } 2697 }
2690 return ERR_NONE; 2698 return ERR_NONE;
2691} 2699}
2692 2700
2693static GSM_Error N6510_PrivGetRingtonesInfo(GSM_StateMachine *s, GSM_AllRingtonesInfo *Info, bool AllRingtones) 2701static GSM_Error N6510_PrivGetRingtonesInfo(GSM_StateMachine *s, GSM_AllRingtonesInfo *Info, bool AllRingtones)
2694{ 2702{
2695 GSM_Errorerror; 2703 GSM_Errorerror;
2696 unsigned char UserReq[8] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0x02}; 2704 unsigned char UserReq[8] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0x02};
2697 // unsigned char All_Req[9] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0xFE, 0x00, 0x7D}; 2705 // unsigned char All_Req[9] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0xFE, 0x00, 0x7D};
2698 unsigned char All_Req[8] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0x00}; 2706 unsigned char All_Req[8] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0x00};
2699 2707
2700 s->Phone.Data.RingtonesInfo=Info; 2708 s->Phone.Data.RingtonesInfo=Info;
2701 smprintf(s, "Getting binary ringtones ID\n"); 2709 smprintf(s, "Getting binary ringtones ID\n");
2702 if (AllRingtones) { 2710 if (AllRingtones) {
2703 // error = GSM_WaitFor (s, All_Req, 9, 0x1f, 4, ID_GetRingtonesInfo); 2711 // error = GSM_WaitFor (s, All_Req, 9, 0x1f, 4, ID_GetRingtonesInfo);
2704 error = GSM_WaitFor (s, All_Req, 8, 0x1f, 4, ID_GetRingtonesInfo); 2712 error = GSM_WaitFor (s, All_Req, 8, 0x1f, 4, ID_GetRingtonesInfo);
2705 if (error == ERR_EMPTY && Info->Number == 0) return ERR_NOTSUPPORTED; 2713 if (error == ERR_EMPTY && Info->Number == 0) return ERR_NOTSUPPORTED;
2706 return error; 2714 return error;
2707 } else { 2715 } else {
2708 error = GSM_WaitFor (s, UserReq, 8, 0x1f, 4, ID_GetRingtonesInfo); 2716 error = GSM_WaitFor (s, UserReq, 8, 0x1f, 4, ID_GetRingtonesInfo);
2709 if (error == ERR_EMPTY && Info->Number == 0) return ERR_NOTSUPPORTED; 2717 if (error == ERR_EMPTY && Info->Number == 0) return ERR_NOTSUPPORTED;
2710 return error; 2718 return error;
2711 } 2719 }
2712} 2720}
2713 2721
2714static GSM_Error N6510_GetRingtonesInfo(GSM_StateMachine *s, GSM_AllRingtonesInfo *Info) 2722static GSM_Error N6510_GetRingtonesInfo(GSM_StateMachine *s, GSM_AllRingtonesInfo *Info)
2715{ 2723{
2716 return N6510_PrivGetRingtonesInfo(s, Info, true); 2724 return N6510_PrivGetRingtonesInfo(s, Info, true);
2717} 2725}
2718 2726
2719static GSM_Error N6510_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) 2727static GSM_Error N6510_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
2720{ 2728{
2721 int tmp,i; 2729 int tmp,i;
2722 GSM_Phone_Data *Data = &s->Phone.Data; 2730 GSM_Phone_Data *Data = &s->Phone.Data;
2723 2731
2724 smprintf(s, "Ringtone received\n"); 2732 smprintf(s, "Ringtone received\n");
2725 memcpy(Data->Ringtone->Name,msg.Buffer+8,msg.Buffer[7]*2); 2733 memcpy(Data->Ringtone->Name,msg.Buffer+8,msg.Buffer[7]*2);
2726 Data->Ringtone->Name[msg.Buffer[7]*2]=0; 2734 Data->Ringtone->Name[msg.Buffer[7]*2]=0;
2727 Data->Ringtone->Name[msg.Buffer[7]*2+1]=0; 2735 Data->Ringtone->Name[msg.Buffer[7]*2+1]=0;
2728 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name)); 2736 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
2729 if (msg.Buffer[msg.Buffer[7]*2+10] == 'M' && 2737 if (msg.Buffer[msg.Buffer[7]*2+10] == 'M' &&
2730 msg.Buffer[msg.Buffer[7]*2+11] == 'T' && 2738 msg.Buffer[msg.Buffer[7]*2+11] == 'T' &&
2731 msg.Buffer[msg.Buffer[7]*2+12] == 'h' && 2739 msg.Buffer[msg.Buffer[7]*2+12] == 'h' &&
2732 msg.Buffer[msg.Buffer[7]*2+13] == 'd') { 2740 msg.Buffer[msg.Buffer[7]*2+13] == 'd') {
2733 smprintf(s,"MIDI\n"); 2741 smprintf(s,"MIDI\n");
2734 tmp = msg.Buffer[7]*2+10; 2742 tmp = msg.Buffer[7]*2+10;
2735 i = msg.Length - 2; /* ?????? */ 2743 i = msg.Length - 2; /* ?????? */
2736 Data->Ringtone->Format = RING_MIDI; 2744 Data->Ringtone->Format = RING_MIDI;
2737 } else { 2745 } else {
2738 /* Looking for end */ 2746 /* Looking for end */
2739 i=8+msg.Buffer[7]*2+3; 2747 i=8+msg.Buffer[7]*2+3;
2740 tmp = i; 2748 tmp = i;
2741 while (true) { 2749 while (true) {
2742 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { 2750 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
2743 i=i+2; break; 2751 i=i+2; break;
2744 } 2752 }
2745 i++; 2753 i++;
2746 if (i==msg.Length) return ERR_EMPTY; 2754 if (i==msg.Length) return ERR_EMPTY;
2747 } 2755 }
2748 } 2756 }
2749 /* Copying frame */ 2757 /* Copying frame */
2750 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+tmp,i-tmp); 2758 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+tmp,i-tmp);
2751 Data->Ringtone->NokiaBinary.Length=i-tmp; 2759 Data->Ringtone->NokiaBinary.Length=i-tmp;
2752 return ERR_NONE; 2760 return ERR_NONE;
2753} 2761}
2754 2762
2755static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 2763static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
2756{ 2764{
2757 GSM_AllRingtonesInfo Info; 2765 GSM_AllRingtonesInfo Info = {0, NULL};
2758 GSM_Error error; 2766 GSM_Error error;
2759 unsigned char req2[6] = {N7110_FRAME_HEADER, 0x12, 2767 unsigned char req2[6] = {N7110_FRAME_HEADER, 0x12,
2760 0x00, 0xe7}; /* Location */ 2768 0x00, 0xe7}; /* Location */
2761 2769
2762 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY; 2770 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
2763 2771
2764 switch (Ringtone->Format) { 2772 switch (Ringtone->Format) {
2765 case RING_NOTETONE: 2773 case RING_NOTETONE:
2766 /* In the future get binary and convert */ 2774 /* In the future get binary and convert */
2767 return ERR_NOTSUPPORTED; 2775 return ERR_NOTSUPPORTED;
2768 case RING_NOKIABINARY: 2776 case RING_NOKIABINARY:
2769 s->Phone.Data.Ringtone= Ringtone; 2777 s->Phone.Data.Ringtone= Ringtone;
2770 Info.Number = 0; 2778 Info.Number = 0;
2771 error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone); 2779 error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone);
2772 if (error != ERR_NONE) return error; 2780 if (error != ERR_NONE) return error;
2773 if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION; 2781 if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION;
2774 req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256; 2782 req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256;
2775 req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256; 2783 req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256;
2776 smprintf(s, "Getting binary ringtone\n"); 2784 smprintf(s, "Getting binary ringtone\n");
2777 return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone); 2785 error = GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone);
2786 if (Info.Ringtone) free(Info.Ringtone);
2787 return error;
2778 case RING_MIDI: 2788 case RING_MIDI:
2779 case RING_MMF: 2789 case RING_MMF:
2780 return ERR_NOTSUPPORTED; 2790 return ERR_NOTSUPPORTED;
2781 } 2791 }
2782 return ERR_NOTSUPPORTED; 2792 return ERR_NOTSUPPORTED;
2783} 2793}
2784 2794
2785static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start) 2795static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start)
2786{ 2796{
2787 GSM_Error error; 2797 GSM_Error error;
2788 unsigned char reqStart[] = { 2798 unsigned char reqStart[] = {
2789 0x00,0x06,0x01,0x00,0x07,0x00 }; 2799 0x00,0x06,0x01,0x00,0x07,0x00 };
2790 unsigned char reqPlay[] = { 2800 unsigned char reqPlay[] = {
2791 0x00,0x06,0x01,0x14,0x05,0x04, 2801 0x00,0x06,0x01,0x14,0x05,0x04,
2792 0x00,0x00,0x00,0x03,0x03,0x08, 2802 0x00,0x00,0x00,0x03,0x03,0x08,
2793 0x00,0x00,0x00,0x01,0x00,0x00, 2803 0x00,0x00,0x00,0x01,0x00,0x00,
2794 0x03,0x08,0x01,0x00, 2804 0x03,0x08,0x01,0x00,
2795 0x07,0xd0,/*Frequency */ 2805 0x07,0xd0,/*Frequency */
2796 0x00,0x00,0x03,0x08,0x02,0x00,0x00, 2806 0x00,0x00,0x03,0x08,0x02,0x00,0x00,
2797 0x05, /*Volume */ 2807 0x05, /*Volume */
2798 0x00,0x00}; 2808 0x00,0x00};
2799 unsigned char reqOff[] = { 2809 unsigned char reqOff[] = {
2800 0x00,0x06,0x01,0x14,0x05,0x05, 2810 0x00,0x06,0x01,0x14,0x05,0x05,
2801 0x00,0x00,0x00,0x01,0x03,0x08, 2811 0x00,0x00,0x00,0x01,0x03,0x08,
2802 0x05,0x00,0x00,0x08,0x00,0x00}; 2812 0x05,0x00,0x00,0x08,0x00,0x00};
2803 // unsigned char reqOff2[] = { 2813 // unsigned char reqOff2[] = {
2804 // 0x00,0x06,0x01,0x14,0x05,0x04, 2814 // 0x00,0x06,0x01,0x14,0x05,0x04,
2805 // 0x00,0x00,0x00,0x01,0x03,0x08, 2815 // 0x00,0x00,0x00,0x01,0x03,0x08,
2806 // 0x00,0x00,0x00,0x00,0x00,0x00}; 2816 // 0x00,0x00,0x00,0x00,0x00,0x00};
2807 2817
2808 if (start) { 2818 if (start) {
2809 smprintf(s, "Enabling sound - part 1\n"); 2819 smprintf(s, "Enabling sound - part 1\n");
2810 error=GSM_WaitFor (s, reqStart, 6, 0x0b, 4, ID_PlayTone); 2820 error=GSM_WaitFor (s, reqStart, 6, 0x0b, 4, ID_PlayTone);
2811 if (error!=ERR_NONE) return error; 2821 if (error!=ERR_NONE) return error;
2812 smprintf(s, "Enabling sound - part 2 (disabling sound command)\n"); 2822 smprintf(s, "Enabling sound - part 2 (disabling sound command)\n");
2813 error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone); 2823 error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone);
2814 if (error!=ERR_NONE) return error; 2824 if (error!=ERR_NONE) return error;
2815 } 2825 }
2816 2826
2817 /* For Herz==255*255 we have silent */ 2827 /* For Herz==255*255 we have silent */
2818 if (Herz!=255*255) { 2828 if (Herz!=255*255) {
2819 reqPlay[23] = Herz%256; 2829 reqPlay[23] = Herz%256;
2820 reqPlay[22] = Herz/256; 2830 reqPlay[22] = Herz/256;
2821 reqPlay[31] = Volume; 2831 reqPlay[31] = Volume;
2822 smprintf(s, "Playing sound\n"); 2832 smprintf(s, "Playing sound\n");
2823 return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone); 2833 return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone);
2824 } else { 2834 } else {
2825 reqPlay[23] = 0; 2835 reqPlay[23] = 0;
2826 reqPlay[22] = 0; 2836 reqPlay[22] = 0;
2827 reqPlay[31] = 0; 2837 reqPlay[31] = 0;
2828 smprintf(s, "Playing silent sound\n"); 2838 smprintf(s, "Playing silent sound\n");
2829 return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone); 2839 return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone);
2830 2840
2831 // smprintf(s, "Disabling sound - part 1\n"); 2841 // smprintf(s, "Disabling sound - part 1\n");
2832 // error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone); 2842 // error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone);
2833 // if (error!=ERR_NONE) return error; 2843 // if (error!=ERR_NONE) return error;
2834 // smprintf(s, "Disabling sound - part 2\n"); 2844 // smprintf(s, "Disabling sound - part 2\n");
2835 // return GSM_WaitFor (s, reqOff2, 18, 0x0b, 4, ID_PlayTone); 2845 // return GSM_WaitFor (s, reqOff2, 18, 0x0b, 4, ID_PlayTone);
2836 } 2846 }
2837} 2847}
2838 2848
2839static GSM_Error N6510_ReplyGetPPM(GSM_Protocol_Message msg, GSM_StateMachine *s) 2849static GSM_Error N6510_ReplyGetPPM(GSM_Protocol_Message msg, GSM_StateMachine *s)
2840{ 2850{
2841 GSM_Phone_Data *Data = &s->Phone.Data; 2851 GSM_Phone_Data *Data = &s->Phone.Data;
2842 int pos = 6,len; 2852 int pos = 6,len;
2843 2853
2844 smprintf(s, "Received phone info\n"); 2854 smprintf(s, "Received phone info\n");
2845 2855
2846 while(pos < msg.Length) { 2856 while(pos < msg.Length) {
2847 if (msg.Buffer[pos] == 0x55 && msg.Buffer[pos+1] == 0x55) { 2857 if (msg.Buffer[pos] == 0x55 && msg.Buffer[pos+1] == 0x55) {
2848 while(1) { 2858 while(1) {
2849 if (msg.Buffer[pos] != 0x55) break; 2859 if (msg.Buffer[pos] != 0x55) break;
2850 pos++; 2860 pos++;
2851 } 2861 }
2852 } 2862 }
2853 len = pos; 2863 len = pos;
2854 while(1) { 2864 while(1) {
2855 if (msg.Buffer[len] == 0x00 && msg.Buffer[len+1] == 0x00) break; 2865 if (msg.Buffer[len] == 0x00 && msg.Buffer[len+1] == 0x00) break;
2856 len++; 2866 len++;
2857 } 2867 }
2858 while(1) { 2868 while(1) {
2859 if (msg.Buffer[len] != 0x00) break; 2869 if (msg.Buffer[len] != 0x00) break;
2860 len++; 2870 len++;
2861 } 2871 }
2862 len = len-pos; 2872 len = len-pos;
2863 smprintf(s, "Block with ID %02x",msg.Buffer[pos]); 2873 smprintf(s, "Block with ID %02x",msg.Buffer[pos]);
2864#ifdef DEBUG 2874#ifdef DEBUG
2865 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, msg.Buffer+pos, len); 2875 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, msg.Buffer+pos, len);
2866#endif 2876#endif
2867 switch (msg.Buffer[pos]) { 2877 switch (msg.Buffer[pos]) {
2868 case 0x49: 2878 case 0x49:
2869 smprintf(s, "hardware version\n"); 2879 smprintf(s, "hardware version\n");
2870 break; 2880 break;
2871 case 0x58: 2881 case 0x58:
2872 pos += 3; 2882 pos += 3;
2873 while (msg.Buffer[pos] != 0x00) pos++; 2883 while (msg.Buffer[pos] != 0x00) pos++;
2874 Data->PhoneString[0] = msg.Buffer[pos - 1]; 2884 Data->PhoneString[0] = msg.Buffer[pos - 1];
2875 Data->PhoneString[1] = 0x00; 2885 Data->PhoneString[1] = 0x00;
2876 smprintf(s, "PPM %s\n",Data->PhoneString); 2886 smprintf(s, "PPM %s\n",Data->PhoneString);
2877 return ERR_NONE; 2887 return ERR_NONE;
2878 default: 2888 default:
2879 break; 2889 break;
2880 } 2890 }
2881 pos += len; 2891 pos += len;
2882 } 2892 }
2883 return ERR_NOTSUPPORTED; 2893 return ERR_NOTSUPPORTED;
2884} 2894}
2885 2895
2886static GSM_Error N6510_GetPPM(GSM_StateMachine *s,char *value) 2896static GSM_Error N6510_GetPPM(GSM_StateMachine *s,char *value)
2887{ 2897{
2888 //unsigned char req[6] = {N6110_FRAME_HEADER, 0x07, 0x01, 0xff}; 2898 //unsigned char req[6] = {N6110_FRAME_HEADER, 0x07, 0x01, 0xff};
2889 unsigned char req[6] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x00}; 2899 unsigned char req[6] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x00};
2890 2900
2891 s->Phone.Data.PhoneString=value; 2901 s->Phone.Data.PhoneString=value;
2892 smprintf(s, "Getting PPM\n"); 2902 smprintf(s, "Getting PPM\n");
2893 return GSM_WaitFor (s, req, 6, 0x1b, 3, ID_GetPPM); 2903 return GSM_WaitFor (s, req, 6, 0x1b, 3, ID_GetPPM);
2894} 2904}
2895 2905
2896static GSM_Error N6510_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial) 2906static GSM_Error N6510_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial)
2897{ 2907{
2898 GSM_MemoryEntry pbk; 2908 GSM_MemoryEntry pbk;
2899 GSM_Error error; 2909 GSM_Error error;
2900 2910
2901 pbk.MemoryType = MEM7110_SP; 2911 pbk.MemoryType = MEM7110_SP;
2902 pbk.Location = SpeedDial->Location; 2912 pbk.Location = SpeedDial->Location;
2903 SpeedDial->MemoryLocation = 0; 2913 SpeedDial->MemoryLocation = 0;
2904 s->Phone.Data.SpeedDial = SpeedDial; 2914 s->Phone.Data.SpeedDial = SpeedDial;
2905 2915
2906 smprintf(s, "Getting speed dial\n"); 2916 smprintf(s, "Getting speed dial\n");
2907 error=N6510_GetMemory(s,&pbk); 2917 error=N6510_GetMemory(s,&pbk);
2908 switch (error) { 2918 switch (error) {
2909 case ERR_NOTSUPPORTED: 2919 case ERR_NOTSUPPORTED:
2910 smprintf(s, "No speed dials set in phone\n"); 2920 smprintf(s, "No speed dials set in phone\n");
2911 return ERR_EMPTY; 2921 return ERR_EMPTY;
2912 case ERR_NONE: 2922 case ERR_NONE:
2913 if (SpeedDial->MemoryLocation == 0) { 2923 if (SpeedDial->MemoryLocation == 0) {
2914 smprintf(s, "Speed dial not assigned or error in firmware\n"); 2924 smprintf(s, "Speed dial not assigned or error in firmware\n");
2915 return ERR_EMPTY; 2925 return ERR_EMPTY;
2916 } 2926 }
2917 return ERR_NONE; 2927 return ERR_NONE;
2918 default: 2928 default:
2919 return error; 2929 return error;
2920 } 2930 }
2921} 2931}
2922 2932
2923static GSM_Error N6510_ReplyGetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s) 2933static GSM_Error N6510_ReplyGetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s)
2924{ 2934{
2925 unsigned char *blockstart; 2935 unsigned char *blockstart;
2926 int i,j; 2936 int i,j;
2927 GSM_Phone_Data*Data = &s->Phone.Data; 2937 GSM_Phone_Data*Data = &s->Phone.Data;
2928 2938
2929 switch (msg.Buffer[3]) { 2939 switch (msg.Buffer[3]) {
2930 case 0x02: 2940 case 0x02:
2931 blockstart = msg.Buffer + 7; 2941 blockstart = msg.Buffer + 7;
2932 for (i = 0; i < 11; i++) { 2942 for (i = 0; i < 11; i++) {
2933 smprintf(s, "Profile feature %02x ",blockstart[1]); 2943 smprintf(s, "Profile feature %02x ",blockstart[1]);
2934#ifdef DEBUG 2944#ifdef DEBUG
2935 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, blockstart, blockstart[0]); 2945 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, blockstart, blockstart[0]);
2936#endif 2946#endif
2937 2947
2938 switch (blockstart[1]) { 2948 switch (blockstart[1]) {
2939 case 0x03: 2949 case 0x03:
2940 smprintf(s, "Ringtone ID\n"); 2950 smprintf(s, "Ringtone ID\n");
2941 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_RingtoneID; 2951 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_RingtoneID;
2942 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[7]; 2952 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[7];
2943 if (blockstart[7] == 0x00) { 2953 if (blockstart[7] == 0x00) {
2944 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[10]; 2954 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[10];
2945 } 2955 }
2946 Data->Profile->FeaturesNumber++; 2956 Data->Profile->FeaturesNumber++;
2947 break; 2957 break;
2948 case 0x05:/* SMS tone */ 2958 case 0x05:/* SMS tone */
2949 j = Data->Profile->FeaturesNumber; 2959 j = Data->Profile->FeaturesNumber;
2950 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false); 2960 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false);
2951 if (j == Data->Profile->FeaturesNumber) { 2961 if (j == Data->Profile->FeaturesNumber) {
2952 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageTone; 2962 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageTone;
2953 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = PROFILE_MESSAGE_PERSONAL; 2963 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = PROFILE_MESSAGE_PERSONAL;
2954 Data->Profile->FeaturesNumber++; 2964 Data->Profile->FeaturesNumber++;
2955 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageToneID; 2965 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_MessageToneID;
2956 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[7]; 2966 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = blockstart[7];
2957 Data->Profile->FeaturesNumber++; 2967 Data->Profile->FeaturesNumber++;
2958 } 2968 }
2959 break; 2969 break;
2960 case 0x08:/* Caller groups */ 2970 case 0x08:/* Caller groups */
2961 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,true); 2971 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,true);
2962 break; 2972 break;
2963 case 0x0c : 2973 case 0x0c :
2964 CopyUnicodeString(Data->Profile->Name,blockstart + 7); 2974 CopyUnicodeString(Data->Profile->Name,blockstart + 7);
2965 smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name)); 2975 smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name));
2966 Data->Profile->DefaultName = false; 2976 Data->Profile->DefaultName = false;
2967 break; 2977 break;
2968 default: 2978 default:
2969 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false); 2979 NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false);
2970 } 2980 }
2971 blockstart = blockstart + blockstart[0]; 2981 blockstart = blockstart + blockstart[0];
2972 } 2982 }
2973 return ERR_NONE; 2983 return ERR_NONE;
2974 case 0x06: 2984 case 0x06:
2975 Data->Profile->Active = false; 2985 Data->Profile->Active = false;
2976 if (Data->Profile->Location == msg.Buffer[5]) Data->Profile->Active = true; 2986 if (Data->Profile->Location == msg.Buffer[5]) Data->Profile->Active = true;
2977 return ERR_NONE; 2987 return ERR_NONE;
2978 } 2988 }
2979 return ERR_UNKNOWNRESPONSE; 2989 return ERR_UNKNOWNRESPONSE;
2980} 2990}
2981 2991
2982static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile) 2992static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
2983{ 2993{
2984 unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01}; 2994 unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01};
2985 unsigned charreqActive[] = {N6110_FRAME_HEADER, 0x05}; 2995 unsigned charreqActive[] = {N6110_FRAME_HEADER, 0x05};
2986 int i, length = 7; 2996 int i, length = 7;
2987 GSM_Errorerror; 2997 GSM_Errorerror;
2988 2998
2989 /* For now !!! */ 2999 /* For now !!! */
2990 if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) { 3000 if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) {
2991 if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED; 3001 if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED;
2992 } 3002 }
2993 if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) { 3003 if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) {
2994 return ERR_NOTSUPPORTED; 3004 return ERR_NOTSUPPORTED;
2995 } 3005 }
2996 if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) { 3006 if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) {
2997 return ERR_NOTSUPPORTED; 3007 return ERR_NOTSUPPORTED;
2998 } 3008 }
2999 3009
3000 if (Profile->Location>5) return ERR_INVALIDLOCATION; 3010 if (Profile->Location>5) return ERR_INVALIDLOCATION;
3001 3011
3002 for (i = 0; i < 0x0a; i++) { 3012 for (i = 0; i < 0x0a; i++) {
3003 req[length++] = 0x04; 3013 req[length++] = 0x04;
3004 req[length++] = Profile->Location; 3014 req[length++] = Profile->Location;
3005 req[length++] = i; 3015 req[length++] = i;
3006 req[length++] = 0x01; 3016 req[length++] = 0x01;
3007 } 3017 }
3008 3018
3009 req[length++] = 0x04; 3019 req[length++] = 0x04;
3010 req[length++] = Profile->Location; 3020 req[length++] = Profile->Location;
3011 req[length++] = 0x0c; 3021 req[length++] = 0x0c;
3012 req[length++] = 0x01; 3022 req[length++] = 0x01;
3013 3023
3014 req[length++] = 0x04; 3024 req[length++] = 0x04;
3015 3025
3016 Profile->CarKitProfile= false; 3026 Profile->CarKitProfile= false;
3017 Profile->HeadSetProfile= false; 3027 Profile->HeadSetProfile= false;
3018 3028
3019 Profile->FeaturesNumber = 0; 3029 Profile->FeaturesNumber = 0;
3020 3030
3021 s->Phone.Data.Profile=Profile; 3031 s->Phone.Data.Profile=Profile;
3022 smprintf(s, "Getting profile\n"); 3032 smprintf(s, "Getting profile\n");
3023 error = GSM_WaitFor (s, req, length, 0x39, 4, ID_GetProfile); 3033 error = GSM_WaitFor (s, req, length, 0x39, 4, ID_GetProfile);
3024 if (error != ERR_NONE) return error; 3034 if (error != ERR_NONE) return error;
3025 3035
3026 smprintf(s, "Checking, which profile is active\n"); 3036 smprintf(s, "Checking, which profile is active\n");
3027 return GSM_WaitFor (s, reqActive, 4, 0x39, 4, ID_GetProfile); 3037 return GSM_WaitFor (s, reqActive, 4, 0x39, 4, ID_GetProfile);
3028} 3038}
3029 3039
3030static GSM_Error N6510_ReplySetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s) 3040static GSM_Error N6510_ReplySetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s)
3031{ 3041{
3032 unsigned char *blockstart; 3042 unsigned char *blockstart;
3033 int i; 3043 int i;
3034 3044
3035 smprintf(s, "Response to profile writing received!\n"); 3045 smprintf(s, "Response to profile writing received!\n");
3036 3046
3037 blockstart = msg.Buffer + 6; 3047 blockstart = msg.Buffer + 6;
3038 for (i = 0; i < msg.Buffer[5]; i++) { 3048 for (i = 0; i < msg.Buffer[5]; i++) {
3039 switch (blockstart[2]) { 3049 switch (blockstart[2]) {
3040 case 0x00: smprintf(s, "keypad tone level"); break; 3050 case 0x00: smprintf(s, "keypad tone level"); break;
3041 case 0x02: smprintf(s, "call alert"); break; 3051 case 0x02: smprintf(s, "call alert"); break;
3042 case 0x03: smprintf(s, "ringtone"); break; 3052 case 0x03: smprintf(s, "ringtone"); break;
3043 case 0x04: smprintf(s, "ringtone volume"); break; 3053 case 0x04: smprintf(s, "ringtone volume"); break;
3044 case 0x05: smprintf(s, "SMS tone"); break; 3054 case 0x05: smprintf(s, "SMS tone"); break;
3045 case 0x06: smprintf(s, "vibration"); break; 3055 case 0x06: smprintf(s, "vibration"); break;
3046 case 0x07: smprintf(s, "warning tone level"); break; 3056 case 0x07: smprintf(s, "warning tone level"); break;
3047 case 0x08: smprintf(s, "caller groups"); break; 3057 case 0x08: smprintf(s, "caller groups"); break;
3048 case 0x09: smprintf(s, "automatic answer"); break; 3058 case 0x09: smprintf(s, "automatic answer"); break;
3049 case 0x0c: smprintf(s, "name"); break; 3059 case 0x0c: smprintf(s, "name"); break;
3050 default: 3060 default:
3051 smprintf(s, "Unknown block type %02x", blockstart[2]); 3061 smprintf(s, "Unknown block type %02x", blockstart[2]);
3052 break; 3062 break;
3053 } 3063 }
3054 if (msg.Buffer[4] == 0x00) { 3064 if (msg.Buffer[4] == 0x00) {
3055 smprintf(s, ": set OK\n"); 3065 smprintf(s, ": set OK\n");
3056 } else { 3066 } else {
3057 smprintf(s, ": setting error %i\n", msg.Buffer[4]); 3067 smprintf(s, ": setting error %i\n", msg.Buffer[4]);
3058 } 3068 }
3059 blockstart = blockstart + blockstart[1]; 3069 blockstart = blockstart + blockstart[1];
3060 } 3070 }
3061 return ERR_NONE; 3071 return ERR_NONE;
3062} 3072}
3063 3073
3064static GSM_Error N6510_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile) 3074static GSM_Error N6510_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
3065{ 3075{
3066 int i, length = 7, blocks = 0; 3076 int i, length = 7, blocks = 0;
3067 bool found; 3077 bool found;
3068 unsigned charID,Value; 3078 unsigned charID,Value;
3069 unsigned char req[150] = {N6110_FRAME_HEADER, 0x03, 0x01, 3079 unsigned char req[150] = {N6110_FRAME_HEADER, 0x03, 0x01,
3070 0x06, /* Number of blocks */ 3080 0x06, /* Number of blocks */
3071 0x03}; 3081 0x03};
3072 3082
3073 if (Profile->Location>5) return ERR_INVALIDLOCATION; 3083 if (Profile->Location>5) return ERR_INVALIDLOCATION;
3074 3084
3075 for (i=0;i<Profile->FeaturesNumber;i++) { 3085 for (i=0;i<Profile->FeaturesNumber;i++) {
3076 found = false; 3086 found = false;
3077 switch (Profile->FeatureID[i]) { 3087 switch (Profile->FeatureID[i]) {
3078 case Profile_RingtoneID: 3088 case Profile_RingtoneID:
3079 ID = 0x03; 3089 ID = 0x03;
3080 Value = Profile->FeatureValue[i]; 3090 Value = Profile->FeatureValue[i];
3081 found = true; 3091 found = true;
3082 break; 3092 break;
3083 default: 3093 default:
3084 found=NOKIA_FindPhoneFeatureValue( 3094 found=NOKIA_FindPhoneFeatureValue(
3085 s, 3095 s,
3086 Profile71_65, 3096 Profile71_65,
3087 Profile->FeatureID[i],Profile->FeatureValue[i], 3097 Profile->FeatureID[i],Profile->FeatureValue[i],
3088 &ID,&Value); 3098 &ID,&Value);
3089 } 3099 }
3090 if (found) { 3100 if (found) {
3091 req[length] = 0x09; 3101 req[length] = 0x09;
3092 req[length + 1] = ID; 3102 req[length + 1] = ID;
3093 req[length + 2] = Profile->Location; 3103 req[length + 2] = Profile->Location;
3094 memcpy(req + length + 4, "\x00\x00\x01", 3); 3104 memcpy(req + length + 4, "\x00\x00\x01", 3);
3095 req[length + 8] = 0x03; 3105 req[length + 8] = 0x03;
3096 req[length + 3] = req[length + 7] = Value; 3106 req[length + 3] = req[length + 7] = Value;
3097 blocks++; 3107 blocks++;
3098 length += 9; 3108 length += 9;
3099 } 3109 }
3100 } 3110 }
3101 3111
3102 smprintf(s, "Setting profile\n"); 3112 smprintf(s, "Setting profile\n");
3103 return GSM_WaitFor (s, req, length, 0x39, 4, ID_SetProfile); 3113 return GSM_WaitFor (s, req, length, 0x39, 4, ID_SetProfile);
3104} 3114}
3105 3115
3106static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) 3116static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
3107{ 3117{
3108 GSM_SMSMessage sms; 3118 GSM_SMSMessage sms;
3109 3119
3110#ifdef DEBUG 3120#ifdef DEBUG
3111 smprintf(s, "SMS message received\n"); 3121 smprintf(s, "SMS message received\n");
3112 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); 3122 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
3113#endif 3123#endif
3114 3124
3115 if (s->Phone.Data.EnableIncomingSMS && s->User.IncomingSMS!=NULL) { 3125 if (s->Phone.Data.EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
3116 sms.State = SMS_UnRead; 3126 sms.State = SMS_UnRead;
3117 sms.InboxFolder = true; 3127 sms.InboxFolder = true;
3118 3128
3119 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); 3129 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
3120 3130
3121 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 3131 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
3122 } 3132 }
3123 return ERR_NONE; 3133 return ERR_NONE;
3124} 3134}
3125 3135
3126static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 3136static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
3127{ 3137{
3128 unsigned int pos2 = 15; 3138 unsigned int pos2 = 15;
3129 unsigned intpos = 4; 3139 unsigned intpos = 4;
3130 unsigned char req2[100] = {N6110_FRAME_HEADER,0x01, 3140 unsigned char req2[100] = {N6110_FRAME_HEADER,0x01,
3131 0x00,0x02,0x07,0x04, 3141 0x00,0x02,0x07,0x04,
3132 0x01, // 1 - voice, 2 - data 3142 0x01, // 1 - voice, 2 - data
3133 0x00,0x03, 3143 0x00,0x03,
3134 0x18, // length of rest + 1 3144 0x18, // length of rest + 1
3135 0x00,0x00,0x00}; 3145 0x00,0x00,0x00};
3136 unsigned char req[100] = {N6110_FRAME_HEADER,0x01, 3146 unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
3137 0x0c};/* Number length */ 3147 0x0c};/* Number length */
3138 GSM_Errorerror; 3148 GSM_Errorerror;
3139 3149
3140 /* USSD not supported */ 3150 /* USSD not supported */
3141 if (number[0] == '*') return ERR_NOTSUPPORTED; 3151 if (number[0] == '*') return ERR_NOTSUPPORTED;
3142 if (number[0] == '#') return ERR_NOTSUPPORTED; 3152 if (number[0] == '#') return ERR_NOTSUPPORTED;
3143 3153
3144 req[pos++] = strlen(number); 3154 req[pos++] = strlen(number);
3145 EncodeUnicode(req+pos,number,strlen(number)); 3155 EncodeUnicode(req+pos,number,strlen(number));
3146 pos += strlen(number)*2; 3156 pos += strlen(number)*2;
3147 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ 3157 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
3148 req[pos++] = 0x01; 3158 req[pos++] = 0x01;
3149 req[pos++] = 0x05; 3159 req[pos++] = 0x05;
3150 req[pos++] = 0x00; 3160 req[pos++] = 0x00;
3151 req[pos++] = 0x02; 3161 req[pos++] = 0x02;
3152 req[pos++] = 0x00; 3162 req[pos++] = 0x00;
3153 req[pos++] = 0x00; 3163 req[pos++] = 0x00;
3154 switch (ShowNumber) { 3164 switch (ShowNumber) {
3155 case GSM_CALL_HideNumber: 3165 case GSM_CALL_HideNumber:
3156 req[pos++] = 0x02; 3166 req[pos++] = 0x02;
3157 break; 3167 break;
3158 case GSM_CALL_ShowNumber: 3168 case GSM_CALL_ShowNumber:
3159 req[pos++] = 0x03; 3169 req[pos++] = 0x03;
3160 break; 3170 break;
3161 case GSM_CALL_DefaultNumberPresence: 3171 case GSM_CALL_DefaultNumberPresence:
@@ -3673,768 +3683,859 @@ GSM_Error N6510_AddCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, int *
3673 } 3683 }
3674 3684
3675 if (EndTime != -1) memcpy(&DT,&Note->Entries[EndTime].Date,sizeof(GSM_DateTime)); 3685 if (EndTime != -1) memcpy(&DT,&Note->Entries[EndTime].Date,sizeof(GSM_DateTime));
3676 req[34]= DT.Year / 256; 3686 req[34]= DT.Year / 256;
3677 req[35]= DT.Year % 256; 3687 req[35]= DT.Year % 256;
3678 req[36]= DT.Month; 3688 req[36]= DT.Month;
3679 req[37]= DT.Day; 3689 req[37]= DT.Day;
3680 req[38]= DT.Hour; 3690 req[38]= DT.Hour;
3681 req[39]= DT.Minute; 3691 req[39]= DT.Minute;
3682 if (NoteType == GSM_CAL_BIRTHDAY) { 3692 if (NoteType == GSM_CAL_BIRTHDAY) {
3683 req[34]= date_time.Year / 256; 3693 req[34]= date_time.Year / 256;
3684 req[35] = date_time.Year % 256; 3694 req[35] = date_time.Year % 256;
3685 } 3695 }
3686 3696
3687 if (Recurrance != -1) { 3697 if (Recurrance != -1) {
3688 /* max. 1 Year = 8760 hours */ 3698 /* max. 1 Year = 8760 hours */
3689 if (Note->Entries[Recurrance].Number >= 8760) { 3699 if (Note->Entries[Recurrance].Number >= 8760) {
3690 req[40] = 0xff; 3700 req[40] = 0xff;
3691 req[41] = 0xff; 3701 req[41] = 0xff;
3692 } else { 3702 } else {
3693 req[40] = Note->Entries[Recurrance].Number / 256; 3703 req[40] = Note->Entries[Recurrance].Number / 256;
3694 req[41] = Note->Entries[Recurrance].Number % 256; 3704 req[41] = Note->Entries[Recurrance].Number % 256;
3695 } 3705 }
3696 } 3706 }
3697 3707
3698 if (Alarm != -1) { 3708 if (Alarm != -1) {
3699 memcpy(&DT,&Note->Entries[Time].Date,sizeof(GSM_DateTime)); 3709 memcpy(&DT,&Note->Entries[Time].Date,sizeof(GSM_DateTime));
3700 if (Note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 3710 if (Note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
3701 req[22] = 0x00; req[23] = 0x00; req[24] = 0x00; req[25] = 0x00; 3711 req[22] = 0x00; req[23] = 0x00; req[24] = 0x00; req[25] = 0x00;
3702 } 3712 }
3703 if (NoteType == GSM_CAL_BIRTHDAY) DT.Year = date_time.Year; 3713 if (NoteType == GSM_CAL_BIRTHDAY) DT.Year = date_time.Year;
3704 t_time2 = Fill_Time_T(DT,8); 3714 t_time2 = Fill_Time_T(DT,8);
3705 t_time1 = Fill_Time_T(Note->Entries[Alarm].Date,8); 3715 t_time1 = Fill_Time_T(Note->Entries[Alarm].Date,8);
3706 diff = (t_time1-t_time2)/60; 3716 diff = (t_time1-t_time2)/60;
3707 3717
3708 smprintf(s, " Difference : %li seconds or minutes\n", -diff); 3718 smprintf(s, " Difference : %li seconds or minutes\n", -diff);
3709 req[14] = (unsigned char)(-diff >> 24); 3719 req[14] = (unsigned char)(-diff >> 24);
3710 req[15] = (unsigned char)(-diff >> 16); 3720 req[15] = (unsigned char)(-diff >> 16);
3711 req[16] = (unsigned char)(-diff >> 8); 3721 req[16] = (unsigned char)(-diff >> 8);
3712 req[17] = (unsigned char)(-diff); 3722 req[17] = (unsigned char)(-diff);
3713 } 3723 }
3714 3724
3715 if (Text != -1) { 3725 if (Text != -1) {
3716 req[49] = UnicodeLength(Note->Entries[Text].Text); 3726 req[49] = UnicodeLength(Note->Entries[Text].Text);
3717 CopyUnicodeString(req+54,Note->Entries[Text].Text); 3727 CopyUnicodeString(req+54,Note->Entries[Text].Text);
3718 count+= req[49]*2; 3728 count+= req[49]*2;
3719 } 3729 }
3720 3730
3721 if (Phone != -1 && NoteType == GSM_CAL_CALL) { 3731 if (Phone != -1 && NoteType == GSM_CAL_CALL) {
3722 req[50] = UnicodeLength(Note->Entries[Phone].Text); 3732 req[50] = UnicodeLength(Note->Entries[Phone].Text);
3723 CopyUnicodeString(req+54+req[49]*2,Note->Entries[Phone].Text); 3733 CopyUnicodeString(req+54+req[49]*2,Note->Entries[Phone].Text);
3724 count+= req[50]*2; 3734 count+= req[50]*2;
3725 } 3735 }
3726 3736
3727 if (Location != -1 && NoteType == GSM_CAL_MEETING) { 3737 if (Location != -1 && NoteType == GSM_CAL_MEETING) {
3728 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62) || 3738 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62) ||
3729 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) || 3739 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) ||
3730 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35)) { 3740 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35)) {
3731 } else { 3741 } else {
3732 req[50] = UnicodeLength(Note->Entries[Location].Text); 3742 req[50] = UnicodeLength(Note->Entries[Location].Text);
3733 CopyUnicodeString(req+54+req[49]*2,Note->Entries[Location].Text); 3743 CopyUnicodeString(req+54+req[49]*2,Note->Entries[Location].Text);
3734 count+= req[50]*2; 3744 count+= req[50]*2;
3735 } 3745 }
3736 } 3746 }
3737 3747
3738 req[count++] = 0x00; 3748 req[count++] = 0x00;
3739 3749
3740 smprintf(s, "Writing calendar note method 3\n"); 3750 smprintf(s, "Writing calendar note method 3\n");
3741 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetCalendarNote); 3751 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetCalendarNote);
3742} 3752}
3743 3753
3744static GSM_Error N6510_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 3754static GSM_Error N6510_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
3745{ 3755{
3746#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3756#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3747 /* Method 1. Some features missed. Not working with some notes in 3510 */ 3757 /* Method 1. Some features missed. Not working with some notes in 3510 */
3748 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3758 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3749#endif 3759#endif
3750 3760
3751 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3761 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3752 /* Method 1. Some features missed. Not working with some notes in 3510 */ 3762 /* Method 1. Some features missed. Not working with some notes in 3510 */
3753 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3763 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3754 3764
3755 /* Method 2. In known phones texts of notes cut to 50 chars. Some features missed */ 3765 /* Method 2. In known phones texts of notes cut to 50 chars. Some features missed */
3756 // return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3766 // return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3757 } else { 3767 } else {
3758 /* Method 3. All DCT4 features supported. Not supported by 8910 */ 3768 /* Method 3. All DCT4 features supported. Not supported by 8910 */
3759 return N6510_GetNextCalendar3(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); 3769 return N6510_GetNextCalendar3(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
3760 } 3770 }
3761} 3771}
3762 3772
3763static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 3773static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
3764{ 3774{
3765 GSM_Error error; 3775 GSM_Error error;
3766 3776
3767#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3777#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3768 /* Method 1 */ 3778 /* Method 1 */
3769 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); 3779 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
3770 if (error!=ERR_NONE) return error; 3780 if (error!=ERR_NONE) return error;
3771 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3781 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3772 return ERR_NONE; 3782 return ERR_NONE;
3773#endif 3783#endif
3774 3784
3775 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3785 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3776 /* Method 1 */ 3786 /* Method 1 */
3777 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); 3787 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
3778 if (error!=ERR_NONE) return error; 3788 if (error!=ERR_NONE) return error;
3779 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3789 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3780 return ERR_NONE; 3790 return ERR_NONE;
3781 3791
3782 /* Method 2 */ 3792 /* Method 2 */
3783 // return ERR_NOTSUPPORTED; 3793 // return ERR_NOTSUPPORTED;
3784 } else { 3794 } else {
3785 /* Method 3 */ 3795 /* Method 3 */
3786 error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0); 3796 error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0);
3787 if (error!=ERR_NONE) return error; 3797 if (error!=ERR_NONE) return error;
3788 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3798 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3789 return ERR_NONE; 3799 return ERR_NONE;
3790 } 3800 }
3791} 3801}
3792 3802
3793static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 3803static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3794{ 3804{
3795#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3805#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3796 return N71_65_AddCalendar2(s,Note); 3806 return N71_65_AddCalendar2(s,Note);
3797#endif 3807#endif
3798 3808
3799 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3809 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3800 return N71_65_AddCalendar2(s,Note); 3810 return N71_65_AddCalendar2(s,Note);
3801 // return N71_65_AddCalendar1(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos); 3811 // return N71_65_AddCalendar1(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
3802 } else { 3812 } else {
3803 /* Method 3. All DCT4 features supported. Not supported by 8910 */ 3813 /* Method 3. All DCT4 features supported. Not supported by 8910 */
3804 return N6510_AddCalendar3(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos); 3814 return N6510_AddCalendar3(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
3805 } 3815 }
3806} 3816}
3807 3817
3808static GSM_Error N6510_ReplyLogIntoNetwork(GSM_Protocol_Message msg, GSM_StateMachine *s) 3818static GSM_Error N6510_ReplyLogIntoNetwork(GSM_Protocol_Message msg, GSM_StateMachine *s)
3809{ 3819{
3810 smprintf(s, "Probably phone says: I log into network\n"); 3820 smprintf(s, "Probably phone says: I log into network\n");
3811 return ERR_NONE; 3821 return ERR_NONE;
3812} 3822}
3813 3823
3814void N6510_EncodeFMFrequency(double freq, unsigned char *buff) 3824void N6510_EncodeFMFrequency(double freq, unsigned char *buff)
3815{ 3825{
3816 double freq0; 3826 double freq0;
3817 unsigned char buffer[20]; 3827 unsigned char buffer[20];
3818 unsigned int i,freq2; 3828 unsigned int i,freq2;
3819 3829
3820 sprintf(buffer,"%.3f",freq); 3830 sprintf(buffer,"%.3f",freq);
3821 for (i=0;i<strlen(buffer);i++) { 3831 for (i=0;i<strlen(buffer);i++) {
3822 if (buffer[i] == ',' || buffer[i] == '.') buffer[i] = ' '; 3832 if (buffer[i] == ',' || buffer[i] == '.') buffer[i] = ' ';
3823 } 3833 }
3824 StringToDouble(buffer, &freq0); 3834 StringToDouble(buffer, &freq0);
3825 freq2 = (unsigned int)freq0; 3835 freq2 = (unsigned int)freq0;
3826 dbgprintf("Frequency: %s %i\n",buffer,freq2); 3836 dbgprintf("Frequency: %s %i\n",buffer,freq2);
3827 freq2= freq2 - 0xffff; 3837 freq2= freq2 - 0xffff;
3828 buff[0] = freq2 / 0x100; 3838 buff[0] = freq2 / 0x100;
3829 buff[1] = freq2 % 0x100; 3839 buff[1] = freq2 % 0x100;
3830} 3840}
3831 3841
3832void N6510_DecodeFMFrequency(double *freq, unsigned char *buff) 3842void N6510_DecodeFMFrequency(double *freq, unsigned char *buff)
3833{ 3843{
3834 unsigned char buffer[20]; 3844 unsigned char buffer[20];
3835 3845
3836 sprintf(buffer,"%i.%i",(0xffff + buff[0] * 0x100 + buff[1])/1000, 3846 sprintf(buffer,"%i.%i",(0xffff + buff[0] * 0x100 + buff[1])/1000,
3837 (0xffff + buff[0] * 0x100 + buff[1])%1000); 3847 (0xffff + buff[0] * 0x100 + buff[1])%1000);
3838 dbgprintf("Frequency: %s\n",buffer); 3848 dbgprintf("Frequency: %s\n",buffer);
3839 StringToDouble(buffer, freq); 3849 StringToDouble(buffer, freq);
3840} 3850}
3841 3851
3842static GSM_Error N6510_ReplyGetFMStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 3852static GSM_Error N6510_ReplyGetFMStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
3843{ 3853{
3844 smprintf(s, "getting FM status OK\n"); 3854 smprintf(s, "getting FM status OK\n");
3845 memcpy(s->Phone.Data.Priv.N6510.FMStatus,msg.Buffer,msg.Length); 3855 memcpy(s->Phone.Data.Priv.N6510.FMStatus,msg.Buffer,msg.Length);
3846 s->Phone.Data.Priv.N6510.FMStatusLength = msg.Length; 3856 s->Phone.Data.Priv.N6510.FMStatusLength = msg.Length;
3847 return ERR_NONE; 3857 return ERR_NONE;
3848} 3858}
3849 3859
3850static GSM_Error N6510_GetFMStatus(GSM_StateMachine *s) 3860static GSM_Error N6510_GetFMStatus(GSM_StateMachine *s)
3851{ 3861{
3852 unsigned char req[7] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x01}; 3862 unsigned char req[7] = {N6110_FRAME_HEADER, 0x0d, 0x00, 0x00, 0x01};
3853 3863
3854 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED; 3864 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED;
3855 return GSM_WaitFor (s, req, 7, 0x3E, 2, ID_GetFMStation); 3865 return GSM_WaitFor (s, req, 7, 0x3E, 2, ID_GetFMStation);
3856} 3866}
3857 3867
3858static GSM_Error N6510_ReplyGetFMStation(GSM_Protocol_Message msg, GSM_StateMachine *s) 3868static GSM_Error N6510_ReplyGetFMStation(GSM_Protocol_Message msg, GSM_StateMachine *s)
3859{ 3869{
3860 unsigned char name[GSM_MAX_FMSTATION_LENGTH*2+2]; 3870 unsigned char name[GSM_MAX_FMSTATION_LENGTH*2+2];
3861 int length; 3871 int length;
3862 GSM_Phone_Data*Data = &s->Phone.Data; 3872 GSM_Phone_Data*Data = &s->Phone.Data;
3863 3873
3864 switch (msg.Buffer[3]) { 3874 switch (msg.Buffer[3]) {
3865 case 0x06: 3875 case 0x06:
3866 smprintf(s, "Received FM station\n"); 3876 smprintf(s, "Received FM station\n");
3867 length = msg.Buffer[8]; 3877 length = msg.Buffer[8];
3868 memcpy(name,msg.Buffer+18,length*2); 3878 memcpy(name,msg.Buffer+18,length*2);
3869 name[length*2] = 0x00; 3879 name[length*2] = 0x00;
3870 name[length*2+1] = 0x00; 3880 name[length*2+1] = 0x00;
3871 CopyUnicodeString(Data->FMStation->StationName,name); 3881 CopyUnicodeString(Data->FMStation->StationName,name);
3872 smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(Data->FMStation->StationName)); 3882 smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(Data->FMStation->StationName));
3873 N6510_DecodeFMFrequency(&Data->FMStation->Frequency, msg.Buffer+16); 3883 N6510_DecodeFMFrequency(&Data->FMStation->Frequency, msg.Buffer+16);
3874 return ERR_NONE; 3884 return ERR_NONE;
3875 case 0x16: 3885 case 0x16:
3876 smprintf(s, "Received FM station. Empty ?\n"); 3886 smprintf(s, "Received FM station. Empty ?\n");
3877 return ERR_EMPTY; 3887 return ERR_EMPTY;
3878 } 3888 }
3879 return ERR_UNKNOWNRESPONSE; 3889 return ERR_UNKNOWNRESPONSE;
3880} 3890}
3881 3891
3882static GSM_Error N6510_GetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStation) 3892static GSM_Error N6510_GetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStation)
3883{ 3893{
3884 GSM_Error error; 3894 GSM_Error error;
3885 int location; 3895 int location;
3886 unsigned char req[7] = {N6110_FRAME_HEADER, 0x05, 3896 unsigned char req[7] = {N6110_FRAME_HEADER, 0x05,
3887 0x00, // location 3897 0x00, // location
3888 0x00,0x01}; 3898 0x00,0x01};
3889 3899
3890 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED; 3900 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED;
3891 if (FMStation->Location > GSM_MAX_FM_STATION) return ERR_INVALIDLOCATION; 3901 if (FMStation->Location > GSM_MAX_FM_STATION) return ERR_INVALIDLOCATION;
3892 3902
3893 s->Phone.Data.FMStation = FMStation; 3903 s->Phone.Data.FMStation = FMStation;
3894 3904
3895 error = N6510_GetFMStatus(s); 3905 error = N6510_GetFMStatus(s);
3896 if (error != ERR_NONE) return error; 3906 if (error != ERR_NONE) return error;
3897 3907
3898 location = FMStation->Location-1; 3908 location = FMStation->Location-1;
3899 if (s->Phone.Data.Priv.N6510.FMStatus[14+location] == 0xFF) return ERR_EMPTY; 3909 if (s->Phone.Data.Priv.N6510.FMStatus[14+location] == 0xFF) return ERR_EMPTY;
3900 req[4] = s->Phone.Data.Priv.N6510.FMStatus[14+location]; 3910 req[4] = s->Phone.Data.Priv.N6510.FMStatus[14+location];
3901 3911
3902 smprintf(s, "Getting FM Station %i\n",FMStation->Location); 3912 smprintf(s, "Getting FM Station %i\n",FMStation->Location);
3903 return GSM_WaitFor (s, req, 7, 0x3E, 2, ID_GetFMStation); 3913 return GSM_WaitFor (s, req, 7, 0x3E, 2, ID_GetFMStation);
3904} 3914}
3905 3915
3906static GSM_Error N6510_ReplySetFMStation(GSM_Protocol_Message msg, GSM_StateMachine *s) 3916static GSM_Error N6510_ReplySetFMStation(GSM_Protocol_Message msg, GSM_StateMachine *s)
3907{ 3917{
3908#ifdef DEBUG 3918#ifdef DEBUG
3909 switch (msg.Buffer[4]){ 3919 switch (msg.Buffer[4]){
3910 case 0x03: smprintf(s, "FM stations cleaned\n"); break; 3920 case 0x03: smprintf(s, "FM stations cleaned\n"); break;
3911 case 0x11: smprintf(s, "Setting FM station status OK\n"); break; 3921 case 0x11: smprintf(s, "Setting FM station status OK\n"); break;
3912 case 0x12: smprintf(s, "Setting FM station OK\n"); break; 3922 case 0x12: smprintf(s, "Setting FM station OK\n"); break;
3913 } 3923 }
3914#endif 3924#endif
3915 return ERR_NONE; 3925 return ERR_NONE;
3916} 3926}
3917 3927
3918static GSM_Error N6510_ClearFMStations (GSM_StateMachine *s) 3928static GSM_Error N6510_ClearFMStations (GSM_StateMachine *s)
3919{ 3929{
3920 unsigned char req[7] = {N6110_FRAME_HEADER, 0x03,0x0f,0x00,0x01}; 3930 unsigned char req[7] = {N6110_FRAME_HEADER, 0x03,0x0f,0x00,0x01};
3921 3931
3922 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED; 3932 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED;
3923 3933
3924 smprintf(s, "Cleaning FM Stations\n"); 3934 smprintf(s, "Cleaning FM Stations\n");
3925 return GSM_WaitFor (s, req, 7, 0x3E, 2, ID_SetFMStation); 3935 return GSM_WaitFor (s, req, 7, 0x3E, 2, ID_SetFMStation);
3926} 3936}
3927 3937
3928static GSM_Error N6510_SetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStation) 3938static GSM_Error N6510_SetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStation)
3929{ 3939{
3930 unsigned int len, location; 3940 unsigned int len, location;
3931 GSM_Error error; 3941 GSM_Error error;
3932 unsigned char setstatus[36] = {N6110_FRAME_HEADER,0x11,0x00,0x01,0x01, 3942 unsigned char setstatus[36] = {N6110_FRAME_HEADER,0x11,0x00,0x01,0x01,
3933 0x00,0x00,0x1c,0x00,0x14,0x00,0x00, 3943 0x00,0x00,0x1c,0x00,0x14,0x00,0x00,
3934 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 3944 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
3935 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 3945 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
3936 0xff,0xff,0xff,0xff,0xff,0x01}; 3946 0xff,0xff,0xff,0xff,0xff,0x01};
3937 unsigned char req[64] = {N6110_FRAME_HEADER, 0x12,0x00,0x01,0x00, 3947 unsigned char req[64] = {N6110_FRAME_HEADER, 0x12,0x00,0x01,0x00,
3938 0x00, // 0x0e + (strlen(name) * 2) 3948 0x00, // 0x0e + (strlen(name) * 2)
3939 0x00, // strlen(name) 3949 0x00, // strlen(name)
3940 0x14,0x09,0x00, 3950 0x14,0x09,0x00,
3941 0x00, // location 3951 0x00, // location
3942 0x00,0x00,0x01, 3952 0x00,0x00,0x01,
3943 0x00, // freqHi 3953 0x00, // freqHi
3944 0x00, // freqLo 3954 0x00, // freqLo
3945 0x01}; 3955 0x01};
3946 3956
3947 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED; 3957 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_RADIO)) return ERR_NOTSUPPORTED;
3948 3958
3949 s->Phone.Data.FMStation = FMStation; 3959 s->Phone.Data.FMStation = FMStation;
3950 location = FMStation->Location-1; 3960 location = FMStation->Location-1;
3951 3961
3952 error = N6510_GetFMStatus(s); 3962 error = N6510_GetFMStatus(s);
3953 if (error != ERR_NONE) return error; 3963 if (error != ERR_NONE) return error;
3954 3964
3955 memcpy(setstatus+14,s->Phone.Data.Priv.N6510.FMStatus+14,20); 3965 memcpy(setstatus+14,s->Phone.Data.Priv.N6510.FMStatus+14,20);
3956 setstatus [14+location] = location; 3966 setstatus [14+location] = location;
3957 3967
3958 smprintf(s, "Setting FM status %i\n",FMStation->Location); 3968 smprintf(s, "Setting FM status %i\n",FMStation->Location);
3959 error = GSM_WaitFor (s, setstatus, 36 , 0x3E, 2, ID_SetFMStation); 3969 error = GSM_WaitFor (s, setstatus, 36 , 0x3E, 2, ID_SetFMStation);
3960 if (error != ERR_NONE) return error; 3970 if (error != ERR_NONE) return error;
3961 3971
3962 req[12] = location; 3972 req[12] = location;
3963 3973
3964 /* Name */ 3974 /* Name */
3965 len = UnicodeLength(FMStation->StationName); 3975 len = UnicodeLength(FMStation->StationName);
3966 req[8] = len; 3976 req[8] = len;
3967 req[7] = 0x0e + len * 2; 3977 req[7] = 0x0e + len * 2;
3968 memcpy (req+18,FMStation->StationName,len*2); 3978 memcpy (req+18,FMStation->StationName,len*2);
3969 3979
3970 /* Frequency */ 3980 /* Frequency */
3971 N6510_EncodeFMFrequency(FMStation->Frequency, req+16); 3981 N6510_EncodeFMFrequency(FMStation->Frequency, req+16);
3972 3982
3973 smprintf(s, "Setting FM Station %i\n",FMStation->Location); 3983 smprintf(s, "Setting FM Station %i\n",FMStation->Location);
3974 return GSM_WaitFor (s, req, 0x13+len*2, 0x3E, 2, ID_SetFMStation); 3984 return GSM_WaitFor (s, req, 0x13+len*2, 0x3E, 2, ID_SetFMStation);
3975} 3985}
3976 3986
3977static GSM_Error N6510_ReplySetLight(GSM_Protocol_Message msg, GSM_StateMachine *s) 3987static GSM_Error N6510_ReplySetLight(GSM_Protocol_Message msg, GSM_StateMachine *s)
3978{ 3988{
3979 smprintf(s, "Light set\n"); 3989 smprintf(s, "Light set\n");
3980 return ERR_NONE; 3990 return ERR_NONE;
3981} 3991}
3982 3992
3983GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable) 3993GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable)
3984{ 3994{
3985 unsigned char req[14] = { 3995 unsigned char req[14] = {
3986 N6110_FRAME_HEADER, 0x05, 3996 N6110_FRAME_HEADER, 0x05,
3987 0x01, /* 0x01 = Display, 0x03 = keypad */ 3997 0x01, /* 0x01 = Display, 0x03 = keypad */
3988 0x01, /* 0x01 = Enable, 0x02 = disable */ 3998 0x01, /* 0x01 = Enable, 0x02 = disable */
3989 0x00, 0x00, 0x00, 0x01, 3999 0x00, 0x00, 0x00, 0x01,
3990 0x05, 0x04, 0x02, 0x00}; 4000 0x05, 0x04, 0x02, 0x00};
3991 4001
3992 req[4] = light; 4002 req[4] = light;
3993 if (!enable) req[5] = 0x02; 4003 if (!enable) req[5] = 0x02;
3994 smprintf(s, "Setting light\n"); 4004 smprintf(s, "Setting light\n");
3995 return GSM_WaitFor (s, req, 14, 0x3A, 4, ID_SetLight); 4005 return GSM_WaitFor (s, req, 14, 0x3A, 4, ID_SetLight);
3996} 4006}
3997 4007
3998static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable) 4008static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable)
3999{ 4009{
4000 GSM_Error error; 4010 GSM_Error error;
4001 4011
4002 if (enable) { 4012 if (enable) {
4003 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,true); 4013 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,true);
4004 if (error != ERR_NONE) return error; 4014 if (error != ERR_NONE) return error;
4005 4015
4006 error=N6510_SetLight(s,N6510_LIGHT_TORCH,true); 4016 error=N6510_SetLight(s,N6510_LIGHT_TORCH,true);
4007 if (error != ERR_NONE) return error; 4017 if (error != ERR_NONE) return error;
4008 4018
4009 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true); 4019 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true);
4010 } else { 4020 } else {
4011 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false); 4021 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false);
4012 if (error != ERR_NONE) return error; 4022 if (error != ERR_NONE) return error;
4013 4023
4014 error=N6510_SetLight(s,N6510_LIGHT_TORCH,false); 4024 error=N6510_SetLight(s,N6510_LIGHT_TORCH,false);
4015 if (error != ERR_NONE) return error; 4025 if (error != ERR_NONE) return error;
4016 4026
4017 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false); 4027 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false);
4018 } 4028 }
4019} 4029}
4020 4030
4021static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 4031static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
4022{ 4032{
4023 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote); 4033 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote);
4024} 4034}
4025 4035
4026static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s) 4036static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
4027{ 4037{
4028 smprintf(s, "Note received\n"); 4038 smprintf(s, "Note received\n");
4029 memcpy(s->Phone.Data.Note->Text,msg.Buffer+54,(msg.Buffer[50]*256+msg.Buffer[51])*2); 4039 memcpy(s->Phone.Data.Note->Text,msg.Buffer+54,(msg.Buffer[50]*256+msg.Buffer[51])*2);
4030 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2] = 0; 4040 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2] = 0;
4031 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0; 4041 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0;
4032 return ERR_NONE; 4042 return ERR_NONE;
4033} 4043}
4034 4044
4035GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start) 4045GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start)
4036{ 4046{
4037 GSM_Error error; 4047 GSM_Error error;
4038 GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote; 4048 GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4039 4049
4040 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED; 4050 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
4041 4051
4042 if (start) { 4052 if (start) {
4043 error=N6510_GetCalendarInfo3(s,LastNote,2); 4053 error=N6510_GetCalendarInfo3(s,LastNote,2);
4044 if (error!=ERR_NONE) return error; 4054 if (error!=ERR_NONE) return error;
4045 Note->Location = 1; 4055 Note->Location = 1;
4046 } else { 4056 } else {
4047 Note->Location++; 4057 Note->Location++;
4048 } 4058 }
4049 4059
4050 if (Note->Location > LastNote->Number) return ERR_EMPTY; 4060 if (Note->Location > LastNote->Number) return ERR_EMPTY;
4051 4061
4052 s->Phone.Data.Note = Note; 4062 s->Phone.Data.Note = Note;
4053 smprintf(s, "Getting note\n"); 4063 smprintf(s, "Getting note\n");
4054 return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote); 4064 return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote);
4055} 4065}
4056 4066
4067static GSM_Error N6510_DeleteNote(GSM_StateMachine *s, GSM_NoteEntry *Not)
4068{
4069 GSM_Error error;
4070 GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4071 GSM_CalendarEntry Note;
4072
4073 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
4074
4075 error=N6510_GetCalendarInfo3(s,LastNote,2);
4076 if (error!=ERR_NONE) return error;
4077
4078 smprintf(s, "Deleting Note\n");
4079
4080 if (Not->Location > LastNote->Number || Not->Location == 0) return ERR_INVALIDLOCATION;
4081
4082 Note.Location = LastNote->Location[Not->Location-1];
4083 return N71_65_DelCalendar(s,&Note);
4084}
4085
4086static GSM_Error N6510_ReplyGetNoteFirstLoc(GSM_Protocol_Message msg, GSM_StateMachine *s)
4087{
4088 smprintf(s, "First Note location: %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
4089 s->Phone.Data.Note->Location = msg.Buffer[8]*256+msg.Buffer[9];
4090 return ERR_NONE;
4091}
4092
4093static GSM_Error N6510_ReplyAddNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
4094{
4095 smprintf(s, "ToDo added\n");
4096 return ERR_NONE;
4097}
4098
4099static GSM_Error N6510_AddNote(GSM_StateMachine *s, GSM_NoteEntry *Not)
4100{
4101 GSM_Error error;
4102 int count=54;
4103 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95,
4104 0x02};/* 1 = todo, 2 = note */
4105 unsigned char req[5000] = {
4106 N6110_FRAME_HEADER, 0x65,
4107 0x02, /* 0 = calendar, 1 = todo, 2 = note */
4108 0x00, 0x00, 0x00,
4109 0x00, 0x00, /* location */
4110 0x00, 0x00, 0x00, 0x00,
4111 0xFF, 0xFF, 0xFF, 0xFF, /* alarm */
4112 0x80, 0x00, 0x00,
4113 0xA9, /* note icon */
4114 0x00, 0x00, 0x00, 0x00, /* alarm type */
4115 0x00, /* 0x02 or 0x00 */
4116 0x80, /* note type */
4117 0x07, 0xD2, 0x01, 0x01, 0x00, 0x00, /* start date/time */
4118 0x07, 0xD2, 0x01, 0x11, 0x00, 0x00, /* end date/time */
4119 0x00, 0x00, /* recurrance */
4120 0xFF, 0xFF, /* birth year */
4121 0x00, /* ToDo priority */
4122 0x00, /* ToDo completed ? */
4123 0x00, 0x00, 0x00,
4124 0x00, /* note text length */
4125 0x00, /* phone length/meeting place */
4126 0x00, 0x00, 0x00};
4127
4128 s->Phone.Data.Note = Not;
4129
4130 smprintf(s, "Getting first free Note location\n");
4131 error = GSM_WaitFor (s, reqLoc, 5, 0x13, 4, ID_SetNote);
4132 if (error!=ERR_NONE) return error;
4133 req[8] = Not->Location/256;
4134 req[9] = Not->Location%256;
4135
4136 req[49] = UnicodeLength(Not->Text);
4137 CopyUnicodeString(req+54,Not->Text);
4138 count+= req[49]*2;
4139
4140 req[count++] = 0x00;
4141
4142 smprintf(s, "Adding Note\n");
4143 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetNote);
4144}
4145
4146static GSM_Error N6510_GetNoteStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
4147{
4148 GSM_NOKIACalToDoLocations*LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4149 GSM_Error error;
4150
4151 error = N6510_GetCalendarInfo3(s,LastNote,2);
4152 if (error!=ERR_NONE) return error;
4153
4154 status->Used = LastNote->Number;
4155 return ERR_NONE;
4156}
4157
4057static int N6510_FindFileCheckSum(unsigned char *ptr, int len) 4158static int N6510_FindFileCheckSum(unsigned char *ptr, int len)
4058{ 4159{
4059 int acc, i, accx; 4160 int acc, i, accx;
4060 4161
4061 accx = 0; 4162 accx = 0;
4062 acc = 0xffff; 4163 acc = 0xffff;
4063 while (len--) { 4164 while (len--) {
4064 accx = (accx & 0xffff00ff) | (acc & 0xff00); 4165 accx = (accx & 0xffff00ff) | (acc & 0xff00);
4065 acc = (acc & 0xffff00ff) | *ptr++ << 8; 4166 acc = (acc & 0xffff00ff) | *ptr++ << 8;
4066 for (i = 0; i < 8; i++) { 4167 for (i = 0; i < 8; i++) {
4067 acc <<= 1; 4168 acc <<= 1;
4068 if (acc & 0x10000) acc ^= 0x1021; 4169 if (acc & 0x10000) acc ^= 0x1021;
4069 if (accx & 0x80000000) acc ^= 0x1021; 4170 if (accx & 0x80000000) acc ^= 0x1021;
4070 accx <<= 1; 4171 accx <<= 1;
4071 } 4172 }
4072 } 4173 }
4073 dbgprintf("Checksum from Gammu is %04X\n",(acc & 0xffff)); 4174 dbgprintf("Checksum from Gammu is %04X\n",(acc & 0xffff));
4074 return (acc & 0xffff); 4175 return (acc & 0xffff);
4075} 4176}
4076 4177
4077static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 4178static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
4078{ 4179{
4079 GSM_File *File = s->Phone.Data.FileInfo; 4180 GSM_File *File = s->Phone.Data.FileInfo;
4080 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 4181 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
4081 int i; 4182 int i;
4082 4183
4083 switch (msg.Buffer[3]) { 4184 switch (msg.Buffer[3]) {
4084 case 0x15: 4185 case 0x15:
4085 smprintf(s,"File or folder details received\n"); 4186 smprintf(s,"File or folder details received\n");
4086 CopyUnicodeString(File->Name,msg.Buffer+10); 4187 CopyUnicodeString(File->Name,msg.Buffer+10);
4087 if (!strncmp(DecodeUnicodeString(File->Name),"GMSTemp",7)) return ERR_EMPTY; 4188 if (!strncmp(DecodeUnicodeString(File->Name),"GMSTemp",7)) return ERR_EMPTY;
4088 if (File->Name[0] == 0x00 && File->Name[1] == 0x00) return ERR_UNKNOWN; 4189 if (File->Name[0] == 0x00 && File->Name[1] == 0x00) return ERR_UNKNOWN;
4089 4190
4090 i = msg.Buffer[8]*256+msg.Buffer[9]; 4191 i = msg.Buffer[8]*256+msg.Buffer[9];
4091 dbgprintf("%02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 4192 dbgprintf("%02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
4092 msg.Buffer[i-5],msg.Buffer[i-4],msg.Buffer[i-3], 4193 msg.Buffer[i-5],msg.Buffer[i-4],msg.Buffer[i-3],
4093 msg.Buffer[i-2],msg.Buffer[i-1],msg.Buffer[i], 4194 msg.Buffer[i-2],msg.Buffer[i-1],msg.Buffer[i],
4094 msg.Buffer[i+1],msg.Buffer[i+2],msg.Buffer[i+3]); 4195 msg.Buffer[i+1],msg.Buffer[i+2],msg.Buffer[i+3]);
4095 4196
4096 File->Folder = false; 4197 File->Folder = false;
4097 if (msg.Buffer[i-5] == 0x00) File->Folder = true; 4198 if (msg.Buffer[i-5] == 0x00) File->Folder = true;
4098 4199
4099 File->ReadOnly = false; 4200 File->ReadOnly = false;
4100 File->Protected = false; 4201 File->Protected = false;
4101 File->System= false; 4202 File->System= false;
4102 File->Hidden= false; 4203 File->Hidden= false;
4103 if (msg.Buffer[i+2] == 0x01) File->Protected = true; 4204 if (msg.Buffer[i+2] == 0x01) File->Protected = true;
4104 if (msg.Buffer[i+4] == 0x01) File->ReadOnly = true; 4205 if (msg.Buffer[i+4] == 0x01) File->ReadOnly = true;
4105 if (msg.Buffer[i+5] == 0x01) File->Hidden= true; 4206 if (msg.Buffer[i+5] == 0x01) File->Hidden= true;
4106 if (msg.Buffer[i+6] == 0x01) File->System= true;//fixme 4207 if (msg.Buffer[i+6] == 0x01) File->System= true;//fixme
4107 4208
4108 File->ModifiedEmpty = false; 4209 File->ModifiedEmpty = false;
4109 NOKIA_DecodeDateTime(s, msg.Buffer+i-22, &File->Modified); 4210 NOKIA_DecodeDateTime(s, msg.Buffer+i-22, &File->Modified);
4110 if (File->Modified.Year == 0x00) File->ModifiedEmpty = true; 4211 if (File->Modified.Year == 0x00) File->ModifiedEmpty = true;
4111 dbgprintf("%02x %02x %02x %02x\n",msg.Buffer[i-22],msg.Buffer[i-21],msg.Buffer[i-20],msg.Buffer[i-19]); 4212 dbgprintf("%02x %02x %02x %02x\n",msg.Buffer[i-22],msg.Buffer[i-21],msg.Buffer[i-20],msg.Buffer[i-19]);
4112 4213
4113 Priv->FileToken = msg.Buffer[i-10]*256+msg.Buffer[i-9]; 4214 Priv->FileToken = msg.Buffer[i-10]*256+msg.Buffer[i-9];
4114 Priv->ParentID = msg.Buffer[i]*256+msg.Buffer[i+1]; 4215 Priv->ParentID = msg.Buffer[i]*256+msg.Buffer[i+1];
4115 smprintf(s,"ParentID is %i\n",Priv->ParentID); 4216 smprintf(s,"ParentID is %i\n",Priv->ParentID);
4116 4217
4117 File->Type = GSM_File_Other; 4218 File->Type = GSM_File_Other;
4118 if (msg.Length > 240){ 4219 if (msg.Length > 240){
4119 i = 227; 4220 i = 227;
4120 if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x01) 4221 if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x01)
4121 File->Type = GSM_File_Image_JPG; 4222 File->Type = GSM_File_Image_JPG;
4122 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x02) 4223 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x02)
4123 File->Type = GSM_File_Image_BMP; 4224 File->Type = GSM_File_Image_BMP;
4124 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x07) 4225 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x07)
4125 File->Type = GSM_File_Image_BMP; 4226 File->Type = GSM_File_Image_BMP;
4126 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x03) 4227 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x03)
4127 File->Type = GSM_File_Image_PNG; 4228 File->Type = GSM_File_Image_PNG;
4128 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05) 4229 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05)
4129 File->Type = GSM_File_Image_GIF; 4230 File->Type = GSM_File_Image_GIF;
4130 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09) 4231 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09)
4131 File->Type = GSM_File_Image_WBMP; 4232 File->Type = GSM_File_Image_WBMP;
4132 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01) 4233 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01)
4133 File->Type = GSM_File_Sound_AMR; 4234 File->Type = GSM_File_Sound_AMR;
4134 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02) 4235 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02)
4135 File->Type = GSM_File_Sound_MIDI; 4236 File->Type = GSM_File_Sound_MIDI;
4136 else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05) 4237 else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05)
4137 File->Type = GSM_File_Video_3GP; 4238 File->Type = GSM_File_Video_3GP;
4138 else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01) 4239 else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01)
4139 File->Type = GSM_File_Java_JAR; 4240 File->Type = GSM_File_Java_JAR;
4140#ifdef DEVELOP 4241#ifdef DEVELOP
4141 else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01) 4242 else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01)
4142 File->Type = GSM_File_MMS; 4243 File->Type = GSM_File_MMS;
4143#endif 4244#endif
4144 } 4245 }
4145 return ERR_NONE; 4246 return ERR_NONE;
4146 case 0x2F: 4247 case 0x2F:
4147 smprintf(s,"File or folder used bytes received\n"); 4248 smprintf(s,"File or folder used bytes received\n");
4148 File->Used = msg.Buffer[6]*256*256*256+ 4249 File->Used = msg.Buffer[6]*256*256*256+
4149 msg.Buffer[7]*256*256+ 4250 msg.Buffer[7]*256*256+
4150 msg.Buffer[8]*256+ 4251 msg.Buffer[8]*256+
4151 msg.Buffer[9]; 4252 msg.Buffer[9];
4152 return ERR_NONE; 4253 return ERR_NONE;
4153 case 0x33: 4254 case 0x33:
4154 if (s->Phone.Data.RequestID == ID_GetFileInfo) { 4255 if (s->Phone.Data.RequestID == ID_GetFileInfo) {
4155 i = Priv->FilesLocationsUsed-1; 4256 i = Priv->FilesLocationsUsed-1;
4156 while (1) { 4257 while (1) {
4157 if (i==Priv->FilesLocationsCurrent-1) break; 4258 if (i==Priv->FilesLocationsCurrent-1) break;
4158 dbgprintf("Copying %i to %i, max %i, current %i\n", 4259 dbgprintf("Copying %i to %i, max %i, current %i\n",
4159 i,i+msg.Buffer[9], 4260 i,i+msg.Buffer[9],
4160 Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent); 4261 Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent);
4161 Priv->FilesLocations[i+msg.Buffer[9]] = Priv->FilesLocations[i]; 4262 Priv->FilesLocations[i+msg.Buffer[9]] = Priv->FilesLocations[i];
4162 Priv->FilesLevels[i+msg.Buffer[9]]= Priv->FilesLevels[i]; 4263 Priv->FilesLevels[i+msg.Buffer[9]]= Priv->FilesLevels[i];
4163 i--; 4264 i--;
4164 } 4265 }
4165 Priv->FilesLocationsUsed += msg.Buffer[9]; 4266 Priv->FilesLocationsUsed += msg.Buffer[9];
4166 for (i=0;i<msg.Buffer[9];i++) { 4267 for (i=0;i<msg.Buffer[9];i++) {
4167 Priv->FilesLocations[Priv->FilesLocationsCurrent+i] = msg.Buffer[13+i*4-1]*256 + msg.Buffer[13+i*4]; 4268 Priv->FilesLocations[Priv->FilesLocationsCurrent+i] = msg.Buffer[13+i*4-1]*256 + msg.Buffer[13+i*4];
4168 Priv->FilesLevels[Priv->FilesLocationsCurrent+i] = File->Level+1; 4269 Priv->FilesLevels[Priv->FilesLocationsCurrent+i] = File->Level+1;
4169 dbgprintf("%i ",Priv->FilesLocations[Priv->FilesLocationsCurrent+i]); 4270 dbgprintf("%i ",Priv->FilesLocations[Priv->FilesLocationsCurrent+i]);
4170 } 4271 }
4171 dbgprintf("\n"); 4272 dbgprintf("\n");
4172 } 4273 }
4173 if (msg.Buffer[9] != 0x00) File->Folder = true; 4274 if (msg.Buffer[9] != 0x00) File->Folder = true;
4174 return ERR_NONE; 4275 return ERR_NONE;
4175 case 0x43: 4276 case 0x43:
4176 Priv->FileCheckSum = msg.Buffer[6] * 256 + msg.Buffer[7]; 4277 Priv->FileCheckSum = msg.Buffer[6] * 256 + msg.Buffer[7];
4177 smprintf(s,"File checksum from phone is %04X\n",Priv->FileCheckSum); 4278 smprintf(s,"File checksum from phone is %04X\n",Priv->FileCheckSum);
4178 return ERR_NONE; 4279 return ERR_NONE;
4179 } 4280 }
4180 return ERR_UNKNOWNRESPONSE; 4281 return ERR_UNKNOWNRESPONSE;
4181} 4282}
4182 4283
4183static GSM_Error N6510_GetFileFolderInfo(GSM_StateMachine *s, GSM_File *File, GSM_Phone_RequestID Request) 4284static GSM_Error N6510_GetFileFolderInfo(GSM_StateMachine *s, GSM_File *File, GSM_Phone_RequestID Request)
4184{ 4285{
4185 GSM_Error error; 4286 GSM_Error error;
4186 unsigned char req[10] = { 4287 unsigned char req[10] = {
4187 N7110_FRAME_HEADER, 4288 N7110_FRAME_HEADER,
4188 0x14, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */ 4289 0x14, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */
4189 0x01, /* 0x00 for sublocations reverse sorting, 0x01 for free */ 4290 0x01, /* 0x00 for sublocations reverse sorting, 0x01 for free */
4190 0x00, 0x00, 0x01, 4291 0x00, 0x00, 0x01,
4191 0x00, 0x01};/* Folder or file number */ 4292 0x00, 0x01};/* Folder or file number */
4192 unsigned char GetCRC[] = { 4293 unsigned char GetCRC[] = {
4193 N7110_FRAME_HEADER, 0x42, 0x00, 0x00, 0x00, 0x01, 4294 N7110_FRAME_HEADER, 0x42, 0x00, 0x00, 0x00, 0x01,
4194 0x00, 0x1E}; /* file ID */ 4295 0x00, 0x1E}; /* file ID */
4195 4296
4196 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; 4297 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
4197 4298
4198 s->Phone.Data.FileInfo = File; 4299 s->Phone.Data.FileInfo = File;
4199 req[8] = atoi(File->ID_FullName) / 256; 4300 req[8] = atoi(File->ID_FullName) / 256;
4200 req[9] = atoi(File->ID_FullName) % 256; 4301 req[9] = atoi(File->ID_FullName) % 256;
4201 4302
4202 req[3] = 0x14; 4303 req[3] = 0x14;
4203 req[4] = 0x01; 4304 req[4] = 0x01;
4204 smprintf(s,"Getting info for file in filesystem\n"); 4305 smprintf(s,"Getting info for file in filesystem\n");
4205 error=GSM_WaitFor (s, req, 10, 0x6D, 4, Request); 4306 error=GSM_WaitFor (s, req, 10, 0x6D, 4, Request);
4206 if (error != ERR_NONE) return error; 4307 if (error != ERR_NONE) return error;
4207 4308
4208 if (Request != ID_AddFile) { 4309 if (Request != ID_AddFile) {
4209 req[3] = 0x32; 4310 req[3] = 0x32;
4210 req[4] = 0x00; 4311 req[4] = 0x00;
4211 smprintf(s,"Getting subfolders for filesystem\n"); 4312 smprintf(s,"Getting subfolders for filesystem\n");
4212 error=GSM_WaitFor (s, req, 10, 0x6D, 4, Request); 4313 error=GSM_WaitFor (s, req, 10, 0x6D, 4, Request);
4213 if (error != ERR_NONE) return error; 4314 if (error != ERR_NONE) return error;
4214 4315
4215 if (!File->Folder) { 4316 if (!File->Folder) {
4216 req[3] = 0x2E; 4317 req[3] = 0x2E;
4217 req[4] = 0x01; 4318 req[4] = 0x01;
4218 smprintf(s,"Getting used memory for file in filesystem\n"); 4319 smprintf(s,"Getting used memory for file in filesystem\n");
4219 error=GSM_WaitFor (s, req, 10, 0x6D, 4, Request); 4320 error=GSM_WaitFor (s, req, 10, 0x6D, 4, Request);
4220 if (error != ERR_NONE) return error; 4321 if (error != ERR_NONE) return error;
4221 4322
4222 GetCRC[8] = atoi(File->ID_FullName) / 256; 4323 GetCRC[8] = atoi(File->ID_FullName) / 256;
4223 GetCRC[9] = atoi(File->ID_FullName) % 256; 4324 GetCRC[9] = atoi(File->ID_FullName) % 256;
4224 smprintf(s,"Getting CRC for file in filesystem\n"); 4325 smprintf(s,"Getting CRC for file in filesystem\n");
4225 error=GSM_WaitFor (s, GetCRC, 10, 0x6D, 4, Request); 4326 error=GSM_WaitFor (s, GetCRC, 10, 0x6D, 4, Request);
4226 } 4327 }
4227 } 4328 }
4228 return error; 4329 return error;
4229} 4330}
4230 4331
4231static GSM_Error N6510_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, bool start) 4332static GSM_Error N6510_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, bool start)
4232{ 4333{
4233 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 4334 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
4234 GSM_Error error; 4335 GSM_Error error;
4235 4336
4236 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; 4337 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
4237 4338
4238 if (start) { 4339 if (start) {
4239 Priv->FilesLocationsUsed = 1; 4340 Priv->FilesLocationsUsed = 1;
4240 Priv->FilesLocationsCurrent = 0; 4341 Priv->FilesLocationsCurrent = 0;
4241 Priv->FilesLocations[0] = 0x01; 4342 Priv->FilesLocations[0] = 0x01;
4242 Priv->FilesLevels[0] = 1; 4343 Priv->FilesLevels[0] = 1;
4243 } 4344 }
4244 4345
4245 while (1) { 4346 while (1) {
4246 if (Priv->FilesLocationsCurrent == Priv->FilesLocationsUsed) return ERR_EMPTY; 4347 if (Priv->FilesLocationsCurrent == Priv->FilesLocationsUsed) return ERR_EMPTY;
4247 4348
4248 sprintf(File->ID_FullName,"%i",Priv->FilesLocations[Priv->FilesLocationsCurrent]); 4349 sprintf(File->ID_FullName,"%i",Priv->FilesLocations[Priv->FilesLocationsCurrent]);
4249 File->Level= Priv->FilesLevels[Priv->FilesLocationsCurrent]; 4350 File->Level= Priv->FilesLevels[Priv->FilesLocationsCurrent];
4250 Priv->FilesLocationsCurrent++; 4351 Priv->FilesLocationsCurrent++;
4251 4352
4252 error = N6510_GetFileFolderInfo(s, File, ID_GetFileInfo); 4353 error = N6510_GetFileFolderInfo(s, File, ID_GetFileInfo);
4253 if (error == ERR_EMPTY) continue; 4354 if (error == ERR_EMPTY) continue;
4254 return error; 4355 return error;
4255 } 4356 }
4256} 4357}
4257 4358
4258static GSM_Error N6510_ReplyGetFileSystemStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) 4359static GSM_Error N6510_ReplyGetFileSystemStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
4259{ 4360{
4260 switch (msg.Buffer[3]) { 4361 switch (msg.Buffer[3]) {
4261 case 0x23: 4362 case 0x23:
4262 if (!strcmp(s->Phone.Data.ModelInfo->model,"6310i")) { 4363 if (!strcmp(s->Phone.Data.ModelInfo->model,"6310i")) {
4263 smprintf(s,"File or folder total bytes received\n"); 4364 smprintf(s,"File or folder total bytes received\n");
4264 s->Phone.Data.FileSystemStatus->Free = 4365 s->Phone.Data.FileSystemStatus->Free =
4265 3*256*256 + msg.Buffer[8]*256 + msg.Buffer[9] - 4366 3*256*256 + msg.Buffer[8]*256 + msg.Buffer[9] -
4266 s->Phone.Data.FileSystemStatus->Used; 4367 s->Phone.Data.FileSystemStatus->Used;
4267 } else { 4368 } else {
4268 smprintf(s,"File or folder free bytes received\n"); 4369 smprintf(s,"File or folder free bytes received\n");
4269 s->Phone.Data.FileSystemStatus->Free = 4370 s->Phone.Data.FileSystemStatus->Free =
4270 msg.Buffer[6]*256*256*256+ 4371 msg.Buffer[6]*256*256*256+
4271 msg.Buffer[7]*256*256+ 4372 msg.Buffer[7]*256*256+
4272 msg.Buffer[8]*256+ 4373 msg.Buffer[8]*256+
4273 msg.Buffer[9]; 4374 msg.Buffer[9];
4274 } 4375 }
4275 return ERR_NONE; 4376 return ERR_NONE;
4276 case 0x2F: 4377 case 0x2F:
4277 smprintf(s,"File or folder used bytes received\n"); 4378 smprintf(s,"File or folder used bytes received\n");
4278 s->Phone.Data.FileSystemStatus->Used = 4379 s->Phone.Data.FileSystemStatus->Used =
4279 msg.Buffer[6]*256*256*256+ 4380 msg.Buffer[6]*256*256*256+
4280 msg.Buffer[7]*256*256+ 4381 msg.Buffer[7]*256*256+
4281 msg.Buffer[8]*256+ 4382 msg.Buffer[8]*256+
4282 msg.Buffer[9]; 4383 msg.Buffer[9];
4283 return ERR_NONE; 4384 return ERR_NONE;
4284 } 4385 }
4285 return ERR_UNKNOWNRESPONSE; 4386 return ERR_UNKNOWNRESPONSE;
4286} 4387}
4287 4388
4288static GSM_Error N6510_GetFileSystemStatus(GSM_StateMachine *s, GSM_FileSystemStatus *status) 4389static GSM_Error N6510_GetFileSystemStatus(GSM_StateMachine *s, GSM_FileSystemStatus *status)
4289{ 4390{
4290 GSM_Error error; 4391 GSM_Error error;
4291 unsigned char req[10] = { 4392 unsigned char req[10] = {
4292 N7110_FRAME_HEADER, 4393 N7110_FRAME_HEADER,
4293 0x22, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */ 4394 0x22, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */
4294 0x01, /* 0x00 for sublocations reverse sorting, 0x01 for free */ 4395 0x01, /* 0x00 for sublocations reverse sorting, 0x01 for free */
4295 0x00, 0x00, 0x01, 4396 0x00, 0x00, 0x01,
4296 0x00, 0x01};/* Folder or file number */ 4397 0x00, 0x01};/* Folder or file number */
4297 4398
4298 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; 4399 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
4299 4400
4300 s->Phone.Data.FileSystemStatus = status; 4401 s->Phone.Data.FileSystemStatus = status;
4301 4402
4302 status->Free = 0; 4403 status->Free = 0;
4303 4404
4304 req[3] = 0x2E; 4405 req[3] = 0x2E;
4305 req[4] = 0x01; 4406 req[4] = 0x01;
4306 smprintf(s, "Getting used/total memory in filesystem\n"); 4407 smprintf(s, "Getting used/total memory in filesystem\n");
4307 error = GSM_WaitFor (s, req, 10, 0x6D, 4, ID_FileSystemStatus); 4408 error = GSM_WaitFor (s, req, 10, 0x6D, 4, ID_FileSystemStatus);
4308 4409
4309 req[3] = 0x22; 4410 req[3] = 0x22;
4310 req[4] = 0x01; 4411 req[4] = 0x01;
4311 smprintf(s, "Getting free memory in filesystem\n"); 4412 smprintf(s, "Getting free memory in filesystem\n");
4312 return GSM_WaitFor (s, req, 10, 0x6D, 4, ID_FileSystemStatus); 4413 return GSM_WaitFor (s, req, 10, 0x6D, 4, ID_FileSystemStatus);
4313} 4414}
4314 4415
4315static GSM_Error N6510_SearchForFileName(GSM_StateMachine *s, GSM_File *File) 4416static GSM_Error N6510_SearchForFileName(GSM_StateMachine *s, GSM_File *File)
4316{ 4417{
4317 GSM_File File2; 4418 GSM_File File2;
4318 GSM_Error error; 4419 GSM_Error error;
4319 int FilesLocations[1000],FilesLocations2[1000]; 4420 int FilesLocations[1000],FilesLocations2[1000];
4320 int FilesLevels[1000]; 4421 int FilesLevels[1000];
4321 int FilesLocationsUsed, FilesLocationsCurrent; 4422 int FilesLocationsUsed, FilesLocationsCurrent;
4322 int FilesLocationsUsed2, FilesLocationsCurrent2; 4423 int FilesLocationsUsed2, FilesLocationsCurrent2;
4323 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 4424 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
4324 4425
4325 memcpy(FilesLocations, Priv->FilesLocations,sizeof(FilesLocations)); 4426 memcpy(FilesLocations, Priv->FilesLocations,sizeof(FilesLocations));
4326 memcpy(FilesLevels, Priv->FilesLevels,sizeof(FilesLevels)); 4427 memcpy(FilesLevels, Priv->FilesLevels,sizeof(FilesLevels));
4327 FilesLocationsUsed = Priv->FilesLocationsUsed; 4428 FilesLocationsUsed = Priv->FilesLocationsUsed;
4328 FilesLocationsCurrent = Priv->FilesLocationsCurrent; 4429 FilesLocationsCurrent = Priv->FilesLocationsCurrent;
4329 4430
4330 Priv->FilesLocationsUsed = 1; 4431 Priv->FilesLocationsUsed = 1;
4331 Priv->FilesLocationsCurrent = 1; 4432 Priv->FilesLocationsCurrent = 1;
4332 Priv->FilesLocations[0] = atoi(File->ID_FullName); 4433 Priv->FilesLocations[0] = atoi(File->ID_FullName);
4333 Priv->FilesLevels[0] = 1; 4434 Priv->FilesLevels[0] = 1;
4334 4435
4335 strcpy(File2.ID_FullName,File->ID_FullName); 4436 strcpy(File2.ID_FullName,File->ID_FullName);
4336 error = N6510_GetFileFolderInfo(s, &File2, ID_GetFileInfo); 4437 error = N6510_GetFileFolderInfo(s, &File2, ID_GetFileInfo);
4337 memcpy(FilesLocations2, Priv->FilesLocations,sizeof(FilesLocations2)); 4438 memcpy(FilesLocations2, Priv->FilesLocations,sizeof(FilesLocations2));
4338 FilesLocationsUsed2 = Priv->FilesLocationsUsed; 4439 FilesLocationsUsed2 = Priv->FilesLocationsUsed;
4339 FilesLocationsCurrent2 = Priv->FilesLocationsCurrent; 4440 FilesLocationsCurrent2 = Priv->FilesLocationsCurrent;
4340 4441
4341 memcpy(Priv->FilesLocations, FilesLocations, sizeof(FilesLocations)); 4442 memcpy(Priv->FilesLocations, FilesLocations, sizeof(FilesLocations));
4342 memcpy(Priv->FilesLevels, FilesLevels, sizeof(FilesLevels)); 4443 memcpy(Priv->FilesLevels, FilesLevels, sizeof(FilesLevels));
4343 Priv->FilesLocationsUsed = FilesLocationsUsed; 4444 Priv->FilesLocationsUsed = FilesLocationsUsed;
4344 Priv->FilesLocationsCurrent = FilesLocationsCurrent; 4445 Priv->FilesLocationsCurrent = FilesLocationsCurrent;
4345 if (error != ERR_NONE) return error; 4446 if (error != ERR_NONE) return error;
4346 4447
4347 while (1) { 4448 while (1) {
4348 if (FilesLocationsCurrent2 == FilesLocationsUsed2) return ERR_EMPTY; 4449 if (FilesLocationsCurrent2 == FilesLocationsUsed2) return ERR_EMPTY;
4349 4450
4350 sprintf(File2.ID_FullName,"%i",FilesLocations2[FilesLocationsCurrent2]); 4451 sprintf(File2.ID_FullName,"%i",FilesLocations2[FilesLocationsCurrent2]);
4351 dbgprintf("Current is %i\n",FilesLocations2[FilesLocationsCurrent2]); 4452 dbgprintf("Current is %i\n",FilesLocations2[FilesLocationsCurrent2]);
4352 FilesLocationsCurrent2++; 4453 FilesLocationsCurrent2++;
4353 4454
4354 error = N6510_GetFileFolderInfo(s, &File2, ID_AddFile); 4455 error = N6510_GetFileFolderInfo(s, &File2, ID_AddFile);
4355 if (error == ERR_EMPTY) continue; 4456 if (error == ERR_EMPTY) continue;
4356 if (error != ERR_NONE) return error; 4457 if (error != ERR_NONE) return error;
4357 dbgprintf("%s %s\n",DecodeUnicodeString(File->Name),DecodeUnicodeString(File2.Name)); 4458 dbgprintf("%s %s\n",DecodeUnicodeString(File->Name),DecodeUnicodeString(File2.Name));
4358 if (mywstrncasecmp(File2.Name,File->Name,0)) return ERR_NONE; 4459 if (mywstrncasecmp(File2.Name,File->Name,0)) return ERR_NONE;
4359 } 4460 }
4360 return ERR_EMPTY; 4461 return ERR_EMPTY;
4361} 4462}
4362 4463
4363static GSM_Error N6510_ReplyGetFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s) 4464static GSM_Error N6510_ReplyGetFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s)
4364{ 4465{
4365 int old; 4466 int old;
4366 4467
4367 smprintf(s,"File part received\n"); 4468 smprintf(s,"File part received\n");
4368 old = s->Phone.Data.File->Used; 4469 old = s->Phone.Data.File->Used;
4369 s->Phone.Data.File->Used += msg.Buffer[6]*256*256*256+ 4470 s->Phone.Data.File->Used += msg.Buffer[6]*256*256*256+
4370 msg.Buffer[7]*256*256+ 4471 msg.Buffer[7]*256*256+
4371 msg.Buffer[8]*256+ 4472 msg.Buffer[8]*256+
4372 msg.Buffer[9]; 4473 msg.Buffer[9];
4373 smprintf(s,"Length of file part: %i\n", 4474 smprintf(s,"Length of file part: %i\n",
4374 msg.Buffer[6]*256*256*256+ 4475 msg.Buffer[6]*256*256*256+
4375 msg.Buffer[7]*256*256+ 4476 msg.Buffer[7]*256*256+
4376 msg.Buffer[8]*256+ 4477 msg.Buffer[8]*256+
4377 msg.Buffer[9]); 4478 msg.Buffer[9]);
4378 s->Phone.Data.File->Buffer = (unsigned char *)realloc(s->Phone.Data.File->Buffer,s->Phone.Data.File->Used); 4479 s->Phone.Data.File->Buffer = (unsigned char *)realloc(s->Phone.Data.File->Buffer,s->Phone.Data.File->Used);
4379 memcpy(s->Phone.Data.File->Buffer+old,msg.Buffer+10,s->Phone.Data.File->Used-old); 4480 memcpy(s->Phone.Data.File->Buffer+old,msg.Buffer+10,s->Phone.Data.File->Used-old);
4380 return ERR_NONE; 4481 return ERR_NONE;
4381} 4482}
4382 4483
4383static GSM_Error N6510_GetFilePart(GSM_StateMachine *s, GSM_File *File) 4484static GSM_Error N6510_GetFilePart(GSM_StateMachine *s, GSM_File *File)
4384{ 4485{
4385 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510; 4486 GSM_Phone_N6510Data*Priv = &s->Phone.Data.Priv.N6510;
4386 int old; 4487 int old;
4387 GSM_Error error; 4488 GSM_Error error;
4388 unsigned char req[] = { 4489 unsigned char req[] = {
4389 N7110_FRAME_HEADER, 0x0E, 0x00, 0x00, 0x00, 0x01, 4490 N7110_FRAME_HEADER, 0x0E, 0x00, 0x00, 0x00, 0x01,
4390 0x00, 0x01, /* Folder or file number */ 4491 0x00, 0x01, /* Folder or file number */
4391 0x00, 0x00, 0x00, 0x00,/* Start from xxx byte */ 4492 0x00, 0x00, 0x00, 0x00,/* Start from xxx byte */
4392 0x00, 0x00, 4493 0x00, 0x00,
4393 0x03, 0xE8}; /* Read xxx bytes */ 4494 0x03, 0xE8}; /* Read xxx bytes */
4394 4495
4395 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; 4496 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
4396 4497
4397 if (File->Used == 0x00) { 4498 if (File->Used == 0x00) {
4398 error = N6510_GetFileFolderInfo(s, File, ID_GetFile); 4499 error = N6510_GetFileFolderInfo(s, File, ID_GetFile);
4399 if (error != ERR_NONE) return error; 4500 if (error != ERR_NONE) return error;
4400 File->Used = 0; 4501 File->Used = 0;
4401 } 4502 }
4402 4503
4403 old = File->Used; 4504 old = File->Used;
4404 req[8] = atoi(File->ID_FullName) / 256; 4505 req[8] = atoi(File->ID_FullName) / 256;
4405 req[9] = atoi(File->ID_FullName) % 256; 4506 req[9] = atoi(File->ID_FullName) % 256;
4406 req[10] = old / (256*256*256); 4507 req[10] = old / (256*256*256);
4407 req[11] = old / (256*256); 4508 req[11] = old / (256*256);
4408 req[12] = old / 256; 4509 req[12] = old / 256;
4409 req[13] = old % 256; 4510 req[13] = old % 256;
4410 4511
4411 s->Phone.Data.File = File; 4512 s->Phone.Data.File = File;
4412 smprintf(s, "Getting file part from filesystem\n"); 4513 smprintf(s, "Getting file part from filesystem\n");
4413 error=GSM_WaitFor (s, req, 18, 0x6D, 4, ID_GetFile); 4514 error=GSM_WaitFor (s, req, 18, 0x6D, 4, ID_GetFile);
4414 if (error != ERR_NONE) return error; 4515 if (error != ERR_NONE) return error;
4415 if (File->Used - old != (0x03 * 256 + 0xE8)) { 4516 if (File->Used - old != (0x03 * 256 + 0xE8)) {
4416 if (N6510_FindFileCheckSum(File->Buffer, File->Used) != Priv->FileCheckSum) { 4517 if (N6510_FindFileCheckSum(File->Buffer, File->Used) != Priv->FileCheckSum) {
4417 smprintf(s,"File2 checksum is %i, File checksum is %i\n",N6510_FindFileCheckSum(File->Buffer, File->Used),Priv->FileCheckSum); 4518 smprintf(s,"File2 checksum is %i, File checksum is %i\n",N6510_FindFileCheckSum(File->Buffer, File->Used),Priv->FileCheckSum);
4418 return ERR_WRONGCRC; 4519 return ERR_WRONGCRC;
4419 } 4520 }
4420 return ERR_EMPTY; 4521 return ERR_EMPTY;
4421 } 4522 }
4422 return ERR_NONE; 4523 return ERR_NONE;
4423} 4524}
4424 4525
4425static GSM_Error N6510_SetReadOnly(GSM_StateMachine *s, unsigned char *ID, bool enable) 4526static GSM_Error N6510_SetReadOnly(GSM_StateMachine *s, unsigned char *ID, bool enable)
4426{ 4527{
4427 unsigned char SetAttr[] = { 4528 unsigned char SetAttr[] = {
4428 N7110_FRAME_HEADER, 0x18, 0x00, 0x00, 0x00, 0x01, 4529 N7110_FRAME_HEADER, 0x18, 0x00, 0x00, 0x00, 0x01,
4429 0x00, 0x20}; /* File ID */ 4530 0x00, 0x20}; /* File ID */
4430 4531
4431 if (!enable) SetAttr[4] = 0x06; 4532 if (!enable) SetAttr[4] = 0x06;
4432 4533
4433 SetAttr[8] = atoi(ID) / 256; 4534 SetAttr[8] = atoi(ID) / 256;
4434 SetAttr[9] = atoi(ID) % 256; 4535 SetAttr[9] = atoi(ID) % 256;
4435 smprintf(s, "Setting readonly attribute\n"); 4536 smprintf(s, "Setting readonly attribute\n");
4436 return GSM_WaitFor (s, SetAttr, 10, 0x6D, 4, ID_DeleteFile); 4537 return GSM_WaitFor (s, SetAttr, 10, 0x6D, 4, ID_DeleteFile);
4437} 4538}
4438 4539
4439static GSM_Error N6510_ReplyAddFileHeader(GSM_Protocol_Message msg, GSM_StateMachine *s) 4540static GSM_Error N6510_ReplyAddFileHeader(GSM_Protocol_Message msg, GSM_StateMachine *s)
4440{ 4541{
@@ -4808,1057 +4909,1066 @@ static GSM_Error N6510_SetGPRSAccessPoint(GSM_StateMachine *s, GSM_GPRSAccessPoi
4808 if (point->Location > 5) return ERR_INVALIDLOCATION; 4909 if (point->Location > 5) return ERR_INVALIDLOCATION;
4809 4910
4810 s->Phone.Data.GPRSPoint = point; 4911 s->Phone.Data.GPRSPoint = point;
4811 4912
4812#ifdef DEVELOP 4913#ifdef DEVELOP
4813 error = N6510_EnableGPRSAccessPoint(s); 4914 error = N6510_EnableGPRSAccessPoint(s);
4814 if (error != ERR_NONE) return error; 4915 if (error != ERR_NONE) return error;
4815#endif 4916#endif
4816 4917
4817 smprintf(s, "Getting GPRS access point name\n"); 4918 smprintf(s, "Getting GPRS access point name\n");
4818 error=GSM_WaitFor (s, Name, 16, 0x43, 4, ID_SetGPRSPoint); 4919 error=GSM_WaitFor (s, Name, 16, 0x43, 4, ID_SetGPRSPoint);
4819 if (error != ERR_NONE) return error; 4920 if (error != ERR_NONE) return error;
4820 CopyUnicodeString(buff+18+(point->Location-1)*42,point->Name); 4921 CopyUnicodeString(buff+18+(point->Location-1)*42,point->Name);
4821 buff[0] = 0x00; 4922 buff[0] = 0x00;
4822 buff[1] = 0x01; 4923 buff[1] = 0x01;
4823 buff[2] = 0x01; 4924 buff[2] = 0x01;
4824 buff[3] = 0x07; 4925 buff[3] = 0x07;
4825 smprintf(s, "Setting GPRS access point name\n"); 4926 smprintf(s, "Setting GPRS access point name\n");
4826 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint); 4927 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint);
4827 if (error != ERR_NONE) return error; 4928 if (error != ERR_NONE) return error;
4828 4929
4829 smprintf(s, "Getting GPRS access point URL\n"); 4930 smprintf(s, "Getting GPRS access point URL\n");
4830 error=GSM_WaitFor (s, URL, 16, 0x43, 4, ID_SetGPRSPoint); 4931 error=GSM_WaitFor (s, URL, 16, 0x43, 4, ID_SetGPRSPoint);
4831 if (error != ERR_NONE) return error; 4932 if (error != ERR_NONE) return error;
4832 CopyUnicodeString(buff+18+(point->Location-1)*42,point->URL); 4933 CopyUnicodeString(buff+18+(point->Location-1)*42,point->URL);
4833 buff[0] = 0x00; 4934 buff[0] = 0x00;
4834 buff[1] = 0x01; 4935 buff[1] = 0x01;
4835 buff[2] = 0x01; 4936 buff[2] = 0x01;
4836 buff[3] = 0x07; 4937 buff[3] = 0x07;
4837 smprintf(s, "Setting GPRS access point URL\n"); 4938 smprintf(s, "Setting GPRS access point URL\n");
4838 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint); 4939 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint);
4839 if (error != ERR_NONE) return error; 4940 if (error != ERR_NONE) return error;
4840 4941
4841 if (point->Active) { 4942 if (point->Active) {
4842 smprintf(s, "Getting number of active GPRS access point\n"); 4943 smprintf(s, "Getting number of active GPRS access point\n");
4843 error=GSM_WaitFor (s, Active, 16, 0x43, 4, ID_SetGPRSPoint); 4944 error=GSM_WaitFor (s, Active, 16, 0x43, 4, ID_SetGPRSPoint);
4844 if (error != ERR_NONE) return error; 4945 if (error != ERR_NONE) return error;
4845 buff[0] = 0x00; 4946 buff[0] = 0x00;
4846 buff[1] = 0x01; 4947 buff[1] = 0x01;
4847 buff[2] = 0x01; 4948 buff[2] = 0x01;
4848 buff[3] = 0x07; 4949 buff[3] = 0x07;
4849 buff[18]= point->Location; 4950 buff[18]= point->Location;
4850 smprintf(s, "Setting number of active GPRS access point\n"); 4951 smprintf(s, "Setting number of active GPRS access point\n");
4851 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint); 4952 error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint);
4852 if (error != ERR_NONE) return error; 4953 if (error != ERR_NONE) return error;
4853 } 4954 }
4854 4955
4855 return error; 4956 return error;
4856} 4957}
4857 4958
4858/* ToDo support - 6310 style */ 4959/* ToDo support - 6310 style */
4859static GSM_Error N6510_ReplyGetToDoStatus1(GSM_Protocol_Message msg, GSM_StateMachine *s) 4960static GSM_Error N6510_ReplyGetToDoStatus1(GSM_Protocol_Message msg, GSM_StateMachine *s)
4860{ 4961{
4861 int i; 4962 int i;
4862 GSM_NOKIACalToDoLocations*Last = &s->Phone.Data.Priv.N6510.LastToDo; 4963 GSM_NOKIACalToDoLocations*Last = &s->Phone.Data.Priv.N6510.LastToDo;
4863 4964
4864 smprintf(s, "TODO locations received\n"); 4965 smprintf(s, "TODO locations received\n");
4865 Last->Number=msg.Buffer[6]*256+msg.Buffer[7]; 4966 Last->Number=msg.Buffer[6]*256+msg.Buffer[7];
4866 smprintf(s, "Number of Entries: %i\n",Last->Number); 4967 smprintf(s, "Number of Entries: %i\n",Last->Number);
4867 smprintf(s, "Locations: "); 4968 smprintf(s, "Locations: ");
4868 for (i=0;i<Last->Number;i++) { 4969 for (i=0;i<Last->Number;i++) {
4869 Last->Location[i]=msg.Buffer[12+(i*4)]*256+msg.Buffer[(i*4)+13]; 4970 Last->Location[i]=msg.Buffer[12+(i*4)]*256+msg.Buffer[(i*4)+13];
4870 smprintf(s, "%i ",Last->Location[i]); 4971 smprintf(s, "%i ",Last->Location[i]);
4871 } 4972 }
4872 smprintf(s, "\n"); 4973 smprintf(s, "\n");
4873 return ERR_NONE; 4974 return ERR_NONE;
4874} 4975}
4875 4976
4876/* ToDo support - 6310 style */ 4977/* ToDo support - 6310 style */
4877static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *status) 4978static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *status)
4878{ 4979{
4879 GSM_Error error; 4980 GSM_Error error;
4880 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 4981 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4881 unsigned char reqLoc[] = { 4982 unsigned char reqLoc[] = {
4882 N6110_FRAME_HEADER, 4983 N6110_FRAME_HEADER,
4883 0x15, 0x01, 0x00, 0x00, 4984 0x15, 0x01, 0x00, 0x00,
4884 0x00, 0x00, 0x00}; 4985 0x00, 0x00, 0x00};
4885 4986
4886 smprintf(s, "Getting ToDo locations\n"); 4987 smprintf(s, "Getting ToDo locations\n");
4887 error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo); 4988 error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo);
4888 if (error != ERR_NONE) return error; 4989 if (error != ERR_NONE) return error;
4889 4990
4890 status->Used = LastToDo->Number; 4991 status->Used = LastToDo->Number;
4891 return ERR_NONE; 4992 return ERR_NONE;
4892} 4993}
4893 4994
4894static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status) 4995static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status)
4895{ 4996{
4896 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 4997 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4897 GSM_Error error; 4998 GSM_Error error;
4898 4999
4899 error = N6510_GetCalendarInfo3(s,LastToDo,1); 5000 error = N6510_GetCalendarInfo3(s,LastToDo,1);
4900 if (error!=ERR_NONE) return error; 5001 if (error!=ERR_NONE) return error;
4901 5002
4902 status->Used = LastToDo->Number; 5003 status->Used = LastToDo->Number;
4903 return ERR_NONE; 5004 return ERR_NONE;
4904} 5005}
4905 5006
4906static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 5007static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
4907{ 5008{
4908 status->Used = 0; 5009 status->Used = 0;
4909 5010
4910 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5011 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
4911 return N6510_GetToDoStatus1(s, status); 5012 return N6510_GetToDoStatus1(s, status);
4912 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5013 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
4913 return N6510_GetToDoStatus2(s, status); 5014 return N6510_GetToDoStatus2(s, status);
4914 } else { 5015 } else {
4915 return ERR_NOTSUPPORTED; 5016 return ERR_NOTSUPPORTED;
4916 } 5017 }
4917} 5018}
4918 5019
4919/* ToDo support - 6310 style */ 5020/* ToDo support - 6310 style */
4920static GSM_Error N6510_ReplyGetToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5021static GSM_Error N6510_ReplyGetToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
4921{ 5022{
4922 GSM_ToDoEntry *Last = s->Phone.Data.ToDo; 5023 GSM_ToDoEntry *Last = s->Phone.Data.ToDo;
4923 5024
4924 smprintf(s, "TODO received method 1\n"); 5025 smprintf(s, "TODO received method 1\n");
4925 5026
4926 switch (msg.Buffer[4]) { 5027 switch (msg.Buffer[4]) {
4927 case 1 : Last->Priority = GSM_Priority_High; break; 5028 case 1 : Last->Priority = GSM_Priority_High; break;
4928 case 2 : Last->Priority = GSM_Priority_Medium; break; 5029 case 2 : Last->Priority = GSM_Priority_Medium; break;
4929 case 3 : Last->Priority = GSM_Priority_Low; break; 5030 case 3 : Last->Priority = GSM_Priority_Low; break;
4930 default: return ERR_UNKNOWN; 5031 default: return ERR_UNKNOWN;
4931 } 5032 }
4932 smprintf(s, "Priority: %i\n",msg.Buffer[4]); 5033 smprintf(s, "Priority: %i\n",msg.Buffer[4]);
4933 5034
4934 CopyUnicodeString(Last->Entries[0].Text,msg.Buffer+14); 5035 CopyUnicodeString(Last->Entries[0].Text,msg.Buffer+14);
4935 Last->Entries[0].EntryType = TODO_TEXT; 5036 Last->Entries[0].EntryType = TODO_TEXT;
4936 Last->EntriesNum = 1; 5037 Last->EntriesNum = 1;
4937 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text)); 5038 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text));
4938 5039
4939 return ERR_NONE; 5040 return ERR_NONE;
4940} 5041}
4941 5042
4942/* ToDo support - 6310 style */ 5043/* ToDo support - 6310 style */
4943static GSM_Error N6510_GetNextToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5044static GSM_Error N6510_GetNextToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
4944{ 5045{
4945 GSM_Error error; 5046 GSM_Error error;
4946 GSM_ToDoStatus status; 5047 GSM_ToDoStatus status;
4947 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5048 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4948 unsigned char reqGet[] = { 5049 unsigned char reqGet[] = {
4949 N6110_FRAME_HEADER, 5050 N6110_FRAME_HEADER,
4950 0x03, 0x00, 0x00, 0x80, 0x00, 5051 0x03, 0x00, 0x00, 0x80, 0x00,
4951 0x00, 0x17}; /* Location */ 5052 0x00, 0x17}; /* Location */
4952 5053
4953 if (refresh) { 5054 if (refresh) {
4954 error = N6510_GetToDoStatus(s, &status); 5055 error = N6510_GetToDoStatus(s, &status);
4955 if (error != ERR_NONE) return error; 5056 if (error != ERR_NONE) return error;
4956 ToDo->Location = 1; 5057 ToDo->Location = 1;
4957 } else { 5058 } else {
4958 ToDo->Location++; 5059 ToDo->Location++;
4959 } 5060 }
4960 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY; 5061 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY;
4961 5062
4962 reqGet[8] = LastToDo->Location[ToDo->Location-1] / 256; 5063 reqGet[8] = LastToDo->Location[ToDo->Location-1] / 256;
4963 reqGet[9] = LastToDo->Location[ToDo->Location-1] % 256; 5064 reqGet[9] = LastToDo->Location[ToDo->Location-1] % 256;
4964 s->Phone.Data.ToDo = ToDo; 5065 s->Phone.Data.ToDo = ToDo;
4965 smprintf(s, "Getting ToDo\n"); 5066 smprintf(s, "Getting ToDo\n");
4966 return GSM_WaitFor (s, reqGet, 10, 0x55, 4, ID_GetToDo); 5067 return GSM_WaitFor (s, reqGet, 10, 0x55, 4, ID_GetToDo);
4967} 5068}
4968 5069
4969static GSM_Error N6510_ReplyGetToDoStatus2(GSM_Protocol_Message msg, GSM_StateMachine *s) 5070static GSM_Error N6510_ReplyGetToDoStatus2(GSM_Protocol_Message msg, GSM_StateMachine *s)
4970{ 5071{
4971 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastToDo); 5072 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastToDo);
4972} 5073}
4973 5074
4974/* Similiar to getting calendar method 3 */ 5075/* Similiar to getting calendar method 3 */
4975static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine *s) 5076static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine *s)
4976{ 5077{
4977 GSM_ToDoEntry *Last = s->Phone.Data.ToDo; 5078 GSM_ToDoEntry *Last = s->Phone.Data.ToDo;
4978 GSM_DateTime Date; 5079 GSM_DateTime Date;
4979 unsigned long diff; 5080 unsigned long diff;
4980 5081
4981 smprintf(s, "ToDo received method 2\n"); 5082 smprintf(s, "ToDo received method 2\n");
4982 5083
4983 switch (msg.Buffer[44]) { 5084 switch (msg.Buffer[44]) {
4984 case 0x10: Last->Priority = GSM_Priority_Low; break; 5085 case 0x10: Last->Priority = GSM_Priority_Low; break;
4985 case 0x20: Last->Priority = GSM_Priority_Medium; break; 5086 case 0x20: Last->Priority = GSM_Priority_Medium; break;
4986 case 0x30: Last->Priority = GSM_Priority_High; break; 5087 case 0x30: Last->Priority = GSM_Priority_High; break;
4987 default : return ERR_UNKNOWN; 5088 default : return ERR_UNKNOWN;
4988 } 5089 }
4989 5090
4990 memcpy(Last->Entries[0].Text,msg.Buffer+54,msg.Buffer[51]*2); 5091 memcpy(Last->Entries[0].Text,msg.Buffer+54,msg.Buffer[51]*2);
4991 Last->Entries[0].Text[msg.Buffer[51]*2] = 0; 5092 Last->Entries[0].Text[msg.Buffer[51]*2] = 0;
4992 Last->Entries[0].Text[msg.Buffer[51]*2+1] = 0; 5093 Last->Entries[0].Text[msg.Buffer[51]*2+1] = 0;
4993 Last->Entries[0].EntryType = TODO_TEXT; 5094 Last->Entries[0].EntryType = TODO_TEXT;
4994 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text)); 5095 smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text));
4995 5096
4996 smprintf(s,"EndTime: %04i-%02i-%02i %02i:%02i\n", 5097 smprintf(s,"EndTime: %04i-%02i-%02i %02i:%02i\n",
4997 msg.Buffer[34]*256+msg.Buffer[35], 5098 msg.Buffer[34]*256+msg.Buffer[35],
4998 msg.Buffer[36],msg.Buffer[37],msg.Buffer[38], 5099 msg.Buffer[36],msg.Buffer[37],msg.Buffer[38],
4999 msg.Buffer[39]); 5100 msg.Buffer[39]);
5000 Date.Year = msg.Buffer[34]*256+msg.Buffer[35]; 5101 Date.Year = msg.Buffer[34]*256+msg.Buffer[35];
5001 Date.Month = msg.Buffer[36]; 5102 Date.Month = msg.Buffer[36];
5002 Date.Day = msg.Buffer[37]; 5103 Date.Day = msg.Buffer[37];
5003 Date.Hour = msg.Buffer[38]; 5104 Date.Hour = msg.Buffer[38];
5004 Date.Minute = msg.Buffer[39]; 5105 Date.Minute = msg.Buffer[39];
5005 Date.Second= 0; 5106 Date.Second= 0;
5006 Last->Entries[1].EntryType = TODO_END_DATETIME; 5107 Last->Entries[1].EntryType = TODO_END_DATETIME;
5007 memcpy(&Last->Entries[1].Date,&Date,sizeof(GSM_DateTime)); 5108 memcpy(&Last->Entries[1].Date,&Date,sizeof(GSM_DateTime));
5008 5109
5009 smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n", 5110 smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n",
5010 msg.Buffer[28]*256+msg.Buffer[29], 5111 msg.Buffer[28]*256+msg.Buffer[29],
5011 msg.Buffer[30],msg.Buffer[31],msg.Buffer[32], 5112 msg.Buffer[30],msg.Buffer[31],msg.Buffer[32],
5012 msg.Buffer[33]); 5113 msg.Buffer[33]);
5013 Date.Year = msg.Buffer[28]*256+msg.Buffer[29]; 5114 Date.Year = msg.Buffer[28]*256+msg.Buffer[29];
5014 Date.Month = msg.Buffer[30]; 5115 Date.Month = msg.Buffer[30];
5015 Date.Day = msg.Buffer[31]; 5116 Date.Day = msg.Buffer[31];
5016 Date.Hour = msg.Buffer[32]; 5117 Date.Hour = msg.Buffer[32];
5017 Date.Minute = msg.Buffer[33]; 5118 Date.Minute = msg.Buffer[33];
5018 Date.Second= 0; 5119 Date.Second= 0;
5019 5120
5020 Last->EntriesNum = 2; 5121 Last->EntriesNum = 2;
5021 5122
5022 if (msg.Buffer[45] == 0x01) { 5123 if (msg.Buffer[45] == 0x01) {
5023 Last->Entries[2].Number = msg.Buffer[45]; 5124 Last->Entries[2].Number = msg.Buffer[45];
5024 Last->Entries[2].EntryType = TODO_COMPLETED; 5125 Last->Entries[2].EntryType = TODO_COMPLETED;
5025 Last->EntriesNum++; 5126 Last->EntriesNum++;
5026 smprintf(s,"Completed\n"); 5127 smprintf(s,"Completed\n");
5027 } 5128 }
5028 5129
5029 if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) { 5130 if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) {
5030 smprintf(s, "No alarm\n"); 5131 smprintf(s, "No alarm\n");
5031 } else { 5132 } else {
5032 diff = ((unsigned int)msg.Buffer[14]) << 24; 5133 diff = ((unsigned int)msg.Buffer[14]) << 24;
5033 diff += ((unsigned int)msg.Buffer[15]) << 16; 5134 diff += ((unsigned int)msg.Buffer[15]) << 16;
5034 diff += ((unsigned int)msg.Buffer[16]) << 8; 5135 diff += ((unsigned int)msg.Buffer[16]) << 8;
5035 diff += msg.Buffer[17]; 5136 diff += msg.Buffer[17];
5036 5137
5037 memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime)); 5138 memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime));
5038 GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60); 5139 GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60);
5039 smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n", 5140 smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n",
5040 Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month, 5141 Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month,
5041 Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour, 5142 Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour,
5042 Last->Entries[Last->EntriesNum].Date.Minute,Last->Entries[Last->EntriesNum].Date.Second); 5143 Last->Entries[Last->EntriesNum].Date.Minute,Last->Entries[Last->EntriesNum].Date.Second);
5043 5144
5044 Last->Entries[Last->EntriesNum].EntryType = TODO_ALARM_DATETIME; 5145 Last->Entries[Last->EntriesNum].EntryType = TODO_ALARM_DATETIME;
5045 if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 && 5146 if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 &&
5046 msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00) 5147 msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00)
5047 { 5148 {
5048 Last->Entries[Last->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; 5149 Last->Entries[Last->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
5049 smprintf(s, "Alarm type : Silent\n"); 5150 smprintf(s, "Alarm type : Silent\n");
5050 } 5151 }
5051 Last->EntriesNum++; 5152 Last->EntriesNum++;
5052 } 5153 }
5053 5154
5054 return ERR_NONE; 5155 return ERR_NONE;
5055} 5156}
5056 5157
5057/* ToDo support - 6610 style */ 5158/* ToDo support - 6610 style */
5058static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5159static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
5059{ 5160{
5060 GSM_Error error; 5161 GSM_Error error;
5061 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5162 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
5062 5163
5063 if (refresh) { 5164 if (refresh) {
5064 error=N6510_GetCalendarInfo3(s,LastToDo,1); 5165 error=N6510_GetCalendarInfo3(s,LastToDo,1);
5065 if (error!=ERR_NONE) return error; 5166 if (error!=ERR_NONE) return error;
5066 ToDo->Location = 1; 5167 ToDo->Location = 1;
5067 } else { 5168 } else {
5068 ToDo->Location++; 5169 ToDo->Location++;
5069 } 5170 }
5070 5171
5071 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY; 5172 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY;
5072 5173
5073 s->Phone.Data.ToDo = ToDo; 5174 s->Phone.Data.ToDo = ToDo;
5074 smprintf(s, "Getting todo method 2\n"); 5175 smprintf(s, "Getting todo method 2\n");
5075 return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo); 5176 return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo);
5076} 5177}
5077 5178
5078static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5179static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
5079{ 5180{
5080 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5181 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
5081 return N6510_GetNextToDo1(s, ToDo, refresh); 5182 return N6510_GetNextToDo1(s, ToDo, refresh);
5082 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5183 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5083 return N6510_GetNextToDo2(s, ToDo, refresh); 5184 return N6510_GetNextToDo2(s, ToDo, refresh);
5084 } else { 5185 } else {
5085 return ERR_NOTSUPPORTED; 5186 return ERR_NOTSUPPORTED;
5086 } 5187 }
5087} 5188}
5088 5189
5089/* ToDo support - 6310 style */ 5190/* ToDo support - 6310 style */
5090static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5191static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
5091{ 5192{
5092 smprintf(s, "All TODO deleted\n"); 5193 smprintf(s, "All TODO deleted\n");
5093 return ERR_NONE; 5194 return ERR_NONE;
5094} 5195}
5095 5196
5096/* ToDo support - 6310 style */ 5197/* ToDo support - 6310 style */
5097static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s) 5198static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s)
5098{ 5199{
5099 unsigned char req[] = {N6110_FRAME_HEADER, 0x11}; 5200 unsigned char req[] = {N6110_FRAME_HEADER, 0x11};
5100 5201
5101 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5202 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
5102 return ERR_NOTSUPPORTED; 5203 return ERR_NOTSUPPORTED;
5103 } 5204 }
5104 5205
5105 smprintf(s, "Deleting all ToDo method 1\n"); 5206 smprintf(s, "Deleting all ToDo method 1\n");
5106 return GSM_WaitFor (s, req, 4, 0x55, 4, ID_DeleteAllToDo); 5207 return GSM_WaitFor (s, req, 4, 0x55, 4, ID_DeleteAllToDo);
5107} 5208}
5108 5209
5109static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5210static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5110{ 5211{
5111 GSM_Error error; 5212 GSM_Error error;
5112 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5213 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
5113 GSM_CalendarEntry Note; 5214 GSM_CalendarEntry Note;
5114 5215
5115 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5216 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5116 return ERR_NOTSUPPORTED; 5217 return ERR_NOTSUPPORTED;
5117 } 5218 }
5118 5219
5119 error=N6510_GetCalendarInfo3(s,LastToDo,1); 5220 error=N6510_GetCalendarInfo3(s,LastToDo,1);
5120 if (error!=ERR_NONE) return error; 5221 if (error!=ERR_NONE) return error;
5121 5222
5122 smprintf(s, "Deleting ToDo method 2\n"); 5223 smprintf(s, "Deleting ToDo method 2\n");
5123 5224
5124 if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION; 5225 if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION;
5125 5226
5126 Note.Location = LastToDo->Location[ToDo->Location-1]; 5227 Note.Location = LastToDo->Location[ToDo->Location-1];
5127 return N71_65_DelCalendar(s,&Note); 5228 return N71_65_DelCalendar(s,&Note);
5128} 5229}
5129 5230
5130/* ToDo support - 6310 style */ 5231/* ToDo support - 6310 style */
5131static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5232static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s)
5132{ 5233{
5133 smprintf(s, "TODO first location received method 1: %02x\n",msg.Buffer[9]); 5234 smprintf(s, "TODO first location received method 1: %02x\n",msg.Buffer[9]);
5134 s->Phone.Data.ToDo->Location = msg.Buffer[9]; 5235 s->Phone.Data.ToDo->Location = msg.Buffer[9];
5135 return ERR_NONE; 5236 return ERR_NONE;
5136} 5237}
5137 5238
5138/* ToDo support - 6310 style */ 5239/* ToDo support - 6310 style */
5139static GSM_Error N6510_ReplyAddToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5240static GSM_Error N6510_ReplyAddToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
5140{ 5241{
5141 smprintf(s, "TODO set OK\n"); 5242 smprintf(s, "TODO set OK\n");
5142 return ERR_NONE; 5243 return ERR_NONE;
5143} 5244}
5144 5245
5145/* ToDo support - 6310 style */ 5246/* ToDo support - 6310 style */
5146static GSM_Error N6510_AddToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5247static GSM_Error N6510_AddToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5147{ 5248{
5148 int Text, Alarm, EndTime, Completed, ulen, Phone; 5249 int Text, Alarm, EndTime, Completed, ulen, Phone;
5149 GSM_Error error; 5250 GSM_Error error;
5150 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x0F}; 5251 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x0F};
5151 unsigned char reqSet[500] = { 5252 unsigned char reqSet[500] = {
5152 N6110_FRAME_HEADER, 0x01, 5253 N6110_FRAME_HEADER, 0x01,
5153 0x03, /* Priority */ 5254 0x03, /* Priority */
5154 0x00, /* Length of text */ 5255 0x00, /* Length of text */
5155 0x80,0x00,0x00, 5256 0x80,0x00,0x00,
5156 0x18}; /* Location */ 5257 0x18}; /* Location */
5157 5258
5158 s->Phone.Data.ToDo = ToDo; 5259 s->Phone.Data.ToDo = ToDo;
5159 5260
5160 smprintf(s, "Getting first ToDo location\n"); 5261 smprintf(s, "Getting first ToDo location\n");
5161 error = GSM_WaitFor (s, reqLoc, 4, 0x55, 4, ID_SetToDo); 5262 error = GSM_WaitFor (s, reqLoc, 4, 0x55, 4, ID_SetToDo);
5162 if (error != ERR_NONE) return error; 5263 if (error != ERR_NONE) return error;
5163 reqSet[9] = ToDo->Location; 5264 reqSet[9] = ToDo->Location;
5164 5265
5165 switch (ToDo->Priority) { 5266 switch (ToDo->Priority) {
5166 case GSM_Priority_Low: reqSet[4] = 3; break; 5267 case GSM_Priority_Low: reqSet[4] = 3; break;
5167 case GSM_Priority_Medium: reqSet[4] = 2; break; 5268 case GSM_Priority_Medium: reqSet[4] = 2; break;
5168 case GSM_Priority_High: reqSet[4] = 1; break; 5269 case GSM_Priority_High: reqSet[4] = 1; break;
5169 } 5270 }
5170 5271
5171 GSM_ToDoFindDefaultTextTimeAlarmCompleted(ToDo, &Text, &Alarm, &Completed, &EndTime, &Phone); 5272 GSM_ToDoFindDefaultTextTimeAlarmCompleted(ToDo, &Text, &Alarm, &Completed, &EndTime, &Phone);
5172 5273
5173 if (Text == -1) return ERR_NOTSUPPORTED; /* XXX: shouldn't this be handled different way? */ 5274 if (Text == -1) return ERR_NOTSUPPORTED; /* XXX: shouldn't this be handled different way? */
5174 ulen = UnicodeLength(ToDo->Entries[Text].Text); 5275 ulen = UnicodeLength(ToDo->Entries[Text].Text);
5175 reqSet[5] = ulen+1; 5276 reqSet[5] = ulen+1;
5176 CopyUnicodeString(reqSet+10,ToDo->Entries[Text].Text); 5277 CopyUnicodeString(reqSet+10,ToDo->Entries[Text].Text);
5177 reqSet[10+ulen*2] = 0x00; 5278 reqSet[10+ulen*2] = 0x00;
5178 reqSet[10+ulen*2+1] = 0x00; 5279 reqSet[10+ulen*2+1] = 0x00;
5179 smprintf(s, "Adding ToDo method 1\n"); 5280 smprintf(s, "Adding ToDo method 1\n");
5180 return GSM_WaitFor (s, reqSet, 12+ulen*2, 0x55, 4, ID_SetToDo); 5281 return GSM_WaitFor (s, reqSet, 12+ulen*2, 0x55, 4, ID_SetToDo);
5181} 5282}
5182 5283
5183static GSM_Error N6510_ReplyAddToDo2(GSM_Protocol_Message msg, GSM_StateMachine *s) 5284static GSM_Error N6510_ReplyAddToDo2(GSM_Protocol_Message msg, GSM_StateMachine *s)
5184{ 5285{
5185 smprintf(s, "ToDo added method 2\n"); 5286 smprintf(s, "ToDo added method 2\n");
5186 return ERR_NONE; 5287 return ERR_NONE;
5187} 5288}
5188 5289
5189static GSM_Error N6510_ReplyGetToDoFirstLoc2(GSM_Protocol_Message msg, GSM_StateMachine *s) 5290static GSM_Error N6510_ReplyGetToDoFirstLoc2(GSM_Protocol_Message msg, GSM_StateMachine *s)
5190{ 5291{
5191 smprintf(s, "First ToDo location method 2: %i\n",msg.Buffer[8]*256+msg.Buffer[9]); 5292 smprintf(s, "First ToDo location method 2: %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
5192 s->Phone.Data.ToDo->Location = msg.Buffer[9]; 5293 s->Phone.Data.ToDo->Location = msg.Buffer[8]*256+msg.Buffer[9];
5193 return ERR_NONE; 5294 return ERR_NONE;
5194} 5295}
5195 5296
5196static GSM_Error N6510_AddToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5297static GSM_Error N6510_AddToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5197{ 5298{
5198 GSM_CalendarEntryNote; 5299 GSM_CalendarEntryNote;
5199 time_t t_time1,t_time2; 5300 time_t t_time1,t_time2;
5200 long diff; 5301 long diff;
5201 GSM_Error error; 5302 GSM_Error error;
5202 GSM_DateTime DT; 5303 GSM_DateTime DT;
5203 int Text, Alarm, EndTime, Completed, count=54, Phone; 5304 int Text, Alarm, EndTime, Completed, count=54, Phone;
5204 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95, 0x01}; 5305 unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95,
5306 0x01};/* 1 = todo, 2 = note */
5205 unsigned char req[5000] = { 5307 unsigned char req[5000] = {
5206 N6110_FRAME_HEADER, 0x65, 5308 N6110_FRAME_HEADER, 0x65,
5207 0x01, /* 0 = calendar, 1 = todo */ 5309 0x01, /* 0 = calendar, 1 = todo */
5208 0x00, 0x00, 0x00, 5310 0x00, 0x00, 0x00,
5209 0x00, 0x00, /* location */ 5311 0x00, 0x00, /* location */
5210 0x00, 0x00, 0x00, 0x00, 5312 0x00, 0x00, 0x00, 0x00,
5211 0xFF, 0xFF, 0xFF, 0xFF, /* alarm */ 5313 0xFF, 0xFF, 0xFF, 0xFF, /* alarm */
5212 0x80, 0x00, 0x00, 5314 0x80, 0x00, 0x00,
5213 0x01, /* note icon */ 5315 0x01, /* note icon */
5214 0xFF, 0xFF, 0xFF, 0xFF, /* alarm type */ 5316 0xFF, 0xFF, 0xFF, 0xFF, /* alarm type */
5215 0x00, /* 0x02 or 0x00 */ 5317 0x00, /* 0x02 or 0x00 */
5216 0x01, /* note type */ 5318 0x01, /* note type */
5217 0x07, 0xD0, 0x01, 0x12, 0x0C, 0x00, /* start date/time */ 5319 0x07, 0xD0, 0x01, 0x12, 0x0C, 0x00, /* start date/time */
5218 0x07, 0xD0, 0x01, 0x12, 0x0C, 0x00, /* end date/time */ 5320 0x07, 0xD0, 0x01, 0x12, 0x0C, 0x00, /* end date/time */
5219 0x00, 0x00, /* recurrance */ 5321 0x00, 0x00, /* recurrance */
5220 0x00, 0x00, /* birth year */ 5322 0x00, 0x00, /* birth year */
5221 0x20, /* ToDo priority */ 5323 0x20, /* ToDo priority */
5222 0x00, /* ToDo completed ? */ 5324 0x00, /* ToDo completed ? */
5223 0x00, 0x00, 0x00, 5325 0x00, 0x00, 0x00,
5224 0x00, /* note text length */ 5326 0x00, /* note text length */
5225 0x00, /* phone length/meeting place*/ 5327 0x00, /* phone length/meeting place*/
5226 0x00, 0x00, 0x00}; 5328 0x00, 0x00, 0x00};
5227 5329
5228 s->Phone.Data.ToDo = ToDo; 5330 s->Phone.Data.ToDo = ToDo;
5229 5331
5230 smprintf(s, "Getting first free ToDo location method 2\n"); 5332 smprintf(s, "Getting first free ToDo location method 2\n");
5231 error = GSM_WaitFor (s, reqLoc, 5, 0x13, 4, ID_SetToDo); 5333 error = GSM_WaitFor (s, reqLoc, 5, 0x13, 4, ID_SetToDo);
5232 if (error!=ERR_NONE) return error; 5334 if (error!=ERR_NONE) return error;
5233 req[8] = ToDo->Location/256; 5335 req[8] = ToDo->Location/256;
5234 req[9] = ToDo->Location%256; 5336 req[9] = ToDo->Location%256;
5235 5337
5236 Note.Type = GSM_CAL_MEETING; 5338 Note.Type = GSM_CAL_MEETING;
5237 DT.Year = 2004; DT.Month = 1; DT.Day = 1; 5339 DT.Year = 2004; DT.Month = 1; DT.Day = 1;
5238 DT.Hour = 12; DT.Minute = 12; DT.Second = 0; 5340 DT.Hour = 12; DT.Minute = 12; DT.Second = 0;
5239 memcpy(&Note.Entries[0].Date,&DT,sizeof(GSM_DateTime)); 5341 memcpy(&Note.Entries[0].Date,&DT,sizeof(GSM_DateTime));
5240 Note.Entries[0].EntryType = CAL_START_DATETIME; 5342 Note.Entries[0].EntryType = CAL_START_DATETIME;
5241 memcpy(&Note.Entries[1].Date,&DT,sizeof(GSM_DateTime)); 5343 memcpy(&Note.Entries[1].Date,&DT,sizeof(GSM_DateTime));
5242 Note.Entries[1].EntryType = CAL_END_DATETIME; 5344 Note.Entries[1].EntryType = CAL_END_DATETIME;
5243 EncodeUnicode(Note.Entries[2].Text,"ala",3); 5345 EncodeUnicode(Note.Entries[2].Text,"ala",3);
5244 Note.Entries[2].EntryType = CAL_TEXT; 5346 Note.Entries[2].EntryType = CAL_TEXT;
5245 Note.EntriesNum = 3; 5347 Note.EntriesNum = 3;
5246 error=N6510_FindCalendarIconID3(s, &Note, &req[21]); 5348 error=N6510_FindCalendarIconID3(s, &Note, &req[21]);
5247 if (error!=ERR_NONE) return error; 5349 if (error!=ERR_NONE) return error;
5248 5350
5249 switch (ToDo->Priority) { 5351 switch (ToDo->Priority) {
5250 case GSM_Priority_Low: req[44] = 0x10; break; 5352 case GSM_Priority_Low: req[44] = 0x10; break;
5251 case GSM_Priority_Medium: req[44] = 0x20; break; 5353 case GSM_Priority_Medium: req[44] = 0x20; break;
5252 case GSM_Priority_High: req[44] = 0x30; break; 5354 case GSM_Priority_High: req[44] = 0x30; break;
5253 } 5355 }
5254 5356
5255 GSM_ToDoFindDefaultTextTimeAlarmCompleted(ToDo, &Text, &Alarm, &Completed, &EndTime, &Phone); 5357 GSM_ToDoFindDefaultTextTimeAlarmCompleted(ToDo, &Text, &Alarm, &Completed, &EndTime, &Phone);
5256 5358
5257 if (Completed != -1) req[45] = 0x01; 5359 if (Completed != -1) req[45] = 0x01;
5258 5360
5259 if (EndTime == -1) { 5361 if (EndTime == -1) {
5260 GSM_GetCurrentDateTime(&DT); 5362 GSM_GetCurrentDateTime(&DT);
5261 } else { 5363 } else {
5262 memcpy(&DT,&ToDo->Entries[EndTime].Date,sizeof(GSM_DateTime)); 5364 memcpy(&DT,&ToDo->Entries[EndTime].Date,sizeof(GSM_DateTime));
5263 } 5365 }
5264 /*Start time*/ 5366 /*Start time*/
5265 req[28]= DT.Year / 256; 5367 req[28]= DT.Year / 256;
5266 req[29]= DT.Year % 256; 5368 req[29]= DT.Year % 256;
5267 req[30]= DT.Month; 5369 req[30]= DT.Month;
5268 req[31]= DT.Day; 5370 req[31]= DT.Day;
5269 req[32]= DT.Hour; 5371 req[32]= DT.Hour;
5270 req[33]= DT.Minute; 5372 req[33]= DT.Minute;
5271 /*End time*/ 5373 /*End time*/
5272 req[34]= DT.Year / 256; 5374 req[34]= DT.Year / 256;
5273 req[35]= DT.Year % 256; 5375 req[35]= DT.Year % 256;
5274 req[36]= DT.Month; 5376 req[36]= DT.Month;
5275 req[37]= DT.Day; 5377 req[37]= DT.Day;
5276 req[38]= DT.Hour; 5378 req[38]= DT.Hour;
5277 req[39]= DT.Minute; 5379 req[39]= DT.Minute;
5278 5380
5279 if (Alarm != -1) { 5381 if (Alarm != -1) {
5280 if (ToDo->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) 5382 if (ToDo->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME)
5281 { 5383 {
5282 req[22] = 0x00; req[23] = 0x00; req[24] = 0x00; req[25] = 0x00; 5384 req[22] = 0x00; req[23] = 0x00; req[24] = 0x00; req[25] = 0x00;
5283 } 5385 }
5284 t_time2 = Fill_Time_T(DT,8); 5386 t_time2 = Fill_Time_T(DT,8);
5285 t_time1 = Fill_Time_T(ToDo->Entries[Alarm].Date,8); 5387 t_time1 = Fill_Time_T(ToDo->Entries[Alarm].Date,8);
5286 diff = (t_time1-t_time2)/60; 5388 diff = (t_time1-t_time2)/60;
5287 5389
5288 smprintf(s, " Difference : %li seconds or minutes\n", -diff); 5390 smprintf(s, " Difference : %li seconds or minutes\n", -diff);
5289 req[14] = (unsigned char)(-diff >> 24); 5391 req[14] = (unsigned char)(-diff >> 24);
5290 req[15] = (unsigned char)(-diff >> 16); 5392 req[15] = (unsigned char)(-diff >> 16);
5291 req[16] = (unsigned char)(-diff >> 8); 5393 req[16] = (unsigned char)(-diff >> 8);
5292 req[17] = (unsigned char)(-diff); 5394 req[17] = (unsigned char)(-diff);
5293 } 5395 }
5294 5396
5295 if (Text != -1) { 5397 if (Text != -1) {
5296 req[49] = UnicodeLength(ToDo->Entries[Text].Text); 5398 req[49] = UnicodeLength(ToDo->Entries[Text].Text);
5297 CopyUnicodeString(req+54,ToDo->Entries[Text].Text); 5399 CopyUnicodeString(req+54,ToDo->Entries[Text].Text);
5298 count+= req[49]*2; 5400 count+= req[49]*2;
5299 } 5401 }
5300 5402
5301 req[count++] = 0x00; 5403 req[count++] = 0x00;
5302 5404
5303 smprintf(s, "Adding ToDo method 2\n"); 5405 smprintf(s, "Adding ToDo method 2\n");
5304 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetToDo); 5406 return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetToDo);
5305} 5407}
5306 5408
5307static GSM_Error N6510_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5409static GSM_Error N6510_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5308{ 5410{
5309 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5411 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
5310 return N6510_AddToDo1(s, ToDo); 5412 return N6510_AddToDo1(s, ToDo);
5311 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5413 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5312 return N6510_AddToDo2(s, ToDo); 5414 return N6510_AddToDo2(s, ToDo);
5313 } else { 5415 } else {
5314 return ERR_NOTSUPPORTED; 5416 return ERR_NOTSUPPORTED;
5315 } 5417 }
5316} 5418}
5317 5419
5318static GSM_Error N6510_ReplyGetLocale(GSM_Protocol_Message msg, GSM_StateMachine *s) 5420static GSM_Error N6510_ReplyGetLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
5319{ 5421{
5320 GSM_Locale *locale = s->Phone.Data.Locale; 5422 GSM_Locale *locale = s->Phone.Data.Locale;
5321 5423
5322 switch (msg.Buffer[3]) { 5424 switch (msg.Buffer[3]) {
5323 case 0x8A: 5425 case 0x8A:
5324 smprintf(s, "Date settings received\n"); 5426 smprintf(s, "Date settings received\n");
5325 switch (msg.Buffer[4]) { 5427 switch (msg.Buffer[4]) {
5326 case 0x00: 5428 case 0x00:
5327 locale->DateFormat = GSM_Date_DDMMYYYY; 5429 locale->DateFormat = GSM_Date_DDMMYYYY;
5328 locale->DateSeparator = '.'; 5430 locale->DateSeparator = '.';
5329 break; 5431 break;
5330 case 0x01: 5432 case 0x01:
5331 locale->DateFormat = GSM_Date_MMDDYYYY; 5433 locale->DateFormat = GSM_Date_MMDDYYYY;
5332 locale->DateSeparator = '.'; 5434 locale->DateSeparator = '.';
5333 break; 5435 break;
5334 case 0x02: 5436 case 0x02:
5335 locale->DateFormat = GSM_Date_YYYYMMDD; 5437 locale->DateFormat = GSM_Date_YYYYMMDD;
5336 locale->DateSeparator = '.'; 5438 locale->DateSeparator = '.';
5337 break; 5439 break;
5338 case 0x04: 5440 case 0x04:
5339 locale->DateFormat = GSM_Date_DDMMYYYY; 5441 locale->DateFormat = GSM_Date_DDMMYYYY;
5340 locale->DateSeparator = '/'; 5442 locale->DateSeparator = '/';
5341 break; 5443 break;
5342 case 0x05: 5444 case 0x05:
5343 locale->DateFormat = GSM_Date_MMDDYYYY; 5445 locale->DateFormat = GSM_Date_MMDDYYYY;
5344 locale->DateSeparator = '/'; 5446 locale->DateSeparator = '/';
5345 break; 5447 break;
5346 case 0x06: 5448 case 0x06:
5347 locale->DateFormat = GSM_Date_YYYYMMDD; 5449 locale->DateFormat = GSM_Date_YYYYMMDD;
5348 locale->DateSeparator = '/'; 5450 locale->DateSeparator = '/';
5349 break; 5451 break;
5350 case 0x08: 5452 case 0x08:
5351 locale->DateFormat = GSM_Date_DDMMYYYY; 5453 locale->DateFormat = GSM_Date_DDMMYYYY;
5352 locale->DateSeparator = '-'; 5454 locale->DateSeparator = '-';
5353 break; 5455 break;
5354 case 0x09: 5456 case 0x09:
5355 locale->DateFormat = GSM_Date_MMDDYYYY; 5457 locale->DateFormat = GSM_Date_MMDDYYYY;
5356 locale->DateSeparator = '-'; 5458 locale->DateSeparator = '-';
5357 break; 5459 break;
5358 case 0x0A: 5460 case 0x0A:
5359 locale->DateFormat = GSM_Date_YYYYMMDD; 5461 locale->DateFormat = GSM_Date_YYYYMMDD;
5360 locale->DateSeparator = '-'; 5462 locale->DateSeparator = '-';
5361 break; 5463 break;
5362 default:/* FIXME */ 5464 default:/* FIXME */
5363 locale->DateFormat = GSM_Date_DDMMYYYY; 5465 locale->DateFormat = GSM_Date_DDMMYYYY;
5364 locale->DateSeparator = '/'; 5466 locale->DateSeparator = '/';
5365 break; 5467 break;
5366 } 5468 }
5367 return ERR_NONE; 5469 return ERR_NONE;
5368 } 5470 }
5369 return ERR_UNKNOWNRESPONSE; 5471 return ERR_UNKNOWNRESPONSE;
5370} 5472}
5371 5473
5372static GSM_Error N6510_GetLocale(GSM_StateMachine *s, GSM_Locale *locale) 5474static GSM_Error N6510_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
5373{ 5475{
5374 unsigned char req[] = {N6110_FRAME_HEADER, 0x89}; 5476 unsigned char req[] = {N6110_FRAME_HEADER, 0x89};
5375 5477
5376 s->Phone.Data.Locale = locale; 5478 s->Phone.Data.Locale = locale;
5377 5479
5378 smprintf(s, "Getting date format\n"); 5480 smprintf(s, "Getting date format\n");
5379 return GSM_WaitFor (s, req, 4, 0x13, 4, ID_GetLocale); 5481 return GSM_WaitFor (s, req, 4, 0x13, 4, ID_GetLocale);
5380} 5482}
5381 5483
5382static GSM_Error N6510_ReplyGetCalendarSettings(GSM_Protocol_Message msg, GSM_StateMachine *s) 5484static GSM_Error N6510_ReplyGetCalendarSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
5383{ 5485{
5384 GSM_CalendarSettings *sett = s->Phone.Data.CalendarSettings; 5486 GSM_CalendarSettings *sett = s->Phone.Data.CalendarSettings;
5385 5487
5386 switch (msg.Buffer[3]) { 5488 switch (msg.Buffer[3]) {
5387 case 0x86: 5489 case 0x86:
5388 smprintf(s, "Auto deleting setting received\n"); 5490 smprintf(s, "Auto deleting setting received\n");
5389 sett->AutoDelete = msg.Buffer[4]; 5491 sett->AutoDelete = msg.Buffer[4];
5390 return ERR_NONE; 5492 return ERR_NONE;
5391 case 0x8E: 5493 case 0x8E:
5392 smprintf(s, "Start day for calendar received\n"); 5494 smprintf(s, "Start day for calendar received\n");
5393 switch(msg.Buffer[4]) { 5495 switch(msg.Buffer[4]) {
5394 case 0x03: 5496 case 0x03:
5395 sett->StartDay = 6; 5497 sett->StartDay = 6;
5396 return ERR_NONE; 5498 return ERR_NONE;
5397 case 0x02: 5499 case 0x02:
5398 sett->StartDay = 7; 5500 sett->StartDay = 7;
5399 return ERR_NONE; 5501 return ERR_NONE;
5400 case 0x01: 5502 case 0x01:
5401 sett->StartDay = 1; 5503 sett->StartDay = 1;
5402 return ERR_NONE; 5504 return ERR_NONE;
5403 } 5505 }
5404 break; 5506 break;
5405 } 5507 }
5406 return ERR_UNKNOWNRESPONSE; 5508 return ERR_UNKNOWNRESPONSE;
5407} 5509}
5408 5510
5409static GSM_Error N6510_GetCalendarSettings(GSM_StateMachine *s, GSM_CalendarSettings *settings) 5511static GSM_Error N6510_GetCalendarSettings(GSM_StateMachine *s, GSM_CalendarSettings *settings)
5410{ 5512{
5411 GSM_Errorerror; 5513 GSM_Errorerror;
5412 unsigned char req1[] = {N6110_FRAME_HEADER, 0x85}; 5514 unsigned char req1[] = {N6110_FRAME_HEADER, 0x85};
5413 unsigned char req2[] = {N6110_FRAME_HEADER, 0x8D}; 5515 unsigned char req2[] = {N6110_FRAME_HEADER, 0x8D};
5414 5516
5415 s->Phone.Data.CalendarSettings = settings; 5517 s->Phone.Data.CalendarSettings = settings;
5416 5518
5417 smprintf(s, "Getting auto delete\n"); 5519 smprintf(s, "Getting auto delete\n");
5418 error = GSM_WaitFor (s, req1, 4, 0x13, 4, ID_GetCalendarSettings); 5520 error = GSM_WaitFor (s, req1, 4, 0x13, 4, ID_GetCalendarSettings);
5419 if (error != ERR_NONE) return error; 5521 if (error != ERR_NONE) return error;
5420 5522
5421 smprintf(s, "Getting start day for week\n"); 5523 smprintf(s, "Getting start day for week\n");
5422 return GSM_WaitFor (s, req2, 4, 0x13, 4, ID_GetCalendarSettings); 5524 return GSM_WaitFor (s, req2, 4, 0x13, 4, ID_GetCalendarSettings);
5423} 5525}
5424 5526
5425GSM_Error N6510_CancelCall(GSM_StateMachine *s, int ID, bool all) 5527GSM_Error N6510_CancelCall(GSM_StateMachine *s, int ID, bool all)
5426{ 5528{
5427 if (all) return ERR_NOTSUPPORTED; 5529 if (all) return ERR_NOTSUPPORTED;
5428 return DCT3DCT4_CancelCall(s,ID); 5530 return DCT3DCT4_CancelCall(s,ID);
5429} 5531}
5430 5532
5431GSM_Error N6510_AnswerCall(GSM_StateMachine *s, int ID, bool all) 5533GSM_Error N6510_AnswerCall(GSM_StateMachine *s, int ID, bool all)
5432{ 5534{
5433 if (all) return ERR_NOTSUPPORTED; 5535 if (all) return ERR_NOTSUPPORTED;
5434 return DCT3DCT4_AnswerCall(s,ID); 5536 return DCT3DCT4_AnswerCall(s,ID);
5435} 5537}
5436 5538
5437static GSM_Error N6510_ReplyAddSMSFolder(GSM_Protocol_Message msg, GSM_StateMachine *s) 5539static GSM_Error N6510_ReplyAddSMSFolder(GSM_Protocol_Message msg, GSM_StateMachine *s)
5438{ 5540{
5439 smprintf(s,"SMS folder \"%s\" has been added\n",DecodeUnicodeString(msg.Buffer+10)); 5541 smprintf(s,"SMS folder \"%s\" has been added\n",DecodeUnicodeString(msg.Buffer+10));
5440 return ERR_NONE; 5542 return ERR_NONE;
5441} 5543}
5442 5544
5443GSM_Error N6510_AddSMSFolder(GSM_StateMachine *s, unsigned char *name) 5545GSM_Error N6510_AddSMSFolder(GSM_StateMachine *s, unsigned char *name)
5444{ 5546{
5445 unsigned char req[200] = {N6110_FRAME_HEADER, 0x10, 0x01, 0x00, 0x01, 5547 unsigned char req[200] = {N6110_FRAME_HEADER, 0x10, 0x01, 0x00, 0x01,
5446 0x00, /* Length */ 5548 0x00, /* Length */
5447 0x00, 0x00}; 5549 0x00, 0x00};
5448 5550
5449 5551
5450 CopyUnicodeString(req+10,name); 5552 CopyUnicodeString(req+10,name);
5451 req[7] = UnicodeLength(name)*2 + 6; 5553 req[7] = UnicodeLength(name)*2 + 6;
5452 5554
5453 smprintf(s, "Adding SMS folder\n"); 5555 smprintf(s, "Adding SMS folder\n");
5454 return GSM_WaitFor (s, req, req[7] + 6, 0x14, 4, ID_AddSMSFolder); 5556 return GSM_WaitFor (s, req, req[7] + 6, 0x14, 4, ID_AddSMSFolder);
5455} 5557}
5456 5558
5457static GSM_Error N6510_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 5559static GSM_Error N6510_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
5458{ 5560{
5459 GSM_Error error; 5561 GSM_Error error;
5460 int count=4, location; 5562 int count=4, location;
5461 unsigned char req[600] = {N6110_FRAME_HEADER, 0x09}; 5563 unsigned char req[600] = {N6110_FRAME_HEADER, 0x09};
5462 5564
5463 /* We have to enable WAP frames in phone */ 5565 /* We have to enable WAP frames in phone */
5464 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); 5566 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
5465 if (error!=ERR_NONE) return error; 5567 if (error!=ERR_NONE) return error;
5466 5568
5467 location = bookmark->Location - 1; 5569 location = bookmark->Location - 1;
5468 if (bookmark->Location == 0) location = 0xffff; 5570 if (bookmark->Location == 0) location = 0xffff;
5469 req[count++] = (location & 0xff00) >> 8; 5571 req[count++] = (location & 0xff00) >> 8;
5470 req[count++] = location & 0x00ff; 5572 req[count++] = location & 0x00ff;
5471 5573
5472 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Title, true); 5574 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Title, true);
5473 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Address, true); 5575 count += NOKIA_SetUnicodeString(s, req+count, bookmark->Address, true);
5474 5576
5475 req[count++] = 0x00; 5577 req[count++] = 0x00;
5476 req[count++] = 0x00; 5578 req[count++] = 0x00;
5477 req[count++] = 0x00; 5579 req[count++] = 0x00;
5478 req[count++] = 0x00; 5580 req[count++] = 0x00;
5479 5581
5480 smprintf(s, "Setting WAP bookmark\n"); 5582 smprintf(s, "Setting WAP bookmark\n");
5481 error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark); 5583 error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark);
5482 if (error != ERR_NONE) { 5584 if (error != ERR_NONE) {
5483 if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) { 5585 if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) {
5484 DCT3DCT4_DisableConnectionFunctions(s); 5586 DCT3DCT4_DisableConnectionFunctions(s);
5485 } 5587 }
5486 return error; 5588 return error;
5487 } 5589 }
5488 5590
5489 return DCT3DCT4_DisableConnectionFunctions(s); 5591 return DCT3DCT4_DisableConnectionFunctions(s);
5490} 5592}
5491 5593
5492GSM_Error N6510_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 5594GSM_Error N6510_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
5493{ 5595{
5494 GSM_Error error; 5596 GSM_Error error;
5495 5597
5496 /* We have to enable WAP frames in phone */ 5598 /* We have to enable WAP frames in phone */
5497 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); 5599 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
5498 if (error!=ERR_NONE) return error; 5600 if (error!=ERR_NONE) return error;
5499 5601
5500 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); 5602 return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
5501} 5603}
5502 5604
5503GSM_Error N6510_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) 5605GSM_Error N6510_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
5504{ 5606{
5505 GSM_Error error; 5607 GSM_Error error;
5506 5608
5507 /* We have to enable WAP frames in phone */ 5609 /* We have to enable WAP frames in phone */
5508 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); 5610 error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
5509 if (error!=ERR_NONE) return error; 5611 if (error!=ERR_NONE) return error;
5510 5612
5511 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); 5613 return DCT3DCT4_GetWAPBookmarkPart(s,bookmark);
5512} 5614}
5513 5615
5514static GSM_Reply_Function N6510ReplyFunctions[] = { 5616static GSM_Reply_Function N6510ReplyFunctions[] = {
5515 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame }, 5617 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
5516 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame }, 5618 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
5517 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame }, 5619 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
5518 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame }, 5620 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
5519 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall }, 5621 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
5520 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame }, 5622 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
5521 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall }, 5623 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
5522 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame }, 5624 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
5523 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame }, 5625 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
5524 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame }, 5626 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
5525 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice }, 5627 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice },
5526 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame }, 5628 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
5527 {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame }, 5629 {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame },
5528 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice }, 5630 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice },
5529 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame }, 5631 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame },
5530 {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame }, 5632 {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
5531 {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame }, 5633 {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
5532 {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame }, 5634 {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
5533 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF }, 5635 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
5534 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame }, 5636 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
5535 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF }, 5637 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
5536 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF }, 5638 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
5537 {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame }, 5639 {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame },
5538 {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame }, 5640 {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame },
5539 {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame }, 5641 {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame },
5540 5642
5541 {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame }, 5643 {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
5542 {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame }, 5644 {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame },
5543 {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC }, 5645 {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC },
5544 {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC }, 5646 {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC },
5545 5647
5546 {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, 5648 {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
5547 {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, 5649 {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
5548 {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory }, 5650 {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
5549 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap }, 5651 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
5550 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory }, 5652 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
5551 5653
5552 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert }, 5654 {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert },
5553 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame }, 5655 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
5554 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame }, 5656 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
5555 {NoneReply, "\x06",0x03,0x09,ID_IncomingFrame }, 5657 {NoneReply, "\x06",0x03,0x09,ID_IncomingFrame },
5556 5658
5557 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x08,ID_EnterSecurityCode }, 5659 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x08,ID_EnterSecurityCode },
5558 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x09,ID_EnterSecurityCode }, 5660 {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x09,ID_EnterSecurityCode },
5559 {N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus }, 5661 {N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus },
5560 5662
5561 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo }, 5663 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo },
5562 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame }, 5664 {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame },
5563 {N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame }, 5665 {N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame },
5564 {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality }, 5666 {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality },
5565 {N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame }, 5667 {N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame },
5566 {NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame }, 5668 {NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame },
5567 {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap }, 5669 {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap },
5568 {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap }, 5670 {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap },
5569 5671
5570 {NoneReply, "\x0B",0x03,0x01,ID_PlayTone }, 5672 {NoneReply, "\x0B",0x03,0x01,ID_PlayTone },
5571 {NoneReply, "\x0B",0x03,0x15,ID_PlayTone }, 5673 {NoneReply, "\x0B",0x03,0x15,ID_PlayTone },
5572 {NoneReply, "\x0B",0x03,0x16,ID_PlayTone }, 5674 {NoneReply, "\x0B",0x03,0x16,ID_PlayTone },
5573 5675
5574 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote }, 5676 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },
5575 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote }, 5677 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },
5576 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote }, 5678 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },
5577 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote }, 5679 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },
5578 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote }, 5680 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
5579 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ 5681 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
5580 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/ 5682 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
5581 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ 5683 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
5582#ifdef DEBUG 5684#ifdef DEBUG
5583 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote }, 5685 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },
5584#endif 5686#endif
5585 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/ 5687 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
5586 {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/ 5688 {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/
5587 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo }, 5689 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo },
5690 {N6510_ReplyAddNote, "\x13",0x03,0x66,ID_SetNote },
5588 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/ 5691 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/
5589 {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo }, 5692 {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo },
5590 {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote }, 5693 {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote },
5591 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings }, 5694 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings },
5592 {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale }, 5695 {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale },
5593 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings }, 5696 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings },
5594 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/ 5697 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/
5595 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo }, 5698 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo },
5699 {N6510_ReplyGetNoteFirstLoc, "\x13",0x03,0x96,ID_SetNote },
5596 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/ 5700 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/
5597 {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo }, 5701 {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo },
5598 {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote }, 5702 {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote },
5599 5703
5600 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage }, 5704 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage },
5601 {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap }, 5705 {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap },
5602 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage }, 5706 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage },
5603 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage }, 5707 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage },
5604 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage }, 5708 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage },
5605 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus }, 5709 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus },
5606 {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus }, 5710 {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus },
5607 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage }, 5711 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage },
5608 {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder }, 5712 {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder },
5609 {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders }, 5713 {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders },
5610 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage }, 5714 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage },
5611 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x1a,ID_GetSMSStatus }, 5715 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x1a,ID_GetSMSStatus },
5612 5716
5613 {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset }, 5717 {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset },
5614 {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset }, 5718 {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset },
5615 {NoneReply, "\x15",0x03,0x68,ID_Reset }, 5719 {NoneReply, "\x15",0x03,0x68,ID_Reset },
5616 5720
5617 {N6510_ReplyGetBatteryCharge, "\x17",0x03,0x0B,ID_GetBatteryCharge }, 5721 {N6510_ReplyGetBatteryCharge, "\x17",0x03,0x0B,ID_GetBatteryCharge },
5618 5722
5619 {N6510_ReplySetDateTime, "\x19",0x03,0x02,ID_SetDateTime }, 5723 {N6510_ReplySetDateTime, "\x19",0x03,0x02,ID_SetDateTime },
5620 {N6510_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime }, 5724 {N6510_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime },
5621 {N6510_ReplySetAlarm, "\x19",0x03,0x12,ID_SetAlarm }, 5725 {N6510_ReplySetAlarm, "\x19",0x03,0x12,ID_SetAlarm },
5622 {N6510_ReplyGetAlarm, "\x19",0x03,0x1A,ID_GetAlarm }, 5726 {N6510_ReplyGetAlarm, "\x19",0x03,0x1A,ID_GetAlarm },
5623 {N6510_ReplyGetAlarm, "\x19",0x03,0x20,ID_GetAlarm }, 5727 {N6510_ReplyGetAlarm, "\x19",0x03,0x20,ID_GetAlarm },
5624 5728
5625 {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI }, 5729 {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI },
5626 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware }, 5730 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware },
5627 {N6510_ReplyGetPPM, "\x1B",0x03,0x08,ID_GetPPM }, 5731 {N6510_ReplyGetPPM, "\x1B",0x03,0x08,ID_GetPPM },
5628 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode }, 5732 {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode },
5629 5733
5630 /* 0x1C - vibra */ 5734 /* 0x1C - vibra */
5631 5735
5632 {N6510_ReplyGetRingtonesInfo, "\x1f",0x03,0x08,ID_GetRingtonesInfo }, 5736 {N6510_ReplyGetRingtonesInfo, "\x1f",0x03,0x08,ID_GetRingtonesInfo },
5633 {N6510_ReplyDeleteRingtones, "\x1f",0x03,0x11,ID_SetRingtone }, 5737 {N6510_ReplyDeleteRingtones, "\x1f",0x03,0x11,ID_SetRingtone },
5634 {N6510_ReplyGetRingtone, "\x1f",0x03,0x13,ID_GetRingtone }, 5738 {N6510_ReplyGetRingtone, "\x1f",0x03,0x13,ID_GetRingtone },
5635 {N6510_ReplySetBinRingtone, "\x1f",0x03,0x0F,ID_SetRingtone }, 5739 {N6510_ReplySetBinRingtone, "\x1f",0x03,0x0F,ID_SetRingtone },
5636 5740
5637 /* 0x23 - voice records */ 5741 /* 0x23 - voice records */
5638 5742
5639 {N6510_ReplyGetProfile, "\x39",0x03,0x02,ID_GetProfile }, 5743 {N6510_ReplyGetProfile, "\x39",0x03,0x02,ID_GetProfile },
5640 {N6510_ReplySetProfile, "\x39",0x03,0x04,ID_SetProfile }, 5744 {N6510_ReplySetProfile, "\x39",0x03,0x04,ID_SetProfile },
5641 {N6510_ReplyGetProfile, "\x39",0x03,0x06,ID_GetProfile }, 5745 {N6510_ReplyGetProfile, "\x39",0x03,0x06,ID_GetProfile },
5642 5746
5643 {N6510_ReplySetLight, "\x3A",0x03,0x06,ID_SetLight }, 5747 {N6510_ReplySetLight, "\x3A",0x03,0x06,ID_SetLight },
5644 5748
5645 {N6510_ReplyGetFMStation, "\x3E",0x03,0x06,ID_GetFMStation }, 5749 {N6510_ReplyGetFMStation, "\x3E",0x03,0x06,ID_GetFMStation },
5646 {N6510_ReplyGetFMStatus, "\x3E",0x03,0x0E,ID_GetFMStation }, 5750 {N6510_ReplyGetFMStatus, "\x3E",0x03,0x0E,ID_GetFMStation },
5647 {N6510_ReplySetFMStation, "\x3E",0x03,0x15,ID_SetFMStation }, 5751 {N6510_ReplySetFMStation, "\x3E",0x03,0x15,ID_SetFMStation },
5648 {N6510_ReplyGetFMStation, "\x3E",0x03,0x16,ID_GetFMStation }, 5752 {N6510_ReplyGetFMStation, "\x3E",0x03,0x16,ID_GetFMStation },
5649 5753
5650 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc }, 5754 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc },
5651 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc }, 5755 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
5652 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc }, 5756 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc },
5653 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc }, 5757 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
5654 {N6510_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark }, 5758 {N6510_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
5655 {N6510_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark }, 5759 {N6510_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
5656 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark }, 5760 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
5657 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark }, 5761 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
5658 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark }, 5762 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
5659 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark }, 5763 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
5660 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet }, 5764 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet },
5661 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet }, 5765 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet },
5662 {N6510_ReplyGetConnectionSettings,"\x3f",0x03,0x16,ID_GetConnectSet }, 5766 {N6510_ReplyGetConnectionSettings,"\x3f",0x03,0x16,ID_GetConnectSet },
5663 {N6510_ReplyGetConnectionSettings,"\x3f",0x03,0x17,ID_GetConnectSet }, 5767 {N6510_ReplyGetConnectionSettings,"\x3f",0x03,0x17,ID_GetConnectSet },
5664 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x19,ID_SetConnectSet }, 5768 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x19,ID_SetConnectSet },
5665 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x1A,ID_SetConnectSet }, 5769 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x1A,ID_SetConnectSet },
5666 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x28,ID_SetConnectSet }, 5770 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x28,ID_SetConnectSet },
5667 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x2B,ID_SetConnectSet }, 5771 {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x2B,ID_SetConnectSet },
5668 {N6510_ReplyGetChatSettings, "\x3f",0x03,0x3B,ID_GetChatSettings }, 5772 {N6510_ReplyGetChatSettings, "\x3f",0x03,0x3B,ID_GetChatSettings },
5669 {N6510_ReplyGetChatSettings, "\x3f",0x03,0x3C,ID_GetChatSettings }, 5773 {N6510_ReplyGetChatSettings, "\x3f",0x03,0x3C,ID_GetChatSettings },
5670 5774
5671 {N6510_ReplyGetOriginalIMEI, "\x42",0x07,0x00,ID_GetOriginalIMEI }, 5775 {N6510_ReplyGetOriginalIMEI, "\x42",0x07,0x00,ID_GetOriginalIMEI },
5672 {N6510_ReplyGetManufactureMonth, "\x42",0x07,0x00,ID_GetManufactureMonth }, 5776 {N6510_ReplyGetManufactureMonth, "\x42",0x07,0x00,ID_GetManufactureMonth },
5673 {N6510_ReplyGetOriginalIMEI, "\x42",0x07,0x01,ID_GetOriginalIMEI }, 5777 {N6510_ReplyGetOriginalIMEI, "\x42",0x07,0x01,ID_GetOriginalIMEI },
5674 {N6510_ReplyGetManufactureMonth, "\x42",0x07,0x02,ID_GetManufactureMonth }, 5778 {N6510_ReplyGetManufactureMonth, "\x42",0x07,0x02,ID_GetManufactureMonth },
5675 5779
5676 {N6510_ReplySetOperatorLogo, "\x43",0x03,0x08,ID_SetBitmap }, 5780 {N6510_ReplySetOperatorLogo, "\x43",0x03,0x08,ID_SetBitmap },
5677 {N6510_ReplyGetGPRSAccessPoint, "\x43",0x03,0x06,ID_GetGPRSPoint }, 5781 {N6510_ReplyGetGPRSAccessPoint, "\x43",0x03,0x06,ID_GetGPRSPoint },
5678 {N6510_ReplySetGPRSAccessPoint1, "\x43",0x03,0x06,ID_SetGPRSPoint }, 5782 {N6510_ReplySetGPRSAccessPoint1, "\x43",0x03,0x06,ID_SetGPRSPoint },
5679#ifdef DEVELOP 5783#ifdef DEVELOP
5680 {N6510_ReplyEnableGPRSAccessPoint,"\x43",0x03,0x06,ID_EnableGPRSPoint }, 5784 {N6510_ReplyEnableGPRSAccessPoint,"\x43",0x03,0x06,ID_EnableGPRSPoint },
5681#endif 5785#endif
5682 {N6510_ReplyGetSyncMLSettings, "\x43",0x03,0x06,ID_GetSyncMLSettings }, 5786 {N6510_ReplyGetSyncMLSettings, "\x43",0x03,0x06,ID_GetSyncMLSettings },
5683 {N6510_ReplyGetSyncMLName, "\x43",0x03,0x06,ID_GetSyncMLName }, 5787 {N6510_ReplyGetSyncMLName, "\x43",0x03,0x06,ID_GetSyncMLName },
5684 {NoneReply, "\x43",0x03,0x08,ID_SetGPRSPoint }, 5788 {NoneReply, "\x43",0x03,0x08,ID_SetGPRSPoint },
5685 5789
5686 /* 0x4A - voice records */ 5790 /* 0x4A - voice records */
5687 5791
5688 /* 0x53 - simlock */ 5792 /* 0x53 - simlock */
5689 5793
5690 {N6510_ReplyAddToDo1, "\x55",0x03,0x02,ID_SetToDo }, 5794 {N6510_ReplyAddToDo1, "\x55",0x03,0x02,ID_SetToDo },
5691 {N6510_ReplyGetToDo1, "\x55",0x03,0x04,ID_GetToDo }, 5795 {N6510_ReplyGetToDo1, "\x55",0x03,0x04,ID_GetToDo },
5692 {N6510_ReplyGetToDoFirstLoc1, "\x55",0x03,0x10,ID_SetToDo }, 5796 {N6510_ReplyGetToDoFirstLoc1, "\x55",0x03,0x10,ID_SetToDo },
5693 {N6510_ReplyDeleteAllToDo1, "\x55",0x03,0x12,ID_DeleteAllToDo }, 5797 {N6510_ReplyDeleteAllToDo1, "\x55",0x03,0x12,ID_DeleteAllToDo },
5694 {N6510_ReplyGetToDoStatus1, "\x55",0x03,0x16,ID_GetToDo }, 5798 {N6510_ReplyGetToDoStatus1, "\x55",0x03,0x16,ID_GetToDo },
5695 5799
5696 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x03,ID_AddFile }, 5800 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x03,ID_AddFile },
5697 {N6510_ReplyAddFolder, "\x6D",0x03,0x05,ID_AddFolder }, 5801 {N6510_ReplyAddFolder, "\x6D",0x03,0x05,ID_AddFolder },
5698 {N6510_ReplyGetFilePart, "\x6D",0x03,0x0F,ID_GetFile }, 5802 {N6510_ReplyGetFilePart, "\x6D",0x03,0x0F,ID_GetFile },
5699 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x13,ID_AddFile }, 5803 {N6510_ReplyAddFileHeader, "\x6D",0x03,0x13,ID_AddFile },
5700 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFileInfo }, 5804 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFileInfo },
5701 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFile }, 5805 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFile },
5702 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_AddFile }, 5806 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_AddFile },
5703 {N6510_ReplyDeleteFile, "\x6D",0x03,0x19,ID_DeleteFile }, 5807 {N6510_ReplyDeleteFile, "\x6D",0x03,0x19,ID_DeleteFile },
5704 {N6510_ReplyDeleteFile, "\x6D",0x03,0x1F,ID_DeleteFile }, 5808 {N6510_ReplyDeleteFile, "\x6D",0x03,0x1F,ID_DeleteFile },
5705 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x23,ID_FileSystemStatus }, 5809 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x23,ID_FileSystemStatus },
5706 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFileInfo }, 5810 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFileInfo },
5707 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFile }, 5811 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFile },
5708 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x2F,ID_FileSystemStatus }, 5812 {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x2F,ID_FileSystemStatus },
5709 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFileInfo }, 5813 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFileInfo },
5710 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFile }, 5814 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFile },
5711 {N6510_ReplyAddFilePart, "\x6D",0x03,0x41,ID_AddFile }, 5815 {N6510_ReplyAddFilePart, "\x6D",0x03,0x41,ID_AddFile },
5712 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_AddFile }, 5816 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_AddFile },
5713 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFile }, 5817 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFile },
5714 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFileInfo }, 5818 {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFileInfo },
5715 5819
5716 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_GetBitmap }, 5820 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_GetBitmap },
5717 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_SetBitmap }, 5821 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_SetBitmap },
5718 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_GetBitmap }, 5822 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_GetBitmap },
5719 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_SetBitmap }, 5823 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_SetBitmap },
5720 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_GetBitmap }, 5824 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_GetBitmap },
5721 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_SetBitmap }, 5825 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_SetBitmap },
5722 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x25,ID_SetBitmap }, 5826 {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x25,ID_SetBitmap },
5723 5827
5724 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, 5828 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
5725 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, 5829 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
5726 5830
5727 /* 0xD7 - Bluetooth */ 5831 /* 0xD7 - Bluetooth */
5728 5832
5729 {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone }, 5833 {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone },
5730 5834
5731 {NULL, "\x00",0x00,0x00,ID_None } 5835 {NULL, "\x00",0x00,0x00,ID_None }
5732}; 5836};
5733 5837
5734GSM_Phone_Functions N6510Phone = { 5838GSM_Phone_Functions N6510Phone = {
5735 "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i", 5839 "1100|1100a|1100b|3100|3100b|3105|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i",
5736 N6510ReplyFunctions, 5840 N6510ReplyFunctions,
5737 N6510_Initialise, 5841 N6510_Initialise,
5738 NONEFUNCTION, /* Terminate */ 5842 NONEFUNCTION, /* Terminate */
5739 GSM_DispatchMessage, 5843 GSM_DispatchMessage,
5740 N6510_ShowStartInfo, 5844 N6510_ShowStartInfo,
5741 NOKIA_GetManufacturer, 5845 NOKIA_GetManufacturer,
5742 DCT3DCT4_GetModel, 5846 DCT3DCT4_GetModel,
5743 DCT3DCT4_GetFirmware, 5847 DCT3DCT4_GetFirmware,
5744 DCT4_GetIMEI, 5848 DCT4_GetIMEI,
5745 N6510_GetOriginalIMEI, 5849 N6510_GetOriginalIMEI,
5746 N6510_GetManufactureMonth, 5850 N6510_GetManufactureMonth,
5747 DCT4_GetProductCode, 5851 DCT4_GetProductCode,
5748 DCT4_GetHardware, 5852 DCT4_GetHardware,
5749 N6510_GetPPM, 5853 N6510_GetPPM,
5750 NOTSUPPORTED, /* GetSIMIMSI */ 5854 NOTSUPPORTED, /* GetSIMIMSI */
5751 N6510_GetDateTime, 5855 N6510_GetDateTime,
5752 N6510_SetDateTime, 5856 N6510_SetDateTime,
5753 N6510_GetAlarm, 5857 N6510_GetAlarm,
5754 N6510_SetAlarm, 5858 N6510_SetAlarm,
5755 N6510_GetLocale, 5859 N6510_GetLocale,
5756 NOTSUPPORTED, /* SetLocale */ 5860 NOTSUPPORTED, /* SetLocale */
5757 N6510_PressKey, 5861 N6510_PressKey,
5758 DCT4_Reset, 5862 DCT4_Reset,
5759 NOTIMPLEMENTED, /* ResetPhoneSettings*/ 5863 NOTIMPLEMENTED, /* ResetPhoneSettings*/
5760 N6510_EnterSecurityCode, 5864 N6510_EnterSecurityCode,
5761 N6510_GetSecurityStatus, 5865 N6510_GetSecurityStatus,
5762 NOTSUPPORTED, /* GetDisplayStatus*/ 5866 NOTSUPPORTED, /* GetDisplayStatus*/
5763 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 5867 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
5764 N6510_GetBatteryCharge, 5868 N6510_GetBatteryCharge,
5765 N6510_GetSignalQuality, 5869 N6510_GetSignalQuality,
5766 N6510_GetNetworkInfo, 5870 N6510_GetNetworkInfo,
5767 NOTSUPPORTED, /* GetCategory */ 5871 NOTSUPPORTED, /* GetCategory */
5768 NOTSUPPORTED, /* AddCategory */ 5872 NOTSUPPORTED, /* AddCategory */
5769 NOTSUPPORTED, /* GetCategoryStatus */ 5873 NOTSUPPORTED, /* GetCategoryStatus */
5770 N6510_GetMemoryStatus, 5874 N6510_GetMemoryStatus,
5771 N6510_GetMemory, 5875 N6510_GetMemory,
5772 NOTIMPLEMENTED, /* GetNextMemory */ 5876 NOTIMPLEMENTED, /* GetNextMemory */
5773 N6510_SetMemory, 5877 N6510_SetMemory,
5774 NOTIMPLEMENTED, /* AddMemory */ 5878 NOTIMPLEMENTED, /* AddMemory */
5775 N6510_DeleteMemory, 5879 N6510_DeleteMemory,
5776 NOTIMPLEMENTED, /* DeleteAllMemory */ 5880 NOTIMPLEMENTED, /* DeleteAllMemory */
5777 N6510_GetSpeedDial, 5881 N6510_GetSpeedDial,
5778 NOTIMPLEMENTED, /* SetSpeedDial */ 5882 NOTIMPLEMENTED, /* SetSpeedDial */
5779 N6510_GetSMSC, 5883 N6510_GetSMSC,
5780 N6510_SetSMSC, 5884 N6510_SetSMSC,
5781 N6510_GetSMSStatus, 5885 N6510_GetSMSStatus,
5782 N6510_GetSMSMessage, 5886 N6510_GetSMSMessage,
5783 N6510_GetNextSMSMessage, 5887 N6510_GetNextSMSMessage,
5784 N6510_SetSMS, 5888 N6510_SetSMS,
5785 N6510_AddSMS, 5889 N6510_AddSMS,
5786 N6510_DeleteSMSMessage, 5890 N6510_DeleteSMSMessage,
5787 N6510_SendSMSMessage, 5891 N6510_SendSMSMessage,
5788 NOTSUPPORTED, /* SendSavedSMS */ 5892 NOTSUPPORTED, /* SendSavedSMS */
5789 NOTSUPPORTED, /* SetFastSMSSending*/ 5893 NOTSUPPORTED, /* SetFastSMSSending*/
5790 NOKIA_SetIncomingSMS, 5894 NOKIA_SetIncomingSMS,
5791 NOTIMPLEMENTED, /* SetIncomingCB */ 5895 NOTIMPLEMENTED, /* SetIncomingCB */
5792 N6510_GetSMSFolders, 5896 N6510_GetSMSFolders,
5793 N6510_AddSMSFolder, 5897 N6510_AddSMSFolder,
5794 NOTIMPLEMENTED, /* DeleteSMSFolder */ 5898 NOTIMPLEMENTED, /* DeleteSMSFolder */
5795 N6510_DialVoice, 5899 N6510_DialVoice,
5796 N6510_AnswerCall, 5900 N6510_AnswerCall,
5797 N6510_CancelCall, 5901 N6510_CancelCall,
5798 NOTIMPLEMENTED, /* HoldCall */ 5902 NOTIMPLEMENTED, /* HoldCall */
5799 NOTIMPLEMENTED, /* UnholdCall */ 5903 NOTIMPLEMENTED, /* UnholdCall */
5800 NOTIMPLEMENTED, /* ConferenceCall */ 5904 NOTIMPLEMENTED, /* ConferenceCall */
5801 NOTIMPLEMENTED, /* SplitCall */ 5905 NOTIMPLEMENTED, /* SplitCall */
5802 NOTIMPLEMENTED, /* TransferCall */ 5906 NOTIMPLEMENTED, /* TransferCall */
5803 NOTIMPLEMENTED, /* SwitchCall */ 5907 NOTIMPLEMENTED, /* SwitchCall */
5804 DCT3DCT4_GetCallDivert, 5908 DCT3DCT4_GetCallDivert,
5805 DCT3DCT4_SetCallDivert, 5909 DCT3DCT4_SetCallDivert,
5806 DCT3DCT4_CancelAllDiverts, 5910 DCT3DCT4_CancelAllDiverts,
5807 NOKIA_SetIncomingCall, 5911 NOKIA_SetIncomingCall,
5808 NOKIA_SetIncomingUSSD, 5912 NOKIA_SetIncomingUSSD,
5809 DCT3DCT4_SendDTMF, 5913 DCT3DCT4_SendDTMF,
5810 N6510_GetRingtone, 5914 N6510_GetRingtone,
5811 N6510_SetRingtone, 5915 N6510_SetRingtone,
5812 N6510_GetRingtonesInfo, 5916 N6510_GetRingtonesInfo,
5813 N6510_DeleteUserRingtones, 5917 N6510_DeleteUserRingtones,
5814 N6510_PlayTone, 5918 N6510_PlayTone,
5815 N6510_GetWAPBookmark, 5919 N6510_GetWAPBookmark,
5816 N6510_SetWAPBookmark, 5920 N6510_SetWAPBookmark,
5817 N6510_DeleteWAPBookmark, 5921 N6510_DeleteWAPBookmark,
5818 N6510_GetWAPSettings, 5922 N6510_GetWAPSettings,
5819 N6510_SetWAPSettings, 5923 N6510_SetWAPSettings,
5820 N6510_GetMMSSettings, 5924 N6510_GetMMSSettings,
5821 N6510_SetMMSSettings, 5925 N6510_SetMMSSettings,
5822 N6510_GetSyncMLSettings, 5926 N6510_GetSyncMLSettings,
5823 NOTSUPPORTED, /* SetSyncMLSettings*/ 5927 NOTSUPPORTED, /* SetSyncMLSettings*/
5824 N6510_GetChatSettings, 5928 N6510_GetChatSettings,
5825 NOTSUPPORTED, /* SetChatSettings */ 5929 NOTSUPPORTED, /* SetChatSettings */
5826 N6510_GetBitmap, 5930 N6510_GetBitmap,
5827 N6510_SetBitmap, 5931 N6510_SetBitmap,
5828 N6510_GetToDoStatus, 5932 N6510_GetToDoStatus,
5829 NOTIMPLEMENTED, /* GetToDo */ 5933 NOTIMPLEMENTED, /* GetToDo */
5830 N6510_GetNextToDo, 5934 N6510_GetNextToDo,
5831 NOTIMPLEMENTED, /* SetToDo */ 5935 NOTIMPLEMENTED, /* SetToDo */
5832 N6510_AddToDo, 5936 N6510_AddToDo,
5833 N6510_DeleteToDo2, 5937 N6510_DeleteToDo2,
5834 N6510_DeleteAllToDo1, 5938 N6510_DeleteAllToDo1,
5835 N6510_GetCalendarStatus, 5939 N6510_GetCalendarStatus,
5836 NOTIMPLEMENTED, /* GetCalendar */ 5940 NOTIMPLEMENTED, /* GetCalendar */
5837 N6510_GetNextCalendar, 5941 N6510_GetNextCalendar,
5838 NOTIMPLEMENTED, /* SetCalendar */ 5942 NOTIMPLEMENTED, /* SetCalendar */
5839 N6510_AddCalendar, 5943 N6510_AddCalendar,
5840 N71_65_DelCalendar, 5944 N71_65_DelCalendar,
5841 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 5945 NOTIMPLEMENTED, /* DeleteAllCalendar*/
5842 N6510_GetCalendarSettings, 5946 N6510_GetCalendarSettings,
5843 NOTSUPPORTED, /* SetCalendarSettings*/ 5947 NOTSUPPORTED, /* SetCalendarSettings*/
5948 N6510_GetNoteStatus,
5949 NOTIMPLEMENTED, /* GetNote */
5844 N6510_GetNextNote, 5950 N6510_GetNextNote,
5951 NOTIMPLEMENTED, /* SetNote */
5952 N6510_AddNote,
5953 N6510_DeleteNote,
5954 NOTSUPPORTED, /* DeleteAllNotes */
5845 N6510_GetProfile, 5955 N6510_GetProfile,
5846 N6510_SetProfile, 5956 N6510_SetProfile,
5847 N6510_GetFMStation, 5957 N6510_GetFMStation,
5848 N6510_SetFMStation, 5958 N6510_SetFMStation,
5849 N6510_ClearFMStations, 5959 N6510_ClearFMStations,
5850 N6510_GetNextFileFolder, 5960 N6510_GetNextFileFolder,
5851 N6510_GetFilePart, 5961 N6510_GetFilePart,
5852 N6510_AddFilePart, 5962 N6510_AddFilePart,
5853 N6510_GetFileSystemStatus, 5963 N6510_GetFileSystemStatus,
5854 N6510_DeleteFile, 5964 N6510_DeleteFile,
5855 N6510_AddFolder, 5965 N6510_AddFolder,
5856 N6510_GetGPRSAccessPoint, 5966 N6510_GetGPRSAccessPoint,
5857 N6510_SetGPRSAccessPoint 5967 N6510_SetGPRSAccessPoint
5858}; 5968};
5859 5969
5860#endif 5970#endif
5861 5971
5862/* How should editor hadle tabs in this file? Add editor commands here. 5972/* How should editor hadle tabs in this file? Add editor commands here.
5863 * vim: noexpandtab sw=8 ts=8 sts=8: 5973 * vim: noexpandtab sw=8 ts=8 sts=8:
5864 */ 5974 */
diff --git a/gammu/emb/common/phone/nokia/nauto.c b/gammu/emb/common/phone/nokia/nauto.c
index 3bb53ec..3c7f2cd 100644
--- a/gammu/emb/common/phone/nokia/nauto.c
+++ b/gammu/emb/common/phone/nokia/nauto.c
@@ -1,144 +1,150 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4#include <time.h> 4#include <time.h>
5 5
6#include "../../gsmcomon.h" 6#include "../../gsmcomon.h"
7#include "../../gsmstate.h" 7#include "../../gsmstate.h"
8#include "nfunc.h" 8#include "nfunc.h"
9 9
10#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 10#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
11 11
12static GSM_Reply_Function NAUTOReplyFunctions[] = { 12static GSM_Reply_Function NAUTOReplyFunctions[] = {
13 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel }, 13 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel },
14 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware }, 14 {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware },
15 15
16 {NULL, "\x00",0x00,0x00,ID_None } 16 {NULL, "\x00",0x00,0x00,ID_None }
17}; 17};
18 18
19GSM_Phone_Functions NAUTOPhone = { 19GSM_Phone_Functions NAUTOPhone = {
20 "NAUTO", 20 "NAUTO",
21 NAUTOReplyFunctions, 21 NAUTOReplyFunctions,
22 NONEFUNCTION, /* Initialise */ 22 NONEFUNCTION, /* Initialise */
23 NONEFUNCTION, /* Terminate */ 23 NONEFUNCTION, /* Terminate */
24 GSM_DispatchMessage, 24 GSM_DispatchMessage,
25 NOTSUPPORTED, /* ShowStartInfo */ 25 NOTSUPPORTED, /* ShowStartInfo */
26 NOKIA_GetManufacturer, 26 NOKIA_GetManufacturer,
27 DCT3DCT4_GetModel, 27 DCT3DCT4_GetModel,
28 DCT3DCT4_GetFirmware, 28 DCT3DCT4_GetFirmware,
29 NOTSUPPORTED, /* GetIMEI */ 29 NOTSUPPORTED, /* GetIMEI */
30 NOTSUPPORTED, /* GetOriginalIMEI */ 30 NOTSUPPORTED, /* GetOriginalIMEI */
31 NOTSUPPORTED, /* GetManufactureMonth*/ 31 NOTSUPPORTED, /* GetManufactureMonth*/
32 NOTSUPPORTED, /* GetProductCode */ 32 NOTSUPPORTED, /* GetProductCode */
33 NOTSUPPORTED, /* GetHardware */ 33 NOTSUPPORTED, /* GetHardware */
34 NOTSUPPORTED, /* GetPPM */ 34 NOTSUPPORTED, /* GetPPM */
35 NOTSUPPORTED, /* GetSIMIMSI */ 35 NOTSUPPORTED, /* GetSIMIMSI */
36 NOTSUPPORTED, /* GetDateTime */ 36 NOTSUPPORTED, /* GetDateTime */
37 NOTSUPPORTED, /* SetDateTime */ 37 NOTSUPPORTED, /* SetDateTime */
38 NOTSUPPORTED, /* GetAlarm */ 38 NOTSUPPORTED, /* GetAlarm */
39 NOTSUPPORTED, /* SetAlarm */ 39 NOTSUPPORTED, /* SetAlarm */
40 NOTSUPPORTED, /* GetLocale */ 40 NOTSUPPORTED, /* GetLocale */
41 NOTSUPPORTED, /* SetLocale */ 41 NOTSUPPORTED, /* SetLocale */
42 NOTSUPPORTED, /* PressKey */ 42 NOTSUPPORTED, /* PressKey */
43 NOTSUPPORTED, /* Reset */ 43 NOTSUPPORTED, /* Reset */
44 NOTSUPPORTED, /* ResetPhoneSettings*/ 44 NOTSUPPORTED, /* ResetPhoneSettings*/
45 NOTSUPPORTED, /* EnterSecurityCode*/ 45 NOTSUPPORTED, /* EnterSecurityCode*/
46 NOTSUPPORTED, /* GetSecurityStatus*/ 46 NOTSUPPORTED, /* GetSecurityStatus*/
47 NOTSUPPORTED, /* GetDisplayStatus*/ 47 NOTSUPPORTED, /* GetDisplayStatus*/
48 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 48 NOTSUPPORTED, /* SetAutoNetworkLogin*/
49 NOTSUPPORTED, /* GetBatteryCharge*/ 49 NOTSUPPORTED, /* GetBatteryCharge*/
50 NOTSUPPORTED, /* GetSignalQuality*/ 50 NOTSUPPORTED, /* GetSignalQuality*/
51 NOTSUPPORTED, /* GetNetworkInfo */ 51 NOTSUPPORTED, /* GetNetworkInfo */
52 NOTSUPPORTED, /* GetCategory */ 52 NOTSUPPORTED, /* GetCategory */
53 NOTSUPPORTED, /* AddCategory */ 53 NOTSUPPORTED, /* AddCategory */
54 NOTSUPPORTED, /* GetCategoryStatus */ 54 NOTSUPPORTED, /* GetCategoryStatus */
55 NOTSUPPORTED, /* GetMemoryStatus */ 55 NOTSUPPORTED, /* GetMemoryStatus */
56 NOTSUPPORTED, /* GetMemory */ 56 NOTSUPPORTED, /* GetMemory */
57 NOTSUPPORTED, /* GetNextMemory */ 57 NOTSUPPORTED, /* GetNextMemory */
58 NOTSUPPORTED, /* SetMemory */ 58 NOTSUPPORTED, /* SetMemory */
59 NOTSUPPORTED, /* AddMemory */ 59 NOTSUPPORTED, /* AddMemory */
60 NOTSUPPORTED, /* DeleteMemory */ 60 NOTSUPPORTED, /* DeleteMemory */
61 NOTIMPLEMENTED, /* DeleteAllMemory */ 61 NOTIMPLEMENTED, /* DeleteAllMemory */
62 NOTSUPPORTED, /* GetSpeedDial */ 62 NOTSUPPORTED, /* GetSpeedDial */
63 NOTSUPPORTED, /* SetSpeedDial */ 63 NOTSUPPORTED, /* SetSpeedDial */
64 NOTSUPPORTED, /* GetSMSC */ 64 NOTSUPPORTED, /* GetSMSC */
65 NOTSUPPORTED, /* SetSMSC */ 65 NOTSUPPORTED, /* SetSMSC */
66 NOTSUPPORTED, /* GetSMSStatus */ 66 NOTSUPPORTED, /* GetSMSStatus */
67 NOTSUPPORTED, /* GetSMS */ 67 NOTSUPPORTED, /* GetSMS */
68 NOTSUPPORTED, /* GetNextSMS */ 68 NOTSUPPORTED, /* GetNextSMS */
69 NOTSUPPORTED, /* SetSMS */ 69 NOTSUPPORTED, /* SetSMS */
70 NOTSUPPORTED, /* AddSMS */ 70 NOTSUPPORTED, /* AddSMS */
71 NOTSUPPORTED, /* DeleteSMS */ 71 NOTSUPPORTED, /* DeleteSMS */
72 NOTSUPPORTED, /* SendSMSMessage */ 72 NOTSUPPORTED, /* SendSMSMessage */
73 NOTSUPPORTED, /* SendSavedSMS */ 73 NOTSUPPORTED, /* SendSavedSMS */
74 NOTSUPPORTED, /* SetIncomingSMS */ 74 NOTSUPPORTED, /* SetIncomingSMS */
75 NOTSUPPORTED, /* SetIncomingCB */ 75 NOTSUPPORTED, /* SetIncomingCB */
76 NOTSUPPORTED, /* GetSMSFolders */ 76 NOTSUPPORTED, /* GetSMSFolders */
77 NOTSUPPORTED, /* AddSMSFolder */ 77 NOTSUPPORTED, /* AddSMSFolder */
78 NOTSUPPORTED, /* DeleteSMSFolder */ 78 NOTSUPPORTED, /* DeleteSMSFolder */
79 NOTSUPPORTED, /* DialVoice */ 79 NOTSUPPORTED, /* DialVoice */
80 NOTSUPPORTED, /* AnswerCall */ 80 NOTSUPPORTED, /* AnswerCall */
81 NOTSUPPORTED, /* CancelCall */ 81 NOTSUPPORTED, /* CancelCall */
82 NOTSUPPORTED, /* HoldCall */ 82 NOTSUPPORTED, /* HoldCall */
83 NOTSUPPORTED, /* UnholdCall */ 83 NOTSUPPORTED, /* UnholdCall */
84 NOTSUPPORTED, /* ConferenceCall */ 84 NOTSUPPORTED, /* ConferenceCall */
85 NOTSUPPORTED, /* SplitCall */ 85 NOTSUPPORTED, /* SplitCall */
86 NOTSUPPORTED, /* TransferCall */ 86 NOTSUPPORTED, /* TransferCall */
87 NOTSUPPORTED, /* SwitchCall */ 87 NOTSUPPORTED, /* SwitchCall */
88 NOTSUPPORTED, /* GetCallDivert */ 88 NOTSUPPORTED, /* GetCallDivert */
89 NOTSUPPORTED, /* SetCallDivert */ 89 NOTSUPPORTED, /* SetCallDivert */
90 NOTSUPPORTED, /* CancelAllDiverts*/ 90 NOTSUPPORTED, /* CancelAllDiverts*/
91 NOTSUPPORTED, /* SetIncomingCall */ 91 NOTSUPPORTED, /* SetIncomingCall */
92 NOTSUPPORTED, /* SetIncomingUSSD */ 92 NOTSUPPORTED, /* SetIncomingUSSD */
93 NOTSUPPORTED, /* SendDTMF */ 93 NOTSUPPORTED, /* SendDTMF */
94 NOTSUPPORTED, /* GetRingtone */ 94 NOTSUPPORTED, /* GetRingtone */
95 NOTSUPPORTED, /* SetRingtone */ 95 NOTSUPPORTED, /* SetRingtone */
96 NOTSUPPORTED, /* GetRingtonesInfo*/ 96 NOTSUPPORTED, /* GetRingtonesInfo*/
97 NOTSUPPORTED, /* DeleteUserRingtones*/ 97 NOTSUPPORTED, /* DeleteUserRingtones*/
98 NOTSUPPORTED, /* PlayTone */ 98 NOTSUPPORTED, /* PlayTone */
99 NOTSUPPORTED, /* GetWAPBookmark */ 99 NOTSUPPORTED, /* GetWAPBookmark */
100 NOTSUPPORTED, /* SetWAPBookmark */ 100 NOTSUPPORTED, /* SetWAPBookmark */
101 NOTSUPPORTED, /* DeleteWAPBookmark */ 101 NOTSUPPORTED, /* DeleteWAPBookmark */
102 NOTSUPPORTED, /* GetWAPSettings */ 102 NOTSUPPORTED, /* GetWAPSettings */
103 NOTSUPPORTED, /* SetWAPSettings */ 103 NOTSUPPORTED, /* SetWAPSettings */
104 NOTSUPPORTED, /* GetMMSSettings */ 104 NOTSUPPORTED, /* GetMMSSettings */
105 NOTSUPPORTED, /* SetMMSSettings */ 105 NOTSUPPORTED, /* SetMMSSettings */
106 NOTSUPPORTED, /* GetBitmap */ 106 NOTSUPPORTED, /* GetBitmap */
107 NOTSUPPORTED, /* SetBitmap */ 107 NOTSUPPORTED, /* SetBitmap */
108 NOTSUPPORTED, /* GetToDoStatus */ 108 NOTSUPPORTED, /* GetToDoStatus */
109 NOTSUPPORTED, /* GetToDo */ 109 NOTSUPPORTED, /* GetToDo */
110 NOTSUPPORTED, /* GetNextToDo */ 110 NOTSUPPORTED, /* GetNextToDo */
111 NOTSUPPORTED, /* SetToDo */ 111 NOTSUPPORTED, /* SetToDo */
112 NOTSUPPORTED, /* AddToDo */ 112 NOTSUPPORTED, /* AddToDo */
113 NOTSUPPORTED, /* DeleteToDo */ 113 NOTSUPPORTED, /* DeleteToDo */
114 NOTSUPPORTED, /* DeleteAllToDo */ 114 NOTSUPPORTED, /* DeleteAllToDo */
115 NOTSUPPORTED, /* GetCalendarStatus*/ 115 NOTSUPPORTED, /* GetCalendarStatus*/
116 NOTSUPPORTED, /* GetCalendar */ 116 NOTSUPPORTED, /* GetCalendar */
117 NOTSUPPORTED, /* GetNextCalendar */ 117 NOTSUPPORTED, /* GetNextCalendar */
118 NOTSUPPORTED, /* SetCalendar */ 118 NOTSUPPORTED, /* SetCalendar */
119 NOTSUPPORTED, /* AddCalendar */ 119 NOTSUPPORTED, /* AddCalendar */
120 NOTSUPPORTED, /* DeleteCalendar */ 120 NOTSUPPORTED, /* DeleteCalendar */
121 NOTSUPPORTED, /* DeleteAllCalendar*/ 121 NOTSUPPORTED, /* DeleteAllCalendar*/
122 NOTSUPPORTED, /* GetCalendarSettings*/ 122 NOTSUPPORTED, /* GetCalendarSettings*/
123 NOTSUPPORTED, /* SetCalendarSettings*/ 123 NOTSUPPORTED, /* SetCalendarSettings*/
124 NOTSUPPORTED, /* GetNoteStatus */
125 NOTSUPPORTED, /* GetNote */
124 NOTSUPPORTED, /* GetNextNote */ 126 NOTSUPPORTED, /* GetNextNote */
127 NOTSUPPORTED, /* SetNote */
128 NOTSUPPORTED, /* AddNote */
129 NOTSUPPORTED, /* DeleteNote */
130 NOTSUPPORTED, /* DeleteAllNotes */
125 NOTSUPPORTED, /* GetProfile */ 131 NOTSUPPORTED, /* GetProfile */
126 NOTSUPPORTED, /* SetProfile */ 132 NOTSUPPORTED, /* SetProfile */
127 NOTSUPPORTED, /* GetFMStation */ 133 NOTSUPPORTED, /* GetFMStation */
128 NOTSUPPORTED, /* SetFMStation */ 134 NOTSUPPORTED, /* SetFMStation */
129 NOTSUPPORTED, /* ClearFMStations */ 135 NOTSUPPORTED, /* ClearFMStations */
130 NOTSUPPORTED, /* GetNextFileFolder*/ 136 NOTSUPPORTED, /* GetNextFileFolder*/
131 NOTSUPPORTED, /* GetFilePart */ 137 NOTSUPPORTED, /* GetFilePart */
132 NOTSUPPORTED, /* AddFilePart */ 138 NOTSUPPORTED, /* AddFilePart */
133 NOTSUPPORTED, /* GetFileSystemStatus*/ 139 NOTSUPPORTED, /* GetFileSystemStatus*/
134 NOTSUPPORTED, /* DeleteFile */ 140 NOTSUPPORTED, /* DeleteFile */
135 NOTSUPPORTED, /* AddFolder */ 141 NOTSUPPORTED, /* AddFolder */
136 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 142 NOTSUPPORTED, /* GetGPRSAccessPoint*/
137 NOTSUPPORTED /* SetGPRSAccessPoint*/ 143 NOTSUPPORTED /* SetGPRSAccessPoint*/
138}; 144};
139 145
140#endif 146#endif
141 147
142/* How should editor hadle tabs in this file? Add editor commands here. 148/* How should editor hadle tabs in this file? Add editor commands here.
143 * vim: noexpandtab sw=8 ts=8 sts=8: 149 * vim: noexpandtab sw=8 ts=8 sts=8:
144 */ 150 */
diff --git a/gammu/emb/common/phone/obex/obexgen.c b/gammu/emb/common/phone/obex/obexgen.c
index 3106369..b91afac 100644
--- a/gammu/emb/common/phone/obex/obexgen.c
+++ b/gammu/emb/common/phone/obex/obexgen.c
@@ -448,405 +448,411 @@ static GSM_Error OBEXGEN_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File,
448 GSM_Error error; 448 GSM_Error error;
449 unsigned char Line[500],Line2[500],*name,*size; 449 unsigned char Line[500],Line2[500],*name,*size;
450 int Pos,i,j,num,pos2,Current,z; 450 int Pos,i,j,num,pos2,Current,z;
451 451
452 if (start) { 452 if (start) {
453 if (!strcmp(s->CurrentConfig->Model,"seobex")) return ERR_NOTSUPPORTED; 453 if (!strcmp(s->CurrentConfig->Model,"seobex")) return ERR_NOTSUPPORTED;
454 454
455 Priv->Files[0].Folder = true; 455 Priv->Files[0].Folder = true;
456 Priv->Files[0].Level = 1; 456 Priv->Files[0].Level = 1;
457 Priv->Files[0].Name[0] = 0; 457 Priv->Files[0].Name[0] = 0;
458 Priv->Files[0].Name[1] = 0; 458 Priv->Files[0].Name[1] = 0;
459 Priv->Files[0].ID_FullName[0]= 0; 459 Priv->Files[0].ID_FullName[0]= 0;
460 Priv->Files[0].ID_FullName[1]= 0; 460 Priv->Files[0].ID_FullName[1]= 0;
461 461
462 Priv->FilesLocationsUsed = 1; 462 Priv->FilesLocationsUsed = 1;
463 Priv->FilesLocationsCurrent = 0; 463 Priv->FilesLocationsCurrent = 0;
464 Priv->FileLev = 1; 464 Priv->FileLev = 1;
465 465
466 error = OBEXGEN_Connect(s,OBEX_BrowsingFolders); 466 error = OBEXGEN_Connect(s,OBEX_BrowsingFolders);
467 if (error != ERR_NONE) return error; 467 if (error != ERR_NONE) return error;
468 468
469 smprintf(s,"Changing to root\n"); 469 smprintf(s,"Changing to root\n");
470 error = OBEXGEN_ChangePath(s, NULL, 2); 470 error = OBEXGEN_ChangePath(s, NULL, 2);
471 if (error != ERR_NONE) return error; 471 if (error != ERR_NONE) return error;
472 472
473 Current = 0; 473 Current = 0;
474 } 474 }
475 475
476 while (1) { 476 while (1) {
477 if (Priv->FilesLocationsCurrent == Priv->FilesLocationsUsed) { 477 if (Priv->FilesLocationsCurrent == Priv->FilesLocationsUsed) {
478 dbgprintf("Last file\n"); 478 dbgprintf("Last file\n");
479 return ERR_EMPTY; 479 return ERR_EMPTY;
480 } 480 }
481 481
482 strcpy(File->ID_FullName,Priv->Files[Priv->FilesLocationsCurrent].ID_FullName); 482 strcpy(File->ID_FullName,Priv->Files[Priv->FilesLocationsCurrent].ID_FullName);
483 File->Level= Priv->Files[Priv->FilesLocationsCurrent].Level; 483 File->Level= Priv->Files[Priv->FilesLocationsCurrent].Level;
484 File->Folder= Priv->Files[Priv->FilesLocationsCurrent].Folder; 484 File->Folder= Priv->Files[Priv->FilesLocationsCurrent].Folder;
485 CopyUnicodeString(File->Name,Priv->Files[Priv->FilesLocationsCurrent].Name); 485 CopyUnicodeString(File->Name,Priv->Files[Priv->FilesLocationsCurrent].Name);
486 Priv->FilesLocationsCurrent++; 486 Priv->FilesLocationsCurrent++;
487 487
488 if (File->Folder) { 488 if (File->Folder) {
489 if (File->Level < Priv->FileLev) { 489 if (File->Level < Priv->FileLev) {
490 for (i=0;i<File->Level;i++) { 490 for (i=0;i<File->Level;i++) {
491 smprintf(s,"Changing path up\n"); 491 smprintf(s,"Changing path up\n");
492 error=OBEXGEN_ChangePath(s, NULL, 2); 492 error=OBEXGEN_ChangePath(s, NULL, 2);
493 if (error != ERR_NONE) return error; 493 if (error != ERR_NONE) return error;
494 } 494 }
495 } 495 }
496 496
497 smprintf(s,"Level %i %i\n",File->Level,Priv->FileLev); 497 smprintf(s,"Level %i %i\n",File->Level,Priv->FileLev);
498 498
499 File->Buffer = NULL; 499 File->Buffer = NULL;
500 File->Used = 0; 500 File->Used = 0;
501 OBEXGEN_PrivGetFilePart(s, File,true); 501 OBEXGEN_PrivGetFilePart(s, File,true);
502 502
503 num = 0; 503 num = 0;
504 Pos = 0; 504 Pos = 0;
505 while (1) { 505 while (1) {
506 MyGetLine(File->Buffer, &Pos, Line, File->Used); 506 MyGetLine(File->Buffer, &Pos, Line, File->Used);
507 if (strlen(Line) == 0) break; 507 if (strlen(Line) == 0) break;
508 name = strstr(Line,"folder name=\""); 508 name = strstr(Line,"folder name=\"");
509 if (name != NULL) { 509 if (name != NULL) {
510 name += 13; 510 name += 13;
511 j = 0; 511 j = 0;
512 while(1) { 512 while(1) {
513 if (name[j] == '"') break; 513 if (name[j] == '"') break;
514 j++; 514 j++;
515 } 515 }
516 name[j] = 0; 516 name[j] = 0;
517 517
518 if (strcmp(name,".")) num++; 518 if (strcmp(name,".")) num++;
519 } 519 }
520 name = strstr(Line,"file name=\""); 520 name = strstr(Line,"file name=\"");
521 if (name != NULL) num++; 521 if (name != NULL) num++;
522 } 522 }
523 if (num != 0) { 523 if (num != 0) {
524 i = Priv->FilesLocationsUsed-1; 524 i = Priv->FilesLocationsUsed-1;
525 while (1) { 525 while (1) {
526 if (i==Priv->FilesLocationsCurrent-1) break; 526 if (i==Priv->FilesLocationsCurrent-1) break;
527 memcpy(&Priv->Files[i+num],&Priv->Files[i],sizeof(GSM_File)); 527 memcpy(&Priv->Files[i+num],&Priv->Files[i],sizeof(GSM_File));
528 i--; 528 i--;
529 } 529 }
530 } 530 }
531 531
532 Pos = 0; 532 Pos = 0;
533 pos2 = 0; 533 pos2 = 0;
534 while (1) { 534 while (1) {
535 MyGetLine(File->Buffer, &Pos, Line, File->Used); 535 MyGetLine(File->Buffer, &Pos, Line, File->Used);
536 if (strlen(Line) == 0) break; 536 if (strlen(Line) == 0) break;
537 strcpy(Line2,Line); 537 strcpy(Line2,Line);
538 name = strstr(Line2,"folder name=\""); 538 name = strstr(Line2,"folder name=\"");
539 if (name != NULL) { 539 if (name != NULL) {
540 name += 13; 540 name += 13;
541 j = 0; 541 j = 0;
542 while(1) { 542 while(1) {
543 if (name[j] == '"') break; 543 if (name[j] == '"') break;
544 j++; 544 j++;
545 } 545 }
546 name[j] = 0; 546 name[j] = 0;
547 if (strcmp(name,".")) { 547 if (strcmp(name,".")) {
548 dbgprintf("copying folder %s to %i parent %i\n",name,Priv->FilesLocationsCurrent+pos2,Priv->FilesLocationsCurrent); 548 dbgprintf("copying folder %s to %i parent %i\n",name,Priv->FilesLocationsCurrent+pos2,Priv->FilesLocationsCurrent);
549 strcpy(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,File->ID_FullName); 549 strcpy(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,File->ID_FullName);
550 if (strlen(File->ID_FullName) != 0) strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,"\\"); 550 if (strlen(File->ID_FullName) != 0) strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,"\\");
551 strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,name); 551 strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,name);
552 Priv->Files[Priv->FilesLocationsCurrent+pos2].Level = File->Level+1; 552 Priv->Files[Priv->FilesLocationsCurrent+pos2].Level = File->Level+1;
553 Priv->Files[Priv->FilesLocationsCurrent+pos2].Folder = true; 553 Priv->Files[Priv->FilesLocationsCurrent+pos2].Folder = true;
554 EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+pos2].Name,name,strlen(name)); 554 EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+pos2].Name,name,strlen(name));
555 Priv->FilesLocationsUsed++; 555 Priv->FilesLocationsUsed++;
556 pos2++; 556 pos2++;
557 } 557 }
558 } 558 }
559 strcpy(Line2,Line); 559 strcpy(Line2,Line);
560 name = strstr(Line2,"file name=\""); 560 name = strstr(Line2,"file name=\"");
561 if (name != NULL) { 561 if (name != NULL) {
562 name += 11; 562 name += 11;
563 j = 0; 563 j = 0;
564 while(1) { 564 while(1) {
565 if (name[j] == '"') break; 565 if (name[j] == '"') break;
566 j++; 566 j++;
567 } 567 }
568 name[j] = 0; 568 name[j] = 0;
569 dbgprintf("copying file %s to %i\n",name,Priv->FilesLocationsCurrent+pos2); 569 dbgprintf("copying file %s to %i\n",name,Priv->FilesLocationsCurrent+pos2);
570 Priv->Files[Priv->FilesLocationsCurrent+pos2].Level= File->Level+1; 570 Priv->Files[Priv->FilesLocationsCurrent+pos2].Level= File->Level+1;
571 Priv->Files[Priv->FilesLocationsCurrent+pos2].Folder = false; 571 Priv->Files[Priv->FilesLocationsCurrent+pos2].Folder = false;
572 strcpy(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,File->ID_FullName); 572 strcpy(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,File->ID_FullName);
573 if (strlen(File->ID_FullName) != 0) strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,"\\"); 573 if (strlen(File->ID_FullName) != 0) strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,"\\");
574 strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,name); 574 strcat(Priv->Files[Priv->FilesLocationsCurrent+pos2].ID_FullName,name);
575 EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+pos2].Name,name,strlen(name)); 575 EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+pos2].Name,name,strlen(name));
576 576
577 Priv->Files[Priv->FilesLocationsCurrent+pos2].Used = 0; 577 Priv->Files[Priv->FilesLocationsCurrent+pos2].Used = 0;
578 strcpy(Line2,Line); 578 strcpy(Line2,Line);
579 size = strstr(Line2,"size=\""); 579 size = strstr(Line2,"size=\"");
580 if (size != NULL) Priv->Files[Priv->FilesLocationsCurrent+pos2].Used = atoi(size+6); 580 if (size != NULL) Priv->Files[Priv->FilesLocationsCurrent+pos2].Used = atoi(size+6);
581 581
582 Priv->Files[Priv->FilesLocationsCurrent+pos2].ModifiedEmpty = true; 582 Priv->Files[Priv->FilesLocationsCurrent+pos2].ModifiedEmpty = true;
583 strcpy(Line2,Line); 583 strcpy(Line2,Line);
584 size = strstr(Line2,"modified=\""); 584 size = strstr(Line2,"modified=\"");
585 if (size != NULL) { 585 if (size != NULL) {
586 Priv->Files[Priv->FilesLocationsCurrent+pos2].ModifiedEmpty = false; 586 Priv->Files[Priv->FilesLocationsCurrent+pos2].ModifiedEmpty = false;
587 ReadVCALDateTime(size+10, &Priv->Files[Priv->FilesLocationsCurrent+pos2].Modified); 587 ReadVCALDateTime(size+10, &Priv->Files[Priv->FilesLocationsCurrent+pos2].Modified);
588 } 588 }
589 Priv->FilesLocationsUsed++; 589 Priv->FilesLocationsUsed++;
590 pos2++; 590 pos2++;
591 } 591 }
592 } 592 }
593 593
594 z = Priv->FilesLocationsCurrent; 594 z = Priv->FilesLocationsCurrent;
595 if (z != 1) { 595 if (z != 1) {
596 while (1) { 596 while (1) {
597 if (z == Priv->FilesLocationsUsed) break; 597 if (z == Priv->FilesLocationsUsed) break;
598 if (Priv->Files[z].Folder) { 598 if (Priv->Files[z].Folder) {
599 if (Priv->Files[z].Level > File->Level) { 599 if (Priv->Files[z].Level > File->Level) {
600 smprintf(s,"Changing path down\n"); 600 smprintf(s,"Changing path down\n");
601 error=OBEXGEN_ChangePath(s, File->Name, 2); 601 error=OBEXGEN_ChangePath(s, File->Name, 2);
602 if (error != ERR_NONE) return error; 602 if (error != ERR_NONE) return error;
603 } 603 }
604 break; 604 break;
605 } 605 }
606 z++; 606 z++;
607 } 607 }
608 } 608 }
609 609
610 Priv->FileLev = File->Level; 610 Priv->FileLev = File->Level;
611 free(File->Buffer); 611 free(File->Buffer);
612 } else { 612 } else {
613 File->Used = Priv->Files[Priv->FilesLocationsCurrent-1].Used; 613 File->Used = Priv->Files[Priv->FilesLocationsCurrent-1].Used;
614 File->ModifiedEmpty = Priv->Files[Priv->FilesLocationsCurrent-1].ModifiedEmpty; 614 File->ModifiedEmpty = Priv->Files[Priv->FilesLocationsCurrent-1].ModifiedEmpty;
615 if (!File->ModifiedEmpty) { 615 if (!File->ModifiedEmpty) {
616 memcpy(&File->Modified,&Priv->Files[Priv->FilesLocationsCurrent-1].Modified,sizeof(GSM_DateTime)); 616 memcpy(&File->Modified,&Priv->Files[Priv->FilesLocationsCurrent-1].Modified,sizeof(GSM_DateTime));
617 } 617 }
618 File->ReadOnly = false; 618 File->ReadOnly = false;
619 File->Protected = false; 619 File->Protected = false;
620 File->Hidden = false; 620 File->Hidden = false;
621 File->System = false; 621 File->System = false;
622 622
623 } 623 }
624 return ERR_NONE; 624 return ERR_NONE;
625 } 625 }
626} 626}
627 627
628static GSM_Error OBEXGEN_DeleteFile(GSM_StateMachine *s, unsigned char *ID) 628static GSM_Error OBEXGEN_DeleteFile(GSM_StateMachine *s, unsigned char *ID)
629{ 629{
630 GSM_Error error; 630 GSM_Error error;
631 unsigned int Current = 0, Pos; 631 unsigned int Current = 0, Pos;
632 unsigned char req[200],req2[200]; 632 unsigned char req[200],req2[200];
633 633
634 if (!strcmp(s->CurrentConfig->Model,"seobex")) return ERR_NOTSUPPORTED; 634 if (!strcmp(s->CurrentConfig->Model,"seobex")) return ERR_NOTSUPPORTED;
635 635
636 error = OBEXGEN_Connect(s,OBEX_BrowsingFolders); 636 error = OBEXGEN_Connect(s,OBEX_BrowsingFolders);
637 if (error != ERR_NONE) return error; 637 if (error != ERR_NONE) return error;
638 638
639 smprintf(s,"Changing to root\n"); 639 smprintf(s,"Changing to root\n");
640 error = OBEXGEN_ChangePath(s, NULL, 2); 640 error = OBEXGEN_ChangePath(s, NULL, 2);
641 if (error != ERR_NONE) return error; 641 if (error != ERR_NONE) return error;
642 642
643 Pos = 0; 643 Pos = 0;
644 do { 644 do {
645 OBEXGEN_FindNextDir(ID, &Pos, req2); 645 OBEXGEN_FindNextDir(ID, &Pos, req2);
646 smprintf(s,"%s %i %i\n",DecodeUnicodeString(req2),Pos,strlen(ID)); 646 smprintf(s,"%s %i %i\n",DecodeUnicodeString(req2),Pos,strlen(ID));
647 if (Pos == strlen(ID)) break; 647 if (Pos == strlen(ID)) break;
648 smprintf(s,"Changing path down\n"); 648 smprintf(s,"Changing path down\n");
649 error=OBEXGEN_ChangePath(s, req2, 2); 649 error=OBEXGEN_ChangePath(s, req2, 2);
650 if (error != ERR_NONE) return error; 650 if (error != ERR_NONE) return error;
651 } while (1); 651 } while (1);
652 652
653 /* Name block */ 653 /* Name block */
654 OBEXAddBlock(req, &Current, 0x01, req2, UnicodeLength(req2)*2+2); 654 OBEXAddBlock(req, &Current, 0x01, req2, UnicodeLength(req2)*2+2);
655 655
656 /* connection ID block */ 656 /* connection ID block */
657 req[Current++] = 0xCB; // ID 657 req[Current++] = 0xCB; // ID
658 req[Current++] = 0x00; req[Current++] = 0x00; 658 req[Current++] = 0x00; req[Current++] = 0x00;
659 req[Current++] = 0x00; req[Current++] = 0x01; 659 req[Current++] = 0x00; req[Current++] = 0x01;
660 660
661 return GSM_WaitFor (s, req, Current, 0x82, 4, ID_AddFile); 661 return GSM_WaitFor (s, req, Current, 0x82, 4, ID_AddFile);
662} 662}
663 663
664static GSM_Error OBEXGEN_AddFolder(GSM_StateMachine *s, GSM_File *File) 664static GSM_Error OBEXGEN_AddFolder(GSM_StateMachine *s, GSM_File *File)
665{ 665{
666 GSM_Error error; 666 GSM_Error error;
667 unsigned char req2[200]; 667 unsigned char req2[200];
668 unsigned int Pos; 668 unsigned int Pos;
669 669
670 if (!strcmp(s->CurrentConfig->Model,"seobex")) return ERR_NOTSUPPORTED; 670 if (!strcmp(s->CurrentConfig->Model,"seobex")) return ERR_NOTSUPPORTED;
671 671
672 error = OBEXGEN_Connect(s,OBEX_BrowsingFolders); 672 error = OBEXGEN_Connect(s,OBEX_BrowsingFolders);
673 if (error != ERR_NONE) return error; 673 if (error != ERR_NONE) return error;
674 674
675 smprintf(s,"Changing to root\n"); 675 smprintf(s,"Changing to root\n");
676 error = OBEXGEN_ChangePath(s, NULL, 2); 676 error = OBEXGEN_ChangePath(s, NULL, 2);
677 if (error != ERR_NONE) return error; 677 if (error != ERR_NONE) return error;
678 678
679 Pos = 0; 679 Pos = 0;
680 do { 680 do {
681 OBEXGEN_FindNextDir(File->ID_FullName, &Pos, req2); 681 OBEXGEN_FindNextDir(File->ID_FullName, &Pos, req2);
682 smprintf(s,"%s %i %i\n",DecodeUnicodeString(req2),Pos,strlen(File->ID_FullName)); 682 smprintf(s,"%s %i %i\n",DecodeUnicodeString(req2),Pos,strlen(File->ID_FullName));
683 smprintf(s,"Changing path down\n"); 683 smprintf(s,"Changing path down\n");
684 error=OBEXGEN_ChangePath(s, req2, 2); 684 error=OBEXGEN_ChangePath(s, req2, 2);
685 if (error != ERR_NONE) return error; 685 if (error != ERR_NONE) return error;
686 if (Pos == strlen(File->ID_FullName)) break; 686 if (Pos == strlen(File->ID_FullName)) break;
687 } while (1); 687 } while (1);
688 688
689 smprintf(s,"Adding directory\n"); 689 smprintf(s,"Adding directory\n");
690 return OBEXGEN_ChangePath(s, File->Name, 0); 690 return OBEXGEN_ChangePath(s, File->Name, 0);
691} 691}
692 692
693GSM_Reply_Function OBEXGENReplyFunctions[] = { 693GSM_Reply_Function OBEXGENReplyFunctions[] = {
694 /* CONTINUE block */ 694 /* CONTINUE block */
695 {OBEXGEN_ReplyAddFilePart, "\x90",0x00,0x00,ID_AddFile }, 695 {OBEXGEN_ReplyAddFilePart, "\x90",0x00,0x00,ID_AddFile },
696 {OBEXGEN_ReplyGetFilePart, "\x90",0x00,0x00,ID_GetFile }, 696 {OBEXGEN_ReplyGetFilePart, "\x90",0x00,0x00,ID_GetFile },
697 {OBEXGEN_ReplyGetFileInfo, "\x90",0x00,0x00,ID_GetFileInfo }, 697 {OBEXGEN_ReplyGetFileInfo, "\x90",0x00,0x00,ID_GetFileInfo },
698 698
699 /* OK block */ 699 /* OK block */
700 {OBEXGEN_ReplyChangePath, "\xA0",0x00,0x00,ID_SetPath }, 700 {OBEXGEN_ReplyChangePath, "\xA0",0x00,0x00,ID_SetPath },
701 {OBEXGEN_ReplyConnect, "\xA0",0x00,0x00,ID_Initialise }, 701 {OBEXGEN_ReplyConnect, "\xA0",0x00,0x00,ID_Initialise },
702 {OBEXGEN_ReplyAddFilePart, "\xA0",0x00,0x00,ID_AddFile }, 702 {OBEXGEN_ReplyAddFilePart, "\xA0",0x00,0x00,ID_AddFile },
703 {OBEXGEN_ReplyGetFilePart, "\xA0",0x00,0x00,ID_GetFile }, 703 {OBEXGEN_ReplyGetFilePart, "\xA0",0x00,0x00,ID_GetFile },
704 {OBEXGEN_ReplyGetFileInfo, "\xA0",0x00,0x00,ID_GetFileInfo }, 704 {OBEXGEN_ReplyGetFileInfo, "\xA0",0x00,0x00,ID_GetFileInfo },
705 705
706 /* FOLDER CREATED block */ 706 /* FOLDER CREATED block */
707 {OBEXGEN_ReplyChangePath, "\xA1",0x00,0x00,ID_SetPath }, 707 {OBEXGEN_ReplyChangePath, "\xA1",0x00,0x00,ID_SetPath },
708 708
709 /* NOT UNDERSTAND block */ 709 /* NOT UNDERSTAND block */
710 {OBEXGEN_ReplyAddFilePart, "\xC0",0x00,0x00,ID_AddFile }, 710 {OBEXGEN_ReplyAddFilePart, "\xC0",0x00,0x00,ID_AddFile },
711 711
712 /* FORBIDDEN block */ 712 /* FORBIDDEN block */
713 {OBEXGEN_ReplyChangePath, "\xC3",0x00,0x00,ID_SetPath }, 713 {OBEXGEN_ReplyChangePath, "\xC3",0x00,0x00,ID_SetPath },
714 {OBEXGEN_ReplyGetFilePart, "\xC3",0x00,0x00,ID_GetFile }, 714 {OBEXGEN_ReplyGetFilePart, "\xC3",0x00,0x00,ID_GetFile },
715 715
716 /* NOT FOUND block */ 716 /* NOT FOUND block */
717 {OBEXGEN_ReplyGetFilePart, "\xC4",0x00,0x00,ID_GetFile }, 717 {OBEXGEN_ReplyGetFilePart, "\xC4",0x00,0x00,ID_GetFile },
718 718
719 {NULL, "\x00",0x00,0x00,ID_None } 719 {NULL, "\x00",0x00,0x00,ID_None }
720}; 720};
721 721
722GSM_Phone_Functions OBEXGENPhone = { 722GSM_Phone_Functions OBEXGENPhone = {
723 "obex|seobex", 723 "obex|seobex",
724 OBEXGENReplyFunctions, 724 OBEXGENReplyFunctions,
725 OBEXGEN_Initialise, 725 OBEXGEN_Initialise,
726 NONEFUNCTION, /* Terminate */ 726 NONEFUNCTION, /* Terminate */
727 GSM_DispatchMessage, 727 GSM_DispatchMessage,
728 NOTIMPLEMENTED, /* ShowStartInfo */ 728 NOTIMPLEMENTED, /* ShowStartInfo */
729 NONEFUNCTION, /* GetManufacturer */ 729 NONEFUNCTION, /* GetManufacturer */
730 NONEFUNCTION, /* GetModel */ 730 NONEFUNCTION, /* GetModel */
731 NONEFUNCTION, /* GetFirmware */ 731 NONEFUNCTION, /* GetFirmware */
732 NOTIMPLEMENTED, /* GetIMEI */ 732 NOTIMPLEMENTED, /* GetIMEI */
733 NOTIMPLEMENTED, /* GetOriginalIMEI */ 733 NOTIMPLEMENTED, /* GetOriginalIMEI */
734 NOTIMPLEMENTED, /* GetManufactureMonth*/ 734 NOTIMPLEMENTED, /* GetManufactureMonth*/
735 NOTIMPLEMENTED, /* GetProductCode */ 735 NOTIMPLEMENTED, /* GetProductCode */
736 NOTIMPLEMENTED, /* GetHardware */ 736 NOTIMPLEMENTED, /* GetHardware */
737 NOTIMPLEMENTED, /* GetPPM */ 737 NOTIMPLEMENTED, /* GetPPM */
738 NOTIMPLEMENTED, /* GetSIMIMSI */ 738 NOTIMPLEMENTED, /* GetSIMIMSI */
739 NOTIMPLEMENTED, /* GetDateTime */ 739 NOTIMPLEMENTED, /* GetDateTime */
740 NOTIMPLEMENTED, /* SetDateTime */ 740 NOTIMPLEMENTED, /* SetDateTime */
741 NOTIMPLEMENTED, /* GetAlarm */ 741 NOTIMPLEMENTED, /* GetAlarm */
742 NOTIMPLEMENTED, /* SetAlarm */ 742 NOTIMPLEMENTED, /* SetAlarm */
743 NOTSUPPORTED, /* GetLocale */ 743 NOTSUPPORTED, /* GetLocale */
744 NOTSUPPORTED, /* SetLocale */ 744 NOTSUPPORTED, /* SetLocale */
745 NOTIMPLEMENTED, /* PressKey */ 745 NOTIMPLEMENTED, /* PressKey */
746 NOTIMPLEMENTED, /* Reset */ 746 NOTIMPLEMENTED, /* Reset */
747 NOTIMPLEMENTED, /* ResetPhoneSettings*/ 747 NOTIMPLEMENTED, /* ResetPhoneSettings*/
748 NOTIMPLEMENTED, /* EnterSecurityCode*/ 748 NOTIMPLEMENTED, /* EnterSecurityCode*/
749 NOTIMPLEMENTED, /* GetSecurityStatus*/ 749 NOTIMPLEMENTED, /* GetSecurityStatus*/
750 NOTIMPLEMENTED, /* GetDisplayStatus*/ 750 NOTIMPLEMENTED, /* GetDisplayStatus*/
751 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/ 751 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
752 NOTIMPLEMENTED, /* GetBatteryCharge*/ 752 NOTIMPLEMENTED, /* GetBatteryCharge*/
753 NOTIMPLEMENTED, /* GetSignalQuality*/ 753 NOTIMPLEMENTED, /* GetSignalQuality*/
754 NOTIMPLEMENTED, /* GetNetworkInfo */ 754 NOTIMPLEMENTED, /* GetNetworkInfo */
755 NOTIMPLEMENTED, /* GetCategory */ 755 NOTIMPLEMENTED, /* GetCategory */
756 NOTSUPPORTED, /* AddCategory */ 756 NOTSUPPORTED, /* AddCategory */
757 NOTIMPLEMENTED, /* GetCategoryStatus */ 757 NOTIMPLEMENTED, /* GetCategoryStatus */
758 NOTIMPLEMENTED, /* GetMemoryStatus */ 758 NOTIMPLEMENTED, /* GetMemoryStatus */
759 NOTIMPLEMENTED, /* GetMemory */ 759 NOTIMPLEMENTED, /* GetMemory */
760 NOTIMPLEMENTED, /* GetNextMemory */ 760 NOTIMPLEMENTED, /* GetNextMemory */
761 NOTIMPLEMENTED, /* SetMemory */ 761 NOTIMPLEMENTED, /* SetMemory */
762 NOTIMPLEMENTED, /* AddMemory */ 762 NOTIMPLEMENTED, /* AddMemory */
763 NOTIMPLEMENTED, /* DeleteMemory */ 763 NOTIMPLEMENTED, /* DeleteMemory */
764 NOTIMPLEMENTED, /* DeleteAllMemory */ 764 NOTIMPLEMENTED, /* DeleteAllMemory */
765 NOTIMPLEMENTED, /* GetSpeedDial */ 765 NOTIMPLEMENTED, /* GetSpeedDial */
766 NOTIMPLEMENTED, /* SetSpeedDial */ 766 NOTIMPLEMENTED, /* SetSpeedDial */
767 NOTIMPLEMENTED, /* GetSMSC */ 767 NOTIMPLEMENTED, /* GetSMSC */
768 NOTIMPLEMENTED, /* SetSMSC */ 768 NOTIMPLEMENTED, /* SetSMSC */
769 NOTIMPLEMENTED, /* GetSMSStatus */ 769 NOTIMPLEMENTED, /* GetSMSStatus */
770 NOTIMPLEMENTED, /* GetSMS */ 770 NOTIMPLEMENTED, /* GetSMS */
771 NOTIMPLEMENTED, /* GetNextSMS */ 771 NOTIMPLEMENTED, /* GetNextSMS */
772 NOTIMPLEMENTED, /* SetSMS */ 772 NOTIMPLEMENTED, /* SetSMS */
773 NOTIMPLEMENTED, /* AddSMS */ 773 NOTIMPLEMENTED, /* AddSMS */
774 NOTIMPLEMENTED, /* DeleteSMS */ 774 NOTIMPLEMENTED, /* DeleteSMS */
775 NOTIMPLEMENTED, /* SendSMSMessage */ 775 NOTIMPLEMENTED, /* SendSMSMessage */
776 NOTSUPPORTED, /* SendSavedSMS */ 776 NOTSUPPORTED, /* SendSavedSMS */
777 NOTSUPPORTED, /* SetFastSMSSending*/ 777 NOTSUPPORTED, /* SetFastSMSSending*/
778 NOTIMPLEMENTED, /* SetIncomingSMS */ 778 NOTIMPLEMENTED, /* SetIncomingSMS */
779 NOTIMPLEMENTED, /* SetIncomingCB */ 779 NOTIMPLEMENTED, /* SetIncomingCB */
780 NOTIMPLEMENTED, /* GetSMSFolders */ 780 NOTIMPLEMENTED, /* GetSMSFolders */
781 NOTIMPLEMENTED, /* AddSMSFolder */ 781 NOTIMPLEMENTED, /* AddSMSFolder */
782 NOTIMPLEMENTED, /* DeleteSMSFolder */ 782 NOTIMPLEMENTED, /* DeleteSMSFolder */
783 NOTIMPLEMENTED, /* DialVoice */ 783 NOTIMPLEMENTED, /* DialVoice */
784 NOTIMPLEMENTED, /* AnswerCall */ 784 NOTIMPLEMENTED, /* AnswerCall */
785 NOTIMPLEMENTED, /* CancelCall */ 785 NOTIMPLEMENTED, /* CancelCall */
786 NOTIMPLEMENTED, /* HoldCall */ 786 NOTIMPLEMENTED, /* HoldCall */
787 NOTIMPLEMENTED, /* UnholdCall */ 787 NOTIMPLEMENTED, /* UnholdCall */
788 NOTIMPLEMENTED, /* ConferenceCall */ 788 NOTIMPLEMENTED, /* ConferenceCall */
789 NOTIMPLEMENTED, /* SplitCall */ 789 NOTIMPLEMENTED, /* SplitCall */
790 NOTIMPLEMENTED, /* TransferCall */ 790 NOTIMPLEMENTED, /* TransferCall */
791 NOTIMPLEMENTED, /* SwitchCall */ 791 NOTIMPLEMENTED, /* SwitchCall */
792 NOTIMPLEMENTED, /* GetCallDivert */ 792 NOTIMPLEMENTED, /* GetCallDivert */
793 NOTIMPLEMENTED, /* SetCallDivert */ 793 NOTIMPLEMENTED, /* SetCallDivert */
794 NOTIMPLEMENTED, /* CancelAllDiverts*/ 794 NOTIMPLEMENTED, /* CancelAllDiverts*/
795 NOTIMPLEMENTED, /* SetIncomingCall */ 795 NOTIMPLEMENTED, /* SetIncomingCall */
796 NOTIMPLEMENTED, /* SetIncomingUSSD */ 796 NOTIMPLEMENTED, /* SetIncomingUSSD */
797 NOTIMPLEMENTED, /* SendDTMF */ 797 NOTIMPLEMENTED, /* SendDTMF */
798 NOTIMPLEMENTED, /* GetRingtone */ 798 NOTIMPLEMENTED, /* GetRingtone */
799 NOTIMPLEMENTED, /* SetRingtone */ 799 NOTIMPLEMENTED, /* SetRingtone */
800 NOTIMPLEMENTED, /* GetRingtonesInfo*/ 800 NOTIMPLEMENTED, /* GetRingtonesInfo*/
801 NOTIMPLEMENTED, /* DeleteUserRingtones*/ 801 NOTIMPLEMENTED, /* DeleteUserRingtones*/
802 NOTIMPLEMENTED, /* PlayTone */ 802 NOTIMPLEMENTED, /* PlayTone */
803 NOTIMPLEMENTED, /* GetWAPBookmark */ 803 NOTIMPLEMENTED, /* GetWAPBookmark */
804 NOTIMPLEMENTED, /* SetWAPBookmark */ 804 NOTIMPLEMENTED, /* SetWAPBookmark */
805 NOTIMPLEMENTED, /* DeleteWAPBookmark */ 805 NOTIMPLEMENTED, /* DeleteWAPBookmark */
806 NOTIMPLEMENTED, /* GetWAPSettings */ 806 NOTIMPLEMENTED, /* GetWAPSettings */
807 NOTIMPLEMENTED, /* SetWAPSettings */ 807 NOTIMPLEMENTED, /* SetWAPSettings */
808 NOTIMPLEMENTED, /* GetMMSSettings */ 808 NOTIMPLEMENTED, /* GetMMSSettings */
809 NOTIMPLEMENTED, /* SetMMSSettings */ 809 NOTIMPLEMENTED, /* SetMMSSettings */
810 NOTSUPPORTED, /* GetSyncMLSettings*/ 810 NOTSUPPORTED, /* GetSyncMLSettings*/
811 NOTSUPPORTED, /* SetSyncMLSettings*/ 811 NOTSUPPORTED, /* SetSyncMLSettings*/
812 NOTSUPPORTED, /* GetChatSettings */ 812 NOTSUPPORTED, /* GetChatSettings */
813 NOTSUPPORTED, /* SetChatSettings */ 813 NOTSUPPORTED, /* SetChatSettings */
814 NOTIMPLEMENTED, /* GetBitmap */ 814 NOTIMPLEMENTED, /* GetBitmap */
815 NOTIMPLEMENTED, /* SetBitmap */ 815 NOTIMPLEMENTED, /* SetBitmap */
816 NOTIMPLEMENTED, /* GetToDoStatus */ 816 NOTIMPLEMENTED, /* GetToDoStatus */
817 NOTIMPLEMENTED, /* GetToDo */ 817 NOTIMPLEMENTED, /* GetToDo */
818 NOTIMPLEMENTED, /* GetNextToDo */ 818 NOTIMPLEMENTED, /* GetNextToDo */
819 NOTIMPLEMENTED, /* SetToDo */ 819 NOTIMPLEMENTED, /* SetToDo */
820 NOTIMPLEMENTED, /* AddToDo */ 820 NOTIMPLEMENTED, /* AddToDo */
821 NOTIMPLEMENTED, /* DeleteToDo */ 821 NOTIMPLEMENTED, /* DeleteToDo */
822 NOTIMPLEMENTED, /* DeleteAllToDo */ 822 NOTIMPLEMENTED, /* DeleteAllToDo */
823 NOTIMPLEMENTED, /* GetCalendarStatus*/ 823 NOTIMPLEMENTED, /* GetCalendarStatus*/
824 NOTIMPLEMENTED, /* GetCalendar */ 824 NOTIMPLEMENTED, /* GetCalendar */
825 NOTIMPLEMENTED, /* GetNextCalendar */ 825 NOTIMPLEMENTED, /* GetNextCalendar */
826 NOTIMPLEMENTED, /* SetCalendar */ 826 NOTIMPLEMENTED, /* SetCalendar */
827 NOTIMPLEMENTED, /* AddCalendar */ 827 NOTIMPLEMENTED, /* AddCalendar */
828 NOTIMPLEMENTED, /* DeleteCalendar */ 828 NOTIMPLEMENTED, /* DeleteCalendar */
829 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 829 NOTIMPLEMENTED, /* DeleteAllCalendar*/
830 NOTSUPPORTED, /* GetCalendarSettings*/ 830 NOTSUPPORTED, /* GetCalendarSettings*/
831 NOTSUPPORTED, /* SetCalendarSettings*/ 831 NOTSUPPORTED, /* SetCalendarSettings*/
832 NOTSUPPORTED, /* GetNoteStatus */
833 NOTSUPPORTED, /* GetNote */
832 NOTSUPPORTED, /* GetNextNote */ 834 NOTSUPPORTED, /* GetNextNote */
835 NOTSUPPORTED, /* SetNote */
836 NOTSUPPORTED, /* AddNote */
837 NOTSUPPORTED, /* DeleteNote */
838 NOTSUPPORTED, /* DeleteAllNotes */
833 NOTIMPLEMENTED, /* GetProfile */ 839 NOTIMPLEMENTED, /* GetProfile */
834 NOTIMPLEMENTED, /* SetProfile */ 840 NOTIMPLEMENTED, /* SetProfile */
835 NOTIMPLEMENTED, /* GetFMStation */ 841 NOTIMPLEMENTED, /* GetFMStation */
836 NOTIMPLEMENTED, /* SetFMStation */ 842 NOTIMPLEMENTED, /* SetFMStation */
837 NOTIMPLEMENTED, /* ClearFMStations */ 843 NOTIMPLEMENTED, /* ClearFMStations */
838 OBEXGEN_GetNextFileFolder, 844 OBEXGEN_GetNextFileFolder,
839 OBEXGEN_GetFilePart, 845 OBEXGEN_GetFilePart,
840 OBEXGEN_AddFilePart, 846 OBEXGEN_AddFilePart,
841 NOTIMPLEMENTED, /* GetFileSystemStatus*/ 847 NOTIMPLEMENTED, /* GetFileSystemStatus*/
842 OBEXGEN_DeleteFile, 848 OBEXGEN_DeleteFile,
843 OBEXGEN_AddFolder, 849 OBEXGEN_AddFolder,
844 NOTIMPLEMENTED, /* GetGPRSAccessPoint*/ 850 NOTIMPLEMENTED, /* GetGPRSAccessPoint*/
845 NOTIMPLEMENTED /* SetGPRSAccessPoint*/ 851 NOTIMPLEMENTED /* SetGPRSAccessPoint*/
846}; 852};
847 853
848#endif 854#endif
849 855
850/* How should editor hadle tabs in this file? Add editor commands here. 856/* How should editor hadle tabs in this file? Add editor commands here.
851 * vim: noexpandtab sw=8 ts=8 sts=8: 857 * vim: noexpandtab sw=8 ts=8 sts=8:
852 */ 858 */
diff --git a/gammu/emb/common/phone/pfunc.c b/gammu/emb/common/phone/pfunc.c
index a03a81d..fe890fc 100644
--- a/gammu/emb/common/phone/pfunc.c
+++ b/gammu/emb/common/phone/pfunc.c
@@ -1,138 +1,139 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4#include <ctype.h> 4#include <ctype.h>
5 5
6#include "../gsmstate.h" 6#include "../gsmstate.h"
7#include "../service/sms/gsmsms.h" 7#include "../service/sms/gsmsms.h"
8#include "../misc/coding/coding.h" 8#include "../misc/coding/coding.h"
9 9
10/* These SMS layouts are used exactly as written in Nokia DCT3 phones. 10/* These SMS layouts are used exactly as written in Nokia DCT3 phones.
11 * In AT module(s) we have to use some layouts to convert AT frame to format 11 * In AT module(s) we have to use some layouts to convert AT frame to format
12 * understod by SMS module. To share source the same layouts are used */ 12 * understod by SMS module. To share source the same layouts are used */
13GSM_SMSMessageLayout PHONE_SMSDeliver = { 13GSM_SMSMessageLayout PHONE_SMSDeliver = {
14 35 /* SMS Text */, 16 /* Phone number*/, 14 35 /* SMS Text */, 16 /* Phone number*/,
15 0 /* SMSC Number */, 14 /* TPDCS */, 15 0 /* SMSC Number */, 14 /* TPDCS */,
16 28 /* SendingDateTime */, 255 /* SMSCDateTime*/, 16 28 /* SendingDateTime */, 255 /* SMSCDateTime*/,
17 255 /* TPStatus */, 15 /* TPUDL */, 17 255 /* TPStatus */, 15 /* TPUDL */,
18 255 /* TPVP */, 12 /* firstbyte*/, 18 255 /* TPVP */, 12 /* firstbyte*/,
19 255 /* TPMR */, 13 /* TPPID */}; 19 255 /* TPMR */, 13 /* TPPID */};
20GSM_SMSMessageLayout PHONE_SMSSubmit = { 20GSM_SMSMessageLayout PHONE_SMSSubmit = {
21 36 /* SMS Text */, 17 /* Phone number*/, 21 36 /* SMS Text */, 17 /* Phone number*/,
22 0 /* SMSC Number */, 15 /* TPDCS */, 22 0 /* SMSC Number */, 15 /* TPDCS */,
23 255 /* SendingDateTime */, 255 /* SMSCDateTime*/, 23 255 /* SendingDateTime */, 255 /* SMSCDateTime*/,
24 255 /* TPStatus */, 16 /* TPUDL */, 24 255 /* TPStatus */, 16 /* TPUDL */,
25 29 /* TPVP */, 12 /* firstbyte*/, 25 29 /* TPVP */, 12 /* firstbyte*/,
26 13 /* TPMR */, 14 /* TPPID */}; 26 13 /* TPMR */, 14 /* TPPID */};
27GSM_SMSMessageLayout PHONE_SMSStatusReport = { 27GSM_SMSMessageLayout PHONE_SMSStatusReport = {
28 255 /* SMS Text */, 15 /* Phone number*/, 28 255 /* SMS Text */, 15 /* Phone number*/,
29 0 /* SMSC Number */, 255 /* TPDCS */, 29 0 /* SMSC Number */, 255 /* TPDCS */,
30 27 /* SendingDateTime */, 34 /* SMSCDateTime*/, 30 27 /* SendingDateTime */, 34 /* SMSCDateTime*/,
31 14 /* TPStatus */, 255 /* TPUDL */, 31 14 /* TPStatus */, 255 /* TPUDL */,
32 255 /* TPVP */, 12 /* firstbyte*/, 32 255 /* TPVP */, 12 /* firstbyte*/,
33 13 /* TPMR */, 255 /* TPPID?? */}; 33 13 /* TPMR */, 255 /* TPPID?? */};
34 34
35GSM_Error PHONE_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders) 35GSM_Error PHONE_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
36{ 36{
37 folders->Number=2; 37 folders->Number=2;
38 EncodeUnicode(folders->Folder[0].Name,GetMsg(s->msg,"Inbox"),strlen(GetMsg(s->msg,"Inbox"))); 38 EncodeUnicode(folders->Folder[0].Name,GetMsg(s->msg,"Inbox"),strlen(GetMsg(s->msg,"Inbox")));
39 EncodeUnicode(folders->Folder[1].Name,GetMsg(s->msg,"Outbox"),strlen(GetMsg(s->msg,"Outbox"))); 39 EncodeUnicode(folders->Folder[1].Name,GetMsg(s->msg,"Outbox"),strlen(GetMsg(s->msg,"Outbox")));
40 folders->Folder[0].InboxFolder = true; 40 folders->Folder[0].InboxFolder = true;
41 folders->Folder[1].InboxFolder = false; 41 folders->Folder[1].InboxFolder = false;
42 folders->Folder[0].Memory = MEM_SM; 42 folders->Folder[0].Memory = MEM_SM;
43 folders->Folder[1].Memory = MEM_SM; 43 folders->Folder[1].Memory = MEM_SM;
44 return ERR_NONE; 44 return ERR_NONE;
45} 45}
46 46
47void GSM_CreateFirmwareNumber(GSM_StateMachine *s) 47void GSM_CreateFirmwareNumber(GSM_StateMachine *s)
48{ 48{
49 StringToDouble(s->Phone.Data.Version, &s->Phone.Data.VerNum); 49 StringToDouble(s->Phone.Data.Version, &s->Phone.Data.VerNum);
50 dbgprintf("Number version is \"%f\"\n", s->Phone.Data.VerNum); 50 dbgprintf("Number version is \"%f\"\n", s->Phone.Data.VerNum);
51} 51}
52 52
53GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, bool clear) 53GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, bool clear)
54{ 54{
55 GSM_Error error; 55 GSM_Error error;
56 56
57 if (SMS->SMSC.Location!=0) { 57 if (SMS->SMSC.Location!=0) {
58 error = s->Phone.Functions->GetSMSC(s, &SMS->SMSC); 58 error = s->Phone.Functions->GetSMSC(s, &SMS->SMSC);
59 if (error != ERR_NONE) return error; 59 if (error != ERR_NONE) return error;
60 SMS->SMSC.Location = 0; 60 SMS->SMSC.Location = 0;
61 } 61 }
62 if (SMS->PDU == SMS_Deliver) { 62 if (SMS->PDU == SMS_Deliver) {
63 if (SMS->SMSC.Number[0] == 0x00 && SMS->SMSC.Number[1] == 0x00) { 63 if (SMS->SMSC.Number[0] == 0x00 && SMS->SMSC.Number[1] == 0x00) {
64 smprintf(s,"No SMSC in SMS Deliver\n");
64 return ERR_EMPTYSMSC; 65 return ERR_EMPTYSMSC;
65 } 66 }
66 } 67 }
67 return GSM_EncodeSMSFrame(SMS, buffer, Layout, length, clear); 68 return GSM_EncodeSMSFrame(SMS, buffer, Layout, length, clear);
68} 69}
69 70
70GSM_Error PHONE_Terminate(GSM_StateMachine *s) 71GSM_Error PHONE_Terminate(GSM_StateMachine *s)
71{ 72{
72 GSM_Error error; 73 GSM_Error error;
73 74
74 if (s->Phone.Data.EnableIncomingCB==true) { 75 if (s->Phone.Data.EnableIncomingCB==true) {
75 error=s->Phone.Functions->SetIncomingCB(s,false); 76 error=s->Phone.Functions->SetIncomingCB(s,false);
76 if (error!=ERR_NONE) return error; 77 if (error!=ERR_NONE) return error;
77 } 78 }
78 if (s->Phone.Data.EnableIncomingSMS==true) { 79 if (s->Phone.Data.EnableIncomingSMS==true) {
79 error=s->Phone.Functions->SetIncomingSMS(s,false); 80 error=s->Phone.Functions->SetIncomingSMS(s,false);
80 if (error!=ERR_NONE) return error; 81 if (error!=ERR_NONE) return error;
81 } 82 }
82 return ERR_NONE; 83 return ERR_NONE;
83} 84}
84 85
85GSM_Error PHONE_RTTLPlayOneNote(GSM_StateMachine *s, GSM_RingNote note, bool first) 86GSM_Error PHONE_RTTLPlayOneNote(GSM_StateMachine *s, GSM_RingNote note, bool first)
86{ 87{
87 int duration, Hz; 88 int duration, Hz;
88 GSM_Error error; 89 GSM_Error error;
89 90
90 Hz=GSM_RingNoteGetFrequency(note); 91 Hz=GSM_RingNoteGetFrequency(note);
91 92
92 error=s->Phone.Functions->PlayTone(s,Hz,5,first); 93 error=s->Phone.Functions->PlayTone(s,Hz,5,first);
93 if (error!=ERR_NONE) return error; 94 if (error!=ERR_NONE) return error;
94 95
95 duration = GSM_RingNoteGetFullDuration(note); 96 duration = GSM_RingNoteGetFullDuration(note);
96 97
97 /* Is it correct ? Experimental values here */ 98 /* Is it correct ? Experimental values here */
98 switch (note.Style) { 99 switch (note.Style) {
99 case StaccatoStyle: 100 case StaccatoStyle:
100 my_sleep (7500); 101 my_sleep (7500);
101 error=s->Phone.Functions->PlayTone(s,0,0,false); 102 error=s->Phone.Functions->PlayTone(s,0,0,false);
102 if (error != ERR_NONE) return error; 103 if (error != ERR_NONE) return error;
103 my_sleep ((1400000/note.Tempo*duration)-(7500)); 104 my_sleep ((1400000/note.Tempo*duration)-(7500));
104 break; 105 break;
105 case ContinuousStyle: 106 case ContinuousStyle:
106 my_sleep (1400000/note.Tempo*duration); 107 my_sleep (1400000/note.Tempo*duration);
107 break; 108 break;
108 case NaturalStyle: 109 case NaturalStyle:
109 my_sleep (1400000/note.Tempo*duration-50); 110 my_sleep (1400000/note.Tempo*duration-50);
110 error=s->Phone.Functions->PlayTone(s,0,0,false); 111 error=s->Phone.Functions->PlayTone(s,0,0,false);
111 if (error != ERR_NONE) return error; 112 if (error != ERR_NONE) return error;
112 my_sleep (50); 113 my_sleep (50);
113 break; 114 break;
114 } 115 }
115 return ERR_NONE; 116 return ERR_NONE;
116} 117}
117 118
118GSM_Error PHONE_Beep(GSM_StateMachine *s) 119GSM_Error PHONE_Beep(GSM_StateMachine *s)
119{ 120{
120 GSM_Error error; 121 GSM_Error error;
121 122
122 error=s->Phone.Functions->PlayTone(s, 4000, 5,true); 123 error=s->Phone.Functions->PlayTone(s, 4000, 5,true);
123 if (error!=ERR_NONE) return error; 124 if (error!=ERR_NONE) return error;
124 125
125 my_sleep(500); 126 my_sleep(500);
126 127
127 return s->Phone.Functions->PlayTone(s,255*255,0,false); 128 return s->Phone.Functions->PlayTone(s,255*255,0,false);
128} 129}
129 130
130GSM_Error NoneReply(GSM_Protocol_Message msg, GSM_StateMachine *s) 131GSM_Error NoneReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
131{ 132{
132 smprintf(s,"None answer\n"); 133 smprintf(s,"None answer\n");
133 return ERR_NONE; 134 return ERR_NONE;
134} 135}
135 136
136/* How should editor hadle tabs in this file? Add editor commands here. 137/* How should editor hadle tabs in this file? Add editor commands here.
137 * vim: noexpandtab sw=8 ts=8 sts=8: 138 * vim: noexpandtab sw=8 ts=8 sts=8:
138 */ 139 */
diff --git a/gammu/emb/common/phone/symbian/mroutgen.c b/gammu/emb/common/phone/symbian/mroutgen.c
index a7382cf..63d26cf 100644
--- a/gammu/emb/common/phone/symbian/mroutgen.c
+++ b/gammu/emb/common/phone/symbian/mroutgen.c
@@ -1,221 +1,227 @@
1/* (c) 2003 by Marcin Wiacek */ 1/* (c) 2003 by Marcin Wiacek */
2/* EXPERIMENTAL. NOT FUNCTIONAL */ 2/* EXPERIMENTAL. NOT FUNCTIONAL */
3 3
4#include <string.h> 4#include <string.h>
5#include <time.h> 5#include <time.h>
6 6
7#include "../../gsmcomon.h" 7#include "../../gsmcomon.h"
8#include "../../gsmstate.h" 8#include "../../gsmstate.h"
9#include "../../misc/coding/coding.h" 9#include "../../misc/coding/coding.h"
10#include "../../service/gsmmisc.h" 10#include "../../service/gsmmisc.h"
11 11
12#ifdef GSM_ENABLE_MROUTERGEN 12#ifdef GSM_ENABLE_MROUTERGEN
13 13
14GSM_Error MROUTERGEN_StartModem(GSM_StateMachine *s) 14GSM_Error MROUTERGEN_StartModem(GSM_StateMachine *s)
15{ 15{
16 return ERR_NONE; 16 return ERR_NONE;
17} 17}
18 18
19GSM_Error MROUTERGEN_Initialise(GSM_StateMachine *s) 19GSM_Error MROUTERGEN_Initialise(GSM_StateMachine *s)
20{ 20{
21 21
22unsigned char req2[]={0xFF,0x03,0x80,0xFD,0x04,0x01,0x00,0x09,0x11, 22unsigned char req2[]={0xFF,0x03,0x80,0xFD,0x04,0x01,0x00,0x09,0x11,
230x05,0x00,0x01,0x03,0x77,0xBC}; 230x05,0x00,0x01,0x03,0x77,0xBC};
24 24
25unsigned char req0[]={ 25unsigned char req0[]={
260xFF,0x7D,0x23,0xC0,0x21,0x7D,0x21,0x7D,0x24,0x7D, 260xFF,0x7D,0x23,0xC0,0x21,0x7D,0x21,0x7D,0x24,0x7D,
270x20,0x7D,0x2E,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D, 270x20,0x7D,0x2E,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D,
280x20,0x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D, 280x20,0x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D,
290x28,0x7D,0x22,0x69,0x27, 290x28,0x7D,0x22,0x69,0x27,
300x7E, 300x7E,
31 31
320x7E, 320x7E,
330xFF,0x7D,0x23,0xC0,0x21,0x7D,0x22,0x7D,0x21,0x7D, 330xFF,0x7D,0x23,0xC0,0x21,0x7D,0x22,0x7D,0x21,0x7D,
340x20,0x7D,0x34,0x7D,0x25,0x7D,0x26,0x87,0xB9,0x7D, 340x20,0x7D,0x34,0x7D,0x25,0x7D,0x26,0x87,0xB9,0x7D,
350x28,0xCF,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D,0x20, 350x28,0xCF,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D,0x20,
360x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D,0x28, 360x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D,0x28,
370x7D,0x22,0x82,0xB0, 370x7D,0x22,0x82,0xB0,
380x7E, 380x7E,
39 39
400x7E, 400x7E,
410xFF,0x7D,0x23,0xC0,0x21,0x7D,0x21,0x7D,0x24,0x7D, 410xFF,0x7D,0x23,0xC0,0x21,0x7D,0x21,0x7D,0x24,0x7D,
420x20,0x7D,0x2E,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D, 420x20,0x7D,0x2E,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D,
430x20,0x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D, 430x20,0x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D,
440x28,0x7D,0x22,0x69,0x27, 440x28,0x7D,0x22,0x69,0x27,
450x7E, 450x7E,
46 46
470x7E, 470x7E,
480xFF,0x7D,0x23,0xC0,0x21,0x7D,0x22,0x7D,0x21,0x7D, 480xFF,0x7D,0x23,0xC0,0x21,0x7D,0x22,0x7D,0x21,0x7D,
490x20,0x7D,0x34,0x7D,0x25,0x7D,0x26,0x87,0xB9,0x7D, 490x20,0x7D,0x34,0x7D,0x25,0x7D,0x26,0x87,0xB9,0x7D,
500x28,0xCF,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D,0x20, 500x28,0xCF,0x7D,0x22,0x7D,0x26,0x7D,0x20,0x7D,0x20,
510x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D,0x28, 510x7D,0x20,0x7D,0x20,0x7D,0x27,0x7D,0x22,0x7D,0x28,
520x7D,0x22,0x82,0xB0}; 520x7D,0x22,0x82,0xB0};
53 53
54unsigned char req[]={0x2F,0x45,0x00,0x00,0x34,0x00,0xC6, 54unsigned char req[]={0x2F,0x45,0x00,0x00,0x34,0x00,0xC6,
55 0x00,0x00,0x0A,0x0D,0x59,0xB4,0xA9,0xFE,0x01, 55 0x00,0x00,0x0A,0x0D,0x59,0xB4,0xA9,0xFE,0x01,
56 0x44,0xA9,0xFE,0x01,0x0A,0x04,0x09,0x0B,0xB8, 56 0x44,0xA9,0xFE,0x01,0x0A,0x04,0x09,0x0B,0xB8,
57 0x10,0x00,0x02,0x79,0x69,0x81,0x74,0x99,0x50, 57 0x10,0x00,0x02,0x79,0x69,0x81,0x74,0x99,0x50,
58 0x18,0x60,0x00,0x9D,0x0C,0x00,0x00,0x08,0x00, 58 0x18,0x60,0x00,0x9D,0x0C,0x00,0x00,0x08,0x00,
59 0x00,0x00,0x12,0x00,0x41,0x00,0x01,0x14,0x00, 59 0x00,0x00,0x12,0x00,0x41,0x00,0x01,0x14,0x00,
60 0x00,0xBA,0x4A}; 60 0x00,0xBA,0x4A};
61 61
62unsigned char req3[]={0x2D,0x5C,0x0D,0xEC,0x4C,0x10,0x26,0x08,0x00, 62unsigned char req3[]={0x2D,0x5C,0x0D,0xEC,0x4C,0x10,0x26,0x08,0x00,
630x00,0x00,0x12,0x00,0x15,0x00,0x01,0x08,0x00,0x00, 630x00,0x00,0x12,0x00,0x15,0x00,0x01,0x08,0x00,0x00,
640xAD,0xDE}; 640xAD,0xDE};
65smprintf(s,"writing\n"); 65smprintf(s,"writing\n");
66 GSM_WaitFor (s, req0, 164, 0x00, 200, ID_Initialise); 66 GSM_WaitFor (s, req0, 164, 0x00, 200, ID_Initialise);
67smprintf(s,"writing\n"); 67smprintf(s,"writing\n");
68 GSM_WaitFor (s, req3, 21, 0x00, 200, ID_Initialise); 68 GSM_WaitFor (s, req3, 21, 0x00, 200, ID_Initialise);
69 GSM_WaitFor (s, req, 55, 0x00, 200, ID_Initialise); 69 GSM_WaitFor (s, req, 55, 0x00, 200, ID_Initialise);
70 70
71 GSM_WaitFor (s, req2, 15, 0x00, 200, ID_Initialise); 71 GSM_WaitFor (s, req2, 15, 0x00, 200, ID_Initialise);
72 72
73 73
74 while (1) { 74 while (1) {
75 GSM_ReadDevice(s,false); 75 GSM_ReadDevice(s,false);
76 } 76 }
77 77
78 78
79 79
80 while (1) { 80 while (1) {
81 GSM_ReadDevice(s,false); 81 GSM_ReadDevice(s,false);
82 } 82 }
83 83
84 84
85return ERR_UNKNOWN; 85return ERR_UNKNOWN;
86} 86}
87 87
88static GSM_Reply_Function MROUTERGENReplyFunctions[] = { 88static GSM_Reply_Function MROUTERGENReplyFunctions[] = {
89 {NULL, "\x00",0x00,0x00,ID_None } 89 {NULL, "\x00",0x00,0x00,ID_None }
90}; 90};
91 91
92GSM_Phone_Functions MROUTERGENPhone = { 92GSM_Phone_Functions MROUTERGENPhone = {
93 "mrouter", 93 "mrouter",
94 MROUTERGENReplyFunctions, 94 MROUTERGENReplyFunctions,
95 MROUTERGEN_Initialise, 95 MROUTERGEN_Initialise,
96 NONEFUNCTION, /* Terminate */ 96 NONEFUNCTION, /* Terminate */
97 GSM_DispatchMessage, 97 GSM_DispatchMessage,
98 NOTSUPPORTED, /* ShowStartInfo */ 98 NOTSUPPORTED, /* ShowStartInfo */
99 NONEFUNCTION, /* GetManufacturer */ 99 NONEFUNCTION, /* GetManufacturer */
100 NONEFUNCTION, /* GetModel */ 100 NONEFUNCTION, /* GetModel */
101 NONEFUNCTION, /* GetFirmware */ 101 NONEFUNCTION, /* GetFirmware */
102 NOTIMPLEMENTED, /* GetIMEI */ 102 NOTIMPLEMENTED, /* GetIMEI */
103 NOTSUPPORTED, /* GetOriginalIMEI */ 103 NOTSUPPORTED, /* GetOriginalIMEI */
104 NOTSUPPORTED, /* GetManufactureMonth*/ 104 NOTSUPPORTED, /* GetManufactureMonth*/
105 NOTSUPPORTED, /* GetProductCode */ 105 NOTSUPPORTED, /* GetProductCode */
106 NOTSUPPORTED, /* GetHardware */ 106 NOTSUPPORTED, /* GetHardware */
107 NOTSUPPORTED, /* GetPPM */ 107 NOTSUPPORTED, /* GetPPM */
108 NOTSUPPORTED, /* GetSIMIMSI */ 108 NOTSUPPORTED, /* GetSIMIMSI */
109 NOTSUPPORTED, /* GetDateTime */ 109 NOTSUPPORTED, /* GetDateTime */
110 NOTSUPPORTED, /* SetDateTime */ 110 NOTSUPPORTED, /* SetDateTime */
111 NOTSUPPORTED, /* GetAlarm */ 111 NOTSUPPORTED, /* GetAlarm */
112 NOTSUPPORTED, /* SetAlarm */ 112 NOTSUPPORTED, /* SetAlarm */
113 NOTSUPPORTED, /* GetLocale */ 113 NOTSUPPORTED, /* GetLocale */
114 NOTSUPPORTED, /* SetLocale */ 114 NOTSUPPORTED, /* SetLocale */
115 NOTSUPPORTED, /* PressKey */ 115 NOTSUPPORTED, /* PressKey */
116 NOTSUPPORTED, /* Reset */ 116 NOTSUPPORTED, /* Reset */
117 NOTSUPPORTED, /* ResetPhoneSettings*/ 117 NOTSUPPORTED, /* ResetPhoneSettings*/
118 NOTSUPPORTED, /* EnterSecurityCode*/ 118 NOTSUPPORTED, /* EnterSecurityCode*/
119 NOTSUPPORTED, /* GetSecurityStatus*/ 119 NOTSUPPORTED, /* GetSecurityStatus*/
120 NOTSUPPORTED, /* GetDisplayStatus*/ 120 NOTSUPPORTED, /* GetDisplayStatus*/
121 NOTSUPPORTED, /* SetAutoNetworkLogin*/ 121 NOTSUPPORTED, /* SetAutoNetworkLogin*/
122 NOTSUPPORTED, /* GetBatteryCharge*/ 122 NOTSUPPORTED, /* GetBatteryCharge*/
123 NOTSUPPORTED, /* GetSignalQuality*/ 123 NOTSUPPORTED, /* GetSignalQuality*/
124 NOTSUPPORTED, /* GetNetworkInfo */ 124 NOTSUPPORTED, /* GetNetworkInfo */
125 NOTSUPPORTED, /* GetCategory */ 125 NOTSUPPORTED, /* GetCategory */
126 NOTSUPPORTED, /* GetCategoryStatus */ 126 NOTSUPPORTED, /* GetCategoryStatus */
127 NOTSUPPORTED, /* GetMemoryStatus */ 127 NOTSUPPORTED, /* GetMemoryStatus */
128 NOTSUPPORTED, /* GetMemory */ 128 NOTSUPPORTED, /* GetMemory */
129 NOTSUPPORTED, /* GetNextMemory */ 129 NOTSUPPORTED, /* GetNextMemory */
130 NOTSUPPORTED, /* SetMemory */ 130 NOTSUPPORTED, /* SetMemory */
131 NOTSUPPORTED, /* AddMemory */ 131 NOTSUPPORTED, /* AddMemory */
132 NOTSUPPORTED, /* DeleteMemory */ 132 NOTSUPPORTED, /* DeleteMemory */
133 NOTIMPLEMENTED, /* DeleteAllMemory */ 133 NOTIMPLEMENTED, /* DeleteAllMemory */
134 NOTSUPPORTED, /* GetSpeedDial */ 134 NOTSUPPORTED, /* GetSpeedDial */
135 NOTSUPPORTED, /* SetSpeedDial */ 135 NOTSUPPORTED, /* SetSpeedDial */
136 NOTSUPPORTED, /* GetSMSC */ 136 NOTSUPPORTED, /* GetSMSC */
137 NOTSUPPORTED, /* SetSMSC */ 137 NOTSUPPORTED, /* SetSMSC */
138 NOTSUPPORTED, /* GetSMSStatus */ 138 NOTSUPPORTED, /* GetSMSStatus */
139 NOTSUPPORTED, /* GetSMS */ 139 NOTSUPPORTED, /* GetSMS */
140 NOTSUPPORTED, /* GetNextSMS */ 140 NOTSUPPORTED, /* GetNextSMS */
141 NOTSUPPORTED, /* SetSMS */ 141 NOTSUPPORTED, /* SetSMS */
142 NOTSUPPORTED, /* AddSMS */ 142 NOTSUPPORTED, /* AddSMS */
143 NOTSUPPORTED, /* DeleteSMS */ 143 NOTSUPPORTED, /* DeleteSMS */
144 NOTSUPPORTED, /* SendSMSMessage */ 144 NOTSUPPORTED, /* SendSMSMessage */
145 NOTSUPPORTED, /* SendSavedSMS */ 145 NOTSUPPORTED, /* SendSavedSMS */
146 NOTSUPPORTED, /* SetFastSMSSending*/ 146 NOTSUPPORTED, /* SetFastSMSSending*/
147 NOTSUPPORTED, /* SetIncomingSMS */ 147 NOTSUPPORTED, /* SetIncomingSMS */
148 NOTSUPPORTED, /* SetIncomingCB */ 148 NOTSUPPORTED, /* SetIncomingCB */
149 NOTSUPPORTED, /* GetSMSFolders */ 149 NOTSUPPORTED, /* GetSMSFolders */
150 NOTSUPPORTED, /* AddSMSFolder */ 150 NOTSUPPORTED, /* AddSMSFolder */
151 NOTSUPPORTED, /* DeleteSMSFolder */ 151 NOTSUPPORTED, /* DeleteSMSFolder */
152 NOTSUPPORTED, /* DialVoice */ 152 NOTSUPPORTED, /* DialVoice */
153 NOTSUPPORTED, /* AnswerCall */ 153 NOTSUPPORTED, /* AnswerCall */
154 NOTSUPPORTED, /* CancelCall */ 154 NOTSUPPORTED, /* CancelCall */
155 NOTSUPPORTED, /* HoldCall */ 155 NOTSUPPORTED, /* HoldCall */
156 NOTSUPPORTED, /* UnholdCall */ 156 NOTSUPPORTED, /* UnholdCall */
157 NOTSUPPORTED, /* ConferenceCall */ 157 NOTSUPPORTED, /* ConferenceCall */
158 NOTSUPPORTED, /* SplitCall */ 158 NOTSUPPORTED, /* SplitCall */
159 NOTSUPPORTED, /* TransferCall */ 159 NOTSUPPORTED, /* TransferCall */
160 NOTSUPPORTED, /* SwitchCall */ 160 NOTSUPPORTED, /* SwitchCall */
161 NOTSUPPORTED, /* GetCallDivert */ 161 NOTSUPPORTED, /* GetCallDivert */
162 NOTSUPPORTED, /* SetCallDivert */ 162 NOTSUPPORTED, /* SetCallDivert */
163 NOTSUPPORTED, /* CancelAllDiverts*/ 163 NOTSUPPORTED, /* CancelAllDiverts*/
164 NOTSUPPORTED, /* SetIncomingCall */ 164 NOTSUPPORTED, /* SetIncomingCall */
165 NOTSUPPORTED, /* SetIncomingUSSD */ 165 NOTSUPPORTED, /* SetIncomingUSSD */
166 NOTSUPPORTED, /* SendDTMF */ 166 NOTSUPPORTED, /* SendDTMF */
167 NOTSUPPORTED, /* GetRingtone */ 167 NOTSUPPORTED, /* GetRingtone */
168 NOTSUPPORTED, /* SetRingtone */ 168 NOTSUPPORTED, /* SetRingtone */
169 NOTSUPPORTED, /* GetRingtonesInfo*/ 169 NOTSUPPORTED, /* GetRingtonesInfo*/
170 NOTSUPPORTED, /* DeleteUserRingtones*/ 170 NOTSUPPORTED, /* DeleteUserRingtones*/
171 NOTSUPPORTED, /* PlayTone */ 171 NOTSUPPORTED, /* PlayTone */
172 NOTSUPPORTED, /* GetWAPBookmark */ 172 NOTSUPPORTED, /* GetWAPBookmark */
173 NOTSUPPORTED, /* SetWAPBookmark */ 173 NOTSUPPORTED, /* SetWAPBookmark */
174 NOTSUPPORTED, /* DeleteWAPBookmark */ 174 NOTSUPPORTED, /* DeleteWAPBookmark */
175 NOTSUPPORTED, /* GetWAPSettings */ 175 NOTSUPPORTED, /* GetWAPSettings */
176 NOTSUPPORTED, /* SetWAPSettings */ 176 NOTSUPPORTED, /* SetWAPSettings */
177 NOTSUPPORTED, /* GetMMSSettings */ 177 NOTSUPPORTED, /* GetMMSSettings */
178 NOTSUPPORTED, /* SetMMSSettings */ 178 NOTSUPPORTED, /* SetMMSSettings */
179 NOTSUPPORTED, /* GetSyncMLSettings*/ 179 NOTSUPPORTED, /* GetSyncMLSettings*/
180 NOTSUPPORTED, /* SetSyncMLSettings*/ 180 NOTSUPPORTED, /* SetSyncMLSettings*/
181 NOTSUPPORTED, /* GetChatSettings */ 181 NOTSUPPORTED, /* GetChatSettings */
182 NOTSUPPORTED, /* SetChatSettings */ 182 NOTSUPPORTED, /* SetChatSettings */
183 NOTSUPPORTED, /* GetBitmap */ 183 NOTSUPPORTED, /* GetBitmap */
184 NOTSUPPORTED, /* SetBitmap */ 184 NOTSUPPORTED, /* SetBitmap */
185 NOTSUPPORTED, /* GetToDoStatus */ 185 NOTSUPPORTED, /* GetToDoStatus */
186 NOTSUPPORTED, /* GetToDo */ 186 NOTSUPPORTED, /* GetToDo */
187 NOTSUPPORTED, /* GetNextToDo */ 187 NOTSUPPORTED, /* GetNextToDo */
188 NOTSUPPORTED, /* SetToDo */ 188 NOTSUPPORTED, /* SetToDo */
189 NOTSUPPORTED, /* AddToDo */ 189 NOTSUPPORTED, /* AddToDo */
190 NOTSUPPORTED, /* DeleteToDo */ 190 NOTSUPPORTED, /* DeleteToDo */
191 NOTSUPPORTED, /* DeleteAllToDo */ 191 NOTSUPPORTED, /* DeleteAllToDo */
192 NOTSUPPORTED, /* GetCalendarStatus*/ 192 NOTSUPPORTED, /* GetCalendarStatus*/
193 NOTSUPPORTED, /* GetCalendar */ 193 NOTSUPPORTED, /* GetCalendar */
194 NOTSUPPORTED, /* GetNextCalendar */ 194 NOTSUPPORTED, /* GetNextCalendar */
195 NOTSUPPORTED, /* SetCalendar */ 195 NOTSUPPORTED, /* SetCalendar */
196 NOTSUPPORTED, /* AddCalendar */ 196 NOTSUPPORTED, /* AddCalendar */
197 NOTSUPPORTED, /* DeleteCalendar */ 197 NOTSUPPORTED, /* DeleteCalendar */
198 NOTSUPPORTED, /* DeleteAllCalendar*/ 198 NOTSUPPORTED, /* DeleteAllCalendar*/
199 NOTSUPPORTED, /* GetCalendarSettings*/ 199 NOTSUPPORTED, /* GetCalendarSettings*/
200 NOTSUPPORTED, /* SetCalendarSettings*/ 200 NOTSUPPORTED, /* SetCalendarSettings*/
201 NOTSUPPORTED, /* GetNoteStatus */
202 NOTSUPPORTED, /* GetNote */
201 NOTSUPPORTED, /* GetNextNote */ 203 NOTSUPPORTED, /* GetNextNote */
204 NOTSUPPORTED, /* SetNote */
205 NOTSUPPORTED, /* AddNote */
206 NOTSUPPORTED, /* DeleteNote */
207 NOTSUPPORTED, /* DeleteAllNotes */
202 NOTSUPPORTED, /* GetProfile */ 208 NOTSUPPORTED, /* GetProfile */
203 NOTSUPPORTED, /* SetProfile */ 209 NOTSUPPORTED, /* SetProfile */
204 NOTSUPPORTED, /* GetFMStation */ 210 NOTSUPPORTED, /* GetFMStation */
205 NOTSUPPORTED, /* SetFMStation */ 211 NOTSUPPORTED, /* SetFMStation */
206 NOTSUPPORTED, /* ClearFMStations */ 212 NOTSUPPORTED, /* ClearFMStations */
207 NOTSUPPORTED, /* GetNextFileFolder*/ 213 NOTSUPPORTED, /* GetNextFileFolder*/
208 NOTSUPPORTED, /* GetFilePart */ 214 NOTSUPPORTED, /* GetFilePart */
209 NOTSUPPORTED, /* AddFilePart */ 215 NOTSUPPORTED, /* AddFilePart */
210 NOTSUPPORTED, /* GetFileSystemStatus*/ 216 NOTSUPPORTED, /* GetFileSystemStatus*/
211 NOTSUPPORTED, /* DeleteFile */ 217 NOTSUPPORTED, /* DeleteFile */
212 NOTSUPPORTED, /* AddFolder */ 218 NOTSUPPORTED, /* AddFolder */
213 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 219 NOTSUPPORTED, /* GetGPRSAccessPoint*/
214 NOTSUPPORTED /* SetGPRSAccessPoint*/ 220 NOTSUPPORTED /* SetGPRSAccessPoint*/
215}; 221};
216 222
217#endif 223#endif
218 224
219/* How should editor hadle tabs in this file? Add editor commands here. 225/* How should editor hadle tabs in this file? Add editor commands here.
220 * vim: noexpandtab sw=8 ts=8 sts=8: 226 * vim: noexpandtab sw=8 ts=8 sts=8:
221 */ 227 */
diff --git a/gammu/emb/common/protocol/nokia/fbus2.c b/gammu/emb/common/protocol/nokia/fbus2.c
index 2b41f8b..967eaa4 100644
--- a/gammu/emb/common/protocol/nokia/fbus2.c
+++ b/gammu/emb/common/protocol/nokia/fbus2.c
@@ -1,448 +1,458 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* based on some work from MyGnokii (www.mwiacek.com) */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3/* Based on some work from Gnokii (www.gnokii.org) 3/* Based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later 5 * GNU GPL version 2 or later
6 */ 6 */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#include "../../gsmstate.h" 17#include "../../gsmstate.h"
9 18
10#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) 19#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303)
11 20
12#include <stdio.h> 21#include <stdio.h>
13#include <string.h> 22#include <string.h>
14 23
15#include "../../gsmcomon.h" 24#include "../../gsmcomon.h"
16#include "fbus2.h" 25#include "fbus2.h"
17 26
18 static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s, 27 static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s,
19 unsigned char *MsgBuffer, 28 unsigned char *MsgBuffer,
20 int MsgLength, 29 int MsgLength,
21 unsigned char MsgType) 30 unsigned char MsgType)
22{ 31{
23 unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 10]; 32 unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 10];
24 unsigned char checksum=0; 33 unsigned char checksum=0;
25 int i, len, sent; 34 int i, len, sent;
26 35
27 buffer2[0] = FBUS2_FRAME_ID; 36 buffer2[0] = FBUS2_FRAME_ID;
28 if (s->ConnectionType==GCT_FBUS2IRDA) buffer2[0] = FBUS2_IRDA_FRAME_ID; 37 if (s->ConnectionType==GCT_FBUS2IRDA) buffer2[0] = FBUS2_IRDA_FRAME_ID;
29 38
30 buffer2[1] = FBUS2_DEVICE_PHONE; //destination 39 buffer2[1] = FBUS2_DEVICE_PHONE; //destination
31 buffer2[2] = FBUS2_DEVICE_PC; //source 40 buffer2[2] = FBUS2_DEVICE_PC; //source
32 buffer2[3]= MsgType; 41 buffer2[3]= MsgType;
33 buffer2[4]= MsgLength / 256; 42 buffer2[4]= MsgLength / 256;
34 buffer2[5]= MsgLength % 256; 43 buffer2[5]= MsgLength % 256;
35 44
36 memcpy(buffer2 + 6, MsgBuffer, MsgLength); 45 memcpy(buffer2 + 6, MsgBuffer, MsgLength);
37 len = MsgLength + 6; 46 len = MsgLength + 6;
38 47
39 /* Odd messages require additional 0x00 byte */ 48 /* Odd messages require additional 0x00 byte */
40 if (MsgLength % 2) buffer2[len++] = 0x00; 49 if (MsgLength % 2) buffer2[len++] = 0x00;
41 50
42 checksum = 0; 51 checksum = 0;
43 for (i = 0; i < len; i+=2) checksum ^= buffer2[i]; 52 for (i = 0; i < len; i+=2) checksum ^= buffer2[i];
44 buffer2[len++] = checksum; 53 buffer2[len++] = checksum;
45 54
46 checksum = 0; 55 checksum = 0;
47 for (i = 1; i < len; i+=2) checksum ^= buffer2[i]; 56 for (i = 1; i < len; i+=2) checksum ^= buffer2[i];
48 buffer2[len++] = checksum; 57 buffer2[len++] = checksum;
49 58
50 /* Sending to phone */ 59 /* Sending to phone */
51 sent=s->Device.Functions->WriteDevice(s,buffer2,len); 60 sent=s->Device.Functions->WriteDevice(s,buffer2,len);
52 if (sent!=len) return ERR_DEVICEWRITEERROR; 61 if (sent!=len) return ERR_DEVICEWRITEERROR;
53 62
54 return ERR_NONE; 63 return ERR_NONE;
55} 64}
56 65
57 static GSM_Error FBUS2_WriteMessage (GSM_StateMachine *s, 66 static GSM_Error FBUS2_WriteMessage (GSM_StateMachine *s,
58 unsigned char *MsgBuffer, 67 unsigned char *MsgBuffer,
59 int MsgLength, 68 int MsgLength,
60 unsigned char MsgType) 69 unsigned char MsgType)
61{ 70{
62 int i, nom, togo, thislength; /* number of messages, ... */ 71 int i, nom, togo, thislength; /* number of messages, ... */
63 unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 2], seqnum; 72 unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 2], seqnum;
64 GSM_Protocol_FBUS2Data*d = &s->Protocol.Data.FBUS2; 73 GSM_Protocol_FBUS2Data*d = &s->Protocol.Data.FBUS2;
65 GSM_Error error; 74 GSM_Error error;
66 75
67 GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); 76 GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType);
68 77
69 nom = (MsgLength + FBUS2_MAX_TRANSMIT_LENGTH - 1) / FBUS2_MAX_TRANSMIT_LENGTH; 78 nom = (MsgLength + FBUS2_MAX_TRANSMIT_LENGTH - 1) / FBUS2_MAX_TRANSMIT_LENGTH;
70 togo = MsgLength; 79 togo = MsgLength;
71 80
72 for (i = 0; i < nom; i++) { 81 for (i = 0; i < nom; i++) {
73 seqnum = d->MsgSequenceNumber; 82 seqnum = d->MsgSequenceNumber;
74 if (i==0) seqnum = seqnum + 0x40; 83 if (i==0) seqnum = seqnum + 0x40;
75 d->MsgSequenceNumber = (d->MsgSequenceNumber + 1) & 0x07; 84 d->MsgSequenceNumber = (d->MsgSequenceNumber + 1) & 0x07;
76 85
77 thislength = togo; 86 thislength = togo;
78 if (togo > FBUS2_MAX_TRANSMIT_LENGTH) thislength = FBUS2_MAX_TRANSMIT_LENGTH; 87 if (togo > FBUS2_MAX_TRANSMIT_LENGTH) thislength = FBUS2_MAX_TRANSMIT_LENGTH;
79 memcpy(buffer2, MsgBuffer + (MsgLength - togo), thislength); 88 memcpy(buffer2, MsgBuffer + (MsgLength - togo), thislength);
80 buffer2[thislength]= nom - i; 89 buffer2[thislength]= nom - i;
81 buffer2[thislength + 1]= seqnum; 90 buffer2[thislength + 1]= seqnum;
82 togo = togo - thislength; 91 togo = togo - thislength;
83 92
84 GSM_DumpMessageLevel2(s, buffer2, thislength, MsgType); 93 GSM_DumpMessageLevel2(s, buffer2, thislength, MsgType);
85 94
86 error=FBUS2_WriteFrame(s, buffer2, thislength + 2, MsgType); 95 error=FBUS2_WriteFrame(s, buffer2, thislength + 2, MsgType);
87 if (error!=ERR_NONE) return error; 96 if (error!=ERR_NONE) return error;
88 } 97 }
89 98
90 return ERR_NONE; 99 return ERR_NONE;
91} 100}
92 101
93 static GSM_Error FBUS2_SendAck(GSM_StateMachine *s, 102 static GSM_Error FBUS2_SendAck(GSM_StateMachine *s,
94 unsigned char MsgType, 103 unsigned char MsgType,
95 unsigned char MsgSequence) 104 unsigned char MsgSequence)
96{ 105{
97 unsigned char buffer2[2]; 106 unsigned char buffer2[2];
98 107
99 buffer2[0] = MsgType; 108 buffer2[0] = MsgType;
100 buffer2[1] = MsgSequence; 109 buffer2[1] = MsgSequence;
101 110
102 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 111 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
103 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 112 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
104 smprintf(s,"[Sending Ack of type %02x, seq %x]\n",buffer2[0],buffer2[1]); 113 smprintf(s,"[Sending Ack of type %02x, seq %x]\n",buffer2[0],buffer2[1]);
105 } 114 }
106 115
107 /* Sending to phone */ 116 /* Sending to phone */
108 return FBUS2_WriteFrame(s, buffer2, 2, FBUS2_ACK_BYTE); 117 return FBUS2_WriteFrame(s, buffer2, 2, FBUS2_ACK_BYTE);
109} 118}
110 119
111static GSM_Error FBUS2_StateMachine(GSM_StateMachine *s, unsigned char rx_char) 120static GSM_Error FBUS2_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
112{ 121{
113 GSM_Protocol_FBUS2Data *d = &s->Protocol.Data.FBUS2; 122 GSM_Protocol_FBUS2Data *d = &s->Protocol.Data.FBUS2;
114 unsigned char frm_num, seq_num; 123 unsigned char frm_num, seq_num;
115 bool correct = false; 124 bool correct = false;
116 125
117 /* XOR the byte with the earlier checksum */ 126 /* XOR the byte with the earlier checksum */
118 d->Msg.CheckSum[d->Msg.Count & 1] ^= rx_char; 127 d->Msg.CheckSum[d->Msg.Count & 1] ^= rx_char;
119 128
120 if (d->MsgRXState == RX_GetMessage) { 129 if (d->MsgRXState == RX_GetMessage) {
121 d->Msg.Buffer[d->Msg.Count] = rx_char; 130 d->Msg.Buffer[d->Msg.Count] = rx_char;
122 d->Msg.Count++; 131 d->Msg.Count++;
123 132
124 /* This is not last byte in frame */ 133 /* This is not last byte in frame */
125 if (d->Msg.Count != d->Msg.Length+(d->Msg.Length%2)+2) return ERR_NONE; 134 if (d->Msg.Count != d->Msg.Length+(d->Msg.Length%2)+2) return ERR_NONE;
126 135
127 /* Checksum is incorrect */ 136 /* Checksum is incorrect */
128 if (d->Msg.CheckSum[0] != d->Msg.CheckSum[1]) { 137 if (d->Msg.CheckSum[0] != d->Msg.CheckSum[1]) {
129 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 138 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
130 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 139 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
131 smprintf(s,"[ERROR: checksum]\n"); 140 smprintf(s,"[ERROR: checksum]\n");
132 } 141 }
133 free(d->Msg.Buffer); 142 free(d->Msg.Buffer);
134 d->Msg.Length = 0; 143 d->Msg.Length = 0;
135 d->Msg.Buffer = NULL; 144 d->Msg.Buffer = NULL;
136 145
137 d->MsgRXState = RX_Sync; 146 d->MsgRXState = RX_Sync;
138 return ERR_NONE; 147 return ERR_NONE;
139 } 148 }
140 149
141 seq_num = d->Msg.Buffer[d->Msg.Length-1]; 150 seq_num = d->Msg.Buffer[d->Msg.Length-1];
142 151
143 if (d->Msg.Type == FBUS2_ACK_BYTE) { 152 if (d->Msg.Type == FBUS2_ACK_BYTE) {
144 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || 153 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
145 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { 154 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
146 smprintf(s, "[Received Ack of type %02x, seq %02x]\n",d->Msg.Buffer[0],seq_num); 155 smprintf(s, "[Received Ack of type %02x, seq %02x]\n",d->Msg.Buffer[0],seq_num);
147 } 156 }
157 free(d->Msg.Buffer);
148 158
149 d->MsgRXState = RX_Sync; 159 d->MsgRXState = RX_Sync;
150 return ERR_NONE; 160 return ERR_NONE;
151 } 161 }
152 162
153 frm_num = d->Msg.Buffer[d->Msg.Length-2]; 163 frm_num = d->Msg.Buffer[d->Msg.Length-2];
154 164
155 if ((seq_num & 0x40) == 0x40) { 165 if ((seq_num & 0x40) == 0x40) {
156 d->FramesToGo = frm_num; 166 d->FramesToGo = frm_num;
157 d->MultiMsg.Length= 0; 167 d->MultiMsg.Length= 0;
158 d->MultiMsg.Type= d->Msg.Type; 168 d->MultiMsg.Type= d->Msg.Type;
159 d->MultiMsg.Destination= d->Msg.Destination; 169 d->MultiMsg.Destination= d->Msg.Destination;
160 d->MultiMsg.Source= d->Msg.Source; 170 d->MultiMsg.Source= d->Msg.Source;
161 } 171 }
162 172
163 if ((seq_num & 0x40) != 0x40 && d->FramesToGo != frm_num) { 173 if ((seq_num & 0x40) != 0x40 && d->FramesToGo != frm_num) {
164 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 174 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
165 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 175 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
166 smprintf(s, "[ERROR: Missed part of multiframe msg]\n"); 176 smprintf(s, "[ERROR: Missed part of multiframe msg]\n");
167 } 177 }
168 178
169 free(d->Msg.Buffer); 179 free(d->Msg.Buffer);
170 d->Msg.Length = 0; 180 d->Msg.Length = 0;
171 d->Msg.Buffer = NULL; 181 d->Msg.Buffer = NULL;
172 182
173 d->MsgRXState = RX_Sync; 183 d->MsgRXState = RX_Sync;
174 return ERR_NONE; 184 return ERR_NONE;
175 } 185 }
176 186
177 if ((seq_num & 0x40) != 0x40 && d->Msg.Type != d->MultiMsg.Type) { 187 if ((seq_num & 0x40) != 0x40 && d->Msg.Type != d->MultiMsg.Type) {
178 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 188 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
179 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 189 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
180 smprintf(s, "[ERROR: Multiframe msg in multiframe msg]\n"); 190 smprintf(s, "[ERROR: Multiframe msg in multiframe msg]\n");
181 } 191 }
182 192
183 free(d->Msg.Buffer); 193 free(d->Msg.Buffer);
184 d->Msg.Length = 0; 194 d->Msg.Length = 0;
185 d->Msg.Buffer = NULL; 195 d->Msg.Buffer = NULL;
186 196
187 d->MsgRXState = RX_Sync; 197 d->MsgRXState = RX_Sync;
188 return ERR_NONE; 198 return ERR_NONE;
189 } 199 }
190 200
191 if (d->MultiMsg.BufferUsed < d->MultiMsg.Length+d->Msg.Length-2) { 201 if (d->MultiMsg.BufferUsed < d->MultiMsg.Length+d->Msg.Length-2) {
192 d->MultiMsg.BufferUsed = d->MultiMsg.Length+d->Msg.Length-2; 202 d->MultiMsg.BufferUsed = d->MultiMsg.Length+d->Msg.Length-2;
193 d->MultiMsg.Buffer = (unsigned char *)realloc(d->MultiMsg.Buffer,d->MultiMsg.BufferUsed); 203 d->MultiMsg.Buffer = (unsigned char *)realloc(d->MultiMsg.Buffer,d->MultiMsg.BufferUsed);
194 } 204 }
195 memcpy(d->MultiMsg.Buffer+d->MultiMsg.Length,d->Msg.Buffer,d->Msg.Length-2); 205 memcpy(d->MultiMsg.Buffer+d->MultiMsg.Length,d->Msg.Buffer,d->Msg.Length-2);
196 d->MultiMsg.Length = d->MultiMsg.Length+d->Msg.Length-2; 206 d->MultiMsg.Length = d->MultiMsg.Length+d->Msg.Length-2;
197 207
198 free(d->Msg.Buffer); 208 free(d->Msg.Buffer);
199 d->Msg.Length = 0; 209 d->Msg.Length = 0;
200 d->Msg.Buffer = NULL; 210 d->Msg.Buffer = NULL;
201 211
202 d->FramesToGo--; 212 d->FramesToGo--;
203 213
204 /* do not ack debug trace, as this could generate a 214 /* do not ack debug trace, as this could generate a
205 * (feedback loop) flood of which even Noah would be scared. 215 * (feedback loop) flood of which even Noah would be scared.
206 */ 216 */
207 if (d->Msg.Type != 0) { 217 if (d->Msg.Type != 0) {
208 FBUS2_SendAck(s,d->Msg.Type,((unsigned char)(seq_num & 0x0f))); 218 FBUS2_SendAck(s,d->Msg.Type,((unsigned char)(seq_num & 0x0f)));
209 } 219 }
210 220
211 if (d->FramesToGo == 0) { 221 if (d->FramesToGo == 0) {
212 s->Phone.Data.RequestMsg= &d->MultiMsg; 222 s->Phone.Data.RequestMsg= &d->MultiMsg;
213 s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); 223 s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s);
214 } 224 }
215 d->MsgRXState = RX_Sync; 225 d->MsgRXState = RX_Sync;
216 return ERR_NONE; 226 return ERR_NONE;
217 } 227 }
218 if (d->MsgRXState == RX_GetLength2) { 228 if (d->MsgRXState == RX_GetLength2) {
219 d->Msg.Length = d->Msg.Length + rx_char; 229 d->Msg.Length = d->Msg.Length + rx_char;
220 d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length+3); 230 d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length+3);
221 d->MsgRXState = RX_GetMessage; 231 d->MsgRXState = RX_GetMessage;
222 return ERR_NONE; 232 return ERR_NONE;
223 } 233 }
224 if (d->MsgRXState == RX_GetLength1) { 234 if (d->MsgRXState == RX_GetLength1) {
225 d->Msg.Length = rx_char * 256; 235 d->Msg.Length = rx_char * 256;
226 d->MsgRXState = RX_GetLength2; 236 d->MsgRXState = RX_GetLength2;
227 return ERR_NONE; 237 return ERR_NONE;
228 } 238 }
229 if (d->MsgRXState == RX_GetType) { 239 if (d->MsgRXState == RX_GetType) {
230 d->Msg.Type = rx_char; 240 d->Msg.Type = rx_char;
231 d->MsgRXState = RX_GetLength1; 241 d->MsgRXState = RX_GetLength1;
232 return ERR_NONE; 242 return ERR_NONE;
233 } 243 }
234 if (d->MsgRXState == RX_GetSource) { 244 if (d->MsgRXState == RX_GetSource) {
235 if (rx_char != FBUS2_DEVICE_PHONE) { 245 if (rx_char != FBUS2_DEVICE_PHONE) {
236 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 246 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
237 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 247 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
238 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_DEVICE_PHONE); 248 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_DEVICE_PHONE);
239 } 249 }
240 250
241 d->MsgRXState = RX_Sync; 251 d->MsgRXState = RX_Sync;
242 return ERR_NONE; 252 return ERR_NONE;
243 } 253 }
244 d->Msg.Source = rx_char; 254 d->Msg.Source = rx_char;
245 255
246 d->MsgRXState = RX_GetType; 256 d->MsgRXState = RX_GetType;
247 return ERR_NONE; 257 return ERR_NONE;
248 } 258 }
249 if (d->MsgRXState == RX_GetDestination) { 259 if (d->MsgRXState == RX_GetDestination) {
250 if (rx_char != FBUS2_DEVICE_PC) { 260 if (rx_char != FBUS2_DEVICE_PC) {
251 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 261 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
252 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 262 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
253 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_DEVICE_PC); 263 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_DEVICE_PC);
254 } 264 }
255 265
256 d->MsgRXState = RX_Sync; 266 d->MsgRXState = RX_Sync;
257 return ERR_NONE; 267 return ERR_NONE;
258 } 268 }
259 d->Msg.Destination = rx_char; 269 d->Msg.Destination = rx_char;
260 270
261 d->MsgRXState = RX_GetSource; 271 d->MsgRXState = RX_GetSource;
262 return ERR_NONE; 272 return ERR_NONE;
263 } 273 }
264 if (d->MsgRXState == RX_Sync) { 274 if (d->MsgRXState == RX_Sync) {
265 switch (s->ConnectionType) { 275 switch (s->ConnectionType) {
266 case GCT_FBUS2: 276 case GCT_FBUS2:
267 case GCT_FBUS2DLR3: 277 case GCT_FBUS2DLR3:
268 case GCT_FBUS2DKU5: 278 case GCT_FBUS2DKU5:
269 case GCT_FBUS2PL2303: 279 case GCT_FBUS2PL2303:
270 case GCT_FBUS2BLUE: 280 case GCT_FBUS2BLUE:
271 case GCT_BLUEFBUS2: 281 case GCT_BLUEFBUS2:
272 if (rx_char == FBUS2_FRAME_ID) correct = true; 282 if (rx_char == FBUS2_FRAME_ID) correct = true;
273 break; 283 break;
274 case GCT_FBUS2IRDA: 284 case GCT_FBUS2IRDA:
275 if (rx_char == FBUS2_IRDA_FRAME_ID) correct = true; 285 if (rx_char == FBUS2_IRDA_FRAME_ID) correct = true;
276 break; 286 break;
277 default: 287 default:
278 break; 288 break;
279 } 289 }
280 if (!correct) { 290 if (!correct) {
281 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 291 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
282 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 292 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
283 if (s->ConnectionType==GCT_FBUS2IRDA) { 293 if (s->ConnectionType==GCT_FBUS2IRDA) {
284 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_IRDA_FRAME_ID); 294 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_IRDA_FRAME_ID);
285 } else { 295 } else {
286 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_FRAME_ID); 296 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_FRAME_ID);
287 } 297 }
288 } 298 }
289 return ERR_NONE; 299 return ERR_NONE;
290 } 300 }
291 301
292 d->Msg.CheckSum[0] = rx_char; 302 d->Msg.CheckSum[0] = rx_char;
293 d->Msg.CheckSum[1] = 0; 303 d->Msg.CheckSum[1] = 0;
294 d->Msg.Count = 0; 304 d->Msg.Count = 0;
295 305
296 d->MsgRXState = RX_GetDestination; 306 d->MsgRXState = RX_GetDestination;
297 return ERR_NONE; 307 return ERR_NONE;
298 } 308 }
299 return ERR_NONE; 309 return ERR_NONE;
300} 310}
301 311
302#if defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303) 312#if defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303)
303static void FBUS2_WriteDLR3(GSM_StateMachine *s, char *command, int length, int timeout) 313static void FBUS2_WriteDLR3(GSM_StateMachine *s, char *command, int length, int timeout)
304{ 314{
305 unsigned char buff[300]; 315 unsigned char buff[300];
306 int w = 0; 316 int w = 0;
307 bool wassomething = false; 317 bool wassomething = false;
308 318
309 s->Device.Functions->WriteDevice(s,command,length); 319 s->Device.Functions->WriteDevice(s,command,length);
310 320
311 for (w=0;w<timeout;w++) { 321 for (w=0;w<timeout;w++) {
312 if (wassomething) { 322 if (wassomething) {
313 if (s->Device.Functions->ReadDevice(s, buff, 255)==0) return; 323 if (s->Device.Functions->ReadDevice(s, buff, 255)==0) return;
314 } else { 324 } else {
315 if (s->Device.Functions->ReadDevice(s, buff, 255)>0) wassomething = true; 325 if (s->Device.Functions->ReadDevice(s, buff, 255)>0) wassomething = true;
316 } 326 }
317 my_sleep(50); 327 my_sleep(50);
318 } 328 }
319} 329}
320#endif 330#endif
321 331
322static GSM_Error FBUS2_Initialise(GSM_StateMachine *s) 332static GSM_Error FBUS2_Initialise(GSM_StateMachine *s)
323{ 333{
324 unsigned char init_char= 0x55; 334 unsigned char init_char= 0x55;
325#ifdef GSM_ENABLE_FBUS2IRDA 335#ifdef GSM_ENABLE_FBUS2IRDA
326 unsigned char end_init_char= 0xc1; 336 unsigned char end_init_char= 0xc1;
327#endif 337#endif
328 338
329 GSM_Protocol_FBUS2Data *d = &s->Protocol.Data.FBUS2; 339 GSM_Protocol_FBUS2Data *d = &s->Protocol.Data.FBUS2;
330 GSM_Device_Functions *Device = s->Device.Functions; 340 GSM_Device_Functions *Device = s->Device.Functions;
331 GSM_Error error; 341 GSM_Error error;
332 int count; 342 int count;
333 343
334 d->Msg.Length = 0; 344 d->Msg.Length = 0;
335 d->Msg.Buffer = NULL; 345 d->Msg.Buffer = NULL;
336 d->MultiMsg.BufferUsed= 0; 346 d->MultiMsg.BufferUsed= 0;
337 d->MultiMsg.Length= 0; 347 d->MultiMsg.Length= 0;
338 d->MultiMsg.Buffer= NULL; 348 d->MultiMsg.Buffer= NULL;
339 349
340 d->MsgSequenceNumber= 0; 350 d->MsgSequenceNumber= 0;
341 d->FramesToGo = 0; 351 d->FramesToGo = 0;
342 d->MsgRXState = RX_Sync; 352 d->MsgRXState = RX_Sync;
343 353
344 error=Device->DeviceSetParity(s,false); 354 error=Device->DeviceSetParity(s,false);
345 if (error!=ERR_NONE) return error; 355 if (error!=ERR_NONE) return error;
346 356
347 switch (s->ConnectionType) { 357 switch (s->ConnectionType) {
348#if defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2BLUE) 358#if defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2BLUE)
349 case GCT_FBUS2BLUE: 359 case GCT_FBUS2BLUE:
350 case GCT_BLUEFBUS2: 360 case GCT_BLUEFBUS2:
351 FBUS2_WriteDLR3(s,"AT\r\n", 4,10); 361 FBUS2_WriteDLR3(s,"AT\r\n", 4,10);
352 FBUS2_WriteDLR3(s,"AT&F\r\n", 6,10); 362 FBUS2_WriteDLR3(s,"AT&F\r\n", 6,10);
353 FBUS2_WriteDLR3(s,"AT*NOKIAFBUS\r\n",14,10); 363 FBUS2_WriteDLR3(s,"AT*NOKIAFBUS\r\n",14,10);
354 break; 364 break;
355#endif 365#endif
356#if defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) 366#if defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303)
357 case GCT_FBUS2DKU5: 367 case GCT_FBUS2DKU5:
358 case GCT_FBUS2PL2303: 368 case GCT_FBUS2PL2303:
359 case GCT_FBUS2DLR3: 369 case GCT_FBUS2DLR3:
360 error=Device->DeviceSetDtrRts(s,false,false); 370 error=Device->DeviceSetDtrRts(s,false,false);
361 if (error!=ERR_NONE) return error; 371 if (error!=ERR_NONE) return error;
362 my_sleep(1000); 372 my_sleep(1000);
363 373
364 error=Device->DeviceSetDtrRts(s,true,true); 374 error=Device->DeviceSetDtrRts(s,true,true);
365 if (error!=ERR_NONE) return error; 375 if (error!=ERR_NONE) return error;
366 error=Device->DeviceSetSpeed(s,19200); 376 error=Device->DeviceSetSpeed(s,19200);
367 if (error!=ERR_NONE) return error; 377 if (error!=ERR_NONE) return error;
368 378
369 FBUS2_WriteDLR3(s,"AT\r\n", 4,10); 379 FBUS2_WriteDLR3(s,"AT\r\n", 4,10);
370 FBUS2_WriteDLR3(s,"AT&F\r\n", 6,10); 380 FBUS2_WriteDLR3(s,"AT&F\r\n", 6,10);
371 FBUS2_WriteDLR3(s,"AT*NOKIAFBUS\r\n",14,10); 381 FBUS2_WriteDLR3(s,"AT*NOKIAFBUS\r\n",14,10);
372 382
373 error=Device->CloseDevice(s); 383 error=Device->CloseDevice(s);
374 if (error!=ERR_NONE) return error; 384 if (error!=ERR_NONE) return error;
375 my_sleep(1000); 385 my_sleep(1000);
376 386
377 error=Device->OpenDevice(s); 387 error=Device->OpenDevice(s);
378 if (error!=ERR_NONE) return error; 388 if (error!=ERR_NONE) return error;
379 error=Device->DeviceSetParity(s,false); 389 error=Device->DeviceSetParity(s,false);
380 if (error!=ERR_NONE) return error; 390 if (error!=ERR_NONE) return error;
381 error=Device->DeviceSetSpeed(s,115200); 391 error=Device->DeviceSetSpeed(s,115200);
382 if (error!=ERR_NONE) return error; 392 if (error!=ERR_NONE) return error;
383 error=Device->DeviceSetDtrRts(s,false,false); 393 error=Device->DeviceSetDtrRts(s,false,false);
384 if (error!=ERR_NONE) return error; 394 if (error!=ERR_NONE) return error;
385 395
386 for (count = 0; count < 55; count ++) { 396 for (count = 0; count < 55; count ++) {
387 if (Device->WriteDevice(s,&init_char,1)!=1) return ERR_DEVICEWRITEERROR; 397 if (Device->WriteDevice(s,&init_char,1)!=1) return ERR_DEVICEWRITEERROR;
388 } 398 }
389 break; 399 break;
390#endif 400#endif
391 case GCT_FBUS2: 401 case GCT_FBUS2:
392 error=Device->DeviceSetSpeed(s,115200); 402 error=Device->DeviceSetSpeed(s,115200);
393 if (error!=ERR_NONE) return error; 403 if (error!=ERR_NONE) return error;
394 404
395 error=Device->DeviceSetDtrRts(s,true,false); /*DTR high,RTS low*/ 405 error=Device->DeviceSetDtrRts(s,true,false); /*DTR high,RTS low*/
396 if (error!=ERR_NONE) return error; 406 if (error!=ERR_NONE) return error;
397 407
398 for (count = 0; count < 55; count ++) { 408 for (count = 0; count < 55; count ++) {
399 if (Device->WriteDevice(s,&init_char,1)!=1) return ERR_DEVICEWRITEERROR; 409 if (Device->WriteDevice(s,&init_char,1)!=1) return ERR_DEVICEWRITEERROR;
400 my_sleep(10); 410 my_sleep(10);
401 } 411 }
402 break; 412 break;
403#ifdef GSM_ENABLE_FBUS2IRDA 413#ifdef GSM_ENABLE_FBUS2IRDA
404 case GCT_FBUS2IRDA: 414 case GCT_FBUS2IRDA:
405 error=Device->DeviceSetSpeed(s,9600); 415 error=Device->DeviceSetSpeed(s,9600);
406 if (error!=ERR_NONE) return error; 416 if (error!=ERR_NONE) return error;
407 417
408 for (count = 0; count < 55; count ++) { 418 for (count = 0; count < 55; count ++) {
409 if (Device->WriteDevice(s,&init_char,1)!=1) return ERR_DEVICEWRITEERROR; 419 if (Device->WriteDevice(s,&init_char,1)!=1) return ERR_DEVICEWRITEERROR;
410 my_sleep(10); 420 my_sleep(10);
411 } 421 }
412 422
413 if (Device->WriteDevice(s,&end_init_char,1)!=1) return ERR_DEVICEWRITEERROR; 423 if (Device->WriteDevice(s,&end_init_char,1)!=1) return ERR_DEVICEWRITEERROR;
414 my_sleep(20); 424 my_sleep(20);
415 425
416 error=Device->DeviceSetSpeed(s,115200); 426 error=Device->DeviceSetSpeed(s,115200);
417 if (error!=ERR_NONE) return error; 427 if (error!=ERR_NONE) return error;
418 428
419 break; 429 break;
420#endif 430#endif
421 default: 431 default:
422 break; 432 break;
423 } 433 }
424 434
425 return ERR_NONE; 435 return ERR_NONE;
426} 436}
427 437
428static GSM_Error FBUS2_Terminate(GSM_StateMachine *s) 438static GSM_Error FBUS2_Terminate(GSM_StateMachine *s)
429{ 439{
430 free(s->Protocol.Data.FBUS2.Msg.Buffer); 440 free(s->Protocol.Data.FBUS2.Msg.Buffer);
431 free(s->Protocol.Data.FBUS2.MultiMsg.Buffer); 441 free(s->Protocol.Data.FBUS2.MultiMsg.Buffer);
432 442
433 my_sleep(200); 443 my_sleep(200);
434 return ERR_NONE; 444 return ERR_NONE;
435} 445}
436 446
437GSM_Protocol_Functions FBUS2Protocol = { 447GSM_Protocol_Functions FBUS2Protocol = {
438 FBUS2_WriteMessage, 448 FBUS2_WriteMessage,
439 FBUS2_StateMachine, 449 FBUS2_StateMachine,
440 FBUS2_Initialise, 450 FBUS2_Initialise,
441 FBUS2_Terminate 451 FBUS2_Terminate
442}; 452};
443 453
444#endif 454#endif
445 455
446/* How should editor hadle tabs in this file? Add editor commands here. 456/* How should editor hadle tabs in this file? Add editor commands here.
447 * vim: noexpandtab sw=8 ts=8 sts=8: 457 * vim: noexpandtab sw=8 ts=8 sts=8:
448 */ 458 */
diff --git a/gammu/emb/common/protocol/nokia/fbus2.h b/gammu/emb/common/protocol/nokia/fbus2.h
index 8dbcb07..3d31006 100644
--- a/gammu/emb/common/protocol/nokia/fbus2.h
+++ b/gammu/emb/common/protocol/nokia/fbus2.h
@@ -1,42 +1,51 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* based on some work from MyGnokii (www.mwiacek.com) */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3/* Based on some work from Gnokii (www.gnokii.org) 3/* Based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later 5 * GNU GPL version 2 or later
6 */ 6 */
7/* Due to a problem in the source code management, the names of some of
8 * the authors have unfortunately been lost. We do not mean to belittle
9 * their efforts and hope they will contact us to see their names
10 * properly added to the Copyright notice above.
11 * Having published their contributions under the terms of the GNU
12 * General Public License (GPL) [version 2], the Copyright of these
13 * authors will remain respected by adhering to the license they chose
14 * to publish their code under.
15 */
7 16
8#ifndef fbus2_h 17#ifndef fbus2_h
9#define fbus2_h 18#define fbus2_h
10 19
11#include "../protocol.h" 20#include "../protocol.h"
12 21
13 #define FBUS2_FRAME_ID 0x1e 22 #define FBUS2_FRAME_ID 0x1e
14 #define FBUS2_IRDA_FRAME_ID 0x1c 23 #define FBUS2_IRDA_FRAME_ID 0x1c
15 #define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ 24 #define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */
16 #define FBUS2_DEVICE_PC 0x0c /* Our PC */ 25 #define FBUS2_DEVICE_PC 0x0c /* Our PC */
17 #define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ 26 #define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */
18 27
19#define FBUS2_MAX_TRANSMIT_LENGTH 120 28#define FBUS2_MAX_TRANSMIT_LENGTH 120
20 29
21typedef struct { 30typedef struct {
22 int MsgSequenceNumber; 31 int MsgSequenceNumber;
23 int MsgRXState; 32 int MsgRXState;
24 int FramesToGo; 33 int FramesToGo;
25 GSM_Protocol_MessageMultiMsg; 34 GSM_Protocol_MessageMultiMsg;
26 GSM_Protocol_MessageMsg; 35 GSM_Protocol_MessageMsg;
27} GSM_Protocol_FBUS2Data; 36} GSM_Protocol_FBUS2Data;
28 37
29#ifndef GSM_USED_SERIALDEVICE 38#ifndef GSM_USED_SERIALDEVICE
30# define GSM_USED_SERIALDEVICE 39# define GSM_USED_SERIALDEVICE
31#endif 40#endif
32#if defined(GSM_ENABLE_BLUEFBUS2) 41#if defined(GSM_ENABLE_BLUEFBUS2)
33# ifndef GSM_USED_BLUETOOTHDEVICE 42# ifndef GSM_USED_BLUETOOTHDEVICE
34# define GSM_USED_BLUETOOTHDEVICE 43# define GSM_USED_BLUETOOTHDEVICE
35# endif 44# endif
36#endif 45#endif
37 46
38#endif 47#endif
39 48
40/* How should editor hadle tabs in this file? Add editor commands here. 49/* How should editor hadle tabs in this file? Add editor commands here.
41 * vim: noexpandtab sw=8 ts=8 sts=8: 50 * vim: noexpandtab sw=8 ts=8 sts=8:
42 */ 51 */
diff --git a/gammu/emb/common/protocol/nokia/phonet.c b/gammu/emb/common/protocol/nokia/phonet.c
index db5bd72..495a1bf 100644
--- a/gammu/emb/common/protocol/nokia/phonet.c
+++ b/gammu/emb/common/protocol/nokia/phonet.c
@@ -1,220 +1,229 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* Based on some work from Gnokii (www.gnokii.org) 2/* Based on some work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later 4 * GNU GPL version 2 or later
5 */ 5 */
6/* Due to a problem in the source code management, the names of some of
7 * the authors have unfortunately been lost. We do not mean to belittle
8 * their efforts and hope they will contact us to see their names
9 * properly added to the Copyright notice above.
10 * Having published their contributions under the terms of the GNU
11 * General Public License (GPL) [version 2], the Copyright of these
12 * authors will remain respected by adhering to the license they chose
13 * to publish their code under.
14 */
6 15
7#include "../../gsmstate.h" 16#include "../../gsmstate.h"
8 17
9#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET) 18#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET)
10 19
11#include <stdio.h> 20#include <stdio.h>
12#include <string.h> 21#include <string.h>
13 22
14#include "../../gsmcomon.h" 23#include "../../gsmcomon.h"
15#include "phonet.h" 24#include "phonet.h"
16 25
17 static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s, 26 static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s,
18 unsigned char *MsgBuffer, 27 unsigned char *MsgBuffer,
19 int MsgLength, 28 int MsgLength,
20 unsigned char MsgType) 29 unsigned char MsgType)
21{ 30{
22 unsigned char *buffer2; 31 unsigned char *buffer2;
23 int sent; 32 int sent;
24 33
25 GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); 34 GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType);
26 35
27 buffer2 = (unsigned char *)malloc(MsgLength + 6); 36 buffer2 = (unsigned char *)malloc(MsgLength + 6);
28 37
29 buffer2[0] = PHONET_FRAME_ID, 38 buffer2[0] = PHONET_FRAME_ID,
30 buffer2[1] = PHONET_DEVICE_PHONE; //destination 39 buffer2[1] = PHONET_DEVICE_PHONE; //destination
31 buffer2[2] = PHONET_DEVICE_PC; //source 40 buffer2[2] = PHONET_DEVICE_PC; //source
32 41
33 if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) { 42 if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) {
34 buffer2[0] = PHONET_BLUE_FRAME_ID; 43 buffer2[0] = PHONET_BLUE_FRAME_ID;
35 buffer2[1] = PHONET_DEVICE_PHONE;//destination 44 buffer2[1] = PHONET_DEVICE_PHONE;//destination
36 buffer2[2] = PHONET_BLUE_DEVICE_PC;//source 45 buffer2[2] = PHONET_BLUE_DEVICE_PC;//source
37 } 46 }
38 47
39 buffer2[3] = MsgType; 48 buffer2[3] = MsgType;
40 buffer2[4] = MsgLength / 256; 49 buffer2[4] = MsgLength / 256;
41 buffer2[5] = MsgLength % 256; 50 buffer2[5] = MsgLength % 256;
42 51
43 memcpy(buffer2 + 6, MsgBuffer, MsgLength); 52 memcpy(buffer2 + 6, MsgBuffer, MsgLength);
44 53
45 GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); 54 GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType);
46 55
47 /* Sending to phone */ 56 /* Sending to phone */
48 sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6); 57 sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6);
49 58
50 free(buffer2); 59 free(buffer2);
51 60
52 if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR; 61 if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR;
53 return ERR_NONE; 62 return ERR_NONE;
54} 63}
55 64
56static GSM_Error PHONET_StateMachine(GSM_StateMachine *s, unsigned char rx_char) 65static GSM_Error PHONET_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
57{ 66{
58 GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET; 67 GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET;
59 bool correct = false; 68 bool correct = false;
60 69
61 if (d->MsgRXState==RX_GetMessage) { 70 if (d->MsgRXState==RX_GetMessage) {
62 d->Msg.Buffer[d->Msg.Count] = rx_char; 71 d->Msg.Buffer[d->Msg.Count] = rx_char;
63 d->Msg.Count++; 72 d->Msg.Count++;
64 73
65 /* This is not last byte in frame */ 74 /* This is not last byte in frame */
66 if (d->Msg.Count != d->Msg.Length) return ERR_NONE; 75 if (d->Msg.Count != d->Msg.Length) return ERR_NONE;
67 76
68 s->Phone.Data.RequestMsg= &d->Msg; 77 s->Phone.Data.RequestMsg= &d->Msg;
69 s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s); 78 s->Phone.Data.DispatchError= s->Phone.Functions->DispatchMessage(s);
70 79
71 free(d->Msg.Buffer); 80 free(d->Msg.Buffer);
72 d->Msg.Length = 0; 81 d->Msg.Length = 0;
73 d->Msg.Buffer = NULL; 82 d->Msg.Buffer = NULL;
74 83
75 d->MsgRXState = RX_Sync; 84 d->MsgRXState = RX_Sync;
76 return ERR_NONE; 85 return ERR_NONE;
77 } 86 }
78 if (d->MsgRXState==RX_GetLength2) { 87 if (d->MsgRXState==RX_GetLength2) {
79 d->Msg.Length = d->Msg.Length + rx_char; 88 d->Msg.Length = d->Msg.Length + rx_char;
80 d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length); 89 d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length);
81 90
82 d->MsgRXState = RX_GetMessage; 91 d->MsgRXState = RX_GetMessage;
83 return ERR_NONE; 92 return ERR_NONE;
84 } 93 }
85 if (d->MsgRXState==RX_GetLength1) { 94 if (d->MsgRXState==RX_GetLength1) {
86 d->Msg.Length = rx_char * 256; 95 d->Msg.Length = rx_char * 256;
87 96
88 d->MsgRXState = RX_GetLength2; 97 d->MsgRXState = RX_GetLength2;
89 return ERR_NONE; 98 return ERR_NONE;
90 } 99 }
91 if (d->MsgRXState==RX_GetType) { 100 if (d->MsgRXState==RX_GetType) {
92 d->Msg.Type = rx_char; 101 d->Msg.Type = rx_char;
93 102
94 d->MsgRXState = RX_GetLength1; 103 d->MsgRXState = RX_GetLength1;
95 return ERR_NONE; 104 return ERR_NONE;
96 } 105 }
97 if (d->MsgRXState==RX_GetSource) { 106 if (d->MsgRXState==RX_GetSource) {
98 if (rx_char != PHONET_DEVICE_PHONE) { 107 if (rx_char != PHONET_DEVICE_PHONE) {
99 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 108 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
100 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 109 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
101 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PHONE); 110 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PHONE);
102 } 111 }
103 d->MsgRXState = RX_Sync; 112 d->MsgRXState = RX_Sync;
104 return ERR_NONE; 113 return ERR_NONE;
105 } 114 }
106 d->Msg.Source = rx_char; 115 d->Msg.Source = rx_char;
107 116
108 d->MsgRXState = RX_GetType; 117 d->MsgRXState = RX_GetType;
109 return ERR_NONE; 118 return ERR_NONE;
110 } 119 }
111 if (d->MsgRXState==RX_GetDestination) { 120 if (d->MsgRXState==RX_GetDestination) {
112 switch (s->ConnectionType) { 121 switch (s->ConnectionType) {
113 case GCT_IRDAPHONET: 122 case GCT_IRDAPHONET:
114 if (rx_char == PHONET_DEVICE_PC) correct = true; 123 if (rx_char == PHONET_DEVICE_PC) correct = true;
115 break; 124 break;
116 case GCT_PHONETBLUE: 125 case GCT_PHONETBLUE:
117 case GCT_BLUEPHONET: 126 case GCT_BLUEPHONET:
118 if (rx_char == PHONET_BLUE_DEVICE_PC) correct = true; 127 if (rx_char == PHONET_BLUE_DEVICE_PC) correct = true;
119 break; 128 break;
120 default: 129 default:
121 break; 130 break;
122 } 131 }
123 if (!correct) { 132 if (!correct) {
124 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 133 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
125 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 134 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
126 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PC); 135 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PC);
127 } 136 }
128 d->MsgRXState = RX_Sync; 137 d->MsgRXState = RX_Sync;
129 return ERR_NONE; 138 return ERR_NONE;
130 } 139 }
131 d->Msg.Destination = rx_char; 140 d->Msg.Destination = rx_char;
132 141
133 d->MsgRXState = RX_GetSource; 142 d->MsgRXState = RX_GetSource;
134 return ERR_NONE; 143 return ERR_NONE;
135 } 144 }
136 if (d->MsgRXState==RX_Sync) { 145 if (d->MsgRXState==RX_Sync) {
137 switch (s->ConnectionType) { 146 switch (s->ConnectionType) {
138 case GCT_IRDAPHONET: 147 case GCT_IRDAPHONET:
139 if (rx_char == PHONET_FRAME_ID) correct = true; 148 if (rx_char == PHONET_FRAME_ID) correct = true;
140 break; 149 break;
141 case GCT_PHONETBLUE: 150 case GCT_PHONETBLUE:
142 case GCT_BLUEPHONET: 151 case GCT_BLUEPHONET:
143 if (rx_char == PHONET_BLUE_FRAME_ID) correct = true; 152 if (rx_char == PHONET_BLUE_FRAME_ID) correct = true;
144 break; 153 break;
145 default: 154 default:
146 break; 155 break;
147 } 156 }
148 if (!correct) { 157 if (!correct) {
149 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || 158 if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR ||
150 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) { 159 s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl==DL_TEXTERRORDATE) {
151 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_FRAME_ID); 160 smprintf(s,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_FRAME_ID);
152 } 161 }
153 return ERR_NONE; 162 return ERR_NONE;
154 } 163 }
155 d->Msg.Count = 0; 164 d->Msg.Count = 0;
156 165
157 d->MsgRXState = RX_GetDestination; 166 d->MsgRXState = RX_GetDestination;
158 return ERR_NONE; 167 return ERR_NONE;
159 } 168 }
160 return ERR_NONE; 169 return ERR_NONE;
161} 170}
162 171
163static GSM_Error PHONET_Initialise(GSM_StateMachine *s) 172static GSM_Error PHONET_Initialise(GSM_StateMachine *s)
164{ 173{
165 int total = 0, i, n; 174 int total = 0, i, n;
166 GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET; 175 GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET;
167 unsigned char req[50]; 176 unsigned char req[50];
168 177
169 d->Msg.Length= 0; 178 d->Msg.Length= 0;
170 d->Msg.Buffer= NULL; 179 d->Msg.Buffer= NULL;
171 d->MsgRXState= RX_Sync; 180 d->MsgRXState= RX_Sync;
172 181
173 if (s->ConnectionType == GCT_PHONETBLUE || s->ConnectionType == GCT_BLUEPHONET) { 182 if (s->ConnectionType == GCT_PHONETBLUE || s->ConnectionType == GCT_BLUEPHONET) {
174 /* Send frame in PHONET style */ 183 /* Send frame in PHONET style */
175 req[0] = PHONET_BLUE_FRAME_ID; req[1] = PHONET_DEVICE_PHONE; 184 req[0] = PHONET_BLUE_FRAME_ID; req[1] = PHONET_DEVICE_PHONE;
176 req[2] = PHONET_BLUE_DEVICE_PC; req[3] = 0xD0; 185 req[2] = PHONET_BLUE_DEVICE_PC; req[3] = 0xD0;
177 req[4] = 0x00; req[5] = 0x01; 186 req[4] = 0x00; req[5] = 0x01;
178 req[6] = 0x04; 187 req[6] = 0x04;
179 if (s->Device.Functions->WriteDevice(s,req,7) != 7) return ERR_DEVICEWRITEERROR; 188 if (s->Device.Functions->WriteDevice(s,req,7) != 7) return ERR_DEVICEWRITEERROR;
180 189
181 while (total < 7) { 190 while (total < 7) {
182 n = s->Device.Functions->ReadDevice(s, req + total, 50 - total); 191 n = s->Device.Functions->ReadDevice(s, req + total, 50 - total);
183 total += n; 192 total += n;
184 } 193 }
185 194
186 /* Answer frame in PHONET style */ 195 /* Answer frame in PHONET style */
187 req[10] = PHONET_BLUE_FRAME_ID; req[11] = PHONET_BLUE_DEVICE_PC; 196 req[10] = PHONET_BLUE_FRAME_ID; req[11] = PHONET_BLUE_DEVICE_PC;
188 req[12] = PHONET_DEVICE_PHONE;req[13] = 0xD0; 197 req[12] = PHONET_DEVICE_PHONE;req[13] = 0xD0;
189 req[14] = 0x00; req[15] = 0x01; 198 req[14] = 0x00; req[15] = 0x01;
190 req[16] = 0x05; 199 req[16] = 0x05;
191 200
192 for (i = 0; i < 7; i++) { 201 for (i = 0; i < 7; i++) {
193 if (req[i] != req[10+i]) { 202 if (req[i] != req[10+i]) {
194 smprintf(s,"Incorrect byte in the answer\n"); 203 smprintf(s,"Incorrect byte in the answer\n");
195 return ERR_UNKNOWN; 204 return ERR_UNKNOWN;
196 } 205 }
197 } 206 }
198 } 207 }
199 208
200 return ERR_NONE; 209 return ERR_NONE;
201} 210}
202 211
203static GSM_Error PHONET_Terminate(GSM_StateMachine *s) 212static GSM_Error PHONET_Terminate(GSM_StateMachine *s)
204{ 213{
205 free(s->Protocol.Data.PHONET.Msg.Buffer); 214 free(s->Protocol.Data.PHONET.Msg.Buffer);
206 return ERR_NONE; 215 return ERR_NONE;
207} 216}
208 217
209GSM_Protocol_Functions PHONETProtocol = { 218GSM_Protocol_Functions PHONETProtocol = {
210 PHONET_WriteMessage, 219 PHONET_WriteMessage,
211 PHONET_StateMachine, 220 PHONET_StateMachine,
212 PHONET_Initialise, 221 PHONET_Initialise,
213 PHONET_Terminate 222 PHONET_Terminate
214}; 223};
215 224
216#endif 225#endif
217 226
218/* How should editor hadle tabs in this file? Add editor commands here. 227/* How should editor hadle tabs in this file? Add editor commands here.
219 * vim: noexpandtab sw=8 ts=8 sts=8: 228 * vim: noexpandtab sw=8 ts=8 sts=8:
220 */ 229 */
diff --git a/gammu/emb/common/protocol/nokia/phonet.h b/gammu/emb/common/protocol/nokia/phonet.h
index e750bbd..7626c23 100644
--- a/gammu/emb/common/protocol/nokia/phonet.h
+++ b/gammu/emb/common/protocol/nokia/phonet.h
@@ -1,38 +1,47 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* Based on some work from Gnokii (www.gnokii.org) 2/* Based on some work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot 3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later 4 * GNU GPL version 2 or later
5 */ 5 */
6/* Due to a problem in the source code management, the names of some of
7 * the authors have unfortunately been lost. We do not mean to belittle
8 * their efforts and hope they will contact us to see their names
9 * properly added to the Copyright notice above.
10 * Having published their contributions under the terms of the GNU
11 * General Public License (GPL) [version 2], the Copyright of these
12 * authors will remain respected by adhering to the license they chose
13 * to publish their code under.
14 */
6 15
7#ifndef PHONET_h 16#ifndef PHONET_h
8#define PHONET_h 17#define PHONET_h
9 18
10#include "../protocol.h" 19#include "../protocol.h"
11 20
12 #define PHONET_FRAME_ID 0x14 21 #define PHONET_FRAME_ID 0x14
13 #define PHONET_BLUE_FRAME_ID0x19 22 #define PHONET_BLUE_FRAME_ID0x19
14 #define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */ 23 #define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */
15 #define PHONET_DEVICE_PC 0x0c /* Our PC */ 24 #define PHONET_DEVICE_PC 0x0c /* Our PC */
16#define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */ 25#define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */
17 26
18typedef struct { 27typedef struct {
19 int MsgRXState; 28 int MsgRXState;
20 GSM_Protocol_MessageMsg; 29 GSM_Protocol_MessageMsg;
21} GSM_Protocol_PHONETData; 30} GSM_Protocol_PHONETData;
22 31
23#if defined(GSM_ENABLE_IRDAPHONET) 32#if defined(GSM_ENABLE_IRDAPHONET)
24# ifndef GSM_USED_IRDADEVICE 33# ifndef GSM_USED_IRDADEVICE
25# define GSM_USED_IRDADEVICE 34# define GSM_USED_IRDADEVICE
26# endif 35# endif
27#endif 36#endif
28#if defined(GSM_ENABLE_BLUEPHONET) 37#if defined(GSM_ENABLE_BLUEPHONET)
29# ifndef GSM_USED_BLUETOOTHDEVICE 38# ifndef GSM_USED_BLUETOOTHDEVICE
30# define GSM_USED_BLUETOOTHDEVICE 39# define GSM_USED_BLUETOOTHDEVICE
31# endif 40# endif
32#endif 41#endif
33 42
34#endif 43#endif
35 44
36/* How should editor hadle tabs in this file? Add editor commands here. 45/* How should editor hadle tabs in this file? Add editor commands here.
37 * vim: noexpandtab sw=8 ts=8 sts=8: 46 * vim: noexpandtab sw=8 ts=8 sts=8:
38 */ 47 */
diff --git a/gammu/emb/common/service/backup/backgen.h b/gammu/emb/common/service/backup/backgen.h
index 9a930fc..9d97954 100644
--- a/gammu/emb/common/service/backup/backgen.h
+++ b/gammu/emb/common/service/backup/backgen.h
@@ -1,73 +1,73 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_backgen_h 3#ifndef __gsm_backgen_h
4#define __gsm_backgen_h 4#define __gsm_backgen_h
5 5
6#include "../../config.h" 6#include "../../config.h"
7#include "../../misc/misc.h" 7#include "../../misc/misc.h"
8#include "../gsmpbk.h" 8#include "../gsmpbk.h"
9#include "../gsmcal.h" 9#include "../gsmcal.h"
10#include "../gsmlogo.h" 10#include "../gsmlogo.h"
11#include "../gsmring.h" 11#include "../gsmring.h"
12#include "../gsmdata.h" 12#include "../gsmdata.h"
13#include "../gsmprof.h" 13#include "../gsmprof.h"
14#include "../gsmmisc.h" 14#include "../gsmmisc.h"
15#include "../sms/gsmsms.h" 15#include "../sms/gsmsms.h"
16 16
17 #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501 17 #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501
18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251 18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251
19 #define GSM_BACKUP_MAX_CALLER 6 19 #define GSM_BACKUP_MAX_CALLER 6
20 #define GSM_BACKUP_MAX_SMSC 10 20 #define GSM_BACKUP_MAX_SMSC 10
21 #define GSM_BACKUP_MAX_WAPBOOKMARK40 21 #define GSM_BACKUP_MAX_WAPBOOKMARK40
22 #define GSM_BACKUP_MAX_WAPSETTINGS30 22 #define GSM_BACKUP_MAX_WAPSETTINGS30
23 #define GSM_BACKUP_MAX_MMSSETTINGS30 23 #define GSM_BACKUP_MAX_MMSSETTINGS30
24 #define GSM_BACKUP_MAX_SYNCMLSETTINGS10 24 #define GSM_BACKUP_MAX_SYNCMLSETTINGS10
25 #define GSM_BACKUP_MAX_CHATSETTINGS10 25 #define GSM_BACKUP_MAX_CHATSETTINGS10
26 #define GSM_BACKUP_MAX_RINGTONES30 26 #define GSM_BACKUP_MAX_RINGTONES30
27 #define GSM_BACKUP_MAX_PROFILES 10 27 #define GSM_BACKUP_MAX_PROFILES 10
28 #define GSM_BACKUP_MAX_FMSTATIONS20 28 #define GSM_BACKUP_MAX_FMSTATIONS20
29 #define GSM_BACKUP_MAX_GPRSPOINT10 29 #define GSM_BACKUP_MAX_GPRSPOINT10
30 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */ 30 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */
31 31
32typedef struct { 32typedef struct {
33 char IMEI [MAX_IMEI_LENGTH]; 33 char IMEI [MAX_IMEI_LENGTH];
34 char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH]; 34 char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH];
35 char Creator [80]; 35 char Creator [80];
36 GSM_DateTime DateTime; 36 GSM_DateTime DateTime;
37 bool DateTimeAvailable; 37 bool DateTimeAvailable;
38 char MD5Original[100]; 38 char MD5Original[100];
39 char MD5Calculated[100]; 39 char MD5Calculated[100];
40 GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1]; 40 GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1];
41 GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1]; 41 GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1];
42 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1]; 42 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1];
43 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1]; 43 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1];
44 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1]; 44 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1];
45 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1]; 45 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1];
46 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1]; 46 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1];
47 GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1]; 47 GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1];
48 GSM_SyncMLSettings*SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1]; 48 GSM_SyncMLSettings*SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
49 GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1]; 49 GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
50 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1]; 50 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1];
51 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1]; 51 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1];
52 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1]; 52 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1];
53 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1]; 53 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1];
54 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1]; 54 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1];
55 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1]; 55 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1];
56 GSM_Bitmap *StartupLogo; 56 GSM_Bitmap *StartupLogo;
57 GSM_Bitmap *OperatorLogo; 57 GSM_Bitmap *OperatorLogo;
58} GSM_Backup; 58} GSM_Backup;
59 59
60 #define GSM_BACKUP_MAX_SMS500 60 #define GSM_BACKUP_MAX_SMS500
61 61
62typedef struct { 62typedef struct {
63 GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS]; 63 GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS];
64} GSM_SMS_Backup; 64} GSM_SMS_Backup;
65 65
66extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); 66extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
67extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); 67extern GSM_Error GSM_AddSMSBackupFile (char *FileName, GSM_SMS_Backup *backup);
68 68
69#endif 69#endif
70 70
71/* How should editor hadle tabs in this file? Add editor commands here. 71/* How should editor hadle tabs in this file? Add editor commands here.
72 * vim: noexpandtab sw=8 ts=8 sts=8: 72 * vim: noexpandtab sw=8 ts=8 sts=8:
73 */ 73 */
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c
index 4cb1bb7..07a3b22 100644
--- a/gammu/emb/common/service/backup/backtext.c
+++ b/gammu/emb/common/service/backup/backtext.c
@@ -2615,495 +2615,499 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
2615 } 2615 }
2616 num = 0; 2616 num = 0;
2617 for (h = file_info; h != NULL; h = h->Next) { 2617 for (h = file_info; h != NULL; h = h->Next) {
2618 found = false; 2618 found = false;
2619 if (UseUnicode) { 2619 if (UseUnicode) {
2620 EncodeUnicode(buffer,"TODO",4); 2620 EncodeUnicode(buffer,"TODO",4);
2621 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; 2621 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2622 } else { 2622 } else {
2623 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true; 2623 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
2624 } 2624 }
2625 if (found) { 2625 if (found) {
2626 readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); 2626 readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode);
2627 if (readvalue==NULL) break; 2627 if (readvalue==NULL) break;
2628 if (num < GSM_MAXCALENDARTODONOTES) { 2628 if (num < GSM_MAXCALENDARTODONOTES) {
2629 backup->ToDo[num] = malloc(sizeof(GSM_ToDoEntry)); 2629 backup->ToDo[num] = malloc(sizeof(GSM_ToDoEntry));
2630 if (backup->ToDo[num] == NULL) return ERR_MOREMEMORY; 2630 if (backup->ToDo[num] == NULL) return ERR_MOREMEMORY;
2631 backup->ToDo[num + 1] = NULL; 2631 backup->ToDo[num + 1] = NULL;
2632 } else { 2632 } else {
2633 dbgprintf("Increase GSM_MAXCALENDARTODONOTES\n"); 2633 dbgprintf("Increase GSM_MAXCALENDARTODONOTES\n");
2634 return ERR_MOREMEMORY; 2634 return ERR_MOREMEMORY;
2635 } 2635 }
2636 backup->ToDo[num]->Location = num + 1; 2636 backup->ToDo[num]->Location = num + 1;
2637 ReadToDoEntry(file_info, h->SectionName, backup->ToDo[num],UseUnicode); 2637 ReadToDoEntry(file_info, h->SectionName, backup->ToDo[num],UseUnicode);
2638 num++; 2638 num++;
2639 } 2639 }
2640 } 2640 }
2641 sprintf(buffer,"Startup"); 2641 sprintf(buffer,"Startup");
2642 readvalue = ReadCFGText(file_info, buffer, "Text", UseUnicode); 2642 readvalue = ReadCFGText(file_info, buffer, "Text", UseUnicode);
2643 if (readvalue==NULL) { 2643 if (readvalue==NULL) {
2644 readvalue = ReadCFGText(file_info, buffer, "Width", UseUnicode); 2644 readvalue = ReadCFGText(file_info, buffer, "Width", UseUnicode);
2645 } 2645 }
2646 if (readvalue!=NULL) { 2646 if (readvalue!=NULL) {
2647 backup->StartupLogo = malloc(sizeof(GSM_Bitmap)); 2647 backup->StartupLogo = malloc(sizeof(GSM_Bitmap));
2648 if (backup->StartupLogo == NULL) return ERR_MOREMEMORY; 2648 if (backup->StartupLogo == NULL) return ERR_MOREMEMORY;
2649 ReadStartupEntry(file_info, buffer, backup->StartupLogo,UseUnicode); 2649 ReadStartupEntry(file_info, buffer, backup->StartupLogo,UseUnicode);
2650 } 2650 }
2651 sprintf(buffer,"Operator"); 2651 sprintf(buffer,"Operator");
2652 readvalue = ReadCFGText(file_info, buffer, "Network", UseUnicode); 2652 readvalue = ReadCFGText(file_info, buffer, "Network", UseUnicode);
2653 if (readvalue!=NULL) { 2653 if (readvalue!=NULL) {
2654 backup->OperatorLogo = malloc(sizeof(GSM_Bitmap)); 2654 backup->OperatorLogo = malloc(sizeof(GSM_Bitmap));
2655 if (backup->OperatorLogo == NULL) return ERR_MOREMEMORY; 2655 if (backup->OperatorLogo == NULL) return ERR_MOREMEMORY;
2656 ReadOperatorEntry(file_info, buffer, backup->OperatorLogo,UseUnicode); 2656 ReadOperatorEntry(file_info, buffer, backup->OperatorLogo,UseUnicode);
2657 } 2657 }
2658 num = 0; 2658 num = 0;
2659 for (h = file_info; h != NULL; h = h->Next) { 2659 for (h = file_info; h != NULL; h = h->Next) {
2660 found = false; 2660 found = false;
2661 if (UseUnicode) { 2661 if (UseUnicode) {
2662 EncodeUnicode(buffer,"FMStation",9); 2662 EncodeUnicode(buffer,"FMStation",9);
2663 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; 2663 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2664 } else { 2664 } else {
2665 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true; 2665 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
2666 } 2666 }
2667 if (found) { 2667 if (found) {
2668 readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); 2668 readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode);
2669 if (readvalue==NULL) break; 2669 if (readvalue==NULL) break;
2670 if (num < GSM_BACKUP_MAX_FMSTATIONS) { 2670 if (num < GSM_BACKUP_MAX_FMSTATIONS) {
2671 backup->FMStation[num] = malloc(sizeof(GSM_FMStation)); 2671 backup->FMStation[num] = malloc(sizeof(GSM_FMStation));
2672 if (backup->FMStation[num] == NULL) return ERR_MOREMEMORY; 2672 if (backup->FMStation[num] == NULL) return ERR_MOREMEMORY;
2673 backup->FMStation[num + 1] = NULL; 2673 backup->FMStation[num + 1] = NULL;
2674 } else { 2674 } else {
2675 dbgprintf("Increase GSM_BACKUP_MAX_FMSTATIONS\n"); 2675 dbgprintf("Increase GSM_BACKUP_MAX_FMSTATIONS\n");
2676 return ERR_MOREMEMORY; 2676 return ERR_MOREMEMORY;
2677 } 2677 }
2678 backup->FMStation[num]->Location = num + 1; 2678 backup->FMStation[num]->Location = num + 1;
2679 ReadFMStationEntry(file_info, h->SectionName, backup->FMStation[num],UseUnicode); 2679 ReadFMStationEntry(file_info, h->SectionName, backup->FMStation[num],UseUnicode);
2680 num++; 2680 num++;
2681 } 2681 }
2682 } 2682 }
2683 num = 0; 2683 num = 0;
2684 for (h = file_info; h != NULL; h = h->Next) { 2684 for (h = file_info; h != NULL; h = h->Next) {
2685 found = false; 2685 found = false;
2686 if (UseUnicode) { 2686 if (UseUnicode) {
2687 EncodeUnicode(buffer,"GPRSPoint",9); 2687 EncodeUnicode(buffer,"GPRSPoint",9);
2688 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; 2688 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2689 } else { 2689 } else {
2690 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true; 2690 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
2691 } 2691 }
2692 if (found) { 2692 if (found) {
2693 readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode); 2693 readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode);
2694 if (readvalue==NULL) break; 2694 if (readvalue==NULL) break;
2695 if (num < GSM_BACKUP_MAX_GPRSPOINT) { 2695 if (num < GSM_BACKUP_MAX_GPRSPOINT) {
2696 backup->GPRSPoint[num] = malloc(sizeof(GSM_GPRSAccessPoint)); 2696 backup->GPRSPoint[num] = malloc(sizeof(GSM_GPRSAccessPoint));
2697 if (backup->GPRSPoint[num] == NULL) return ERR_MOREMEMORY; 2697 if (backup->GPRSPoint[num] == NULL) return ERR_MOREMEMORY;
2698 backup->GPRSPoint[num + 1] = NULL; 2698 backup->GPRSPoint[num + 1] = NULL;
2699 } else { 2699 } else {
2700 dbgprintf("Increase GSM_BACKUP_MAX_GPRSPOINT\n"); 2700 dbgprintf("Increase GSM_BACKUP_MAX_GPRSPOINT\n");
2701 return ERR_MOREMEMORY; 2701 return ERR_MOREMEMORY;
2702 } 2702 }
2703 backup->GPRSPoint[num]->Location = num + 1; 2703 backup->GPRSPoint[num]->Location = num + 1;
2704 ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode); 2704 ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode);
2705 num++; 2705 num++;
2706 } 2706 }
2707 } 2707 }
2708 num = 0; 2708 num = 0;
2709 for (h = file_info; h != NULL; h = h->Next) { 2709 for (h = file_info; h != NULL; h = h->Next) {
2710 found = false; 2710 found = false;
2711 if (UseUnicode) { 2711 if (UseUnicode) {
2712 EncodeUnicode(buffer,"Note",4); 2712 EncodeUnicode(buffer,"Note",4);
2713 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; 2713 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2714 } else { 2714 } else {
2715 if (mystrncasecmp("Note", h->SectionName, 4)) found = true; 2715 if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
2716 } 2716 }
2717 if (found) { 2717 if (found) {
2718 readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode); 2718 readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode);
2719 if (readvalue==NULL) break; 2719 if (readvalue==NULL) break;
2720 if (num < GSM_BACKUP_MAX_NOTE) { 2720 if (num < GSM_BACKUP_MAX_NOTE) {
2721 backup->Note[num] = malloc(sizeof(GSM_NoteEntry)); 2721 backup->Note[num] = malloc(sizeof(GSM_NoteEntry));
2722 if (backup->Note[num] == NULL) return ERR_MOREMEMORY; 2722 if (backup->Note[num] == NULL) return ERR_MOREMEMORY;
2723 backup->Note[num + 1] = NULL; 2723 backup->Note[num + 1] = NULL;
2724 } else { 2724 } else {
2725 dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n"); 2725 dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n");
2726 return ERR_MOREMEMORY; 2726 return ERR_MOREMEMORY;
2727 } 2727 }
2728 ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode); 2728 ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode);
2729 num++; 2729 num++;
2730 } 2730 }
2731 } 2731 }
2732 if (backup->MD5Original[0]!=0) { 2732 if (backup->MD5Original[0]!=0) {
2733 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated); 2733 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated);
2734 } 2734 }
2735 for (h = file_info; h != NULL; h = h->Next) { 2735 for (h = file_info; h != NULL; h = h->Next) {
2736 found = false; 2736 found = false;
2737 if (UseUnicode) { 2737 if (UseUnicode) {
2738 EncodeUnicode(buffer,"Backup",4); 2738 EncodeUnicode(buffer,"Backup",4);
2739 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true; 2739 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2740 } else { 2740 } else {
2741 if (mystrncasecmp("Backup", h->SectionName, 6)) found = true; 2741 if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
2742 } 2742 }
2743 if (UseUnicode) { 2743 if (UseUnicode) {
2744 EncodeUnicode(buffer,"Checksum",4); 2744 EncodeUnicode(buffer,"Checksum",4);
2745 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2745 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2746 } else { 2746 } else {
2747 if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true; 2747 if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
2748 } 2748 }
2749 if (UseUnicode) { 2749 if (UseUnicode) {
2750 EncodeUnicode(buffer,"Profile",7); 2750 EncodeUnicode(buffer,"Profile",7);
2751 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true; 2751 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2752 } else { 2752 } else {
2753 if (mystrncasecmp("Profile", h->SectionName, 7)) found = true; 2753 if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
2754 } 2754 }
2755 if (UseUnicode) { 2755 if (UseUnicode) {
2756 EncodeUnicode(buffer,"PhonePBK",8); 2756 EncodeUnicode(buffer,"PhonePBK",8);
2757 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2757 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2758 } else { 2758 } else {
2759 if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true; 2759 if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
2760 } 2760 }
2761 if (UseUnicode) { 2761 if (UseUnicode) {
2762 EncodeUnicode(buffer,"SIMPBK",6); 2762 EncodeUnicode(buffer,"SIMPBK",6);
2763 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true; 2763 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2764 } else { 2764 } else {
2765 if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true; 2765 if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
2766 } 2766 }
2767 if (UseUnicode) { 2767 if (UseUnicode) {
2768 EncodeUnicode(buffer,"Calendar",8); 2768 EncodeUnicode(buffer,"Calendar",8);
2769 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2769 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2770 } else { 2770 } else {
2771 if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true; 2771 if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
2772 } 2772 }
2773 if (UseUnicode) { 2773 if (UseUnicode) {
2774 EncodeUnicode(buffer,"Caller",6); 2774 EncodeUnicode(buffer,"Caller",6);
2775 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true; 2775 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2776 } else { 2776 } else {
2777 if (mystrncasecmp("Caller", h->SectionName, 6)) found = true; 2777 if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
2778 } 2778 }
2779 if (UseUnicode) { 2779 if (UseUnicode) {
2780 EncodeUnicode(buffer,"SMSC",4); 2780 EncodeUnicode(buffer,"SMSC",4);
2781 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; 2781 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2782 } else { 2782 } else {
2783 if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true; 2783 if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
2784 } 2784 }
2785 if (UseUnicode) { 2785 if (UseUnicode) {
2786 EncodeUnicode(buffer,"WAPBookmark",11); 2786 EncodeUnicode(buffer,"WAPBookmark",11);
2787 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true; 2787 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2788 if (!found) { 2788 if (!found) {
2789 EncodeUnicode(buffer,"Bookmark",8); 2789 EncodeUnicode(buffer,"Bookmark",8);
2790 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2790 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2791 } 2791 }
2792 } else { 2792 } else {
2793 if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true; 2793 if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
2794 if (!found) { 2794 if (!found) {
2795 if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true; 2795 if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
2796 } 2796 }
2797 } 2797 }
2798 if (UseUnicode) { 2798 if (UseUnicode) {
2799 EncodeUnicode(buffer,"WAPSettings",11); 2799 EncodeUnicode(buffer,"WAPSettings",11);
2800 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true; 2800 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2801 if (!found) { 2801 if (!found) {
2802 EncodeUnicode(buffer,"Settings",8); 2802 EncodeUnicode(buffer,"Settings",8);
2803 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2803 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2804 } 2804 }
2805 } else { 2805 } else {
2806 if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true; 2806 if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
2807 if (!found) { 2807 if (!found) {
2808 if (mystrncasecmp("Settings", h->SectionName, 8)) found = true; 2808 if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
2809 } 2809 }
2810 } 2810 }
2811 if (UseUnicode) { 2811 if (UseUnicode) {
2812 EncodeUnicode(buffer,"MMSSettings",8); 2812 EncodeUnicode(buffer,"MMSSettings",8);
2813 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2813 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2814 } else { 2814 } else {
2815 if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true; 2815 if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
2816 } 2816 }
2817 if (UseUnicode) { 2817 if (UseUnicode) {
2818 EncodeUnicode(buffer,"Ringtone",8); 2818 EncodeUnicode(buffer,"Ringtone",8);
2819 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2819 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2820 } else { 2820 } else {
2821 if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true; 2821 if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
2822 } 2822 }
2823 if (UseUnicode) { 2823 if (UseUnicode) {
2824 EncodeUnicode(buffer,"TODO",4); 2824 EncodeUnicode(buffer,"TODO",4);
2825 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; 2825 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2826 } else { 2826 } else {
2827 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true; 2827 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
2828 } 2828 }
2829 if (UseUnicode) { 2829 if (UseUnicode) {
2830 EncodeUnicode(buffer,"Startup",7); 2830 EncodeUnicode(buffer,"Startup",7);
2831 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true; 2831 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2832 } else { 2832 } else {
2833 if (mystrncasecmp("Startup", h->SectionName, 7)) found = true; 2833 if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
2834 } 2834 }
2835 if (UseUnicode) { 2835 if (UseUnicode) {
2836 EncodeUnicode(buffer,"Operator",7); 2836 EncodeUnicode(buffer,"Operator",7);
2837 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true; 2837 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2838 } else { 2838 } else {
2839 if (mystrncasecmp("Operator", h->SectionName, 8)) found = true; 2839 if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
2840 } 2840 }
2841 if (UseUnicode) { 2841 if (UseUnicode) {
2842 EncodeUnicode(buffer,"FMStation",9); 2842 EncodeUnicode(buffer,"FMStation",9);
2843 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; 2843 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2844 } else { 2844 } else {
2845 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true; 2845 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
2846 } 2846 }
2847 if (UseUnicode) { 2847 if (UseUnicode) {
2848 EncodeUnicode(buffer,"GPRSPoint",9); 2848 EncodeUnicode(buffer,"GPRSPoint",9);
2849 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true; 2849 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2850 } else { 2850 } else {
2851 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true; 2851 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
2852 } 2852 }
2853 if (UseUnicode) { 2853 if (UseUnicode) {
2854 EncodeUnicode(buffer,"Note",4); 2854 EncodeUnicode(buffer,"Note",4);
2855 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; 2855 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2856 } else { 2856 } else {
2857 if (mystrncasecmp("Note", h->SectionName, 4)) found = true; 2857 if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
2858 } 2858 }
2859 if (!found) return ERR_NOTIMPLEMENTED; 2859 if (!found) return ERR_NOTIMPLEMENTED;
2860 } 2860 }
2861 return ERR_NONE; 2861 return ERR_NONE;
2862} 2862}
2863 2863
2864/* ---------------------- backup files for SMS ----------------------------- */ 2864/* ---------------------- backup files for SMS ----------------------------- */
2865 2865
2866static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) 2866static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS)
2867{ 2867{
2868 unsigned char buffer[10000], *readvalue; 2868 unsigned char buffer[10000], *readvalue;
2869 2869
2870 GSM_SetDefaultSMSData(SMS); 2870 GSM_SetDefaultSMSData(SMS);
2871 2871
2872 SMS->PDU = SMS_Submit; 2872 SMS->PDU = SMS_Submit;
2873 SMS->SMSC.Location = 0; 2873 SMS->SMSC.Location = 0;
2874 sprintf(buffer,"SMSC"); 2874 sprintf(buffer,"SMSC");
2875 ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false); 2875 ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false);
2876 sprintf(buffer,"ReplySMSC"); 2876 sprintf(buffer,"ReplySMSC");
2877 SMS->ReplyViaSameSMSC = false; 2877 SMS->ReplyViaSameSMSC = false;
2878 readvalue = ReadCFGText(file_info, section, buffer, false); 2878 readvalue = ReadCFGText(file_info, section, buffer, false);
2879 if (readvalue!=NULL) { 2879 if (readvalue!=NULL) {
2880 if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true; 2880 if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true;
2881 } 2881 }
2882 sprintf(buffer,"Class"); 2882 sprintf(buffer,"Class");
2883 SMS->Class = -1; 2883 SMS->Class = -1;
2884 readvalue = ReadCFGText(file_info, section, buffer, false); 2884 readvalue = ReadCFGText(file_info, section, buffer, false);
2885 if (readvalue!=NULL) SMS->Class = atoi(readvalue); 2885 if (readvalue!=NULL) SMS->Class = atoi(readvalue);
2886 sprintf(buffer,"Sent"); 2886 sprintf(buffer,"Sent");
2887 readvalue = ReadCFGText(file_info, section, buffer, false); 2887 readvalue = ReadCFGText(file_info, section, buffer, false);
2888 if (readvalue!=NULL) { 2888 if (readvalue!=NULL) {
2889 ReadVCALDateTime(readvalue, &SMS->DateTime); 2889 ReadVCALDateTime(readvalue, &SMS->DateTime);
2890 SMS->PDU = SMS_Deliver; 2890 SMS->PDU = SMS_Deliver;
2891 } 2891 }
2892 sprintf(buffer,"RejectDuplicates"); 2892 sprintf(buffer,"RejectDuplicates");
2893 SMS->RejectDuplicates = false; 2893 SMS->RejectDuplicates = false;
2894 readvalue = ReadCFGText(file_info, section, buffer, false); 2894 readvalue = ReadCFGText(file_info, section, buffer, false);
2895 if (readvalue!=NULL) { 2895 if (readvalue!=NULL) {
2896 if (mystrncasecmp(readvalue,"True",0)) SMS->RejectDuplicates = true; 2896 if (mystrncasecmp(readvalue,"True",0)) SMS->RejectDuplicates = true;
2897 } 2897 }
2898 sprintf(buffer,"ReplaceMessage"); 2898 sprintf(buffer,"ReplaceMessage");
2899 SMS->ReplaceMessage = 0; 2899 SMS->ReplaceMessage = 0;
2900 readvalue = ReadCFGText(file_info, section, buffer, false); 2900 readvalue = ReadCFGText(file_info, section, buffer, false);
2901 if (readvalue!=NULL) SMS->ReplaceMessage = atoi(readvalue); 2901 if (readvalue!=NULL) SMS->ReplaceMessage = atoi(readvalue);
2902 sprintf(buffer,"MessageReference"); 2902 sprintf(buffer,"MessageReference");
2903 SMS->MessageReference = 0; 2903 SMS->MessageReference = 0;
2904 readvalue = ReadCFGText(file_info, section, buffer, false); 2904 readvalue = ReadCFGText(file_info, section, buffer, false);
2905 if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue); 2905 if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue);
2906 sprintf(buffer,"State"); 2906 sprintf(buffer,"State");
2907 SMS->State = SMS_UnRead; 2907 SMS->State = SMS_UnRead;
2908 readvalue = ReadCFGText(file_info, section, buffer, false); 2908 readvalue = ReadCFGText(file_info, section, buffer, false);
2909 if (readvalue!=NULL) { 2909 if (readvalue!=NULL) {
2910 if (mystrncasecmp(readvalue,"Read",0)) SMS->State = SMS_Read; 2910 if (mystrncasecmp(readvalue,"Read",0)) SMS->State = SMS_Read;
2911 else if (mystrncasecmp(readvalue,"Sent",0))SMS->State = SMS_Sent; 2911 else if (mystrncasecmp(readvalue,"Sent",0))SMS->State = SMS_Sent;
2912 else if (mystrncasecmp(readvalue,"UnSent",0))SMS->State = SMS_UnSent; 2912 else if (mystrncasecmp(readvalue,"UnSent",0))SMS->State = SMS_UnSent;
2913 } 2913 }
2914 sprintf(buffer,"Number"); 2914 sprintf(buffer,"Number");
2915 ReadBackupText(file_info, section, buffer, SMS->Number, false); 2915 ReadBackupText(file_info, section, buffer, SMS->Number, false);
2916 sprintf(buffer,"Name"); 2916 sprintf(buffer,"Name");
2917 ReadBackupText(file_info, section, buffer, SMS->Name, false); 2917 ReadBackupText(file_info, section, buffer, SMS->Name, false);
2918 sprintf(buffer,"Length"); 2918 sprintf(buffer,"Length");
2919 SMS->Length = 0; 2919 SMS->Length = 0;
2920 readvalue = ReadCFGText(file_info, section, buffer, false); 2920 readvalue = ReadCFGText(file_info, section, buffer, false);
2921 if (readvalue!=NULL) SMS->Length = atoi(readvalue); 2921 if (readvalue!=NULL) SMS->Length = atoi(readvalue);
2922 sprintf(buffer,"Coding"); 2922 sprintf(buffer,"Coding");
2923 SMS->Coding = SMS_Coding_Default; 2923 SMS->Coding = SMS_Coding_Default;
2924 readvalue = ReadCFGText(file_info, section, buffer, false); 2924 readvalue = ReadCFGText(file_info, section, buffer, false);
2925 if (readvalue!=NULL) { 2925 if (readvalue!=NULL) {
2926 if (mystrncasecmp(readvalue,"Unicode",0)) { 2926 if (mystrncasecmp(readvalue,"Unicode",0)) {
2927 SMS->Coding = SMS_Coding_Unicode; 2927 SMS->Coding = SMS_Coding_Unicode;
2928 } else if (mystrncasecmp(readvalue,"8bit",0)) { 2928 } else if (mystrncasecmp(readvalue,"8bit",0)) {
2929 SMS->Coding = SMS_Coding_8bit; 2929 SMS->Coding = SMS_Coding_8bit;
2930 } 2930 }
2931 } 2931 }
2932 ReadLinkedBackupText(file_info, section, "Text", buffer, false); 2932 ReadLinkedBackupText(file_info, section, "Text", buffer, false);
2933 DecodeHexBin (SMS->Text, buffer, strlen(buffer)); 2933 DecodeHexBin (SMS->Text, buffer, strlen(buffer));
2934 SMS->Text[strlen(buffer)/2]= 0; 2934 SMS->Text[strlen(buffer)/2]= 0;
2935 SMS->Text[strlen(buffer)/2+1] = 0; 2935 SMS->Text[strlen(buffer)/2+1] = 0;
2936 sprintf(buffer,"Folder"); 2936 sprintf(buffer,"Folder");
2937 readvalue = ReadCFGText(file_info, section, buffer, false); 2937 readvalue = ReadCFGText(file_info, section, buffer, false);
2938 if (readvalue!=NULL) SMS->Folder = atoi(readvalue); 2938 if (readvalue!=NULL) SMS->Folder = atoi(readvalue);
2939 SMS->UDH.Type = UDH_NoUDH; 2939 SMS->UDH.Type = UDH_NoUDH;
2940 SMS->UDH.Length = 0; 2940 SMS->UDH.Length = 0;
2941 SMS->UDH.ID8bit = -1; 2941 SMS->UDH.ID8bit = -1;
2942 SMS->UDH.ID16bit= -1; 2942 SMS->UDH.ID16bit= -1;
2943 SMS->UDH.PartNumber= -1; 2943 SMS->UDH.PartNumber= -1;
2944 SMS->UDH.AllParts= -1; 2944 SMS->UDH.AllParts= -1;
2945 sprintf(buffer,"UDH"); 2945 sprintf(buffer,"UDH");
2946 readvalue = ReadCFGText(file_info, section, buffer, false); 2946 readvalue = ReadCFGText(file_info, section, buffer, false);
2947 if (readvalue!=NULL) { 2947 if (readvalue!=NULL) {
2948 DecodeHexBin (SMS->UDH.Text, readvalue, strlen(readvalue)); 2948 DecodeHexBin (SMS->UDH.Text, readvalue, strlen(readvalue));
2949 SMS->UDH.Length = strlen(readvalue)/2; 2949 SMS->UDH.Length = strlen(readvalue)/2;
2950 GSM_DecodeUDHHeader(&SMS->UDH); 2950 GSM_DecodeUDHHeader(&SMS->UDH);
2951 } 2951 }
2952} 2952}
2953 2953
2954static GSM_Error GSM_ReadSMSBackupTextFile(char *FileName, GSM_SMS_Backup *backup) 2954static GSM_Error GSM_ReadSMSBackupTextFile(char *FileName, GSM_SMS_Backup *backup)
2955{ 2955{
2956 INI_Section*file_info, *h; 2956 INI_Section*file_info, *h;
2957 char *readvalue; 2957 char *readvalue;
2958 int num; 2958 int num;
2959 2959
2960 backup->SMS[0] = NULL; 2960 backup->SMS[0] = NULL;
2961 2961
2962 file_info = INI_ReadFile(FileName, false); 2962 file_info = INI_ReadFile(FileName, false);
2963 2963
2964 num = 0; 2964 num = 0;
2965 for (h = file_info; h != NULL; h = h->Next) { 2965 for (h = file_info; h != NULL; h = h->Next) {
2966 if (mystrncasecmp("SMSBackup", h->SectionName, 9)) { 2966 if (mystrncasecmp("SMSBackup", h->SectionName, 9)) {
2967 readvalue = ReadCFGText(file_info, h->SectionName, "Number", false); 2967 readvalue = ReadCFGText(file_info, h->SectionName, "Number", false);
2968 if (readvalue==NULL) break; 2968 if (readvalue==NULL) break;
2969 if (num < GSM_BACKUP_MAX_SMS) { 2969 if (num < GSM_BACKUP_MAX_SMS) {
2970 backup->SMS[num] = malloc(sizeof(GSM_SMSMessage)); 2970 backup->SMS[num] = malloc(sizeof(GSM_SMSMessage));
2971 if (backup->SMS[num] == NULL) return ERR_MOREMEMORY; 2971 if (backup->SMS[num] == NULL) return ERR_MOREMEMORY;
2972 backup->SMS[num + 1] = NULL; 2972 backup->SMS[num + 1] = NULL;
2973 } else { 2973 } else {
2974 dbgprintf("Increase GSM_BACKUP_MAX_SMS\n"); 2974 dbgprintf("Increase GSM_BACKUP_MAX_SMS\n");
2975 return ERR_MOREMEMORY; 2975 return ERR_MOREMEMORY;
2976 } 2976 }
2977 backup->SMS[num]->Location = num + 1; 2977 backup->SMS[num]->Location = num + 1;
2978 ReadSMSBackupEntry(file_info, h->SectionName, backup->SMS[num]); 2978 ReadSMSBackupEntry(file_info, h->SectionName, backup->SMS[num]);
2979 num++; 2979 num++;
2980 } 2980 }
2981 } 2981 }
2982 return ERR_NONE; 2982 return ERR_NONE;
2983} 2983}
2984 2984
2985GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) 2985GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup)
2986{ 2986{
2987 FILE *file; 2987 FILE *file;
2988 2988
2989 backup->SMS[0] = NULL; 2989 backup->SMS[0] = NULL;
2990 2990
2991 file = fopen(FileName, "rb"); 2991 file = fopen(FileName, "rb");
2992 if (file == NULL) return(ERR_CANTOPENFILE); 2992 if (file == NULL) return(ERR_CANTOPENFILE);
2993 2993
2994 fclose(file); 2994 fclose(file);
2995 2995
2996 return GSM_ReadSMSBackupTextFile(FileName, backup); 2996 return GSM_ReadSMSBackupTextFile(FileName, backup);
2997} 2997}
2998 2998
2999GSM_Error SaveSMSBackupTextFile(FILE *file, GSM_SMS_Backup *backup) 2999static GSM_Error SaveSMSBackupTextFile(FILE *file, GSM_SMS_Backup *backup)
3000{ 3000{
3001 int i,w,current; 3001 int i,w,current;
3002 unsigned char buffer[10000]; 3002 unsigned char buffer[10000];
3003 GSM_DateTimeDT; 3003 GSM_DateTimeDT;
3004 3004
3005 fprintf(file,"\n# File created by Gammu (www.mwiacek.com) version %s\n",VERSION); 3005 fprintf(file,"\n# File created by Gammu (www.mwiacek.com) version %s\n",VERSION);
3006 GSM_GetCurrentDateTime (&DT); 3006 GSM_GetCurrentDateTime (&DT);
3007 fprintf(file,"# Saved %s\n\n",OSDateTime(DT,false)); 3007 fprintf(file,"# Saved ");
3008 fprintf(file, "%04d%02d%02dT%02d%02d%02d",
3009 DT.Year, DT.Month, DT.Day,
3010 DT.Hour, DT.Minute, DT.Second);
3011 fprintf(file," (%s)\n\n",OSDateTime(DT,false));
3008 3012
3009 i=0; 3013 i=0;
3010 while (backup->SMS[i]!=NULL) { 3014 while (backup->SMS[i]!=NULL) {
3011 fprintf(file,"[SMSBackup%03i]\n",i); 3015 fprintf(file,"[SMSBackup%03i]\n",i);
3012 switch (backup->SMS[i]->Coding) { 3016 switch (backup->SMS[i]->Coding) {
3013 case SMS_Coding_Unicode: 3017 case SMS_Coding_Unicode:
3014 case SMS_Coding_Default: 3018 case SMS_Coding_Default:
3015 sprintf(buffer,"%s",DecodeUnicodeString(backup->SMS[i]->Text)); 3019 sprintf(buffer,"%s",DecodeUnicodeString(backup->SMS[i]->Text));
3016 fprintf(file,"#"); 3020 fprintf(file,"#");
3017 current = 0; 3021 current = 0;
3018 for (w=0;w<(int)(strlen(buffer));w++) { 3022 for (w=0;w<(int)(strlen(buffer));w++) {
3019 switch (buffer[w]) { 3023 switch (buffer[w]) {
3020 case 10: 3024 case 10:
3021 fprintf(file,"\n#"); 3025 fprintf(file,"\n#");
3022 current = 0; 3026 current = 0;
3023 break; 3027 break;
3024 case 13: 3028 case 13:
3025 break; 3029 break;
3026 default: 3030 default:
3027 if (isprint(buffer[w])) { 3031 if (isprint(buffer[w])) {
3028 fprintf(file,"%c",buffer[w]); 3032 fprintf(file,"%c",buffer[w]);
3029 current ++; 3033 current ++;
3030 } 3034 }
3031 if (current == 75) { 3035 if (current == 75) {
3032 fprintf(file,"\n#"); 3036 fprintf(file,"\n#");
3033 current = 0; 3037 current = 0;
3034 } 3038 }
3035 } 3039 }
3036 } 3040 }
3037 fprintf(file,"\n"); 3041 fprintf(file,"\n");
3038 break; 3042 break;
3039 default: 3043 default:
3040 break; 3044 break;
3041 } 3045 }
3042 if (backup->SMS[i]->PDU == SMS_Deliver) { 3046 if (backup->SMS[i]->PDU == SMS_Deliver) {
3043 SaveBackupText(file, "SMSC", backup->SMS[i]->SMSC.Number, false); 3047 SaveBackupText(file, "SMSC", backup->SMS[i]->SMSC.Number, false);
3044 if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"SMSCReply = true\n"); 3048 if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"SMSCReply = true\n");
3045 fprintf(file,"Sent"); 3049 fprintf(file,"Sent");
3046 SaveVCalDateTime(file,&backup->SMS[i]->DateTime, false); 3050 SaveVCalDateTime(file,&backup->SMS[i]->DateTime, false);
3047 } 3051 }
3048 fprintf(file,"State = "); 3052 fprintf(file,"State = ");
3049 switch (backup->SMS[i]->State) { 3053 switch (backup->SMS[i]->State) {
3050 case SMS_UnRead : fprintf(file,"UnRead\n");break; 3054 case SMS_UnRead : fprintf(file,"UnRead\n");break;
3051 case SMS_Read : fprintf(file,"Read\n");break; 3055 case SMS_Read : fprintf(file,"Read\n");break;
3052 case SMS_Sent : fprintf(file,"Sent\n");break; 3056 case SMS_Sent : fprintf(file,"Sent\n");break;
3053 case SMS_UnSent : fprintf(file,"UnSent\n");break; 3057 case SMS_UnSent : fprintf(file,"UnSent\n");break;
3054 } 3058 }
3055 SaveBackupText(file, "Number", backup->SMS[i]->Number, false); 3059 SaveBackupText(file, "Number", backup->SMS[i]->Number, false);
3056 SaveBackupText(file, "Name", backup->SMS[i]->Name, false); 3060 SaveBackupText(file, "Name", backup->SMS[i]->Name, false);
3057 if (backup->SMS[i]->UDH.Type != UDH_NoUDH) { 3061 if (backup->SMS[i]->UDH.Type != UDH_NoUDH) {
3058 EncodeHexBin(buffer,backup->SMS[i]->UDH.Text,backup->SMS[i]->UDH.Length); 3062 EncodeHexBin(buffer,backup->SMS[i]->UDH.Text,backup->SMS[i]->UDH.Length);
3059 fprintf(file,"UDH = %s\n",buffer); 3063 fprintf(file,"UDH = %s\n",buffer);
3060 } 3064 }
3061 switch (backup->SMS[i]->Coding) { 3065 switch (backup->SMS[i]->Coding) {
3062 case SMS_Coding_Unicode: 3066 case SMS_Coding_Unicode:
3063 case SMS_Coding_Default: 3067 case SMS_Coding_Default:
3064 EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length*2); 3068 EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length*2);
3065 break; 3069 break;
3066 default: 3070 default:
3067 EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length); 3071 EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length);
3068 break; 3072 break;
3069 } 3073 }
3070 SaveLinkedBackupText(file, "Text", buffer, false); 3074 SaveLinkedBackupText(file, "Text", buffer, false);
3071 switch (backup->SMS[i]->Coding) { 3075 switch (backup->SMS[i]->Coding) {
3072 case SMS_Coding_Unicode : fprintf(file,"Coding = Unicode\n"); break; 3076 case SMS_Coding_Unicode : fprintf(file,"Coding = Unicode\n"); break;
3073 case SMS_Coding_Default : fprintf(file,"Coding = Default\n"); break; 3077 case SMS_Coding_Default : fprintf(file,"Coding = Default\n"); break;
3074 case SMS_Coding_8bit : fprintf(file,"Coding = 8bit\n"); break; 3078 case SMS_Coding_8bit : fprintf(file,"Coding = 8bit\n"); break;
3075 } 3079 }
3076 fprintf(file,"Folder = %i\n",backup->SMS[i]->Folder); 3080 fprintf(file,"Folder = %i\n",backup->SMS[i]->Folder);
3077 fprintf(file,"Length = %i\n",backup->SMS[i]->Length); 3081 fprintf(file,"Length = %i\n",backup->SMS[i]->Length);
3078 fprintf(file,"Class = %i\n",backup->SMS[i]->Class); 3082 fprintf(file,"Class = %i\n",backup->SMS[i]->Class);
3079 fprintf(file,"ReplySMSC = "); 3083 fprintf(file,"ReplySMSC = ");
3080 if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"True\n"); else fprintf(file,"False\n"); 3084 if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"True\n"); else fprintf(file,"False\n");
3081 fprintf(file,"RejectDuplicates = "); 3085 fprintf(file,"RejectDuplicates = ");
3082 if (backup->SMS[i]->RejectDuplicates) fprintf(file,"True\n"); else fprintf(file,"False\n"); 3086 if (backup->SMS[i]->RejectDuplicates) fprintf(file,"True\n"); else fprintf(file,"False\n");
3083 fprintf(file,"ReplaceMessage = %i\n",backup->SMS[i]->ReplaceMessage); 3087 fprintf(file,"ReplaceMessage = %i\n",backup->SMS[i]->ReplaceMessage);
3084 fprintf(file,"MessageReference = %i\n",backup->SMS[i]->MessageReference); 3088 fprintf(file,"MessageReference = %i\n",backup->SMS[i]->MessageReference);
3085 fprintf(file,"\n"); 3089 fprintf(file,"\n");
3086 i++; 3090 i++;
3087 } 3091 }
3088 return ERR_NONE; 3092 return ERR_NONE;
3089} 3093}
3090 3094
3091GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) 3095GSM_Error GSM_AddSMSBackupFile(char *FileName, GSM_SMS_Backup *backup)
3092{ 3096{
3093 FILE *file; 3097 FILE *file;
3094 3098
3095 file = fopen(FileName, "wb"); 3099 file = fopen(FileName, "ab");
3096 if (file == NULL) return(ERR_CANTOPENFILE); 3100 if (file == NULL) return(ERR_CANTOPENFILE);
3097 3101
3098 SaveSMSBackupTextFile(file,backup); 3102 SaveSMSBackupTextFile(file,backup);
3099 3103
3100 fclose(file); 3104 fclose(file);
3101 3105
3102 return ERR_NONE; 3106 return ERR_NONE;
3103} 3107}
3104 3108
3105#endif 3109#endif
3106 3110
3107/* How should editor hadle tabs in this file? Add editor commands here. 3111/* How should editor hadle tabs in this file? Add editor commands here.
3108 * vim: noexpandtab sw=8 ts=8 sts=8: 3112 * vim: noexpandtab sw=8 ts=8 sts=8:
3109 */ 3113 */
diff --git a/gammu/emb/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h
index 2d2dd7a..33e5424 100644
--- a/gammu/emb/common/service/gsmring.h
+++ b/gammu/emb/common/service/gsmring.h
@@ -1,204 +1,204 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_ring_h 3#ifndef __gsm_ring_h
4#define __gsm_ring_h 4#define __gsm_ring_h
5 5
6/* --------------- Smart Messaging Specification 2.0 & 3.0 ----------------- */ 6/* --------------- Smart Messaging Specification 2.0 & 3.0 ----------------- */
7 7
8 #define SM_CommandEnd_CommandEnd 0x00 8 #define SM_CommandEnd_CommandEnd 0x00
9 9
10/* specification gives also other */ 10/* specification gives also other */
11 #define SM_Command_RingingToneProgramming 0x25<<1 11 #define SM_Command_RingingToneProgramming 0x25<<1
12 #define SM_Command_Sound 0x1d<<1 12 #define SM_Command_Sound 0x1d<<1
13/* specification gives also other */ 13/* specification gives also other */
14 14
15 #define SM_Song_BasicSongType 0x01<<5 15 #define SM_Song_BasicSongType 0x01<<5
16/* specification gives also other */ 16/* specification gives also other */
17 17
18 #define SM_PatternID_A_part 0x00<<6 18 #define SM_PatternID_A_part 0x00<<6
19/* specification gives also other */ 19/* specification gives also other */
20 20
21 #define SM_InstructionID_PatternHeaderId 0x00<<5 21 #define SM_InstructionID_PatternHeaderId 0x00<<5
22 #define SM_InstructionID_NoteInstructionId 0x01<<5 22 #define SM_InstructionID_NoteInstructionId 0x01<<5
23 #define SM_InstructionID_ScaleInstructionId 0x02<<5 23 #define SM_InstructionID_ScaleInstructionId 0x02<<5
24 #define SM_InstructionID_StyleInstructionId 0x03<<5 24 #define SM_InstructionID_StyleInstructionId 0x03<<5
25 #define SM_InstructionID_TempoInstructionId 0x04<<5 25 #define SM_InstructionID_TempoInstructionId 0x04<<5
26 #define SM_InstructionID_VolumeInstructionId 0x05<<5 26 #define SM_InstructionID_VolumeInstructionId 0x05<<5
27 27
28/* ------ end of Smart Messaging Specification 2.0 & 3.0 definitions ------- */ 28/* ------ end of Smart Messaging Specification 2.0 & 3.0 definitions ------- */
29 29
30#define MAX_RINGTONE_NOTES 255 30#define MAX_RINGTONE_NOTES 255
31 31
32typedef enum { 32typedef enum {
33 /** 33 /**
34 * Natural style (rest between notes) 34 * Natural style (rest between notes)
35 */ 35 */
36 NaturalStyle = 0x00<<6, 36 NaturalStyle = 0x00<<6,
37 /** 37 /**
38 * Continuous style (no rest between notes) 38 * Continuous style (no rest between notes)
39 */ 39 */
40 ContinuousStyle = 0x01<<6, 40 ContinuousStyle = 0x01<<6,
41 /** 41 /**
42 * Staccato style (shorter notes and longer rest period) 42 * Staccato style (shorter notes and longer rest period)
43 */ 43 */
44 StaccatoStyle = 0x02<<6 44 StaccatoStyle = 0x02<<6
45} GSM_RingNoteStyle; 45} GSM_RingNoteStyle;
46 46
47typedef enum { 47typedef enum {
48 Note_Pause = 0x00<<4, 48 Note_Pause = 0x00<<4,
49 Note_C = 0x01<<4, 49 Note_C = 0x01<<4,
50 Note_Cis = 0x02<<4, 50 Note_Cis = 0x02<<4,
51 Note_D = 0x03<<4, 51 Note_D = 0x03<<4,
52 Note_Dis = 0x04<<4, 52 Note_Dis = 0x04<<4,
53 Note_E = 0x05<<4, 53 Note_E = 0x05<<4,
54 Note_F = 0x06<<4, 54 Note_F = 0x06<<4,
55 Note_Fis = 0x07<<4, 55 Note_Fis = 0x07<<4,
56 Note_G = 0x08<<4, 56 Note_G = 0x08<<4,
57 Note_Gis = 0x09<<4, 57 Note_Gis = 0x09<<4,
58 Note_A = 0x0a<<4, 58 Note_A = 0x0a<<4,
59 Note_Ais = 0x0b<<4, 59 Note_Ais = 0x0b<<4,
60 Note_H = 0x0c<<4 60 Note_H = 0x0c<<4
61} GSM_RingNoteNote; 61} GSM_RingNoteNote;
62 62
63typedef enum { 63typedef enum {
64 Duration_Full = 0x00<<5, 64 Duration_Full = 0x00<<5,
65 Duration_1_2 = 0x01<<5, 65 Duration_1_2 = 0x01<<5,
66 Duration_1_4 = 0x02<<5, 66 Duration_1_4 = 0x02<<5,
67 Duration_1_8 = 0x03<<5, 67 Duration_1_8 = 0x03<<5,
68 Duration_1_16 = 0x04<<5, 68 Duration_1_16 = 0x04<<5,
69 Duration_1_32 = 0x05<<5 69 Duration_1_32 = 0x05<<5
70} GSM_RingNoteDuration; 70} GSM_RingNoteDuration;
71 71
72typedef enum { 72typedef enum {
73 NoSpecialDuration = 0x00<<6, 73 NoSpecialDuration = 0x00<<6,
74 DottedNote = 0x01<<6, 74 DottedNote = 0x01<<6,
75 DoubleDottedNote = 0x02<<6, 75 DoubleDottedNote = 0x02<<6,
76 Length_2_3 = 0x03<<6 76 Length_2_3 = 0x03<<6
77} GSM_RingNoteDurationSpec; 77} GSM_RingNoteDurationSpec;
78 78
79typedef enum { 79typedef enum {
80 Scale_55 = 1, /* 55 Hz for note A */ 80 Scale_55 = 1, /* 55 Hz for note A */
81 Scale_110, /* 110 Hz for note A */ 81 Scale_110, /* 110 Hz for note A */
82 Scale_220, 82 Scale_220,
83 Scale_440, /* first scale for Nokia */ 83 Scale_440, /* first scale for Nokia */
84 Scale_880, 84 Scale_880,
85 Scale_1760, 85 Scale_1760,
86 Scale_3520, /* last scale for Nokia */ 86 Scale_3520, /* last scale for Nokia */
87 Scale_7040, 87 Scale_7040,
88 Scale_14080 88 Scale_14080
89} GSM_RingNoteScale; 89} GSM_RingNoteScale;
90 90
91typedef struct { 91typedef struct {
92 GSM_RingNoteDuration Duration; 92 GSM_RingNoteDuration Duration;
93 GSM_RingNoteDurationSpec DurationSpec; 93 GSM_RingNoteDurationSpec DurationSpec;
94 GSM_RingNoteNote Note; 94 GSM_RingNoteNote Note;
95 GSM_RingNoteStyle Style; 95 GSM_RingNoteStyle Style;
96 GSM_RingNoteScale Scale; 96 GSM_RingNoteScale Scale;
97 int Tempo; 97 int Tempo;
98} GSM_RingNote; 98} GSM_RingNote;
99 99
100typedef enum { 100typedef enum {
101 RING_Note = 1, 101 RING_Note = 1,
102 RING_EnableVibra, 102 RING_EnableVibra,
103 RING_DisableVibra, 103 RING_DisableVibra,
104 RING_EnableLight, 104 RING_EnableLight,
105 RING_DisableLight, 105 RING_DisableLight,
106 RING_EnableLED, 106 RING_EnableLED,
107 RING_DisableLED, 107 RING_DisableLED,
108 RING_Repeat 108 RING_Repeat
109} GSM_RingCommandType; 109} GSM_RingCommandType;
110 110
111typedef struct { 111typedef struct {
112 GSM_RingCommandType Type; 112 GSM_RingCommandType Type;
113 GSM_RingNote Note; 113 GSM_RingNote Note;
114 unsigned char Value; 114 unsigned char Value;
115} GSM_RingCommand; 115} GSM_RingCommand;
116 116
117typedef struct { 117typedef struct {
118 int NrCommands; 118 int NrCommands;
119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES]; 119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
120 bool AllNotesScale; 120 bool AllNotesScale;
121} GSM_NoteRingtone; 121} GSM_NoteRingtone;
122 122
123/* FIXME: should use BinaryTone instead? */ 123/* FIXME: should use BinaryTone instead? */
124/* Structure to hold Nokia binary ringtones. */ 124/* Structure to hold Nokia binary ringtones. */
125typedef struct { 125typedef struct {
126 unsigned char Frame[50000]; 126 unsigned char Frame[50000];
127 int Length; 127 int Length;
128} GSM_NokiaBinaryRingtone; 128} GSM_NokiaBinaryRingtone;
129 129
130typedef struct { 130typedef struct {
131 unsigned char *Buffer; 131 unsigned char *Buffer;
132 int Length; 132 int Length;
133} GSM_BinaryTone; 133} GSM_BinaryTone;
134 134
135typedef enum { 135typedef enum {
136 RING_NOTETONE = 1, 136 RING_NOTETONE = 1,
137 RING_NOKIABINARY, 137 RING_NOKIABINARY,
138 RING_MIDI, 138 RING_MIDI,
139 RING_MMF 139 RING_MMF
140} GSM_RingtoneFormat; 140} GSM_RingtoneFormat;
141 141
142/** 142/**
143 * Structure for saving various ringtones formats 143 * Structure for saving various ringtones formats
144 */ 144 */
145typedef struct { 145typedef struct {
146 /** 146 /**
147 * Ringtone saved in one of three formats 147 * Ringtone saved in one of three formats
148 */ 148 */
149 GSM_NokiaBinaryRingtone NokiaBinary; 149 GSM_NokiaBinaryRingtone NokiaBinary;
150 GSM_BinaryTone BinaryTone; 150 GSM_BinaryTone BinaryTone;
151 GSM_NoteRingtone NoteTone; 151 GSM_NoteRingtone NoteTone;
152 /** 152 /**
153 * Ringtone format 153 * Ringtone format
154 */ 154 */
155 GSM_RingtoneFormat Format; 155 GSM_RingtoneFormat Format;
156 /** 156 /**
157 * Ringtone name 157 * Ringtone name
158 */ 158 */
159 char Name[20*2]; 159 char Name[20*2];
160 /** 160 /**
161 * Ringtone location 161 * Ringtone location
162 */ 162 */
163 int Location; 163 int Location;
164} GSM_Ringtone; 164} GSM_Ringtone;
165 165
166typedef struct { 166typedef struct {
167 int Group;//Nokia specific 167 int Group;//Nokia specific
168 int ID; 168 int ID;
169 char Name[30*2]; 169 char Name[30*2];
170} GSM_RingtoneInfo; 170} GSM_RingtoneInfo;
171 171
172typedef struct { 172typedef struct {
173 int Number; 173 int Number;
174 GSM_RingtoneInfo Ringtone[100]; 174 GSM_RingtoneInfo *Ringtone;
175} GSM_AllRingtonesInfo; 175} GSM_AllRingtonesInfo;
176 176
177GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone); 177GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone);
178GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone); 178GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone);
179 179
180void saveott(FILE *file, GSM_Ringtone *ringtone); 180void saveott(FILE *file, GSM_Ringtone *ringtone);
181void savemid(FILE *file, GSM_Ringtone *ringtone); 181void savemid(FILE *file, GSM_Ringtone *ringtone);
182void saverng(FILE *file, GSM_Ringtone *ringtone); 182void saverng(FILE *file, GSM_Ringtone *ringtone);
183void saveimelody(FILE *file, GSM_Ringtone *ringtone); 183void saveimelody(FILE *file, GSM_Ringtone *ringtone);
184GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone); 184GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone);
185GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone); 185GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone);
186 186
187 unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength); 187 unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength);
188 unsigned char GSM_EncodeEMSSound (GSM_Ringtone ringtone, unsigned char *package, int *maxlength, double version, bool start); 188 unsigned char GSM_EncodeEMSSound (GSM_Ringtone ringtone, unsigned char *package, int *maxlength, double version, bool start);
189 189
190 GSM_Error GSM_DecodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, int maxlength); 190 GSM_Error GSM_DecodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, int maxlength);
191 191
192 GSM_Error GSM_RingtoneConvert(GSM_Ringtone *dest, GSM_Ringtone *src, GSM_RingtoneFormatFormat); 192 GSM_Error GSM_RingtoneConvert(GSM_Ringtone *dest, GSM_Ringtone *src, GSM_RingtoneFormatFormat);
193 193
194 int GSM_RTTLGetTempo (int Beats); 194 int GSM_RTTLGetTempo (int Beats);
195 int GSM_RingNoteGetFrequency(GSM_RingNote Note); 195 int GSM_RingNoteGetFrequency(GSM_RingNote Note);
196 int GSM_RingNoteGetFullDuration(GSM_RingNote Note); 196 int GSM_RingNoteGetFullDuration(GSM_RingNote Note);
197 197
198char *GSM_GetRingtoneName(GSM_AllRingtonesInfo *Info, int ID); 198char *GSM_GetRingtoneName(GSM_AllRingtonesInfo *Info, int ID);
199 199
200#endif 200#endif
201 201
202/* How should editor hadle tabs in this file? Add editor commands here. 202/* How should editor hadle tabs in this file? Add editor commands here.
203 * vim: noexpandtab sw=8 ts=8 sts=8: 203 * vim: noexpandtab sw=8 ts=8 sts=8:
204 */ 204 */
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index 684e67c..4c6486d 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -54,966 +54,974 @@ static INI_Section *cfg = NULL;
54 GSM_Error error = ERR_NONE; 54 GSM_Error error = ERR_NONE;
55 static int i; 55 static int i;
56 56
57 volatile bool gshutdown = false; 57 volatile bool gshutdown = false;
58 58
59void interrupt(int sign) 59void interrupt(int sign)
60{ 60{
61 signal(sign, SIG_IGN); 61 signal(sign, SIG_IGN);
62 gshutdown = true; 62 gshutdown = true;
63} 63}
64 64
65#ifdef __GNUC__ 65#ifdef __GNUC__
66__attribute__((format(printf, 1, 2))) 66__attribute__((format(printf, 1, 2)))
67#endif 67#endif
68int printmsg(char *format, ...) 68int printmsg(char *format, ...)
69{ 69{
70 va_list argp; 70 va_list argp;
71 int result; 71 int result;
72 72
73 va_start(argp, format); 73 va_start(argp, format);
74 result = vfprintf(stdout,GetMsg(s.msg,format),argp); 74 result = vfprintf(stdout,GetMsg(s.msg,format),argp);
75 va_end(argp); 75 va_end(argp);
76 return result; 76 return result;
77} 77}
78 78
79#ifdef __GNUC__ 79#ifdef __GNUC__
80__attribute__((format(printf, 1, 2))) 80__attribute__((format(printf, 1, 2)))
81#endif 81#endif
82int printmsgerr(char *format, ...) 82int printmsgerr(char *format, ...)
83{ 83{
84 va_list argp; 84 va_list argp;
85 int result; 85 int result;
86 86
87 va_start(argp, format); 87 va_start(argp, format);
88 result = vfprintf(stderr,GetMsg(s.msg,format), argp); 88 result = vfprintf(stderr,GetMsg(s.msg,format), argp);
89 va_end(argp); 89 va_end(argp);
90 return result; 90 return result;
91} 91}
92 92
93static void PrintSecurityStatus() 93static void PrintSecurityStatus()
94{ 94{
95 GSM_SecurityCodeType Status; 95 GSM_SecurityCodeType Status;
96 96
97 error=Phone->GetSecurityStatus(&s,&Status); 97 error=Phone->GetSecurityStatus(&s,&Status);
98 Print_Error(error); 98 Print_Error(error);
99 switch(Status) { 99 switch(Status) {
100 case SEC_SecurityCode: 100 case SEC_SecurityCode:
101 printmsg("Waiting for Security Code.\n"); 101 printmsg("Waiting for Security Code.\n");
102 break; 102 break;
103 case SEC_Pin: 103 case SEC_Pin:
104 printmsg("Waiting for PIN.\n"); 104 printmsg("Waiting for PIN.\n");
105 break; 105 break;
106 case SEC_Pin2: 106 case SEC_Pin2:
107 printmsg("Waiting for PIN2.\n"); 107 printmsg("Waiting for PIN2.\n");
108 break; 108 break;
109 case SEC_Puk: 109 case SEC_Puk:
110 printmsg("Waiting for PUK.\n"); 110 printmsg("Waiting for PUK.\n");
111 break; 111 break;
112 case SEC_Puk2: 112 case SEC_Puk2:
113 printmsg("Waiting for PUK2.\n"); 113 printmsg("Waiting for PUK2.\n");
114 break; 114 break;
115 case SEC_None: 115 case SEC_None:
116 printmsg("Nothing to enter.\n"); 116 printmsg("Nothing to enter.\n");
117 break; 117 break;
118 default: 118 default:
119 printmsg("Unknown\n"); 119 printmsg("Unknown\n");
120 } 120 }
121} 121}
122 122
123void Print_Error(GSM_Error error) 123void Print_Error(GSM_Error error)
124{ 124{
125 if (error != ERR_NONE) { 125 if (error != ERR_NONE) {
126 printf("%s\n",print_error(error,s.di.df,s.msg)); 126 printf("%s\n",print_error(error,s.di.df,s.msg));
127 if (error == ERR_SECURITYERROR) { 127 if (error == ERR_SECURITYERROR) {
128 printmsg("Security status: "); 128 printmsg("Security status: ");
129 PrintSecurityStatus(); 129 PrintSecurityStatus();
130 } 130 }
131 if (s.opened) GSM_TerminateConnection(&s); 131 if (s.opened) GSM_TerminateConnection(&s);
132 exit (-1); 132 exit (-1);
133 } 133 }
134} 134}
135 135
136void GSM_Init(bool checkerror) 136void GSM_Init(bool checkerror)
137{ 137{
138 error=GSM_InitConnection(&s,3); 138 error=GSM_InitConnection(&s,3);
139 if (checkerror) Print_Error(error); 139 if (checkerror) Print_Error(error);
140 140
141 Phone=s.Phone.Functions; 141 Phone=s.Phone.Functions;
142} 142}
143 143
144void GSM_Terminate(void) 144void GSM_Terminate(void)
145{ 145{
146 error=GSM_TerminateConnection(&s); 146 error=GSM_TerminateConnection(&s);
147 Print_Error(error); 147 Print_Error(error);
148} 148}
149 149
150static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[]) 150static void GetStartStop(int *start, int *stop, int num, int argc, char *argv[])
151{ 151{
152 *start=atoi(argv[num]); 152 *start=atoi(argv[num]);
153 if (*start==0) { 153 if (*start==0) {
154 printmsg("ERROR: enumerate locations from 1\n"); 154 printmsg("ERROR: enumerate locations from 1\n");
155 exit (-1); 155 exit (-1);
156 } 156 }
157 157
158 if (stop!=NULL) { 158 if (stop!=NULL) {
159 *stop=*start; 159 *stop=*start;
160 if (argc>=num+2) *stop=atoi(argv[num+1]); 160 if (argc>=num+2) *stop=atoi(argv[num+1]);
161 if (*stop==0) { 161 if (*stop==0) {
162 printmsg("ERROR: enumerate locations from 1\n"); 162 printmsg("ERROR: enumerate locations from 1\n");
163 exit (-1); 163 exit (-1);
164 } 164 }
165 } 165 }
166} 166}
167 167
168bool always_answer_yes = false; 168bool always_answer_yes = false;
169bool always_answer_no = false; 169bool always_answer_no = false;
170 170
171static bool answer_yes(char *text) 171static bool answer_yes(char *text)
172{ 172{
173 int len; 173 int len;
174 char ans[99]; 174 char ans[99];
175 175
176 while (1) { 176 while (1) {
177 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text); 177 printmsgerr("%s (yes/no/ALL/ONLY/NONE) ? ",text);
178 if (always_answer_yes) { 178 if (always_answer_yes) {
179 printmsgerr("YES (always)\n"); 179 printmsgerr("YES (always)\n");
180 return true; 180 return true;
181 } 181 }
182 if (always_answer_no) { 182 if (always_answer_no) {
183 printmsgerr("NO (always)\n"); 183 printmsgerr("NO (always)\n");
184 return false; 184 return false;
185 } 185 }
186 len=GetLine(stdin, ans, 99); 186 len=GetLine(stdin, ans, 99);
187 if (len==-1) exit(-1); 187 if (len==-1) exit(-1);
188 if (!strcmp(ans, "NONE")) { 188 if (!strcmp(ans, "NONE")) {
189 always_answer_no = true; 189 always_answer_no = true;
190 return false; 190 return false;
191 } 191 }
192 if (!strcmp(ans, "ONLY")) { 192 if (!strcmp(ans, "ONLY")) {
193 always_answer_no = true; 193 always_answer_no = true;
194 return true; 194 return true;
195 } 195 }
196 if (!strcmp(ans, "ALL")) { 196 if (!strcmp(ans, "ALL")) {
197 always_answer_yes = true; 197 always_answer_yes = true;
198 return true; 198 return true;
199 } 199 }
200 if (mystrncasecmp(ans, "yes",0)) return true; 200 if (mystrncasecmp(ans, "yes",0)) return true;
201 if (mystrncasecmp(ans, "no" ,0)) return false; 201 if (mystrncasecmp(ans, "no" ,0)) return false;
202 } 202 }
203} 203}
204 204
205#ifdef GSM_ENABLE_BEEP 205#ifdef GSM_ENABLE_BEEP
206void GSM_PhoneBeep(void) 206void GSM_PhoneBeep(void)
207{ 207{
208 error = PHONE_Beep(&s); 208 error = PHONE_Beep(&s);
209 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error); 209 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error);
210} 210}
211#endif 211#endif
212 212
213static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone) 213static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
214{ 214{
215 int i; 215 int i;
216 bool first=true; 216 bool first=true;
217 GSM_Error error; 217 GSM_Error error;
218 218
219 signal(SIGINT, interrupt); 219 signal(SIGINT, interrupt);
220 printmsg("Press Ctrl+C to break...\n"); 220 printmsg("Press Ctrl+C to break...\n");
221 221
222 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 222 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
223 if (gshutdown) break; 223 if (gshutdown) break;
224 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue; 224 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue;
225 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first); 225 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first);
226 if (error!=ERR_NONE) return error; 226 if (error!=ERR_NONE) return error;
227 first = false; 227 first = false;
228 } 228 }
229 229
230 /* Disables buzzer */ 230 /* Disables buzzer */
231 return s.Phone.Functions->PlayTone(&s,255*255,0,false); 231 return s.Phone.Functions->PlayTone(&s,255*255,0,false);
232} 232}
233 233
234static void PlayRingtone(int argc, char *argv[]) 234static void PlayRingtone(int argc, char *argv[])
235{ 235{
236 GSM_Ringtone ringtone,ringtone2; 236 GSM_Ringtone ringtone,ringtone2;
237 237
238 ringtone.Format= 0; 238 ringtone.Format= 0;
239 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 239 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
240 Print_Error(error); 240 Print_Error(error);
241 241
242 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE); 242 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE);
243 Print_Error(error); 243 Print_Error(error);
244 244
245 GSM_Init(true); 245 GSM_Init(true);
246 246
247 error=GSM_PlayRingtone(ringtone2); 247 error=GSM_PlayRingtone(ringtone2);
248 Print_Error(error); 248 Print_Error(error);
249 249
250 GSM_Terminate(); 250 GSM_Terminate();
251} 251}
252 252
253static void Identify(int argc, char *argv[]) 253static void Identify(int argc, char *argv[])
254{ 254{
255 unsigned char buffer[100]; 255 unsigned char buffer[100];
256 256
257 GSM_Init(true); 257 GSM_Init(true);
258 258
259 error=Phone->GetManufacturer(&s); 259 error=Phone->GetManufacturer(&s);
260 Print_Error(error); 260 Print_Error(error);
261 printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer); 261 printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer);
262 error=Phone->GetModel(&s); 262 error=Phone->GetModel(&s);
263 Print_Error(error); 263 Print_Error(error);
264 printmsg("Model : %s (%s)\n", 264 printmsg("Model : %s (%s)\n",
265 s.Phone.Data.ModelInfo->model, 265 s.Phone.Data.ModelInfo->model,
266 s.Phone.Data.Model); 266 s.Phone.Data.Model);
267 267
268 error=Phone->GetFirmware(&s); 268 error=Phone->GetFirmware(&s);
269 Print_Error(error); 269 Print_Error(error);
270 printmsg("Firmware : %s",s.Phone.Data.Version); 270 printmsg("Firmware : %s",s.Phone.Data.Version);
271 error=Phone->GetPPM(&s, buffer); 271 error=Phone->GetPPM(&s, buffer);
272 if (error != ERR_NOTSUPPORTED) { 272 if (error != ERR_NOTSUPPORTED) {
273 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 273 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
274 if (error == ERR_NONE) printmsg(" %s",buffer); 274 if (error == ERR_NONE) printmsg(" %s",buffer);
275 } 275 }
276 if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate); 276 if (s.Phone.Data.VerDate[0]!=0) printmsg(" (%s)",s.Phone.Data.VerDate);
277 printf("\n"); 277 printf("\n");
278 278
279 error=Phone->GetHardware(&s, buffer); 279 error=Phone->GetHardware(&s, buffer);
280 if (error != ERR_NOTSUPPORTED) { 280 if (error != ERR_NOTSUPPORTED) {
281 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 281 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
282 if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer); 282 if (error == ERR_NONE) printmsg("Hardware : %s\n",buffer);
283 } 283 }
284 284
285 error=Phone->GetIMEI(&s); 285 error=Phone->GetIMEI(&s);
286 if (error != ERR_NOTSUPPORTED) { 286 if (error != ERR_NOTSUPPORTED) {
287 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 287 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
288 if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI); 288 if (error == ERR_NONE) printmsg("IMEI : %s\n",s.Phone.Data.IMEI);
289 289
290 error=Phone->GetOriginalIMEI(&s, buffer); 290 error=Phone->GetOriginalIMEI(&s, buffer);
291 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) { 291 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
292 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 292 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
293 if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer); 293 if (error == ERR_NONE) printmsg("Original IMEI : %s\n",buffer);
294 } 294 }
295 } 295 }
296 296
297 error=Phone->GetManufactureMonth(&s, buffer); 297 error=Phone->GetManufactureMonth(&s, buffer);
298 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) { 298 if (error != ERR_NOTSUPPORTED && error != ERR_SECURITYERROR) {
299 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 299 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
300 if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer); 300 if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer);
301 } 301 }
302 302
303 error=Phone->GetProductCode(&s, buffer); 303 error=Phone->GetProductCode(&s, buffer);
304 if (error != ERR_NOTSUPPORTED) { 304 if (error != ERR_NOTSUPPORTED) {
305 if (error != ERR_NOTIMPLEMENTED) Print_Error(error); 305 if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
306 if (error == ERR_NONE) printmsg("Product code : %s\n",buffer); 306 if (error == ERR_NONE) printmsg("Product code : %s\n",buffer);
307 } 307 }
308 308
309 error=Phone->GetSIMIMSI(&s, buffer); 309 error=Phone->GetSIMIMSI(&s, buffer);
310 switch (error) { 310 switch (error) {
311 case ERR_SECURITYERROR: 311 case ERR_SECURITYERROR:
312 case ERR_NOTSUPPORTED: 312 case ERR_NOTSUPPORTED:
313 case ERR_NOTIMPLEMENTED: 313 case ERR_NOTIMPLEMENTED:
314 break; 314 break;
315 case ERR_NONE: 315 case ERR_NONE:
316 printmsg("SIM IMSI : %s\n",buffer); 316 printmsg("SIM IMSI : %s\n",buffer);
317 break; 317 break;
318 default: 318 default:
319 Print_Error(error); 319 Print_Error(error);
320 } 320 }
321 321
322#ifdef GSM_ENABLE_NOKIA_DCT3 322#ifdef GSM_ENABLE_NOKIA_DCT3
323 DCT3Info(argc, argv); 323 DCT3Info(argc, argv);
324#endif 324#endif
325#ifdef GSM_ENABLE_NOKIA_DCT4 325#ifdef GSM_ENABLE_NOKIA_DCT4
326 DCT4Info(argc, argv); 326 DCT4Info(argc, argv);
327#endif 327#endif
328 328
329 GSM_Terminate(); 329 GSM_Terminate();
330} 330}
331 331
332static void GetDateTime(int argc, char *argv[]) 332static void GetDateTime(int argc, char *argv[])
333{ 333{
334 GSM_DateTime date_time; 334 GSM_DateTime date_time;
335 GSM_Localelocale; 335 GSM_Localelocale;
336 336
337 GSM_Init(true); 337 GSM_Init(true);
338 338
339 error=Phone->GetDateTime(&s, &date_time); 339 error=Phone->GetDateTime(&s, &date_time);
340 switch (error) { 340 switch (error) {
341 case ERR_EMPTY: 341 case ERR_EMPTY:
342 printmsg("Date and time not set in phone\n"); 342 printmsg("Date and time not set in phone\n");
343 break; 343 break;
344 case ERR_NONE: 344 case ERR_NONE:
345 printmsg("Phone time is %s\n",OSDateTime(date_time,false)); 345 printmsg("Phone time is %s\n",OSDateTime(date_time,false));
346 break; 346 break;
347 default: 347 default:
348 Print_Error(error); 348 Print_Error(error);
349 } 349 }
350 350
351 error=Phone->GetLocale(&s, &locale); 351 error=Phone->GetLocale(&s, &locale);
352 switch (error) { 352 switch (error) {
353 case ERR_NOTSUPPORTED: 353 case ERR_NOTSUPPORTED:
354 case ERR_NOTIMPLEMENTED: 354 case ERR_NOTIMPLEMENTED:
355 break; 355 break;
356 default: 356 default:
357 Print_Error(error); 357 Print_Error(error);
358 printmsg("Time format is "); 358 printmsg("Time format is ");
359 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n"); 359 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n");
360 printmsg("Date format is "); 360 printmsg("Date format is ");
361 switch (locale.DateFormat) { 361 switch (locale.DateFormat) {
362 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break; 362 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break;
363 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break; 363 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break;
364 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD"); 364 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
365 default :break; 365 default :break;
366 } 366 }
367 printmsg(", date separator is %c\n",locale.DateSeparator); 367 printmsg(", date separator is %c\n",locale.DateSeparator);
368 } 368 }
369 369
370 GSM_Terminate(); 370 GSM_Terminate();
371} 371}
372 372
373static void SetDateTime(int argc, char *argv[]) 373static void SetDateTime(int argc, char *argv[])
374{ 374{
375 GSM_DateTime date_time; 375 GSM_DateTime date_time;
376 376
377 GSM_GetCurrentDateTime(&date_time); 377 GSM_GetCurrentDateTime(&date_time);
378 378
379 GSM_Init(true); 379 GSM_Init(true);
380 380
381 error=Phone->SetDateTime(&s, &date_time); 381 error=Phone->SetDateTime(&s, &date_time);
382 Print_Error(error); 382 Print_Error(error);
383 383
384 GSM_Terminate(); 384 GSM_Terminate();
385} 385}
386 386
387static void GetAlarm(int argc, char *argv[]) 387static void GetAlarm(int argc, char *argv[])
388{ 388{
389 GSM_Alarm alarm; 389 GSM_Alarm alarm;
390 390
391 GSM_Init(true); 391 GSM_Init(true);
392 392
393 alarm.Location = 1; 393 alarm.Location = 1;
394 error=Phone->GetAlarm(&s, &alarm); 394 error=Phone->GetAlarm(&s, &alarm);
395 switch (error) { 395 switch (error) {
396 case ERR_EMPTY: 396 case ERR_EMPTY:
397 printmsg("Alarm not set in phone\n"); 397 printmsg("Alarm not set in phone\n");
398 break; 398 break;
399 case ERR_NONE: 399 case ERR_NONE:
400 if (alarm.Repeating) { 400 if (alarm.Repeating) {
401 printmsg("Date: %s\n","Every day"); 401 printmsg("Date: %s\n","Every day");
402 } else { 402 } else {
403 printmsg("Date: %s\n",OSDate(alarm.DateTime)); 403 printmsg("Date: %s\n",OSDate(alarm.DateTime));
404 } 404 }
405 printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute); 405 printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute);
406 if (alarm.Text[0] != 0 || alarm.Text[1] != 0) { 406 if (alarm.Text[0] != 0 || alarm.Text[1] != 0) {
407 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text)); 407 printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text));
408 } 408 }
409 break; 409 break;
410 default: 410 default:
411 Print_Error(error); 411 Print_Error(error);
412 } 412 }
413 413
414 GSM_Terminate(); 414 GSM_Terminate();
415} 415}
416 416
417static void SetAlarm(int argc, char *argv[]) 417static void SetAlarm(int argc, char *argv[])
418{ 418{
419 GSM_Alarm alarm; 419 GSM_Alarm alarm;
420 420
421 alarm.DateTime.Hour = atoi(argv[2]); 421 alarm.DateTime.Hour = atoi(argv[2]);
422 alarm.DateTime.Minute = atoi(argv[3]); 422 alarm.DateTime.Minute = atoi(argv[3]);
423 alarm.DateTime.Second = 0; 423 alarm.DateTime.Second = 0;
424 alarm.Location = 1; 424 alarm.Location = 1;
425 alarm.Repeating = true; 425 alarm.Repeating = true;
426 alarm.Text[0] = 0; 426 alarm.Text[0] = 0;
427 alarm.Text[1] = 0; 427 alarm.Text[1] = 0;
428 428
429 GSM_Init(true); 429 GSM_Init(true);
430 430
431 error=Phone->SetAlarm(&s, &alarm); 431 error=Phone->SetAlarm(&s, &alarm);
432 Print_Error(error); 432 Print_Error(error);
433 433
434 GSM_Terminate(); 434 GSM_Terminate();
435} 435}
436 436
437 GSM_Bitmap caller[5]; 437 GSM_Bitmap caller[5];
438 GSM_AllRingtonesInfo Info; 438 GSM_AllRingtonesInfo Info = {0, NULL};
439 bool callerinit[5] = {false, false, false, false, false}; 439 bool callerinit[5] = {false, false, false, false, false};
440 bool ringinit = false; 440 bool ringinit = false;
441 441
442static void PrintMemoryEntry(GSM_MemoryEntry *entry) 442static void PrintMemoryEntry(GSM_MemoryEntry *entry)
443{ 443{
444 GSM_Category Category; 444 GSM_Category Category;
445 bool unknown; 445 bool unknown;
446 int z; 446 int z;
447 447
448 for (i=0;i<entry->EntriesNum;i++) { 448 for (i=0;i<entry->EntriesNum;i++) {
449 unknown = false; 449 unknown = false;
450 switch (entry->Entries[i].EntryType) { 450 switch (entry->Entries[i].EntryType) {
451 case PBK_Date: 451 case PBK_Date:
452 printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false)); 452 printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false));
453 continue; 453 continue;
454 case PBK_Category: 454 case PBK_Category:
455 Category.Location = entry->Entries[i].Number; 455 Category.Location = entry->Entries[i].Number;
456 Category.Type = Category_Phonebook; 456 Category.Type = Category_Phonebook;
457 error=Phone->GetCategory(&s, &Category); 457 error=Phone->GetCategory(&s, &Category);
458 if (error == ERR_NONE) { 458 if (error == ERR_NONE) {
459 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number); 459 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number);
460 } else { 460 } else {
461 printmsg("Category : %i\n", entry->Entries[i].Number); 461 printmsg("Category : %i\n", entry->Entries[i].Number);
462 } 462 }
463 continue; 463 continue;
464 case PBK_Private: 464 case PBK_Private:
465 printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No"); 465 printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No");
466 continue; 466 continue;
467 case PBK_Number_General : printmsg("General number "); break; 467 case PBK_Number_General : printmsg("General number "); break;
468 case PBK_Number_Mobile : printmsg("Mobile number "); break; 468 case PBK_Number_Mobile : printmsg("Mobile number "); break;
469 case PBK_Number_Work : printmsg("Work number "); break; 469 case PBK_Number_Work : printmsg("Work number "); break;
470 case PBK_Number_Fax : printmsg("Fax number "); break; 470 case PBK_Number_Fax : printmsg("Fax number "); break;
471 case PBK_Number_Home : printmsg("Home number "); break; 471 case PBK_Number_Home : printmsg("Home number "); break;
472 case PBK_Number_Pager : printmsg("Pager number "); break; 472 case PBK_Number_Pager : printmsg("Pager number "); break;
473 case PBK_Number_Other : printmsg("Other number "); break; 473 case PBK_Number_Other : printmsg("Other number "); break;
474 case PBK_Text_Note : printmsg("Text "); break; 474 case PBK_Text_Note : printmsg("Text "); break;
475 case PBK_Text_Postal : printmsg("Snail address "); break; 475 case PBK_Text_Postal : printmsg("Snail address "); break;
476 case PBK_Text_Email : printmsg("Email address 1 "); break; 476 case PBK_Text_Email : printmsg("Email address 1 "); break;
477 case PBK_Text_Email2 : printmsg("Email address 2 "); break; 477 case PBK_Text_Email2 : printmsg("Email address 2 "); break;
478 case PBK_Text_URL : printmsg("URL address "); break; 478 case PBK_Text_URL : printmsg("URL address "); break;
479 case PBK_Text_Name : printmsg("Name "); break; 479 case PBK_Text_Name : printmsg("Name "); break;
480 case PBK_Text_LastName : printmsg("Last name "); break; 480 case PBK_Text_LastName : printmsg("Last name "); break;
481 case PBK_Text_FirstName : printmsg("First name "); break; 481 case PBK_Text_FirstName : printmsg("First name "); break;
482 case PBK_Text_Company : printmsg("Company "); break; 482 case PBK_Text_Company : printmsg("Company "); break;
483 case PBK_Text_JobTitle : printmsg("Job title "); break; 483 case PBK_Text_JobTitle : printmsg("Job title "); break;
484 case PBK_Text_StreetAddress : printmsg("Street address "); break; 484 case PBK_Text_StreetAddress : printmsg("Street address "); break;
485 case PBK_Text_City : printmsg("City "); break; 485 case PBK_Text_City : printmsg("City "); break;
486 case PBK_Text_State : printmsg("State "); break; 486 case PBK_Text_State : printmsg("State "); break;
487 case PBK_Text_Zip : printmsg("Zip code "); break; 487 case PBK_Text_Zip : printmsg("Zip code "); break;
488 case PBK_Text_Country : printmsg("Country "); break; 488 case PBK_Text_Country : printmsg("Country "); break;
489 case PBK_Text_Custom1 : printmsg("Custom text 1 "); break; 489 case PBK_Text_Custom1 : printmsg("Custom text 1 "); break;
490 case PBK_Text_Custom2 : printmsg("Custom text 2 "); break; 490 case PBK_Text_Custom2 : printmsg("Custom text 2 "); break;
491 case PBK_Text_Custom3 : printmsg("Custom text 3 "); break; 491 case PBK_Text_Custom3 : printmsg("Custom text 3 "); break;
492 case PBK_Text_Custom4 : printmsg("Custom text 4 "); break; 492 case PBK_Text_Custom4 : printmsg("Custom text 4 "); break;
493 case PBK_Caller_Group : 493 case PBK_Caller_Group :
494 unknown = true; 494 unknown = true;
495 if (!callerinit[entry->Entries[i].Number]) { 495 if (!callerinit[entry->Entries[i].Number]) {
496 caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo; 496 caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo;
497 caller[entry->Entries[i].Number].Location = entry->Entries[i].Number; 497 caller[entry->Entries[i].Number].Location = entry->Entries[i].Number;
498 error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]); 498 error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]);
499 Print_Error(error); 499 Print_Error(error);
500 if (caller[entry->Entries[i].Number].DefaultName) { 500 if (caller[entry->Entries[i].Number].DefaultName) {
501 NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]); 501 NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]);
502 } 502 }
503 callerinit[entry->Entries[i].Number]=true; 503 callerinit[entry->Entries[i].Number]=true;
504 } 504 }
505 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text)); 505 printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text));
506 break; 506 break;
507 case PBK_RingtoneID : 507 case PBK_RingtoneID :
508 unknown = true; 508 unknown = true;
509 if (!ringinit) { 509 if (!ringinit) {
510 error=Phone->GetRingtonesInfo(&s,&Info); 510 error=Phone->GetRingtonesInfo(&s,&Info);
511 if (error != ERR_NOTSUPPORTED) Print_Error(error); 511 if (error != ERR_NOTSUPPORTED) Print_Error(error);
512 if (error == ERR_NONE) ringinit = true; 512 if (error == ERR_NONE) ringinit = true;
513 } 513 }
514 if (ringinit) { 514 if (ringinit) {
515 for (z=0;z<Info.Number;z++) { 515 for (z=0;z<Info.Number;z++) {
516 if (Info.Ringtone[z].ID == entry->Entries[i].Number) { 516 if (Info.Ringtone[z].ID == entry->Entries[i].Number) {
517 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name)); 517 printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name));
518 break; 518 break;
519 } 519 }
520 } 520 }
521 } else { 521 } else {
522 printmsg("Ringtone ID : %i\n",entry->Entries[i].Number); 522 printmsg("Ringtone ID : %i\n",entry->Entries[i].Number);
523 } 523 }
524 break; 524 break;
525 case PBK_PictureID : 525 case PBK_PictureID :
526 unknown = true; 526 unknown = true;
527 printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number); 527 printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number);
528 break; 528 break;
529 default : 529 default :
530 printmsg("UNKNOWN\n"); 530 printmsg("UNKNOWN\n");
531 unknown = true; 531 unknown = true;
532 break; 532 break;
533 } 533 }
534 if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text)); 534 if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text));
535 } 535 }
536 printf("\n"); 536 printf("\n");
537} 537}
538 538
539static void GetAllMemory(int argc, char *argv[]) 539static void GetAllMemory(int argc, char *argv[])
540{ 540{
541 GSM_MemoryEntry Entry; 541 GSM_MemoryEntry Entry;
542 bool start = true; 542 bool start = true;
543 543
544 signal(SIGINT, interrupt); 544 signal(SIGINT, interrupt);
545 printmsgerr("Press Ctrl+C to break...\n"); 545 printmsgerr("Press Ctrl+C to break...\n");
546 546
547 Entry.MemoryType = 0; 547 Entry.MemoryType = 0;
548 548
549 if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC; 549 if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC;
550 if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON; 550 if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON;
551 if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC; 551 if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC;
552 if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC; 552 if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC;
553 if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME; 553 if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME;
554 if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM; 554 if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM;
555 if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM; 555 if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM;
556 if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD; 556 if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD;
557 if (Entry.MemoryType==0) { 557 if (Entry.MemoryType==0) {
558 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 558 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
559 exit (-1); 559 exit (-1);
560 } 560 }
561 561
562 GSM_Init(true); 562 GSM_Init(true);
563 563
564 while (!gshutdown) { 564 while (!gshutdown) {
565 error = Phone->GetNextMemory(&s, &Entry, start); 565 error = Phone->GetNextMemory(&s, &Entry, start);
566 if (error == ERR_EMPTY) break; 566 if (error == ERR_EMPTY) break;
567 if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone);
567 Print_Error(error); 568 Print_Error(error);
568 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location); 569 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
569 PrintMemoryEntry(&Entry); 570 PrintMemoryEntry(&Entry);
570 start = false; 571 start = false;
571 } 572 }
572 573
574 if (Info.Ringtone) free(Info.Ringtone);
575
573 GSM_Terminate(); 576 GSM_Terminate();
574} 577}
575 578
576static void GetMemory(int argc, char *argv[]) 579static void GetMemory(int argc, char *argv[])
577{ 580{
578 int j, start, stop, emptynum = 0, fillednum = 0; 581 int j, start, stop, emptynum = 0, fillednum = 0;
579 GSM_MemoryEntry entry; 582 GSM_MemoryEntry entry;
580 bool empty = true; 583 bool empty = true;
581 584
582 entry.MemoryType=0; 585 entry.MemoryType=0;
583 586
584 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC; 587 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC;
585 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON; 588 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON;
586 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC; 589 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC;
587 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC; 590 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC;
588 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME; 591 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME;
589 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM; 592 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM;
590 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM; 593 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM;
591 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD; 594 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD;
592 if (entry.MemoryType==0) { 595 if (entry.MemoryType==0) {
593 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 596 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
594 exit (-1); 597 exit (-1);
595 } 598 }
596 599
597 GetStartStop(&start, &stop, 3, argc, argv); 600 GetStartStop(&start, &stop, 3, argc, argv);
598 601
599 if (argc > 5 && strcmp(argv[5],"")) { 602 if (argc > 5 && strcmp(argv[5],"")) {
600 if (mystrncasecmp(argv[5],"-nonempty",0)) { 603 if (mystrncasecmp(argv[5],"-nonempty",0)) {
601 empty = false; 604 empty = false;
602 } else { 605 } else {
603 printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]); 606 printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]);
604 exit (-1); 607 exit (-1);
605 } 608 }
606 } 609 }
607 610
608 GSM_Init(true); 611 GSM_Init(true);
609 612
610 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) { 613 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) {
611 if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n"); 614 if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n");
612 } 615 }
613 616
614 for (j=start;j<=stop;j++) { 617 for (j=start;j<=stop;j++) {
615 if (empty) printmsg("Memory %s, Location %i\n",argv[2],j); 618 if (empty) printmsg("Memory %s, Location %i\n",argv[2],j);
616 619
617 entry.Location=j; 620 entry.Location=j;
618 621
619 error=Phone->GetMemory(&s, &entry); 622 error=Phone->GetMemory(&s, &entry);
620 if (error != ERR_EMPTY) Print_Error(error); 623 if (error != ERR_EMPTY) {
624 if (Info.Ringtone) free(Info.Ringtone);
625 Print_Error(error);
626 }
621 627
622 if (error == ERR_EMPTY) { 628 if (error == ERR_EMPTY) {
623 emptynum++; 629 emptynum++;
624 if (empty) { 630 if (empty) {
625 printmsg("Entry is empty\n"); 631 printmsg("Entry is empty\n");
626 printf("\n"); 632 printf("\n");
627 } 633 }
628 } else { 634 } else {
629 fillednum++; 635 fillednum++;
630 if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j); 636 if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j);
631 PrintMemoryEntry(&entry); 637 PrintMemoryEntry(&entry);
632 } 638 }
633 } 639 }
634 640
635 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum); 641 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
642
643 if (Info.Ringtone) free(Info.Ringtone);
636 644
637 GSM_Terminate(); 645 GSM_Terminate();
638} 646}
639 647
640#define MemoryLocationToString(x) ( \ 648#define MemoryLocationToString(x) ( \
641 x == MEM_ON ? "ON" : \ 649 x == MEM_ON ? "ON" : \
642 x == MEM_RC ? "RC" : \ 650 x == MEM_RC ? "RC" : \
643 x == MEM_MC ? "MC" : \ 651 x == MEM_MC ? "MC" : \
644 x == MEM_ME ? "ME" : \ 652 x == MEM_ME ? "ME" : \
645 x == MEM_SM ? "SM" : \ 653 x == MEM_SM ? "SM" : \
646 x == MEM_VM ? "VM" : \ 654 x == MEM_VM ? "VM" : \
647 x == MEM_FD ? "FD" : "XX") 655 x == MEM_FD ? "FD" : "XX")
648 656
649static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text) 657static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
650{ 658{
651 int i; 659 int i;
652 660
653 for (i=0;i<Entry->EntriesNum;i++) { 661 for (i=0;i<Entry->EntriesNum;i++) {
654 switch (Entry->Entries[i].EntryType) { 662 switch (Entry->Entries[i].EntryType) {
655 case PBK_Number_General : 663 case PBK_Number_General :
656 case PBK_Number_Mobile : 664 case PBK_Number_Mobile :
657 case PBK_Number_Work : 665 case PBK_Number_Work :
658 case PBK_Number_Fax : 666 case PBK_Number_Fax :
659 case PBK_Number_Home : 667 case PBK_Number_Home :
660 case PBK_Number_Pager : 668 case PBK_Number_Pager :
661 case PBK_Number_Other : 669 case PBK_Number_Other :
662 case PBK_Text_Note : 670 case PBK_Text_Note :
663 case PBK_Text_Postal : 671 case PBK_Text_Postal :
664 case PBK_Text_Email : 672 case PBK_Text_Email :
665 case PBK_Text_Email2 : 673 case PBK_Text_Email2 :
666 case PBK_Text_URL : 674 case PBK_Text_URL :
667 case PBK_Text_Name : 675 case PBK_Text_Name :
668 case PBK_Text_LastName : 676 case PBK_Text_LastName :
669 case PBK_Text_FirstName : 677 case PBK_Text_FirstName :
670 case PBK_Text_Company : 678 case PBK_Text_Company :
671 case PBK_Text_JobTitle : 679 case PBK_Text_JobTitle :
672 case PBK_Text_StreetAddress : 680 case PBK_Text_StreetAddress :
673 case PBK_Text_City : 681 case PBK_Text_City :
674 case PBK_Text_State : 682 case PBK_Text_State :
675 case PBK_Text_Zip : 683 case PBK_Text_Zip :
676 case PBK_Text_Country : 684 case PBK_Text_Country :
677 case PBK_Text_Custom1 : 685 case PBK_Text_Custom1 :
678 case PBK_Text_Custom2 : 686 case PBK_Text_Custom2 :
679 case PBK_Text_Custom3 : 687 case PBK_Text_Custom3 :
680 case PBK_Text_Custom4 : 688 case PBK_Text_Custom4 :
681 case PBK_Caller_Group : 689 case PBK_Caller_Group :
682 if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) { 690 if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) {
683 fprintf(stderr,"\n"); 691 fprintf(stderr,"\n");
684 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location); 692 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location);
685 PrintMemoryEntry(Entry); 693 PrintMemoryEntry(Entry);
686 return; 694 return;
687 } 695 }
688 break; 696 break;
689 default: 697 default:
690 break; 698 break;
691 } 699 }
692 } 700 }
693 } 701 }
694 702
695static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text) 703static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text)
696{ 704{
697 GSM_MemoryEntry Entry; 705 GSM_MemoryEntry Entry;
698 GSM_MemoryStatusStatus; 706 GSM_MemoryStatusStatus;
699 int i = 0, l = 1; 707 int i = 0, l = 1;
700 bool start = true; 708 bool start = true;
701 709
702 Status.MemoryType = MemoryType; 710 Status.MemoryType = MemoryType;
703 Entry.MemoryType = MemoryType; 711 Entry.MemoryType = MemoryType;
704 712
705 if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) { 713 if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) {
706 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); 714 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
707 if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) { 715 if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) {
708 while (i < Status.MemoryUsed) { 716 while (i < Status.MemoryUsed) {
709 if (gshutdown) return; 717 if (gshutdown) return;
710 i++; 718 i++;
711 fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1)); 719 fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1));
712 error = Phone->GetNextMemory(&s, &Entry, start); 720 error = Phone->GetNextMemory(&s, &Entry, start);
713 if (error == ERR_EMPTY) break; 721 if (error == ERR_EMPTY) break;
714 Print_Error(error); 722 Print_Error(error);
715 SearchOneEntry(&Entry, Text); 723 SearchOneEntry(&Entry, Text);
716 start = false; 724 start = false;
717 } 725 }
718 } else { 726 } else {
719 while (i < Status.MemoryUsed) { 727 while (i < Status.MemoryUsed) {
720 Entry.Location = l; 728 Entry.Location = l;
721 error = Phone->GetMemory(&s, &Entry); 729 error = Phone->GetMemory(&s, &Entry);
722 if (error != ERR_EMPTY) { 730 if (error != ERR_EMPTY) {
723 Print_Error(error); 731 Print_Error(error);
724 i++; 732 i++;
725 SearchOneEntry(&Entry, Text); 733 SearchOneEntry(&Entry, Text);
726 } 734 }
727 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); 735 fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
728 l++; 736 l++;
729 } 737 }
730 } 738 }
731 fprintf(stderr,"\n"); 739 fprintf(stderr,"\n");
732 } 740 }
733} 741}
734 742
735static void SearchMemory(int argc, char *argv[]) 743static void SearchMemory(int argc, char *argv[])
736{ 744{
737 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2]; 745 unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1)*2];
738 int Length; 746 int Length;
739 747
740 signal(SIGINT, interrupt); 748 signal(SIGINT, interrupt);
741 printmsgerr("Press Ctrl+C to break...\n"); 749 printmsgerr("Press Ctrl+C to break...\n");
742 750
743 Length = strlen(argv[2]); 751 Length = strlen(argv[2]);
744 if (Length > GSM_PHONEBOOK_TEXT_LENGTH) { 752 if (Length > GSM_PHONEBOOK_TEXT_LENGTH) {
745 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH); 753 printmsg("Search text too long, truncating to %d chars!\n", GSM_PHONEBOOK_TEXT_LENGTH);
746 Length = GSM_PHONEBOOK_TEXT_LENGTH; 754 Length = GSM_PHONEBOOK_TEXT_LENGTH;
747 } 755 }
748 EncodeUnicode(Text, argv[2], Length); 756 EncodeUnicode(Text, argv[2], Length);
749 757
750 GSM_Init(true); 758 GSM_Init(true);
751 759
752 if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text); 760 if (!gshutdown) SearchOneMemory(MEM_ME, "Phone phonebook", Text);
753 if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text); 761 if (!gshutdown) SearchOneMemory(MEM_SM, "SIM phonebook", Text);
754 if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text); 762 if (!gshutdown) SearchOneMemory(MEM_ON, "Own numbers", Text);
755 if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text); 763 if (!gshutdown) SearchOneMemory(MEM_DC, "Dialled numbers", Text);
756 if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text); 764 if (!gshutdown) SearchOneMemory(MEM_RC, "Received numbers", Text);
757 if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text); 765 if (!gshutdown) SearchOneMemory(MEM_MC, "Missed numbers", Text);
758 if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text); 766 if (!gshutdown) SearchOneMemory(MEM_FD, "Fix dialling", Text);
759 if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text); 767 if (!gshutdown) SearchOneMemory(MEM_VM, "Voice mailbox", Text);
760 768
761 GSM_Terminate(); 769 GSM_Terminate();
762} 770}
763 771
764static void ListMemoryCategoryEntries(int Category) 772static void ListMemoryCategoryEntries(int Category)
765{ 773{
766 GSM_MemoryEntry Entry; 774 GSM_MemoryEntry Entry;
767 bool start = true; 775 bool start = true;
768 int j; 776 int j;
769 777
770 /* Category can be only for ME stored entries */ 778 /* Category can be only for ME stored entries */
771 Entry.MemoryType = MEM_ME; 779 Entry.MemoryType = MEM_ME;
772 780
773 while (!gshutdown) { 781 while (!gshutdown) {
774 error = Phone->GetNextMemory(&s, &Entry, start); 782 error = Phone->GetNextMemory(&s, &Entry, start);
775 if (error == ERR_EMPTY) break; 783 if (error == ERR_EMPTY) break;
776 Print_Error(error); 784 Print_Error(error);
777 for (j=0;j<Entry.EntriesNum;j++) { 785 for (j=0;j<Entry.EntriesNum;j++) {
778 if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) { 786 if (Entry.Entries[j].EntryType == PBK_Category && Entry.Entries[j].Number == Category) {
779 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location); 787 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry.MemoryType),Entry.Location);
780 PrintMemoryEntry(&Entry); 788 PrintMemoryEntry(&Entry);
781 } 789 }
782 } 790 }
783 start = false; 791 start = false;
784 } 792 }
785} 793}
786 794
787static void ListMemoryCategory(int argc, char *argv[]) 795static void ListMemoryCategory(int argc, char *argv[])
788{ 796{
789 GSM_Category Category; 797 GSM_Category Category;
790 GSM_CategoryStatusStatus; 798 GSM_CategoryStatusStatus;
791 int j, count; 799 int j, count;
792 800
793 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 801 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
794 int Length; 802 int Length;
795 bool Number = true;; 803 bool Number = true;;
796 804
797 GSM_Init(true); 805 GSM_Init(true);
798 806
799 signal(SIGINT, interrupt); 807 signal(SIGINT, interrupt);
800 printmsgerr("Press Ctrl+C to break...\n"); 808 printmsgerr("Press Ctrl+C to break...\n");
801 809
802 Length = strlen(argv[2]); 810 Length = strlen(argv[2]);
803 for (j = 0; j < Length; j++) { 811 for (j = 0; j < Length; j++) {
804 if (!isdigit(argv[2][j])) { 812 if (!isdigit(argv[2][j])) {
805 Number = false; 813 Number = false;
806 break; 814 break;
807 } 815 }
808 } 816 }
809 817
810 if (Number) { 818 if (Number) {
811 j = atoi(argv[2]); 819 j = atoi(argv[2]);
812 if (j > 0) { 820 if (j > 0) {
813 ListMemoryCategoryEntries(j); 821 ListMemoryCategoryEntries(j);
814 } 822 }
815 } else { 823 } else {
816 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 824 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
817 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 825 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
818 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 826 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
819 } 827 }
820 EncodeUnicode(Text, argv[2], Length); 828 EncodeUnicode(Text, argv[2], Length);
821 829
822 Category.Type = Category_Phonebook; 830 Category.Type = Category_Phonebook;
823 Status.Type = Category_Phonebook; 831 Status.Type = Category_Phonebook;
824 832
825 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 833 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
826 for (count=0,j=1;count<Status.Used;j++) { 834 for (count=0,j=1;count<Status.Used;j++) {
827 Category.Location=j; 835 Category.Location=j;
828 error=Phone->GetCategory(&s, &Category); 836 error=Phone->GetCategory(&s, &Category);
829 837
830 if (error != ERR_EMPTY) { 838 if (error != ERR_EMPTY) {
831 count++; 839 count++;
832 if (mywstrstr(Category.Name, Text) != NULL) { 840 if (mywstrstr(Category.Name, Text) != NULL) {
833 ListMemoryCategoryEntries(j); 841 ListMemoryCategoryEntries(j);
834 } 842 }
835 } 843 }
836 } 844 }
837 } 845 }
838 } 846 }
839 GSM_Terminate(); 847 GSM_Terminate();
840} 848}
841 849
842static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh) 850static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh)
843{ 851{
844 switch (sms.PDU) { 852 switch (sms.PDU) {
845 case SMS_Status_Report: 853 case SMS_Status_Report:
846 printmsg("SMS status report\n"); 854 printmsg("SMS status report\n");
847 printmsg("Status : "); 855 printmsg("Status : ");
848 switch (sms.State) { 856 switch (sms.State) {
849 case SMS_Sent : printmsg("Sent");break; 857 case SMS_Sent : printmsg("Sent");break;
850 case SMS_Read : printmsg("Read");break; 858 case SMS_Read : printmsg("Read");break;
851 case SMS_UnRead : printmsg("UnRead");break; 859 case SMS_UnRead : printmsg("UnRead");break;
852 case SMS_UnSent : printmsg("UnSent");break; 860 case SMS_UnSent : printmsg("UnSent");break;
853 } 861 }
854 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 862 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
855 printmsg("Reference number: %d\n",sms.MessageReference); 863 printmsg("Reference number: %d\n",sms.MessageReference);
856 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true)); 864 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
857 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number)); 865 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number));
858 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true)); 866 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true));
859 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text)); 867 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text));
860 printmsg("Details : "); 868 printmsg("Details : ");
861 if (sms.DeliveryStatus & 0x40) { 869 if (sms.DeliveryStatus & 0x40) {
862 if (sms.DeliveryStatus & 0x20) { 870 if (sms.DeliveryStatus & 0x20) {
863 printmsg("Temporary error, "); 871 printmsg("Temporary error, ");
864 } else { 872 } else {
865 printmsg("Permanent error, "); 873 printmsg("Permanent error, ");
866 } 874 }
867 } else if (sms.DeliveryStatus & 0x20) { 875 } else if (sms.DeliveryStatus & 0x20) {
868 printmsg("Temporary error, "); 876 printmsg("Temporary error, ");
869 } 877 }
870 switch (sms.DeliveryStatus) { 878 switch (sms.DeliveryStatus) {
871 case 0x00: printmsg("SM received by the SME"); break; 879 case 0x00: printmsg("SM received by the SME"); break;
872 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break; 880 case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
873 case 0x02: printmsg("SM replaced by the SC"); break; 881 case 0x02: printmsg("SM replaced by the SC"); break;
874 case 0x20: printmsg("Congestion"); break; 882 case 0x20: printmsg("Congestion"); break;
875 case 0x21: printmsg("SME busy"); break; 883 case 0x21: printmsg("SME busy"); break;
876 case 0x22: printmsg("No response from SME"); break; 884 case 0x22: printmsg("No response from SME"); break;
877 case 0x23: printmsg("Service rejected"); break; 885 case 0x23: printmsg("Service rejected"); break;
878 case 0x24: printmsg("Quality of service not aviable"); break; 886 case 0x24: printmsg("Quality of service not aviable"); break;
879 case 0x25: printmsg("Error in SME"); break; 887 case 0x25: printmsg("Error in SME"); break;
880 case 0x40: printmsg("Remote procedure error"); break; 888 case 0x40: printmsg("Remote procedure error"); break;
881 case 0x41: printmsg("Incompatibile destination"); break; 889 case 0x41: printmsg("Incompatibile destination"); break;
882 case 0x42: printmsg("Connection rejected by SME"); break; 890 case 0x42: printmsg("Connection rejected by SME"); break;
883 case 0x43: printmsg("Not obtainable"); break; 891 case 0x43: printmsg("Not obtainable"); break;
884 case 0x44: printmsg("Quality of service not available"); break; 892 case 0x44: printmsg("Quality of service not available"); break;
885 case 0x45: printmsg("No internetworking available"); break; 893 case 0x45: printmsg("No internetworking available"); break;
886 case 0x46: printmsg("SM Validity Period Expired"); break; 894 case 0x46: printmsg("SM Validity Period Expired"); break;
887 case 0x47: printmsg("SM deleted by originating SME"); break; 895 case 0x47: printmsg("SM deleted by originating SME"); break;
888 case 0x48: printmsg("SM Deleted by SC Administration"); break; 896 case 0x48: printmsg("SM Deleted by SC Administration"); break;
889 case 0x49: printmsg("SM does not exist"); break; 897 case 0x49: printmsg("SM does not exist"); break;
890 case 0x60: printmsg("Congestion"); break; 898 case 0x60: printmsg("Congestion"); break;
891 case 0x61: printmsg("SME busy"); break; 899 case 0x61: printmsg("SME busy"); break;
892 case 0x62: printmsg("No response from SME"); break; 900 case 0x62: printmsg("No response from SME"); break;
893 case 0x63: printmsg("Service rejected"); break; 901 case 0x63: printmsg("Service rejected"); break;
894 case 0x64: printmsg("Quality of service not available"); break; 902 case 0x64: printmsg("Quality of service not available"); break;
895 case 0x65: printmsg("Error in SME"); break; 903 case 0x65: printmsg("Error in SME"); break;
896 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break; 904 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break;
897 } 905 }
898 printf("\n"); 906 printf("\n");
899 break; 907 break;
900 case SMS_Deliver: 908 case SMS_Deliver:
901 printmsg("SMS message\n"); 909 printmsg("SMS message\n");
902 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) { 910 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
903 printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true)); 911 printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true));
904 } else { 912 } else {
905 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number)); 913 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
906 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)"); 914 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
907 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true)); 915 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
908 } 916 }
909 /* No break. The only difference for SMS_Deliver and SMS_Submit is, 917 /* No break. The only difference for SMS_Deliver and SMS_Submit is,
910 * that SMS_Deliver contains additional data. We wrote them and then go 918 * that SMS_Deliver contains additional data. We wrote them and then go
911 * for data shared with SMS_Submit 919 * for data shared with SMS_Submit
912 */ 920 */
913 case SMS_Submit: 921 case SMS_Submit:
914 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage); 922 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage);
915 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */ 923 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
916 if (sms.PDU==SMS_Submit) { 924 if (sms.PDU==SMS_Submit) {
917 printmsg("SMS message\n"); 925 printmsg("SMS message\n");
918 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) { 926 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
919 } else { 927 } else {
920 printmsg("Reference number : %d\n",sms.MessageReference); 928 printmsg("Reference number : %d\n",sms.MessageReference);
921 } 929 }
922 } 930 }
923 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) { 931 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) {
924 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name)); 932 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name));
925 } 933 }
926 if (sms.Class != -1) { 934 if (sms.Class != -1) {
927 printmsg("Class : %i\n",sms.Class); 935 printmsg("Class : %i\n",sms.Class);
928 } 936 }
929 printmsg("Coding : "); 937 printmsg("Coding : ");
930 switch (sms.Coding) { 938 switch (sms.Coding) {
931 case SMS_Coding_Unicode : printmsg("Unicode\n"); break; 939 case SMS_Coding_Unicode : printmsg("Unicode\n"); break;
932 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break; 940 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break;
933 case SMS_Coding_8bit : printmsg("8 bit\n"); break; 941 case SMS_Coding_8bit : printmsg("8 bit\n"); break;
934 } 942 }
935 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) { 943 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
936 } else { 944 } else {
937 printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 945 printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
938 } 946 }
939 printmsg("Status : "); 947 printmsg("Status : ");
940 switch (sms.State) { 948 switch (sms.State) {
941 case SMS_Sent : printmsg("Sent\n");break; 949 case SMS_Sent : printmsg("Sent\n");break;
942 case SMS_Read : printmsg("Read\n");break; 950 case SMS_Read : printmsg("Read\n");break;
943 case SMS_UnRead : printmsg("UnRead\n");break; 951 case SMS_UnRead : printmsg("UnRead\n");break;
944 case SMS_UnSent : printmsg("UnSent\n");break; 952 case SMS_UnSent : printmsg("UnSent\n");break;
945 } 953 }
946 if (sms.UDH.Type != UDH_NoUDH) { 954 if (sms.UDH.Type != UDH_NoUDH) {
947 printmsg("User Data Header : "); 955 printmsg("User Data Header : ");
948 switch (sms.UDH.Type) { 956 switch (sms.UDH.Type) {
949 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break; 957 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break;
950 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break; 958 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break;
951 case UDH_DisableVoice : printmsg("Disables voice indicator"); break; 959 case UDH_DisableVoice : printmsg("Disables voice indicator"); break;
952 case UDH_EnableVoice : printmsg("Enables voice indicator"); break; 960 case UDH_EnableVoice : printmsg("Enables voice indicator"); break;
953 case UDH_DisableFax : printmsg("Disables fax indicator"); break; 961 case UDH_DisableFax : printmsg("Disables fax indicator"); break;
954 case UDH_EnableFax : printmsg("Enables fax indicator"); break; 962 case UDH_EnableFax : printmsg("Enables fax indicator"); break;
955 case UDH_DisableEmail : printmsg("Disables email indicator"); break; 963 case UDH_DisableEmail : printmsg("Disables email indicator"); break;
956 case UDH_EnableEmail : printmsg("Enables email indicator"); break; 964 case UDH_EnableEmail : printmsg("Enables email indicator"); break;
957 case UDH_VoidSMS : printmsg("Void SMS"); break; 965 case UDH_VoidSMS : printmsg("Void SMS"); break;
958 case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break; 966 case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break;
959 case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break; 967 case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break;
960 case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break; 968 case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break;
961 case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break; 969 case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break;
962 case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break; 970 case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break;
963 case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break; 971 case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break;
964 case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break; 972 case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break;
965 case UDH_NokiaProfileLong : printmsg("Nokia profile"); break; 973 case UDH_NokiaProfileLong : printmsg("Nokia profile"); break;
966 case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break; 974 case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break;
967 case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break; 975 case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break;
968 case UDH_UserUDH : printmsg("User UDH"); break; 976 case UDH_UserUDH : printmsg("User UDH"); break;
969 case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break; 977 case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break;
970 case UDH_NoUDH: break; 978 case UDH_NoUDH: break;
971 } 979 }
972 if (sms.UDH.Type != UDH_NoUDH) { 980 if (sms.UDH.Type != UDH_NoUDH) {
973 if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit); 981 if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit);
974 if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit); 982 if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit);
975 if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) { 983 if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) {
976 if (displayudh) { 984 if (displayudh) {
977 printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts); 985 printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts);
978 } else { 986 } else {
979 printmsg(", %i parts",sms.UDH.AllParts); 987 printmsg(", %i parts",sms.UDH.AllParts);
980 } 988 }
981 } 989 }
982 } 990 }
983 printf("\n"); 991 printf("\n");
984 } 992 }
985 if (displaytext) { 993 if (displaytext) {
986 printf("\n"); 994 printf("\n");
987 if (sms.Coding!=SMS_Coding_8bit) { 995 if (sms.Coding!=SMS_Coding_8bit) {
988 printmsg("%s\n",DecodeUnicodeConsole(sms.Text)); 996 printmsg("%s\n",DecodeUnicodeConsole(sms.Text));
989 } else { 997 } else {
990 printmsg("8 bit SMS, cannot be displayed here\n"); 998 printmsg("8 bit SMS, cannot be displayed here\n");
991 } 999 }
992 } 1000 }
993 break; 1001 break;
994 } 1002 }
995} 1003}
996 1004
997static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems) 1005static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
998{ 1006{
999 GSM_MultiPartSMSInfoSMSInfo; 1007 GSM_MultiPartSMSInfoSMSInfo;
1000 bool RetVal,udhinfo=true; 1008 bool RetVal,udhinfo=true;
1001 int j; 1009 int j;
1002 1010
1003 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */ 1011 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
1004 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems); 1012 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems);
1005 1013
1006 if (eachsms) { 1014 if (eachsms) {
1007 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false; 1015 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false;
1008 if (RetVal && !udhinfo) { 1016 if (RetVal && !udhinfo) {
1009 displaysinglesmsinfo(sms.SMS[0],false,false); 1017 displaysinglesmsinfo(sms.SMS[0],false,false);
1010 printf("\n"); 1018 printf("\n");
1011 } else { 1019 } else {
1012 for (j=0;j<sms.Number;j++) { 1020 for (j=0;j<sms.Number;j++) {
1013 displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo); 1021 displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo);
1014 printf("\n"); 1022 printf("\n");
1015 } 1023 }
1016 } 1024 }
1017 } else { 1025 } else {
1018 for (j=0;j<sms.Number;j++) { 1026 for (j=0;j<sms.Number;j++) {
1019 displaysinglesmsinfo(sms.SMS[j],!RetVal,true); 1027 displaysinglesmsinfo(sms.SMS[j],!RetVal,true);
@@ -1242,1393 +1250,1398 @@ static void Monitor(int argc, char *argv[])
1242 break; 1250 break;
1243 default: 1251 default:
1244 printmsg("unknown"); 1252 printmsg("unknown");
1245 break; 1253 break;
1246 } 1254 }
1247 printf("\n"); 1255 printf("\n");
1248 } 1256 }
1249 } 1257 }
1250 if (gshutdown) break; 1258 if (gshutdown) break;
1251 if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) { 1259 if (Phone->GetSignalQuality(&s,&SignalQuality)==ERR_NONE) {
1252 if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength); 1260 if (SignalQuality.SignalStrength != -1) printmsg("Signal strength : %i dBm\n", SignalQuality.SignalStrength);
1253 if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent); 1261 if (SignalQuality.SignalPercent != -1) printmsg("Network level : %i percent\n", SignalQuality.SignalPercent);
1254 if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate); 1262 if (SignalQuality.BitErrorRate != -1) printmsg("Bit error rate : %i percent\n", SignalQuality.BitErrorRate);
1255 } 1263 }
1256 if (gshutdown) break; 1264 if (gshutdown) break;
1257 if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) { 1265 if (Phone->GetSMSStatus(&s,&SMSStatus)==ERR_NONE) {
1258 if (SMSStatus.SIMSize > 0) { 1266 if (SMSStatus.SIMSize > 0) {
1259 printmsg("SIM SMS status : %i used, %i unread, %i locations\n", 1267 printmsg("SIM SMS status : %i used, %i unread, %i locations\n",
1260 SMSStatus.SIMUsed, 1268 SMSStatus.SIMUsed,
1261 SMSStatus.SIMUnRead, 1269 SMSStatus.SIMUnRead,
1262 SMSStatus.SIMSize); 1270 SMSStatus.SIMSize);
1263 } 1271 }
1264 1272
1265 if (SMSStatus.PhoneSize > 0) { 1273 if (SMSStatus.PhoneSize > 0) {
1266 printmsg("Phone SMS status : %i used, %i unread, %i locations", 1274 printmsg("Phone SMS status : %i used, %i unread, %i locations",
1267 SMSStatus.PhoneUsed, 1275 SMSStatus.PhoneUsed,
1268 SMSStatus.PhoneUnRead, 1276 SMSStatus.PhoneUnRead,
1269 SMSStatus.PhoneSize); 1277 SMSStatus.PhoneSize);
1270 if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed); 1278 if (SMSStatus.TemplatesUsed!=0) printmsg(", %i templates", SMSStatus.TemplatesUsed);
1271 printf("\n"); 1279 printf("\n");
1272 } 1280 }
1273 } 1281 }
1274 if (gshutdown) break; 1282 if (gshutdown) break;
1275 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) { 1283 if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
1276 printmsg("Network state : "); 1284 printmsg("Network state : ");
1277 switch (NetInfo.State) { 1285 switch (NetInfo.State) {
1278 case GSM_HomeNetwork : printmsg("home network\n"); break; 1286 case GSM_HomeNetwork : printmsg("home network\n"); break;
1279 case GSM_RoamingNetwork : printmsg("roaming network\n"); break; 1287 case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
1280 case GSM_RequestingNetwork : printmsg("requesting network\n"); break; 1288 case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
1281 case GSM_NoNetwork : printmsg("not logged into network\n"); break; 1289 case GSM_NoNetwork : printmsg("not logged into network\n"); break;
1282 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break; 1290 case GSM_RegistrationDenied : printmsg("registration to network denied\n");break;
1283 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break; 1291 case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
1284 default : printmsg("unknown\n"); 1292 default : printmsg("unknown\n");
1285 } 1293 }
1286 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) { 1294 if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
1287 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode))); 1295 printmsg("Network : %s (%s",NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
1288 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode))); 1296 printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
1289 printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID); 1297 printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID);
1290 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) { 1298 if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
1291 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName)); 1299 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
1292 } 1300 }
1293 } 1301 }
1294 } 1302 }
1295 printf("\n"); 1303 printf("\n");
1296 } 1304 }
1297 1305
1298 printmsg("Leaving monitor mode...\n"); 1306 printmsg("Leaving monitor mode...\n");
1299 1307
1300 GSM_Terminate(); 1308 GSM_Terminate();
1301} 1309}
1302 1310
1303static void IncomingUSSD2(char *Device, char *Buffer) 1311static void IncomingUSSD2(char *Device, char *Buffer)
1304{ 1312{
1305 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer)); 1313 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
1306 1314
1307 gshutdown = true; 1315 gshutdown = true;
1308} 1316}
1309 1317
1310static void GetUSSD(int argc, char *argv[]) 1318static void GetUSSD(int argc, char *argv[])
1311{ 1319{
1312 GSM_Init(true); 1320 GSM_Init(true);
1313 1321
1314 signal(SIGINT, interrupt); 1322 signal(SIGINT, interrupt);
1315 printmsgerr("Press Ctrl+C to break...\n"); 1323 printmsgerr("Press Ctrl+C to break...\n");
1316 1324
1317 s.User.IncomingUSSD = IncomingUSSD2; 1325 s.User.IncomingUSSD = IncomingUSSD2;
1318 1326
1319 error=Phone->SetIncomingUSSD(&s,true); 1327 error=Phone->SetIncomingUSSD(&s,true);
1320 Print_Error(error); 1328 Print_Error(error);
1321 1329
1322 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence); 1330 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence);
1323 Print_Error(error); 1331 Print_Error(error);
1324 1332
1325 while (!gshutdown) GSM_ReadDevice(&s,true); 1333 while (!gshutdown) GSM_ReadDevice(&s,true);
1326 1334
1327 GSM_Terminate(); 1335 GSM_Terminate();
1328} 1336}
1329 1337
1330static void GetSMSC(int argc, char *argv[]) 1338static void GetSMSC(int argc, char *argv[])
1331{ 1339{
1332 GSM_SMSC smsc; 1340 GSM_SMSC smsc;
1333 int start, stop; 1341 int start, stop;
1334 1342
1335 GetStartStop(&start, &stop, 2, argc, argv); 1343 GetStartStop(&start, &stop, 2, argc, argv);
1336 1344
1337 GSM_Init(true); 1345 GSM_Init(true);
1338 1346
1339 for (i=start;i<=stop;i++) { 1347 for (i=start;i<=stop;i++) {
1340 smsc.Location=i; 1348 smsc.Location=i;
1341 1349
1342 error=Phone->GetSMSC(&s, &smsc); 1350 error=Phone->GetSMSC(&s, &smsc);
1343 Print_Error(error); 1351 Print_Error(error);
1344 1352
1345 if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) { 1353 if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) {
1346 printmsg("%i. Set %i\n",smsc.Location, smsc.Location); 1354 printmsg("%i. Set %i\n",smsc.Location, smsc.Location);
1347 } else { 1355 } else {
1348 printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name)); 1356 printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name));
1349 } 1357 }
1350 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number)); 1358 printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number));
1351 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber)); 1359 printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber));
1352 1360
1353 printmsg("Format : "); 1361 printmsg("Format : ");
1354 switch (smsc.Format) { 1362 switch (smsc.Format) {
1355 case SMS_FORMAT_Text : printmsg("Text");break; 1363 case SMS_FORMAT_Text : printmsg("Text");break;
1356 case SMS_FORMAT_Fax : printmsg("Fax");break; 1364 case SMS_FORMAT_Fax : printmsg("Fax");break;
1357 case SMS_FORMAT_Email : printmsg("Email");break; 1365 case SMS_FORMAT_Email : printmsg("Email");break;
1358 case SMS_FORMAT_Pager : printmsg("Pager");break; 1366 case SMS_FORMAT_Pager : printmsg("Pager");break;
1359 } 1367 }
1360 printf("\n"); 1368 printf("\n");
1361 1369
1362 printmsg("Validity : "); 1370 printmsg("Validity : ");
1363 switch (smsc.Validity.Relative) { 1371 switch (smsc.Validity.Relative) {
1364 case SMS_VALID_1_Hour : printmsg("1 hour"); break; 1372 case SMS_VALID_1_Hour : printmsg("1 hour"); break;
1365 case SMS_VALID_6_Hours : printmsg("6 hours"); break; 1373 case SMS_VALID_6_Hours : printmsg("6 hours"); break;
1366 case SMS_VALID_1_Day : printmsg("24 hours"); break; 1374 case SMS_VALID_1_Day : printmsg("24 hours"); break;
1367 case SMS_VALID_3_Days : printmsg("72 hours"); break; 1375 case SMS_VALID_3_Days : printmsg("72 hours"); break;
1368 case SMS_VALID_1_Week : printmsg("1 week"); break; 1376 case SMS_VALID_1_Week : printmsg("1 week"); break;
1369 case SMS_VALID_Max_Time: printmsg("Maximum time"); break; 1377 case SMS_VALID_Max_Time: printmsg("Maximum time"); break;
1370 default : 1378 default :
1371 if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) { 1379 if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) {
1372 printmsg("%i minutes",(smsc.Validity.Relative+1)*5); 1380 printmsg("%i minutes",(smsc.Validity.Relative+1)*5);
1373 } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) { 1381 } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) {
1374 printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30); 1382 printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30);
1375 } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) { 1383 } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) {
1376 printmsg("%i days",smsc.Validity.Relative-166); 1384 printmsg("%i days",smsc.Validity.Relative-166);
1377 } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) { 1385 } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) {
1378 printmsg("%i weeks",smsc.Validity.Relative-192); 1386 printmsg("%i weeks",smsc.Validity.Relative-192);
1379 } 1387 }
1380 } 1388 }
1381 printf("\n"); 1389 printf("\n");
1382 } 1390 }
1383 1391
1384 GSM_Terminate(); 1392 GSM_Terminate();
1385} 1393}
1386 1394
1387static void GetSMS(int argc, char *argv[]) 1395static void GetSMS(int argc, char *argv[])
1388{ 1396{
1389 GSM_MultiSMSMessagesms; 1397 GSM_MultiSMSMessagesms;
1390 GSM_SMSFolders folders; 1398 GSM_SMSFolders folders;
1391 int start, stop; 1399 int start, stop;
1392 int j; 1400 int j;
1393 1401
1394 GetStartStop(&start, &stop, 3, argc, argv); 1402 GetStartStop(&start, &stop, 3, argc, argv);
1395 1403
1396 GSM_Init(true); 1404 GSM_Init(true);
1397 1405
1398 error=Phone->GetSMSFolders(&s, &folders); 1406 error=Phone->GetSMSFolders(&s, &folders);
1399 Print_Error(error); 1407 Print_Error(error);
1400 1408
1401 for (j = start; j <= stop; j++) { 1409 for (j = start; j <= stop; j++) {
1402 sms.SMS[0].Folder= atoi(argv[2]); 1410 sms.SMS[0].Folder= atoi(argv[2]);
1403 sms.SMS[0].Location= j; 1411 sms.SMS[0].Location= j;
1404 error=Phone->GetSMS(&s, &sms); 1412 error=Phone->GetSMS(&s, &sms);
1405 switch (error) { 1413 switch (error) {
1406 case ERR_EMPTY: 1414 case ERR_EMPTY:
1407 printmsg("Location %i\n",sms.SMS[0].Location); 1415 printmsg("Location %i\n",sms.SMS[0].Location);
1408 printmsg("Empty\n"); 1416 printmsg("Empty\n");
1409 break; 1417 break;
1410 default: 1418 default:
1411 Print_Error(error); 1419 Print_Error(error);
1412 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1420 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1413 switch(sms.SMS[0].Memory) { 1421 switch(sms.SMS[0].Memory) {
1414 case MEM_SM: printmsg(", SIM memory"); break; 1422 case MEM_SM: printmsg(", SIM memory"); break;
1415 case MEM_ME: printmsg(", phone memory"); break; 1423 case MEM_ME: printmsg(", phone memory"); break;
1416 case MEM_MT: printmsg(", phone or SIM memory"); break; 1424 case MEM_MT: printmsg(", phone or SIM memory"); break;
1417 default : break; 1425 default : break;
1418 } 1426 }
1419 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1427 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1420 printf("\n"); 1428 printf("\n");
1421 displaymultismsinfo(sms,false,false); 1429 displaymultismsinfo(sms,false,false);
1422 } 1430 }
1423 } 1431 }
1424 1432
1425 GSM_Terminate(); 1433 GSM_Terminate();
1426} 1434}
1427 1435
1428static void DeleteSMS(int argc, char *argv[]) 1436static void DeleteSMS(int argc, char *argv[])
1429{ 1437{
1430 GSM_SMSMessagesms; 1438 GSM_SMSMessagesms;
1431 int start, stop; 1439 int start, stop;
1432 1440
1433 sms.Folder=atoi(argv[2]); 1441 sms.Folder=atoi(argv[2]);
1434 1442
1435 GetStartStop(&start, &stop, 3, argc, argv); 1443 GetStartStop(&start, &stop, 3, argc, argv);
1436 1444
1437 GSM_Init(true); 1445 GSM_Init(true);
1438 1446
1439 for (i=start;i<=stop;i++) { 1447 for (i=start;i<=stop;i++) {
1440 sms.Folder= 0; 1448 sms.Folder= 0;
1441 sms.Location= i; 1449 sms.Location= i;
1442 error=Phone->DeleteSMS(&s, &sms); 1450 error=Phone->DeleteSMS(&s, &sms);
1443 Print_Error(error); 1451 Print_Error(error);
1444 } 1452 }
1445#ifdef GSM_ENABLE_BEEP 1453#ifdef GSM_ENABLE_BEEP
1446 GSM_PhoneBeep(); 1454 GSM_PhoneBeep();
1447#endif 1455#endif
1448 GSM_Terminate(); 1456 GSM_Terminate();
1449} 1457}
1450 1458
1451static void GetAllSMS(int argc, char *argv[]) 1459static void GetAllSMS(int argc, char *argv[])
1452{ 1460{
1453 GSM_MultiSMSMessage sms; 1461 GSM_MultiSMSMessage sms;
1454 GSM_SMSFolders folders; 1462 GSM_SMSFolders folders;
1455 bool start = true; 1463 bool start = true;
1456 1464
1457 GSM_Init(true); 1465 GSM_Init(true);
1458 1466
1459 error=Phone->GetSMSFolders(&s, &folders); 1467 error=Phone->GetSMSFolders(&s, &folders);
1460 Print_Error(error); 1468 Print_Error(error);
1461 1469
1462 while (error == ERR_NONE) { 1470 while (error == ERR_NONE) {
1463 sms.SMS[0].Folder=0x00; 1471 sms.SMS[0].Folder=0x00;
1464 error=Phone->GetNextSMS(&s, &sms, start); 1472 error=Phone->GetNextSMS(&s, &sms, start);
1465 switch (error) { 1473 switch (error) {
1466 case ERR_EMPTY: 1474 case ERR_EMPTY:
1467 break; 1475 break;
1468 default: 1476 default:
1469 Print_Error(error); 1477 Print_Error(error);
1470 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1478 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1471 switch(sms.SMS[0].Memory) { 1479 switch(sms.SMS[0].Memory) {
1472 case MEM_SM: printmsg(", SIM memory"); break; 1480 case MEM_SM: printmsg(", SIM memory"); break;
1473 case MEM_ME: printmsg(", phone memory"); break; 1481 case MEM_ME: printmsg(", phone memory"); break;
1474 case MEM_MT: printmsg(", phone or SIM memory"); break; 1482 case MEM_MT: printmsg(", phone or SIM memory"); break;
1475 default : break; 1483 default : break;
1476 } 1484 }
1477 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1485 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1478 printf("\n"); 1486 printf("\n");
1479 displaymultismsinfo(sms,false,false); 1487 displaymultismsinfo(sms,false,false);
1480 } 1488 }
1481 start=false; 1489 start=false;
1482 } 1490 }
1483 fprintf(stderr,"\n"); 1491 fprintf(stderr,"\n");
1484 1492
1485#ifdef GSM_ENABLE_BEEP 1493#ifdef GSM_ENABLE_BEEP
1486 GSM_PhoneBeep(); 1494 GSM_PhoneBeep();
1487#endif 1495#endif
1488 GSM_Terminate(); 1496 GSM_Terminate();
1489} 1497}
1490 1498
1491static void GetEachSMS(int argc, char *argv[]) 1499static void GetEachSMS(int argc, char *argv[])
1492{ 1500{
1493 GSM_MultiSMSMessage*GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms; 1501 GSM_MultiSMSMessage*GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms;
1494 int GetSMSNumber = 0,i,j; 1502 int GetSMSNumber = 0,i,j;
1495 GSM_SMSFolders folders; 1503 GSM_SMSFolders folders;
1496 bool start = true, ems = true; 1504 bool start = true, ems = true;
1497 1505
1498 GetSMS[0] = NULL; 1506 GetSMS[0] = NULL;
1499 1507
1500 GSM_Init(true); 1508 GSM_Init(true);
1501 1509
1502 error=Phone->GetSMSFolders(&s, &folders); 1510 error=Phone->GetSMSFolders(&s, &folders);
1503 Print_Error(error); 1511 Print_Error(error);
1504 1512
1505 fprintf(stderr,"Reading: "); 1513 fprintf(stderr,"Reading: ");
1506 while (error == ERR_NONE) { 1514 while (error == ERR_NONE) {
1507 sms.SMS[0].Folder=0x00; 1515 sms.SMS[0].Folder=0x00;
1508 error=Phone->GetNextSMS(&s, &sms, start); 1516 error=Phone->GetNextSMS(&s, &sms, start);
1509 switch (error) { 1517 switch (error) {
1510 case ERR_EMPTY: 1518 case ERR_EMPTY:
1511 break; 1519 break;
1512 default: 1520 default:
1513 Print_Error(error); 1521 Print_Error(error);
1514 GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage)); 1522 GetSMS[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage));
1515 if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY); 1523 if (GetSMS[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY);
1516 GetSMS[GetSMSNumber+1] = NULL; 1524 GetSMS[GetSMSNumber+1] = NULL;
1517 memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage)); 1525 memcpy(GetSMS[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage));
1518 GetSMSNumber++; 1526 GetSMSNumber++;
1519 if (GetSMSNumber==PHONE_MAXSMSINFOLDER) { 1527 if (GetSMSNumber==PHONE_MAXSMSINFOLDER) {
1520 fprintf(stderr,"SMS counter overflow\n"); 1528 fprintf(stderr,"SMS counter overflow\n");
1521 return; 1529 return;
1522 } 1530 }
1523 } 1531 }
1524 fprintf(stderr,"*"); 1532 fprintf(stderr,"*");
1525 start=false; 1533 start=false;
1526 } 1534 }
1527 fprintf(stderr,"\n"); 1535 fprintf(stderr,"\n");
1528 1536
1529#ifdef GSM_ENABLE_BEEP 1537#ifdef GSM_ENABLE_BEEP
1530 GSM_PhoneBeep(); 1538 GSM_PhoneBeep();
1531#endif 1539#endif
1532 1540
1533 error = GSM_LinkSMS(GetSMS, SortedSMS, ems); 1541 error = GSM_LinkSMS(GetSMS, SortedSMS, ems);
1534 Print_Error(error); 1542 Print_Error(error);
1535 1543
1536 i=0; 1544 i=0;
1537 while(GetSMS[i] != NULL) { 1545 while(GetSMS[i] != NULL) {
1538 free(GetSMS[i]); 1546 free(GetSMS[i]);
1539 GetSMS[i] = NULL; 1547 GetSMS[i] = NULL;
1540 i++; 1548 i++;
1541 } 1549 }
1542 1550
1543 i=0; 1551 i=0;
1544 while(SortedSMS[i] != NULL) { 1552 while(SortedSMS[i] != NULL) {
1545 for (j=0;j<SortedSMS[i]->Number;j++) { 1553 for (j=0;j<SortedSMS[i]->Number;j++) {
1546 if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) { 1554 if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) {
1547 printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name)); 1555 printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name));
1548 switch(SortedSMS[i]->SMS[j].Memory) { 1556 switch(SortedSMS[i]->SMS[j].Memory) {
1549 case MEM_SM: printmsg(", SIM memory"); break; 1557 case MEM_SM: printmsg(", SIM memory"); break;
1550 case MEM_ME: printmsg(", phone memory"); break; 1558 case MEM_ME: printmsg(", phone memory"); break;
1551 case MEM_MT: printmsg(", phone or SIM memory"); break; 1559 case MEM_MT: printmsg(", phone or SIM memory"); break;
1552 default : break; 1560 default : break;
1553 } 1561 }
1554 if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder"); 1562 if (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder");
1555 printf("\n"); 1563 printf("\n");
1556 } 1564 }
1557 } 1565 }
1558 displaymultismsinfo(*SortedSMS[i],true,ems); 1566 displaymultismsinfo(*SortedSMS[i],true,ems);
1559 1567
1560 free(SortedSMS[i]); 1568 free(SortedSMS[i]);
1561 SortedSMS[i] = NULL; 1569 SortedSMS[i] = NULL;
1562 i++; 1570 i++;
1563 } 1571 }
1564 1572
1565 GSM_Terminate(); 1573 GSM_Terminate();
1566} 1574}
1567 1575
1568static void GetSMSFolders(int argc, char *argv[]) 1576static void GetSMSFolders(int argc, char *argv[])
1569{ 1577{
1570 GSM_SMSFolders folders; 1578 GSM_SMSFolders folders;
1571 1579
1572 GSM_Init(true); 1580 GSM_Init(true);
1573 1581
1574 error=Phone->GetSMSFolders(&s,&folders); 1582 error=Phone->GetSMSFolders(&s,&folders);
1575 Print_Error(error); 1583 Print_Error(error);
1576 1584
1577 for (i=0;i<folders.Number;i++) { 1585 for (i=0;i<folders.Number;i++) {
1578 printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name)); 1586 printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name));
1579 switch(folders.Folder[i].Memory) { 1587 switch(folders.Folder[i].Memory) {
1580 case MEM_SM: printmsg(", SIM memory"); break; 1588 case MEM_SM: printmsg(", SIM memory"); break;
1581 case MEM_ME: printmsg(", phone memory"); break; 1589 case MEM_ME: printmsg(", phone memory"); break;
1582 case MEM_MT: printmsg(", phone or SIM memory"); break; 1590 case MEM_MT: printmsg(", phone or SIM memory"); break;
1583 default : break; 1591 default : break;
1584 } 1592 }
1585 if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder"); 1593 if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder");
1586 printf("\n"); 1594 printf("\n");
1587 } 1595 }
1588 1596
1589 GSM_Terminate(); 1597 GSM_Terminate();
1590} 1598}
1591 1599
1592static void GetRingtone(int argc, char *argv[]) 1600static void GetRingtone(int argc, char *argv[])
1593{ 1601{
1594 GSM_Ringtone ringtone; 1602 GSM_Ringtone ringtone;
1595 bool PhoneRingtone = false; 1603 bool PhoneRingtone = false;
1596 1604
1597 if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true; 1605 if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true;
1598 1606
1599 GetStartStop(&ringtone.Location, NULL, 2, argc, argv); 1607 GetStartStop(&ringtone.Location, NULL, 2, argc, argv);
1600 1608
1601 GSM_Init(true); 1609 GSM_Init(true);
1602 1610
1603 ringtone.Format=0; 1611 ringtone.Format=0;
1604 1612
1605 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone); 1613 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone);
1606 Print_Error(error); 1614 Print_Error(error);
1607 1615
1608 switch (ringtone.Format) { 1616 switch (ringtone.Format) {
1609 case RING_NOTETONE : printmsg("Smart Messaging");break; 1617 case RING_NOTETONE : printmsg("Smart Messaging");break;
1610 case RING_NOKIABINARY : printmsg("Nokia binary");break; 1618 case RING_NOKIABINARY : printmsg("Nokia binary");break;
1611 case RING_MIDI : printmsg("MIDI"); break; 1619 case RING_MIDI : printmsg("MIDI"); break;
1612 case RING_MMF : printmsg("SMAF (MMF)");break; 1620 case RING_MMF : printmsg("SMAF (MMF)");break;
1613 } 1621 }
1614 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name)); 1622 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name));
1615 1623
1616 if (argc==4) { 1624 if (argc==4) {
1617 error=GSM_SaveRingtoneFile(argv[3], &ringtone); 1625 error=GSM_SaveRingtoneFile(argv[3], &ringtone);
1618 Print_Error(error); 1626 Print_Error(error);
1619 } 1627 }
1620 1628
1621 GSM_Terminate(); 1629 GSM_Terminate();
1622} 1630}
1623 1631
1624static void GetRingtonesList(int argc, char *argv[]) 1632static void GetRingtonesList(int argc, char *argv[])
1625{ 1633{
1626 GSM_AllRingtonesInfo Info; 1634 GSM_AllRingtonesInfo Info = {0, NULL};
1627 int i; 1635 int i;
1628 1636
1629 GSM_Init(true); 1637 GSM_Init(true);
1630 1638
1631 error=Phone->GetRingtonesInfo(&s,&Info); 1639 error=Phone->GetRingtonesInfo(&s,&Info);
1640 if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone);
1632 Print_Error(error); 1641 Print_Error(error);
1633 1642
1634 GSM_Terminate(); 1643 GSM_Terminate();
1635 1644
1636 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); 1645 for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
1646
1647 if (Info.Ringtone) free(Info.Ringtone);
1637} 1648}
1638 1649
1639static void DialVoice(int argc, char *argv[]) 1650static void DialVoice(int argc, char *argv[])
1640{ 1651{
1641 GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence; 1652 GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence;
1642 1653
1643 if (argc > 3) { 1654 if (argc > 3) {
1644 if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber; 1655 if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber;
1645 } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber; 1656 } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber;
1646 } else { 1657 } else {
1647 printmsg("Unknown parameter (\"%s\")\n",argv[3]); 1658 printmsg("Unknown parameter (\"%s\")\n",argv[3]);
1648 exit(-1); 1659 exit(-1);
1649 } 1660 }
1650 } 1661 }
1651 1662
1652 GSM_Init(true); 1663 GSM_Init(true);
1653 1664
1654 error=Phone->DialVoice(&s, argv[2], ShowNumber); 1665 error=Phone->DialVoice(&s, argv[2], ShowNumber);
1655 Print_Error(error); 1666 Print_Error(error);
1656 1667
1657 GSM_Terminate(); 1668 GSM_Terminate();
1658} 1669}
1659 1670
1660static void CancelCall(int argc, char *argv[]) 1671static void CancelCall(int argc, char *argv[])
1661{ 1672{
1662 GSM_Init(true); 1673 GSM_Init(true);
1663 1674
1664 if (argc>2) { 1675 if (argc>2) {
1665 error=Phone->CancelCall(&s,atoi(argv[2]),false); 1676 error=Phone->CancelCall(&s,atoi(argv[2]),false);
1666 } else { 1677 } else {
1667 error=Phone->CancelCall(&s,0,true); 1678 error=Phone->CancelCall(&s,0,true);
1668 } 1679 }
1669 Print_Error(error); 1680 Print_Error(error);
1670 1681
1671 GSM_Terminate(); 1682 GSM_Terminate();
1672} 1683}
1673 1684
1674static void AnswerCall(int argc, char *argv[]) 1685static void AnswerCall(int argc, char *argv[])
1675{ 1686{
1676 GSM_Init(true); 1687 GSM_Init(true);
1677 1688
1678 if (argc>2) { 1689 if (argc>2) {
1679 error=Phone->AnswerCall(&s,atoi(argv[2]),false); 1690 error=Phone->AnswerCall(&s,atoi(argv[2]),false);
1680 } else { 1691 } else {
1681 error=Phone->AnswerCall(&s,0,true); 1692 error=Phone->AnswerCall(&s,0,true);
1682 } 1693 }
1683 Print_Error(error); 1694 Print_Error(error);
1684 1695
1685 GSM_Terminate(); 1696 GSM_Terminate();
1686} 1697}
1687 1698
1688static void UnholdCall(int argc, char *argv[]) 1699static void UnholdCall(int argc, char *argv[])
1689{ 1700{
1690 GSM_Init(true); 1701 GSM_Init(true);
1691 1702
1692 error=Phone->UnholdCall(&s,atoi(argv[2])); 1703 error=Phone->UnholdCall(&s,atoi(argv[2]));
1693 Print_Error(error); 1704 Print_Error(error);
1694 1705
1695 GSM_Terminate(); 1706 GSM_Terminate();
1696} 1707}
1697 1708
1698static void HoldCall(int argc, char *argv[]) 1709static void HoldCall(int argc, char *argv[])
1699{ 1710{
1700 GSM_Init(true); 1711 GSM_Init(true);
1701 1712
1702 error=Phone->HoldCall(&s,atoi(argv[2])); 1713 error=Phone->HoldCall(&s,atoi(argv[2]));
1703 Print_Error(error); 1714 Print_Error(error);
1704 1715
1705 GSM_Terminate(); 1716 GSM_Terminate();
1706} 1717}
1707 1718
1708static void ConferenceCall(int argc, char *argv[]) 1719static void ConferenceCall(int argc, char *argv[])
1709{ 1720{
1710 GSM_Init(true); 1721 GSM_Init(true);
1711 1722
1712 error=Phone->ConferenceCall(&s,atoi(argv[2])); 1723 error=Phone->ConferenceCall(&s,atoi(argv[2]));
1713 Print_Error(error); 1724 Print_Error(error);
1714 1725
1715 GSM_Terminate(); 1726 GSM_Terminate();
1716} 1727}
1717 1728
1718static void SplitCall(int argc, char *argv[]) 1729static void SplitCall(int argc, char *argv[])
1719{ 1730{
1720 GSM_Init(true); 1731 GSM_Init(true);
1721 1732
1722 error=Phone->SplitCall(&s,atoi(argv[2])); 1733 error=Phone->SplitCall(&s,atoi(argv[2]));
1723 Print_Error(error); 1734 Print_Error(error);
1724 1735
1725 GSM_Terminate(); 1736 GSM_Terminate();
1726} 1737}
1727 1738
1728static void SwitchCall(int argc, char *argv[]) 1739static void SwitchCall(int argc, char *argv[])
1729{ 1740{
1730 GSM_Init(true); 1741 GSM_Init(true);
1731 1742
1732 if (argc > 2) { 1743 if (argc > 2) {
1733 error=Phone->SwitchCall(&s,atoi(argv[2]),false); 1744 error=Phone->SwitchCall(&s,atoi(argv[2]),false);
1734 } else { 1745 } else {
1735 error=Phone->SwitchCall(&s,0,true); 1746 error=Phone->SwitchCall(&s,0,true);
1736 } 1747 }
1737 Print_Error(error); 1748 Print_Error(error);
1738 1749
1739 GSM_Terminate(); 1750 GSM_Terminate();
1740} 1751}
1741 1752
1742static void TransferCall(int argc, char *argv[]) 1753static void TransferCall(int argc, char *argv[])
1743{ 1754{
1744 GSM_Init(true); 1755 GSM_Init(true);
1745 1756
1746 if (argc > 2) { 1757 if (argc > 2) {
1747 error=Phone->TransferCall(&s,atoi(argv[2]),false); 1758 error=Phone->TransferCall(&s,atoi(argv[2]),false);
1748 } else { 1759 } else {
1749 error=Phone->TransferCall(&s,0,true); 1760 error=Phone->TransferCall(&s,0,true);
1750 } 1761 }
1751 Print_Error(error); 1762 Print_Error(error);
1752 1763
1753 GSM_Terminate(); 1764 GSM_Terminate();
1754} 1765}
1755 1766
1756static void AddSMSFolder(int argc, char *argv[]) 1767static void AddSMSFolder(int argc, char *argv[])
1757{ 1768{
1758 unsigned char buffer[200]; 1769 unsigned char buffer[200];
1759 1770
1760 GSM_Init(true); 1771 GSM_Init(true);
1761 1772
1762 EncodeUnicode(buffer,argv[2],strlen(argv[2])); 1773 EncodeUnicode(buffer,argv[2],strlen(argv[2]));
1763 error=Phone->AddSMSFolder(&s,buffer); 1774 error=Phone->AddSMSFolder(&s,buffer);
1764 Print_Error(error); 1775 Print_Error(error);
1765 1776
1766 GSM_Terminate(); 1777 GSM_Terminate();
1767} 1778}
1768 1779
1769static void Reset(int argc, char *argv[]) 1780static void Reset(int argc, char *argv[])
1770{ 1781{
1771 bool hard; 1782 bool hard;
1772 1783
1773 if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false; 1784 if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false;
1774 } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true; 1785 } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true;
1775 } else { 1786 } else {
1776 printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]); 1787 printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]);
1777 exit(-1); 1788 exit(-1);
1778 } 1789 }
1779 1790
1780 GSM_Init(true); 1791 GSM_Init(true);
1781 1792
1782 error=Phone->Reset(&s, hard); 1793 error=Phone->Reset(&s, hard);
1783 Print_Error(error); 1794 Print_Error(error);
1784 1795
1785 GSM_Terminate(); 1796 GSM_Terminate();
1786} 1797}
1787 1798
1788static void PrintCalendar(GSM_CalendarEntry *Note) 1799static void PrintCalendar(GSM_CalendarEntry *Note)
1789{ 1800{
1790 int i_age = 0,i; 1801 int i_age = 0,i;
1791 GSM_DateTime Alarm,DateTime; 1802 GSM_DateTime Alarm,DateTime;
1792 GSM_MemoryEntry entry; 1803 GSM_MemoryEntry entry;
1793 unsigned char *name; 1804 unsigned char *name;
1794 1805
1795 bool repeating = false; 1806 bool repeating = false;
1796 int repeat_dayofweek = -1; 1807 int repeat_dayofweek = -1;
1797 int repeat_day = -1; 1808 int repeat_day = -1;
1798 int repeat_weekofmonth = -1; 1809 int repeat_weekofmonth = -1;
1799 int repeat_month = -1; 1810 int repeat_month = -1;
1800 int repeat_frequency = -1; 1811 int repeat_frequency = -1;
1801 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 1812 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1802 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 1813 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1803 1814
1804 printmsg("Location : %d\n", Note->Location); 1815 printmsg("Location : %d\n", Note->Location);
1805 printmsg("Note type : "); 1816 printmsg("Note type : ");
1806 switch (Note->Type) { 1817 switch (Note->Type) {
1807 case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break; 1818 case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break;
1808 case GSM_CAL_CALL : printmsg("Call\n"); break; 1819 case GSM_CAL_CALL : printmsg("Call\n"); break;
1809 case GSM_CAL_MEETING : printmsg("Meeting\n"); break; 1820 case GSM_CAL_MEETING : printmsg("Meeting\n"); break;
1810 case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break; 1821 case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break;
1811 case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break; 1822 case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break;
1812 case GSM_CAL_TRAVEL : printmsg("Travel\n"); break; 1823 case GSM_CAL_TRAVEL : printmsg("Travel\n"); break;
1813 case GSM_CAL_VACATION : printmsg("Vacation\n"); break; 1824 case GSM_CAL_VACATION : printmsg("Vacation\n"); break;
1814 case GSM_CAL_ALARM : printmsg("Alarm\n"); break; 1825 case GSM_CAL_ALARM : printmsg("Alarm\n"); break;
1815 case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break; 1826 case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break;
1816 case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break; 1827 case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break;
1817 case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break; 1828 case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break;
1818 case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break; 1829 case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break;
1819 case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break; 1830 case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break;
1820 case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break; 1831 case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break;
1821 case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break; 1832 case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break;
1822 case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break; 1833 case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break;
1823 case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break; 1834 case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break;
1824 case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break; 1835 case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break;
1825 case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break; 1836 case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break;
1826 case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break; 1837 case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break;
1827 case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break; 1838 case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break;
1828 case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break; 1839 case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break;
1829 case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break; 1840 case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break;
1830 case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break; 1841 case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break;
1831 case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break; 1842 case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break;
1832 case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break; 1843 case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break;
1833 case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break; 1844 case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break;
1834 case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break; 1845 case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break;
1835 default : printmsg("UNKNOWN\n"); 1846 default : printmsg("UNKNOWN\n");
1836 } 1847 }
1837 Alarm.Year = 0; 1848 Alarm.Year = 0;
1838 1849
1839 repeating = false; 1850 repeating = false;
1840 repeat_dayofweek = -1; 1851 repeat_dayofweek = -1;
1841 repeat_day = -1; 1852 repeat_day = -1;
1842 repeat_weekofmonth = -1; 1853 repeat_weekofmonth = -1;
1843 repeat_month = -1; 1854 repeat_month = -1;
1844 repeat_frequency = -1; 1855 repeat_frequency = -1;
1845 repeat_startdate.Day= 0; 1856 repeat_startdate.Day= 0;
1846 repeat_stopdate.Day = 0; 1857 repeat_stopdate.Day = 0;
1847 1858
1848 for (i=0;i<Note->EntriesNum;i++) { 1859 for (i=0;i<Note->EntriesNum;i++) {
1849 switch (Note->Entries[i].EntryType) { 1860 switch (Note->Entries[i].EntryType) {
1850 case CAL_START_DATETIME: 1861 case CAL_START_DATETIME:
1851 printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1862 printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1852 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1863 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1853 break; 1864 break;
1854 case CAL_END_DATETIME: 1865 case CAL_END_DATETIME:
1855 printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1866 printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1856 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1867 memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1857 break; 1868 break;
1858 case CAL_ALARM_DATETIME: 1869 case CAL_ALARM_DATETIME:
1859 printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1870 printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1860 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1871 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1861 break; 1872 break;
1862 case CAL_SILENT_ALARM_DATETIME: 1873 case CAL_SILENT_ALARM_DATETIME:
1863 printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); 1874 printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1864 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); 1875 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1865 break; 1876 break;
1866 case CAL_RECURRANCE: 1877 case CAL_RECURRANCE:
1867 printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24, 1878 printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,
1868 ((Note->Entries[i].Number/24)>1) ? "s":"" ); 1879 ((Note->Entries[i].Number/24)>1) ? "s":"" );
1869 break; 1880 break;
1870 case CAL_TEXT: 1881 case CAL_TEXT:
1871 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1882 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1872 break; 1883 break;
1873 case CAL_LOCATION: 1884 case CAL_LOCATION:
1874 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1885 printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1875 break; 1886 break;
1876 case CAL_PHONE: 1887 case CAL_PHONE:
1877 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 1888 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1878 break; 1889 break;
1879 case CAL_PRIVATE: 1890 case CAL_PRIVATE:
1880 printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); 1891 printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1881 break; 1892 break;
1882 case CAL_CONTACTID: 1893 case CAL_CONTACTID:
1883 entry.Location = Note->Entries[i].Number; 1894 entry.Location = Note->Entries[i].Number;
1884 entry.MemoryType = MEM_ME; 1895 entry.MemoryType = MEM_ME;
1885 error=Phone->GetMemory(&s, &entry); 1896 error=Phone->GetMemory(&s, &entry);
1886 if (error == ERR_NONE) { 1897 if (error == ERR_NONE) {
1887 name = GSM_PhonebookGetEntryName(&entry); 1898 name = GSM_PhonebookGetEntryName(&entry);
1888 if (name != NULL) { 1899 if (name != NULL) {
1889 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 1900 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1890 } else { 1901 } else {
1891 printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1902 printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1892 } 1903 }
1893 } else { 1904 } else {
1894 printmsg("Contact ID : %d\n",Note->Entries[i].Number); 1905 printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1895 } 1906 }
1896 break; 1907 break;
1897 case CAL_REPEAT_DAYOFWEEK: 1908 case CAL_REPEAT_DAYOFWEEK:
1898 repeat_dayofweek = Note->Entries[i].Number; 1909 repeat_dayofweek = Note->Entries[i].Number;
1899 repeating = true; 1910 repeating = true;
1900 break; 1911 break;
1901 case CAL_REPEAT_DAY: 1912 case CAL_REPEAT_DAY:
1902 repeat_day = Note->Entries[i].Number; 1913 repeat_day = Note->Entries[i].Number;
1903 repeating = true; 1914 repeating = true;
1904 break; 1915 break;
1905 case CAL_REPEAT_WEEKOFMONTH: 1916 case CAL_REPEAT_WEEKOFMONTH:
1906 repeat_weekofmonth = Note->Entries[i].Number; 1917 repeat_weekofmonth = Note->Entries[i].Number;
1907 repeating = true; 1918 repeating = true;
1908 break; 1919 break;
1909 case CAL_REPEAT_MONTH: 1920 case CAL_REPEAT_MONTH:
1910 repeat_month = Note->Entries[i].Number; 1921 repeat_month = Note->Entries[i].Number;
1911 repeating = true; 1922 repeating = true;
1912 break; 1923 break;
1913 case CAL_REPEAT_FREQUENCY: 1924 case CAL_REPEAT_FREQUENCY:
1914 repeat_frequency = Note->Entries[i].Number; 1925 repeat_frequency = Note->Entries[i].Number;
1915 repeating = true; 1926 repeating = true;
1916 break; 1927 break;
1917 case CAL_REPEAT_STARTDATE: 1928 case CAL_REPEAT_STARTDATE:
1918 repeat_startdate = Note->Entries[i].Date; 1929 repeat_startdate = Note->Entries[i].Date;
1919 repeating = true; 1930 repeating = true;
1920 break; 1931 break;
1921 case CAL_REPEAT_STOPDATE: 1932 case CAL_REPEAT_STOPDATE:
1922 repeat_stopdate = Note->Entries[i].Date; 1933 repeat_stopdate = Note->Entries[i].Date;
1923 repeating = true; 1934 repeating = true;
1924 break; 1935 break;
1925 } 1936 }
1926 } 1937 }
1927 if (repeating) { 1938 if (repeating) {
1928 printmsg("Repeating : "); 1939 printmsg("Repeating : ");
1929 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) { 1940 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) {
1930 printmsg("Forever"); 1941 printmsg("Forever");
1931 } else if (repeat_startdate.Day == 0) { 1942 } else if (repeat_startdate.Day == 0) {
1932 printmsg("Till %s", OSDate(repeat_stopdate)); 1943 printmsg("Till %s", OSDate(repeat_stopdate));
1933 } else if (repeat_stopdate.Day == 0) { 1944 } else if (repeat_stopdate.Day == 0) {
1934 printmsg("Since %s", OSDate(repeat_startdate)); 1945 printmsg("Since %s", OSDate(repeat_startdate));
1935 } else { 1946 } else {
1936 printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate)); 1947 printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate));
1937 } 1948 }
1938 if (repeat_frequency != -1) { 1949 if (repeat_frequency != -1) {
1939 if (repeat_frequency == 1) { 1950 if (repeat_frequency == 1) {
1940 printmsg (" on each "); 1951 printmsg (" on each ");
1941 } else { 1952 } else {
1942 printmsg(" on each %d. ", repeat_frequency); 1953 printmsg(" on each %d. ", repeat_frequency);
1943 } 1954 }
1944 if (repeat_dayofweek > 0) { 1955 if (repeat_dayofweek > 0) {
1945 switch (repeat_dayofweek) { 1956 switch (repeat_dayofweek) {
1946 case 1 : printmsg("Monday"); break; 1957 case 1 : printmsg("Monday"); break;
1947 case 2 : printmsg("Tuesday"); break; 1958 case 2 : printmsg("Tuesday"); break;
1948 case 3 : printmsg("Wednesday"); break; 1959 case 3 : printmsg("Wednesday"); break;
1949 case 4 : printmsg("Thursday"); break; 1960 case 4 : printmsg("Thursday"); break;
1950 case 5 : printmsg("Friday"); break; 1961 case 5 : printmsg("Friday"); break;
1951 case 6 : printmsg("Saturday"); break; 1962 case 6 : printmsg("Saturday"); break;
1952 case 7 : printmsg("Sunday"); break; 1963 case 7 : printmsg("Sunday"); break;
1953 default: printmsg("Bad day!"); break; 1964 default: printmsg("Bad day!"); break;
1954 } 1965 }
1955 if (repeat_weekofmonth > 0) { 1966 if (repeat_weekofmonth > 0) {
1956 printmsg(" in %d. week of ", repeat_weekofmonth); 1967 printmsg(" in %d. week of ", repeat_weekofmonth);
1957 } else { 1968 } else {
1958 printmsg(" in "); 1969 printmsg(" in ");
1959 } 1970 }
1960 if (repeat_month > 0) { 1971 if (repeat_month > 0) {
1961 switch(repeat_month) { 1972 switch(repeat_month) {
1962 case 1 : printmsg("January"); break; 1973 case 1 : printmsg("January"); break;
1963 case 2 : printmsg("February"); break; 1974 case 2 : printmsg("February"); break;
1964 case 3 : printmsg("March"); break; 1975 case 3 : printmsg("March"); break;
1965 case 4 : printmsg("April"); break; 1976 case 4 : printmsg("April"); break;
1966 case 5 : printmsg("May"); break; 1977 case 5 : printmsg("May"); break;
1967 case 6 : printmsg("June"); break; 1978 case 6 : printmsg("June"); break;
1968 case 7 : printmsg("July"); break; 1979 case 7 : printmsg("July"); break;
1969 case 8 : printmsg("August"); break; 1980 case 8 : printmsg("August"); break;
1970 case 9 : printmsg("September"); break; 1981 case 9 : printmsg("September"); break;
1971 case 10: printmsg("October"); break; 1982 case 10: printmsg("October"); break;
1972 case 11: printmsg("November"); break; 1983 case 11: printmsg("November"); break;
1973 case 12: printmsg("December"); break; 1984 case 12: printmsg("December"); break;
1974 default: printmsg("Bad month!"); break; 1985 default: printmsg("Bad month!"); break;
1975 } 1986 }
1976 } else { 1987 } else {
1977 printmsg("each month"); 1988 printmsg("each month");
1978 } 1989 }
1979 } else if (repeat_day > 0) { 1990 } else if (repeat_day > 0) {
1980 printmsg("%d. day of ", repeat_day); 1991 printmsg("%d. day of ", repeat_day);
1981 if (repeat_month > 0) { 1992 if (repeat_month > 0) {
1982 switch(repeat_month) { 1993 switch(repeat_month) {
1983 case 1 : printmsg("January"); break; 1994 case 1 : printmsg("January"); break;
1984 case 2 : printmsg("February"); break; 1995 case 2 : printmsg("February"); break;
1985 case 3 : printmsg("March");break; 1996 case 3 : printmsg("March");break;
1986 case 4 : printmsg("April"); break; 1997 case 4 : printmsg("April"); break;
1987 case 5 : printmsg("May"); break; 1998 case 5 : printmsg("May"); break;
1988 case 6 : printmsg("June"); break; 1999 case 6 : printmsg("June"); break;
1989 case 7 : printmsg("July"); break; 2000 case 7 : printmsg("July"); break;
1990 case 8 : printmsg("August"); break; 2001 case 8 : printmsg("August"); break;
1991 case 9 : printmsg("September"); break; 2002 case 9 : printmsg("September"); break;
1992 case 10: printmsg("October"); break; 2003 case 10: printmsg("October"); break;
1993 case 11: printmsg("November"); break; 2004 case 11: printmsg("November"); break;
1994 case 12: printmsg("December"); break; 2005 case 12: printmsg("December"); break;
1995 default: printmsg("Bad month!");break; 2006 default: printmsg("Bad month!");break;
1996 } 2007 }
1997 } else { 2008 } else {
1998 printmsg("each month"); 2009 printmsg("each month");
1999 } 2010 }
2000 } else { 2011 } else {
2001 printmsg("day"); 2012 printmsg("day");
2002 } 2013 }
2003 } 2014 }
2004 printf("\n"); 2015 printf("\n");
2005 } 2016 }
2006 if (Note->Type == GSM_CAL_BIRTHDAY) { 2017 if (Note->Type == GSM_CAL_BIRTHDAY) {
2007 if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm); 2018 if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm);
2008 if (DateTime.Year != 0) { 2019 if (DateTime.Year != 0) {
2009 i_age = Alarm.Year - DateTime.Year; 2020 i_age = Alarm.Year - DateTime.Year;
2010 if (DateTime.Month < Alarm.Month) i_age++; 2021 if (DateTime.Month < Alarm.Month) i_age++;
2011 if (DateTime.Month == Alarm.Month && 2022 if (DateTime.Month == Alarm.Month &&
2012 DateTime.Day < Alarm.Day) { 2023 DateTime.Day < Alarm.Day) {
2013 i_age++; 2024 i_age++;
2014 } 2025 }
2015 printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years"); 2026 printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years");
2016 } 2027 }
2017 } 2028 }
2018 printf("\n"); 2029 printf("\n");
2019} 2030}
2020 2031
2021static void GetCalendar(int argc, char *argv[]) 2032static void GetCalendar(int argc, char *argv[])
2022{ 2033{
2023 GSM_CalendarEntryNote; 2034 GSM_CalendarEntryNote;
2024 int start,stop; 2035 int start,stop;
2025 2036
2026 GetStartStop(&start, &stop, 2, argc, argv); 2037 GetStartStop(&start, &stop, 2, argc, argv);
2027 2038
2028 GSM_Init(true); 2039 GSM_Init(true);
2029 2040
2030 for (i=start;i<=stop;i++) { 2041 for (i=start;i<=stop;i++) {
2031 Note.Location=i; 2042 Note.Location=i;
2032 error = Phone->GetCalendar(&s, &Note); 2043 error = Phone->GetCalendar(&s, &Note);
2033 if (error == ERR_EMPTY) continue; 2044 if (error == ERR_EMPTY) continue;
2034 Print_Error(error); 2045 Print_Error(error);
2035 PrintCalendar(&Note); 2046 PrintCalendar(&Note);
2036 } 2047 }
2037 2048
2038 GSM_Terminate(); 2049 GSM_Terminate();
2039} 2050}
2040 2051
2041static void DeleteCalendar(int argc, char *argv[]) 2052static void DeleteCalendar(int argc, char *argv[])
2042{ 2053{
2043 GSM_CalendarEntryNote; 2054 GSM_CalendarEntryNote;
2044 int start,stop; 2055 int start,stop;
2045 2056
2046 GetStartStop(&start, &stop, 2, argc, argv); 2057 GetStartStop(&start, &stop, 2, argc, argv);
2047 2058
2048 GSM_Init(true); 2059 GSM_Init(true);
2049 2060
2050 for (i=start;i<=stop;i++) { 2061 for (i=start;i<=stop;i++) {
2051 Note.Location=i; 2062 Note.Location=i;
2052 error = Phone->DeleteCalendar(&s, &Note); 2063 error = Phone->DeleteCalendar(&s, &Note);
2053 if (error == ERR_EMPTY) continue; 2064 if (error == ERR_EMPTY) continue;
2054 Print_Error(error); 2065 Print_Error(error);
2055 PrintCalendar(&Note); 2066 PrintCalendar(&Note);
2056 } 2067 }
2057 2068
2058 GSM_Terminate(); 2069 GSM_Terminate();
2059} 2070}
2060 2071
2061 2072
2062static void GetAllCalendar(int argc, char *argv[]) 2073static void GetAllCalendar(int argc, char *argv[])
2063{ 2074{
2064 GSM_CalendarEntryNote; 2075 GSM_CalendarEntryNote;
2065 bool refresh= true; 2076 bool refresh= true;
2066 2077
2067 signal(SIGINT, interrupt); 2078 signal(SIGINT, interrupt);
2068 printmsgerr("Press Ctrl+C to break...\n"); 2079 printmsgerr("Press Ctrl+C to break...\n");
2069 2080
2070 GSM_Init(true); 2081 GSM_Init(true);
2071 2082
2072 while (!gshutdown) { 2083 while (!gshutdown) {
2073 error=Phone->GetNextCalendar(&s,&Note,refresh); 2084 error=Phone->GetNextCalendar(&s,&Note,refresh);
2074 if (error == ERR_EMPTY) break; 2085 if (error == ERR_EMPTY) break;
2075 Print_Error(error); 2086 Print_Error(error);
2076 PrintCalendar(&Note); 2087 PrintCalendar(&Note);
2077 refresh=false; 2088 refresh=false;
2078 } 2089 }
2079 2090
2080 GSM_Terminate(); 2091 GSM_Terminate();
2081} 2092}
2082 2093
2083static void GetCalendarSettings(int argc, char *argv[]) 2094static void GetCalendarSettings(int argc, char *argv[])
2084{ 2095{
2085 GSM_CalendarSettings settings; 2096 GSM_CalendarSettings settings;
2086 2097
2087 GSM_Init(true); 2098 GSM_Init(true);
2088 2099
2089 error=Phone->GetCalendarSettings(&s,&settings); 2100 error=Phone->GetCalendarSettings(&s,&settings);
2090 Print_Error(error); 2101 Print_Error(error);
2091 2102
2092 if (settings.AutoDelete == 0) { 2103 if (settings.AutoDelete == 0) {
2093 printmsg("Auto deleting disabled"); 2104 printmsg("Auto deleting disabled");
2094 } else { 2105 } else {
2095 printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete); 2106 printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete);
2096 } 2107 }
2097 printmsg("\nWeek start on "); 2108 printmsg("\nWeek start on ");
2098 switch(settings.StartDay) { 2109 switch(settings.StartDay) {
2099 case 1: printmsg("Monday"); break; 2110 case 1: printmsg("Monday"); break;
2100 case 6: printmsg("Saturday"); break; 2111 case 6: printmsg("Saturday"); break;
2101 case 7: printmsg("Sunday"); break; 2112 case 7: printmsg("Sunday"); break;
2102 } 2113 }
2103 printf("\n"); 2114 printf("\n");
2104 2115
2105 GSM_Terminate(); 2116 GSM_Terminate();
2106} 2117}
2107 2118
2108static void GetWAPBookmark(int argc, char *argv[]) 2119static void GetWAPBookmark(int argc, char *argv[])
2109{ 2120{
2110 GSM_WAPBookmark bookmark; 2121 GSM_WAPBookmark bookmark;
2111 int start,stop; 2122 int start,stop;
2112 2123
2113 GetStartStop(&start, &stop, 2, argc, argv); 2124 GetStartStop(&start, &stop, 2, argc, argv);
2114 2125
2115 GSM_Init(true); 2126 GSM_Init(true);
2116 2127
2117 for (i=start;i<=stop;i++) { 2128 for (i=start;i<=stop;i++) {
2118 bookmark.Location=i; 2129 bookmark.Location=i;
2119 error=Phone->GetWAPBookmark(&s,&bookmark); 2130 error=Phone->GetWAPBookmark(&s,&bookmark);
2120 Print_Error(error); 2131 Print_Error(error);
2121 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title)); 2132 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title));
2122 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address)); 2133 printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address));
2123 } 2134 }
2124 2135
2125 GSM_Terminate(); 2136 GSM_Terminate();
2126} 2137}
2127 2138
2128static void DeleteWAPBookmark(int argc, char *argv[]) 2139static void DeleteWAPBookmark(int argc, char *argv[])
2129{ 2140{
2130 GSM_WAPBookmarkbookmark; 2141 GSM_WAPBookmarkbookmark;
2131 int start, stop; 2142 int start, stop;
2132 2143
2133 GetStartStop(&start, &stop, 2, argc, argv); 2144 GetStartStop(&start, &stop, 2, argc, argv);
2134 2145
2135 GSM_Init(true); 2146 GSM_Init(true);
2136 2147
2137 for (i=start;i<=stop;i++) { 2148 for (i=start;i<=stop;i++) {
2138 bookmark.Location=i; 2149 bookmark.Location=i;
2139 error=Phone->DeleteWAPBookmark(&s, &bookmark); 2150 error=Phone->DeleteWAPBookmark(&s, &bookmark);
2140 Print_Error(error); 2151 Print_Error(error);
2141 } 2152 }
2142 2153
2143 GSM_Terminate(); 2154 GSM_Terminate();
2144} 2155}
2145 2156
2146static void GetGPRSPoint(int argc, char *argv[]) 2157static void GetGPRSPoint(int argc, char *argv[])
2147{ 2158{
2148 GSM_GPRSAccessPointpoint; 2159 GSM_GPRSAccessPointpoint;
2149 int start,stop; 2160 int start,stop;
2150 2161
2151 GetStartStop(&start, &stop, 2, argc, argv); 2162 GetStartStop(&start, &stop, 2, argc, argv);
2152 2163
2153 GSM_Init(true); 2164 GSM_Init(true);
2154 2165
2155 for (i=start;i<=stop;i++) { 2166 for (i=start;i<=stop;i++) {
2156 point.Location=i; 2167 point.Location=i;
2157 error=Phone->GetGPRSAccessPoint(&s,&point); 2168 error=Phone->GetGPRSAccessPoint(&s,&point);
2158 if (error != ERR_EMPTY) { 2169 if (error != ERR_EMPTY) {
2159 Print_Error(error); 2170 Print_Error(error);
2160 printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name)); 2171 printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name));
2161 } else { 2172 } else {
2162 printmsg("%i. Access point %i",point.Location,point.Location); 2173 printmsg("%i. Access point %i",point.Location,point.Location);
2163 } 2174 }
2164 if (point.Active) printmsg(" (active)"); 2175 if (point.Active) printmsg(" (active)");
2165 if (error != ERR_EMPTY) { 2176 if (error != ERR_EMPTY) {
2166 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL)); 2177 printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL));
2167 } else { 2178 } else {
2168 printmsg("\n\n"); 2179 printmsg("\n\n");
2169 } 2180 }
2170 } 2181 }
2171 2182
2172 GSM_Terminate(); 2183 GSM_Terminate();
2173} 2184}
2174 2185
2175static void GetBitmap(int argc, char *argv[]) 2186static void GetBitmap(int argc, char *argv[])
2176{ 2187{
2177 GSM_File File; 2188 GSM_File File;
2178 GSM_MultiBitmap MultiBitmap; 2189 GSM_MultiBitmap MultiBitmap;
2179 int location=0; 2190 int location=0;
2180 GSM_AllRingtonesInfo Info; 2191 GSM_AllRingtonesInfo Info = {0, NULL};
2181 2192
2182 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2193 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2183 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2194 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
2184 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2195 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2185 MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo; 2196 MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo;
2186 GetStartStop(&location, NULL, 3, argc, argv); 2197 GetStartStop(&location, NULL, 3, argc, argv);
2187 if (location>5) { 2198 if (location>5) {
2188 printmsg("Maximal location for caller logo can be 5\n"); 2199 printmsg("Maximal location for caller logo can be 5\n");
2189 exit (-1); 2200 exit (-1);
2190 } 2201 }
2191 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2202 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2192 MultiBitmap.Bitmap[0].Type=GSM_PictureImage; 2203 MultiBitmap.Bitmap[0].Type=GSM_PictureImage;
2193 GetStartStop(&location, NULL, 3, argc, argv); 2204 GetStartStop(&location, NULL, 3, argc, argv);
2194 } else if (mystrncasecmp(argv[2],"TEXT",0)) { 2205 } else if (mystrncasecmp(argv[2],"TEXT",0)) {
2195 MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text; 2206 MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text;
2196 } else if (mystrncasecmp(argv[2],"DEALER",0)) { 2207 } else if (mystrncasecmp(argv[2],"DEALER",0)) {
2197 MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text; 2208 MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text;
2198 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2209 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2199 MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo; 2210 MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo;
2200 } else { 2211 } else {
2201 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]); 2212 printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]);
2202 exit(-1); 2213 exit(-1);
2203 } 2214 }
2204 MultiBitmap.Bitmap[0].Location=location; 2215 MultiBitmap.Bitmap[0].Location=location;
2205 2216
2206 GSM_Init(true); 2217 GSM_Init(true);
2207 2218
2208 error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]); 2219 error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]);
2209 Print_Error(error); 2220 Print_Error(error);
2210 2221
2211 MultiBitmap.Number = 1; 2222 MultiBitmap.Number = 1;
2212 2223
2213 error=ERR_NONE; 2224 error=ERR_NONE;
2214 switch (MultiBitmap.Bitmap[0].Type) { 2225 switch (MultiBitmap.Bitmap[0].Type) {
2215 case GSM_CallerGroupLogo: 2226 case GSM_CallerGroupLogo:
2216 if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2227 if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2217 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2228 printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2218 if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)"); 2229 if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)");
2219 printf("\n"); 2230 printf("\n");
2220 if (MultiBitmap.Bitmap[0].DefaultRingtone) { 2231 if (MultiBitmap.Bitmap[0].DefaultRingtone) {
2221 printmsg("Ringtone : default\n"); 2232 printmsg("Ringtone : default\n");
2222 } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) { 2233 } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) {
2223 sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID); 2234 sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID);
2224 2235
2225 File.Buffer = NULL; 2236 File.Buffer = NULL;
2226 File.Used = 0; 2237 File.Used = 0;
2227 2238
2228 error = ERR_NONE; 2239 error = ERR_NONE;
2229 // while (error == ERR_NONE) { 2240 // while (error == ERR_NONE) {
2230 error = Phone->GetFilePart(&s,&File); 2241 error = Phone->GetFilePart(&s,&File);
2231 // } 2242 // }
2232 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); 2243 if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error);
2233 error = ERR_NONE; 2244 error = ERR_NONE;
2234 2245
2235 printmsg("Ringtone : \"%s\" (file with ID %i)\n", 2246 printmsg("Ringtone : \"%s\" (file with ID %i)\n",
2236 DecodeUnicodeString(File.Name), 2247 DecodeUnicodeString(File.Name),
2237 MultiBitmap.Bitmap[0].RingtoneID); 2248 MultiBitmap.Bitmap[0].RingtoneID);
2238 } else { 2249 } else {
2239 error = Phone->GetRingtonesInfo(&s,&Info); 2250 error = Phone->GetRingtonesInfo(&s,&Info);
2240 if (error != ERR_NONE) Info.Number = 0; 2251 if (error != ERR_NONE) Info.Number = 0;
2241 error = ERR_NONE; 2252 error = ERR_NONE;
2242 2253
2243 printmsg("Ringtone : "); 2254 printmsg("Ringtone : ");
2244 if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) { 2255 if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) {
2245 printmsg("\"%s\" (ID %i)\n", 2256 printmsg("\"%s\" (ID %i)\n",
2246 DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)), 2257 DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)),
2247 MultiBitmap.Bitmap[0].RingtoneID); 2258 MultiBitmap.Bitmap[0].RingtoneID);
2248 } else { 2259 } else {
2249 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID); 2260 printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID);
2250 } 2261 }
2262
2263 if (Info.Ringtone) free(Info.Ringtone);
2251 } 2264 }
2252 if (MultiBitmap.Bitmap[0].BitmapEnabled) { 2265 if (MultiBitmap.Bitmap[0].BitmapEnabled) {
2253 printmsg("Bitmap : enabled\n"); 2266 printmsg("Bitmap : enabled\n");
2254 } else { 2267 } else {
2255 printmsg("Bitmap : disabled\n"); 2268 printmsg("Bitmap : disabled\n");
2256 } 2269 }
2257 if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2270 if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
2258 break; 2271 break;
2259 case GSM_StartupLogo: 2272 case GSM_StartupLogo:
2260 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2273 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2261 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2274 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2262 break; 2275 break;
2263 case GSM_OperatorLogo: 2276 case GSM_OperatorLogo:
2264 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) { 2277 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) {
2265 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2278 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2266 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2279 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2267 } else { 2280 } else {
2268 printmsg("No operator logo in phone\n"); 2281 printmsg("No operator logo in phone\n");
2269 } 2282 }
2270 break; 2283 break;
2271 case GSM_PictureImage: 2284 case GSM_PictureImage:
2272 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2285 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2273 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2286 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2274 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender)); 2287 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
2275 if (MultiBitmap.Bitmap[0].Name) 2288 if (MultiBitmap.Bitmap[0].Name)
2276 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name)); 2289 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name));
2277 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2290 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
2278 break; 2291 break;
2279 case GSM_WelcomeNote_Text: 2292 case GSM_WelcomeNote_Text:
2280 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2293 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2281 break; 2294 break;
2282 case GSM_DealerNote_Text: 2295 case GSM_DealerNote_Text:
2283 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2296 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2284 break; 2297 break;
2285 default: 2298 default:
2286 break; 2299 break;
2287 } 2300 }
2288 Print_Error(error); 2301 Print_Error(error);
2289 2302
2290 GSM_Terminate(); 2303 GSM_Terminate();
2291} 2304}
2292 2305
2293static void SetBitmap(int argc, char *argv[]) 2306static void SetBitmap(int argc, char *argv[])
2294{ 2307{
2295 GSM_Bitmap Bitmap, NewBitmap; 2308 GSM_Bitmap Bitmap, NewBitmap;
2296 GSM_MultiBitmap MultiBitmap; 2309 GSM_MultiBitmap MultiBitmap;
2297 GSM_NetworkInfo NetInfo; 2310 GSM_NetworkInfo NetInfo;
2298 bool init = true; 2311 bool init = true;
2299 2312
2300 if (mystrncasecmp(argv[2],"STARTUP",0)) { 2313 if (mystrncasecmp(argv[2],"STARTUP",0)) {
2301 if (argc<4) { 2314 if (argc<4) {
2302 printmsg("More arguments required\n"); 2315 printmsg("More arguments required\n");
2303 exit(-1); 2316 exit(-1);
2304 } 2317 }
2305 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; 2318 MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
2306 MultiBitmap.Bitmap[0].Location=1; 2319 MultiBitmap.Bitmap[0].Location=1;
2307 if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2; 2320 if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2;
2308 if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3; 2321 if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3;
2309 if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4; 2322 if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4;
2310 if (MultiBitmap.Bitmap[0].Location == 1) { 2323 if (MultiBitmap.Bitmap[0].Location == 1) {
2311 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2324 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2312 Print_Error(error); 2325 Print_Error(error);
2313 } 2326 }
2314 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2327 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2315 } else if (mystrncasecmp(argv[2],"TEXT",0)) { 2328 } else if (mystrncasecmp(argv[2],"TEXT",0)) {
2316 if (argc<4) { 2329 if (argc<4) {
2317 printmsg("More arguments required\n"); 2330 printmsg("More arguments required\n");
2318 exit(-1); 2331 exit(-1);
2319 } 2332 }
2320 Bitmap.Type=GSM_WelcomeNote_Text; 2333 Bitmap.Type=GSM_WelcomeNote_Text;
2321 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); 2334 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
2322 } else if (mystrncasecmp(argv[2],"DEALER",0)) { 2335 } else if (mystrncasecmp(argv[2],"DEALER",0)) {
2323 if (argc<4) { 2336 if (argc<4) {
2324 printmsg("More arguments required\n"); 2337 printmsg("More arguments required\n");
2325 exit(-1); 2338 exit(-1);
2326 } 2339 }
2327 Bitmap.Type=GSM_DealerNote_Text; 2340 Bitmap.Type=GSM_DealerNote_Text;
2328 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); 2341 EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
2329 } else if (mystrncasecmp(argv[2],"CALLER",0)) { 2342 } else if (mystrncasecmp(argv[2],"CALLER",0)) {
2330 if (argc<4) { 2343 if (argc<4) {
2331 printmsg("More arguments required\n"); 2344 printmsg("More arguments required\n");
2332 exit(-1); 2345 exit(-1);
2333 } 2346 }
2334 GetStartStop(&i, NULL, 3, argc, argv); 2347 GetStartStop(&i, NULL, 3, argc, argv);
2335 if (i>5 && i!=255) { 2348 if (i>5 && i!=255) {
2336 printmsg("Maximal location for caller logo can be 5\n"); 2349 printmsg("Maximal location for caller logo can be 5\n");
2337 exit (-1); 2350 exit (-1);
2338 } 2351 }
2339 MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo; 2352 MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo;
2340 MultiBitmap.Bitmap[0].Location= i; 2353 MultiBitmap.Bitmap[0].Location= i;
2341 if (argc>4) { 2354 if (argc>4) {
2342 error=GSM_ReadBitmapFile(argv[4],&MultiBitmap); 2355 error=GSM_ReadBitmapFile(argv[4],&MultiBitmap);
2343 Print_Error(error); 2356 Print_Error(error);
2344 } 2357 }
2345 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2358 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2346 if (i!=255) { 2359 if (i!=255) {
2347 GSM_Init(true); 2360 GSM_Init(true);
2348 init = false; 2361 init = false;
2349 NewBitmap.Type = GSM_CallerGroupLogo; 2362 NewBitmap.Type = GSM_CallerGroupLogo;
2350 NewBitmap.Location = i; 2363 NewBitmap.Location = i;
2351 error=Phone->GetBitmap(&s,&NewBitmap); 2364 error=Phone->GetBitmap(&s,&NewBitmap);
2352 Print_Error(error); 2365 Print_Error(error);
2353 Bitmap.RingtoneID = NewBitmap.RingtoneID; 2366 Bitmap.RingtoneID = NewBitmap.RingtoneID;
2354 Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone; 2367 Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone;
2355 Bitmap.FileSystemRingtone = false; 2368 Bitmap.FileSystemRingtone = false;
2356 CopyUnicodeString(Bitmap.Text, NewBitmap.Text); 2369 CopyUnicodeString(Bitmap.Text, NewBitmap.Text);
2357 Bitmap.DefaultName = NewBitmap.DefaultName; 2370 Bitmap.DefaultName = NewBitmap.DefaultName;
2358 } 2371 }
2359 } else if (mystrncasecmp(argv[2],"PICTURE",0)) { 2372 } else if (mystrncasecmp(argv[2],"PICTURE",0)) {
2360 if (argc<5) { 2373 if (argc<5) {
2361 printmsg("More arguments required\n"); 2374 printmsg("More arguments required\n");
2362 exit(-1); 2375 exit(-1);
2363 } 2376 }
2364 MultiBitmap.Bitmap[0].Type = GSM_PictureImage; 2377 MultiBitmap.Bitmap[0].Type = GSM_PictureImage;
2365 MultiBitmap.Bitmap[0].Location = atoi(argv[4]); 2378 MultiBitmap.Bitmap[0].Location = atoi(argv[4]);
2366 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2379 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2367 Print_Error(error); 2380 Print_Error(error);
2368 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2381 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2369 Bitmap.Text[0]=0; 2382 Bitmap.Text[0]=0;
2370 Bitmap.Text[1]=0; 2383 Bitmap.Text[1]=0;
2371 if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5])); 2384 if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5]));
2372 Bitmap.Sender[0]=0; 2385 Bitmap.Sender[0]=0;
2373 Bitmap.Sender[1]=0; 2386 Bitmap.Sender[1]=0;
2374 } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) { 2387 } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) {
2375 Bitmap.Type = GSM_ColourOperatorLogo_ID; 2388 Bitmap.Type = GSM_ColourOperatorLogo_ID;
2376 strcpy(Bitmap.NetworkCode,"000 00"); 2389 strcpy(Bitmap.NetworkCode,"000 00");
2377 if (argc > 3) { 2390 if (argc > 3) {
2378 Bitmap.ID = atoi(argv[3]); 2391 Bitmap.ID = atoi(argv[3]);
2379 if (argc>4) { 2392 if (argc>4) {
2380 strncpy(Bitmap.NetworkCode,argv[4],6); 2393 strncpy(Bitmap.NetworkCode,argv[4],6);
2381 } else { 2394 } else {
2382 GSM_Init(true); 2395 GSM_Init(true);
2383 init = false; 2396 init = false;
2384 error=Phone->GetNetworkInfo(&s,&NetInfo); 2397 error=Phone->GetNetworkInfo(&s,&NetInfo);
2385 Print_Error(error); 2398 Print_Error(error);
2386 strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode); 2399 strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode);
2387 } 2400 }
2388 } 2401 }
2389 } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) { 2402 } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) {
2390 Bitmap.Type = GSM_ColourStartupLogo_ID; 2403 Bitmap.Type = GSM_ColourStartupLogo_ID;
2391 Bitmap.Location = 0; 2404 Bitmap.Location = 0;
2392 if (argc > 3) { 2405 if (argc > 3) {
2393 Bitmap.Location = 1; 2406 Bitmap.Location = 1;
2394 Bitmap.ID = atoi(argv[3]); 2407 Bitmap.ID = atoi(argv[3]);
2395 } 2408 }
2396 } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) { 2409 } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) {
2397 Bitmap.Type = GSM_ColourWallPaper_ID; 2410 Bitmap.Type = GSM_ColourWallPaper_ID;
2398 Bitmap.ID = 0; 2411 Bitmap.ID = 0;
2399 if (argc > 3) Bitmap.ID = atoi(argv[3]); 2412 if (argc > 3) Bitmap.ID = atoi(argv[3]);
2400 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { 2413 } else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
2401 MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo; 2414 MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo;
2402 MultiBitmap.Bitmap[0].Location = 1; 2415 MultiBitmap.Bitmap[0].Location = 1;
2403 strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00"); 2416 strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00");
2404 if (argc>3) { 2417 if (argc>3) {
2405 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); 2418 error=GSM_ReadBitmapFile(argv[3],&MultiBitmap);
2406 Print_Error(error); 2419 Print_Error(error);
2407 if (argc>4) { 2420 if (argc>4) {
2408 strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6); 2421 strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6);
2409 } else { 2422 } else {
2410 GSM_Init(true); 2423 GSM_Init(true);
2411 init = false; 2424 init = false;
2412 error=Phone->GetNetworkInfo(&s,&NetInfo); 2425 error=Phone->GetNetworkInfo(&s,&NetInfo);
2413 Print_Error(error); 2426 Print_Error(error);
2414 strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode); 2427 strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode);
2415 } 2428 }
2416 } 2429 }
2417 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); 2430 memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
2418 } else { 2431 } else {
2419 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]); 2432 printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]);
2420 exit(-1); 2433 exit(-1);
2421 } 2434 }
2422 2435
2423 if (init) GSM_Init(true); 2436 if (init) GSM_Init(true);
2424 2437
2425 error=Phone->SetBitmap(&s,&Bitmap); 2438 error=Phone->SetBitmap(&s,&Bitmap);
2426 Print_Error(error); 2439 Print_Error(error);
2427 2440
2428#ifdef GSM_ENABLE_BEEP 2441#ifdef GSM_ENABLE_BEEP
2429 GSM_PhoneBeep(); 2442 GSM_PhoneBeep();
2430#endif 2443#endif
2431 2444
2432 GSM_Terminate(); 2445 GSM_Terminate();
2433} 2446}
2434 2447
2435static void SetRingtone(int argc, char *argv[]) 2448static void SetRingtone(int argc, char *argv[])
2436{ 2449{
2437 GSM_Ringtone ringtone; 2450 GSM_Ringtone ringtone;
2438 int i,nextlong=0; 2451 int i,nextlong=0;
2439 2452
2440 ringtone.Format= 0; 2453 ringtone.Format= 0;
2441 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 2454 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
2442 Print_Error(error); 2455 Print_Error(error);
2443 ringtone.Location = 255; 2456 ringtone.Location = 255;
2444 for (i=3;i<argc;i++) { 2457 for (i=3;i<argc;i++) {
2445 switch (nextlong) { 2458 switch (nextlong) {
2446 case 0: 2459 case 0:
2447 if (mystrncasecmp(argv[i],"-scale",0)) { 2460 if (mystrncasecmp(argv[i],"-scale",0)) {
2448 ringtone.NoteTone.AllNotesScale = true; 2461 ringtone.NoteTone.AllNotesScale = true;
2449 break; 2462 break;
2450 } 2463 }
2451 if (mystrncasecmp(argv[i],"-location",0)) { 2464 if (mystrncasecmp(argv[i],"-location",0)) {
2452 nextlong = 1; 2465 nextlong = 1;
2453 break; 2466 break;
2454 } 2467 }
2455 if (mystrncasecmp(argv[i],"-name",0)) { 2468 if (mystrncasecmp(argv[i],"-name",0)) {
2456 nextlong = 2; 2469 nextlong = 2;
2457 break; 2470 break;
2458 } 2471 }
2459 printmsg("Unknown parameter \"%s\"",argv[i]); 2472 printmsg("Unknown parameter \"%s\"",argv[i]);
2460 exit(-1); 2473 exit(-1);
2461 case 1: 2474 case 1:
2462 ringtone.Location=atoi(argv[i]); 2475 ringtone.Location=atoi(argv[i]);
2463 nextlong = 0; 2476 nextlong = 0;
2464 break; 2477 break;
2465 case 2: 2478 case 2:
2466 EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i])); 2479 EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i]));
2467 nextlong = 0; 2480 nextlong = 0;
2468 break; 2481 break;
2469 } 2482 }
2470 } 2483 }
2471 if (nextlong!=0) { 2484 if (nextlong!=0) {
2472 printmsg("Parameter missed...\n"); 2485 printmsg("Parameter missed...\n");
2473 exit(-1); 2486 exit(-1);
2474 } 2487 }
2475 if (ringtone.Location==0) { 2488 if (ringtone.Location==0) {
2476 printmsg("ERROR: enumerate locations from 1\n"); 2489 printmsg("ERROR: enumerate locations from 1\n");
2477 exit (-1); 2490 exit (-1);
2478 } 2491 }
2479 2492
2480 GSM_Init(true); 2493 GSM_Init(true);
2481 error=Phone->SetRingtone(&s, &ringtone, &i); 2494 error=Phone->SetRingtone(&s, &ringtone, &i);
2482 Print_Error(error); 2495 Print_Error(error);
2483#ifdef GSM_ENABLE_BEEP 2496#ifdef GSM_ENABLE_BEEP
2484 GSM_PhoneBeep(); 2497 GSM_PhoneBeep();
2485#endif 2498#endif
2486 GSM_Terminate(); 2499 GSM_Terminate();
2487} 2500}
2488 2501
2489static void DisplaySMSFrame(GSM_SMSMessage *SMS) 2502static void DisplaySMSFrame(GSM_SMSMessage *SMS)
2490{ 2503{
2491 GSM_Error error; 2504 GSM_Error error;
2492 int i, length, current = 0; 2505 int i, length, current = 0;
2493 unsigned char req[1000], buffer[1000], hexreq[1000]; 2506 unsigned char req[1000], buffer[1000], hexreq[1000];
2494#ifdef OSCAR 2507#ifdef OSCAR
2495 unsigned char hexmsg[1000], hexudh[1000]; 2508 unsigned char hexmsg[1000], hexudh[1000];
2496#endif 2509#endif
2497 error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true); 2510 error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true);
2498 if (error != ERR_NONE) { 2511 if (error != ERR_NONE) {
2499 printmsg("Error\n"); 2512 printmsg("Error\n");
2500 exit(-1); 2513 exit(-1);
2501 } 2514 }
2502 length = length - PHONE_SMSSubmit.Text; 2515 length = length - PHONE_SMSSubmit.Text;
2503#ifdef OSCAR 2516#ifdef OSCAR
2504 for(i=SMS->UDH.Length;i<length;i++) { 2517 for(i=SMS->UDH.Length;i<length;i++) {
2505 req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i]; 2518 req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i];
2506 } 2519 }
2507 EncodeHexBin(hexmsg, req, length-SMS->UDH.Length); 2520 EncodeHexBin(hexmsg, req, length-SMS->UDH.Length);
2508 2521
2509 for(i=0;i<SMS->UDH.Length;i++) { 2522 for(i=0;i<SMS->UDH.Length;i++) {
2510 req[i]=buffer[PHONE_SMSSubmit.Text+i]; 2523 req[i]=buffer[PHONE_SMSSubmit.Text+i];
2511 } 2524 }
2512 EncodeHexBin(hexudh, req, SMS->UDH.Length); 2525 EncodeHexBin(hexudh, req, SMS->UDH.Length);
2513 2526
2514 printf("msg:%s nb:%i udh:%s\n", 2527 printf("msg:%s nb:%i udh:%s\n",
2515 hexmsg, 2528 hexmsg,
2516 (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8, 2529 (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8,
2517 hexudh); 2530 hexudh);
2518#else 2531#else
2519 for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) { 2532 for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) {
2520 req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i]; 2533 req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i];
2521 } 2534 }
2522 req[current++]=buffer[PHONE_SMSSubmit.firstbyte]; 2535 req[current++]=buffer[PHONE_SMSSubmit.firstbyte];
2523 req[current++]=buffer[PHONE_SMSSubmit.TPMR]; 2536 req[current++]=buffer[PHONE_SMSSubmit.TPMR];
2524 for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) { 2537 for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) {
2525 req[current++]=buffer[PHONE_SMSSubmit.Number+i]; 2538 req[current++]=buffer[PHONE_SMSSubmit.Number+i];
2526 } 2539 }
2527 req[current++]=buffer[PHONE_SMSSubmit.TPPID]; 2540 req[current++]=buffer[PHONE_SMSSubmit.TPPID];
2528 req[current++]=buffer[PHONE_SMSSubmit.TPDCS]; 2541 req[current++]=buffer[PHONE_SMSSubmit.TPDCS];
2529 req[current++]=buffer[PHONE_SMSSubmit.TPVP]; 2542 req[current++]=buffer[PHONE_SMSSubmit.TPVP];
2530 req[current++]=buffer[PHONE_SMSSubmit.TPUDL]; 2543 req[current++]=buffer[PHONE_SMSSubmit.TPUDL];
2531 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i]; 2544 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i];
2532 EncodeHexBin(hexreq, req, current); 2545 EncodeHexBin(hexreq, req, current);
2533 printmsg("%s\n\n",hexreq); 2546 printmsg("%s\n\n",hexreq);
2534#endif 2547#endif
2535} 2548}
2536 2549
2537#define SEND_SAVE_SMS_BUFFER_SIZE 10000 2550#define SEND_SAVE_SMS_BUFFER_SIZE 10000
2538 2551
2539static GSM_Error SMSStatus; 2552static GSM_Error SMSStatus;
2540 2553
2541static void SendSMSStatus (char *Device, int status, int MessageReference) 2554static void SendSMSStatus (char *Device, int status, int MessageReference)
2542{ 2555{
2543 dbgprintf("Sent SMS on device: \"%s\"\n",Device); 2556 dbgprintf("Sent SMS on device: \"%s\"\n",Device);
2544 if (status==0) { 2557 if (status==0) {
2545 printmsg("..OK"); 2558 printmsg("..OK");
2546 SMSStatus = ERR_NONE; 2559 SMSStatus = ERR_NONE;
2547 } else { 2560 } else {
2548 printmsg("..error %i",status); 2561 printmsg("..error %i",status);
2549 SMSStatus = ERR_UNKNOWN; 2562 SMSStatus = ERR_UNKNOWN;
2550 } 2563 }
2551 printmsg(", message reference=%d\n",MessageReference); 2564 printmsg(", message reference=%d\n",MessageReference);
2552} 2565}
2553 2566
2554static void SendSaveDisplaySMS(int argc, char *argv[]) 2567static void SendSaveDisplaySMS(int argc, char *argv[])
2555{ 2568{
2556#ifdef GSM_ENABLE_BACKUP 2569#ifdef GSM_ENABLE_BACKUP
2557 GSM_Backup Backup; 2570 GSM_Backup Backup;
2558#endif 2571#endif
2559 int i,j,z,FramesNum = 0; 2572 int i,j,z,FramesNum = 0;
2560 int Protected = 0; 2573 int Protected = 0;
2561 GSM_SMSFolders folders; 2574 GSM_SMSFolders folders;
2562 GSM_MultiSMSMessage sms; 2575 GSM_MultiSMSMessage sms;
2563 GSM_Ringtone ringtone[MAX_MULTI_SMS]; 2576 GSM_Ringtone ringtone[MAX_MULTI_SMS];
2564 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2; 2577 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
2565 GSM_MultiPartSMSInfo SMSInfo; 2578 GSM_MultiPartSMSInfo SMSInfo;
2566 GSM_NetworkInfo NetInfo; 2579 GSM_NetworkInfo NetInfo;
2567 GSM_MMSIndicator MMSInfo; 2580 GSM_MMSIndicator MMSInfo;
2568 FILE *ReplaceFile,*f; 2581 FILE *ReplaceFile,*f;
2569 char ReplaceBuffer2[200],ReplaceBuffer[200]; 2582 char ReplaceBuffer2[200],ReplaceBuffer[200];
2570 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1]; 2583 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1];
2571 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE]; 2584 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE];
2572 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2585 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2];
2573 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2586 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2];
2574 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2587 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2];
2575 int startarg = 0; 2588 int startarg = 0;
2576 int chars_read = 0; 2589 int chars_read = 0;
2577 int nextlong = 0; 2590 int nextlong = 0;
2578 bool ReplyViaSameSMSC = false; 2591 bool ReplyViaSameSMSC = false;
2579 int SMSCSet = 1; 2592 int SMSCSet = 1;
2580 int MaxSMS = -1; 2593 int MaxSMS = -1;
2581 bool EMS16Bit = false; 2594 bool EMS16Bit = false;
2582 bool SendSaved = false; 2595 bool SendSaved = false;
2583 2596
2584 /* Parameters required only during saving */ 2597 /* Parameters required only during saving */
2585 int Folder = 1; /*Inbox by default */ 2598 int Folder = 1; /*Inbox by default */
2586 GSM_SMS_State State = SMS_Sent; 2599 GSM_SMS_State State = SMS_Sent;
2587 2600
2588 /* Required only during sending */ 2601 /* Required only during sending */
2589 GSM_SMSValidity Validity; 2602 GSM_SMSValidity Validity;
2590 GSM_SMSC PhoneSMSC; 2603 GSM_SMSC PhoneSMSC;
2591 bool DeliveryReport = false; 2604 bool DeliveryReport = false;
2592 2605
2593 ReplaceBuffer[0] = 0; 2606 ReplaceBuffer[0] = 0;
2594 ReplaceBuffer[1] = 0; 2607 ReplaceBuffer[1] = 0;
2595 GSM_ClearMultiPartSMSInfo(&SMSInfo); 2608 GSM_ClearMultiPartSMSInfo(&SMSInfo);
2596 SMSInfo.ReplaceMessage = 0; 2609 SMSInfo.ReplaceMessage = 0;
2597 SMSInfo.EntriesNum = 1; 2610 SMSInfo.EntriesNum = 1;
2598 2611
2599 if (mystrncasecmp(argv[1],"--savesms",0)) { 2612 if (mystrncasecmp(argv[1],"--savesms",0)) {
2600 EncodeUnicode(Sender,"Gammu",5); 2613 EncodeUnicode(Sender,"Gammu",5);
2601 Name[0] = 0; 2614 Name[0] = 0;
2602 Name[1] = 0; 2615 Name[1] = 0;
2603 startarg = 0; 2616 startarg = 0;
2604 } else { 2617 } else {
2605 EncodeUnicode(Sender,argv[3],strlen(argv[3])); 2618 EncodeUnicode(Sender,argv[3],strlen(argv[3]));
2606 startarg = 1; 2619 startarg = 1;
2607 Validity.Format = 0; 2620 Validity.Format = 0;
2608 } 2621 }
2609 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { 2622 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
2610 startarg=startarg+2; 2623 startarg=startarg+2;
2611 EncodeUnicode(SMSC,"1234",4); 2624 EncodeUnicode(SMSC,"1234",4);
2612 SMSCSet= 0; 2625 SMSCSet= 0;
2613 } 2626 }
2614 2627
2615 if (mystrncasecmp(argv[2],"TEXT",0)) { 2628 if (mystrncasecmp(argv[2],"TEXT",0)) {
2616 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin); 2629 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin);
2617 if (chars_read == 0) printmsg("Warning: 0 chars read !\n"); 2630 if (chars_read == 0) printmsg("Warning: 0 chars read !\n");
2618 InputBuffer[chars_read] = 0x00; 2631 InputBuffer[chars_read] = 0x00;
2619 InputBuffer[chars_read+1] = 0x00; 2632 InputBuffer[chars_read+1] = 0x00;
2620 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer)); 2633 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer));
2621 SMSInfo.Entries[0].Buffer = Buffer[0]; 2634 SMSInfo.Entries[0].Buffer = Buffer[0];
2622 SMSInfo.Entries[0].ID = SMS_Text; 2635 SMSInfo.Entries[0].ID = SMS_Text;
2623 SMSInfo.UnicodeCoding = false; 2636 SMSInfo.UnicodeCoding = false;
2624 startarg += 3; 2637 startarg += 3;
2625 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { 2638 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
2626 SMSInfo.UnicodeCoding = false; 2639 SMSInfo.UnicodeCoding = false;
2627 SMSInfo.EntriesNum = 1; 2640 SMSInfo.EntriesNum = 1;
2628 Buffer[0][0] = 0x00; 2641 Buffer[0][0] = 0x00;
2629 Buffer[0][1] = 0x00; 2642 Buffer[0][1] = 0x00;
2630 SMSInfo.Entries[0].Buffer = Buffer[0]; 2643 SMSInfo.Entries[0].Buffer = Buffer[0];
2631 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName; 2644 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName;
2632 startarg += 3; 2645 startarg += 3;
2633 } else if (mystrncasecmp(argv[2],"EMS",0)) { 2646 } else if (mystrncasecmp(argv[2],"EMS",0)) {
2634 SMSInfo.UnicodeCoding = false; 2647 SMSInfo.UnicodeCoding = false;
@@ -4264,2610 +4277,2672 @@ static void Backup(int argc, char *argv[])
4264 used = 0; 4277 used = 0;
4265 printmsgerr(" Reading: "); 4278 printmsgerr(" Reading: ");
4266 while (true) { 4279 while (true) {
4267 SMSC.Location = used + 1; 4280 SMSC.Location = used + 1;
4268 error = Phone->GetSMSC(&s,&SMSC); 4281 error = Phone->GetSMSC(&s,&SMSC);
4269 if (error != ERR_NONE) break; 4282 if (error != ERR_NONE) break;
4270 if (used < GSM_BACKUP_MAX_SMSC) { 4283 if (used < GSM_BACKUP_MAX_SMSC) {
4271 Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); 4284 Backup.SMSC[used] = malloc(sizeof(GSM_SMSC));
4272 if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); 4285 if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY);
4273 Backup.SMSC[used + 1] = NULL; 4286 Backup.SMSC[used + 1] = NULL;
4274 } else { 4287 } else {
4275 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); 4288 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC");
4276 GSM_Terminate(); 4289 GSM_Terminate();
4277 exit(-1); 4290 exit(-1);
4278 } 4291 }
4279 *Backup.SMSC[used]=SMSC; 4292 *Backup.SMSC[used]=SMSC;
4280 used++; 4293 used++;
4281 printmsgerr("*"); 4294 printmsgerr("*");
4282 } 4295 }
4283 printmsgerr("\n"); 4296 printmsgerr("\n");
4284 } 4297 }
4285 DoBackup = false; 4298 DoBackup = false;
4286 if (Info.StartupLogo) { 4299 if (Info.StartupLogo) {
4287 printmsg("Checking startup text\n"); 4300 printmsg("Checking startup text\n");
4288 Bitmap.Type = GSM_WelcomeNote_Text; 4301 Bitmap.Type = GSM_WelcomeNote_Text;
4289 error = Phone->GetBitmap(&s,&Bitmap); 4302 error = Phone->GetBitmap(&s,&Bitmap);
4290 if (error == ERR_NONE) { 4303 if (error == ERR_NONE) {
4291 if (answer_yes(" Backup startup logo/text")) DoBackup = true; 4304 if (answer_yes(" Backup startup logo/text")) DoBackup = true;
4292 } 4305 }
4293 } 4306 }
4294 if (DoBackup) { 4307 if (DoBackup) {
4295 Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); 4308 Backup.StartupLogo = malloc(sizeof(GSM_Bitmap));
4296 if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); 4309 if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY);
4297 *Backup.StartupLogo = Bitmap; 4310 *Backup.StartupLogo = Bitmap;
4298 if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { 4311 if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) {
4299 Bitmap.Type = GSM_StartupLogo; 4312 Bitmap.Type = GSM_StartupLogo;
4300 error = Phone->GetBitmap(&s,&Bitmap); 4313 error = Phone->GetBitmap(&s,&Bitmap);
4301 if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; 4314 if (error == ERR_NONE) *Backup.StartupLogo = Bitmap;
4302 } 4315 }
4303 } 4316 }
4304 DoBackup = false; 4317 DoBackup = false;
4305 if (Info.OperatorLogo) { 4318 if (Info.OperatorLogo) {
4306 printmsg("Checking operator logo\n"); 4319 printmsg("Checking operator logo\n");
4307 Bitmap.Type = GSM_OperatorLogo; 4320 Bitmap.Type = GSM_OperatorLogo;
4308 error=Phone->GetBitmap(&s,&Bitmap); 4321 error=Phone->GetBitmap(&s,&Bitmap);
4309 if (error == ERR_NONE) { 4322 if (error == ERR_NONE) {
4310 if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { 4323 if (strcmp(Bitmap.NetworkCode,"000 00")!=0) {
4311 if (answer_yes(" Backup operator logo")) DoBackup = true; 4324 if (answer_yes(" Backup operator logo")) DoBackup = true;
4312 } 4325 }
4313 } 4326 }
4314 } 4327 }
4315 if (DoBackup) { 4328 if (DoBackup) {
4316 Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); 4329 Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap));
4317 if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); 4330 if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY);
4318 *Backup.OperatorLogo = Bitmap; 4331 *Backup.OperatorLogo = Bitmap;
4319 } 4332 }
4320 DoBackup = false; 4333 DoBackup = false;
4321 if (Info.WAPBookmark) { 4334 if (Info.WAPBookmark) {
4322 printmsg("Checking WAP bookmarks\n"); 4335 printmsg("Checking WAP bookmarks\n");
4323 Bookmark.Location = 1; 4336 Bookmark.Location = 1;
4324 error=Phone->GetWAPBookmark(&s,&Bookmark); 4337 error=Phone->GetWAPBookmark(&s,&Bookmark);
4325 if (error==ERR_NONE) { 4338 if (error==ERR_NONE) {
4326 if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; 4339 if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
4327 } 4340 }
4328 } 4341 }
4329 if (DoBackup) { 4342 if (DoBackup) {
4330 used = 0; 4343 used = 0;
4331 printmsgerr(" Reading : "); 4344 printmsgerr(" Reading : ");
4332 while (error == ERR_NONE) { 4345 while (error == ERR_NONE) {
4333 if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { 4346 if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
4334 Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); 4347 Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
4335 if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); 4348 if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
4336 Backup.WAPBookmark[used+1] = NULL; 4349 Backup.WAPBookmark[used+1] = NULL;
4337 } else { 4350 } else {
4338 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); 4351 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
4339 GSM_Terminate(); 4352 GSM_Terminate();
4340 exit(-1); 4353 exit(-1);
4341 } 4354 }
4342 *Backup.WAPBookmark[used]=Bookmark; 4355 *Backup.WAPBookmark[used]=Bookmark;
4343 used ++; 4356 used ++;
4344 Bookmark.Location = used+1; 4357 Bookmark.Location = used+1;
4345 error=Phone->GetWAPBookmark(&s,&Bookmark); 4358 error=Phone->GetWAPBookmark(&s,&Bookmark);
4346 printmsgerr("*"); 4359 printmsgerr("*");
4347 if (gshutdown) { 4360 if (gshutdown) {
4348 GSM_Terminate(); 4361 GSM_Terminate();
4349 exit(0); 4362 exit(0);
4350 } 4363 }
4351 } 4364 }
4352 printmsgerr("\n"); 4365 printmsgerr("\n");
4353 } 4366 }
4354 DoBackup = false; 4367 DoBackup = false;
4355 if (Info.WAPSettings) { 4368 if (Info.WAPSettings) {
4356 printmsg("Checking WAP settings\n"); 4369 printmsg("Checking WAP settings\n");
4357 Settings.Location = 1; 4370 Settings.Location = 1;
4358 error=Phone->GetWAPSettings(&s,&Settings); 4371 error=Phone->GetWAPSettings(&s,&Settings);
4359 if (error==ERR_NONE) { 4372 if (error==ERR_NONE) {
4360 if (answer_yes(" Backup WAP settings")) DoBackup = true; 4373 if (answer_yes(" Backup WAP settings")) DoBackup = true;
4361 } 4374 }
4362 } 4375 }
4363 if (DoBackup) { 4376 if (DoBackup) {
4364 used = 0; 4377 used = 0;
4365 printmsgerr(" Reading : "); 4378 printmsgerr(" Reading : ");
4366 while (error == ERR_NONE) { 4379 while (error == ERR_NONE) {
4367 if (used < GSM_BACKUP_MAX_WAPSETTINGS) { 4380 if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
4368 Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); 4381 Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
4369 if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4382 if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4370 Backup.WAPSettings[used+1] = NULL; 4383 Backup.WAPSettings[used+1] = NULL;
4371 } else { 4384 } else {
4372 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); 4385 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
4373 GSM_Terminate(); 4386 GSM_Terminate();
4374 exit(-1); 4387 exit(-1);
4375 } 4388 }
4376 *Backup.WAPSettings[used]=Settings; 4389 *Backup.WAPSettings[used]=Settings;
4377 used ++; 4390 used ++;
4378 Settings.Location = used+1; 4391 Settings.Location = used+1;
4379 error=Phone->GetWAPSettings(&s,&Settings); 4392 error=Phone->GetWAPSettings(&s,&Settings);
4380 printmsgerr("*"); 4393 printmsgerr("*");
4381 if (gshutdown) { 4394 if (gshutdown) {
4382 GSM_Terminate(); 4395 GSM_Terminate();
4383 exit(0); 4396 exit(0);
4384 } 4397 }
4385 } 4398 }
4386 printmsgerr("\n"); 4399 printmsgerr("\n");
4387 } 4400 }
4388 DoBackup = false; 4401 DoBackup = false;
4389 if (Info.MMSSettings) { 4402 if (Info.MMSSettings) {
4390 printmsg("Checking MMS settings\n"); 4403 printmsg("Checking MMS settings\n");
4391 Settings.Location = 1; 4404 Settings.Location = 1;
4392 error=Phone->GetMMSSettings(&s,&Settings); 4405 error=Phone->GetMMSSettings(&s,&Settings);
4393 if (error==ERR_NONE) { 4406 if (error==ERR_NONE) {
4394 if (answer_yes(" Backup MMS settings")) DoBackup = true; 4407 if (answer_yes(" Backup MMS settings")) DoBackup = true;
4395 } 4408 }
4396 } 4409 }
4397 if (DoBackup) { 4410 if (DoBackup) {
4398 used = 0; 4411 used = 0;
4399 printmsgerr(" Reading : "); 4412 printmsgerr(" Reading : ");
4400 while (error == ERR_NONE) { 4413 while (error == ERR_NONE) {
4401 if (used < GSM_BACKUP_MAX_MMSSETTINGS) { 4414 if (used < GSM_BACKUP_MAX_MMSSETTINGS) {
4402 Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); 4415 Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
4403 if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4416 if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4404 Backup.MMSSettings[used+1] = NULL; 4417 Backup.MMSSettings[used+1] = NULL;
4405 } else { 4418 } else {
4406 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); 4419 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS");
4407 GSM_Terminate(); 4420 GSM_Terminate();
4408 exit(-1); 4421 exit(-1);
4409 } 4422 }
4410 *Backup.MMSSettings[used]=Settings; 4423 *Backup.MMSSettings[used]=Settings;
4411 used ++; 4424 used ++;
4412 Settings.Location = used+1; 4425 Settings.Location = used+1;
4413 error=Phone->GetMMSSettings(&s,&Settings); 4426 error=Phone->GetMMSSettings(&s,&Settings);
4414 printmsgerr("*"); 4427 printmsgerr("*");
4415 if (gshutdown) { 4428 if (gshutdown) {
4416 GSM_Terminate(); 4429 GSM_Terminate();
4417 exit(0); 4430 exit(0);
4418 } 4431 }
4419 } 4432 }
4420 printmsgerr("\n"); 4433 printmsgerr("\n");
4421 } 4434 }
4422 DoBackup = false; 4435 DoBackup = false;
4423 if (Info.ChatSettings) { 4436 if (Info.ChatSettings) {
4424 printmsg("Checking Chat settings\n"); 4437 printmsg("Checking Chat settings\n");
4425 Chat.Location = 1; 4438 Chat.Location = 1;
4426 error=Phone->GetChatSettings(&s,&Chat); 4439 error=Phone->GetChatSettings(&s,&Chat);
4427 if (error==ERR_NONE) { 4440 if (error==ERR_NONE) {
4428 if (answer_yes(" Backup Chat settings")) DoBackup = true; 4441 if (answer_yes(" Backup Chat settings")) DoBackup = true;
4429 } 4442 }
4430 } 4443 }
4431 if (DoBackup) { 4444 if (DoBackup) {
4432 used = 0; 4445 used = 0;
4433 printmsgerr(" Reading : "); 4446 printmsgerr(" Reading : ");
4434 while (error == ERR_NONE) { 4447 while (error == ERR_NONE) {
4435 if (used < GSM_BACKUP_MAX_CHATSETTINGS) { 4448 if (used < GSM_BACKUP_MAX_CHATSETTINGS) {
4436 Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings)); 4449 Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings));
4437 if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4450 if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4438 Backup.ChatSettings[used+1] = NULL; 4451 Backup.ChatSettings[used+1] = NULL;
4439 } else { 4452 } else {
4440 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS"); 4453 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS");
4441 GSM_Terminate(); 4454 GSM_Terminate();
4442 exit(-1); 4455 exit(-1);
4443 } 4456 }
4444 *Backup.ChatSettings[used]=Chat; 4457 *Backup.ChatSettings[used]=Chat;
4445 used ++; 4458 used ++;
4446 Chat.Location = used+1; 4459 Chat.Location = used+1;
4447 error=Phone->GetChatSettings(&s,&Chat); 4460 error=Phone->GetChatSettings(&s,&Chat);
4448 printmsgerr("*"); 4461 printmsgerr("*");
4449 if (gshutdown) { 4462 if (gshutdown) {
4450 GSM_Terminate(); 4463 GSM_Terminate();
4451 exit(0); 4464 exit(0);
4452 } 4465 }
4453 } 4466 }
4454 printmsgerr("\n"); 4467 printmsgerr("\n");
4455 } 4468 }
4456 DoBackup = false; 4469 DoBackup = false;
4457 if (Info.SyncMLSettings) { 4470 if (Info.SyncMLSettings) {
4458 printmsg("Checking SyncML settings\n"); 4471 printmsg("Checking SyncML settings\n");
4459 SyncML.Location = 1; 4472 SyncML.Location = 1;
4460 error=Phone->GetSyncMLSettings(&s,&SyncML); 4473 error=Phone->GetSyncMLSettings(&s,&SyncML);
4461 if (error==ERR_NONE) { 4474 if (error==ERR_NONE) {
4462 if (answer_yes(" Backup SyncML settings")) DoBackup = true; 4475 if (answer_yes(" Backup SyncML settings")) DoBackup = true;
4463 } 4476 }
4464 } 4477 }
4465 if (DoBackup) { 4478 if (DoBackup) {
4466 used = 0; 4479 used = 0;
4467 printmsgerr(" Reading : "); 4480 printmsgerr(" Reading : ");
4468 while (error == ERR_NONE) { 4481 while (error == ERR_NONE) {
4469 if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) { 4482 if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) {
4470 Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings)); 4483 Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings));
4471 if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4484 if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4472 Backup.SyncMLSettings[used+1] = NULL; 4485 Backup.SyncMLSettings[used+1] = NULL;
4473 } else { 4486 } else {
4474 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS"); 4487 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS");
4475 GSM_Terminate(); 4488 GSM_Terminate();
4476 exit(-1); 4489 exit(-1);
4477 } 4490 }
4478 *Backup.SyncMLSettings[used]=SyncML; 4491 *Backup.SyncMLSettings[used]=SyncML;
4479 used ++; 4492 used ++;
4480 SyncML.Location = used+1; 4493 SyncML.Location = used+1;
4481 error=Phone->GetSyncMLSettings(&s,&SyncML); 4494 error=Phone->GetSyncMLSettings(&s,&SyncML);
4482 printmsgerr("*"); 4495 printmsgerr("*");
4483 if (gshutdown) { 4496 if (gshutdown) {
4484 GSM_Terminate(); 4497 GSM_Terminate();
4485 exit(0); 4498 exit(0);
4486 } 4499 }
4487 } 4500 }
4488 printmsgerr("\n"); 4501 printmsgerr("\n");
4489 } 4502 }
4490 DoBackup = false; 4503 DoBackup = false;
4491 if (Info.Ringtone) { 4504 if (Info.Ringtone) {
4492 printmsg("Checking user ringtones\n"); 4505 printmsg("Checking user ringtones\n");
4493 Ringtone.Location = 1; 4506 Ringtone.Location = 1;
4494 Ringtone.Format = 0; 4507 Ringtone.Format = 0;
4495 error=Phone->GetRingtone(&s,&Ringtone,false); 4508 error=Phone->GetRingtone(&s,&Ringtone,false);
4496 if (error==ERR_EMPTY || error == ERR_NONE) { 4509 if (error==ERR_EMPTY || error == ERR_NONE) {
4497 if (answer_yes(" Backup user ringtones")) DoBackup = true; 4510 if (answer_yes(" Backup user ringtones")) DoBackup = true;
4498 } 4511 }
4499 } 4512 }
4500 if (DoBackup) { 4513 if (DoBackup) {
4501 used = 0; 4514 used = 0;
4502 i= 1; 4515 i= 1;
4503 printmsgerr(" Reading : "); 4516 printmsgerr(" Reading : ");
4504 while (error == ERR_NONE || error == ERR_EMPTY) { 4517 while (error == ERR_NONE || error == ERR_EMPTY) {
4505 if (error == ERR_NONE) { 4518 if (error == ERR_NONE) {
4506 if (used < GSM_BACKUP_MAX_RINGTONES) { 4519 if (used < GSM_BACKUP_MAX_RINGTONES) {
4507 Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); 4520 Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone));
4508 if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); 4521 if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY);
4509 Backup.Ringtone[used+1] = NULL; 4522 Backup.Ringtone[used+1] = NULL;
4510 } else { 4523 } else {
4511 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); 4524 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES");
4512 GSM_Terminate(); 4525 GSM_Terminate();
4513 exit(-1); 4526 exit(-1);
4514 } 4527 }
4515 *Backup.Ringtone[used]=Ringtone; 4528 *Backup.Ringtone[used]=Ringtone;
4516 used ++; 4529 used ++;
4517 } 4530 }
4518 i++; 4531 i++;
4519 Ringtone.Location = i; 4532 Ringtone.Location = i;
4520 Ringtone.Format = 0; 4533 Ringtone.Format = 0;
4521 error=Phone->GetRingtone(&s,&Ringtone,false); 4534 error=Phone->GetRingtone(&s,&Ringtone,false);
4522 printmsgerr("*"); 4535 printmsgerr("*");
4523 if (gshutdown) { 4536 if (gshutdown) {
4524 GSM_Terminate(); 4537 GSM_Terminate();
4525 exit(0); 4538 exit(0);
4526 } 4539 }
4527 } 4540 }
4528 printmsgerr("\n"); 4541 printmsgerr("\n");
4529 } 4542 }
4530 DoBackup = false; 4543 DoBackup = false;
4531 if (Info.Profiles) { 4544 if (Info.Profiles) {
4532 printmsg("Checking phone profiles\n"); 4545 printmsg("Checking phone profiles\n");
4533 Profile.Location = 1; 4546 Profile.Location = 1;
4534 error = Phone->GetProfile(&s,&Profile); 4547 error = Phone->GetProfile(&s,&Profile);
4535 if (error == ERR_NONE) { 4548 if (error == ERR_NONE) {
4536 if (answer_yes(" Backup phone profiles")) DoBackup = true; 4549 if (answer_yes(" Backup phone profiles")) DoBackup = true;
4537 } 4550 }
4538 } 4551 }
4539 if (DoBackup) { 4552 if (DoBackup) {
4540 used = 0; 4553 used = 0;
4541 printmsgerr(" Reading: "); 4554 printmsgerr(" Reading: ");
4542 while (true) { 4555 while (true) {
4543 Profile.Location = used + 1; 4556 Profile.Location = used + 1;
4544 error = Phone->GetProfile(&s,&Profile); 4557 error = Phone->GetProfile(&s,&Profile);
4545 if (error != ERR_NONE) break; 4558 if (error != ERR_NONE) break;
4546 if (used < GSM_BACKUP_MAX_PROFILES) { 4559 if (used < GSM_BACKUP_MAX_PROFILES) {
4547 Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); 4560 Backup.Profiles[used] = malloc(sizeof(GSM_Profile));
4548 if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); 4561 if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY);
4549 Backup.Profiles[used + 1] = NULL; 4562 Backup.Profiles[used + 1] = NULL;
4550 } else { 4563 } else {
4551 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); 4564 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES");
4552 GSM_Terminate(); 4565 GSM_Terminate();
4553 exit(-1); 4566 exit(-1);
4554 } 4567 }
4555 *Backup.Profiles[used]=Profile; 4568 *Backup.Profiles[used]=Profile;
4556 used++; 4569 used++;
4557 printmsgerr("*"); 4570 printmsgerr("*");
4558 } 4571 }
4559 printmsgerr("\n"); 4572 printmsgerr("\n");
4560 } 4573 }
4561 DoBackup = false; 4574 DoBackup = false;
4562 if (Info.FMStation) { 4575 if (Info.FMStation) {
4563 printmsg("Checking FM stations\n"); 4576 printmsg("Checking FM stations\n");
4564 FMStation.Location = 1; 4577 FMStation.Location = 1;
4565 error = Phone->GetFMStation(&s,&FMStation); 4578 error = Phone->GetFMStation(&s,&FMStation);
4566 if (error == ERR_NONE || error == ERR_EMPTY) { 4579 if (error == ERR_NONE || error == ERR_EMPTY) {
4567 if (answer_yes(" Backup phone FM stations")) DoBackup=true; 4580 if (answer_yes(" Backup phone FM stations")) DoBackup=true;
4568 } 4581 }
4569 } 4582 }
4570 if (DoBackup) { 4583 if (DoBackup) {
4571 used= 0; 4584 used= 0;
4572 i = 1; 4585 i = 1;
4573 printmsgerr(" Reading: "); 4586 printmsgerr(" Reading: ");
4574 while (error == ERR_NONE || error == ERR_EMPTY) { 4587 while (error == ERR_NONE || error == ERR_EMPTY) {
4575 error = Phone->GetFMStation(&s,&FMStation); 4588 error = Phone->GetFMStation(&s,&FMStation);
4576 if (error == ERR_NONE) { 4589 if (error == ERR_NONE) {
4577 if (used < GSM_BACKUP_MAX_FMSTATIONS) { 4590 if (used < GSM_BACKUP_MAX_FMSTATIONS) {
4578 Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); 4591 Backup.FMStation[used] = malloc(sizeof(GSM_FMStation));
4579 if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); 4592 if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY);
4580 Backup.FMStation[used + 1] = NULL; 4593 Backup.FMStation[used + 1] = NULL;
4581 } else { 4594 } else {
4582 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); 4595 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS");
4583 GSM_Terminate(); 4596 GSM_Terminate();
4584 exit(-1); 4597 exit(-1);
4585 } 4598 }
4586 *Backup.FMStation[used]=FMStation; 4599 *Backup.FMStation[used]=FMStation;
4587 used++; 4600 used++;
4588 } 4601 }
4589 i++; 4602 i++;
4590 FMStation.Location = i; 4603 FMStation.Location = i;
4591 printmsgerr("*"); 4604 printmsgerr("*");
4592 } 4605 }
4593 printmsgerr("\n"); 4606 printmsgerr("\n");
4594 } 4607 }
4595 DoBackup = false; 4608 DoBackup = false;
4596 if (Info.GPRSPoint) { 4609 if (Info.GPRSPoint) {
4597 printmsg("Checking GPRS access points\n"); 4610 printmsg("Checking GPRS access points\n");
4598 GPRSPoint.Location = 1; 4611 GPRSPoint.Location = 1;
4599 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 4612 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
4600 if (error == ERR_NONE || error == ERR_EMPTY) { 4613 if (error == ERR_NONE || error == ERR_EMPTY) {
4601 if (answer_yes(" Backup GPRS access points")) DoBackup = true; 4614 if (answer_yes(" Backup GPRS access points")) DoBackup = true;
4602 } 4615 }
4603 } 4616 }
4604 if (DoBackup) { 4617 if (DoBackup) {
4605 used= 0; 4618 used= 0;
4606 i = 1; 4619 i = 1;
4607 printmsgerr(" Reading: "); 4620 printmsgerr(" Reading: ");
4608 while (error == ERR_NONE || error == ERR_EMPTY) { 4621 while (error == ERR_NONE || error == ERR_EMPTY) {
4609 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 4622 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
4610 if (error == ERR_NONE) { 4623 if (error == ERR_NONE) {
4611 if (used < GSM_BACKUP_MAX_GPRSPOINT) { 4624 if (used < GSM_BACKUP_MAX_GPRSPOINT) {
4612 Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); 4625 Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint));
4613 if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); 4626 if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY);
4614 Backup.GPRSPoint[used + 1] = NULL; 4627 Backup.GPRSPoint[used + 1] = NULL;
4615 } else { 4628 } else {
4616 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); 4629 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT");
4617 GSM_Terminate(); 4630 GSM_Terminate();
4618 exit(-1); 4631 exit(-1);
4619 } 4632 }
4620 *Backup.GPRSPoint[used]=GPRSPoint; 4633 *Backup.GPRSPoint[used]=GPRSPoint;
4621 used++; 4634 used++;
4622 } 4635 }
4623 i++; 4636 i++;
4624 GPRSPoint.Location = i; 4637 GPRSPoint.Location = i;
4625 printmsgerr("*"); 4638 printmsgerr("*");
4626 } 4639 }
4627 printmsgerr("\n"); 4640 printmsgerr("\n");
4628 } 4641 }
4629 4642
4630 GSM_Terminate(); 4643 GSM_Terminate();
4631 4644
4632 GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode); 4645 GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode);
4633 GSM_FreeBackup(&Backup); 4646 GSM_FreeBackup(&Backup);
4634} 4647}
4635 4648
4636static void Restore(int argc, char *argv[]) 4649static void Restore(int argc, char *argv[])
4637{ 4650{
4638 GSM_Backup Backup; 4651 GSM_Backup Backup;
4639 GSM_FMStation FMStation; 4652 GSM_FMStation FMStation;
4640 GSM_DateTime date_time; 4653 GSM_DateTime date_time;
4641 GSM_CalendarEntryCalendar; 4654 GSM_CalendarEntryCalendar;
4642 GSM_Bitmap Bitmap; 4655 GSM_Bitmap Bitmap;
4643 GSM_Ringtone Ringtone; 4656 GSM_Ringtone Ringtone;
4644 GSM_MemoryEntry Pbk; 4657 GSM_MemoryEntry Pbk;
4645 GSM_MemoryStatusMemStatus; 4658 GSM_MemoryStatusMemStatus;
4646 GSM_ToDoEntry ToDo; 4659 GSM_ToDoEntry ToDo;
4647 GSM_ToDoStatus ToDoStatus; 4660 GSM_ToDoStatus ToDoStatus;
4661 GSM_NoteEntry Note;
4648 GSM_Profile Profile; 4662 GSM_Profile Profile;
4649 GSM_MultiWAPSettingsSettings; 4663 GSM_MultiWAPSettingsSettings;
4650 GSM_GPRSAccessPointGPRSPoint; 4664 GSM_GPRSAccessPointGPRSPoint;
4651 GSM_WAPBookmark Bookmark; 4665 GSM_WAPBookmark Bookmark;
4652 int i, used, max = 0; 4666 int i, used, max = 0;
4653 bool Past = true; 4667 bool Past = true;
4654 bool Found, DoRestore; 4668 bool Found, DoRestore;
4655 4669
4656 error=GSM_ReadBackupFile(argv[2],&Backup); 4670 error=GSM_ReadBackupFile(argv[2],&Backup);
4657 if (error!=ERR_NOTIMPLEMENTED) { 4671 if (error!=ERR_NOTIMPLEMENTED) {
4658 Print_Error(error); 4672 Print_Error(error);
4659 } else { 4673 } else {
4660 printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n"); 4674 printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n");
4661 } 4675 }
4662 4676
4663 signal(SIGINT, interrupt); 4677 signal(SIGINT, interrupt);
4664 printmsgerr("Press Ctrl+C to break...\n"); 4678 printmsgerr("Press Ctrl+C to break...\n");
4665 4679
4666 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 4680 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
4667 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 4681 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
4668 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 4682 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
4669 if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator); 4683 if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator);
4670 4684
4671 if (Backup.MD5Calculated[0]!=0) { 4685 if (Backup.MD5Calculated[0]!=0) {
4672 dbgprintf("\"%s\"\n",Backup.MD5Original); 4686 dbgprintf("\"%s\"\n",Backup.MD5Original);
4673 dbgprintf("\"%s\"\n",Backup.MD5Calculated); 4687 dbgprintf("\"%s\"\n",Backup.MD5Calculated);
4674 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { 4688 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) {
4675 if (!answer_yes("Checksum in backup file do not match. Continue")) return; 4689 if (!answer_yes("Checksum in backup file do not match. Continue")) return;
4676 } 4690 }
4677 } 4691 }
4678 4692
4679 GSM_Init(true); 4693 GSM_Init(true);
4680 4694
4681 DoRestore = false; 4695 DoRestore = false;
4682 if (Backup.PhonePhonebook[0] != NULL) { 4696 if (Backup.PhonePhonebook[0] != NULL) {
4683 MemStatus.MemoryType = MEM_ME; 4697 MemStatus.MemoryType = MEM_ME;
4684 error=Phone->GetMemoryStatus(&s, &MemStatus); 4698 error=Phone->GetMemoryStatus(&s, &MemStatus);
4685 if (error==ERR_NONE) { 4699 if (error==ERR_NONE) {
4686 max = 0; 4700 max = 0;
4687 while (Backup.PhonePhonebook[max]!=NULL) max++; 4701 while (Backup.PhonePhonebook[max]!=NULL) max++;
4688 printmsgerr("%i entries in backup file\n",max); 4702 printmsgerr("%i entries in backup file\n",max);
4689 /* LR if (answer_yes("Restore phone phonebook")) */DoRestore = true; 4703 /* LR if (answer_yes("Restore phone phonebook")) */DoRestore = true;
4690 } 4704 }
4691 } 4705 }
4692 if (DoRestore) { 4706 if (DoRestore) {
4693 used = 0; 4707 used = 0;
4694 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 4708 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
4695 Pbk.MemoryType = MEM_ME; 4709 Pbk.MemoryType = MEM_ME;
4696 Pbk.Location= i + 1; 4710 Pbk.Location= i + 1;
4697 Pbk.EntriesNum= 0; 4711 Pbk.EntriesNum= 0;
4698 if (used<max) { 4712 if (used<max) {
4699 if (Backup.PhonePhonebook[used]->Location == Pbk.Location) { 4713 if (Backup.PhonePhonebook[used]->Location == Pbk.Location) {
4700 Pbk = *Backup.PhonePhonebook[used]; 4714 Pbk = *Backup.PhonePhonebook[used];
4701 used++; 4715 used++;
4702 dbgprintf("Location %i\n",Pbk.Location); 4716 dbgprintf("Location %i\n",Pbk.Location);
4703 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); 4717 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
4704 } 4718 }
4705 } 4719 }
4706 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); 4720 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
4707 Print_Error(error); 4721 Print_Error(error);
4708 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 4722 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
4709 if (gshutdown) { 4723 if (gshutdown) {
4710 GSM_Terminate(); 4724 GSM_Terminate();
4711 exit(0); 4725 exit(0);
4712 } 4726 }
4713 } 4727 }
4714 printmsgerr("\n"); 4728 printmsgerr("\n");
4715 } 4729 }
4716 4730
4717 DoRestore = false; 4731 DoRestore = false;
4718 if (Backup.SIMPhonebook[0] != NULL) { 4732 if (Backup.SIMPhonebook[0] != NULL) {
4719 MemStatus.MemoryType = MEM_SM; 4733 MemStatus.MemoryType = MEM_SM;
4720 error=Phone->GetMemoryStatus(&s, &MemStatus); 4734 error=Phone->GetMemoryStatus(&s, &MemStatus);
4721 if (error==ERR_NONE) { 4735 if (error==ERR_NONE) {
4722 max = 0; 4736 max = 0;
4723 while (Backup.SIMPhonebook[max]!=NULL) max++; 4737 while (Backup.SIMPhonebook[max]!=NULL) max++;
4724 printmsgerr("%i entries in backup file\n",max); 4738 printmsgerr("%i entries in backup file\n",max);
4725 if (answer_yes("Restore SIM phonebook")) DoRestore = true; 4739 if (answer_yes("Restore SIM phonebook")) DoRestore = true;
4726 } 4740 }
4727 } 4741 }
4728 if (DoRestore) { 4742 if (DoRestore) {
4729 used = 0; 4743 used = 0;
4730 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 4744 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
4731 Pbk.MemoryType = MEM_SM; 4745 Pbk.MemoryType = MEM_SM;
4732 Pbk.Location= i + 1; 4746 Pbk.Location= i + 1;
4733 Pbk.EntriesNum= 0; 4747 Pbk.EntriesNum= 0;
4734 if (used<max) { 4748 if (used<max) {
4735 if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { 4749 if (Backup.SIMPhonebook[used]->Location == Pbk.Location) {
4736 Pbk = *Backup.SIMPhonebook[used]; 4750 Pbk = *Backup.SIMPhonebook[used];
4737 used++; 4751 used++;
4738 dbgprintf("Location %i\n",Pbk.Location); 4752 dbgprintf("Location %i\n",Pbk.Location);
4739 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); 4753 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
4740 } 4754 }
4741 } 4755 }
4742 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); 4756 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
4743 Print_Error(error); 4757 Print_Error(error);
4744 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 4758 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
4745 if (gshutdown) { 4759 if (gshutdown) {
4746 GSM_Terminate(); 4760 GSM_Terminate();
4747 exit(0); 4761 exit(0);
4748 } 4762 }
4749 } 4763 }
4750 printmsgerr("\n"); 4764 printmsgerr("\n");
4751 } 4765 }
4752 4766
4753 DoRestore = false; 4767 DoRestore = false;
4754 if (Backup.CallerLogos[0] != NULL) { 4768 if (Backup.CallerLogos[0] != NULL) {
4755 Bitmap.Type = GSM_CallerGroupLogo; 4769 Bitmap.Type = GSM_CallerGroupLogo;
4756 Bitmap.Location = 1; 4770 Bitmap.Location = 1;
4757 error=Phone->GetBitmap(&s,&Bitmap); 4771 error=Phone->GetBitmap(&s,&Bitmap);
4758 if (error == ERR_NONE) { 4772 if (error == ERR_NONE) {
4759 if (answer_yes("Restore caller groups and logos")) DoRestore = true; 4773 if (answer_yes("Restore caller groups and logos")) DoRestore = true;
4760 } 4774 }
4761 } 4775 }
4762 if (DoRestore) { 4776 if (DoRestore) {
4763 max = 0; 4777 max = 0;
4764 while (Backup.CallerLogos[max]!=NULL) max++; 4778 while (Backup.CallerLogos[max]!=NULL) max++;
4765 for (i=0;i<max;i++) { 4779 for (i=0;i<max;i++) {
4766 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); 4780 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]);
4767 Print_Error(error); 4781 Print_Error(error);
4768 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4782 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4769 if (gshutdown) { 4783 if (gshutdown) {
4770 GSM_Terminate(); 4784 GSM_Terminate();
4771 exit(0); 4785 exit(0);
4772 } 4786 }
4773 } 4787 }
4774 printmsgerr("\n"); 4788 printmsgerr("\n");
4775 } 4789 }
4776 4790
4777 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { 4791 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
4778 if ( true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) { 4792 if ( true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) {
4779 GSM_GetCurrentDateTime(&date_time); 4793 GSM_GetCurrentDateTime(&date_time);
4780 4794
4781 error=Phone->SetDateTime(&s, &date_time); 4795 error=Phone->SetDateTime(&s, &date_time);
4782 Print_Error(error); 4796 Print_Error(error);
4783 } 4797 }
4784 } 4798 }
4785 DoRestore = false; 4799 DoRestore = false;
4786 if (Backup.Calendar[0] != NULL) { 4800 if (Backup.Calendar[0] != NULL) {
4787 /* N6110 doesn't support getting calendar status */ 4801 /* N6110 doesn't support getting calendar status */
4788 error = Phone->GetNextCalendar(&s,&Calendar,true); 4802 error = Phone->GetNextCalendar(&s,&Calendar,true);
4789 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { 4803 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
4790 max = 0; 4804 max = 0;
4791 while (Backup.Calendar[max] != NULL) max++; 4805 while (Backup.Calendar[max] != NULL) max++;
4792 printmsgerr("%i entries in backup file\n",max); 4806 printmsgerr("%i entries in backup file\n",max);
4793 // LR 4807 // LR
4794 //if (answer_yes("Restore calendar notes")) { 4808 //if (answer_yes("Restore calendar notes")) {
4795 //Past = answer_yes("Restore notes from the past"); 4809 //Past = answer_yes("Restore notes from the past");
4796 DoRestore = true; 4810 DoRestore = true;
4797 //} 4811 //}
4798 } 4812 }
4799 } 4813 }
4800 if (DoRestore) { 4814 if (DoRestore) {
4801 printmsgerr("Deleting old notes: "); 4815 printmsgerr("Deleting old notes: ");
4802 error = Phone->DeleteAllCalendar(&s); 4816 error = Phone->DeleteAllCalendar(&s);
4803 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4817 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4804 while (1) { 4818 while (1) {
4805 error = Phone->GetNextCalendar(&s,&Calendar,true); 4819 error = Phone->GetNextCalendar(&s,&Calendar,true);
4806 if (error != ERR_NONE) break; 4820 if (error != ERR_NONE) break;
4807 error = Phone->DeleteCalendar(&s,&Calendar); 4821 error = Phone->DeleteCalendar(&s,&Calendar);
4808 Print_Error(error); 4822 Print_Error(error);
4809 printmsgerr("*"); 4823 printmsgerr("*");
4810 } 4824 }
4811 printmsgerr("\n"); 4825 printmsgerr("\n");
4812 } else { 4826 } else {
4813 printmsgerr("Done\n"); 4827 printmsgerr("Done\n");
4814 Print_Error(error); 4828 Print_Error(error);
4815 } 4829 }
4816 4830
4817 for (i=0;i<max;i++) { 4831 for (i=0;i<max;i++) {
4818 if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; 4832 if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue;
4819 4833
4820 Calendar = *Backup.Calendar[i]; 4834 Calendar = *Backup.Calendar[i];
4821 error=Phone->AddCalendar(&s,&Calendar); 4835 error=Phone->AddCalendar(&s,&Calendar);
4822 Print_Error(error); 4836 Print_Error(error);
4823 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4837 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4824 if (gshutdown) { 4838 if (gshutdown) {
4825 GSM_Terminate(); 4839 GSM_Terminate();
4826 exit(0); 4840 exit(0);
4827 } 4841 }
4828 } 4842 }
4829 printmsgerr("\n"); 4843 printmsgerr("\n");
4830 } 4844 }
4831 4845
4832 DoRestore = false; 4846 DoRestore = false;
4833 if (Backup.ToDo[0] != NULL) { 4847 if (Backup.ToDo[0] != NULL) {
4834 error = Phone->GetToDoStatus(&s,&ToDoStatus); 4848 error = Phone->GetToDoStatus(&s,&ToDoStatus);
4835 if (error == ERR_NONE) { 4849 if (error == ERR_NONE) {
4836 max = 0; 4850 max = 0;
4837 while (Backup.ToDo[max]!=NULL) max++; 4851 while (Backup.ToDo[max]!=NULL) max++;
4838 printmsgerr("%i entries in backup file\n",max); 4852 printmsgerr("%i entries in backup file\n",max);
4839 4853
4840 //LR if (answer_yes("Restore ToDo")) 4854 //LR if (answer_yes("Restore ToDo"))
4841 DoRestore = true; 4855 DoRestore = true;
4842 } 4856 }
4843 } 4857 }
4844 if (DoRestore) { 4858 if (DoRestore) {
4845 ToDo = *Backup.ToDo[0]; 4859 ToDo = *Backup.ToDo[0];
4846 error = Phone->SetToDo(&s,&ToDo); 4860 error = Phone->SetToDo(&s,&ToDo);
4847 } 4861 }
4848 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { 4862 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) {
4849 printmsgerr("Deleting old ToDo: "); 4863 printmsgerr("Deleting old ToDo: ");
4850 error=Phone->DeleteAllToDo(&s); 4864 error=Phone->DeleteAllToDo(&s);
4851 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4865 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4852 while (1) { 4866 while (1) {
4853 error = Phone->GetNextToDo(&s,&ToDo,true); 4867 error = Phone->GetNextToDo(&s,&ToDo,true);
4854 if (error != ERR_NONE) break; 4868 if (error != ERR_NONE) break;
4855 error = Phone->DeleteToDo(&s,&ToDo); 4869 error = Phone->DeleteToDo(&s,&ToDo);
4856 Print_Error(error); 4870 Print_Error(error);
4857 printmsgerr("*"); 4871 printmsgerr("*");
4858 } 4872 }
4859 printmsgerr("\n"); 4873 printmsgerr("\n");
4860 } else { 4874 } else {
4861 printmsgerr("Done\n"); 4875 printmsgerr("Done\n");
4862 Print_Error(error); 4876 Print_Error(error);
4863 } 4877 }
4864 4878
4865 for (i=0;i<max;i++) { 4879 for (i=0;i<max;i++) {
4866 ToDo = *Backup.ToDo[i]; 4880 ToDo = *Backup.ToDo[i];
4867 ToDo.Location = 0; 4881 ToDo.Location = 0;
4868 error=Phone->AddToDo(&s,&ToDo); 4882 error=Phone->AddToDo(&s,&ToDo);
4869 Print_Error(error); 4883 Print_Error(error);
4870 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4884 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4871 if (gshutdown) { 4885 if (gshutdown) {
4872 GSM_Terminate(); 4886 GSM_Terminate();
4873 exit(0); 4887 exit(0);
4874 } 4888 }
4875 } 4889 }
4876 printmsgerr("\n"); 4890 printmsgerr("\n");
4877 } else if (DoRestore) { 4891 } else if (DoRestore) {
4878 /* At first delete entries, that were deleted */ 4892 /* At first delete entries, that were deleted */
4879 used = 0; 4893 used = 0;
4880 error = Phone->GetNextToDo(&s,&ToDo,true); 4894 error = Phone->GetNextToDo(&s,&ToDo,true);
4881 while (error == ERR_NONE) { 4895 while (error == ERR_NONE) {
4882 used++; 4896 used++;
4883 Found = false; 4897 Found = false;
4884 for (i=0;i<max;i++) { 4898 for (i=0;i<max;i++) {
4885 if (Backup.ToDo[i]->Location == ToDo.Location) { 4899 if (Backup.ToDo[i]->Location == ToDo.Location) {
4886 Found = true; 4900 Found = true;
4887 break; 4901 break;
4888 } 4902 }
4889 } 4903 }
4890 if (!Found) { 4904 if (!Found) {
4891 error=Phone->DeleteToDo(&s,&ToDo); 4905 error=Phone->DeleteToDo(&s,&ToDo);
4892 Print_Error(error); 4906 Print_Error(error);
4893 } 4907 }
4894 error = Phone->GetNextToDo(&s,&ToDo,false); 4908 error = Phone->GetNextToDo(&s,&ToDo,false);
4895 printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); 4909 printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used);
4896 if (gshutdown) { 4910 if (gshutdown) {
4897 GSM_Terminate(); 4911 GSM_Terminate();
4898 exit(0); 4912 exit(0);
4899 } 4913 }
4900 } 4914 }
4901 printmsgerr("\n"); 4915 printmsgerr("\n");
4902 4916
4903 /* Now write modified/new entries */ 4917 /* Now write modified/new entries */
4904 for (i=0;i<max;i++) { 4918 for (i=0;i<max;i++) {
4905 ToDo = *Backup.ToDo[i]; 4919 ToDo = *Backup.ToDo[i];
4906 error = Phone->SetToDo(&s,&ToDo); 4920 error = Phone->SetToDo(&s,&ToDo);
4907 Print_Error(error); 4921 Print_Error(error);
4908 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4922 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4909 if (gshutdown) { 4923 if (gshutdown) {
4910 GSM_Terminate(); 4924 GSM_Terminate();
4911 exit(0); 4925 exit(0);
4912 } 4926 }
4913 } 4927 }
4914 printmsgerr("\n"); 4928 printmsgerr("\n");
4915 } 4929 }
4916 4930
4931 DoRestore = false;
4932 if (Backup.ToDo[0] != NULL) {
4933 error = Phone->GetNotesStatus(&s,&ToDoStatus);
4934 if (error == ERR_NONE) {
4935 max = 0;
4936 while (Backup.Note[max]!=NULL) max++;
4937 printmsgerr("%i entries in backup file\n",max);
4938
4939 if (answer_yes("Restore Notes")) DoRestore = true;
4940 }
4941 }
4942 if (DoRestore) {
4943 printmsgerr("Deleting old Notes: ");
4944 while (1) {
4945 error = Phone->GetNextNote(&s,&Note,true);
4946 if (error != ERR_NONE) break;
4947 error = Phone->DeleteNote(&s,&Note);
4948 Print_Error(error);
4949 printmsgerr("*");
4950 }
4951 printmsgerr("\n");
4952
4953 for (i=0;i<max;i++) {
4954 Note = *Backup.Note[i];
4955 Note.Location = 0;
4956 error=Phone->AddNote(&s,&Note);
4957 Print_Error(error);
4958 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4959 if (gshutdown) {
4960 GSM_Terminate();
4961 exit(0);
4962 }
4963 }
4964 printmsgerr("\n");
4965 }
4966
4917 if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { 4967 if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) {
4918 max = 0; 4968 max = 0;
4919 while (Backup.SMSC[max]!=NULL) max++; 4969 while (Backup.SMSC[max]!=NULL) max++;
4920 for (i=0;i<max;i++) { 4970 for (i=0;i<max;i++) {
4921 error=Phone->SetSMSC(&s,Backup.SMSC[i]); 4971 error=Phone->SetSMSC(&s,Backup.SMSC[i]);
4922 Print_Error(error); 4972 Print_Error(error);
4923 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4973 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4924 if (gshutdown) { 4974 if (gshutdown) {
4925 GSM_Terminate(); 4975 GSM_Terminate();
4926 exit(0); 4976 exit(0);
4927 } 4977 }
4928 } 4978 }
4929 printmsgerr("\n"); 4979 printmsgerr("\n");
4930 } 4980 }
4931 if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { 4981 if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) {
4932 error=Phone->SetBitmap(&s,Backup.StartupLogo); 4982 error=Phone->SetBitmap(&s,Backup.StartupLogo);
4933 Print_Error(error); 4983 Print_Error(error);
4934 } 4984 }
4935 if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { 4985 if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) {
4936 error=Phone->SetBitmap(&s,Backup.OperatorLogo); 4986 error=Phone->SetBitmap(&s,Backup.OperatorLogo);
4937 Print_Error(error); 4987 Print_Error(error);
4938 } 4988 }
4939 DoRestore = false; 4989 DoRestore = false;
4940 if (Backup.WAPBookmark[0] != NULL) { 4990 if (Backup.WAPBookmark[0] != NULL) {
4941 Bookmark.Location = 1; 4991 Bookmark.Location = 1;
4942 error = Phone->GetWAPBookmark(&s,&Bookmark); 4992 error = Phone->GetWAPBookmark(&s,&Bookmark);
4943 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 4993 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
4944 if (answer_yes("Restore WAP bookmarks")) DoRestore = true; 4994 if (answer_yes("Restore WAP bookmarks")) DoRestore = true;
4945 } 4995 }
4946 } 4996 }
4947 if (DoRestore) { 4997 if (DoRestore) {
4948 printmsgerr("Deleting old bookmarks: "); 4998 printmsgerr("Deleting old bookmarks: ");
4949 /* One thing to explain: DCT4 phones seems to have bug here. 4999 /* One thing to explain: DCT4 phones seems to have bug here.
4950 * When delete for example first bookmark, phone change 5000 * When delete for example first bookmark, phone change
4951 * numeration for getting frame, not for deleting. So, we try to 5001 * numeration for getting frame, not for deleting. So, we try to
4952 * get 1'st bookmark. Inside frame is "correct" location. We use 5002 * get 1'st bookmark. Inside frame is "correct" location. We use
4953 * it later 5003 * it later
4954 */ 5004 */
4955 while (error==ERR_NONE) { 5005 while (error==ERR_NONE) {
4956 error = Phone->DeleteWAPBookmark(&s,&Bookmark); 5006 error = Phone->DeleteWAPBookmark(&s,&Bookmark);
4957 Bookmark.Location = 1; 5007 Bookmark.Location = 1;
4958 error = Phone->GetWAPBookmark(&s,&Bookmark); 5008 error = Phone->GetWAPBookmark(&s,&Bookmark);
4959 printmsgerr("*"); 5009 printmsgerr("*");
4960 } 5010 }
4961 printmsgerr("\n"); 5011 printmsgerr("\n");
4962 max = 0; 5012 max = 0;
4963 while (Backup.WAPBookmark[max]!=NULL) max++; 5013 while (Backup.WAPBookmark[max]!=NULL) max++;
4964 for (i=0;i<max;i++) { 5014 for (i=0;i<max;i++) {
4965 Bookmark = *Backup.WAPBookmark[i]; 5015 Bookmark = *Backup.WAPBookmark[i];
4966 Bookmark.Location = 0; 5016 Bookmark.Location = 0;
4967 error=Phone->SetWAPBookmark(&s,&Bookmark); 5017 error=Phone->SetWAPBookmark(&s,&Bookmark);
4968 Print_Error(error); 5018 Print_Error(error);
4969 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5019 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4970 if (gshutdown) { 5020 if (gshutdown) {
4971 GSM_Terminate(); 5021 GSM_Terminate();
4972 exit(0); 5022 exit(0);
4973 } 5023 }
4974 } 5024 }
4975 printmsgerr("\n"); 5025 printmsgerr("\n");
4976 } 5026 }
4977 DoRestore = false; 5027 DoRestore = false;
4978 if (Backup.WAPSettings[0] != NULL) { 5028 if (Backup.WAPSettings[0] != NULL) {
4979 Settings.Location = 1; 5029 Settings.Location = 1;
4980 error = Phone->GetWAPSettings(&s,&Settings); 5030 error = Phone->GetWAPSettings(&s,&Settings);
4981 if (error == ERR_NONE) { 5031 if (error == ERR_NONE) {
4982 if (answer_yes("Restore WAP settings")) DoRestore = true; 5032 if (answer_yes("Restore WAP settings")) DoRestore = true;
4983 } 5033 }
4984 } 5034 }
4985 if (DoRestore) { 5035 if (DoRestore) {
4986 max = 0; 5036 max = 0;
4987 while (Backup.WAPSettings[max]!=NULL) max++; 5037 while (Backup.WAPSettings[max]!=NULL) max++;
4988 for (i=0;i<max;i++) { 5038 for (i=0;i<max;i++) {
4989 error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); 5039 error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]);
4990 Print_Error(error); 5040 Print_Error(error);
4991 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5041 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4992 if (gshutdown) { 5042 if (gshutdown) {
4993 GSM_Terminate(); 5043 GSM_Terminate();
4994 exit(0); 5044 exit(0);
4995 } 5045 }
4996 } 5046 }
4997 printmsgerr("\n"); 5047 printmsgerr("\n");
4998 } 5048 }
4999 DoRestore = false; 5049 DoRestore = false;
5000 if (Backup.MMSSettings[0] != NULL) { 5050 if (Backup.MMSSettings[0] != NULL) {
5001 Settings.Location = 1; 5051 Settings.Location = 1;
5002 error = Phone->GetMMSSettings(&s,&Settings); 5052 error = Phone->GetMMSSettings(&s,&Settings);
5003 if (error == ERR_NONE) { 5053 if (error == ERR_NONE) {
5004 if (answer_yes("Restore MMS settings")) DoRestore = true; 5054 if (answer_yes("Restore MMS settings")) DoRestore = true;
5005 } 5055 }
5006 } 5056 }
5007 if (DoRestore) { 5057 if (DoRestore) {
5008 max = 0; 5058 max = 0;
5009 while (Backup.MMSSettings[max]!=NULL) max++; 5059 while (Backup.MMSSettings[max]!=NULL) max++;
5010 for (i=0;i<max;i++) { 5060 for (i=0;i<max;i++) {
5011 error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); 5061 error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]);
5012 Print_Error(error); 5062 Print_Error(error);
5013 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5063 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5014 if (gshutdown) { 5064 if (gshutdown) {
5015 GSM_Terminate(); 5065 GSM_Terminate();
5016 exit(0); 5066 exit(0);
5017 } 5067 }
5018 } 5068 }
5019 printmsgerr("\n"); 5069 printmsgerr("\n");
5020 } 5070 }
5021 DoRestore = false; 5071 DoRestore = false;
5022 if (Backup.Ringtone[0] != NULL) { 5072 if (Backup.Ringtone[0] != NULL) {
5023 Ringtone.Location = 1; 5073 Ringtone.Location = 1;
5024 Ringtone.Format = 0; 5074 Ringtone.Format = 0;
5025 error = Phone->GetRingtone(&s,&Ringtone,false); 5075 error = Phone->GetRingtone(&s,&Ringtone,false);
5026 if (error == ERR_NONE || error ==ERR_EMPTY) { 5076 if (error == ERR_NONE || error ==ERR_EMPTY) {
5027 if (Phone->DeleteUserRingtones != NOTSUPPORTED) { 5077 if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
5028 if (answer_yes("Delete all user ringtones")) DoRestore = true; 5078 if (answer_yes("Delete all user ringtones")) DoRestore = true;
5029 } 5079 }
5030 } 5080 }
5031 } 5081 }
5032 if (DoRestore) { 5082 if (DoRestore) {
5033 printmsgerr("Deleting: "); 5083 printmsgerr("Deleting: ");
5034 error=Phone->DeleteUserRingtones(&s); 5084 error=Phone->DeleteUserRingtones(&s);
5035 Print_Error(error); 5085 Print_Error(error);
5036 printmsgerr("Done\n"); 5086 printmsgerr("Done\n");
5037 DoRestore = false; 5087 DoRestore = false;
5038 if (answer_yes("Restore user ringtones")) DoRestore = true; 5088 if (answer_yes("Restore user ringtones")) DoRestore = true;
5039 } 5089 }
5040 if (DoRestore) { 5090 if (DoRestore) {
5041 max = 0; 5091 max = 0;
5042 while (Backup.Ringtone[max]!=NULL) max++; 5092 while (Backup.Ringtone[max]!=NULL) max++;
5043 for (i=0;i<max;i++) { 5093 for (i=0;i<max;i++) {
5044 error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); 5094 error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format);
5045 Print_Error(error); 5095 Print_Error(error);
5046 error=Phone->SetRingtone(&s,&Ringtone,&i); 5096 error=Phone->SetRingtone(&s,&Ringtone,&i);
5047 Print_Error(error); 5097 Print_Error(error);
5048 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5098 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5049 if (gshutdown) { 5099 if (gshutdown) {
5050 GSM_Terminate(); 5100 GSM_Terminate();
5051 exit(0); 5101 exit(0);
5052 } 5102 }
5053 } 5103 }
5054 printmsgerr("\n"); 5104 printmsgerr("\n");
5055 } 5105 }
5056 DoRestore = false; 5106 DoRestore = false;
5057 if (Backup.Profiles[0] != NULL) { 5107 if (Backup.Profiles[0] != NULL) {
5058 Profile.Location = 1; 5108 Profile.Location = 1;
5059 error = Phone->GetProfile(&s,&Profile); 5109 error = Phone->GetProfile(&s,&Profile);
5060 if (error == ERR_NONE) { 5110 if (error == ERR_NONE) {
5061 if (answer_yes("Restore profiles")) DoRestore = true; 5111 if (answer_yes("Restore profiles")) DoRestore = true;
5062 } 5112 }
5063 } 5113 }
5064 if (DoRestore) { 5114 if (DoRestore) {
5065 Profile.Location= 0; 5115 Profile.Location= 0;
5066 max = 0; 5116 max = 0;
5067 while (Backup.Profiles[max]!=NULL) max++; 5117 while (Backup.Profiles[max]!=NULL) max++;
5068 for (i=0;i<max;i++) { 5118 for (i=0;i<max;i++) {
5069 Profile= *Backup.Profiles[i]; 5119 Profile= *Backup.Profiles[i];
5070 error=Phone->SetProfile(&s,&Profile); 5120 error=Phone->SetProfile(&s,&Profile);
5071 Print_Error(error); 5121 Print_Error(error);
5072 if (gshutdown) { 5122 if (gshutdown) {
5073 GSM_Terminate(); 5123 GSM_Terminate();
5074 exit(0); 5124 exit(0);
5075 } 5125 }
5076 } 5126 }
5077 printmsgerr("\n"); 5127 printmsgerr("\n");
5078 } 5128 }
5079 DoRestore = false; 5129 DoRestore = false;
5080 if (Backup.FMStation[0] != NULL) { 5130 if (Backup.FMStation[0] != NULL) {
5081 FMStation.Location = 1; 5131 FMStation.Location = 1;
5082 error = Phone->GetFMStation(&s,&FMStation); 5132 error = Phone->GetFMStation(&s,&FMStation);
5083 if (error == ERR_NONE || error == ERR_EMPTY) { 5133 if (error == ERR_NONE || error == ERR_EMPTY) {
5084 if (answer_yes("Restore FM stations")) DoRestore = true; 5134 if (answer_yes("Restore FM stations")) DoRestore = true;
5085 } 5135 }
5086 } 5136 }
5087 if (DoRestore) { 5137 if (DoRestore) {
5088 printmsgerr("Deleting old FM stations: "); 5138 printmsgerr("Deleting old FM stations: ");
5089 error=Phone->ClearFMStations(&s); 5139 error=Phone->ClearFMStations(&s);
5090 Print_Error(error); 5140 Print_Error(error);
5091 printmsgerr("Done\n"); 5141 printmsgerr("Done\n");
5092 max = 0; 5142 max = 0;
5093 while (Backup.FMStation[max]!=NULL) max++; 5143 while (Backup.FMStation[max]!=NULL) max++;
5094 for (i=0;i<max;i++) { 5144 for (i=0;i<max;i++) {
5095 FMStation = *Backup.FMStation[i]; 5145 FMStation = *Backup.FMStation[i];
5096 error=Phone->SetFMStation(&s,&FMStation); 5146 error=Phone->SetFMStation(&s,&FMStation);
5097 Print_Error(error); 5147 Print_Error(error);
5098 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5148 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5099 if (gshutdown) { 5149 if (gshutdown) {
5100 GSM_Terminate(); 5150 GSM_Terminate();
5101 exit(0); 5151 exit(0);
5102 } 5152 }
5103 } 5153 }
5104 printmsgerr("\n"); 5154 printmsgerr("\n");
5105 } 5155 }
5106 DoRestore = false; 5156 DoRestore = false;
5107 if (Backup.GPRSPoint[0] != NULL) { 5157 if (Backup.GPRSPoint[0] != NULL) {
5108 GPRSPoint.Location = 1; 5158 GPRSPoint.Location = 1;
5109 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 5159 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
5110 if (error == ERR_NONE || error == ERR_EMPTY) { 5160 if (error == ERR_NONE || error == ERR_EMPTY) {
5111 if (answer_yes("Restore GPRS Points")) DoRestore = true; 5161 if (answer_yes("Restore GPRS Points")) DoRestore = true;
5112 } 5162 }
5113 } 5163 }
5114 if (DoRestore) { 5164 if (DoRestore) {
5115 max = 0; 5165 max = 0;
5116 while (Backup.GPRSPoint[max]!=NULL) max++; 5166 while (Backup.GPRSPoint[max]!=NULL) max++;
5117 for (i=0;i<max;i++) { 5167 for (i=0;i<max;i++) {
5118 error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); 5168 error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]);
5119 Print_Error(error); 5169 Print_Error(error);
5120 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5170 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5121 if (gshutdown) { 5171 if (gshutdown) {
5122 GSM_Terminate(); 5172 GSM_Terminate();
5123 exit(0); 5173 exit(0);
5124 } 5174 }
5125 } 5175 }
5126 printmsgerr("\n"); 5176 printmsgerr("\n");
5127 } 5177 }
5128 5178
5129 GSM_Terminate(); 5179 GSM_Terminate();
5130} 5180}
5131 5181
5132static void AddNew(int argc, char *argv[]) 5182static void AddNew(int argc, char *argv[])
5133{ 5183{
5134 GSM_Backup Backup; 5184 GSM_Backup Backup;
5135 GSM_DateTime date_time; 5185 GSM_DateTime date_time;
5136 GSM_MemoryEntry Pbk; 5186 GSM_MemoryEntry Pbk;
5137 GSM_MemoryStatusMemStatus; 5187 GSM_MemoryStatusMemStatus;
5138 GSM_ToDoEntry ToDo; 5188 GSM_ToDoEntry ToDo;
5139 GSM_ToDoStatus ToDoStatus; 5189 GSM_ToDoStatus ToDoStatus;
5140 GSM_CalendarEntryCalendar; 5190 GSM_CalendarEntryCalendar;
5141 GSM_WAPBookmark Bookmark; 5191 GSM_WAPBookmark Bookmark;
5142 int i, max, j; 5192 int i, max, j;
5143 5193
5144 error=GSM_ReadBackupFile(argv[2],&Backup); 5194 error=GSM_ReadBackupFile(argv[2],&Backup);
5145 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); 5195 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
5146 5196
5147 signal(SIGINT, interrupt); 5197 signal(SIGINT, interrupt);
5148 printmsgerr("Press Ctrl+C to break...\n"); 5198 printmsgerr("Press Ctrl+C to break...\n");
5149 5199
5150 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 5200 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
5151 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 5201 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
5152 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 5202 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
5153 5203
5154 GSM_Init(true); 5204 GSM_Init(true);
5155 5205
5156 if (Backup.PhonePhonebook[0] != NULL) { 5206 if (Backup.PhonePhonebook[0] != NULL) {
5157 MemStatus.MemoryType = MEM_ME; 5207 MemStatus.MemoryType = MEM_ME;
5158 error=Phone->GetMemoryStatus(&s, &MemStatus); 5208 error=Phone->GetMemoryStatus(&s, &MemStatus);
5159 if (error==ERR_NONE) { 5209 if (error==ERR_NONE) {
5160 max = 0; 5210 max = 0;
5161 while (Backup.PhonePhonebook[max]!=NULL) max++; 5211 while (Backup.PhonePhonebook[max]!=NULL) max++;
5162 printmsgerr("%i entries in backup file\n",max); 5212 printmsgerr("%i entries in backup file\n",max);
5163 if (MemStatus.MemoryFree < max) { 5213 if (MemStatus.MemoryFree < max) {
5164 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); 5214 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
5165 } else if (answer_yes("Add phone phonebook entries")) { 5215 } else if (answer_yes("Add phone phonebook entries")) {
5166 for (i=0;i<max;i++) { 5216 for (i=0;i<max;i++) {
5167 Pbk = *Backup.PhonePhonebook[i]; 5217 Pbk = *Backup.PhonePhonebook[i];
5168 Pbk.MemoryType = MEM_ME; 5218 Pbk.MemoryType = MEM_ME;
5169 error=Phone->AddMemory(&s, &Pbk); 5219 error=Phone->AddMemory(&s, &Pbk);
5170 Print_Error(error); 5220 Print_Error(error);
5171 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5221 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5172 if (gshutdown) { 5222 if (gshutdown) {
5173 GSM_Terminate(); 5223 GSM_Terminate();
5174 exit(0); 5224 exit(0);
5175 } 5225 }
5176 } 5226 }
5177 printmsgerr("\n"); 5227 printmsgerr("\n");
5178 } 5228 }
5179 } 5229 }
5180 } 5230 }
5181 if (Backup.SIMPhonebook[0] != NULL) { 5231 if (Backup.SIMPhonebook[0] != NULL) {
5182 MemStatus.MemoryType = MEM_SM; 5232 MemStatus.MemoryType = MEM_SM;
5183 error=Phone->GetMemoryStatus(&s, &MemStatus); 5233 error=Phone->GetMemoryStatus(&s, &MemStatus);
5184 if (error==ERR_NONE) { 5234 if (error==ERR_NONE) {
5185 max = 0; 5235 max = 0;
5186 while (Backup.SIMPhonebook[max]!=NULL) max++; 5236 while (Backup.SIMPhonebook[max]!=NULL) max++;
5187 printmsgerr("%i entries in backup file\n",max); 5237 printmsgerr("%i entries in backup file\n",max);
5188 if (MemStatus.MemoryFree < max) { 5238 if (MemStatus.MemoryFree < max) {
5189 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); 5239 printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
5190 } else if (answer_yes("Add SIM phonebook entries")) { 5240 } else if (answer_yes("Add SIM phonebook entries")) {
5191 j = 1; 5241 j = 1;
5192 for (i=0;i<max;i++) { 5242 for (i=0;i<max;i++) {
5193 Pbk = *Backup.SIMPhonebook[i]; 5243 Pbk = *Backup.SIMPhonebook[i];
5194 Pbk.MemoryType = MEM_SM; 5244 Pbk.MemoryType = MEM_SM;
5195 error=Phone->AddMemory(&s, &Pbk); 5245 error=Phone->AddMemory(&s, &Pbk);
5196 Print_Error(error); 5246 Print_Error(error);
5197 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5247 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5198 if (gshutdown) { 5248 if (gshutdown) {
5199 GSM_Terminate(); 5249 GSM_Terminate();
5200 exit(0); 5250 exit(0);
5201 } 5251 }
5202 } 5252 }
5203 printmsgerr("\n"); 5253 printmsgerr("\n");
5204 } 5254 }
5205 } 5255 }
5206 } 5256 }
5207 5257
5208 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { 5258 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
5209 if (true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) { 5259 if (true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) {
5210 GSM_GetCurrentDateTime(&date_time); 5260 GSM_GetCurrentDateTime(&date_time);
5211 5261
5212 error=Phone->SetDateTime(&s, &date_time); 5262 error=Phone->SetDateTime(&s, &date_time);
5213 Print_Error(error); 5263 Print_Error(error);
5214 } 5264 }
5215 } 5265 }
5216 if (Backup.Calendar[0] != NULL) { 5266 if (Backup.Calendar[0] != NULL) {
5217 error = Phone->GetNextCalendar(&s,&Calendar,true); 5267 error = Phone->GetNextCalendar(&s,&Calendar,true);
5218 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { 5268 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
5219 if (answer_yes("Add calendar notes")) { 5269 if (answer_yes("Add calendar notes")) {
5220 max = 0; 5270 max = 0;
5221 while (Backup.Calendar[max]!=NULL) max++; 5271 while (Backup.Calendar[max]!=NULL) max++;
5222 for (i=0;i<max;i++) { 5272 for (i=0;i<max;i++) {
5223 Calendar = *Backup.Calendar[i]; 5273 Calendar = *Backup.Calendar[i];
5224 error=Phone->AddCalendar(&s,&Calendar); 5274 error=Phone->AddCalendar(&s,&Calendar);
5225 Print_Error(error); 5275 Print_Error(error);
5226 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5276 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5227 if (gshutdown) { 5277 if (gshutdown) {
5228 GSM_Terminate(); 5278 GSM_Terminate();
5229 exit(0); 5279 exit(0);
5230 } 5280 }
5231 } 5281 }
5232 printmsgerr("\n"); 5282 printmsgerr("\n");
5233 } 5283 }
5234 } 5284 }
5235 } 5285 }
5236 if (Backup.ToDo[0] != NULL) { 5286 if (Backup.ToDo[0] != NULL) {
5237 ToDo.Location = 1; 5287 ToDo.Location = 1;
5238 error=Phone->GetToDoStatus(&s,&ToDoStatus); 5288 error=Phone->GetToDoStatus(&s,&ToDoStatus);
5239 if (error == ERR_NONE) { 5289 if (error == ERR_NONE) {
5240 if (answer_yes("Add ToDo")) { 5290 if (answer_yes("Add ToDo")) {
5241 max = 0; 5291 max = 0;
5242 while (Backup.ToDo[max]!=NULL) max++; 5292 while (Backup.ToDo[max]!=NULL) max++;
5243 for (i=0;i<max;i++) { 5293 for (i=0;i<max;i++) {
5244 ToDo = *Backup.ToDo[i]; 5294 ToDo = *Backup.ToDo[i];
5245 error = Phone->AddToDo(&s,&ToDo); 5295 error = Phone->AddToDo(&s,&ToDo);
5246 Print_Error(error); 5296 Print_Error(error);
5247 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5297 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5248 if (gshutdown) { 5298 if (gshutdown) {
5249 GSM_Terminate(); 5299 GSM_Terminate();
5250 exit(0); 5300 exit(0);
5251 } 5301 }
5252 } 5302 }
5253 printmsgerr("\n"); 5303 printmsgerr("\n");
5254 } 5304 }
5255 } 5305 }
5256 } 5306 }
5257 if (Backup.WAPBookmark[0] != NULL) { 5307 if (Backup.WAPBookmark[0] != NULL) {
5258 Bookmark.Location = 1; 5308 Bookmark.Location = 1;
5259 error = Phone->GetWAPBookmark(&s,&Bookmark); 5309 error = Phone->GetWAPBookmark(&s,&Bookmark);
5260 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 5310 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
5261 if (answer_yes("Add WAP bookmarks")) { 5311 if (answer_yes("Add WAP bookmarks")) {
5262 max = 0; 5312 max = 0;
5263 while (Backup.WAPBookmark[max]!=NULL) max++; 5313 while (Backup.WAPBookmark[max]!=NULL) max++;
5264 for (i=0;i<max;i++) { 5314 for (i=0;i<max;i++) {
5265 Bookmark = *Backup.WAPBookmark[i]; 5315 Bookmark = *Backup.WAPBookmark[i];
5266 Bookmark.Location = 0; 5316 Bookmark.Location = 0;
5267 error=Phone->SetWAPBookmark(&s,&Bookmark); 5317 error=Phone->SetWAPBookmark(&s,&Bookmark);
5268 Print_Error(error); 5318 Print_Error(error);
5269 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 5319 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
5270 if (gshutdown) { 5320 if (gshutdown) {
5271 GSM_Terminate(); 5321 GSM_Terminate();
5272 exit(0); 5322 exit(0);
5273 } 5323 }
5274 } 5324 }
5275 printmsgerr("\n"); 5325 printmsgerr("\n");
5276 } 5326 }
5277 } 5327 }
5278 } 5328 }
5279 5329
5280 GSM_Terminate(); 5330 GSM_Terminate();
5281} 5331}
5282#endif 5332#endif
5283 5333
5284static void ClearAll(int argc, char *argv[]) 5334static void ClearAll(int argc, char *argv[])
5285{ 5335{
5286 GSM_MemoryStatusMemStatus; 5336 GSM_MemoryStatusMemStatus;
5287 GSM_ToDoStatus ToDoStatus; 5337 GSM_ToDoStatus ToDoStatus;
5288 GSM_CalendarEntryCalendar; 5338 GSM_CalendarEntryCalendar;
5289 GSM_ToDoEntry ToDo; 5339 GSM_ToDoEntry ToDo;
5340 GSM_NoteEntry Note;
5290 GSM_WAPBookmark Bookmark; 5341 GSM_WAPBookmark Bookmark;
5291 GSM_FMStation Station; 5342 GSM_FMStation Station;
5292 GSM_MemoryEntry Pbk; 5343 GSM_MemoryEntry Pbk;
5293 bool DoClear; 5344 bool DoClear;
5294 5345
5295 GSM_Init(true); 5346 GSM_Init(true);
5296 5347
5297 DoClear = false; 5348 DoClear = false;
5298 MemStatus.MemoryType = MEM_ME; 5349 MemStatus.MemoryType = MEM_ME;
5299 error=Phone->GetMemoryStatus(&s, &MemStatus); 5350 error=Phone->GetMemoryStatus(&s, &MemStatus);
5300 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { 5351 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) {
5301 if (answer_yes("Delete phone phonebook")) DoClear = true; 5352 if (answer_yes("Delete phone phonebook")) DoClear = true;
5302 } 5353 }
5303 if (DoClear) { 5354 if (DoClear) {
5304 error = Phone->DeleteAllMemory(&s,MEM_ME); 5355 error = Phone->DeleteAllMemory(&s,MEM_ME);
5305 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5356 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5306 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 5357 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
5307 Pbk.MemoryType = MEM_ME; 5358 Pbk.MemoryType = MEM_ME;
5308 Pbk.Location= i + 1; 5359 Pbk.Location= i + 1;
5309 Pbk.EntriesNum= 0; 5360 Pbk.EntriesNum= 0;
5310 error=Phone->DeleteMemory(&s, &Pbk); 5361 error=Phone->DeleteMemory(&s, &Pbk);
5311 Print_Error(error); 5362 Print_Error(error);
5312 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 5363 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
5313 if (gshutdown) { 5364 if (gshutdown) {
5314 GSM_Terminate(); 5365 GSM_Terminate();
5315 exit(0); 5366 exit(0);
5316 } 5367 }
5317 } 5368 }
5318 printmsgerr("\n"); 5369 printmsgerr("\n");
5319 } else { 5370 } else {
5320 printmsgerr("Done\n"); 5371 printmsgerr("Done\n");
5321 Print_Error(error); 5372 Print_Error(error);
5322 } 5373 }
5323 } 5374 }
5324 5375
5325 DoClear = false; 5376 DoClear = false;
5326 MemStatus.MemoryType = MEM_SM; 5377 MemStatus.MemoryType = MEM_SM;
5327 error=Phone->GetMemoryStatus(&s, &MemStatus); 5378 error=Phone->GetMemoryStatus(&s, &MemStatus);
5328 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { 5379 if (error==ERR_NONE && MemStatus.MemoryUsed !=0) {
5329 if (answer_yes("Delete SIM phonebook")) DoClear = true; 5380 if (answer_yes("Delete SIM phonebook")) DoClear = true;
5330 } 5381 }
5331 if (DoClear) { 5382 if (DoClear) {
5332 error = Phone->DeleteAllMemory(&s,MEM_SM); 5383 error = Phone->DeleteAllMemory(&s,MEM_SM);
5333 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5384 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5334 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 5385 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
5335 Pbk.MemoryType = MEM_SM; 5386 Pbk.MemoryType = MEM_SM;
5336 Pbk.Location= i + 1; 5387 Pbk.Location= i + 1;
5337 Pbk.EntriesNum= 0; 5388 Pbk.EntriesNum= 0;
5338 error=Phone->DeleteMemory(&s, &Pbk); 5389 error=Phone->DeleteMemory(&s, &Pbk);
5339 Print_Error(error); 5390 Print_Error(error);
5340 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 5391 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
5341 if (gshutdown) { 5392 if (gshutdown) {
5342 GSM_Terminate(); 5393 GSM_Terminate();
5343 exit(0); 5394 exit(0);
5344 } 5395 }
5345 } 5396 }
5346 printmsgerr("\n"); 5397 printmsgerr("\n");
5347 } else { 5398 } else {
5348 printmsgerr("Done\n"); 5399 printmsgerr("Done\n");
5349 Print_Error(error); 5400 Print_Error(error);
5350 } 5401 }
5351 } 5402 }
5352 5403
5353 DoClear = false; 5404 DoClear = false;
5354 error = Phone->GetNextCalendar(&s,&Calendar,true); 5405 error = Phone->GetNextCalendar(&s,&Calendar,true);
5355 if (error == ERR_NONE) { 5406 if (error == ERR_NONE) {
5356 if (answer_yes("Delete calendar notes")) DoClear = true; 5407 if (answer_yes("Delete calendar notes")) DoClear = true;
5357 } 5408 }
5358 if (DoClear) { 5409 if (DoClear) {
5359 printmsgerr("Deleting: "); 5410 printmsgerr("Deleting: ");
5360 error=Phone->DeleteAllCalendar(&s); 5411 error=Phone->DeleteAllCalendar(&s);
5361 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5412 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5362 while (1) { 5413 while (1) {
5363 error = Phone->GetNextCalendar(&s,&Calendar,true); 5414 error = Phone->GetNextCalendar(&s,&Calendar,true);
5364 if (error != ERR_NONE) break; 5415 if (error != ERR_NONE) break;
5365 error = Phone->DeleteCalendar(&s,&Calendar); 5416 error = Phone->DeleteCalendar(&s,&Calendar);
5366 Print_Error(error); 5417 Print_Error(error);
5367 printmsgerr("*"); 5418 printmsgerr("*");
5368 } 5419 }
5369 printmsgerr("\n"); 5420 printmsgerr("\n");
5370 } else { 5421 } else {
5371 printmsgerr("Done\n"); 5422 printmsgerr("Done\n");
5372 Print_Error(error); 5423 Print_Error(error);
5373 } 5424 }
5374 } 5425 }
5375 5426
5376 DoClear = false; 5427 DoClear = false;
5377 error = Phone->GetToDoStatus(&s,&ToDoStatus); 5428 error = Phone->GetToDoStatus(&s,&ToDoStatus);
5378 if (error == ERR_NONE && ToDoStatus.Used != 0) { 5429 if (error == ERR_NONE && ToDoStatus.Used != 0) {
5379 if (answer_yes("Delete ToDo")) DoClear = true; 5430 if (answer_yes("Delete ToDo")) DoClear = true;
5380 } 5431 }
5381 if (DoClear) { 5432 if (DoClear) {
5382 printmsgerr("Deleting: "); 5433 printmsgerr("Deleting: ");
5383 error=Phone->DeleteAllToDo(&s); 5434 error=Phone->DeleteAllToDo(&s);
5384 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 5435 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
5385 while (1) { 5436 while (1) {
5386 error = Phone->GetNextToDo(&s,&ToDo,true); 5437 error = Phone->GetNextToDo(&s,&ToDo,true);
5387 if (error != ERR_NONE) break; 5438 if (error != ERR_NONE) break;
5388 error = Phone->DeleteToDo(&s,&ToDo); 5439 error = Phone->DeleteToDo(&s,&ToDo);
5389 Print_Error(error); 5440 Print_Error(error);
5390 printmsgerr("*"); 5441 printmsgerr("*");
5391 } 5442 }
5392 printmsgerr("\n"); 5443 printmsgerr("\n");
5393 } else { 5444 } else {
5394 printmsgerr("Done\n"); 5445 printmsgerr("Done\n");
5395 Print_Error(error); 5446 Print_Error(error);
5396 } 5447 }
5397 } 5448 }
5398 5449
5450 DoClear = false;
5451 error = Phone->GetNotesStatus(&s,&ToDoStatus);
5452 if (error == ERR_NONE && ToDoStatus.Used != 0) {
5453 if (answer_yes("Delete Notes")) DoClear = true;
5454 }
5455 if (DoClear) {
5456 printmsgerr("Deleting: ");
5457 while (1) {
5458 error = Phone->GetNextNote(&s,&Note,true);
5459 if (error != ERR_NONE) break;
5460 error = Phone->DeleteNote(&s,&Note);
5461 Print_Error(error);
5462 printmsgerr("*");
5463 }
5464 printmsgerr("\n");
5465 }
5466
5399 Bookmark.Location = 1; 5467 Bookmark.Location = 1;
5400 error = Phone->GetWAPBookmark(&s,&Bookmark); 5468 error = Phone->GetWAPBookmark(&s,&Bookmark);
5401 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { 5469 if (error == ERR_NONE || error == ERR_INVALIDLOCATION) {
5402 if (answer_yes("Delete WAP bookmarks")) { 5470 if (answer_yes("Delete WAP bookmarks")) {
5403 printmsgerr("Deleting: "); 5471 printmsgerr("Deleting: ");
5404 /* One thing to explain: DCT4 phones seems to have bug here. 5472 /* One thing to explain: DCT4 phones seems to have bug here.
5405 * When delete for example first bookmark, phone change 5473 * When delete for example first bookmark, phone change
5406 * numeration for getting frame, not for deleting. So, we try to 5474 * numeration for getting frame, not for deleting. So, we try to
5407 * get 1'st bookmark. Inside frame is "correct" location. We use 5475 * get 1'st bookmark. Inside frame is "correct" location. We use
5408 * it later 5476 * it later
5409 */ 5477 */
5410 while (error==ERR_NONE) { 5478 while (error==ERR_NONE) {
5411 error = Phone->DeleteWAPBookmark(&s,&Bookmark); 5479 error = Phone->DeleteWAPBookmark(&s,&Bookmark);
5412 Bookmark.Location = 1; 5480 Bookmark.Location = 1;
5413 error = Phone->GetWAPBookmark(&s,&Bookmark); 5481 error = Phone->GetWAPBookmark(&s,&Bookmark);
5414 printmsgerr("*"); 5482 printmsgerr("*");
5415 } 5483 }
5416 printmsgerr("\n"); 5484 printmsgerr("\n");
5417 } 5485 }
5418 } 5486 }
5419 if (Phone->DeleteUserRingtones != NOTSUPPORTED) { 5487 if (Phone->DeleteUserRingtones != NOTSUPPORTED) {
5420 if (answer_yes("Delete all user ringtones")) { 5488 if (answer_yes("Delete all user ringtones")) {
5421 printmsgerr("Deleting: "); 5489 printmsgerr("Deleting: ");
5422 error=Phone->DeleteUserRingtones(&s); 5490 error=Phone->DeleteUserRingtones(&s);
5423 Print_Error(error); 5491 Print_Error(error);
5424 printmsgerr("Done\n"); 5492 printmsgerr("Done\n");
5425 } 5493 }
5426 } 5494 }
5427 Station.Location=i; 5495 Station.Location=i;
5428 error=Phone->GetFMStation(&s,&Station); 5496 error=Phone->GetFMStation(&s,&Station);
5429 if (error == ERR_NONE || error == ERR_EMPTY) { 5497 if (error == ERR_NONE || error == ERR_EMPTY) {
5430 if (answer_yes("Delete all FM station")) { 5498 if (answer_yes("Delete all FM station")) {
5431 error=Phone->ClearFMStations(&s); 5499 error=Phone->ClearFMStations(&s);
5432 Print_Error(error); 5500 Print_Error(error);
5433 } 5501 }
5434 } 5502 }
5435 5503
5436 GSM_Terminate(); 5504 GSM_Terminate();
5437} 5505}
5438 5506
5439static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) 5507static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j)
5440{ 5508{
5441 if (settings->Settings[j].IsContinuous) { 5509 if (settings->Settings[j].IsContinuous) {
5442 printmsg("Connection type : Continuous\n"); 5510 printmsg("Connection type : Continuous\n");
5443 } else { 5511 } else {
5444 printmsg("Connection type : Temporary\n"); 5512 printmsg("Connection type : Temporary\n");
5445 } 5513 }
5446 if (settings->Settings[j].IsSecurity) { 5514 if (settings->Settings[j].IsSecurity) {
5447 printmsg("Connection security : On\n"); 5515 printmsg("Connection security : On\n");
5448 } else { 5516 } else {
5449 printmsg("Connection security : Off\n"); 5517 printmsg("Connection security : Off\n");
5450 } 5518 }
5451 printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); 5519 printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort);
5452 printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); 5520 printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port);
5453 switch (settings->Settings[j].Bearer) { 5521 switch (settings->Settings[j].Bearer) {
5454 case WAPSETTINGS_BEARER_SMS: 5522 case WAPSETTINGS_BEARER_SMS:
5455 printmsg("Bearer : SMS"); 5523 printmsg("Bearer : SMS");
5456 if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); 5524 if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)");
5457 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); 5525 printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server));
5458 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5526 printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5459 break; 5527 break;
5460 case WAPSETTINGS_BEARER_DATA: 5528 case WAPSETTINGS_BEARER_DATA:
5461 printmsg("Bearer : Data (CSD)"); 5529 printmsg("Bearer : Data (CSD)");
5462 if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); 5530 if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)");
5463 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); 5531 printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
5464 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); 5532 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
5465 if (settings->Settings[j].ManualLogin) { 5533 if (settings->Settings[j].ManualLogin) {
5466 printmsg("Login Type : Manual\n"); 5534 printmsg("Login Type : Manual\n");
5467 } else { 5535 } else {
5468 printmsg("Login Type : Automatic\n"); 5536 printmsg("Login Type : Automatic\n");
5469 } 5537 }
5470 if (settings->Settings[j].IsNormalAuthentication) { 5538 if (settings->Settings[j].IsNormalAuthentication) {
5471 printmsg("Authentication type : Normal\n"); 5539 printmsg("Authentication type : Normal\n");
5472 } else { 5540 } else {
5473 printmsg("Authentication type : Secure\n"); 5541 printmsg("Authentication type : Secure\n");
5474 } 5542 }
5475 if (settings->Settings[j].IsISDNCall) { 5543 if (settings->Settings[j].IsISDNCall) {
5476 printmsg("Data call type : ISDN\n"); 5544 printmsg("Data call type : ISDN\n");
5477 } else { 5545 } else {
5478 printmsg("Data call type : Analogue\n"); 5546 printmsg("Data call type : Analogue\n");
5479 } 5547 }
5480 switch (settings->Settings[j].Speed) { 5548 switch (settings->Settings[j].Speed) {
5481 case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; 5549 case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break;
5482 case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; 5550 case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break;
5483 case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; 5551 case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break;
5484 } 5552 }
5485 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); 5553 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
5486 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); 5554 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
5487 break; 5555 break;
5488 case WAPSETTINGS_BEARER_USSD: 5556 case WAPSETTINGS_BEARER_USSD:
5489 printmsg("Bearer : USSD"); 5557 printmsg("Bearer : USSD");
5490 if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); 5558 if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)");
5491 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); 5559 printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code));
5492 if (settings->Settings[j].IsIP) { 5560 if (settings->Settings[j].IsIP) {
5493 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5561 printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5494 } else { 5562 } else {
5495 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); 5563 printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service));
5496 } 5564 }
5497 break; 5565 break;
5498 case WAPSETTINGS_BEARER_GPRS: 5566 case WAPSETTINGS_BEARER_GPRS:
5499 printmsg("Bearer : GPRS"); 5567 printmsg("Bearer : GPRS");
5500 if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); 5568 if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)");
5501 if (settings->Settings[j].ManualLogin) { 5569 if (settings->Settings[j].ManualLogin) {
5502 printmsg("\nLogin Type : Manual\n"); 5570 printmsg("\nLogin Type : Manual\n");
5503 } else { 5571 } else {
5504 printmsg("\nLogin Type : Automatic\n"); 5572 printmsg("\nLogin Type : Automatic\n");
5505 } 5573 }
5506 if (settings->Settings[j].IsNormalAuthentication) { 5574 if (settings->Settings[j].IsNormalAuthentication) {
5507 printmsg("Authentication type : Normal\n"); 5575 printmsg("Authentication type : Normal\n");
5508 } else { 5576 } else {
5509 printmsg("Authentication type : Secure\n"); 5577 printmsg("Authentication type : Secure\n");
5510 } 5578 }
5511 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); 5579 printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp));
5512 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); 5580 printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress));
5513 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); 5581 printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User));
5514 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); 5582 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password));
5515 } 5583 }
5516} 5584}
5517 5585
5518static void GetSyncMLSettings(int argc, char *argv[]) 5586static void GetSyncMLSettings(int argc, char *argv[])
5519{ 5587{
5520 GSM_SyncMLSettingssettings; 5588 GSM_SyncMLSettingssettings;
5521 int start,stop,j; 5589 int start,stop,j;
5522 5590
5523 GetStartStop(&start, &stop, 2, argc, argv); 5591 GetStartStop(&start, &stop, 2, argc, argv);
5524 5592
5525 GSM_Init(true); 5593 GSM_Init(true);
5526 5594
5527 for (i=start;i<=stop;i++) { 5595 for (i=start;i<=stop;i++) {
5528 settings.Location=i; 5596 settings.Location=i;
5529 error=Phone->GetSyncMLSettings(&s,&settings); 5597 error=Phone->GetSyncMLSettings(&s,&settings);
5530 Print_Error(error); 5598 Print_Error(error);
5531 printmsg("%i. ",i); 5599 printmsg("%i. ",i);
5532 if (settings.Name[0]==0 && settings.Name[1]==0) { 5600 if (settings.Name[0]==0 && settings.Name[1]==0) {
5533 printmsg("Set %i",i); 5601 printmsg("Set %i",i);
5534 } else { 5602 } else {
5535 printmsg("%s",DecodeUnicodeConsole(settings.Name)); 5603 printmsg("%s",DecodeUnicodeConsole(settings.Name));
5536 } 5604 }
5537 if (settings.Active) printmsg(" (active)"); 5605 if (settings.Active) printmsg(" (active)");
5538 // if (settings.ReadOnly) printmsg("\nRead only : yes"); 5606 // if (settings.ReadOnly) printmsg("\nRead only : yes");
5539 printmsg("\n"); 5607 printmsg("\n");
5540 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); 5608 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
5541 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); 5609 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
5542 printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); 5610 printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase));
5543 printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); 5611 printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase));
5544 printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); 5612 printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server));
5545 printmsg("Sync. phonebook : "); 5613 printmsg("Sync. phonebook : ");
5546 if (settings.SyncPhonebook) printmsg("yes\n"); 5614 if (settings.SyncPhonebook) printmsg("yes\n");
5547 if (!settings.SyncPhonebook) printmsg("no\n"); 5615 if (!settings.SyncPhonebook) printmsg("no\n");
5548 printmsg("Sync. calendar : "); 5616 printmsg("Sync. calendar : ");
5549 if (settings.SyncCalendar) printmsg("yes\n"); 5617 if (settings.SyncCalendar) printmsg("yes\n");
5550 if (!settings.SyncCalendar) printmsg("no\n"); 5618 if (!settings.SyncCalendar) printmsg("no\n");
5551 printmsg("\n"); 5619 printmsg("\n");
5552 for (j=0;j<settings.Connection.Number;j++) { 5620 for (j=0;j<settings.Connection.Number;j++) {
5553 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { 5621 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
5554 printmsg("Connection set name : Set %i\n",i); 5622 printmsg("Connection set name : Set %i\n",i);
5555 } else { 5623 } else {
5556 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); 5624 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
5557 } 5625 }
5558 DisplayConnectionSettings(&settings.Connection,j); 5626 DisplayConnectionSettings(&settings.Connection,j);
5559 printf("\n"); 5627 printf("\n");
5560 } 5628 }
5561 } 5629 }
5562 GSM_Terminate(); 5630 GSM_Terminate();
5563} 5631}
5564 5632
5565static void GetChatSettings(int argc, char *argv[]) 5633static void GetChatSettings(int argc, char *argv[])
5566{ 5634{
5567 GSM_ChatSettingssettings; 5635 GSM_ChatSettingssettings;
5568 int start,stop,j; 5636 int start,stop,j;
5569 5637
5570 GetStartStop(&start, &stop, 2, argc, argv); 5638 GetStartStop(&start, &stop, 2, argc, argv);
5571 5639
5572 GSM_Init(true); 5640 GSM_Init(true);
5573 5641
5574 for (i=start;i<=stop;i++) { 5642 for (i=start;i<=stop;i++) {
5575 settings.Location=i; 5643 settings.Location=i;
5576 error=Phone->GetChatSettings(&s,&settings); 5644 error=Phone->GetChatSettings(&s,&settings);
5577 Print_Error(error); 5645 Print_Error(error);
5578 printmsg("%i. ",i); 5646 printmsg("%i. ",i);
5579 if (settings.Name[0]==0 && settings.Name[1]==0) { 5647 if (settings.Name[0]==0 && settings.Name[1]==0) {
5580 printmsg("Set %i",i); 5648 printmsg("Set %i",i);
5581 } else { 5649 } else {
5582 printmsg("%s",DecodeUnicodeConsole(settings.Name)); 5650 printmsg("%s",DecodeUnicodeConsole(settings.Name));
5583 } 5651 }
5584 if (settings.Active) printmsg(" (active)"); 5652 if (settings.Active) printmsg(" (active)");
5585 // if (settings.ReadOnly) printmsg("\nRead only : yes"); 5653 // if (settings.ReadOnly) printmsg("\nRead only : yes");
5586 printmsg("\n"); 5654 printmsg("\n");
5587 printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); 5655 printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage));
5588 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); 5656 printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User));
5589 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); 5657 printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password));
5590 printmsg("\n"); 5658 printmsg("\n");
5591 for (j=0;j<settings.Connection.Number;j++) { 5659 for (j=0;j<settings.Connection.Number;j++) {
5592 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { 5660 if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) {
5593 printmsg("Connection set name : Set %i\n",i); 5661 printmsg("Connection set name : Set %i\n",i);
5594 } else { 5662 } else {
5595 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); 5663 printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title));
5596 } 5664 }
5597 DisplayConnectionSettings(&settings.Connection,j); 5665 DisplayConnectionSettings(&settings.Connection,j);
5598 printf("\n"); 5666 printf("\n");
5599 } 5667 }
5600 } 5668 }
5601 GSM_Terminate(); 5669 GSM_Terminate();
5602} 5670}
5603 5671
5604static void GetWAPMMSSettings(int argc, char *argv[]) 5672static void GetWAPMMSSettings(int argc, char *argv[])
5605{ 5673{
5606 GSM_MultiWAPSettingssettings; 5674 GSM_MultiWAPSettingssettings;
5607 int start,stop,j; 5675 int start,stop,j;
5608 5676
5609 GetStartStop(&start, &stop, 2, argc, argv); 5677 GetStartStop(&start, &stop, 2, argc, argv);
5610 5678
5611 GSM_Init(true); 5679 GSM_Init(true);
5612 5680
5613 for (i=start;i<=stop;i++) { 5681 for (i=start;i<=stop;i++) {
5614 settings.Location=i; 5682 settings.Location=i;
5615 if (mystrncasecmp(argv[1],"--getwapsettings",0)) { 5683 if (mystrncasecmp(argv[1],"--getwapsettings",0)) {
5616 error=Phone->GetWAPSettings(&s,&settings); 5684 error=Phone->GetWAPSettings(&s,&settings);
5617 } else { 5685 } else {
5618 error=Phone->GetMMSSettings(&s,&settings); 5686 error=Phone->GetMMSSettings(&s,&settings);
5619 } 5687 }
5620 Print_Error(error); 5688 Print_Error(error);
5621 for (j=0;j<settings.Number;j++) { 5689 for (j=0;j<settings.Number;j++) {
5622 printmsg("%i. ",i); 5690 printmsg("%i. ",i);
5623 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { 5691 if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) {
5624 printmsg("Set %i",i); 5692 printmsg("Set %i",i);
5625 } else { 5693 } else {
5626 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); 5694 printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title));
5627 } 5695 }
5628 if (settings.Active) printmsg(" (active)"); 5696 if (settings.Active) printmsg(" (active)");
5629 if (settings.ReadOnly) printmsg("\nRead only : yes"); 5697 if (settings.ReadOnly) printmsg("\nRead only : yes");
5630 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); 5698 printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage));
5631 DisplayConnectionSettings(&settings,j); 5699 DisplayConnectionSettings(&settings,j);
5632 printf("\n"); 5700 printf("\n");
5633 } 5701 }
5634 } 5702 }
5635 GSM_Terminate(); 5703 GSM_Terminate();
5636} 5704}
5637 5705
5638#ifdef GSM_ENABLE_BACKUP 5706#ifdef GSM_ENABLE_BACKUP
5639static void BackupSMS(int argc, char *argv[]) 5707static void BackupSMS(int argc, char *argv[])
5640{ 5708{
5641 GSM_SMS_Backup Backup; 5709 GSM_SMS_Backup Backup;
5642 GSM_MultiSMSMessage sms; 5710 GSM_MultiSMSMessage sms;
5643 GSM_SMSFolders folders; 5711 GSM_SMSFolders folders;
5644 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; 5712 bool BackupFromFolder[GSM_MAX_SMS_FOLDERS];
5645 bool start = true; 5713 bool start = true;
5646 bool DeleteAfter; 5714 bool DeleteAfter;
5647 int j, smsnum; 5715 int j, smsnum = 0;
5648 char buffer[200]; 5716 char buffer[200];
5649 5717
5650 /* We ignore return code, because (when file doesn't exist) we
5651 * will create new later
5652 */
5653 GSM_ReadSMSBackupFile(argv[2], &Backup);
5654 smsnum = 0;
5655 while (Backup.SMS[smsnum]!=NULL) smsnum++;
5656
5657 GSM_Init(true); 5718 GSM_Init(true);
5658 5719
5659 error=Phone->GetSMSFolders(&s, &folders); 5720 error=Phone->GetSMSFolders(&s, &folders);
5660 Print_Error(error); 5721 Print_Error(error);
5661 5722
5662 DeleteAfter=answer_yes("Delete each sms after backup"); 5723 DeleteAfter=answer_yes("Delete each sms after backup");
5663 5724
5664 for (j=0;j<folders.Number;j++) { 5725 for (j=0;j<folders.Number;j++) {
5665 BackupFromFolder[j] = false; 5726 BackupFromFolder[j] = false;
5666 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); 5727 sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name));
5728 if (folders.Folder[j].Memory == MEM_SM) strcat(buffer," (SIM)");
5667 if (answer_yes(buffer)) BackupFromFolder[j] = true; 5729 if (answer_yes(buffer)) BackupFromFolder[j] = true;
5668 } 5730 }
5669 5731
5670 while (error == ERR_NONE) { 5732 while (error == ERR_NONE) {
5671 sms.SMS[0].Folder=0x00; 5733 sms.SMS[0].Folder=0x00;
5672 error=Phone->GetNextSMS(&s, &sms, start); 5734 error=Phone->GetNextSMS(&s, &sms, start);
5673 switch (error) { 5735 switch (error) {
5674 case ERR_EMPTY: 5736 case ERR_EMPTY:
5675 break; 5737 break;
5676 default: 5738 default:
5677 Print_Error(error); 5739 Print_Error(error);
5678 for (j=0;j<sms.Number;j++) { 5740 for (j=0;j<sms.Number;j++) {
5679 if (BackupFromFolder[sms.SMS[j].Folder-1]) { 5741 if (BackupFromFolder[sms.SMS[j].Folder-1]) {
5680 switch (sms.SMS[j].PDU) { 5742 switch (sms.SMS[j].PDU) {
5681 case SMS_Status_Report: 5743 case SMS_Status_Report:
5682 break; 5744 break;
5683 case SMS_Submit: 5745 case SMS_Submit:
5684 case SMS_Deliver: 5746 case SMS_Deliver:
5685 if (sms.SMS[j].Length == 0) break; 5747 if (sms.SMS[j].Length == 0) break;
5686 if (smsnum < GSM_BACKUP_MAX_SMS) { 5748 if (smsnum < GSM_BACKUP_MAX_SMS) {
5687 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); 5749 Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage));
5688 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); 5750 if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY);
5689 Backup.SMS[smsnum+1] = NULL; 5751 Backup.SMS[smsnum+1] = NULL;
5690 } else { 5752 } else {
5691 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); 5753 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS");
5692 GSM_Terminate(); 5754 GSM_Terminate();
5693 exit(-1); 5755 exit(-1);
5694 } 5756 }
5695 *Backup.SMS[smsnum] = sms.SMS[j]; 5757 *Backup.SMS[smsnum] = sms.SMS[j];
5696 smsnum++; 5758 smsnum++;
5697 break; 5759 break;
5698 } 5760 }
5699 } 5761 }
5700 } 5762 }
5701 } 5763 }
5702 start=false; 5764 start=false;
5703 } 5765 }
5704 5766
5705 error = GSM_SaveSMSBackupFile(argv[2],&Backup); 5767 error = GSM_AddSMSBackupFile(argv[2],&Backup);
5706 Print_Error(error); 5768 Print_Error(error);
5707 5769
5708 if (DeleteAfter) { 5770 if (DeleteAfter) {
5709 for (j=0;j<smsnum;j++) { 5771 for (j=0;j<smsnum;j++) {
5710 Backup.SMS[j]->Folder = 0; 5772 Backup.SMS[j]->Folder = 0;
5711 error=Phone->DeleteSMS(&s, Backup.SMS[j]); 5773 error=Phone->DeleteSMS(&s, Backup.SMS[j]);
5712 Print_Error(error); 5774 Print_Error(error);
5713 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); 5775 printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum);
5714 } 5776 }
5715 } 5777 }
5716 5778
5717 GSM_Terminate(); 5779 GSM_Terminate();
5718} 5780}
5719 5781
5720static void AddSMS(int argc, char *argv[]) 5782static void AddSMS(int argc, char *argv[])
5721{ 5783{
5722 GSM_MultiSMSMessage SMS; 5784 GSM_MultiSMSMessage SMS;
5723 GSM_SMS_Backup Backup; 5785 GSM_SMS_Backup Backup;
5724 int smsnum = 0; 5786 int smsnum = 0;
5725 int folder; 5787 int folder;
5726 5788
5727 folder = atoi(argv[2]); 5789 folder = atoi(argv[2]);
5728 5790
5729 error = GSM_ReadSMSBackupFile(argv[3], &Backup); 5791 error = GSM_ReadSMSBackupFile(argv[3], &Backup);
5730 Print_Error(error); 5792 Print_Error(error);
5731 5793
5732 GSM_Init(true); 5794 GSM_Init(true);
5733 5795
5734 while (Backup.SMS[smsnum] != NULL) { 5796 while (Backup.SMS[smsnum] != NULL) {
5735 Backup.SMS[smsnum]->Folder = folder; 5797 Backup.SMS[smsnum]->Folder = folder;
5736 Backup.SMS[smsnum]->SMSC.Location = 1; 5798 Backup.SMS[smsnum]->SMSC.Location = 1;
5737 SMS.Number = 1; 5799 SMS.Number = 1;
5738 SMS.SMS[0] = *Backup.SMS[smsnum]; 5800 SMS.SMS[0] = *Backup.SMS[smsnum];
5739 displaymultismsinfo(SMS,false,false); 5801 displaymultismsinfo(SMS,false,false);
5740 if (answer_yes("Restore sms")) { 5802 if (answer_yes("Restore sms")) {
5741 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5803 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5742 Print_Error(error); 5804 Print_Error(error);
5743 } 5805 }
5744 smsnum++; 5806 smsnum++;
5745 } 5807 }
5746 5808
5747 GSM_Terminate(); 5809 GSM_Terminate();
5748} 5810}
5749 5811
5750static void RestoreSMS(int argc, char *argv[]) 5812static void RestoreSMS(int argc, char *argv[])
5751{ 5813{
5752 GSM_MultiSMSMessage SMS; 5814 GSM_MultiSMSMessage SMS;
5753 GSM_SMS_Backup Backup; 5815 GSM_SMS_Backup Backup;
5754 GSM_SMSFolders folders; 5816 GSM_SMSFolders folders;
5755 int smsnum = 0; 5817 int smsnum = 0;
5756 char buffer[200]; 5818 char buffer[200];
5819 bool restore8bit,doit;
5757 5820
5758 error=GSM_ReadSMSBackupFile(argv[2], &Backup); 5821 error=GSM_ReadSMSBackupFile(argv[2], &Backup);
5759 Print_Error(error); 5822 Print_Error(error);
5760 5823
5824 sprintf(buffer,"Do you want to restore binary SMS");
5825 restore8bit = answer_yes(buffer);
5826
5761 GSM_Init(true); 5827 GSM_Init(true);
5762 5828
5763 error=Phone->GetSMSFolders(&s, &folders); 5829 error=Phone->GetSMSFolders(&s, &folders);
5764 Print_Error(error); 5830 Print_Error(error);
5765 5831
5766 while (Backup.SMS[smsnum] != NULL) { 5832 while (Backup.SMS[smsnum] != NULL) {
5767 SMS.Number = 1; 5833 doit = true;
5768 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); 5834 if (!restore8bit && Backup.SMS[smsnum]->Coding == SMS_Coding_8bit) doit = false;
5769 displaymultismsinfo(SMS,false,false); 5835 if (doit) {
5770 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); 5836 SMS.Number = 1;
5771 if (answer_yes(buffer)) { 5837 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
5772 error=Phone->AddSMS(&s, Backup.SMS[smsnum]); 5838 displaymultismsinfo(SMS,false,false);
5773 Print_Error(error); 5839 sprintf(buffer,"Restore %03i sms to folder \"%s\"",smsnum+1,DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
5840 if (folders.Folder[Backup.SMS[smsnum]->Folder-1].Memory == MEM_SM) strcat(buffer," (SIM)");
5841 if (answer_yes(buffer)) {
5842 smprintf(&s,"saving %i SMS\n",smsnum);
5843 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5844 Print_Error(error);
5845 }
5774 } 5846 }
5775 smsnum++; 5847 smsnum++;
5776 } 5848 }
5777 5849
5778 GSM_Terminate(); 5850 GSM_Terminate();
5779} 5851}
5780#endif 5852#endif
5781 5853
5782static void CopyBitmap(int argc, char *argv[]) 5854static void CopyBitmap(int argc, char *argv[])
5783{ 5855{
5784 GSM_MultiBitmap Bitmap; 5856 GSM_MultiBitmap Bitmap;
5785 int i; 5857 int i;
5786 5858
5787 Bitmap.Bitmap[0].Type = GSM_None; 5859 Bitmap.Bitmap[0].Type = GSM_None;
5788 5860
5789 error=GSM_ReadBitmapFile(argv[2],&Bitmap); 5861 error=GSM_ReadBitmapFile(argv[2],&Bitmap);
5790 Print_Error(error); 5862 Print_Error(error);
5791 5863
5792 if (argc==3) { 5864 if (argc==3) {
5793 for (i=0;i<Bitmap.Number;i++) { 5865 for (i=0;i<Bitmap.Number;i++) {
5794 switch (Bitmap.Bitmap[i].Type) { 5866 switch (Bitmap.Bitmap[i].Type) {
5795 case GSM_StartupLogo : printmsg("Startup logo"); break; 5867 case GSM_StartupLogo : printmsg("Startup logo"); break;
5796 case GSM_OperatorLogo: printmsg("Operator logo"); break; 5868 case GSM_OperatorLogo: printmsg("Operator logo"); break;
5797 case GSM_PictureImage: printmsg("Picture Image"); break; 5869 case GSM_PictureImage: printmsg("Picture Image"); break;
5798 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; 5870 case GSM_CallerGroupLogo : printmsg("Caller group logo"); break;
5799 default : break; 5871 default : break;
5800 } 5872 }
5801 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); 5873 printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight);
5802 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); 5874 GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]);
5803 } 5875 }
5804 } else { 5876 } else {
5805 if (argc == 5) { 5877 if (argc == 5) {
5806 for (i=0;i<Bitmap.Number;i++) { 5878 for (i=0;i<Bitmap.Number;i++) {
5807 if (mystrncasecmp(argv[4],"PICTURE",0)) { 5879 if (mystrncasecmp(argv[4],"PICTURE",0)) {
5808 Bitmap.Bitmap[i].Type = GSM_PictureImage; 5880 Bitmap.Bitmap[i].Type = GSM_PictureImage;
5809 } else if (mystrncasecmp(argv[4],"STARTUP",0)) { 5881 } else if (mystrncasecmp(argv[4],"STARTUP",0)) {
5810 Bitmap.Bitmap[i].Type = GSM_StartupLogo; 5882 Bitmap.Bitmap[i].Type = GSM_StartupLogo;
5811 } else if (mystrncasecmp(argv[4],"CALLER",0)) { 5883 } else if (mystrncasecmp(argv[4],"CALLER",0)) {
5812 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; 5884 Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo;
5813 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { 5885 } else if (mystrncasecmp(argv[4],"OPERATOR",0)) {
5814 Bitmap.Bitmap[i].Type = GSM_OperatorLogo; 5886 Bitmap.Bitmap[i].Type = GSM_OperatorLogo;
5815 } else { 5887 } else {
5816 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); 5888 printmsg("What format of output file logo (\"%s\") ?\n",argv[4]);
5817 exit(-1); 5889 exit(-1);
5818 } 5890 }
5819 } 5891 }
5820 } 5892 }
5821 error=GSM_SaveBitmapFile(argv[3],&Bitmap); 5893 error=GSM_SaveBitmapFile(argv[3],&Bitmap);
5822 Print_Error(error); 5894 Print_Error(error);
5823 } 5895 }
5824} 5896}
5825 5897
5826static void NokiaComposer(int argc, char *argv[]) 5898static void NokiaComposer(int argc, char *argv[])
5827{ 5899{
5828 GSM_Ringtone ringtone; 5900 GSM_Ringtone ringtone;
5829 bool started; 5901 bool started;
5830 int i,j; 5902 int i,j;
5831 GSM_RingNote *Note; 5903 GSM_RingNote *Note;
5832 GSM_RingNoteDuration Duration; 5904 GSM_RingNoteDuration Duration;
5833 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ 5905 GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */
5834 unsigned int DefNoteScale = Scale_880; 5906 unsigned int DefNoteScale = Scale_880;
5835 5907
5836 ringtone.Format= 0; 5908 ringtone.Format= 0;
5837 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5909 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5838 5910
5839 if (ringtone.Format != RING_NOTETONE) { 5911 if (ringtone.Format != RING_NOTETONE) {
5840 printmsg("It can be RTTL ringtone only used with this option\n"); 5912 printmsg("It can be RTTL ringtone only used with this option\n");
5841 exit(-1); 5913 exit(-1);
5842 } 5914 }
5843 5915
5844 started = false; 5916 started = false;
5845 j= 0; 5917 j= 0;
5846 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5918 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5847 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5919 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5848 Note = &ringtone.NoteTone.Commands[i].Note; 5920 Note = &ringtone.NoteTone.Commands[i].Note;
5849 if (!started) { 5921 if (!started) {
5850 if (Note->Note != Note_Pause) { 5922 if (Note->Note != Note_Pause) {
5851 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); 5923 printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo));
5852 started = true; 5924 started = true;
5853 } 5925 }
5854 } 5926 }
5855 if (started) j++; 5927 if (started) j++;
5856 } 5928 }
5857 } 5929 }
5858 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); 5930 if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j);
5859 5931
5860 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); 5932 printmsg("\n\nThis ringtone in Nokia Composer in phone should look: ");
5861 started = false; 5933 started = false;
5862 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5934 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5863 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5935 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5864 Note = &ringtone.NoteTone.Commands[i].Note; 5936 Note = &ringtone.NoteTone.Commands[i].Note;
5865 if (!started) { 5937 if (!started) {
5866 if (Note->Note != Note_Pause) started = true; 5938 if (Note->Note != Note_Pause) started = true;
5867 } 5939 }
5868 if (started) { 5940 if (started) {
5869 switch (Note->Duration) { 5941 switch (Note->Duration) {
5870 case Duration_Full: printmsg("1"); break; 5942 case Duration_Full: printmsg("1"); break;
5871 case Duration_1_2 : printmsg("2"); break; 5943 case Duration_1_2 : printmsg("2"); break;
5872 case Duration_1_4 : printmsg("4"); break; 5944 case Duration_1_4 : printmsg("4"); break;
5873 case Duration_1_8 : printmsg("8"); break; 5945 case Duration_1_8 : printmsg("8"); break;
5874 case Duration_1_16: printmsg("16");break; 5946 case Duration_1_16: printmsg("16");break;
5875 case Duration_1_32: printmsg("32");break; 5947 case Duration_1_32: printmsg("32");break;
5876 } 5948 }
5877 if (Note->DurationSpec == DottedNote) printmsg("."); 5949 if (Note->DurationSpec == DottedNote) printmsg(".");
5878 switch (Note->Note) { 5950 switch (Note->Note) {
5879 case Note_C : printmsg("c");break; 5951 case Note_C : printmsg("c");break;
5880 case Note_Cis : printmsg("#c");break; 5952 case Note_Cis : printmsg("#c");break;
5881 case Note_D :printmsg("d");break; 5953 case Note_D :printmsg("d");break;
5882 case Note_Dis : printmsg("#d");break; 5954 case Note_Dis : printmsg("#d");break;
5883 case Note_E : printmsg("e");break; 5955 case Note_E : printmsg("e");break;
5884 case Note_F : printmsg("f");break; 5956 case Note_F : printmsg("f");break;
5885 case Note_Fis : printmsg("#f");break; 5957 case Note_Fis : printmsg("#f");break;
5886 case Note_G : printmsg("g");break; 5958 case Note_G : printmsg("g");break;
5887 case Note_Gis : printmsg("#g");break; 5959 case Note_Gis : printmsg("#g");break;
5888 case Note_A : printmsg("a");break; 5960 case Note_A : printmsg("a");break;
5889 case Note_Ais : printmsg("#a");break; 5961 case Note_Ais : printmsg("#a");break;
5890 case Note_H : printmsg("h");break; 5962 case Note_H : printmsg("h");break;
5891 case Note_Pause : printmsg("-");break; 5963 case Note_Pause : printmsg("-");break;
5892 } 5964 }
5893 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); 5965 if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4);
5894 printmsg(" "); 5966 printmsg(" ");
5895 } 5967 }
5896 } 5968 }
5897 } 5969 }
5898 5970
5899 printmsg("\n\nTo enter it please press: "); 5971 printmsg("\n\nTo enter it please press: ");
5900 started = false; 5972 started = false;
5901 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 5973 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
5902 if (ringtone.NoteTone.Commands[i].Type == RING_Note) { 5974 if (ringtone.NoteTone.Commands[i].Type == RING_Note) {
5903 Note = &ringtone.NoteTone.Commands[i].Note; 5975 Note = &ringtone.NoteTone.Commands[i].Note;
5904 if (!started) { 5976 if (!started) {
5905 if (Note->Note != Note_Pause) started = true; 5977 if (Note->Note != Note_Pause) started = true;
5906 } 5978 }
5907 if (started) { 5979 if (started) {
5908 switch (Note->Note) { 5980 switch (Note->Note) {
5909 case Note_C : case Note_Cis:printmsg("1");break; 5981 case Note_C : case Note_Cis:printmsg("1");break;
5910 case Note_D : case Note_Dis:printmsg("2");break; 5982 case Note_D : case Note_Dis:printmsg("2");break;
5911 case Note_E : printmsg("3");break; 5983 case Note_E : printmsg("3");break;
5912 case Note_F : case Note_Fis:printmsg("4");break; 5984 case Note_F : case Note_Fis:printmsg("4");break;
5913 case Note_G : case Note_Gis:printmsg("5");break; 5985 case Note_G : case Note_Gis:printmsg("5");break;
5914 case Note_A : case Note_Ais:printmsg("6");break; 5986 case Note_A : case Note_Ais:printmsg("6");break;
5915 case Note_H : printmsg("7");break; 5987 case Note_H : printmsg("7");break;
5916 default : printmsg("0");break; 5988 default : printmsg("0");break;
5917 } 5989 }
5918 if (Note->DurationSpec == DottedNote) printmsg("(longer)"); 5990 if (Note->DurationSpec == DottedNote) printmsg("(longer)");
5919 switch (Note->Note) { 5991 switch (Note->Note) {
5920 case Note_Cis: case Note_Dis: 5992 case Note_Cis: case Note_Dis:
5921 case Note_Fis: case Note_Gis: 5993 case Note_Fis: case Note_Gis:
5922 case Note_Ais: 5994 case Note_Ais:
5923 printmsg("#"); 5995 printmsg("#");
5924 break; 5996 break;
5925 default : 5997 default :
5926 break; 5998 break;
5927 } 5999 }
5928 if (Note->Note != Note_Pause) { 6000 if (Note->Note != Note_Pause) {
5929 if ((unsigned int)Note->Scale != DefNoteScale) { 6001 if ((unsigned int)Note->Scale != DefNoteScale) {
5930 while (DefNoteScale != (unsigned int)Note->Scale) { 6002 while (DefNoteScale != (unsigned int)Note->Scale) {
5931 printmsg("*"); 6003 printmsg("*");
5932 DefNoteScale++; 6004 DefNoteScale++;
5933 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; 6005 if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880;
5934 } 6006 }
5935 } 6007 }
5936 } 6008 }
5937 Duration = 0; 6009 Duration = 0;
5938 switch (Note->Duration) { 6010 switch (Note->Duration) {
5939 case Duration_Full : Duration = 128;break; 6011 case Duration_Full : Duration = 128;break;
5940 case Duration_1_2 : Duration = 64;break; 6012 case Duration_1_2 : Duration = 64;break;
5941 case Duration_1_4 : Duration = 32;break; 6013 case Duration_1_4 : Duration = 32;break;
5942 case Duration_1_8 : Duration = 16;break; 6014 case Duration_1_8 : Duration = 16;break;
5943 case Duration_1_16 : Duration = 8;break; 6015 case Duration_1_16 : Duration = 8;break;
5944 case Duration_1_32 : Duration = 4;break; 6016 case Duration_1_32 : Duration = 4;break;
5945 default : dbgprintf("error\n");break; 6017 default : dbgprintf("error\n");break;
5946 } 6018 }
5947 if (Duration > DefNoteDuration) { 6019 if (Duration > DefNoteDuration) {
5948 while (DefNoteDuration != Duration) { 6020 while (DefNoteDuration != Duration) {
5949 printmsg("9"); 6021 printmsg("9");
5950 DefNoteDuration = DefNoteDuration * 2; 6022 DefNoteDuration = DefNoteDuration * 2;
5951 } 6023 }
5952 } 6024 }
5953 if (Duration < DefNoteDuration) { 6025 if (Duration < DefNoteDuration) {
5954 while (DefNoteDuration != Duration) { 6026 while (DefNoteDuration != Duration) {
5955 printmsg("8"); 6027 printmsg("8");
5956 DefNoteDuration = DefNoteDuration / 2; 6028 DefNoteDuration = DefNoteDuration / 2;
5957 } 6029 }
5958 } 6030 }
5959 printmsg(" "); 6031 printmsg(" ");
5960 } 6032 }
5961 } 6033 }
5962 } 6034 }
5963 6035
5964 printf("\n"); 6036 printf("\n");
5965} 6037}
5966 6038
5967static void CopyRingtone(int argc, char *argv[]) 6039static void CopyRingtone(int argc, char *argv[])
5968{ 6040{
5969 GSM_Ringtone ringtone, ringtone2; 6041 GSM_Ringtone ringtone, ringtone2;
5970 GSM_RingtoneFormatFormat; 6042 GSM_RingtoneFormatFormat;
5971 6043
5972 ringtone.Format= 0; 6044 ringtone.Format= 0;
5973 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 6045 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5974 Print_Error(error); 6046 Print_Error(error);
5975 6047
5976 Format = ringtone.Format; 6048 Format = ringtone.Format;
5977 if (argc == 5) { 6049 if (argc == 5) {
5978 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; 6050 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
5979 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY; 6051 } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY;
5980 } else { 6052 } else {
5981 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); 6053 printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]);
5982 exit(-1); 6054 exit(-1);
5983 } 6055 }
5984 } 6056 }
5985 6057
5986 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); 6058 error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format);
5987 Print_Error(error); 6059 Print_Error(error);
5988 6060
5989 error=GSM_SaveRingtoneFile(argv[3],&ringtone2); 6061 error=GSM_SaveRingtoneFile(argv[3],&ringtone2);
5990 Print_Error(error); 6062 Print_Error(error);
5991} 6063}
5992 6064
5993static void PressKeySequence(int argc, char *argv[]) 6065static void PressKeySequence(int argc, char *argv[])
5994{ 6066{
5995 int i,Length; 6067 int i,Length;
5996 GSM_KeyCodeKeyCode[500]; 6068 GSM_KeyCodeKeyCode[500];
5997 6069
5998 error = MakeKeySequence(argv[2], KeyCode, &Length); 6070 error = MakeKeySequence(argv[2], KeyCode, &Length);
5999 if (error == ERR_NOTSUPPORTED) { 6071 if (error == ERR_NOTSUPPORTED) {
6000 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); 6072 printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]);
6001 exit(-1); 6073 exit(-1);
6002 } 6074 }
6003 6075
6004 GSM_Init(true); 6076 GSM_Init(true);
6005 6077
6006 for (i=0;i<Length;i++) { 6078 for (i=0;i<Length;i++) {
6007 error=Phone->PressKey(&s, KeyCode[i], true); 6079 error=Phone->PressKey(&s, KeyCode[i], true);
6008 Print_Error(error); 6080 Print_Error(error);
6009 error=Phone->PressKey(&s, KeyCode[i], false); 6081 error=Phone->PressKey(&s, KeyCode[i], false);
6010 Print_Error(error); 6082 Print_Error(error);
6011 } 6083 }
6012 6084
6013 GSM_Terminate(); 6085 GSM_Terminate();
6014} 6086}
6015 6087
6016static void GetAllCategories(int argc, char *argv[]) 6088static void GetAllCategories(int argc, char *argv[])
6017{ 6089{
6018 GSM_Category Category; 6090 GSM_Category Category;
6019 GSM_CategoryStatusStatus; 6091 GSM_CategoryStatusStatus;
6020 int j, count; 6092 int j, count;
6021 6093
6022 if (mystrncasecmp(argv[2],"TODO",0)) { 6094 if (mystrncasecmp(argv[2],"TODO",0)) {
6023 Category.Type = Category_ToDo; 6095 Category.Type = Category_ToDo;
6024 Status.Type = Category_ToDo; 6096 Status.Type = Category_ToDo;
6025 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 6097 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
6026 Category.Type = Category_Phonebook; 6098 Category.Type = Category_Phonebook;
6027 Status.Type = Category_Phonebook; 6099 Status.Type = Category_Phonebook;
6028 } else { 6100 } else {
6029 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 6101 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
6030 exit(-1); 6102 exit(-1);
6031 } 6103 }
6032 6104
6033 GSM_Init(true); 6105 GSM_Init(true);
6034 6106
6035 error=Phone->GetCategoryStatus(&s, &Status); 6107 error=Phone->GetCategoryStatus(&s, &Status);
6036 Print_Error(error); 6108 Print_Error(error);
6037 6109
6038 for (count=0,j=1;count<Status.Used;j++) 6110 for (count=0,j=1;count<Status.Used;j++)
6039 { 6111 {
6040 Category.Location=j; 6112 Category.Location=j;
6041 error=Phone->GetCategory(&s, &Category); 6113 error=Phone->GetCategory(&s, &Category);
6042 6114
6043 if (error != ERR_EMPTY) { 6115 if (error != ERR_EMPTY) {
6044 printmsg("Location: %i\n",j); 6116 printmsg("Location: %i\n",j);
6045 6117
6046 Print_Error(error); 6118 Print_Error(error);
6047 6119
6048 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 6120 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
6049 count++; 6121 count++;
6050 } 6122 }
6051 } 6123 }
6052 6124
6053 GSM_Terminate(); 6125 GSM_Terminate();
6054} 6126}
6055 6127
6056static void GetCategory(int argc, char *argv[]) 6128static void GetCategory(int argc, char *argv[])
6057{ 6129{
6058 GSM_CategoryCategory; 6130 GSM_CategoryCategory;
6059 int start,stop,j; 6131 int start,stop,j;
6060 6132
6061 if (mystrncasecmp(argv[2],"TODO",0)) { 6133 if (mystrncasecmp(argv[2],"TODO",0)) {
6062 Category.Type = Category_ToDo; 6134 Category.Type = Category_ToDo;
6063 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { 6135 } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) {
6064 Category.Type = Category_Phonebook; 6136 Category.Type = Category_Phonebook;
6065 } else { 6137 } else {
6066 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); 6138 printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]);
6067 exit(-1); 6139 exit(-1);
6068 } 6140 }
6069 6141
6070 GetStartStop(&start, &stop, 2, argc - 1, argv + 1); 6142 GetStartStop(&start, &stop, 2, argc - 1, argv + 1);
6071 6143
6072 GSM_Init(true); 6144 GSM_Init(true);
6073 6145
6074 for (j=start;j<=stop;j++) 6146 for (j=start;j<=stop;j++)
6075 { 6147 {
6076 printmsg("Location: %i\n",j); 6148 printmsg("Location: %i\n",j);
6077 6149
6078 Category.Location=j; 6150 Category.Location=j;
6079 6151
6080 error=Phone->GetCategory(&s, &Category); 6152 error=Phone->GetCategory(&s, &Category);
6081 if (error != ERR_EMPTY) Print_Error(error); 6153 if (error != ERR_EMPTY) Print_Error(error);
6082 6154
6083 if (error == ERR_EMPTY) { 6155 if (error == ERR_EMPTY) {
6084 printmsg("Entry is empty\n\n"); 6156 printmsg("Entry is empty\n\n");
6085 } else { 6157 } else {
6086 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); 6158 printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name));
6087 } 6159 }
6088 } 6160 }
6089 6161
6090 GSM_Terminate(); 6162 GSM_Terminate();
6091} 6163}
6092 6164
6093static void DeleteToDo(int argc, char *argv[]) 6165static void DeleteToDo(int argc, char *argv[])
6094{ 6166{
6095 GSM_ToDoEntryToDo; 6167 GSM_ToDoEntryToDo;
6096 int i; 6168 int i;
6097 int start,stop; 6169 int start,stop;
6098 6170
6099 GetStartStop(&start, &stop, 2, argc, argv); 6171 GetStartStop(&start, &stop, 2, argc, argv);
6100 6172
6101 GSM_Init(true); 6173 GSM_Init(true);
6102 6174
6103 for (i=start;i<=stop;i++) { 6175 for (i=start;i<=stop;i++) {
6104 ToDo.Location=i; 6176 ToDo.Location=i;
6105 printmsg("Location : %i\n",i); 6177 printmsg("Location : %i\n",i);
6106 error=Phone->DeleteToDo(&s,&ToDo); 6178 error=Phone->DeleteToDo(&s,&ToDo);
6107 if (error != ERR_EMPTY) Print_Error(error); 6179 if (error != ERR_EMPTY) Print_Error(error);
6108 6180
6109 if (error == ERR_EMPTY) { 6181 if (error == ERR_EMPTY) {
6110 printmsg("Entry was empty\n"); 6182 printmsg("Entry was empty\n");
6111 } else { 6183 } else {
6112 printmsg("Entry was deleted\n"); 6184 printmsg("Entry was deleted\n");
6113 } 6185 }
6114 printf("\n"); 6186 printf("\n");
6115 } 6187 }
6116 6188
6117 GSM_Terminate(); 6189 GSM_Terminate();
6118} 6190}
6119 6191
6120static void PrintToDo(GSM_ToDoEntry *ToDo) 6192static void PrintToDo(GSM_ToDoEntry *ToDo)
6121{ 6193{
6122 int j; 6194 int j;
6123 GSM_MemoryEntry entry; 6195 GSM_MemoryEntry entry;
6124 unsigned char *name; 6196 unsigned char *name;
6125 GSM_Category Category; 6197 GSM_Category Category;
6126 6198
6127 printmsg("Location : %i\n",ToDo->Location); 6199 printmsg("Location : %i\n",ToDo->Location);
6128 printmsg("Priority : "); 6200 printmsg("Priority : ");
6129 switch (ToDo->Priority) { 6201 switch (ToDo->Priority) {
6130 case GSM_Priority_Low : printmsg("Low\n"); break; 6202 case GSM_Priority_Low : printmsg("Low\n"); break;
6131 case GSM_Priority_Medium : printmsg("Medium\n"); break; 6203 case GSM_Priority_Medium : printmsg("Medium\n"); break;
6132 case GSM_Priority_High : printmsg("High\n"); break; 6204 case GSM_Priority_High : printmsg("High\n"); break;
6133 default : printmsg("Unknown\n");break; 6205 default : printmsg("Unknown\n");break;
6134 } 6206 }
6135 for (j=0;j<ToDo->EntriesNum;j++) { 6207 for (j=0;j<ToDo->EntriesNum;j++) {
6136 switch (ToDo->Entries[j].EntryType) { 6208 switch (ToDo->Entries[j].EntryType) {
6137 case TODO_END_DATETIME: 6209 case TODO_END_DATETIME:
6138 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6210 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
6139 break; 6211 break;
6140 case TODO_COMPLETED: 6212 case TODO_COMPLETED:
6141 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 6213 printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
6142 break; 6214 break;
6143 case TODO_ALARM_DATETIME: 6215 case TODO_ALARM_DATETIME:
6144 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6216 printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
6145 break; 6217 break;
6146 case TODO_SILENT_ALARM_DATETIME: 6218 case TODO_SILENT_ALARM_DATETIME:
6147 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6219 printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
6148 break; 6220 break;
6149 case TODO_TEXT: 6221 case TODO_TEXT:
6150 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6222 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
6151 break; 6223 break;
6152 case TODO_PRIVATE: 6224 case TODO_PRIVATE:
6153 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); 6225 printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No");
6154 break; 6226 break;
6155 case TODO_CATEGORY: 6227 case TODO_CATEGORY:
6156 Category.Location = ToDo->Entries[j].Number; 6228 Category.Location = ToDo->Entries[j].Number;
6157 Category.Type = Category_ToDo; 6229 Category.Type = Category_ToDo;
6158 error=Phone->GetCategory(&s, &Category); 6230 error=Phone->GetCategory(&s, &Category);
6159 if (error == ERR_NONE) { 6231 if (error == ERR_NONE) {
6160 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); 6232 printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number);
6161 } else { 6233 } else {
6162 printmsg("Category : %i\n", ToDo->Entries[j].Number); 6234 printmsg("Category : %i\n", ToDo->Entries[j].Number);
6163 } 6235 }
6164 break; 6236 break;
6165 case TODO_CONTACTID: 6237 case TODO_CONTACTID:
6166 entry.Location = ToDo->Entries[j].Number; 6238 entry.Location = ToDo->Entries[j].Number;
6167 entry.MemoryType = MEM_ME; 6239 entry.MemoryType = MEM_ME;
6168 error=Phone->GetMemory(&s, &entry); 6240 error=Phone->GetMemory(&s, &entry);
6169 if (error == ERR_NONE) { 6241 if (error == ERR_NONE) {
6170 name = GSM_PhonebookGetEntryName(&entry); 6242 name = GSM_PhonebookGetEntryName(&entry);
6171 if (name != NULL) { 6243 if (name != NULL) {
6172 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 6244 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
6173 } else { 6245 } else {
6174 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 6246 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
6175 } 6247 }
6176 } else { 6248 } else {
6177 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 6249 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
6178 } 6250 }
6179 break; 6251 break;
6180 case TODO_PHONE: 6252 case TODO_PHONE:
6181 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 6253 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
6182 break; 6254 break;
6183 } 6255 }
6184 } 6256 }
6185 printf("\n"); 6257 printf("\n");
6186} 6258}
6187 6259
6188static void ListToDoCategoryEntries(int Category) 6260static void ListToDoCategoryEntries(int Category)
6189{ 6261{
6190 GSM_ToDoEntry Entry; 6262 GSM_ToDoEntry Entry;
6191 bool start = true; 6263 bool start = true;
6192 int j; 6264 int j;
6193 6265
6194 while (!gshutdown) { 6266 while (!gshutdown) {
6195 error = Phone->GetNextToDo(&s, &Entry, start); 6267 error = Phone->GetNextToDo(&s, &Entry, start);
6196 if (error == ERR_EMPTY) break; 6268 if (error == ERR_EMPTY) break;
6197 Print_Error(error); 6269 Print_Error(error);
6198 for (j=0;j<Entry.EntriesNum;j++) { 6270 for (j=0;j<Entry.EntriesNum;j++) {
6199 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) 6271 if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category)
6200 PrintToDo(&Entry); 6272 PrintToDo(&Entry);
6201 } 6273 }
6202 start = false; 6274 start = false;
6203 } 6275 }
6204} 6276}
6205 6277
6206static void ListToDoCategory(int argc, char *argv[]) 6278static void ListToDoCategory(int argc, char *argv[])
6207{ 6279{
6208 GSM_Category Category; 6280 GSM_Category Category;
6209 GSM_CategoryStatusStatus; 6281 GSM_CategoryStatusStatus;
6210 int j, count; 6282 int j, count;
6211 6283
6212 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; 6284 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2];
6213 int Length; 6285 int Length;
6214 bool Number = true;; 6286 bool Number = true;;
6215 6287
6216 GSM_Init(true); 6288 GSM_Init(true);
6217 6289
6218 signal(SIGINT, interrupt); 6290 signal(SIGINT, interrupt);
6219 printmsgerr("Press Ctrl+C to break...\n"); 6291 printmsgerr("Press Ctrl+C to break...\n");
6220 6292
6221 Length = strlen(argv[2]); 6293 Length = strlen(argv[2]);
6222 for (j = 0; j < Length; j++) { 6294 for (j = 0; j < Length; j++) {
6223 if (!isdigit(argv[2][j])) { 6295 if (!isdigit(argv[2][j])) {
6224 Number = false; 6296 Number = false;
6225 break; 6297 break;
6226 } 6298 }
6227 } 6299 }
6228 6300
6229 if (Number) { 6301 if (Number) {
6230 j = atoi(argv[2]); 6302 j = atoi(argv[2]);
6231 if (j > 0) { 6303 if (j > 0) {
6232 ListToDoCategoryEntries(j); 6304 ListToDoCategoryEntries(j);
6233 } 6305 }
6234 } else { 6306 } else {
6235 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { 6307 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
6236 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); 6308 printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
6237 Length = GSM_MAX_CATEGORY_NAME_LENGTH; 6309 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
6238 } 6310 }
6239 EncodeUnicode(Text, argv[2], Length); 6311 EncodeUnicode(Text, argv[2], Length);
6240 6312
6241 Category.Type = Category_ToDo; 6313 Category.Type = Category_ToDo;
6242 Status.Type = Category_ToDo; 6314 Status.Type = Category_ToDo;
6243 6315
6244 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 6316 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
6245 for (count=0,j=1;count<Status.Used;j++) { 6317 for (count=0,j=1;count<Status.Used;j++) {
6246 Category.Location=j; 6318 Category.Location=j;
6247 error=Phone->GetCategory(&s, &Category); 6319 error=Phone->GetCategory(&s, &Category);
6248 6320
6249 if (error != ERR_EMPTY) { 6321 if (error != ERR_EMPTY) {
6250 count++; 6322 count++;
6251 if (mywstrstr(Category.Name, Text) != NULL) { 6323 if (mywstrstr(Category.Name, Text) != NULL) {
6252 ListToDoCategoryEntries(j); 6324 ListToDoCategoryEntries(j);
6253 } 6325 }
6254 } 6326 }
6255 } 6327 }
6256 } 6328 }
6257 } 6329 }
6258 GSM_Terminate(); 6330 GSM_Terminate();
6259} 6331}
6260 6332
6261 6333
6262static void GetToDo(int argc, char *argv[]) 6334static void GetToDo(int argc, char *argv[])
6263{ 6335{
6264 GSM_ToDoEntryToDo; 6336 GSM_ToDoEntryToDo;
6265 int i; 6337 int i;
6266 int start,stop; 6338 int start,stop;
6267 6339
6268 GetStartStop(&start, &stop, 2, argc, argv); 6340 GetStartStop(&start, &stop, 2, argc, argv);
6269 6341
6270 GSM_Init(true); 6342 GSM_Init(true);
6271 6343
6272 for (i=start;i<=stop;i++) { 6344 for (i=start;i<=stop;i++) {
6273 ToDo.Location=i; 6345 ToDo.Location=i;
6274 error = Phone->GetToDo(&s,&ToDo); 6346 error = Phone->GetToDo(&s,&ToDo);
6275 if (error == ERR_EMPTY) continue; 6347 if (error == ERR_EMPTY) continue;
6276 Print_Error(error); 6348 Print_Error(error);
6277 PrintToDo(&ToDo); 6349 PrintToDo(&ToDo);
6278 } 6350 }
6279 6351
6280 GSM_Terminate(); 6352 GSM_Terminate();
6281} 6353}
6282 6354
6283static void GetAllToDo(int argc, char *argv[]) 6355static void GetAllToDo(int argc, char *argv[])
6284{ 6356{
6285 GSM_ToDoEntry ToDo; 6357 GSM_ToDoEntry ToDo;
6286 bool start = true; 6358 bool start = true;
6287 6359
6288 signal(SIGINT, interrupt); 6360 signal(SIGINT, interrupt);
6289 printmsgerr("Press Ctrl+C to break...\n"); 6361 printmsgerr("Press Ctrl+C to break...\n");
6290 6362
6291 GSM_Init(true); 6363 GSM_Init(true);
6292 6364
6293 while (!gshutdown) { 6365 while (!gshutdown) {
6294 error = Phone->GetNextToDo(&s, &ToDo, start); 6366 error = Phone->GetNextToDo(&s, &ToDo, start);
6295 if (error == ERR_EMPTY) break; 6367 if (error == ERR_EMPTY) break;
6296 Print_Error(error); 6368 Print_Error(error);
6297 PrintToDo(&ToDo); 6369 PrintToDo(&ToDo);
6298 start = false; 6370 start = false;
6299 } 6371 }
6300 6372
6301 GSM_Terminate(); 6373 GSM_Terminate();
6302} 6374}
6303 6375
6304static void GetAllNotes(int argc, char *argv[]) 6376static void GetAllNotes(int argc, char *argv[])
6305{ 6377{
6306 GSM_NoteEntry Note; 6378 GSM_NoteEntry Note;
6307 bool start = true; 6379 bool start = true;
6308 6380
6309 signal(SIGINT, interrupt); 6381 signal(SIGINT, interrupt);
6310 printmsgerr("Press Ctrl+C to break...\n"); 6382 printmsgerr("Press Ctrl+C to break...\n");
6311 6383
6312 GSM_Init(true); 6384 GSM_Init(true);
6313 6385
6314 while (!gshutdown) { 6386 while (!gshutdown) {
6315 error = Phone->GetNextNote(&s, &Note, start); 6387 error = Phone->GetNextNote(&s, &Note, start);
6316 if (error == ERR_EMPTY) break; 6388 if (error == ERR_EMPTY) break;
6317 Print_Error(error); 6389 Print_Error(error);
6318 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text)); 6390 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
6319 printf("\n"); 6391 printf("\n");
6320 start = false; 6392 start = false;
6321 } 6393 }
6322 GSM_Terminate(); 6394 GSM_Terminate();
6323} 6395}
6324 6396
6325static void GetSecurityStatus(int argc, char *argv[]) 6397static void GetSecurityStatus(int argc, char *argv[])
6326{ 6398{
6327 GSM_Init(true); 6399 GSM_Init(true);
6328 6400
6329 PrintSecurityStatus(); 6401 PrintSecurityStatus();
6330 6402
6331 GSM_Terminate(); 6403 GSM_Terminate();
6332} 6404}
6333 6405
6334static void EnterSecurityCode(int argc, char *argv[]) 6406static void EnterSecurityCode(int argc, char *argv[])
6335{ 6407{
6336 GSM_SecurityCode Code; 6408 GSM_SecurityCode Code;
6337 6409
6338 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin; 6410 if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin;
6339 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk; 6411 } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk;
6340 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2; 6412 } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2;
6341 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2; 6413 } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2;
6342 } else { 6414 } else {
6343 printmsg("What security code (\"%s\") ?\n",argv[2]); 6415 printmsg("What security code (\"%s\") ?\n",argv[2]);
6344 exit(-1); 6416 exit(-1);
6345 } 6417 }
6346 6418
6347 strcpy(Code.Code,argv[3]); 6419 strcpy(Code.Code,argv[3]);
6348 6420
6349 GSM_Init(true); 6421 GSM_Init(true);
6350 6422
6351 error=Phone->EnterSecurityCode(&s,Code); 6423 error=Phone->EnterSecurityCode(&s,Code);
6352 Print_Error(error); 6424 Print_Error(error);
6353 6425
6354 GSM_Terminate(); 6426 GSM_Terminate();
6355} 6427}
6356 6428
6357static void GetProfile(int argc, char *argv[]) 6429static void GetProfile(int argc, char *argv[])
6358{ 6430{
6359 GSM_Profile Profile; 6431 GSM_Profile Profile;
6360 int start,stop,j,k; 6432 int start,stop,j,k;
6361 GSM_Bitmap caller[5]; 6433 GSM_Bitmap caller[5];
6362 bool callerinit[5],special; 6434 bool callerinit[5],special;
6363 GSM_AllRingtonesInfo Info; 6435 GSM_AllRingtonesInfo Info = {0, NULL};
6364 6436
6365 GetStartStop(&start, &stop, 2, argc, argv); 6437 GetStartStop(&start, &stop, 2, argc, argv);
6366 6438
6367 for (i=0;i<5;i++) callerinit[i] = false; 6439 for (i=0;i<5;i++) callerinit[i] = false;
6368 6440
6369 GSM_Init(true); 6441 GSM_Init(true);
6370 6442
6371 error=Phone->GetRingtonesInfo(&s,&Info); 6443 error=Phone->GetRingtonesInfo(&s,&Info);
6372 if (error != ERR_NONE) Info.Number = 0; 6444 if (error != ERR_NONE) Info.Number = 0;
6373 6445
6374 for (i=start;i<=stop;i++) { 6446 for (i=start;i<=stop;i++) {
6375 Profile.Location=i; 6447 Profile.Location=i;
6376 error=Phone->GetProfile(&s,&Profile); 6448 error=Phone->GetProfile(&s,&Profile);
6449 if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone);
6377 Print_Error(error); 6450 Print_Error(error);
6378 6451
6379 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); 6452 printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name));
6380 if (Profile.Active) printmsg(" (active)"); 6453 if (Profile.Active) printmsg(" (active)");
6381 if (Profile.DefaultName) printmsg(" (default name)"); 6454 if (Profile.DefaultName) printmsg(" (default name)");
6382 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); 6455 if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)");
6383 if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); 6456 if (Profile.CarKitProfile) printmsg(" (CarKit profile)");
6384 printf("\n"); 6457 printf("\n");
6385 for (j=0;j<Profile.FeaturesNumber;j++) { 6458 for (j=0;j<Profile.FeaturesNumber;j++) {
6386 special = false; 6459 special = false;
6387 switch (Profile.FeatureID[j]) { 6460 switch (Profile.FeatureID[j]) {
6388 case Profile_MessageToneID: 6461 case Profile_MessageToneID:
6389 case Profile_RingtoneID: 6462 case Profile_RingtoneID:
6390 special = true; 6463 special = true;
6391 if (Profile.FeatureID[j] == Profile_RingtoneID) { 6464 if (Profile.FeatureID[j] == Profile_RingtoneID) {
6392 printmsg("Ringtone ID : "); 6465 printmsg("Ringtone ID : ");
6393 } else { 6466 } else {
6394 printmsg("Message alert tone ID : "); 6467 printmsg("Message alert tone ID : ");
6395 } 6468 }
6396 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { 6469 if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) {
6397 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); 6470 printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j])));
6398 } else { 6471 } else {
6399 printmsg("%i\n",Profile.FeatureValue[j]); 6472 printmsg("%i\n",Profile.FeatureValue[j]);
6400 } 6473 }
6401 break; 6474 break;
6402 case Profile_CallerGroups: 6475 case Profile_CallerGroups:
6403 special = true; 6476 special = true;
6404 printmsg("Call alert for :"); 6477 printmsg("Call alert for :");
6405 for (k=0;k<5;k++) { 6478 for (k=0;k<5;k++) {
6406 if (Profile.CallerGroups[k]) { 6479 if (Profile.CallerGroups[k]) {
6407 if (!callerinit[k]) { 6480 if (!callerinit[k]) {
6408 caller[k].Type = GSM_CallerGroupLogo; 6481 caller[k].Type = GSM_CallerGroupLogo;
6409 caller[k].Location = k + 1; 6482 caller[k].Location = k + 1;
6410 error=Phone->GetBitmap(&s,&caller[k]); 6483 error=Phone->GetBitmap(&s,&caller[k]);
6411 if (error == ERR_SECURITYERROR) { 6484 if (error == ERR_SECURITYERROR) {
6412 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); 6485 NOKIA_GetDefaultCallerGroupName(&s,&caller[k]);
6413 } else { 6486 } else {
6414 Print_Error(error); 6487 Print_Error(error);
6415 } 6488 }
6416 callerinit[k]= true; 6489 callerinit[k]= true;
6417 } 6490 }
6418 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); 6491 printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text));
6419 } 6492 }
6420 } 6493 }
6421 printf("\n"); 6494 printf("\n");
6422 break; 6495 break;
6423 case Profile_ScreenSaverNumber: 6496 case Profile_ScreenSaverNumber:
6424 special = true; 6497 special = true;
6425 printmsg("Screen saver number : "); 6498 printmsg("Screen saver number : ");
6426 printmsg("%i\n",Profile.FeatureValue[j]); 6499 printmsg("%i\n",Profile.FeatureValue[j]);
6427 break; 6500 break;
6428 case Profile_CallAlert : printmsg("Incoming call alert : "); break; 6501 case Profile_CallAlert : printmsg("Incoming call alert : "); break;
6429 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; 6502 case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break;
6430 case Profile_Vibration : printmsg("Vibrating alert : "); break; 6503 case Profile_Vibration : printmsg("Vibrating alert : "); break;
6431 case Profile_MessageTone: printmsg("Message alert tone : "); break; 6504 case Profile_MessageTone: printmsg("Message alert tone : "); break;
6432 case Profile_KeypadTone : printmsg("Keypad tones : "); break; 6505 case Profile_KeypadTone : printmsg("Keypad tones : "); break;
6433 case Profile_WarningTone: printmsg("Warning (games) tones : "); break; 6506 case Profile_WarningTone: printmsg("Warning (games) tones : "); break;
6434 case Profile_ScreenSaver: printmsg("Screen saver : "); break; 6507 case Profile_ScreenSaver: printmsg("Screen saver : "); break;
6435 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break; 6508 case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break;
6436 case Profile_AutoAnswer : printmsg("Automatic answer : "); break; 6509 case Profile_AutoAnswer : printmsg("Automatic answer : "); break;
6437 case Profile_Lights : printmsg("Lights : "); break; 6510 case Profile_Lights : printmsg("Lights : "); break;
6438 default: 6511 default:
6439 printmsg("Unknown\n"); 6512 printmsg("Unknown\n");
6440 special = true; 6513 special = true;
6441 } 6514 }
6442 if (!special) { 6515 if (!special) {
6443 switch (Profile.FeatureValue[j]) { 6516 switch (Profile.FeatureValue[j]) {
6444 case PROFILE_VOLUME_LEVEL1 : 6517 case PROFILE_VOLUME_LEVEL1 :
6445 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; 6518 case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break;
6446 case PROFILE_VOLUME_LEVEL2 : 6519 case PROFILE_VOLUME_LEVEL2 :
6447 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; 6520 case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break;
6448 case PROFILE_VOLUME_LEVEL3 : 6521 case PROFILE_VOLUME_LEVEL3 :
6449 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; 6522 case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break;
6450 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; 6523 case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break;
6451 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; 6524 case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break;
6452 case PROFILE_MESSAGE_NOTONE : 6525 case PROFILE_MESSAGE_NOTONE :
6453 case PROFILE_AUTOANSWER_OFF : 6526 case PROFILE_AUTOANSWER_OFF :
6454 case PROFILE_LIGHTS_OFF : 6527 case PROFILE_LIGHTS_OFF :
6455 case PROFILE_SAVER_OFF : 6528 case PROFILE_SAVER_OFF :
6456 case PROFILE_WARNING_OFF : 6529 case PROFILE_WARNING_OFF :
6457 case PROFILE_CALLALERT_OFF : 6530 case PROFILE_CALLALERT_OFF :
6458 case PROFILE_VIBRATION_OFF : 6531 case PROFILE_VIBRATION_OFF :
6459 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; 6532 case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break;
6460 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; 6533 case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break;
6461 case PROFILE_CALLALERT_BEEPONCE : 6534 case PROFILE_CALLALERT_BEEPONCE :
6462 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; 6535 case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break;
6463 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break; 6536 case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break;
6464 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; 6537 case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break;
6465 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break; 6538 case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break;
6466 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; 6539 case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break;
6467 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; 6540 case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break;
6468 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; 6541 case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break;
6469 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; 6542 case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break;
6470 case PROFILE_AUTOANSWER_ON : 6543 case PROFILE_AUTOANSWER_ON :
6471 case PROFILE_WARNING_ON : 6544 case PROFILE_WARNING_ON :
6472 case PROFILE_SAVER_ON : 6545 case PROFILE_SAVER_ON :
6473 case PROFILE_VIBRATION_ON : printmsg("On\n"); break; 6546 case PROFILE_VIBRATION_ON : printmsg("On\n"); break;
6474 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break; 6547 case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break;
6475 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; 6548 case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break;
6476 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; 6549 case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break;
6477 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; 6550 case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break;
6478 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; 6551 case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break;
6479 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break; 6552 case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break;
6480 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break; 6553 case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break;
6481 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break; 6554 case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break;
6482 default : printmsg("UNKNOWN\n"); 6555 default : printmsg("UNKNOWN\n");
6483 } 6556 }
6484 } 6557 }
6485 } 6558 }
6486 printf("\n"); 6559 printf("\n");
6487 } 6560 }
6488 6561
6489 GSM_Terminate(); 6562 GSM_Terminate();
6563
6564 if (Info.Ringtone) free(Info.Ringtone);
6490} 6565}
6491 6566
6492static void GetSpeedDial(int argc, char *argv[]) 6567static void GetSpeedDial(int argc, char *argv[])
6493{ 6568{
6494 GSM_SpeedDial SpeedDial; 6569 GSM_SpeedDial SpeedDial;
6495 GSM_MemoryEntry Phonebook; 6570 GSM_MemoryEntry Phonebook;
6496 int start,stop,Name,Number,Group; 6571 int start,stop,Name,Number,Group;
6497 6572
6498 GetStartStop(&start, &stop, 2, argc, argv); 6573 GetStartStop(&start, &stop, 2, argc, argv);
6499 6574
6500 GSM_Init(true); 6575 GSM_Init(true);
6501 6576
6502 for (i=start;i<=stop;i++) { 6577 for (i=start;i<=stop;i++) {
6503 SpeedDial.Location=i; 6578 SpeedDial.Location=i;
6504 error=Phone->GetSpeedDial(&s,&SpeedDial); 6579 error=Phone->GetSpeedDial(&s,&SpeedDial);
6505 printmsg("%i.",i); 6580 printmsg("%i.",i);
6506 switch (error) { 6581 switch (error) {
6507 case ERR_EMPTY: 6582 case ERR_EMPTY:
6508 printmsg(" speed dial not assigned\n"); 6583 printmsg(" speed dial not assigned\n");
6509 break; 6584 break;
6510 default: 6585 default:
6511 Print_Error(error); 6586 Print_Error(error);
6512 6587
6513 Phonebook.Location= SpeedDial.MemoryLocation; 6588 Phonebook.Location= SpeedDial.MemoryLocation;
6514 Phonebook.MemoryType = SpeedDial.MemoryType; 6589 Phonebook.MemoryType = SpeedDial.MemoryType;
6515 error=Phone->GetMemory(&s,&Phonebook); 6590 error=Phone->GetMemory(&s,&Phonebook);
6516 6591
6517 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); 6592 GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group);
6518 6593
6519 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); 6594 if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text));
6520 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); 6595 printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text));
6521 } 6596 }
6522 printf("\n"); 6597 printf("\n");
6523 } 6598 }
6524 6599
6525 GSM_Terminate(); 6600 GSM_Terminate();
6526} 6601}
6527 6602
6528static void ResetPhoneSettings(int argc, char *argv[]) 6603static void ResetPhoneSettings(int argc, char *argv[])
6529{ 6604{
6530 GSM_ResetSettingsType Type; 6605 GSM_ResetSettingsType Type;
6531 6606
6532 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; 6607 if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS;
6533 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; 6608 } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE;
6534 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; 6609 } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS;
6535 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; 6610 } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE;
6536 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; 6611 } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY;
6537 } else { 6612 } else {
6538 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); 6613 printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]);
6539 exit(-1); 6614 exit(-1);
6540 } 6615 }
6541 6616
6542 GSM_Init(true); 6617 GSM_Init(true);
6543 6618
6544 error=Phone->ResetPhoneSettings(&s,Type); 6619 error=Phone->ResetPhoneSettings(&s,Type);
6545 Print_Error(error); 6620 Print_Error(error);
6546 6621
6547 GSM_Terminate(); 6622 GSM_Terminate();
6548} 6623}
6549 6624
6550#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 6625#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
6551static void NokiaSecurityCode(int argc, char *argv[]) 6626static void NokiaSecurityCode(int argc, char *argv[])
6552{ 6627{
6553 GSM_Init(true); 6628 GSM_Init(true);
6554 6629
6555#ifdef GSM_ENABLE_NOKIA_DCT3 6630#ifdef GSM_ENABLE_NOKIA_DCT3
6556 DCT3GetSecurityCode(argc,argv); 6631 DCT3GetSecurityCode(argc,argv);
6557#endif 6632#endif
6558#ifdef GSM_ENABLE_NOKIA_DCT4 6633#ifdef GSM_ENABLE_NOKIA_DCT4
6559 //DCT4ResetSecurityCode(argc, argv); 6634 //DCT4ResetSecurityCode(argc, argv);
6560 DCT4GetSecurityCode(argc,argv); 6635 DCT4GetSecurityCode(argc,argv);
6561#endif 6636#endif
6562 6637
6563 GSM_Terminate(); 6638 GSM_Terminate();
6564} 6639}
6565 6640
6566static void NokiaSetPhoneMenus(int argc, char *argv[]) 6641static void NokiaSetPhoneMenus(int argc, char *argv[])
6567{ 6642{
6568 GSM_Init(true); 6643 GSM_Init(true);
6569 6644
6570#ifdef GSM_ENABLE_NOKIA_DCT3 6645#ifdef GSM_ENABLE_NOKIA_DCT3
6571 DCT3SetPhoneMenus (argc, argv); 6646 DCT3SetPhoneMenus (argc, argv);
6572#endif 6647#endif
6573#ifdef GSM_ENABLE_NOKIA_DCT4 6648#ifdef GSM_ENABLE_NOKIA_DCT4
6574 DCT4SetPhoneMenus (argc, argv); 6649 DCT4SetPhoneMenus (argc, argv);
6575#endif 6650#endif
6576 6651
6577 GSM_Terminate(); 6652 GSM_Terminate();
6578} 6653}
6579 6654
6580static void NokiaSelfTests(int argc, char *argv[]) 6655static void NokiaSelfTests(int argc, char *argv[])
6581{ 6656{
6582 GSM_Init(true); 6657 GSM_Init(true);
6583 6658
6584#ifdef GSM_ENABLE_NOKIA_DCT3 6659#ifdef GSM_ENABLE_NOKIA_DCT3
6585 DCT3SelfTests(argc, argv); 6660 DCT3SelfTests(argc, argv);
6586#endif 6661#endif
6587#ifdef GSM_ENABLE_NOKIA_DCT4 6662#ifdef GSM_ENABLE_NOKIA_DCT4
6588 DCT4SelfTests(argc, argv); 6663 DCT4SelfTests(argc, argv);
6589#endif 6664#endif
6590 6665
6591 GSM_Terminate(); 6666 GSM_Terminate();
6592} 6667}
6593#endif 6668#endif
6594 6669
6595static void DeleteAllSMS(int argc, char *argv[]) 6670static void DeleteAllSMS(int argc, char *argv[])
6596{ 6671{
6597 GSM_MultiSMSMessage sms; 6672 GSM_MultiSMSMessage sms;
6598 GSM_SMSFolders folders; 6673 GSM_SMSFolders folders;
6599 int foldernum; 6674 int foldernum;
6600 bool start = true; 6675 bool start = true;
6601 6676
6602 GSM_Init(true); 6677 GSM_Init(true);
6603 6678
6604 error=Phone->GetSMSFolders(&s, &folders); 6679 error=Phone->GetSMSFolders(&s, &folders);
6605 Print_Error(error); 6680 Print_Error(error);
6606 6681
6607 GetStartStop(&foldernum, NULL, 2, argc, argv); 6682 GetStartStop(&foldernum, NULL, 2, argc, argv);
6608 if (foldernum > folders.Number) { 6683 if (foldernum > folders.Number) {
6609 printmsg("Too high folder number (max. %i)\n",folders.Number); 6684 printmsg("Too high folder number (max. %i)\n",folders.Number);
6610 GSM_Terminate(); 6685 GSM_Terminate();
6611 exit(-1); 6686 exit(-1);
6612 } 6687 }
6613 6688
6614 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); 6689 printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name));
6615 6690
6616 while (error == ERR_NONE) { 6691 while (error == ERR_NONE) {
6617 sms.SMS[0].Folder=0x00; 6692 sms.SMS[0].Folder=0x00;
6618 error=Phone->GetNextSMS(&s, &sms, start); 6693 error=Phone->GetNextSMS(&s, &sms, start);
6619 switch (error) { 6694 switch (error) {
6620 case ERR_EMPTY: 6695 case ERR_EMPTY:
6621 break; 6696 break;
6622 default: 6697 default:
6623 Print_Error(error); 6698 Print_Error(error);
6624 if (sms.SMS[0].Folder == foldernum) { 6699 if (sms.SMS[0].Folder == foldernum) {
6625 sms.SMS[0].Folder=0x00; 6700 sms.SMS[0].Folder=0x00;
6626 error=Phone->DeleteSMS(&s, &sms.SMS[0]); 6701 error=Phone->DeleteSMS(&s, &sms.SMS[0]);
6627 Print_Error(error); 6702 Print_Error(error);
6628 printmsg("*"); 6703 printmsg("*");
6629 } 6704 }
6630 } 6705 }
6631 start=false; 6706 start=false;
6632 } 6707 }
6633 6708
6634 printf("\n"); 6709 printf("\n");
6635 6710
6636 GSM_Terminate(); 6711 GSM_Terminate();
6637} 6712}
6638 6713
6639static void SendDTMF(int argc, char *argv[]) 6714static void SendDTMF(int argc, char *argv[])
6640{ 6715{
6641 GSM_Init(true); 6716 GSM_Init(true);
6642 6717
6643 error=Phone->SendDTMF(&s,argv[2]); 6718 error=Phone->SendDTMF(&s,argv[2]);
6644 Print_Error(error); 6719 Print_Error(error);
6645 6720
6646 GSM_Terminate(); 6721 GSM_Terminate();
6647} 6722}
6648 6723
6649static void GetDisplayStatus(int argc, char *argv[]) 6724static void GetDisplayStatus(int argc, char *argv[])
6650{ 6725{
6651 GSM_DisplayFeatures Features; 6726 GSM_DisplayFeatures Features;
6652 int i; 6727 int i;
6653 6728
6654 GSM_Init(true); 6729 GSM_Init(true);
6655 6730
6656 error=Phone->GetDisplayStatus(&s,&Features); 6731 error=Phone->GetDisplayStatus(&s,&Features);
6657 Print_Error(error); 6732 Print_Error(error);
6658 6733
6659 printmsg("Current display features :\n"); 6734 printmsg("Current display features :\n");
6660 6735
6661 for (i=0;i<Features.Number;i++) { 6736 for (i=0;i<Features.Number;i++) {
6662 switch(Features.Feature[i]) { 6737 switch(Features.Feature[i]) {
6663 case GSM_CallActive : printmsg("Call active\n");break; 6738 case GSM_CallActive : printmsg("Call active\n");break;
6664 case GSM_UnreadSMS : printmsg("Unread SMS\n");break; 6739 case GSM_UnreadSMS : printmsg("Unread SMS\n");break;
6665 case GSM_VoiceCall : printmsg("Voice call\n");break; 6740 case GSM_VoiceCall : printmsg("Voice call\n");break;
6666 case GSM_FaxCall : printmsg("Fax call\n");break; 6741 case GSM_FaxCall : printmsg("Fax call\n");break;
6667 case GSM_DataCall : printmsg("Data call\n");break; 6742 case GSM_DataCall : printmsg("Data call\n");break;
6668 case GSM_KeypadLocked : printmsg("Keypad locked\n");break; 6743 case GSM_KeypadLocked : printmsg("Keypad locked\n");break;
6669 case GSM_SMSMemoryFull: printmsg("SMS memory full\n"); 6744 case GSM_SMSMemoryFull: printmsg("SMS memory full\n");
6670 } 6745 }
6671 } 6746 }
6672 6747
6673 GSM_Terminate(); 6748 GSM_Terminate();
6674} 6749}
6675 6750
6676static void SetAutoNetworkLogin(int argc, char *argv[]) 6751static void SetAutoNetworkLogin(int argc, char *argv[])
6677{ 6752{
6678 GSM_Init(true); 6753 GSM_Init(true);
6679 6754
6680 error=Phone->SetAutoNetworkLogin(&s); 6755 error=Phone->SetAutoNetworkLogin(&s);
6681 Print_Error(error); 6756 Print_Error(error);
6682 6757
6683 GSM_Terminate(); 6758 GSM_Terminate();
6684} 6759}
6685 6760
6686#ifdef DEBUG 6761#ifdef DEBUG
6687static void MakeConvertTable(int argc, char *argv[]) 6762static void MakeConvertTable(int argc, char *argv[])
6688{ 6763{
6689 unsigned char InputBuffer[10000], Buffer[10000]; 6764 unsigned char InputBuffer[10000], Buffer[10000];
6690 FILE *file; 6765 FILE *file;
6691 int size,i,j=0; 6766 int size,i,j=0;
6692 6767
6693 file = fopen(argv[2], "rb"); 6768 file = fopen(argv[2], "rb");
6694 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 6769 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
6695 size=fread(InputBuffer, 1, 10000-1, file); 6770 size=fread(InputBuffer, 1, 10000-1, file);
6696 fclose(file); 6771 fclose(file);
6697 InputBuffer[size] = 0; 6772 InputBuffer[size] = 0;
6698 InputBuffer[size+1] = 0; 6773 InputBuffer[size+1] = 0;
6699 6774
6700 ReadUnicodeFile(Buffer,InputBuffer); 6775 ReadUnicodeFile(Buffer,InputBuffer);
6701 6776
6702 for(i=0;i<((int)UnicodeLength(Buffer));i++) { 6777 for(i=0;i<((int)UnicodeLength(Buffer));i++) {
6703 j++; 6778 j++;
6704 if (j==100) { 6779 if (j==100) {
6705 printf("\"\\\n\""); 6780 printf("\"\\\n\"");
6706 j=0; 6781 j=0;
6707 } 6782 }
6708 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); 6783 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
6709 } 6784 }
6710 printf("\\x00\\x00"); 6785 printf("\\x00\\x00");
6711} 6786}
6712#endif 6787#endif
6713 6788
6714static void ListNetworks(int argc, char *argv[]) 6789static void ListNetworks(int argc, char *argv[])
6715{ 6790{
6716 extern unsigned char *GSM_Networks[]; 6791 extern unsigned char *GSM_Networks[];
6717 extern unsigned char *GSM_Countries[]; 6792 extern unsigned char *GSM_Countries[];
6718 int i=0; 6793 int i=0;
6719 char country[4]=""; 6794 char country[4]="";
6720 6795
6721 if (argc>2) { 6796 if (argc>2) {
6722 while (GSM_Countries[i*2]!=NULL) { 6797 while (GSM_Countries[i*2]!=NULL) {
6723 if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) { 6798 if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) {
6724 strcpy(country,GSM_Countries[i*2]); 6799 strcpy(country,GSM_Countries[i*2]);
6725 printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]); 6800 printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]);
6726 break; 6801 break;
6727 } 6802 }
6728 i++; 6803 i++;
6729 } 6804 }
6730 if (!*country) { 6805 if (!*country) {
6731 printmsg("Unknown country name."); 6806 printmsg("Unknown country name.");
6732 exit(-1); 6807 exit(-1);
6733 } 6808 }
6734 } 6809 }
6735 printmsg("Network Name\n"); 6810 printmsg("Network Name\n");
6736 i=0; 6811 i=0;
6737 while (GSM_Networks[i*2]!=NULL) { 6812 while (GSM_Networks[i*2]!=NULL) {
6738 if (argc>2) { 6813 if (argc>2) {
6739 if (!strncmp(GSM_Networks[i*2],country,strlen(country))) { 6814 if (!strncmp(GSM_Networks[i*2],country,strlen(country))) {
6740 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6815 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6741 } 6816 }
6742 } else { 6817 } else {
6743 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6818 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6744 } 6819 }
6745 i++; 6820 i++;
6746 } 6821 }
6747} 6822}
6748 6823
6749static void Version(int argc, char *argv[]) 6824static void Version(int argc, char *argv[])
6750{ 6825{
6751 // unsigned char buff[10]; 6826 // unsigned char buff[10];
6752 // int len; 6827 // int len;
6753 6828
6754 printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__); 6829 printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__);
6755 if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler()); 6830 if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler());
6756 printmsg("]\n\n"); 6831 printmsg("]\n\n");
6757 6832
6758#ifdef DEBUG 6833#ifdef DEBUG
6759 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); 6834 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
6760 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); 6835 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
6761 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); 6836 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
6762 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); 6837 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
6763 printf("bool - %i\n",sizeof(bool)); 6838 printf("bool - %i\n",sizeof(bool));
6764 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); 6839 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
6765 printf("int - %i\n",sizeof(int)); 6840 printf("int - %i\n",sizeof(int));
6766 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); 6841 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
6767#endif 6842#endif
6768 6843
6769 //len=DecodeBASE64("AXw", buff, 3); 6844 //len=DecodeBASE64("AXw", buff, 3);
6770 //DumpMessage(stdout, buff, len); 6845 //DumpMessage(stdout, buff, len);
6771} 6846}
6772 6847
6773static void GetFMStation(int argc, char *argv[]) 6848static void GetFMStation(int argc, char *argv[])
6774{ 6849{
6775 GSM_FMStation Station; 6850 GSM_FMStation Station;
6776 int start,stop; 6851 int start,stop;
6777 6852
6778 GetStartStop(&start, &stop, 2, argc, argv); 6853 GetStartStop(&start, &stop, 2, argc, argv);
6779 6854
6780 GSM_Init(true); 6855 GSM_Init(true);
6781 6856
6782 for (i=start;i<=stop;i++) { 6857 for (i=start;i<=stop;i++) {
6783 Station.Location=i; 6858 Station.Location=i;
6784 error=Phone->GetFMStation(&s,&Station); 6859 error=Phone->GetFMStation(&s,&Station);
6785 switch (error) { 6860 switch (error) {
6786 case ERR_EMPTY: 6861 case ERR_EMPTY:
6787 printmsg("Entry number %i is empty\n",i); 6862 printmsg("Entry number %i is empty\n",i);
6788 break; 6863 break;
6789 case ERR_NONE: 6864 case ERR_NONE:
6790 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", 6865 printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n",
6791 i,DecodeUnicodeConsole(Station.StationName), 6866 i,DecodeUnicodeConsole(Station.StationName),
6792 Station.Frequency); 6867 Station.Frequency);
6793 break; 6868 break;
6794 default: 6869 default:
6795 Print_Error(error); 6870 Print_Error(error);
6796 } 6871 }
6797 } 6872 }
6798 GSM_Terminate(); 6873 GSM_Terminate();
6799} 6874}
6800 6875
6801static void GetFileSystemStatus(int argc, char *argv[]) 6876static void GetFileSystemStatus(int argc, char *argv[])
6802{ 6877{
6803 GSM_FileSystemStatusStatus; 6878 GSM_FileSystemStatusStatus;
6804 6879
6805 GSM_Init(true); 6880 GSM_Init(true);
6806 6881
6807 error = Phone->GetFileSystemStatus(&s,&Status); 6882 error = Phone->GetFileSystemStatus(&s,&Status);
6808 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6883 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6809 Print_Error(error); 6884 Print_Error(error);
6810 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6885 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6811 } 6886 }
6812 6887
6813 GSM_Terminate(); 6888 GSM_Terminate();
6814} 6889}
6815 6890
6816static void GetFileSystem(int argc, char *argv[]) 6891static void GetFileSystem(int argc, char *argv[])
6817{ 6892{
6818 bool Start = true; 6893 bool Start = true;
6819 GSM_File Files; 6894 GSM_File Files;
6820 int j; 6895 int j;
6821 GSM_FileSystemStatusStatus; 6896 GSM_FileSystemStatusStatus;
6822 char FolderName[256]; 6897 char FolderName[256];
6823 6898
6824 GSM_Init(true); 6899 GSM_Init(true);
6825 6900
6826 while (1) { 6901 while (1) {
6827 error = Phone->GetNextFileFolder(&s,&Files,Start); 6902 error = Phone->GetNextFileFolder(&s,&Files,Start);
6828 if (error == ERR_EMPTY) break; 6903 if (error == ERR_EMPTY) break;
6829 Print_Error(error); 6904 Print_Error(error);
6830 6905
6831 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { 6906 if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) {
6832 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { 6907 if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) {
6833 printf("%5s.",Files.ID_FullName); 6908 printf("%5s.",Files.ID_FullName);
6834 } 6909 }
6835 if (Files.Protected) { 6910 if (Files.Protected) {
6836 printf("P"); 6911 printf("P");
6837 } else { 6912 } else {
6838 printf(" "); 6913 printf(" ");
6839 } 6914 }
6840 if (Files.ReadOnly) { 6915 if (Files.ReadOnly) {
6841 printf("R"); 6916 printf("R");
6842 } else { 6917 } else {
6843 printf(" "); 6918 printf(" ");
6844 } 6919 }
6845 if (Files.Hidden) { 6920 if (Files.Hidden) {
6846 printf("H"); 6921 printf("H");
6847 } else { 6922 } else {
6848 printf(" "); 6923 printf(" ");
6849 } 6924 }
6850 if (Files.System) { 6925 if (Files.System) {
6851 printf("S"); 6926 printf("S");
6852 } else { 6927 } else {
6853 printf(" "); 6928 printf(" ");
6854 } 6929 }
6855 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { 6930 if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) {
6856 if (!Files.Folder) { 6931 if (!Files.Folder) {
6857 if (mystrncasecmp(argv[2],"-flatall",0)) { 6932 if (mystrncasecmp(argv[2],"-flatall",0)) {
6858 if (!Files.ModifiedEmpty) { 6933 if (!Files.ModifiedEmpty) {
6859 printf(" %30s",OSDateTime(Files.Modified,false)); 6934 printf(" %30s",OSDateTime(Files.Modified,false));
6860 } else printf(" %30c",0x20); 6935 } else printf(" %30c",0x20);
6861 printf(" %9i",Files.Used); 6936 printf(" %9i",Files.Used);
6862 printf(" "); 6937 printf(" ");
6863 } else printf("|-- "); 6938 } else printf("|-- ");
6864 } else printf("Folder "); 6939 } else printf("Folder ");
6865 } else { 6940 } else {
6866 if (Files.Level != 1) { 6941 if (Files.Level != 1) {
6867 for (j=0;j<Files.Level-2;j++) printf(" | "); 6942 for (j=0;j<Files.Level-2;j++) printf(" | ");
6868 printf(" |-- "); 6943 printf(" |-- ");
6869 } 6944 }
6870 if (Files.Folder) printf("Folder "); 6945 if (Files.Folder) printf("Folder ");
6871 } 6946 }
6872 printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); 6947 printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
6873 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { 6948 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
@@ -7598,769 +7673,769 @@ static void SaveMMSFile(int argc, char *argv[])
7598 continue; 7673 continue;
7599 } 7674 }
7600 if (mystrncasecmp(argv[i],"-from",0)) { 7675 if (mystrncasecmp(argv[i],"-from",0)) {
7601 nextlong=3; 7676 nextlong=3;
7602 continue; 7677 continue;
7603 } 7678 }
7604 if (mystrncasecmp(argv[i],"-to",0)) { 7679 if (mystrncasecmp(argv[i],"-to",0)) {
7605 nextlong=4; 7680 nextlong=4;
7606 continue; 7681 continue;
7607 } 7682 }
7608 printmsg("Unknown parameter (\"%s\")\n",argv[i]); 7683 printmsg("Unknown parameter (\"%s\")\n",argv[i]);
7609 exit(-1); 7684 exit(-1);
7610 break; 7685 break;
7611 case 1: /* Subject */ 7686 case 1: /* Subject */
7612 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); 7687 EncodeUnicode(Info.Subject,argv[i],strlen(argv[i]));
7613 nextlong = 0; 7688 nextlong = 0;
7614 break; 7689 break;
7615 case 2: /* Text */ 7690 case 2: /* Text */
7616 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); 7691 EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i]));
7617 Info.Entries[Info.EntriesNum].ID = MMS_Text; 7692 Info.Entries[Info.EntriesNum].ID = MMS_Text;
7618 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; 7693 Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum];
7619 Info.EntriesNum++; 7694 Info.EntriesNum++;
7620 nextlong = 0; 7695 nextlong = 0;
7621 break; 7696 break;
7622 case 3: /* From */ 7697 case 3: /* From */
7623 EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); 7698 EncodeUnicode(Info.Source,argv[i],strlen(argv[i]));
7624 nextlong = 0; 7699 nextlong = 0;
7625 break; 7700 break;
7626 case 4: /* To */ 7701 case 4: /* To */
7627 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); 7702 EncodeUnicode(Info.Destination,argv[i],strlen(argv[i]));
7628 nextlong = 0; 7703 nextlong = 0;
7629 break; 7704 break;
7630 } 7705 }
7631 } 7706 }
7632 if (nextlong!=0) { 7707 if (nextlong!=0) {
7633 printmsg("Parameter missed...\n"); 7708 printmsg("Parameter missed...\n");
7634 exit(-1); 7709 exit(-1);
7635 } 7710 }
7636 7711
7637 GSM_EncodeMMSFile(&Info,Buffer,&len); 7712 GSM_EncodeMMSFile(&Info,Buffer,&len);
7638 7713
7639 file = fopen(argv[2],"wb"); 7714 file = fopen(argv[2],"wb");
7640 if (file == NULL) Print_Error(ERR_CANTOPENFILE); 7715 if (file == NULL) Print_Error(ERR_CANTOPENFILE);
7641 fwrite(Buffer,1,len,file); 7716 fwrite(Buffer,1,len,file);
7642 fclose(file); 7717 fclose(file);
7643} 7718}
7644 7719
7645static void CallDivert(int argc, char *argv[]) 7720static void CallDivert(int argc, char *argv[])
7646{ 7721{
7647 GSM_MultiCallDivert cd; 7722 GSM_MultiCallDivert cd;
7648 7723
7649 if (mystrncasecmp("get",argv[2],0)) {} 7724 if (mystrncasecmp("get",argv[2],0)) {}
7650 else if (mystrncasecmp("set",argv[2],0)) {} 7725 else if (mystrncasecmp("set",argv[2],0)) {}
7651 else { 7726 else {
7652 printmsg("Unknown divert action (\"%s\")\n",argv[2]); 7727 printmsg("Unknown divert action (\"%s\")\n",argv[2]);
7653 exit(-1); 7728 exit(-1);
7654 } 7729 }
7655 7730
7656 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} 7731 if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;}
7657 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} 7732 else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;}
7658 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} 7733 else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;}
7659 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} 7734 else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;}
7660 else { 7735 else {
7661 printmsg("Unknown divert type (\"%s\")\n",argv[3]); 7736 printmsg("Unknown divert type (\"%s\")\n",argv[3]);
7662 exit(-1); 7737 exit(-1);
7663 } 7738 }
7664 7739
7665 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} 7740 if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;}
7666 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} 7741 else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;}
7667 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} 7742 else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;}
7668 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} 7743 else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;}
7669 else { 7744 else {
7670 printmsg("Unknown call type (\"%s\")\n",argv[4]); 7745 printmsg("Unknown call type (\"%s\")\n",argv[4]);
7671 exit(-1); 7746 exit(-1);
7672 } 7747 }
7673 7748
7674 GSM_Init(true); 7749 GSM_Init(true);
7675 7750
7676 if (mystrncasecmp("get", argv[2],0)) { 7751 if (mystrncasecmp("get", argv[2],0)) {
7677 error = Phone->GetCallDivert(&s,&cd); 7752 error = Phone->GetCallDivert(&s,&cd);
7678 Print_Error(error); 7753 Print_Error(error);
7679 printmsg("Query:\n Divert type: "); 7754 printmsg("Query:\n Divert type: ");
7680 } else { 7755 } else {
7681 cd.Request.Number[0] = 0; 7756 cd.Request.Number[0] = 0;
7682 cd.Request.Number[1] = 0; 7757 cd.Request.Number[1] = 0;
7683 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); 7758 if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5]));
7684 7759
7685 cd.Request.Timeout = 0; 7760 cd.Request.Timeout = 0;
7686 if (argc > 6) cd.Request.Timeout = atoi(argv[6]); 7761 if (argc > 6) cd.Request.Timeout = atoi(argv[6]);
7687 7762
7688 error = Phone->SetCallDivert(&s,&cd); 7763 error = Phone->SetCallDivert(&s,&cd);
7689 Print_Error(error); 7764 Print_Error(error);
7690 printmsg("Changed:\n Divert type: "); 7765 printmsg("Changed:\n Divert type: ");
7691 } 7766 }
7692 7767
7693 switch (cd.Request.DivertType) { 7768 switch (cd.Request.DivertType) {
7694 case GSM_DIVERT_Busy : printmsg("when busy"); break; 7769 case GSM_DIVERT_Busy : printmsg("when busy"); break;
7695 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; 7770 case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break;
7696 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break; 7771 case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break;
7697 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; 7772 case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break;
7698 default : printmsg("unknown %i",cd.Request.DivertType); break; 7773 default : printmsg("unknown %i",cd.Request.DivertType); break;
7699 } 7774 }
7700 printmsg("\n Calls type : "); 7775 printmsg("\n Calls type : ");
7701 switch (cd.Request.CallType) { 7776 switch (cd.Request.CallType) {
7702 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7777 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7703 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7778 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7704 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7779 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7705 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; 7780 case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break;
7706 default : printmsg("unknown %i",cd.Request.CallType); break; 7781 default : printmsg("unknown %i",cd.Request.CallType); break;
7707 } 7782 }
7708 printmsg("\nResponse:"); 7783 printmsg("\nResponse:");
7709 7784
7710 for (i=0;i<cd.Response.EntriesNum;i++) { 7785 for (i=0;i<cd.Response.EntriesNum;i++) {
7711 printmsg("\n Calls type : "); 7786 printmsg("\n Calls type : ");
7712 switch (cd.Response.Entries[i].CallType) { 7787 switch (cd.Response.Entries[i].CallType) {
7713 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; 7788 case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
7714 case GSM_DIVERT_FaxCalls : printmsg("fax"); break; 7789 case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
7715 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7790 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7716 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; 7791 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
7717 } 7792 }
7718 printf("\n"); 7793 printf("\n");
7719 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); 7794 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
7720 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); 7795 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
7721 } 7796 }
7722 printf("\n"); 7797 printf("\n");
7723 7798
7724 GSM_Terminate(); 7799 GSM_Terminate();
7725} 7800}
7726 7801
7727static void CancelAllDiverts(int argc, char *argv[]) 7802static void CancelAllDiverts(int argc, char *argv[])
7728{ 7803{
7729 GSM_Init(true); 7804 GSM_Init(true);
7730 7805
7731 error = Phone->CancelAllDiverts(&s); 7806 error = Phone->CancelAllDiverts(&s);
7732 Print_Error(error); 7807 Print_Error(error);
7733 7808
7734 GSM_Terminate(); 7809 GSM_Terminate();
7735} 7810}
7736 7811
7737typedef struct { 7812typedef struct {
7738 unsigned char Connection[50]; 7813 unsigned char Connection[50];
7739} OneConnectionInfo; 7814} OneConnectionInfo;
7740 7815
7741typedef struct { 7816typedef struct {
7742 unsigned char Device[50]; 7817 unsigned char Device[50];
7743 OneConnectionInfo Connections[4]; 7818 OneConnectionInfo Connections[4];
7744} OneDeviceInfo; 7819} OneDeviceInfo;
7745 7820
7746 int num; 7821 int num;
7747 bool SearchOutput; 7822 bool SearchOutput;
7748 7823
7749void SearchPhoneThread(OneDeviceInfo *Info) 7824void SearchPhoneThread(OneDeviceInfo *Info)
7750{ 7825{
7751 //LR 7826 //LR
7752#if 0 7827#if 0
7753 int j; 7828 int j;
7754 GSM_Error error; 7829 GSM_Error error;
7755 GSM_StateMachiness; 7830 GSM_StateMachiness;
7756 7831
7757 j = 0; 7832 j = 0;
7758 while(strlen(Info->Connections[j].Connection) != 0) { 7833 while(strlen(Info->Connections[j].Connection) != 0) {
7759 memcpy(&ss.di,&s.di,sizeof(Debug_Info)); 7834 memcpy(&ss.di,&s.di,sizeof(Debug_Info));
7760 ss.msg = s.msg; 7835 ss.msg = s.msg;
7761 ss.ConfigNum = 1; 7836 ss.ConfigNum = 1;
7762 ss.opened = false; 7837 ss.opened = false;
7763 ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile; 7838 ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
7764 ss.Config[0].Localize = s.Config[0].Localize; 7839 ss.Config[0].Localize = s.Config[0].Localize;
7765 ss.Config[0].Device = Info->Device; 7840 ss.Config[0].Device = Info->Device;
7766 ss.Config[0].Connection = Info->Connections[j].Connection; 7841 ss.Config[0].Connection = Info->Connections[j].Connection;
7767 ss.Config[0].SyncTime = "no"; 7842 ss.Config[0].SyncTime = "no";
7768 ss.Config[0].DebugFile = s.Config[0].DebugFile; 7843 ss.Config[0].DebugFile = s.Config[0].DebugFile;
7769 ss.Config[0].Model[0] = 0; 7844 ss.Config[0].Model[0] = 0;
7770 strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel); 7845 strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel);
7771 ss.Config[0].LockDevice = "no"; 7846 ss.Config[0].LockDevice = "no";
7772 ss.Config[0].StartInfo = "no"; 7847 ss.Config[0].StartInfo = "no";
7773 7848
7774 error = GSM_InitConnection(&ss,1); 7849 error = GSM_InitConnection(&ss,1);
7775 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7850 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7776 if (error == ERR_NONE) { 7851 if (error == ERR_NONE) {
7777 error=ss.Phone.Functions->GetManufacturer(&ss); 7852 error=ss.Phone.Functions->GetManufacturer(&ss);
7778 if (error == ERR_NONE) { 7853 if (error == ERR_NONE) {
7779 error=ss.Phone.Functions->GetModel(&ss); 7854 error=ss.Phone.Functions->GetModel(&ss);
7780 if (error == ERR_NONE) { 7855 if (error == ERR_NONE) {
7781 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7856 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7782 printmsg(" Manufacturer : %s\n", 7857 printmsg(" Manufacturer : %s\n",
7783 ss.Phone.Data.Manufacturer); 7858 ss.Phone.Data.Manufacturer);
7784 printmsg(" Model : %s (%s)\n", 7859 printmsg(" Model : %s (%s)\n",
7785 ss.Phone.Data.ModelInfo->model, 7860 ss.Phone.Data.ModelInfo->model,
7786 ss.Phone.Data.Model); 7861 ss.Phone.Data.Model);
7787 } else { 7862 } else {
7788 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg)); 7863 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7789 } 7864 }
7790 } else { 7865 } else {
7791 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg)); 7866 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7792 } 7867 }
7793 } else { 7868 } else {
7794 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg)); 7869 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7795 } 7870 }
7796 if (error != ERR_DEVICEOPENERROR) { 7871 if (error != ERR_DEVICEOPENERROR) {
7797 GSM_TerminateConnection(&ss); 7872 GSM_TerminateConnection(&ss);
7798 dbgprintf("Closing done\n"); 7873 dbgprintf("Closing done\n");
7799 } 7874 }
7800 if (error == ERR_DEVICEOPENERROR) break; 7875 if (error == ERR_DEVICEOPENERROR) break;
7801 j++; 7876 j++;
7802 } 7877 }
7803 num--; 7878 num--;
7804#endif 7879#endif
7805} 7880}
7806 7881
7807#if defined(WIN32) || defined(HAVE_PTHREAD) 7882#if defined(WIN32) || defined(HAVE_PTHREAD)
7808#ifdef HAVE_PTHREAD 7883#ifdef HAVE_PTHREAD
7809 pthread_t Thread[100]; 7884 pthread_t Thread[100];
7810#endif 7885#endif
7811 7886
7812OneDeviceInfo SearchDevices[60]; 7887OneDeviceInfo SearchDevices[60];
7813 7888
7814void MakeSearchThread(int i) 7889void MakeSearchThread(int i)
7815{ 7890{
7816 num++; 7891 num++;
7817#ifdef HAVE_PTHREAD 7892#ifdef HAVE_PTHREAD
7818 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { 7893 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) {
7819 dbgprintf("Error creating thread\n"); 7894 dbgprintf("Error creating thread\n");
7820 } 7895 }
7821#else 7896#else
7822 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, 7897 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0,
7823 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], 7898 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i],
7824 0,NULL)==NULL) { 7899 0,NULL)==NULL) {
7825 dbgprintf("Error creating thread\n"); 7900 dbgprintf("Error creating thread\n");
7826 } 7901 }
7827#endif 7902#endif
7828} 7903}
7829 7904
7830static void SearchPhone(int argc, char *argv[]) 7905static void SearchPhone(int argc, char *argv[])
7831{ 7906{
7832 int i,dev = 0, dev2 = 0; 7907 int i,dev = 0, dev2 = 0;
7833 7908
7834 SearchOutput = false; 7909 SearchOutput = false;
7835 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; 7910 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true;
7836 7911
7837 num = 0; 7912 num = 0;
7838#ifdef WIN32 7913#ifdef WIN32
7839# ifdef GSM_ENABLE_IRDADEVICE 7914# ifdef GSM_ENABLE_IRDADEVICE
7840 sprintf(SearchDevices[dev].Device,""); 7915 sprintf(SearchDevices[dev].Device,"");
7841 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7916 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7842 sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat"); 7917 sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat");
7843 SearchDevices[dev].Connections[2].Connection[0] = 0; 7918 SearchDevices[dev].Connections[2].Connection[0] = 0;
7844 dev++; 7919 dev++;
7845# endif 7920# endif
7846# ifdef GSM_ENABLE_SERIALDEVICE 7921# ifdef GSM_ENABLE_SERIALDEVICE
7847 dev2 = dev; 7922 dev2 = dev;
7848 for(i=0;i<20;i++) { 7923 for(i=0;i<20;i++) {
7849 sprintf(SearchDevices[dev2].Device,"com%i:",i+1); 7924 sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
7850 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7925 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7851 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7926 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7852 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7927 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7853 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7928 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7854 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7929 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7855 dev2++; 7930 dev2++;
7856 } 7931 }
7857# endif 7932# endif
7858#endif 7933#endif
7859#ifdef __linux__ 7934#ifdef __linux__
7860# ifdef GSM_ENABLE_IRDADEVICE 7935# ifdef GSM_ENABLE_IRDADEVICE
7861 for(i=0;i<6;i++) { 7936 for(i=0;i<6;i++) {
7862 sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i); 7937 sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i);
7863 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7938 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7864 sprintf(SearchDevices[dev].Connections[1].Connection,"at19200"); 7939 sprintf(SearchDevices[dev].Connections[1].Connection,"at19200");
7865 SearchDevices[dev].Connections[2].Connection[0] = 0; 7940 SearchDevices[dev].Connections[2].Connection[0] = 0;
7866 dev++; 7941 dev++;
7867 } 7942 }
7868# endif 7943# endif
7869# ifdef GSM_ENABLE_SERIALDEVICE 7944# ifdef GSM_ENABLE_SERIALDEVICE
7870 dev2 = dev; 7945 dev2 = dev;
7871 for(i=0;i<10;i++) { 7946 for(i=0;i<10;i++) {
7872 sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i); 7947 sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i);
7873 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7948 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7874 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7949 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7875 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7950 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7876 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7951 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7877 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7952 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7878 dev2++; 7953 dev2++;
7879 } 7954 }
7880 for(i=0;i<8;i++) { 7955 for(i=0;i<8;i++) {
7881 sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i); 7956 sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i);
7882 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7957 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7883 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7958 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7884 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7959 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7885 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7960 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7886 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7961 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7887 dev2++; 7962 dev2++;
7888 } 7963 }
7889 for(i=0;i<4;i++) { 7964 for(i=0;i<4;i++) {
7890 sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i); 7965 sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i);
7891 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7966 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7892 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7967 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7893 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7968 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7894 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7969 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7895 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7970 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7896 dev2++; 7971 dev2++;
7897 } 7972 }
7898# endif 7973# endif
7899#endif 7974#endif
7900 for(i=0;i<dev;i++) MakeSearchThread(i); 7975 for(i=0;i<dev;i++) MakeSearchThread(i);
7901 while (num != 0) my_sleep(5); 7976 while (num != 0) my_sleep(5);
7902 for(i=dev;i<dev2;i++) MakeSearchThread(i); 7977 for(i=dev;i<dev2;i++) MakeSearchThread(i);
7903 while (num != 0) my_sleep(5); 7978 while (num != 0) my_sleep(5);
7904} 7979}
7905#endif /*Support for threads */ 7980#endif /*Support for threads */
7906 7981
7907static void NokiaGetADC(int argc, char *argv[]) 7982static void NokiaGetADC(int argc, char *argv[])
7908{ 7983{
7909 GSM_Init(true); 7984 GSM_Init(true);
7910 7985
7911#ifdef GSM_ENABLE_NOKIA_DCT3 7986#ifdef GSM_ENABLE_NOKIA_DCT3
7912 DCT3GetADC(argc,argv); 7987 DCT3GetADC(argc,argv);
7913#endif 7988#endif
7914#ifdef GSM_ENABLE_NOKIA_DCT4 7989#ifdef GSM_ENABLE_NOKIA_DCT4
7915 DCT4GetADC(argc, argv); 7990 DCT4GetADC(argc, argv);
7916#endif 7991#endif
7917 7992
7918 GSM_Terminate(); 7993 GSM_Terminate();
7919} 7994}
7920 7995
7921static void NokiaDisplayTest(int argc, char *argv[]) 7996static void NokiaDisplayTest(int argc, char *argv[])
7922{ 7997{
7923 GSM_Init(true); 7998 GSM_Init(true);
7924 7999
7925#ifdef GSM_ENABLE_NOKIA_DCT3 8000#ifdef GSM_ENABLE_NOKIA_DCT3
7926 DCT3DisplayTest(argc,argv); 8001 DCT3DisplayTest(argc,argv);
7927#endif 8002#endif
7928#ifdef GSM_ENABLE_NOKIA_DCT4 8003#ifdef GSM_ENABLE_NOKIA_DCT4
7929 DCT4DisplayTest(argc, argv); 8004 DCT4DisplayTest(argc, argv);
7930#endif 8005#endif
7931 8006
7932 GSM_Terminate(); 8007 GSM_Terminate();
7933} 8008}
7934 8009
7935static void NokiaGetT9(int argc, char *argv[]) 8010static void NokiaGetT9(int argc, char *argv[])
7936{ 8011{
7937 GSM_Init(true); 8012 GSM_Init(true);
7938 8013
7939#ifdef GSM_ENABLE_NOKIA_DCT3 8014#ifdef GSM_ENABLE_NOKIA_DCT3
7940 DCT3GetT9(argc,argv); 8015 DCT3GetT9(argc,argv);
7941#endif 8016#endif
7942#ifdef GSM_ENABLE_NOKIA_DCT4 8017#ifdef GSM_ENABLE_NOKIA_DCT4
7943 DCT4GetT9(argc, argv); 8018 DCT4GetT9(argc, argv);
7944#endif 8019#endif
7945 8020
7946 GSM_Terminate(); 8021 GSM_Terminate();
7947} 8022}
7948 8023
7949static void NokiaVibraTest(int argc, char *argv[]) 8024static void NokiaVibraTest(int argc, char *argv[])
7950{ 8025{
7951 GSM_Init(true); 8026 GSM_Init(true);
7952 8027
7953#ifdef GSM_ENABLE_NOKIA_DCT3 8028#ifdef GSM_ENABLE_NOKIA_DCT3
7954 DCT3VibraTest(argc,argv); 8029 DCT3VibraTest(argc,argv);
7955#endif 8030#endif
7956#ifdef GSM_ENABLE_NOKIA_DCT4 8031#ifdef GSM_ENABLE_NOKIA_DCT4
7957 DCT4VibraTest(argc, argv); 8032 DCT4VibraTest(argc, argv);
7958#endif 8033#endif
7959 8034
7960 GSM_Terminate(); 8035 GSM_Terminate();
7961} 8036}
7962 8037
7963static GSM_Parameters Parameters[] = { 8038static GSM_Parameters Parameters[] = {
7964 {"--identify", 0, 0, Identify, {H_Info,0}, ""}, 8039 {"--identify", 0, 0, Identify, {H_Info,0}, ""},
7965 {"--version", 0, 0, Version, {H_Other,0}, ""}, 8040 {"--version", 0, 0, Version, {H_Other,0}, ""},
7966 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, 8041 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
7967 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"}, 8042 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"},
7968 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, 8043 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
7969 {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"}, 8044 {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"},
7970 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, 8045 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
7971 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, 8046 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"},
7972 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, 8047 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"},
7973 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, 8048 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""},
7974 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, 8049 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."},
7975 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, 8050 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."},
7976 {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"}, 8051 {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"},
7977 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, 8052 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
7978 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"}, 8053 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"},
7979 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, 8054 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
7980 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, 8055 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
7981 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, 8056 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
7982 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, 8057 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, "number"},
7983 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, 8058 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
7984 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, 8059 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
7985 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, 8060 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},
7986 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, 8061 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"},
7987 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, 8062 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
7988 {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"}, 8063 {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"},
7989 {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, 8064 {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
7990 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, 8065 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
7991 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"}, 8066 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"},
7992 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, 8067 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"},
7993 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, 8068 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"},
7994 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, 8069 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"},
7995 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, 8070 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"},
7996 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, 8071 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"},
7997 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, 8072 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""},
7998 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, 8073 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""},
7999 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, 8074 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""},
8000 8075
8001 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" 8076 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
8002 #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]" 8077 #define SMS_PICTURE_OPTIONS"[-text text][-unicode][-alcatelbmmi]"
8003 #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]" 8078 #define SMS_PROFILE_OPTIONS"[-name name][-bitmap bitmap][-ringtone ringtone]"
8004 #define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]" 8079 #define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]"
8005 #define SMS_SMSTEMPLATE_OPTIONS"[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]" 8080 #define SMS_SMSTEMPLATE_OPTIONS"[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]"
8006 #define SMS_ANIMATION_OPTIONS"" 8081 #define SMS_ANIMATION_OPTIONS""
8007 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]" 8082 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]"
8008 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]" 8083 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]"
8009 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" 8084 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]"
8010 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]" 8085 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]"
8011 8086
8012 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 8087 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
8013 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8088 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8014 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 8089 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
8015 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8090 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8016 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 8091 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
8017 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 8092 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
8018 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8093 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8019 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR URL Title " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8094 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR URL Title " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8020#ifdef GSM_ENABLE_BACKUP 8095#ifdef GSM_ENABLE_BACKUP
8021 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8096 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8022 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8097 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8023 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8098 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8024 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8099 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8025 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8100 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8026 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8101 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
8027#endif 8102#endif
8028 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, 8103 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS},
8029 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 8104 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
8030 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 8105 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
8031 8106
8032 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 8107 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
8033 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8108 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8034 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 8109 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
8035 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8110 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8036 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 8111 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
8037 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 8112 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
8038 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8113 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8039 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR destination URL Title " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8114 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR destination URL Title " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8040#ifdef GSM_ENABLE_BACKUP 8115#ifdef GSM_ENABLE_BACKUP
8041 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8116 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8042 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8117 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8043 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8118 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8044 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8119 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8045 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8120 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8046 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8121 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
8047#endif 8122#endif
8048 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, 8123 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS},
8049 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 8124 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
8050 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 8125 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
8051 8126
8052 {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"}, 8127 {"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"},
8053 8128
8054 {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"}, 8129 {"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"},
8055#ifdef HAVE_MYSQL_MYSQL_H 8130#ifdef HAVE_MYSQL_MYSQL_H
8056 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"}, 8131 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"},
8057#endif 8132#endif
8058 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"}, 8133 {"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"},
8059 {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"}, 8134 {"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"},
8060 {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, 8135 {"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
8061 {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"}, 8136 {"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
8062 {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""}, 8137 {"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""},
8063 {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"}, 8138 {"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"},
8064 {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"}, 8139 {"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"},
8065 {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"}, 8140 {"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"},
8066 {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"}, 8141 {"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"},
8067 {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"}, 8142 {"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"},
8068 {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"}, 8143 {"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"},
8069 {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"}, 8144 {"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"},
8070 {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"}, 8145 {"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"},
8071 {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"}, 8146 {"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"},
8072 {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"}, 8147 {"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"},
8073 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, 8148 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"},
8074 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, 8149 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"},
8075 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, 8150 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"},
8076 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, 8151 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"},
8077 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, 8152 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
8078 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, 8153 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""},
8079 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, 8154 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"},
8080 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""}, 8155 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""},
8081 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, 8156 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""},
8082 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, 8157 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"},
8083 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, 8158 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"},
8084 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, 8159 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
8085 {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""}, 8160 {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""},
8086 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, 8161 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
8087 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, 8162 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""},
8088 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, 8163 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"},
8089 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"}, 8164 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"},
8090 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"}, 8165 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"},
8091 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, 8166 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"},
8092 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, 8167 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"},
8093 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, 8168 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""},
8094 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, 8169 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"},
8095 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, 8170 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"},
8096 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, 8171 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"},
8097 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, 8172 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"},
8098 {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"}, 8173 {"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"},
8099 {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"}, 8174 {"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"},
8100 {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"}, 8175 {"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"},
8101 {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"}, 8176 {"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"},
8102 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"}, 8177 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"},
8103 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"}, 8178 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"},
8104 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"}, 8179 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"},
8105 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"}, 8180 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"},
8106 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"}, 8181 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"},
8107 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"}, 8182 {"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"},
8108 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"}, 8183 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"},
8109 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"}, 8184 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"},
8110 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"}, 8185 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"},
8111 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"}, 8186 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"},
8112 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"}, 8187 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"},
8113 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"}, 8188 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"},
8114 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"}, 8189 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"},
8115 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"}, 8190 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"},
8116 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"}, 8191 {"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"},
8117 {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"}, 8192 {"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"},
8118 {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"}, 8193 {"--presskeysequence", 1, 1, PressKeySequence, {H_Other,0}, "mMnNpPuUdD+-123456789*0#gGrRwW"},
8119#if defined(WIN32) || defined(HAVE_PTHREAD) 8194#if defined(WIN32) || defined(HAVE_PTHREAD)
8120 {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"}, 8195 {"--searchphone", 0, 1, SearchPhone, {H_Other,0}, "[-debug]"},
8121#endif 8196#endif
8122#ifdef GSM_ENABLE_BACKUP 8197#ifdef GSM_ENABLE_BACKUP
8123 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"}, 8198 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0},"CALENDAR target.vcs file location"},
8124 {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"}, 8199 {"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"},
8125 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"}, 8200 {"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"},
8126 {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"}, 8201 {"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"},
8127 {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"}, 8202 {"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"},
8128 {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"}, 8203 {"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"},
8129 {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, 8204 {"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
8130 {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"}, 8205 {"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
8131 {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"}, 8206 {"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"},
8132 {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"}, 8207 {"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"},
8133#endif 8208#endif
8134 {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""}, 8209 {"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0},""},
8135 {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""}, 8210 {"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""},
8136 #ifdef GSM_ENABLE_AT 8211 #ifdef GSM_ENABLE_AT
8137 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""}, 8212 {"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0},""},
8138 {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"}, 8213 {"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"},
8139 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"}, 8214 {"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0},"test"},
8140 #endif 8215 #endif
8141#ifdef GSM_ENABLE_NOKIA6110 8216#ifdef GSM_ENABLE_NOKIA6110
8142 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, 8217 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""},
8143 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, 8218 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"},
8144 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, 8219 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""},
8145#endif 8220#endif
8146#ifdef GSM_ENABLE_NOKIA_DCT3 8221#ifdef GSM_ENABLE_NOKIA_DCT3
8147 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, 8222 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"},
8148 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, 8223 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""},
8149 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, 8224 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"},
8150#endif 8225#endif
8151#ifdef GSM_ENABLE_NOKIA_DCT4 8226#ifdef GSM_ENABLE_NOKIA_DCT4
8152 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, 8227 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"},
8153 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, 8228 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
8154#ifdef GSM_ENABLE_NOKIA6510 8229#ifdef GSM_ENABLE_NOKIA6510
8155 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, 8230 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
8156 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, 8231 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
8157#endif 8232#endif
8158 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, 8233 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
8159 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, 8234 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""},
8160#endif 8235#endif
8161#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 8236#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
8162 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, 8237 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""},
8163 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, 8238 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""},
8164 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, 8239 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"},
8165 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, 8240 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""},
8166 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, 8241 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""},
8167 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, 8242 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""},
8168 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, 8243 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""},
8169#endif 8244#endif
8170#ifdef DEBUG 8245#ifdef DEBUG
8171 {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"}, 8246 {"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"},
8172 {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"}, 8247 {"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"},
8173 {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"}, 8248 {"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"},
8174#endif 8249#endif
8175 {"", 0, 0, NULL } 8250 {"", 0, 0, NULL }
8176}; 8251};
8177 8252
8178static HelpCategoryDescriptions HelpDescriptions[] = { 8253static HelpCategoryDescriptions HelpDescriptions[] = {
8179 {H_Call, "call", "Calls",}, 8254 {H_Call, "call", "Calls",},
8180 {H_SMS, "sms", "SMS and EMS"}, 8255 {H_SMS, "sms", "SMS and EMS"},
8181 {H_Memory, "memory","Memory (phonebooks and calls)"}, 8256 {H_Memory, "memory","Memory (phonebooks and calls)"},
8182 {H_Filesystem, "filesystem","Filesystem"}, 8257 {H_Filesystem, "filesystem","Filesystem"},
8183 {H_Logo, "logo", "Logo and pictures"}, 8258 {H_Logo, "logo", "Logo and pictures"},
8184 {H_Ringtone, "ringtone","Ringtones"}, 8259 {H_Ringtone, "ringtone","Ringtones"},
8185 {H_Calendar, "calendar","Calendar notes"}, 8260 {H_Calendar, "calendar","Calendar notes"},
8186 {H_ToDo, "todo", "To do lists"}, 8261 {H_ToDo, "todo", "To do lists"},
8187 {H_Note, "note", "Notes"}, 8262 {H_Note, "note", "Notes"},
8188 {H_DateTime, "datetime","Date, time and alarms"}, 8263 {H_DateTime, "datetime","Date, time and alarms"},
8189 {H_Category, "category","Categories"}, 8264 {H_Category, "category","Categories"},
8190#ifdef GSM_ENABLE_BACKUP 8265#ifdef GSM_ENABLE_BACKUP
8191 {H_Backup, "backup","Backing up and restoring"}, 8266 {H_Backup, "backup","Backing up and restoring"},
8192#endif 8267#endif
8193#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 8268#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
8194 {H_Nokia, "nokia","Nokia specific"}, 8269 {H_Nokia, "nokia","Nokia specific"},
8195#endif 8270#endif
8196#ifdef GSM_ENABLE_AT 8271#ifdef GSM_ENABLE_AT
8197 {H_Siemens, "siemens","Siemens specific"}, 8272 {H_Siemens, "siemens","Siemens specific"},
8198#endif 8273#endif
8199 {H_Network, "network","Network"}, 8274 {H_Network, "network","Network"},
8200 {H_WAP, "wap", "WAP settings and bookmarks"}, 8275 {H_WAP, "wap", "WAP settings and bookmarks"},
8201 {H_MMS, "mms", "MMS and MMS settings"}, 8276 {H_MMS, "mms", "MMS and MMS settings"},
8202 {H_Tests, "tests","Phone tests"}, 8277 {H_Tests, "tests","Phone tests"},
8203 {H_FM, "fm", "FM radio"}, 8278 {H_FM, "fm", "FM radio"},
8204 {H_Info, "info", "Phone information"}, 8279 {H_Info, "info", "Phone information"},
8205 {H_Settings, "settings","Phone settings"}, 8280 {H_Settings, "settings","Phone settings"},
8206#ifdef DEBUG 8281#ifdef DEBUG
8207 {H_Decode, "decode","Dumps decoding"}, 8282 {H_Decode, "decode","Dumps decoding"},
8208#endif 8283#endif
8209 {H_Other, "other","Functions that don't fit elsewhere"}, 8284 {H_Other, "other","Functions that don't fit elsewhere"},
8210 {0, NULL, NULL} 8285 {0, NULL, NULL}
8211}; 8286};
8212 8287
8213 8288
8214void HelpHeader(void) 8289void HelpHeader(void)
8215{ 8290{
8216 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 8291 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
8217} 8292}
8218 8293
8219static void HelpGeneral(void) 8294static void HelpGeneral(void)
8220{ 8295{
8221 inti=0; 8296 inti=0;
8222 8297
8223 HelpHeader(); 8298 HelpHeader();
8224 8299
8225 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); 8300 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
8226 printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n"); 8301 printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n");
8227 printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n"); 8302 printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n");
8228 8303
8229 /* We might want to put here some most used commands */ 8304 /* We might want to put here some most used commands */
8230 printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n"); 8305 printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n");
8231 8306
8232 while (HelpDescriptions[i].category != 0) { 8307 while (HelpDescriptions[i].category != 0) {
8233 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); 8308 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description);
8234 i++; 8309 i++;
8235 } 8310 }
8236 printf("\n"); 8311 printf("\n");
8237} 8312}
8238 8313
8239static void HelpSplit(int cols, int len, unsigned char *buff) 8314static void HelpSplit(int cols, int len, unsigned char *buff)
8240{ 8315{
8241 int l, len2, pos, split; 8316 int l, len2, pos, split;
8242 bool in_opt,first=true; 8317 bool in_opt,first=true;
8243 char *remain, spaces[50], buffer[500]; 8318 char *remain, spaces[50], buffer[500];
8244 8319
8245 if (cols == 0) { 8320 if (cols == 0) {
8246 printf(" %s\n", buff); 8321 printf(" %s\n", buff);
8247 } else { 8322 } else {
8248 printf(" "); 8323 printf(" ");
8249 spaces[0] = 0; 8324 spaces[0] = 0;
8250 len2 = strlen(buff); 8325 len2 = strlen(buff);
8251 if (len + len2 < cols) { 8326 if (len + len2 < cols) {
8252 printf("%s\n", buff); 8327 printf("%s\n", buff);
8253 } else { 8328 } else {
8254 for(l = 0; l < len; l++) strcat(spaces, " "); 8329 for(l = 0; l < len; l++) strcat(spaces, " ");
8255 8330
8256 remain = buff; 8331 remain = buff;
8257 8332
8258 while (strlen(remain) > 0) { 8333 while (strlen(remain) > 0) {
8259 split= 0; 8334 split= 0;
8260 pos= 0; 8335 pos= 0;
8261 in_opt= false; 8336 in_opt= false;
8262 if (!first) printf(spaces); 8337 if (!first) printf(spaces);
8263 while (pos < cols - len && remain[pos] != 0) { 8338 while (pos < cols - len && remain[pos] != 0) {
8264 if (in_opt && remain[pos] == ']') { 8339 if (in_opt && remain[pos] == ']') {
8265 in_opt = false; 8340 in_opt = false;
8266 split = pos; 8341 split = pos;
8267 } else if (remain[pos] == '[') { 8342 } else if (remain[pos] == '[') {
8268 in_opt = true; 8343 in_opt = true;
8269 } else if (!in_opt && remain[pos] == ' ') { 8344 } else if (!in_opt && remain[pos] == ' ') {
8270 split = pos - 1; 8345 split = pos - 1;
8271 } 8346 }
8272 pos++; 8347 pos++;
8273 } 8348 }
8274 /* Can not be split */ 8349 /* Can not be split */
8275 if (split == 0) { 8350 if (split == 0) {
8276 printf("%s\n", remain); 8351 printf("%s\n", remain);
8277 remain += strlen(remain); 8352 remain += strlen(remain);
8278 } else { 8353 } else {
8279 first = false; 8354 first = false;
8280 split++; 8355 split++;
8281 strncpy(buffer, remain, split); 8356 strncpy(buffer, remain, split);
8282 buffer[split] = 0; 8357 buffer[split] = 0;
8283 printf("%s\n", buffer); 8358 printf("%s\n", buffer);
8284 remain += split; 8359 remain += split;
8285 if (remain[0] == ' ') remain++; 8360 if (remain[0] == ' ') remain++;
8286 } 8361 }
8287 } 8362 }
8288 } 8363 }
8289 } 8364 }
8290} 8365}
8291 8366
8292static void Help(int argc, char *argv[]) 8367static void Help(int argc, char *argv[])
8293{ 8368{
8294 int i = 0, j = 0, k, cols; 8369 int i = 0, j = 0, k, cols;
8295 bool disp; 8370 bool disp;
8296#ifdef TIOCGWINSZ 8371#ifdef TIOCGWINSZ
8297 struct winsize w; 8372 struct winsize w;
8298#endif 8373#endif
8299#if defined(WIN32) || defined(DJGPP) 8374#if defined(WIN32) || defined(DJGPP)
8300#else 8375#else
8301 char *columns; 8376 char *columns;
8302#endif 8377#endif
8303 8378
8304 /* Just --help */ 8379 /* Just --help */
8305 if (argc == 2) { 8380 if (argc == 2) {
8306 HelpGeneral(); 8381 HelpGeneral();
8307 return; 8382 return;
8308 } 8383 }
8309 8384
8310 if (!strcmp(argv[2],"all")) { 8385 if (!strcmp(argv[2],"all")) {
8311 HelpHeader(); 8386 HelpHeader();
8312 } else { 8387 } else {
8313 while (HelpDescriptions[i].category != 0) { 8388 while (HelpDescriptions[i].category != 0) {
8314 if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break; 8389 if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break;
8315 i++; 8390 i++;
8316 } 8391 }
8317 if (HelpDescriptions[i].category == 0) { 8392 if (HelpDescriptions[i].category == 0) {
8318 HelpGeneral(); 8393 HelpGeneral();
8319 printmsg("Unknown help topic specified!\n"); 8394 printmsg("Unknown help topic specified!\n");
8320 return; 8395 return;
8321 } 8396 }
8322 HelpHeader(); 8397 HelpHeader();
8323 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); 8398 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description);
8324 } 8399 }
8325 8400
8326#if defined(WIN32) || defined(DJGPP) 8401#if defined(WIN32) || defined(DJGPP)
8327 cols = 80; 8402 cols = 80;
8328#else 8403#else
8329 cols = 0; 8404 cols = 0;
8330 /* If stdout is a tty, we will wrap to columns it has */ 8405 /* If stdout is a tty, we will wrap to columns it has */
8331 if (isatty(1)) { 8406 if (isatty(1)) {
8332#ifdef TIOCGWINSZ 8407#ifdef TIOCGWINSZ
8333 if (ioctl(2, TIOCGWINSZ, &w) == 0) { 8408 if (ioctl(2, TIOCGWINSZ, &w) == 0) {
8334 if (w.ws_col > 0) cols = w.ws_col; 8409 if (w.ws_col > 0) cols = w.ws_col;
8335 } 8410 }
8336#endif 8411#endif
8337 if (cols == 0) { 8412 if (cols == 0) {
8338 columns = getenv("COLUMNS"); 8413 columns = getenv("COLUMNS");
8339 if (columns != NULL) { 8414 if (columns != NULL) {
8340 cols = atoi(columns); 8415 cols = atoi(columns);
8341 if (cols <= 0) cols = 0; 8416 if (cols <= 0) cols = 0;
8342 } 8417 }
8343 } 8418 }
8344 8419
8345 if (cols == 0) { 8420 if (cols == 0) {
8346 /* Fallback */ 8421 /* Fallback */
8347 cols = 80; 8422 cols = 80;
8348 } 8423 }
8349 } 8424 }
8350#endif 8425#endif
8351 8426
8352 while (Parameters[j].Function != NULL) { 8427 while (Parameters[j].Function != NULL) {
8353 k = 0; 8428 k = 0;
8354 disp = false; 8429 disp = false;
8355 if (!strcmp(argv[2],"all")) { 8430 if (!strcmp(argv[2],"all")) {
8356 if (j==0) disp = true; 8431 if (j==0) disp = true;
8357 if (j!=0) { 8432 if (j!=0) {
8358 if (strcmp(Parameters[j].help,Parameters[j-1].help)) { 8433 if (strcmp(Parameters[j].help,Parameters[j-1].help)) {
8359 disp = true; 8434 disp = true;
8360 } else { 8435 } else {
8361 if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) { 8436 if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) {
8362 disp = true; 8437 disp = true;
8363 } 8438 }
8364 } 8439 }
8365 } 8440 }
8366 } else { 8441 } else {
diff --git a/gammu/emb/gammu/smsd/s_files.c b/gammu/emb/gammu/smsd/s_files.c
index b791e58..e1c626f 100644
--- a/gammu/emb/gammu/smsd/s_files.c
+++ b/gammu/emb/gammu/smsd/s_files.c
@@ -1,360 +1,360 @@
1/* (c) 2002-2004 by Joergen Thomsen */ 1/* (c) 2002-2004 by Joergen Thomsen */
2 2
3#include "../../cfg/config.h" 3#include "../../cfg/config.h"
4 4
5#include <string.h> 5#include <string.h>
6#include <stdio.h> 6#include <stdio.h>
7#include <errno.h> 7#include <errno.h>
8#include <time.h> 8#include <time.h>
9#ifdef WIN32 9#ifdef WIN32
10# include <io.h> 10# include <io.h>
11#endif 11#endif
12#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR && defined HAVE_ALPHASORT 12#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR && defined HAVE_ALPHASORT
13# include <dirent.h> 13# include <dirent.h>
14#endif 14#endif
15 15
16#include "../../common/misc/coding/coding.h" 16#include "../../common/misc/coding/coding.h"
17#include "../../common/service/backup/gsmback.h" 17#include "../../common/service/backup/gsmback.h"
18#include "smsdcore.h" 18#include "smsdcore.h"
19 19
20/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */ 20/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */
21static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config) 21static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config)
22{ 22{
23 GSM_Errorerror = ERR_NONE; 23 GSM_Errorerror = ERR_NONE;
24 int i,j; 24 int i,j;
25 unsigned char FileName[100], FullName[400], ext[4], buffer[64],buffer2[400]; 25 unsigned char FileName[100], FullName[400], ext[4], buffer[64],buffer2[400];
26 bool done; 26 bool done;
27 FILE *file; 27 FILE *file;
28#ifdef GSM_ENABLE_BACKUP 28#ifdef GSM_ENABLE_BACKUP
29 GSM_SMS_Backup backup; 29 GSM_SMS_Backup backup;
30#endif 30#endif
31 31
32 j = 0; 32 j = 0;
33 done = false; 33 done = false;
34 for (i=0;i<sms.Number && !done;i++) { 34 for (i=0;i<sms.Number && !done;i++) {
35 strcpy(ext, "txt"); 35 strcpy(ext, "txt");
36 if (sms.SMS[i].Coding == SMS_Coding_8bit) strcpy(ext, "bin"); 36 if (sms.SMS[i].Coding == SMS_Coding_8bit) strcpy(ext, "bin");
37 DecodeUnicode(sms.SMS[i].Number,buffer2); 37 DecodeUnicode(sms.SMS[i].Number,buffer2);
38 /* we loop on yy for the first SMS assuming that if xxxx_yy_00.ext is absent, 38 /* we loop on yy for the first SMS assuming that if xxxx_yy_00.ext is absent,
39 any xxxx_yy_01,02, must be garbage, that can be overwritten */ 39 any xxxx_yy_01,02, must be garbage, that can be overwritten */
40 file = NULL; 40 file = NULL;
41 do { 41 do {
42 sprintf(FileName, 42 sprintf(FileName,
43 "IN%02d%02d%02d_%02d%02d%02d_%02i_%s_%02i.%s", 43 "IN%02d%02d%02d_%02d%02d%02d_%02i_%s_%02i.%s",
44 sms.SMS[i].DateTime.Year, sms.SMS[i].DateTime.Month, sms.SMS[i].DateTime.Day, 44 sms.SMS[i].DateTime.Year, sms.SMS[i].DateTime.Month, sms.SMS[i].DateTime.Day,
45 sms.SMS[i].DateTime.Hour, sms.SMS[i].DateTime.Minute, sms.SMS[i].DateTime.Second, 45 sms.SMS[i].DateTime.Hour, sms.SMS[i].DateTime.Minute, sms.SMS[i].DateTime.Second,
46 j, buffer2, i, ext); 46 j, buffer2, i, ext);
47 strcpy(FullName, Config->inboxpath); 47 strcpy(FullName, Config->inboxpath);
48 strcat(FullName, FileName); 48 strcat(FullName, FileName);
49 if (file) fclose(file); 49 if (file) fclose(file);
50 file = fopen(FullName, "r"); 50 file = fopen(FullName, "r");
51 } while ((i == 0) && (file && (++j < 100))); 51 } while ((i == 0) && (file && (++j < 100)));
52 if (file) { 52 if (file) {
53 fclose(file); 53 fclose(file);
54 if (i == 0) { 54 if (i == 0) {
55 WriteSMSDLog("Cannot save %s. No available file names", FileName); 55 WriteSMSDLog("Cannot save %s. No available file names", FileName);
56 return ERR_CANTOPENFILE; 56 return ERR_CANTOPENFILE;
57 } 57 }
58 } 58 }
59 errno = 0; 59 errno = 0;
60 60
61 if ((sms.SMS[i].PDU == SMS_Status_Report) && mystrncasecmp(Config->deliveryreport, "log", 3)) { 61 if ((sms.SMS[i].PDU == SMS_Status_Report) && mystrncasecmp(Config->deliveryreport, "log", 3)) {
62 strcpy(buffer, DecodeUnicodeString(sms.SMS[i].Number)); 62 strcpy(buffer, DecodeUnicodeString(sms.SMS[i].Number));
63 WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer); 63 WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer);
64 } else { 64 } else {
65#ifdef GSM_ENABLE_BACKUP 65#ifdef GSM_ENABLE_BACKUP
66 if (mystrncasecmp(Config->inboxformat, "detail", 0)) { 66 if (mystrncasecmp(Config->inboxformat, "detail", 0)) {
67 for (j=0;j<sms.Number;j++) backup.SMS[j] = &sms.SMS[j]; 67 for (j=0;j<sms.Number;j++) backup.SMS[j] = &sms.SMS[j];
68 backup.SMS[sms.Number] = NULL; 68 backup.SMS[sms.Number] = NULL;
69 error = GSM_SaveSMSBackupFile(FullName, &backup); 69 error = GSM_AddSMSBackupFile(FullName, &backup);
70 done = true; 70 done = true;
71 } 71 }
72#endif 72#endif
73 if (!mystrncasecmp(Config->inboxformat, "detail", 0)) { 73 if (!mystrncasecmp(Config->inboxformat, "detail", 0)) {
74 file = fopen(FullName, "wb"); 74 file = fopen(FullName, "wb");
75 if (file) { 75 if (file) {
76 switch (sms.SMS[i].Coding) { 76 switch (sms.SMS[i].Coding) {
77 case SMS_Coding_Unicode: 77 case SMS_Coding_Unicode:
78 case SMS_Coding_Default: 78 case SMS_Coding_Default:
79 79
80 DecodeUnicode(sms.SMS[i].Text,buffer2); 80 DecodeUnicode(sms.SMS[i].Text,buffer2);
81 if (mystrncasecmp(Config->inboxformat, "unicode", 0)) { 81 if (mystrncasecmp(Config->inboxformat, "unicode", 0)) {
82 buffer[0] = 0xFE; 82 buffer[0] = 0xFE;
83 buffer[1] = 0xFF; 83 buffer[1] = 0xFF;
84 fwrite(buffer,1,2,file); 84 fwrite(buffer,1,2,file);
85 fwrite(sms.SMS[i].Text,1,strlen(buffer2)*2,file); 85 fwrite(sms.SMS[i].Text,1,strlen(buffer2)*2,file);
86 } else { 86 } else {
87 fwrite(buffer2,1,strlen(buffer2),file); 87 fwrite(buffer2,1,strlen(buffer2),file);
88 } 88 }
89 break; 89 break;
90 case SMS_Coding_8bit: 90 case SMS_Coding_8bit:
91 fwrite(sms.SMS[i].Text,1,sms.SMS[i].Length,file); 91 fwrite(sms.SMS[i].Text,1,sms.SMS[i].Length,file);
92 } 92 }
93 fclose(file); 93 fclose(file);
94 } else error = ERR_CANTOPENFILE; 94 } else error = ERR_CANTOPENFILE;
95 } 95 }
96 if (error == ERR_NONE) { 96 if (error == ERR_NONE) {
97 WriteSMSDLog("%s %s", (sms.SMS[i].PDU == SMS_Status_Report?"Delivery report":"Received"), FileName); 97 WriteSMSDLog("%s %s", (sms.SMS[i].PDU == SMS_Status_Report?"Delivery report":"Received"), FileName);
98 } else { 98 } else {
99 WriteSMSDLog("Cannot save %s (%i)", FileName, errno); 99 WriteSMSDLog("Cannot save %s (%i)", FileName, errno);
100 return ERR_CANTOPENFILE; 100 return ERR_CANTOPENFILE;
101 } 101 }
102 } 102 }
103 } 103 }
104 return ERR_NONE; 104 return ERR_NONE;
105} 105}
106 106
107/* Find one multi SMS to sending and return it (or return ERR_EMPTY) 107/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
108 * There is also set ID for SMS 108 * There is also set ID for SMS
109 * File extension convention: 109 * File extension convention:
110 * OUTxxxxx.txt : normal text SMS 110 * OUTxxxxx.txt : normal text SMS
111 * Options appended to the extension applying to this SMS only: 111 * Options appended to the extension applying to this SMS only:
112 * d: delivery report requested 112 * d: delivery report requested
113 * f: flash SMS 113 * f: flash SMS
114 * b: WAP bookmark as name,URL 114 * b: WAP bookmark as name,URL
115 * e.g. OUTG20040620_193810_123_+4512345678_xpq.txtdf 115 * e.g. OUTG20040620_193810_123_+4512345678_xpq.txtdf
116 * is a flash text SMS requesting delivery reports 116 * is a flash text SMS requesting delivery reports
117 */ 117 */
118static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID) 118static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
119{ 119{
120 GSM_Error error = ERR_NOTSUPPORTED; 120 GSM_Error error = ERR_NOTSUPPORTED;
121 GSM_MultiPartSMSInfo SMSInfo; 121 GSM_MultiPartSMSInfo SMSInfo;
122 GSM_WAPBookmark Bookmark; 122 GSM_WAPBookmark Bookmark;
123 unsigned char FileName[100],FullName[400]; 123 unsigned char FileName[100],FullName[400];
124 unsigned char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2]; 124 unsigned char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
125 unsigned char Buffer2[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2]; 125 unsigned char Buffer2[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
126 FILE *File; 126 FILE *File;
127 int i, len, phlen; 127 int i, len, phlen;
128 char *pos1, *pos2, *options; 128 char *pos1, *pos2, *options;
129#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT 129#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT
130 struct dirent **namelist = NULL; 130 struct dirent **namelist = NULL;
131 int l, m ,n; 131 int l, m ,n;
132 132
133 strcpy(FullName, Config->outboxpath); 133 strcpy(FullName, Config->outboxpath);
134 FullName[strlen(Config->outboxpath)-1] = '\0'; 134 FullName[strlen(Config->outboxpath)-1] = '\0';
135 n = scandir(FullName, &namelist, 0, alphasort); 135 n = scandir(FullName, &namelist, 0, alphasort);
136 m = 0; 136 m = 0;
137 while ((m < n) && ((*(namelist[m]->d_name) == '.') || // directory and UNIX hidden file 137 while ((m < n) && ((*(namelist[m]->d_name) == '.') || // directory and UNIX hidden file
138 !mystrncasecmp(namelist[m]->d_name,"out", 3) || // must start with 'out' 138 !mystrncasecmp(namelist[m]->d_name,"out", 3) || // must start with 'out'
139 ((strlen(namelist[m]->d_name) >= 4) && 139 ((strlen(namelist[m]->d_name) >= 4) &&
140 !mystrncasecmp(strrchr(namelist[m]->d_name, '.'),".txt",4) 140 !mystrncasecmp(strrchr(namelist[m]->d_name, '.'),".txt",4)
141 ) 141 )
142 ) 142 )
143 ) m++; 143 ) m++;
144 if (m < n) strcpy(FileName,namelist[m]->d_name); 144 if (m < n) strcpy(FileName,namelist[m]->d_name);
145 for (l=0; l < n; l++) free(namelist[l]); 145 for (l=0; l < n; l++) free(namelist[l]);
146 free(namelist); 146 free(namelist);
147 namelist = NULL; 147 namelist = NULL;
148 if (m >= n) return ERR_EMPTY; 148 if (m >= n) return ERR_EMPTY;
149 error = ERR_NONE; 149 error = ERR_NONE;
150#else 150#else
151#ifdef WIN32 151#ifdef WIN32
152 struct _finddata_t c_file; 152 struct _finddata_t c_file;
153 long hFile; 153 long hFile;
154 154
155 strcpy(FullName, Config->outboxpath); 155 strcpy(FullName, Config->outboxpath);
156 strcat(FullName, "OUT*.txt*"); 156 strcat(FullName, "OUT*.txt*");
157 if((hFile = _findfirst( FullName, &c_file )) == -1L ) { 157 if((hFile = _findfirst( FullName, &c_file )) == -1L ) {
158 return ERR_EMPTY; 158 return ERR_EMPTY;
159 } else { 159 } else {
160 strcpy(FileName,c_file.name); 160 strcpy(FileName,c_file.name);
161 } 161 }
162 _findclose( hFile ); 162 _findclose( hFile );
163 error = ERR_NONE; 163 error = ERR_NONE;
164#endif 164#endif
165#endif 165#endif
166 if (error != ERR_NONE) return error; 166 if (error != ERR_NONE) return error;
167 options = strrchr(FileName, '.') + 4; 167 options = strrchr(FileName, '.') + 4;
168 strcpy(FullName, Config->outboxpath); 168 strcpy(FullName, Config->outboxpath);
169 strcat(FullName, FileName); 169 strcat(FullName, FileName);
170 170
171 File = fopen(FullName, "rb"); 171 File = fopen(FullName, "rb");
172 len = fread(Buffer, 1, sizeof(Buffer)-2, File); 172 len = fread(Buffer, 1, sizeof(Buffer)-2, File);
173 fclose(File); 173 fclose(File);
174 174
175 if ((len < 2) || 175 if ((len < 2) ||
176 (len >= 2 && ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) && 176 (len >= 2 && ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) &&
177 (Buffer[0] != 0xFE || Buffer[1] != 0xFF)))) { 177 (Buffer[0] != 0xFE || Buffer[1] != 0xFF)))) {
178 if (len > GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS) len = GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS; 178 if (len > GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS) len = GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS;
179 EncodeUnicode(Buffer2, Buffer, len); 179 EncodeUnicode(Buffer2, Buffer, len);
180 len = len*2; 180 len = len*2;
181 memmove(Buffer, Buffer2, len); 181 memmove(Buffer, Buffer2, len);
182 } 182 }
183 183
184 Buffer[len] = 0; 184 Buffer[len] = 0;
185 Buffer[len+1] = 0; 185 Buffer[len+1] = 0;
186 ReadUnicodeFile(Buffer2,Buffer); 186 ReadUnicodeFile(Buffer2,Buffer);
187 187
188 GSM_ClearMultiPartSMSInfo(&SMSInfo); 188 GSM_ClearMultiPartSMSInfo(&SMSInfo);
189 sms->Number = 0; 189 sms->Number = 0;
190 190
191 SMSInfo.ReplaceMessage = 0; 191 SMSInfo.ReplaceMessage = 0;
192 SMSInfo.Entries[0].Buffer= Buffer2; 192 SMSInfo.Entries[0].Buffer= Buffer2;
193 SMSInfo.Class = -1; 193 SMSInfo.Class = -1;
194 SMSInfo.EntriesNum = 1; 194 SMSInfo.EntriesNum = 1;
195 Config->currdeliveryreport= -1; 195 Config->currdeliveryreport= -1;
196 if (strchr(options, 'd')) Config->currdeliveryreport= 1; 196 if (strchr(options, 'd')) Config->currdeliveryreport= 1;
197 if (strchr(options, 'f')) SMSInfo.Class = 0; /* flash SMS */ 197 if (strchr(options, 'f')) SMSInfo.Class = 0; /* flash SMS */
198 198
199 if (mystrncasecmp(Config->transmitformat, "unicode", 0)) { 199 if (mystrncasecmp(Config->transmitformat, "unicode", 0)) {
200 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; 200 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
201 SMSInfo.UnicodeCoding = true; 201 SMSInfo.UnicodeCoding = true;
202 } else if (mystrncasecmp(Config->transmitformat, "7bit", 0)) { 202 } else if (mystrncasecmp(Config->transmitformat, "7bit", 0)) {
203 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; 203 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
204 SMSInfo.UnicodeCoding = false; 204 SMSInfo.UnicodeCoding = false;
205 } else { 205 } else {
206 /* auto */ 206 /* auto */
207 SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong; 207 SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
208 } 208 }
209 209
210 if (strchr(options, 'b')) { // WAP bookmark as title,URL 210 if (strchr(options, 'b')) { // WAP bookmark as title,URL
211 SMSInfo.Entries[0].Buffer = NULL; 211 SMSInfo.Entries[0].Buffer = NULL;
212 SMSInfo.Entries[0].Bookmark = &Bookmark; 212 SMSInfo.Entries[0].Bookmark = &Bookmark;
213 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong; 213 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
214 SMSInfo.Entries[0].Bookmark->Location= 0; 214 SMSInfo.Entries[0].Bookmark->Location= 0;
215 pos2 = mywstrstr(Buffer2, "\0,"); 215 pos2 = mywstrstr(Buffer2, "\0,");
216 if (pos2 == NULL) { 216 if (pos2 == NULL) {
217 pos2 = Buffer2; 217 pos2 = Buffer2;
218 } else { 218 } else {
219 *pos2 = '\0'; pos2++; *pos2 = '\0'; pos2++; // replace comma by zero 219 *pos2 = '\0'; pos2++; *pos2 = '\0'; pos2++; // replace comma by zero
220 } 220 }
221 221
222 len = UnicodeLength(Buffer2); 222 len = UnicodeLength(Buffer2);
223 if (len > 50) len = 50; 223 if (len > 50) len = 50;
224 memmove(&SMSInfo.Entries[0].Bookmark->Title, Buffer2, len * 2); 224 memmove(&SMSInfo.Entries[0].Bookmark->Title, Buffer2, len * 2);
225 pos1 = &SMSInfo.Entries[0].Bookmark->Title[0] + len * 2; 225 pos1 = &SMSInfo.Entries[0].Bookmark->Title[0] + len * 2;
226 *pos1 = '\0'; pos1++; *pos1 = '\0'; 226 *pos1 = '\0'; pos1++; *pos1 = '\0';
227 227
228 len = UnicodeLength(pos2); 228 len = UnicodeLength(pos2);
229 if (len > 255) len = 255; 229 if (len > 255) len = 255;
230 memmove(&SMSInfo.Entries[0].Bookmark->Address, pos2, len * 2); 230 memmove(&SMSInfo.Entries[0].Bookmark->Address, pos2, len * 2);
231 pos1 = &SMSInfo.Entries[0].Bookmark->Address[0] + len * 2; 231 pos1 = &SMSInfo.Entries[0].Bookmark->Address[0] + len * 2;
232 *pos1 = '\0'; pos1++; *pos1 = '\0'; 232 *pos1 = '\0'; pos1++; *pos1 = '\0';
233 } 233 }
234 234
235 GSM_EncodeMultiPartSMS(&SMSInfo,sms); 235 GSM_EncodeMultiPartSMS(&SMSInfo,sms);
236 236
237 pos1 = FileName; 237 pos1 = FileName;
238 strcpy(ID,FileName); 238 strcpy(ID,FileName);
239 for (i = 1; i <= 3 && pos1 != NULL ; i++) pos1 = strchr(++pos1, '_'); 239 for (i = 1; i <= 3 && pos1 != NULL ; i++) pos1 = strchr(++pos1, '_');
240 if (pos1 != NULL) { 240 if (pos1 != NULL) {
241 /* OUT<priority><date>_<time>_<serialno>_<phone number>_<anything>.txt */ 241 /* OUT<priority><date>_<time>_<serialno>_<phone number>_<anything>.txt */
242 pos2 = strchr(++pos1, '_'); 242 pos2 = strchr(++pos1, '_');
243 if (pos2 != NULL) { 243 if (pos2 != NULL) {
244 phlen = strlen(pos1) - strlen(pos2); 244 phlen = strlen(pos1) - strlen(pos2);
245 } else { 245 } else {
246 /* something wrong */ 246 /* something wrong */
247 return ERR_UNKNOWN; 247 return ERR_UNKNOWN;
248 } 248 }
249 } else if (i == 2) { 249 } else if (i == 2) {
250 /* OUTxxxxxxx.txt or OUTxxxxxxx */ 250 /* OUTxxxxxxx.txt or OUTxxxxxxx */
251 pos1 = &FileName[3]; 251 pos1 = &FileName[3];
252 pos2 = strchr(pos1, '.'); 252 pos2 = strchr(pos1, '.');
253 if (pos2 == NULL) { 253 if (pos2 == NULL) {
254 phlen = strlen(pos1); 254 phlen = strlen(pos1);
255 } else { 255 } else {
256 phlen = strlen(pos1) - strlen(pos2); 256 phlen = strlen(pos1) - strlen(pos2);
257 } 257 }
258 } else if (i == 4) { 258 } else if (i == 4) {
259 /* OUT<priority>_<phone number>_<serialno>.txt */ 259 /* OUT<priority>_<phone number>_<serialno>.txt */
260 pos1 = strchr(FileName, '_'); 260 pos1 = strchr(FileName, '_');
261 pos2 = strchr(++pos1, '_'); 261 pos2 = strchr(++pos1, '_');
262 phlen = strlen(pos1) - strlen(pos2); 262 phlen = strlen(pos1) - strlen(pos2);
263 } else { 263 } else {
264 /* something wrong */ 264 /* something wrong */
265 return ERR_UNKNOWN; 265 return ERR_UNKNOWN;
266 } 266 }
267 267
268 for (len=0;len<sms->Number;len++) { 268 for (len=0;len<sms->Number;len++) {
269 EncodeUnicode(sms->SMS[len].Number, pos1, phlen); 269 EncodeUnicode(sms->SMS[len].Number, pos1, phlen);
270 } 270 }
271 271
272#ifdef DEBUG 272#ifdef DEBUG
273 if (sms->Number != 0) { 273 if (sms->Number != 0) {
274 DecodeUnicode(sms->SMS[0].Number,Buffer); 274 DecodeUnicode(sms->SMS[0].Number,Buffer);
275 dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i dlr: %i fls: %i", 275 dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i dlr: %i fls: %i",
276 sms->Number, 276 sms->Number,
277 Buffer, 277 Buffer,
278 DecodeUnicodeString(sms->SMS[0].Text), 278 DecodeUnicodeString(sms->SMS[0].Text),
279 sms->SMS[0].Coding, 279 sms->SMS[0].Coding,
280 sms->SMS[0].Length, 280 sms->SMS[0].Length,
281 sms->SMS[0].UDH.Type, 281 sms->SMS[0].UDH.Type,
282 sms->SMS[0].UDH.Length, 282 sms->SMS[0].UDH.Length,
283 Config->currdeliveryreport, 283 Config->currdeliveryreport,
284 SMSInfo.Class); 284 SMSInfo.Class);
285 } else dbgprintf("error: SMS-count = 0"); 285 } else dbgprintf("error: SMS-count = 0");
286#endif 286#endif
287 287
288 return ERR_NONE; 288 return ERR_NONE;
289} 289}
290 290
291/* After sending SMS is moved to Sent Items or Error Items. */ 291/* After sending SMS is moved to Sent Items or Error Items. */
292static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent) 292static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
293{ 293{
294 FILE *oFile,*iFile; 294 FILE *oFile,*iFile;
295 int ilen = 0, olen = 0; 295 int ilen = 0, olen = 0;
296 char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2],ifilename[400],ofilename[400]; 296 char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2],ifilename[400],ofilename[400];
297 char*sourcepath, *destpath; 297 char*sourcepath, *destpath;
298 298
299 sourcepath = Config->outboxpath; 299 sourcepath = Config->outboxpath;
300 if (sent) { 300 if (sent) {
301 destpath = Config->sentsmspath; 301 destpath = Config->sentsmspath;
302 } else { 302 } else {
303 destpath = Config->errorsmspath; 303 destpath = Config->errorsmspath;
304 } 304 }
305 305
306 strcpy(ifilename, sourcepath); 306 strcpy(ifilename, sourcepath);
307 strcat(ifilename, ID); 307 strcat(ifilename, ID);
308 strcpy(ofilename, destpath); 308 strcpy(ofilename, destpath);
309 strcat(ofilename, ID); 309 strcat(ofilename, ID);
310 310
311#ifdef WIN32 311#ifdef WIN32
312 if (!mystrncasecmp(ifilename, ofilename, strlen(ofilename))) { 312 if (!mystrncasecmp(ifilename, ofilename, strlen(ofilename))) {
313#else 313#else
314 if (strcmp(ifilename, ofilename) != 0) { 314 if (strcmp(ifilename, ofilename) != 0) {
315#endif 315#endif
316 iFile = fopen(ifilename, "r"); 316 iFile = fopen(ifilename, "r");
317 ilen = fread(Buffer, 1, sizeof(Buffer), iFile); 317 ilen = fread(Buffer, 1, sizeof(Buffer), iFile);
318 fclose(iFile); 318 fclose(iFile);
319 oFile = fopen(ofilename, "w"); 319 oFile = fopen(ofilename, "w");
320 olen = fwrite(Buffer, 1, ilen, oFile); 320 olen = fwrite(Buffer, 1, ilen, oFile);
321 fclose(oFile); 321 fclose(oFile);
322 } 322 }
323 if (ilen == olen) { 323 if (ilen == olen) {
324 if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0)) { 324 if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0)) {
325 WriteSMSDLog("Could not delete %s (%i)", ifilename, errno); 325 WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
326 return ERR_UNKNOWN; 326 return ERR_UNKNOWN;
327 } 327 }
328 return ERR_NONE; 328 return ERR_NONE;
329 } else { 329 } else {
330 WriteSMSDLog("Error copying SMS %s -> %s", ifilename, ofilename); 330 WriteSMSDLog("Error copying SMS %s -> %s", ifilename, ofilename);
331 if (alwaysDelete) { 331 if (alwaysDelete) {
332 if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0)) 332 if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0))
333 WriteSMSDLog("Could not delete %s (%i)", ifilename, errno); 333 WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
334 } 334 }
335 return ERR_UNKNOWN; 335 return ERR_UNKNOWN;
336 } 336 }
337} 337}
338 338
339static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR) 339static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
340{ 340{
341 if (err == SMSD_SEND_OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number)); 341 if (err == SMSD_SEND_OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
342 342
343 return ERR_NONE; 343 return ERR_NONE;
344} 344}
345 345
346GSM_SMSDService SMSDFiles = { 346GSM_SMSDService SMSDFiles = {
347 NONEFUNCTION, /* Init */ 347 NONEFUNCTION, /* Init */
348 NONEFUNCTION, /* InitAfterConnect */ 348 NONEFUNCTION, /* InitAfterConnect */
349 SMSDFiles_SaveInboxSMS, 349 SMSDFiles_SaveInboxSMS,
350 SMSDFiles_FindOutboxSMS, 350 SMSDFiles_FindOutboxSMS,
351 SMSDFiles_MoveSMS, 351 SMSDFiles_MoveSMS,
352 NOTSUPPORTED, /* CreateOutboxSMS*/ 352 NOTSUPPORTED, /* CreateOutboxSMS*/
353 SMSDFiles_AddSentSMSInfo, 353 SMSDFiles_AddSentSMSInfo,
354 NOTSUPPORTED, /* RefreshSendStatus*/ 354 NOTSUPPORTED, /* RefreshSendStatus*/
355 NOTSUPPORTED /* RefreshPhoneStatus*/ 355 NOTSUPPORTED /* RefreshPhoneStatus*/
356}; 356};
357 357
358/* How should editor handle tabs in this file? Add editor commands here. 358/* How should editor handle tabs in this file? Add editor commands here.
359 * vim: noexpandtab sw=8 ts=8 sts=8: 359 * vim: noexpandtab sw=8 ts=8 sts=8:
360 */ 360 */
diff --git a/gammu/emb/gammu/smsd/smsdcore.c b/gammu/emb/gammu/smsd/smsdcore.c
index cc9accc..e69a6e7 100644
--- a/gammu/emb/gammu/smsd/smsdcore.c
+++ b/gammu/emb/gammu/smsd/smsdcore.c
@@ -1,583 +1,588 @@
1/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */ 1/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
2 2
3#include <string.h> 3#include <string.h>
4#include <signal.h> 4#include <signal.h>
5#include <stdarg.h> 5#include <stdarg.h>
6#include <time.h> 6#include <time.h>
7 7
8#include "../../common/misc/coding/coding.h" 8#include "../../common/misc/coding/coding.h"
9#include "../gammu.h" 9#include "../gammu.h"
10#include "smsdcore.h" 10#include "smsdcore.h"
11#include "s_files.h" 11#include "s_files.h"
12#ifdef HAVE_MYSQL_MYSQL_H 12#ifdef HAVE_MYSQL_MYSQL_H
13# include "s_mysql.h" 13# include "s_mysql.h"
14#endif 14#endif
15 15
16 FILE *smsd_log_file = NULL; 16 FILE *smsd_log_file = NULL;
17 static int TPMR; 17 static int TPMR;
18static GSM_Error SendingSMSStatus; 18static GSM_Error SendingSMSStatus;
19 19
20static void SMSSendingSMSStatus (char *Device, int status, int mr) 20static void SMSSendingSMSStatus (char *Device, int status, int mr)
21{ 21{
22 dbgprintf("Incoming SMS device: \"%s\" status=%d, reference=%d\n",Device, status, mr); 22 dbgprintf("Incoming SMS device: \"%s\" status=%d, reference=%d\n",Device, status, mr);
23 TPMR = mr; 23 TPMR = mr;
24 if (status==0) { 24 if (status==0) {
25 SendingSMSStatus = ERR_NONE; 25 SendingSMSStatus = ERR_NONE;
26 } else { 26 } else {
27 SendingSMSStatus = ERR_UNKNOWN; 27 SendingSMSStatus = ERR_UNKNOWN;
28 } 28 }
29} 29}
30 30
31void GSM_Terminate_SMSD(char *msg, int error, bool exitprogram, int rc) 31void GSM_Terminate_SMSD(char *msg, int error, bool exitprogram, int rc)
32{ 32{
33 int ret = ERR_NONE; 33 int ret = ERR_NONE;
34 34
35 if (s.opened) { 35 if (s.opened) {
36 WriteSMSDLog("Terminating communication"); 36 WriteSMSDLog("Terminating communication");
37 ret=GSM_TerminateConnection(&s); 37 ret=GSM_TerminateConnection(&s);
38 if (ret!=ERR_NONE) { 38 if (ret!=ERR_NONE) {
39 printf("%s\n",print_error(error,s.di.df,s.msg)); 39 printf("%s\n",print_error(error,s.di.df,s.msg));
40 if (s.opened) GSM_TerminateConnection(&s); 40 if (s.opened) GSM_TerminateConnection(&s);
41 } 41 }
42 } 42 }
43 if (error != 0) { 43 if (error != 0) {
44 WriteSMSDLog(msg, error, print_error(error,s.di.df,s.msg)); 44 WriteSMSDLog(msg, error, print_error(error,s.di.df,s.msg));
45 fprintf(stderr, msg, error, print_error(error,s.di.df,s.msg)); 45 fprintf(stderr, msg, error, print_error(error,s.di.df,s.msg));
46 fprintf(stderr, "\n"); 46 fprintf(stderr, "\n");
47 } 47 }
48 if (exitprogram) { 48 if (exitprogram) {
49 if (smsd_log_file!=NULL) fclose(smsd_log_file); 49 if (smsd_log_file!=NULL) fclose(smsd_log_file);
50 exit(rc); 50 exit(rc);
51 } 51 }
52} 52}
53 53
54#ifdef __GNUC__ 54#ifdef __GNUC__
55__attribute__((format(printf, 1, 2))) 55__attribute__((format(printf, 1, 2)))
56#endif 56#endif
57void WriteSMSDLog(char *format, ...) 57void WriteSMSDLog(char *format, ...)
58{ 58{
59 GSM_DateTime date_time; 59 GSM_DateTime date_time;
60 char Buffer[2000]; 60 char Buffer[2000];
61 va_list argp; 61 va_list argp;
62 int result; 62 int result;
63 63
64 if (smsd_log_file != NULL) { 64 if (smsd_log_file != NULL) {
65 va_start(argp, format); 65 va_start(argp, format);
66 result = vsprintf(Buffer,GetMsg(s.msg,format),argp); 66 result = vsprintf(Buffer,GetMsg(s.msg,format),argp);
67 va_end(argp); 67 va_end(argp);
68 68
69 GSM_GetCurrentDateTime(&date_time); 69 GSM_GetCurrentDateTime(&date_time);
70 70
71 fprintf(smsd_log_file,"%s %4d/%02d/%02d %02d:%02d:%02d : %s\n", 71 fprintf(smsd_log_file,"%s %4d/%02d/%02d %02d:%02d:%02d : %s\n",
72 DayOfWeek(date_time.Year, date_time.Month, date_time.Day), 72 DayOfWeek(date_time.Year, date_time.Month, date_time.Day),
73 date_time.Year, date_time.Month, date_time.Day, 73 date_time.Year, date_time.Month, date_time.Day,
74 date_time.Hour, date_time.Minute, date_time.Second,Buffer); 74 date_time.Hour, date_time.Minute, date_time.Second,Buffer);
75 fflush(smsd_log_file); 75 fflush(smsd_log_file);
76 } 76 }
77} 77}
78 78
79void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log, char *service) 79void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log, char *service)
80{ 80{
81 INI_Section *smsdcfgfile = NULL; 81 INI_Section *smsdcfgfile = NULL;
82 GSM_Config smsdcfg; 82 GSM_Config smsdcfg;
83 unsigned char *str; 83 unsigned char *str;
84 static unsigned charemptyPath[1] = "\0"; 84 static unsigned charemptyPath[1] = "\0";
85 85
86 smsdcfgfile=INI_ReadFile(filename, false); 86 smsdcfgfile=INI_ReadFile(filename, false);
87 if (smsdcfgfile==NULL) { 87 if (smsdcfgfile==NULL) {
88 fprintf(stderr,"Can't find file \"%s\"\n",filename); 88 fprintf(stderr,"Can't find file \"%s\"\n",filename);
89 exit(-1); 89 exit(-1);
90 } 90 }
91 91
92 Config->logfilename=INI_GetValue(smsdcfgfile, "smsd", "logfile", false); 92 Config->logfilename=INI_GetValue(smsdcfgfile, "smsd", "logfile", false);
93 if (Config->logfilename != NULL) { 93 if (Config->logfilename != NULL) {
94 smsd_log_file=fopen(Config->logfilename,"ab"); 94 smsd_log_file=fopen(Config->logfilename,"ab");
95 if (smsd_log_file == NULL) { 95 if (smsd_log_file == NULL) {
96 fprintf(stderr,"Can't open file \"%s\"\n",Config->logfilename); 96 fprintf(stderr,"Can't open file \"%s\"\n",Config->logfilename);
97 exit(-1); 97 exit(-1);
98 } 98 }
99 fprintf(stderr,"Log filename is \"%s\"\n",Config->logfilename); 99 fprintf(stderr,"Log filename is \"%s\"\n",Config->logfilename);
100 } 100 }
101 if (log) WriteSMSDLog("Start GAMMU smsd"); 101 if (log) WriteSMSDLog("Start GAMMU smsd");
102 102
103 /* Include Numbers used, because we don't want create new variable */ 103 /* Include Numbers used, because we don't want create new variable */
104 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "gammu", false); 104 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "gammu", false);
105 if (Config->IncludeNumbers) { 105 if (Config->IncludeNumbers) {
106 GSM_ReadConfig(smsdcfgfile, &smsdcfg, 0); 106 GSM_ReadConfig(smsdcfgfile, &smsdcfg, 0);
107 memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config)); 107 memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config));
108 error=GSM_SetDebugFile(s.Config[0].DebugFile, &di); 108 error=GSM_SetDebugFile(s.Config[0].DebugFile, &di);
109 } 109 }
110 110
111 Config->PINCode=INI_GetValue(smsdcfgfile, "smsd", "PIN", false); 111 Config->PINCode=INI_GetValue(smsdcfgfile, "smsd", "PIN", false);
112 if (Config->PINCode == NULL) { 112 if (Config->PINCode == NULL) {
113 if (log) WriteSMSDLog("No PIN code in %s file",filename); 113 if (log) WriteSMSDLog("Warning: No PIN code in %s file",filename);
114 fprintf(stderr,"No PIN code in %s file\n",filename); 114 fprintf(stderr,"Warning: No PIN code in %s file\n",filename);
115 exit(-1); 115 } else {
116 if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode);
116 } 117 }
117 if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode);
118 118
119 str = INI_GetValue(smsdcfgfile, "smsd", "commtimeout", false); 119 str = INI_GetValue(smsdcfgfile, "smsd", "commtimeout", false);
120 if (str) Config->commtimeout=atoi(str); else Config->commtimeout = 1; 120 if (str) Config->commtimeout=atoi(str); else Config->commtimeout = 1;
121 str = INI_GetValue(smsdcfgfile, "smsd", "sendtimeout", false); 121 str = INI_GetValue(smsdcfgfile, "smsd", "sendtimeout", false);
122 if (str) Config->sendtimeout=atoi(str); else Config->sendtimeout = 10; 122 if (str) Config->sendtimeout=atoi(str); else Config->sendtimeout = 10;
123 str = INI_GetValue(smsdcfgfile, "smsd", "receivefrequency", false); 123 str = INI_GetValue(smsdcfgfile, "smsd", "receivefrequency", false);
124 if (str) Config->receivefrequency=atoi(str); else Config->receivefrequency = 0; 124 if (str) Config->receivefrequency=atoi(str); else Config->receivefrequency = 0;
125 str = INI_GetValue(smsdcfgfile, "smsd", "resetfrequency", false); 125 str = INI_GetValue(smsdcfgfile, "smsd", "resetfrequency", false);
126 if (str) Config->resetfrequency=atoi(str); else Config->resetfrequency = 0; 126 if (str) Config->resetfrequency=atoi(str); else Config->resetfrequency = 0;
127 if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i, resetfrequency=%i", 127 if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i, resetfrequency=%i",
128 Config->commtimeout, Config->sendtimeout, Config->receivefrequency, Config->resetfrequency); 128 Config->commtimeout, Config->sendtimeout, Config->receivefrequency, Config->resetfrequency);
129 129
130 Config->deliveryreport = INI_GetValue(smsdcfgfile, "smsd", "deliveryreport", false); 130 Config->deliveryreport = INI_GetValue(smsdcfgfile, "smsd", "deliveryreport", false);
131 if (Config->deliveryreport == NULL || (!mystrncasecmp(Config->deliveryreport, "log", 3) && !mystrncasecmp(Config->deliveryreport, "sms", 3))) { 131 if (Config->deliveryreport == NULL || (!mystrncasecmp(Config->deliveryreport, "log", 3) && !mystrncasecmp(Config->deliveryreport, "sms", 3))) {
132 Config->deliveryreport = "no"; 132 Config->deliveryreport = "no";
133 } 133 }
134 if (log) WriteSMSDLog("deliveryreport = %s", Config->deliveryreport); 134 if (log) WriteSMSDLog("deliveryreport = %s", Config->deliveryreport);
135 135
136 Config->PhoneID = INI_GetValue(smsdcfgfile, "smsd", "phoneid", false); 136 Config->PhoneID = INI_GetValue(smsdcfgfile, "smsd", "phoneid", false);
137 if (Config->PhoneID == NULL) Config->PhoneID = ""; 137 if (Config->PhoneID == NULL) Config->PhoneID = "";
138 if (log) WriteSMSDLog("phoneid = %s", Config->PhoneID); 138 if (log) WriteSMSDLog("phoneid = %s", Config->PhoneID);
139 139
140 if (!strcmp(service,"FILES")) { 140 if (!strcmp(service,"FILES")) {
141 Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false); 141 Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false);
142 if (Config->inboxpath == NULL) Config->inboxpath = emptyPath; 142 if (Config->inboxpath == NULL) Config->inboxpath = emptyPath;
143 143
144 Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false); 144 Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false);
145 if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) { 145 if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) {
146 Config->inboxformat = "standard"; 146 Config->inboxformat = "standard";
147 } 147 }
148 if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat); 148 if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat);
149 149
150 Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false); 150 Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false);
151 if (Config->outboxpath == NULL) Config->outboxpath = emptyPath; 151 if (Config->outboxpath == NULL) Config->outboxpath = emptyPath;
152 152
153 Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false); 153 Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false);
154 if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) { 154 if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) {
155 Config->transmitformat = "7bit"; 155 Config->transmitformat = "7bit";
156 } 156 }
157 if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat); 157 if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat);
158 158
159 Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false); 159 Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false);
160 if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath; 160 if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath;
161 if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath); 161 if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath);
162 162
163 Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false); 163 Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false);
164 if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath; 164 if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath;
165 if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath); 165 if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath);
166 } 166 }
167 167
168#ifdef HAVE_MYSQL_MYSQL_H 168#ifdef HAVE_MYSQL_MYSQL_H
169 if (!strcmp(service,"MYSQL")) { 169 if (!strcmp(service,"MYSQL")) {
170 Config->skipsmscnumber = INI_GetValue(smsdcfgfile, "smsd", "skipsmscnumber", false); 170 Config->skipsmscnumber = INI_GetValue(smsdcfgfile, "smsd", "skipsmscnumber", false);
171 if (Config->skipsmscnumber == NULL) Config->skipsmscnumber=""; 171 if (Config->skipsmscnumber == NULL) Config->skipsmscnumber="";
172 Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false); 172 Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
173 if (Config->user == NULL) Config->user="root"; 173 if (Config->user == NULL) Config->user="root";
174 Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false); 174 Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
175 if (Config->password == NULL) Config->password=""; 175 if (Config->password == NULL) Config->password="";
176 Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false); 176 Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
177 if (Config->PC == NULL) Config->PC="localhost"; 177 if (Config->PC == NULL) Config->PC="localhost";
178 Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false); 178 Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
179 if (Config->database == NULL) Config->database="sms"; 179 if (Config->database == NULL) Config->database="sms";
180 } 180 }
181#endif 181#endif
182 182
183 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "include_numbers", false); 183 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "include_numbers", false);
184 Config->ExcludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "exclude_numbers", false); 184 Config->ExcludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "exclude_numbers", false);
185 if (Config->IncludeNumbers != NULL) { 185 if (Config->IncludeNumbers != NULL) {
186 if (log) WriteSMSDLog("Include numbers available"); 186 if (log) WriteSMSDLog("Include numbers available");
187 } 187 }
188 if (Config->ExcludeNumbers != NULL) { 188 if (Config->ExcludeNumbers != NULL) {
189 if (Config->IncludeNumbers == NULL) { 189 if (Config->IncludeNumbers == NULL) {
190 if (log) WriteSMSDLog("Exclude numbers available"); 190 if (log) WriteSMSDLog("Exclude numbers available");
191 } else { 191 } else {
192 if (log) WriteSMSDLog("Exclude numbers available, but IGNORED"); 192 if (log) WriteSMSDLog("Exclude numbers available, but IGNORED");
193 } 193 }
194 } 194 }
195 195
196 Config->retries = 0; 196 Config->retries = 0;
197 Config->prevSMSID[0] = 0; 197 Config->prevSMSID[0] = 0;
198 Config->SMSC.Location = 0; 198 Config->SMSC.Location = 0;
199 Config->relativevalidity = -1; 199 Config->relativevalidity = -1;
200} 200}
201 201
202bool SMSD_CheckSecurity(GSM_SMSDConfig *Config) 202bool SMSD_CheckSecurity(GSM_SMSDConfig *Config)
203{ 203{
204 GSM_SecurityCode SecurityCode; 204 GSM_SecurityCode SecurityCode;
205 GSM_Error error; 205 GSM_Error error;
206 206
207 /* Need PIN ? */ 207 /* Need PIN ? */
208 error=Phone->GetSecurityStatus(&s,&SecurityCode.Type); 208 error=Phone->GetSecurityStatus(&s,&SecurityCode.Type);
209 /* Unknown error */ 209 /* Unknown error */
210 if (error != ERR_NOTSUPPORTED && error != ERR_NONE) { 210 if (error != ERR_NOTSUPPORTED && error != ERR_NONE) {
211 WriteSMSDLog("Error getting security status (%i)", error); 211 WriteSMSDLog("Error getting security status (%i)", error);
212 return false; 212 return false;
213 } 213 }
214 /* No supported - do not check more */ 214 /* No supported - do not check more */
215 if (error == ERR_NOTSUPPORTED) return true; 215 if (error == ERR_NOTSUPPORTED) return true;
216 216
217 /* If PIN, try to enter */ 217 /* If PIN, try to enter */
218 switch (SecurityCode.Type) { 218 switch (SecurityCode.Type) {
219 case SEC_Pin: 219 case SEC_Pin:
220 WriteSMSDLog("Trying to enter PIN"); 220 if (Config->PINCode==NULL) {
221 strcpy(SecurityCode.Code,Config->PINCode); 221 WriteSMSDLog("Warning: no PIN in config");
222 error=Phone->EnterSecurityCode(&s,SecurityCode);
223 if (error == ERR_SECURITYERROR) {
224 GSM_Terminate_SMSD("ERROR: incorrect PIN", error, true, -1);
225 }
226 if (error != ERR_NONE) {
227 WriteSMSDLog("Error entering PIN (%i)", error);
228 return false; 222 return false;
229 } 223 } else {
224 WriteSMSDLog("Trying to enter PIN");
225 strcpy(SecurityCode.Code,Config->PINCode);
226 error=Phone->EnterSecurityCode(&s,SecurityCode);
227 if (error == ERR_SECURITYERROR) {
228 GSM_Terminate_SMSD("ERROR: incorrect PIN", error, true, -1);
229 }
230 if (error != ERR_NONE) {
231 WriteSMSDLog("Error entering PIN (%i)", error);
232 return false;
233 }
234 }
230 break; 235 break;
231 case SEC_SecurityCode: 236 case SEC_SecurityCode:
232 case SEC_Pin2: 237 case SEC_Pin2:
233 case SEC_Puk: 238 case SEC_Puk:
234 case SEC_Puk2: 239 case SEC_Puk2:
235 GSM_Terminate_SMSD("ERROR: phone requires not supported code type", 0, true, -1); 240 GSM_Terminate_SMSD("ERROR: phone requires not supported code type", 0, true, -1);
236 case SEC_None: 241 case SEC_None:
237 break; 242 break;
238 } 243 }
239 return true; 244 return true;
240} 245}
241 246
242bool SMSD_ReadDeleteSMS(GSM_SMSDConfig *Config, GSM_SMSDService *Service) 247bool SMSD_ReadDeleteSMS(GSM_SMSDConfig *Config, GSM_SMSDService *Service)
243{ 248{
244 bool start,process; 249 bool start,process;
245 GSM_MultiSMSMessage sms; 250 GSM_MultiSMSMessage sms;
246 unsigned char buffer[100]; 251 unsigned char buffer[100];
247 GSM_Error error=ERR_NONE; 252 GSM_Error error=ERR_NONE;
248 INI_Entry *e; 253 INI_Entry *e;
249 int i; 254 int i;
250 255
251 start=true; 256 start=true;
252 while (error == ERR_NONE && !gshutdown) { 257 while (error == ERR_NONE && !gshutdown) {
253 sms.SMS[0].Folder=0x00; 258 sms.SMS[0].Folder=0x00;
254 error=Phone->GetNextSMS(&s, &sms, start); 259 error=Phone->GetNextSMS(&s, &sms, start);
255 switch (error) { 260 switch (error) {
256 case ERR_EMPTY: 261 case ERR_EMPTY:
257 break; 262 break;
258 case ERR_NONE: 263 case ERR_NONE:
259 /* Not Inbox SMS - exit */ 264 /* Not Inbox SMS - exit */
260 if (!sms.SMS[0].InboxFolder) break; 265 if (!sms.SMS[0].InboxFolder) break;
261 process=true; 266 process=true;
262 DecodeUnicode(sms.SMS[0].Number,buffer); 267 DecodeUnicode(sms.SMS[0].Number,buffer);
263 if (Config->IncludeNumbers != NULL) { 268 if (Config->IncludeNumbers != NULL) {
264 e=Config->IncludeNumbers; 269 e=Config->IncludeNumbers;
265 process=false; 270 process=false;
266 while (1) { 271 while (1) {
267 if (e == NULL) break; 272 if (e == NULL) break;
268 if (strcmp(buffer,e->EntryValue)==0) { 273 if (strcmp(buffer,e->EntryValue)==0) {
269 process=true; 274 process=true;
270 break; 275 break;
271 } 276 }
272 e = e->Prev; 277 e = e->Prev;
273 } 278 }
274 } else if (Config->ExcludeNumbers != NULL) { 279 } else if (Config->ExcludeNumbers != NULL) {
275 e=Config->ExcludeNumbers; 280 e=Config->ExcludeNumbers;
276 process=true; 281 process=true;
277 while (1) { 282 while (1) {
278 if (e == NULL) break; 283 if (e == NULL) break;
279 if (strcmp(buffer,e->EntryValue)==0) { 284 if (strcmp(buffer,e->EntryValue)==0) {
280 process=false; 285 process=false;
281 break; 286 break;
282 } 287 }
283 e = e->Prev; 288 e = e->Prev;
284 } 289 }
285 } 290 }
286 if (process) { 291 if (process) {
287 Service->SaveInboxSMS(sms, Config); 292 Service->SaveInboxSMS(sms, Config);
288 } else { 293 } else {
289 WriteSMSDLog("Excluded %s", buffer); 294 WriteSMSDLog("Excluded %s", buffer);
290 } 295 }
291 break; 296 break;
292 default: 297 default:
293 WriteSMSDLog("Error getting SMS (%i)", error); 298 WriteSMSDLog("Error getting SMS (%i)", error);
294 return false; 299 return false;
295 } 300 }
296 if (error == ERR_NONE && sms.SMS[0].InboxFolder) { 301 if (error == ERR_NONE && sms.SMS[0].InboxFolder) {
297 for (i=0;i<sms.Number;i++) { 302 for (i=0;i<sms.Number;i++) {
298 sms.SMS[i].Folder=0; 303 sms.SMS[i].Folder=0;
299 error=Phone->DeleteSMS(&s,&sms.SMS[i]); 304 error=Phone->DeleteSMS(&s,&sms.SMS[i]);
300 switch (error) { 305 switch (error) {
301 case ERR_NONE: 306 case ERR_NONE:
302 case ERR_EMPTY: 307 case ERR_EMPTY:
303 break; 308 break;
304 default: 309 default:
305 WriteSMSDLog("Error deleting SMS (%i)", error); 310 WriteSMSDLog("Error deleting SMS (%i)", error);
306 return false; 311 return false;
307 } 312 }
308 } 313 }
309 } 314 }
310 start=false; 315 start=false;
311 } 316 }
312 return true; 317 return true;
313} 318}
314 319
315bool SMSD_CheckSMSStatus(GSM_SMSDConfig *Config,GSM_SMSDService *Service) 320bool SMSD_CheckSMSStatus(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
316{ 321{
317 GSM_SMSMemoryStatusSMSStatus; 322 GSM_SMSMemoryStatusSMSStatus;
318 GSM_Error error; 323 GSM_Error error;
319 324
320 /* Do we have any SMS in phone ? */ 325 /* Do we have any SMS in phone ? */
321 error=Phone->GetSMSStatus(&s,&SMSStatus); 326 error=Phone->GetSMSStatus(&s,&SMSStatus);
322 if (error != ERR_NONE) { 327 if (error != ERR_NONE) {
323 WriteSMSDLog("Error getting SMS status (%i)", error); 328 WriteSMSDLog("Error getting SMS status (%i)", error);
324 return false; 329 return false;
325 } 330 }
326 /* Yes. We have SMS in phone */ 331 /* Yes. We have SMS in phone */
327 if (SMSStatus.SIMUsed+SMSStatus.PhoneUsed != 0) { 332 if (SMSStatus.SIMUsed+SMSStatus.PhoneUsed != 0) {
328 return SMSD_ReadDeleteSMS(Config,Service); 333 return SMSD_ReadDeleteSMS(Config,Service);
329 } 334 }
330 return true; 335 return true;
331} 336}
332 337
333bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service) 338bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
334{ 339{
335 GSM_MultiSMSMessage sms; 340 GSM_MultiSMSMessage sms;
336 GSM_DateTime Date; 341 GSM_DateTime Date;
337 GSM_Error error; 342 GSM_Error error;
338 unsigned int i, j, z; 343 unsigned int i, j, z;
339 344
340 error = Service->FindOutboxSMS(&sms, Config, Config->SMSID); 345 error = Service->FindOutboxSMS(&sms, Config, Config->SMSID);
341 346
342 if (error == ERR_EMPTY || error == ERR_NOTSUPPORTED) { 347 if (error == ERR_EMPTY || error == ERR_NOTSUPPORTED) {
343 /* No outbox sms - wait few seconds and escape */ 348 /* No outbox sms - wait few seconds and escape */
344 for (j=0;j<Config->commtimeout && !gshutdown;j++) { 349 for (j=0;j<Config->commtimeout && !gshutdown;j++) {
345 GSM_GetCurrentDateTime (&Date); 350 GSM_GetCurrentDateTime (&Date);
346 i=Date.Second; 351 i=Date.Second;
347 while (i==Date.Second && !gshutdown) { 352 while (i==Date.Second && !gshutdown) {
348 my_sleep(10); 353 my_sleep(10);
349 GSM_GetCurrentDateTime(&Date); 354 GSM_GetCurrentDateTime(&Date);
350 } 355 }
351 Service->RefreshPhoneStatus(Config); 356 Service->RefreshPhoneStatus(Config);
352 } 357 }
353 return true; 358 return true;
354 } 359 }
355 if (error != ERR_NONE) { 360 if (error != ERR_NONE) {
356 /* Unknown error - escape */ 361 /* Unknown error - escape */
357 WriteSMSDLog("Error in outbox on %s", Config->SMSID); 362 WriteSMSDLog("Error in outbox on %s", Config->SMSID);
358 for (i=0;i<sms.Number;i++) { 363 for (i=0;i<sms.Number;i++) {
359 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1); 364 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
360 } 365 }
361 Service->MoveSMS(&sms,Config, Config->SMSID, true,false); 366 Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
362 return false; 367 return false;
363 } 368 }
364 369
365 if (!gshutdown) { 370 if (!gshutdown) {
366 if (strcmp(Config->prevSMSID, Config->SMSID) == 0) { 371 if (strcmp(Config->prevSMSID, Config->SMSID) == 0) {
367 Config->retries++; 372 Config->retries++;
368 if (Config->retries > MAX_RETRIES) { 373 if (Config->retries > MAX_RETRIES) {
369 Config->retries = 0; 374 Config->retries = 0;
370 strcpy(Config->prevSMSID, ""); 375 strcpy(Config->prevSMSID, "");
371 WriteSMSDLog("Moved to errorbox: %s", Config->SMSID); 376 WriteSMSDLog("Moved to errorbox: %s", Config->SMSID);
372 for (i=0;i<sms.Number;i++) { 377 for (i=0;i<sms.Number;i++) {
373 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1); 378 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
374 } 379 }
375 Service->MoveSMS(&sms,Config, Config->SMSID, true,false); 380 Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
376 return false; 381 return false;
377 } 382 }
378 } else { 383 } else {
379 Config->retries = 0; 384 Config->retries = 0;
380 strcpy(Config->prevSMSID, Config->SMSID); 385 strcpy(Config->prevSMSID, Config->SMSID);
381 } 386 }
382 for (i=0;i<sms.Number;i++) { 387 for (i=0;i<sms.Number;i++) {
383 if (sms.SMS[i].SMSC.Location == 1) { 388 if (sms.SMS[i].SMSC.Location == 1) {
384 if (Config->SMSC.Location == 0) { 389 if (Config->SMSC.Location == 0) {
385 Config->SMSC.Location = 1; 390 Config->SMSC.Location = 1;
386 error = Phone->GetSMSC(&s,&Config->SMSC); 391 error = Phone->GetSMSC(&s,&Config->SMSC);
387 if (error!=ERR_NONE) { 392 if (error!=ERR_NONE) {
388 WriteSMSDLog("Error getting SMSC from phone"); 393 WriteSMSDLog("Error getting SMSC from phone");
389 return false; 394 return false;
390 } 395 }
391 396
392 } 397 }
393 memcpy(&sms.SMS[i].SMSC,&Config->SMSC,sizeof(GSM_SMSC)); 398 memcpy(&sms.SMS[i].SMSC,&Config->SMSC,sizeof(GSM_SMSC));
394 sms.SMS[i].SMSC.Location = 0; 399 sms.SMS[i].SMSC.Location = 0;
395 if (Config->relativevalidity != -1) { 400 if (Config->relativevalidity != -1) {
396 sms.SMS[i].SMSC.Validity.Format = SMS_Validity_RelativeFormat; 401 sms.SMS[i].SMSC.Validity.Format = SMS_Validity_RelativeFormat;
397 sms.SMS[i].SMSC.Validity.Relative = Config->relativevalidity; 402 sms.SMS[i].SMSC.Validity.Relative = Config->relativevalidity;
398 } 403 }
399 } 404 }
400 405
401 if (Config->currdeliveryreport == 1) { 406 if (Config->currdeliveryreport == 1) {
402 sms.SMS[i].PDU = SMS_Status_Report; 407 sms.SMS[i].PDU = SMS_Status_Report;
403 } else { 408 } else {
404 if ((strcmp(Config->deliveryreport, "no") != 0 && (Config->currdeliveryreport == -1))) sms.SMS[i].PDU = SMS_Status_Report; 409 if ((strcmp(Config->deliveryreport, "no") != 0 && (Config->currdeliveryreport == -1))) sms.SMS[i].PDU = SMS_Status_Report;
405 } 410 }
406 411
407 error=Phone->SendSMS(&s, &sms.SMS[i]); 412 error=Phone->SendSMS(&s, &sms.SMS[i]);
408 if (error!=ERR_NONE) { 413 if (error!=ERR_NONE) {
409 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, -1); 414 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, -1);
410 WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg)); 415 WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg));
411 return false; 416 return false;
412 } 417 }
413 Service->RefreshPhoneStatus(Config); 418 Service->RefreshPhoneStatus(Config);
414 j = 0; 419 j = 0;
415 TPMR = -1; 420 TPMR = -1;
416 SendingSMSStatus = ERR_TIMEOUT; 421 SendingSMSStatus = ERR_TIMEOUT;
417 while (!gshutdown) { 422 while (!gshutdown) {
418 GSM_GetCurrentDateTime (&Date); 423 GSM_GetCurrentDateTime (&Date);
419 z=Date.Second; 424 z=Date.Second;
420 while (z==Date.Second) { 425 while (z==Date.Second) {
421 my_sleep(10); 426 my_sleep(10);
422 GSM_GetCurrentDateTime(&Date); 427 GSM_GetCurrentDateTime(&Date);
423 GSM_ReadDevice(&s,true); 428 GSM_ReadDevice(&s,true);
424 if (SendingSMSStatus != ERR_TIMEOUT) break; 429 if (SendingSMSStatus != ERR_TIMEOUT) break;
425 } 430 }
426 Service->RefreshSendStatus(Config, Config->SMSID); 431 Service->RefreshSendStatus(Config, Config->SMSID);
427 Service->RefreshPhoneStatus(Config); 432 Service->RefreshPhoneStatus(Config);
428 if (SendingSMSStatus != ERR_TIMEOUT) break; 433 if (SendingSMSStatus != ERR_TIMEOUT) break;
429 j++; 434 j++;
430 if (j>Config->sendtimeout) break; 435 if (j>Config->sendtimeout) break;
431 } 436 }
432 if (SendingSMSStatus != ERR_NONE) { 437 if (SendingSMSStatus != ERR_NONE) {
433 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, TPMR); 438 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, TPMR);
434 WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg)); 439 WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg));
435 return false; 440 return false;
436 } 441 }
437 error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_OK, TPMR); 442 error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_OK, TPMR);
438 if (error!=ERR_NONE) { 443 if (error!=ERR_NONE) {
439 return false; 444 return false;
440 } 445 }
441 } 446 }
442 strcpy(Config->prevSMSID, ""); 447 strcpy(Config->prevSMSID, "");
443 if (Service->MoveSMS(&sms,Config, Config->SMSID, false, true) != ERR_NONE) { 448 if (Service->MoveSMS(&sms,Config, Config->SMSID, false, true) != ERR_NONE) {
444 Service->MoveSMS(&sms,Config, Config->SMSID, true, false); 449 Service->MoveSMS(&sms,Config, Config->SMSID, true, false);
445 } 450 }
446 } 451 }
447 return true; 452 return true;
448} 453}
449 454
450void SMSDaemon(int argc, char *argv[]) 455void SMSDaemon(int argc, char *argv[])
451{ 456{
452 int errors = 255, initerrors=0; 457 int errors = 255, initerrors=0;
453 GSM_SMSDService *Service; 458 GSM_SMSDService *Service;
454 GSM_Error error; 459 GSM_Error error;
455 time_t lastreceive, lastreset = 0; 460 time_t lastreceive, lastreset = 0;
456 GSM_SMSDConfig Config; 461 GSM_SMSDConfig Config;
457 462
458 if (!strcmp(argv[2],"FILES")) { 463 if (!strcmp(argv[2],"FILES")) {
459 Service = &SMSDFiles; 464 Service = &SMSDFiles;
460#ifdef HAVE_MYSQL_MYSQL_H 465#ifdef HAVE_MYSQL_MYSQL_H
461 } else if (!strcmp(argv[2],"MYSQL")) { 466 } else if (!strcmp(argv[2],"MYSQL")) {
462 Service = &SMSDMySQL; 467 Service = &SMSDMySQL;
463#endif 468#endif
464 } else { 469 } else {
465 fprintf(stderr,"Unknown service type (\"%s\")\n",argv[2]); 470 fprintf(stderr,"Unknown service type (\"%s\")\n",argv[2]);
466 exit(-1); 471 exit(-1);
467 } 472 }
468 473
469 SMSD_ReadConfig(argv[3], &Config, true, argv[2]); 474 SMSD_ReadConfig(argv[3], &Config, true, argv[2]);
470 475
471 error = Service->Init(&Config); 476 error = Service->Init(&Config);
472 if (error!=ERR_NONE) { 477 if (error!=ERR_NONE) {
473 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1); 478 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
474 } 479 }
475 480
476 signal(SIGINT, interrupt); 481 signal(SIGINT, interrupt);
477 signal(SIGTERM, interrupt); 482 signal(SIGTERM, interrupt);
478 fprintf(stderr,"Press Ctrl+C to stop the program ...\n"); 483 fprintf(stderr,"Press Ctrl+C to stop the program ...\n");
479 484
480 lastreceive = time(NULL); 485 lastreceive = time(NULL);
481 lastreset = time(NULL); 486 lastreset = time(NULL);
482 SendingSMSStatus = ERR_UNKNOWN; 487 SendingSMSStatus = ERR_UNKNOWN;
483 488
484 while (!gshutdown) { 489 while (!gshutdown) {
485 /* There were errors in communication - try to recover */ 490 /* There were errors in communication - try to recover */
486 if (errors > 2) { 491 if (errors > 2) {
487 if (errors != 255) { 492 if (errors != 255) {
488 WriteSMSDLog("Terminating communication (%i,%i)", error, errors); 493 WriteSMSDLog("Terminating communication (%i,%i)", error, errors);
489 error=GSM_TerminateConnection(&s); 494 error=GSM_TerminateConnection(&s);
490 } 495 }
491 if (initerrors++ > 3) my_sleep(30000); 496 if (initerrors++ > 3) my_sleep(30000);
492 WriteSMSDLog("Starting communication"); 497 WriteSMSDLog("Starting communication");
493 error=GSM_InitConnection(&s,2); 498 error=GSM_InitConnection(&s,2);
494 switch (error) { 499 switch (error) {
495 case ERR_NONE: 500 case ERR_NONE:
496 s.User.SendSMSStatus = SMSSendingSMSStatus; 501 s.User.SendSMSStatus = SMSSendingSMSStatus;
497 Phone = s.Phone.Functions; 502 Phone = s.Phone.Functions;
498 if (errors == 255) { 503 if (errors == 255) {
499 errors = 0; 504 errors = 0;
500 s.Phone.Data.IMEI[0] = 0; 505 s.Phone.Data.IMEI[0] = 0;
501 if (!(Phone->GetIMEI(&s))) { 506 if (!(Phone->GetIMEI(&s))) {
502 errors++; 507 errors++;
503 } else { 508 } else {
504 error = Service->InitAfterConnect(&Config); 509 error = Service->InitAfterConnect(&Config);
505 if (error!=ERR_NONE) { 510 if (error!=ERR_NONE) {
506 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1); 511 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
507 } 512 }
508 Phone->SetFastSMSSending(&s,true); 513 Phone->SetFastSMSSending(&s,true);
509 } 514 }
510 } else { 515 } else {
511 errors = 0; 516 errors = 0;
512 } 517 }
513 if (initerrors > 3 || initerrors < 0) { 518 if (initerrors > 3 || initerrors < 0) {
514 error=Phone->Reset(&s, false); /* soft reset */ 519 error=Phone->Reset(&s, false); /* soft reset */
515 WriteSMSDLog("Reset return code: %s (%i) ", error == ERR_NONE? "OK":"ERROR", error); 520 WriteSMSDLog("Reset return code: %s (%i) ", error == ERR_NONE? "OK":"ERROR", error);
516 lastreset = time(NULL); 521 lastreset = time(NULL);
517 my_sleep(5000); 522 my_sleep(5000);
518 } 523 }
519 /* Marcin Wiacek: FIXME. To check */ 524 /* Marcin Wiacek: FIXME. To check */
520 // di = s.di; 525 // di = s.di;
521 break; 526 break;
522 case ERR_DEVICEOPENERROR: 527 case ERR_DEVICEOPENERROR:
523 GSM_Terminate_SMSD("Can't open device (%i)", error, true, -1); 528 GSM_Terminate_SMSD("Can't open device (%i)", error, true, -1);
524 default: 529 default:
525 WriteSMSDLog("Error at init connection (%i)", error); 530 WriteSMSDLog("Error at init connection (%i)", error);
526 errors = 250; 531 errors = 250;
527 } 532 }
528 continue; 533 continue;
529 } 534 }
530 if ((difftime(time(NULL), lastreceive) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) { 535 if ((difftime(time(NULL), lastreceive) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
531 lastreceive = time(NULL); 536 lastreceive = time(NULL);
532 537
533 if (!SMSD_CheckSecurity(&Config)) { 538 if (!SMSD_CheckSecurity(&Config)) {
534 errors++; 539 errors++;
535 initerrors++; 540 initerrors++;
536 continue; 541 continue;
537 } else errors=0; 542 } else errors=0;
538 543
539 initerrors = 0; 544 initerrors = 0;
540 545
541 if (!SMSD_CheckSMSStatus(&Config,Service)) { /* read all incoming SMS */ 546 if (!SMSD_CheckSMSStatus(&Config,Service)) { /* read all incoming SMS */
542 errors++; 547 errors++;
543 continue; 548 continue;
544 } else errors=0; 549 } else errors=0;
545 550
546 if (Config.resetfrequency > 0 && difftime(time(NULL), lastreset) >= Config.resetfrequency) { /* time for preventive reset */ 551 if (Config.resetfrequency > 0 && difftime(time(NULL), lastreset) >= Config.resetfrequency) { /* time for preventive reset */
547 errors = 254; initerrors = -2; 552 errors = 254; initerrors = -2;
548 continue; 553 continue;
549 } 554 }
550 } 555 }
551 if (!SMSD_SendSMS(&Config,Service)) continue; 556 if (!SMSD_SendSMS(&Config,Service)) continue;
552 } 557 }
553 Phone->SetFastSMSSending(&s,false); 558 Phone->SetFastSMSSending(&s,false);
554 GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0); 559 GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0);
555} 560}
556 561
557GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms) 562GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms)
558{ 563{
559 GSM_SMSDService *Service; 564 GSM_SMSDService *Service;
560 GSM_SMSDConfig Config; 565 GSM_SMSDConfig Config;
561 566
562 if (!strcmp(service,"FILES")) { 567 if (!strcmp(service,"FILES")) {
563 Service = &SMSDFiles; 568 Service = &SMSDFiles;
564#ifdef HAVE_MYSQL_MYSQL_H 569#ifdef HAVE_MYSQL_MYSQL_H
565 } else if (!strcmp(service,"MYSQL")) { 570 } else if (!strcmp(service,"MYSQL")) {
566 Service = &SMSDMySQL; 571 Service = &SMSDMySQL;
567#endif 572#endif
568 } else { 573 } else {
569 fprintf(stderr,"Unknown service type (\"%s\")\n",service); 574 fprintf(stderr,"Unknown service type (\"%s\")\n",service);
570 exit(-1); 575 exit(-1);
571 } 576 }
572 577
573 SMSD_ReadConfig(filename, &Config, false, service); 578 SMSD_ReadConfig(filename, &Config, false, service);
574 579
575 error = Service->Init(&Config); 580 error = Service->Init(&Config);
576 if (error!=ERR_NONE) return ERR_UNKNOWN; 581 if (error!=ERR_NONE) return ERR_UNKNOWN;
577 582
578 return Service->CreateOutboxSMS(sms,&Config); 583 return Service->CreateOutboxSMS(sms,&Config);
579} 584}
580 585
581/* How should editor hadle tabs in this file? Add editor commands here. 586/* How should editor hadle tabs in this file? Add editor commands here.
582 * vim: noexpandtab sw=8 ts=8 sts=8: 587 * vim: noexpandtab sw=8 ts=8 sts=8:
583 */ 588 */