summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/cfg/config.h2
-rw-r--r--gammu/emb/common/common.pro1
-rw-r--r--gammu/emb/common/commonE.pro1
-rw-r--r--gammu/emb/common/device/bluetoth/bluez.c29
-rw-r--r--gammu/emb/common/device/devfunc.c12
-rw-r--r--gammu/emb/common/device/irda/irda.c8
-rw-r--r--gammu/emb/common/device/irda/irda_unx.h2
-rw-r--r--gammu/emb/common/device/serial/ser_djg.c10
-rw-r--r--gammu/emb/common/device/serial/ser_unx.c38
-rw-r--r--gammu/emb/common/device/serial/ser_w32.c6
-rw-r--r--gammu/emb/common/gsmcomon.c21
-rw-r--r--gammu/emb/common/gsmcomon.h3
-rw-r--r--gammu/emb/common/gsmstate.c74
-rw-r--r--gammu/emb/common/gsmstate.h31
-rw-r--r--gammu/emb/common/misc/coding/coding.c177
-rw-r--r--gammu/emb/common/misc/coding/coding.h27
-rw-r--r--gammu/emb/common/misc/coding/md5.c2
-rw-r--r--gammu/emb/common/misc/misc.c19
-rw-r--r--gammu/emb/common/misc/misc.h8
-rw-r--r--gammu/emb/common/phone/alcatel/alcatel.c298
-rw-r--r--gammu/emb/common/phone/at/atgen.c295
-rw-r--r--gammu/emb/common/phone/at/atgen.h8
-rw-r--r--gammu/emb/common/phone/at/samsung.c447
-rw-r--r--gammu/emb/common/phone/at/samsung.h16
-rw-r--r--gammu/emb/common/phone/at/siemens.c74
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c141
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.c16
-rw-r--r--gammu/emb/common/phone/nokia/dct3/dct3func.h2
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n6110.c17
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.c9
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n9210.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3320.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n3650.c3
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.c168
-rw-r--r--gammu/emb/common/phone/nokia/dct4/n6510.h2
-rw-r--r--gammu/emb/common/phone/nokia/nauto.c2
-rw-r--r--gammu/emb/common/phone/nokia/nfunc.c14
-rw-r--r--gammu/emb/common/phone/obex/obexgen.c3
-rw-r--r--gammu/emb/common/phone/obex/obexgen.h4
-rw-r--r--gammu/emb/common/phone/symbian/mroutgen.c3
-rw-r--r--gammu/emb/common/protocol/at/at.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.c6
-rw-r--r--gammu/emb/common/protocol/nokia/fbus2.h6
-rw-r--r--gammu/emb/common/protocol/nokia/mbus2.c2
-rw-r--r--gammu/emb/common/protocol/nokia/mbus2.h2
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.c5
-rw-r--r--gammu/emb/common/protocol/nokia/phonet.h5
-rw-r--r--gammu/emb/common/service/backup/backgen.h4
-rw-r--r--gammu/emb/common/service/backup/backtext.c229
-rw-r--r--gammu/emb/common/service/backup/gsmback.c36
-rw-r--r--gammu/emb/common/service/backup/gsmback.h2
-rw-r--r--gammu/emb/common/service/gsmcal.h2
-rw-r--r--gammu/emb/common/service/gsmdata.c124
-rw-r--r--gammu/emb/common/service/gsmdata.h2
-rw-r--r--gammu/emb/common/service/gsmlogo.c47
-rw-r--r--gammu/emb/common/service/gsmlogo.h28
-rw-r--r--gammu/emb/common/service/gsmmisc.h7
-rw-r--r--gammu/emb/common/service/gsmring.c45
-rw-r--r--gammu/emb/common/service/gsmring.h8
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.c5
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.h11
-rw-r--r--gammu/emb/common/service/sms/gsmsms.c5
-rw-r--r--gammu/emb/common/service/sms/gsmsms.h5
-rw-r--r--gammu/emb/gammu/depend/nokia/dct3.c6
-rw-r--r--gammu/emb/gammu/depend/nokia/dct4.c11
-rw-r--r--gammu/emb/gammu/depend/nokia/dct4.h13
-rw-r--r--gammu/emb/gammu/gammu.c662
-rw-r--r--gammu/emb/gammu/gammu.h8
-rw-r--r--gammu/emb/gammu/smsd/s_files.c81
-rw-r--r--gammu/emb/gammu/smsd/s_files.h2
-rw-r--r--gammu/emb/gammu/smsd/s_mysql.c608
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.c180
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.h37
-rw-r--r--libkcal/phoneformat.cpp4
74 files changed, 3210 insertions, 993 deletions
diff --git a/gammu/emb/cfg/config.h b/gammu/emb/cfg/config.h
index 1ba6365..62b4fcf 100644
--- a/gammu/emb/cfg/config.h
+++ b/gammu/emb/cfg/config.h
@@ -149,3 +149,3 @@
149# define HAVE_SYS_IOCTL_H 1 149# define HAVE_SYS_IOCTL_H 1
150# define HAVE_MYSQL_MYSQL_H 1 150//LR # define HAVE_MYSQL_MYSQL_H 1
151#endif 151#endif
diff --git a/gammu/emb/common/common.pro b/gammu/emb/common/common.pro
index 0e719ee..797199b 100644
--- a/gammu/emb/common/common.pro
+++ b/gammu/emb/common/common.pro
@@ -158,2 +158,3 @@ phone/at/atgen.c \
158phone/at/siemens.c \ 158phone/at/siemens.c \
159phone/at/samsung.c \
159phone/at/sonyeric.c \ 160phone/at/sonyeric.c \
diff --git a/gammu/emb/common/commonE.pro b/gammu/emb/common/commonE.pro
index a36947b..f5b559d 100644
--- a/gammu/emb/common/commonE.pro
+++ b/gammu/emb/common/commonE.pro
@@ -159,2 +159,3 @@ phone/at/atgen.c \
159phone/at/siemens.c \ 159phone/at/siemens.c \
160phone/at/samsung.c \
160phone/at/sonyeric.c \ 161phone/at/sonyeric.c \
diff --git a/gammu/emb/common/device/bluetoth/bluez.c b/gammu/emb/common/device/bluetoth/bluez.c
index 8a4807e..e7e8adf 100644
--- a/gammu/emb/common/device/bluetoth/bluez.c
+++ b/gammu/emb/common/device/bluetoth/bluez.c
@@ -1,2 +1,11 @@
1/* Based on work by Marcel Holtmann and other authors of Bluez */ 1/* Based on some work from Bluez (www.bluez.org)
2 * (C) 2000-2001 Qualcomm Incorporated
3 * (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
4 * (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
5 * GNU GPL version 2
6 */
7/* based on some Marcel Holtmann work from Gnokii (www.gnokii.org)
8 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
9 * GNU GPL version 2 or later
10 */
2 11
@@ -83,3 +92,3 @@ static void print_service_desc(void *value, void *user)
83 case SDP_UUID128: 92 case SDP_UUID128:
84 proto = 1;//sdp_uuid_to_proto(&p->val.uuid); 93 proto = sdp_uuid_to_proto(&p->val.uuid);
85 break; 94 break;
@@ -106,9 +115,9 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
106 sdp_session_t *sess; 115 sdp_session_t *sess;
107 sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
108 uint32_t range = 0x0000ffff;
109 char str[20];
110 sdp_record_t *rec; 116 sdp_record_t *rec;
117 sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
111 sdp_data_t *d; 118 sdp_data_t *d;
112 bdaddr_t interface; 119 bdaddr_t interface;
120 uint32_t range = 0x0000ffff;
113 struct search_context subcontext; 121 struct search_context subcontext;
122 char str[20];
114 int channel,channel2; 123 int channel,channel2;
@@ -144,6 +153,6 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
144 153
145 if (false) { 154 if (sdp_get_access_protos(rec,&proto) == 0) {
146 channel = -1; 155 channel = -1;
147 sdp_list_foreach(proto,print_access_protos,&channel); 156 sdp_list_foreach(proto,print_access_protos,&channel);
148 //sdp_list_free(proto,(sdp_free_func_t)sdp_data_free); 157 sdp_list_free(proto,(sdp_free_func_t)sdp_data_free);
149 } 158 }
@@ -164,3 +173,3 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
164 free(seq); 173 free(seq);
165 //sdp_record_free(rec); 174 sdp_record_free(rec);
166 } 175 }
@@ -170,3 +179,3 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
170 179
171 return ERR_UNKNOWN; 180 return ERR_NOTSUPPORTED;
172} 181}
@@ -182,3 +191,3 @@ GSM_Error bluetooth_findchannel(GSM_StateMachine *s)
182 memset(&context, '\0', sizeof(struct search_context)); 191 memset(&context, '\0', sizeof(struct search_context));
183 //sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP); 192 sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP);
184 193
diff --git a/gammu/emb/common/device/devfunc.c b/gammu/emb/common/device/devfunc.c
index d31ebbf..c58a01f 100644
--- a/gammu/emb/common/device/devfunc.c
+++ b/gammu/emb/common/device/devfunc.c
@@ -1 +1,9 @@
1/* Some source from Gnokii (www.gnokii.org)
2 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
3 * GNU GPL version 2 or later
4 */
5/* Some source from Minicom (http://alioth.debian.org/projects/minicom)
6 * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg
7 * GNU GPL version 2
8 */
1 9
@@ -107,3 +115,3 @@ GSM_Error lock_device(const char* port, char **lock_device)
107{ 115{
108#ifndef WIN32 116#if !defined(WIN32) && !defined(DJGPP)
109 char *lock_file = NULL; 117 char *lock_file = NULL;
@@ -220,3 +228,3 @@ bool unlock_device(char **lock_file)
220{ 228{
221#ifndef WIN32 229#if !defined(WIN32) && !defined(DJGPP)
222 int err; 230 int err;
diff --git a/gammu/emb/common/device/irda/irda.c b/gammu/emb/common/device/irda/irda.c
index fef50ac..e680377 100644
--- a/gammu/emb/common/device/irda/irda.c
+++ b/gammu/emb/common/device/irda/irda.c
@@ -1,4 +1,8 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Ralf Thelen and MyGnokii */ 2/* based on some work from Ralf Thelen and MyGnokii (www.mwiacek.com) */
3/* based on some work from Gnokii and MSDN */ 3/* based on some work from MSDN */
4/* based on some work from Gnokii (www.gnokii.org)
5 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
6 * GNU GPL version 2 or later
7 */
4 8
diff --git a/gammu/emb/common/device/irda/irda_unx.h b/gammu/emb/common/device/irda/irda_unx.h
index 8dbcb97..7a55273 100644
--- a/gammu/emb/common/device/irda/irda_unx.h
+++ b/gammu/emb/common/device/irda/irda_unx.h
@@ -1,2 +1,2 @@
1/* part of irda.h available in Linux kernel source */ 1/* part of irda.h available in Linux kernel source (www.kernel.org) */
2 2
diff --git a/gammu/emb/common/device/serial/ser_djg.c b/gammu/emb/common/device/serial/ser_djg.c
index ac9d7c8..2524187 100644
--- a/gammu/emb/common/device/serial/ser_djg.c
+++ b/gammu/emb/common/device/serial/ser_djg.c
@@ -13,3 +13,3 @@ static GSM_Error serial_close(GSM_StateMachine *s)
13 13
14 return ERR_NONE; 14 return ERR_NOTIMPLEMENTED;
15} 15}
@@ -20,3 +20,3 @@ static GSM_Error serial_open (GSM_StateMachine *s)
20 20
21 return ERR_NONE; 21 return ERR_NOTIMPLEMENTED;
22} 22}
@@ -27,3 +27,3 @@ static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
27 27
28 return ERR_NONE; 28 return ERR_NOTIMPLEMENTED;
29} 29}
@@ -34,3 +34,3 @@ static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
34 34
35 return ERR_NONE; 35 return ERR_NOTIMPLEMENTED;
36} 36}
@@ -41,3 +41,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
41 41
42 return ERR_NONE; 42 return ERR_NOTIMPLEMENTED;
43} 43}
diff --git a/gammu/emb/common/device/serial/ser_unx.c b/gammu/emb/common/device/serial/ser_unx.c
index 2a87b11..69c7515 100644
--- a/gammu/emb/common/device/serial/ser_unx.c
+++ b/gammu/emb/common/device/serial/ser_unx.c
@@ -2,2 +2,6 @@
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)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
@@ -18,2 +22,26 @@
18 22
23#ifndef O_NONBLOCK
24# define O_NONBLOCK 0
25#endif
26
27#ifdef __NetBSD__
28# define FNONBLOCK O_NONBLOCK
29
30# define B57600 0010001
31# define B115200 0010002
32# define B230400 0010003
33# define B460800 0010004
34# define B500000 0010005
35# define B576000 0010006
36# define B921600 0010007
37# define B1000000 0010010
38# define B1152000 0010011
39# define B1500000 0010012
40# define B2000000 0010013
41# define B2500000 0010014
42# define B3000000 0010015
43# define B3500000 0010016
44# define B4000000 0010017
45#endif
46
19static GSM_Error serial_close(GSM_StateMachine *s) 47static GSM_Error serial_close(GSM_StateMachine *s)
@@ -31,6 +59,2 @@ static GSM_Error serial_close(GSM_StateMachine *s)
31 59
32#ifndef O_NONBLOCK
33# define O_NONBLOCK 0
34#endif
35
36static GSM_Error serial_open (GSM_StateMachine *s) 60static GSM_Error serial_open (GSM_StateMachine *s)
@@ -179,3 +203,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
179 struct termios t; 203 struct termios t;
180 int speed2 = B19200; 204 int speed2 = B19200;
181 205
@@ -204,2 +228,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
204 case 38400: speed2 = B38400;break; 228 case 38400: speed2 = B38400;break;
229#ifdef B57600
205 case 57600: speed2 = B57600;break; 230 case 57600: speed2 = B57600;break;
@@ -208,2 +233,3 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
208 case 460800: speed2 = B460800;break; 233 case 460800: speed2 = B460800;break;
234#ifdef B500000
209 case 500000: speed2 = B500000;break; 235 case 500000: speed2 = B500000;break;
@@ -219,2 +245,4 @@ static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
219 case 4000000: speed2 = B4000000; break; 245 case 4000000: speed2 = B4000000; break;
246#endif
247#endif
220 } 248 }
diff --git a/gammu/emb/common/device/serial/ser_w32.c b/gammu/emb/common/device/serial/ser_w32.c
index 9fa0135..7d88fc7 100644
--- a/gammu/emb/common/device/serial/ser_w32.c
+++ b/gammu/emb/common/device/serial/ser_w32.c
@@ -1,3 +1,7 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* based on some work from Gnokii, MSDN and others */ 2/* based on some work from MSDN and others */
3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
diff --git a/gammu/emb/common/gsmcomon.c b/gammu/emb/common/gsmcomon.c
index d094ef3..445c3a6 100644
--- a/gammu/emb/common/gsmcomon.c
+++ b/gammu/emb/common/gsmcomon.c
@@ -123,3 +123,3 @@ static PrintErrorEntry PrintErrorEntries[] = {
123 {ERR_DEVICELOCKED, "Error opening device. Device locked."}, 123 {ERR_DEVICELOCKED, "Error opening device. Device locked."},
124 {ERR_DEVICENOTEXIST, "Error opening device. Not exist."}, 124 {ERR_DEVICENOTEXIST, "Error opening device. Doesn't exist."},
125 {ERR_DEVICEBUSY, "Error opening device. Already opened by other application."}, 125 {ERR_DEVICEBUSY, "Error opening device. Already opened by other application."},
@@ -131,4 +131,4 @@ static PrintErrorEntry PrintErrorEntries[] = {
131 {ERR_DEVICEWRITEERROR, "Error writing device."}, 131 {ERR_DEVICEWRITEERROR, "Error writing device."},
132 {ERR_DEVICEREADERROR, "Error during reading device"}, 132 {ERR_DEVICEREADERROR, "Error during reading device."},
133 {ERR_DEVICEPARITYERROR, "Can't set parity on device"}, 133 {ERR_DEVICEPARITYERROR, "Can't set parity on device."},
134 {ERR_TIMEOUT, "No response in specified timeout. Probably phone not connected."}, 134 {ERR_TIMEOUT, "No response in specified timeout. Probably phone not connected."},
@@ -151,15 +151,16 @@ static PrintErrorEntry PrintErrorEntries[] = {
151 {ERR_PERMISSION, "Permission to file/device required..."}, 151 {ERR_PERMISSION, "Permission to file/device required..."},
152 {ERR_EMPTYSMSC, "Empty SMSC number. Set in phone or use -smscnumber"}, 152 {ERR_EMPTYSMSC, "Empty SMSC number. Set in phone or use -smscnumber."},
153 {ERR_INSIDEPHONEMENU, "You're inside phone menu (during editing ?). Leave it and try again."}, 153 {ERR_INSIDEPHONEMENU, "You're inside phone menu (during editing ?). Leave it and try again."},
154 {ERR_WORKINPROGRESS, "Function is during writing. If want help, please contact with authors."}, 154 {ERR_WORKINPROGRESS, "Function is during writing. If want help, please contact with authors."},
155 {ERR_PHONEOFF, "Phone is disabled and connected to charger"}, 155 {ERR_PHONEOFF, "Phone is disabled and connected to charger."},
156 {ERR_FILENOTSUPPORTED, "File format not supported by Gammu"}, 156 {ERR_FILENOTSUPPORTED, "File format not supported by Gammu."},
157 {ERR_BUG, "Nobody is perfect, some bug appeared in protocol implementation. Please contact authors."}, 157 {ERR_BUG, "Nobody is perfect, some bug appeared in protocol implementation. Please contact authors."},
158 {ERR_CANCELED, "Transfer was canceled by phone (you pressed cancel on phone?)."}, 158 {ERR_CANCELED, "Transfer was canceled by phone (you pressed cancel on phone?)"},
159 /* Some missed */ 159 /* Some missed */
160 {ERR_OTHERCONNECTIONREQUIRED,"Current connection type doesn't support called function."}, 160 {ERR_OTHERCONNECTIONREQUIRED,"Current connection type doesn't support called function."},
161 /* Some missed */ 161 {ERR_WRONGCRC, "CRC error."},
162 {ERR_INVALIDDATETIME, "Invalid date or time specified."}, 162 {ERR_INVALIDDATETIME, "Invalid date or time specified."},
163 {ERR_MEMORY, "Phone memory error, maybe it is read only"}, 163 {ERR_MEMORY, "Phone memory error, maybe it is read only."},
164 {ERR_INVALIDDATA, "Invalid data"}, 164 {ERR_INVALIDDATA, "Invalid data."},
165 {ERR_FILEALREADYEXIST, "File with specified name already exist."},
165 166
diff --git a/gammu/emb/common/gsmcomon.h b/gammu/emb/common/gsmcomon.h
index cd36708..e067955 100644
--- a/gammu/emb/common/gsmcomon.h
+++ b/gammu/emb/common/gsmcomon.h
@@ -68,3 +68,4 @@ typedef enum {
68 ERR_MEMORY, /* Phone memory error, maybe it is read only */ 68 ERR_MEMORY, /* Phone memory error, maybe it is read only */
69 ERR_INVALIDDATA /* Invalid data */ 69 ERR_INVALIDDATA, /* Invalid data */
70 ERR_FILEALREADYEXIST /* File with specified name already exist */
70} GSM_Error; 71} GSM_Error;
diff --git a/gammu/emb/common/gsmstate.c b/gammu/emb/common/gsmstate.c
index b8f5f89..31e365d 100644
--- a/gammu/emb/common/gsmstate.c
+++ b/gammu/emb/common/gsmstate.c
@@ -188,2 +188,5 @@ GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s)
188#endif 188#endif
189#ifdef GSM_ENABLE_NOKIA650
190 GSM_RegisterModule(s,&N650Phone);
191#endif
189#ifdef GSM_ENABLE_NOKIA6110 192#ifdef GSM_ENABLE_NOKIA6110
@@ -212,3 +215,2 @@ GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
212 int i; 215 int i;
213 char Buffer[80];
214 216
@@ -252,14 +254,12 @@ GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
252 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) {
253 smprintf(s,"[Gammu - version %s built %s %s]\n",VERSION,__TIME__,__DATE__); 255 smprintf(s,"[Gammu - %s built %s %s",VERSION,__TIME__,__DATE__);
254 smprintf(s,"[Connection - \"%s\"]\n",s->CurrentConfig->Connection); 256 if (strlen(GetCompiler()) != 0) {
257 smprintf(s," in %s",GetCompiler());
258 }
259 smprintf(s,"]\n[Connection - \"%s\"]\n",s->CurrentConfig->Connection);
255 smprintf(s,"[Model type - \"%s\"]\n",s->CurrentConfig->Model); 260 smprintf(s,"[Model type - \"%s\"]\n",s->CurrentConfig->Model);
256 smprintf(s,"[Device - \"%s\"]\n",s->CurrentConfig->Device); 261 smprintf(s,"[Device - \"%s\"]\n",s->CurrentConfig->Device);
257 262 if (strlen(GetOS()) != 0) {
258 Buffer[0] = 0; 263 smprintf(s,"[Run on - %s]\n",GetOS());
259 if (strlen(GetOS()) != 0) sprintf(Buffer,"%s",GetOS());
260 if (strlen(GetCompiler()) != 0) {
261 if (Buffer[0] != 0) strcat(Buffer+strlen(Buffer),", ");
262 strcat(Buffer+strlen(Buffer),GetCompiler());
263 } 264 }
264 if (Buffer[0] != 0) smprintf(s,"[OS/compiler - %s]\n",Buffer);
265 } 265 }
@@ -556,2 +556,3 @@ static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Re
556 int i = 0; 556 int i = 0;
557 //int j;
557 558
@@ -570,4 +571,14 @@ static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Re
570 } else { 571 } else {
571 if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) { 572 // printf("msg length %i %i\n",strlen(Reply[i].msgtype),msg->Length);
572 execute=true; 573 if ((int)strlen(Reply[i].msgtype)<msg->Length) {
574 // printf("Comparing \"%s\" and \"",Reply[i].msgtype);
575 // for (j=0;j<strlen(Reply[i].msgtype);j++) {
576 // if (msg->Buffer[j]!=13 && msg->Buffer[j]!=10) {
577 // printf("%c",msg->Buffer[j]);
578 // }
579 // }
580 // printf("\"\n");
581 if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) {
582 execute=true;
583 }
573 } 584 }
@@ -847,4 +858,7 @@ bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num)
847static OnePhoneModel allmodels[] = { 858static OnePhoneModel allmodels[] = {
859#ifdef GSM_ENABLE_NOKIA650
860 {"0650" ,"THF-12","", {0}},
861#endif
848#ifdef GSM_ENABLE_NOKIA6510 862#ifdef GSM_ENABLE_NOKIA6510
849 {"1100", "RH-18" ,"", {0}}, 863 {"1100" ,"RH-18" ,"", {0}},
850 {"1100a","RH-38" ,"", {0}}, 864 {"1100a","RH-38" ,"", {0}},
@@ -856,7 +870,7 @@ static OnePhoneModel allmodels[] = {
856#ifdef GSM_ENABLE_NOKIA6510 870#ifdef GSM_ENABLE_NOKIA6510
857 {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}}, 871 {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
858 {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}}, 872 {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
859 {"3108", "RH-6", "Nokia 3108",{0}}, //does it have irda ? 873 {"3108", "RH-6", "Nokia 3108",{0}}, //does it have irda ?
860 {"3200", "RH-30" ,"Nokia 3200",{F_PBKTONEGAL,0}}, 874 {"3200", "RH-30" ,"Nokia 3200",{F_PBKTONEGAL,0}},//fixme
861 {"3200a","RH-31" ,"Nokia 3200",{F_PBKTONEGAL,0}}, 875 {"3200a","RH-31" ,"Nokia 3200",{F_PBKTONEGAL,0}},//fixme
862#endif 876#endif
@@ -867,4 +881,4 @@ static OnePhoneModel allmodels[] = {
867#ifdef GSM_ENABLE_NOKIA6510 881#ifdef GSM_ENABLE_NOKIA6510
868 {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}}, 882 {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
869 {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}}, 883 {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
870#endif 884#endif
@@ -900,2 +914,4 @@ static OnePhoneModel allmodels[] = {
900 {"5100" ,"NPM-6X","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 914 {"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-5" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
901#endif 917#endif
@@ -924,3 +940,3 @@ static OnePhoneModel allmodels[] = {
924 {"6200" ,"NPL-3" ,"Nokia 6200", {F_PBKTONEGAL,0}}, 940 {"6200" ,"NPL-3" ,"Nokia 6200", {F_PBKTONEGAL,0}},
925 {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,0}}, 941 {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
926#endif 942#endif
@@ -931,3 +947,3 @@ static OnePhoneModel allmodels[] = {
931#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 947#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
932 {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}}, 948 {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
933 {"6310" ,"NPE-4" ,"Nokia 6310", {F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}}, 949 {"6310" ,"NPE-4" ,"Nokia 6310", {F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
@@ -937,4 +953,7 @@ static OnePhoneModel allmodels[] = {
937 {"6610" ,"NHL-4U","Nokia 6610", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 953 {"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}},
938 {"6800" ,"NSB-9" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}}, 955 {"6800" ,"NSB-9" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
939 {"6800" ,"NHL-6" ,"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 {"6810" ,"RM-2" ,"Nokia 6810", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess
958 {"6820" ,"NHL-9" ,"Nokia 6820", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess
940#endif 959#endif
@@ -945,2 +964,3 @@ static OnePhoneModel allmodels[] = {
945#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 964#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
946 {"7210" ,"NHL-4" ,"Nokia 7210", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 966 {"7210" ,"NHL-4" ,"Nokia 7210", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
@@ -977,4 +997,6 @@ static OnePhoneModel allmodels[] = {
977 {"at" , "at", "", {0}}, 997 {"at" , "at", "", {0}},
998 /* Siemens */
978 {"M20" , "M20", "", {F_M20SMS,F_SLOWWRITE,0}}, 999 {"M20" , "M20", "", {F_M20SMS,F_SLOWWRITE,0}},
979 {"MC35" , "MC35", "", {0}}, 1000 {"MC35" , "MC35", "", {0}},
1001 {"TC35" , "TC35", "", {0}},
980 {"S25", "S25", "SIEMENS S25", {0}}, 1002 {"S25", "S25", "SIEMENS S25", {0}},
@@ -993,2 +1015,11 @@ static OnePhoneModel allmodels[] = {
993 {"S55" , "S55" , "", {0}}, 1015 {"S55" , "S55" , "", {0}},
1016 /* Samsung */
1017 {"S100" , "SGH-S100" , "", {0}},
1018 {"S200" , "SGH-S200" , "", {0}},
1019 {"S300" , "SGH-S300" , "", {0}},
1020 {"S500" , "SGH-S500" , "", {0}},
1021 {"V200" , "SGH-V200" , "", {0}},
1022 {"T100" , "SGH-T100" , "", {0}},
1023 {"E700" , "SGH-E700" , "", {0}},
1024 /* Ericsson/Sony Ericsson */
994 {"T28s", "1101101-BVT28s","", {0}}, 1025 {"T28s", "1101101-BVT28s","", {0}},
@@ -1006,2 +1037,3 @@ static OnePhoneModel allmodels[] = {
1006 {"P800", "7130501-BVP800" ,"", {0}}, 1037 {"P800", "7130501-BVP800" ,"", {0}},
1038 /* Other */
1007 {"iPAQ" , "iPAQ" , "" , {0}}, 1039 {"iPAQ" , "iPAQ" , "" , {0}},
diff --git a/gammu/emb/common/gsmstate.h b/gammu/emb/common/gsmstate.h
index cb17623..2b4806c 100644
--- a/gammu/emb/common/gsmstate.h
+++ b/gammu/emb/common/gsmstate.h
@@ -10,2 +10,7 @@
10 10
11 typedef struct _GSM_StateMachine GSM_StateMachine;
12 typedef struct _GSM_User GSM_User;
13 typedef struct _OnePhoneModel OnePhoneModel;
14 typedef struct _GSM_Reply_FunctionGSM_Reply_Function;
15
11#ifdef GSM_ENABLE_NOKIA3320 16#ifdef GSM_ENABLE_NOKIA3320
@@ -16,2 +21,5 @@
16#endif 21#endif
22#ifdef GSM_ENABLE_NOKIA650
23# include "phone/nokia/dct3/n0650.h"
24#endif
17#ifdef GSM_ENABLE_NOKIA6110 25#ifdef GSM_ENABLE_NOKIA6110
@@ -96,3 +104,3 @@
96 104
97#if defined(GSM_ENABLE_NOKIA3320) || 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)
98# define GSM_ENABLE_NOKIA_DCT3 106# define GSM_ENABLE_NOKIA_DCT3
@@ -201,5 +209,2 @@
201 209
202typedef struct _GSM_StateMachine GSM_StateMachine;
203 typedef struct _GSM_User GSM_User;
204 typedef struct _OnePhoneModel OnePhoneModel;
205 210
@@ -373,2 +378,4 @@ typedef enum {
373 ID_SetOBEX, 378 ID_SetOBEX,
379 ID_SetUSSD,
380 ID_GetNote,
374 ID_GetSignalQuality, 381 ID_GetSignalQuality,
@@ -440,2 +447,3 @@ typedef enum {
440 ID_GetLanguage, 447 ID_GetLanguage,
448 ID_SetFastSMSSending,
441 ID_Reset, 449 ID_Reset,
@@ -671,2 +679,3 @@ typedef struct {
671 GSM_ToDoEntry *ToDo; 679 GSM_ToDoEntry *ToDo;
680 GSM_NoteEntry *Note;
672 /** 681 /**
@@ -772,2 +781,5 @@ typedef struct {
772#endif 781#endif
782#ifdef GSM_ENABLE_NOKIA650
783 GSM_Phone_N650Data N650;
784#endif
773#ifdef GSM_ENABLE_NOKIA6110 785#ifdef GSM_ENABLE_NOKIA6110
@@ -806,3 +818,3 @@ typedef struct {
806 */ 818 */
807typedef struct { 819struct _GSM_Reply_Function {
808 /** 820 /**
@@ -830,3 +842,3 @@ typedef struct {
830 GSM_Phone_RequestIDrequestID; 842 GSM_Phone_RequestIDrequestID;
831} GSM_Reply_Function; 843};
832 844
@@ -1061,2 +1073,3 @@ typedef struct {
1061 GSM_Error (*SendSavedSMS)(GSM_StateMachine *s, int Folder, int Location); 1073 GSM_Error (*SendSavedSMS)(GSM_StateMachine *s, int Folder, int Location);
1074 GSM_Error (*SetFastSMSSending) (GSM_StateMachine *s, bool enable);
1062 /** 1075 /**
@@ -1281,3 +1294,3 @@ typedef struct {
1281 */ 1294 */
1282 GSM_Error (*GetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh); 1295 GSM_Error (*GetNextNote)(GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh);
1283 /** 1296 /**
@@ -1346,2 +1359,5 @@ typedef struct {
1346#endif 1359#endif
1360#ifdef GSM_ENABLE_NOKIA650
1361 extern GSM_Phone_Functions N650Phone;
1362#endif
1347#ifdef GSM_ENABLE_NOKIA6510 1363#ifdef GSM_ENABLE_NOKIA6510
@@ -1525,2 +1541,3 @@ typedef enum {
1525 F_CAL62, /* Calendar,6210 style - Call,Birthday,Memo,Meeting */ 1541 F_CAL62, /* Calendar,6210 style - Call,Birthday,Memo,Meeting */
1542 F_NOTES,
1526 1543
diff --git a/gammu/emb/common/misc/coding/coding.c b/gammu/emb/common/misc/coding/coding.c
index 62543ac..b30b645 100644
--- a/gammu/emb/common/misc/coding/coding.c
+++ b/gammu/emb/common/misc/coding/coding.c
@@ -1,3 +1,7 @@
1/* (c) 2002-2004 by Marcin Wiacek, Michal Cihar and others */ 1/* (c) 2002-2004 by Marcin Wiacek, Michal Cihar and others */
2/* based on some work from MyGnokii and Gnokii */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
@@ -18,2 +22,151 @@
18 22
23/* function changes #10 #13 chars to \n \r */
24char *EncodeUnicodeSpecialChars(unsigned char *buffer)
25{
26 int Pos=0, Pos2=0;
27 static unsigned charBuf[20000];
28
29 while (buffer[Pos*2]!=0x00 || buffer[Pos*2+1]!=0x00) {
30 if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 10) {
31 Buf[Pos2*2] = 0x00;
32 Buf[Pos2*2+1] = '\\';
33 Pos2++;
34 Buf[Pos2*2] = 0x00;
35 Buf[Pos2*2+1] = 'n';
36 Pos2++;
37 } else if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 13) {
38 Buf[Pos2*2] = 0x00;
39 Buf[Pos2*2+1] = '\\';
40 Pos2++;
41 Buf[Pos2*2] = 0x00;
42 Buf[Pos2*2+1] = 'r';
43 Pos2++;
44 } else if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
45 Buf[Pos2*2] = 0x00;
46 Buf[Pos2*2+1] = '\\';
47 Pos2++;
48 Buf[Pos2*2] = 0x00;
49 Buf[Pos2*2+1] = '\\';
50 Pos2++;
51 } else {
52 Buf[Pos2*2] = buffer[Pos*2];
53 Buf[Pos2*2+1] = buffer[Pos*2+1];
54 Pos2++;
55 }
56 Pos++;
57 }
58 Buf[Pos2*2] = 0;
59 Buf[Pos2*2+1] = 0;
60 return Buf;
61}
62
63/* function changes #10 #13 chars to \n \r */
64char *EncodeSpecialChars(unsigned char *buffer)
65{
66 int Pos=0, Pos2=0;
67 static unsigned charBuf[10000];
68
69 while (buffer[Pos]!=0x00) {
70 switch (buffer[Pos]) {
71 case 10:
72 Buf[Pos2++] = '\\';
73 Buf[Pos2++] = 'n';
74 break;
75 case 13:
76 Buf[Pos2++] = '\\';
77 Buf[Pos2++] = 'r';
78 break;
79 case '\\':
80 Buf[Pos2++] = '\\';
81 Buf[Pos2++] = '\\';
82 break;
83 default:
84 Buf[Pos2++] = buffer[Pos];
85 }
86 Pos++;
87 }
88 Buf[Pos2] = 0;
89 return Buf;
90}
91
92char *DecodeUnicodeSpecialChars(unsigned char *buffer)
93{
94 int Pos=0, Pos2=0, level=0;
95 static unsigned charBuf[10000];
96
97 while (buffer[Pos*2]!=0x00 || buffer[Pos*2+1]!=0x00) {
98 Buf[Pos2*2] = buffer[Pos*2];
99 Buf[Pos2*2+1] = buffer[Pos*2+1];
100 switch (level) {
101 case 0:
102 if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
103 level = 1;
104 } else {
105 Pos2++;
106 }
107 break;
108 case 1:
109 if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 'n') {
110 Buf[Pos2*2] = 0;
111 Buf[Pos2*2+1] = 10;
112 }
113 if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 'r') {
114 Buf[Pos2*2] = 0;
115 Buf[Pos2*2+1] = 13;
116 }
117 if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
118 Buf[Pos2*2] = 0;
119 Buf[Pos2*2+1] = '\\';
120 }
121 Pos2++;
122 level = 0;
123 }
124 Pos++;
125 }
126 Buf[Pos2*2] = 0;
127 Buf[Pos2*2+1] = 0;
128 return Buf;
129}
130
131char *DecodeSpecialChars(unsigned char *buffer)
132{
133 int Pos=0, Pos2=0, level=0;
134 static unsigned charBuf[10000];
135
136 while (buffer[Pos]!=0x00) {
137 Buf[Pos2] = buffer[Pos];
138 switch (level) {
139 case 0:
140 if (buffer[Pos] == '\\') {
141 level = 1;
142 } else {
143 Pos2++;
144 }
145 break;
146 case 1:
147 if (buffer[Pos] == 'n') Buf[Pos2] = 10;
148 if (buffer[Pos] == 'r') Buf[Pos2] = 13;
149 if (buffer[Pos] == '\\') Buf[Pos2] = '\\';
150 Pos2++;
151 level = 0;
152 }
153 Pos++;
154 }
155 Buf[Pos2] = 0;
156 return Buf;
157}
158
159char *mystrcasestr(unsigned const char *a, unsigned const char *b)
160{
161 unsigned char A[2000], B[200];
162 int i;
163
164 memset(A,0,sizeof(A));
165 memset(B,0,sizeof(B));
166 for (i=0;i<(int)strlen(a);i++) A[i] = tolower(a[i]);
167 for (i=0;i<(int)strlen(b);i++) B[i] = tolower(b[i]);
168
169 return strstr(A,B);
170}
171
19unsigned int UnicodeLength(const unsigned char *str) 172unsigned int UnicodeLength(const unsigned char *str)
@@ -588,4 +741,4 @@ void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, boo
588 741
589 switch (Number[1]) { 742 switch ((Number[1] & 112)) {
590 case NUMBER_ALPHANUMERIC: 743 case (NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN & 112):
591 if (length > 6) length++; 744 if (length > 6) length++;
@@ -595,3 +748,3 @@ void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, boo
595 break; 748 break;
596 case NUMBER_INTERNATIONAL: 749 case (NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN & 112):
597 dbgprintf("International number\n"); 750 dbgprintf("International number\n");
@@ -633,3 +786,3 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
633 /* Checking for format number */ 786 /* Checking for format number */
634 format = NUMBER_UNKNOWN; 787 format = NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN;
635 for (i=0;i<length;i++) { 788 for (i=0;i<length;i++) {
@@ -637,6 +790,6 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
637 if (i==0 && buffer[i]=='+') { 790 if (i==0 && buffer[i]=='+') {
638 format=NUMBER_INTERNATIONAL; 791 format=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN;
639 } else { 792 } else {
640 /*char is not number. It must be alphanumeric*/ 793 /*char is not number. It must be alphanumeric*/
641 if (!isdigit(buffer[i])) format=NUMBER_ALPHANUMERIC; 794 if (!isdigit(buffer[i])) format=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN;
642 } 795 }
@@ -652,3 +805,3 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
652 switch (format) { 805 switch (format) {
653 case NUMBER_ALPHANUMERIC: 806 case NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN:
654 length=GSM_PackSevenBitsToEight(0, buffer, Output+1, strlen(buffer))*2; 807 length=GSM_PackSevenBitsToEight(0, buffer, Output+1, strlen(buffer))*2;
@@ -656,3 +809,3 @@ int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool s
656 break; 809 break;
657 case NUMBER_INTERNATIONAL: 810 case NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN:
658 length--; 811 length--;
@@ -921,3 +1074,3 @@ bool mystrncasecmp(unsigned const char *a, unsigned const char *b, int num)
921 1074
922 num--; 1075 if (num == 0) num = -1;
923 1076
@@ -941,3 +1094,3 @@ bool mywstrncasecmp(unsigned const char *a, unsigned const char *b, int num)
941 1094
942 num--; 1095 if (num == 0) num = -1;
943 1096
@@ -1017,3 +1170,3 @@ int mytowlower(wchar_t c)
1017 1170
1018unsigned char *mystrstr (const unsigned char *haystack, const unsigned char *needle) 1171unsigned char *mywstrstr (const unsigned char *haystack, const unsigned char *needle)
1019{ 1172{
diff --git a/gammu/emb/common/misc/coding/coding.h b/gammu/emb/common/misc/coding/coding.h
index d0c334d..4cf0038 100644
--- a/gammu/emb/common/misc/coding/coding.h
+++ b/gammu/emb/common/misc/coding/coding.h
@@ -5,2 +5,6 @@
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include <stdlib.h> 10#include <stdlib.h>
@@ -15,3 +19,3 @@ typedef int wint_t;
15 bool mywstrncasecmp (unsigned const char *a, unsigned const char *b, int num); 19 bool mywstrncasecmp (unsigned const char *a, unsigned const char *b, int num);
16 unsigned char *mystrstr (unsigned const char *haystack, unsigned const char *needle); 20 unsigned char *mywstrstr (unsigned const char *haystack, unsigned const char *needle);
17 bool mywstrncmp (unsigned const char *a, unsigned const char *b, int num); 21 bool mywstrncmp (unsigned const char *a, unsigned const char *b, int num);
@@ -37,2 +41,5 @@ void EncodeUnicodeSpecialNOKIAChars (unsigned char *dest, const unsigned char
37 41
42 char *EncodeUnicodeSpecialChars(unsigned char *buffer);
43 char *DecodeUnicodeSpecialChars(unsigned char *buffer);
44
38/* ------------------------------- BCD ------------------------------------- */ 45/* ------------------------------- BCD ------------------------------------- */
@@ -88,3 +95,3 @@ typedef enum {
88 */ 95 */
89 NUMBER_UNKNOWN = 0x81, 96 NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN = 0x81,
90 /** 97 /**
@@ -92,3 +99,3 @@ typedef enum {
92 */ 99 */
93 NUMBER_INTERNATIONAL= 0x91, 100 NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN= 0x91,
94 /** 101 /**
@@ -96,3 +103,3 @@ typedef enum {
96 */ 103 */
97 NUMBER_ALPHANUMERIC= 0xD0 104 NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN= 0xD0
98 105
@@ -124,5 +131,13 @@ void StringToDouble (char *text, double *d);
124 131
125bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num); 132 bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num);
133 char *mystrcasestr (unsigned const char *a, unsigned const char *b);
126 134
127void MyGetLine(unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen); 135 void MyGetLine (unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen);
136
137char *EncodeSpecialChars(unsigned char *buffer);
138char *DecodeSpecialChars(unsigned char *buffer);
139
140#if defined(_MSC_VER) && defined(__cplusplus)
141 }
142#endif
128 143
diff --git a/gammu/emb/common/misc/coding/md5.c b/gammu/emb/common/misc/coding/md5.c
index 30fe33f..abb61be 100644
--- a/gammu/emb/common/misc/coding/md5.c
+++ b/gammu/emb/common/misc/coding/md5.c
@@ -1,2 +1,2 @@
1/* Taken from ReHash (see http://www.reichlsoft.de.vu/) and released 1/* Taken from ReHash (www.reichlsoft.de.vu) and released
2 * under GPL/LGPL with permission from ReHash author 2 * under GPL/LGPL with permission from ReHash author
diff --git a/gammu/emb/common/misc/misc.c b/gammu/emb/common/misc/misc.c
index c2f09e4..7227e7b 100644
--- a/gammu/emb/common/misc/misc.c
+++ b/gammu/emb/common/misc/misc.c
@@ -13,2 +13,5 @@
13#endif 13#endif
14#if defined(linux) || defined(__linux) || defined(__linux__)
15# include <sys/utsname.h>
16#endif
14 17
@@ -232,7 +235,9 @@ char *OSDate (GSM_DateTime dt)
232bool CheckDate(GSM_DateTime *date) 235bool CheckDate(GSM_DateTime *date)
233{ 236 {
234 /* FIXME: This could also check if day is correct for selected month */ 237 const unsigned int days[]={31,29,31,30,31,30,31,31,30,31,30,31};
238
239 /* FIXME: This could also check for leap years */
235 return date->Year != 0 && 240 return date->Year != 0 &&
236 date->Month >= 1 && date->Month <= 12 && 241 date->Month >= 1 && date->Month <= 12 &&
237 date->Day >= 1 && date->Day <= 31; 242 date->Day >= 1 && date->Day <= days[date->Month];
238} 243}
@@ -453,2 +458,5 @@ char *GetOS(void)
453#endif 458#endif
459#if defined(linux) || defined(__linux) || defined(__linux__)
460 struct utsnameVer;
461#endif
454 static char Buffer[100] = {0x00}; 462 static char Buffer[100] = {0x00};
@@ -522,3 +530,4 @@ char *GetOS(void)
522#elif defined(linux) || defined(__linux) || defined(__linux__) 530#elif defined(linux) || defined(__linux) || defined(__linux__)
523 sprintf(Buffer, "Linux"); 531 uname(&Ver);
532 sprintf(Buffer, "Linux, kernel %s",Ver.release);
524#elif defined(__FreeBSD__) 533#elif defined(__FreeBSD__)
diff --git a/gammu/emb/common/misc/misc.h b/gammu/emb/common/misc/misc.h
index 8b46170..c461001 100644
--- a/gammu/emb/common/misc/misc.h
+++ b/gammu/emb/common/misc/misc.h
@@ -5,2 +5,6 @@
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include <stdio.h> 10#include <stdio.h>
@@ -132,2 +136,6 @@ char *GetOS(void);
132 136
137#if defined(_MSC_VER) && defined(__cplusplus)
138 }
139#endif
140
133#endif 141#endif
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c
index f004ad4..3821f13 100644
--- a/gammu/emb/common/phone/alcatel/alcatel.c
+++ b/gammu/emb/common/phone/alcatel/alcatel.c
@@ -11,5 +11,5 @@
11 * - BH4 series (535/735) 11 * - BH4 series (535/735)
12 * For some functions it uses normal AT mode (not implemented here, look at 12 * For some functions it uses normal AT mode (not implemented here, look at
13 * ../at/atgen.[ch]) for others it switches into binary mode and initialises 13 * ../at/atgen.[ch]) for others it switches into binary mode and initialises
14 * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and 14 * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and
15 * communicates over it. Don't ask me why Alcatel uses such silly thing... 15 * communicates over it. Don't ask me why Alcatel uses such silly thing...
@@ -103,2 +103,3 @@ extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType typ
103 extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s); 103 extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
104 extern GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable);
104 extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); 105 extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable);
@@ -118,3 +119,3 @@ unsigned char GSM_AlcatelAlphabet[] =
118 0x83, 0x00,0x20, /* empty*/ 119 0x83, 0x00,0x20, /* empty*/
119 120
120 0x84, 0x00,0xe7, /* c cedilla*/ 121 0x84, 0x00,0xe7, /* c cedilla*/
@@ -170,14 +171,14 @@ unsigned char GSM_AlcatelAlphabet[] =
170 0xb5, 0x00,0x20, /* empty*/ 171 0xb5, 0x00,0x20, /* empty*/
171 172
172 0xb6, 0x01,0x48, /* n caron*/ 173 0xb6, 0x01,0x48, /* n caron*/
173 0xb7, 0x01,0x65, /* t caron*/ 174 0xb7, 0x01,0x65, /* t caron*/
174 175
175 0xb8, 0x00,0x20, /* empty*/ 176 0xb8, 0x00,0x20, /* empty*/
176 177
177 0xb9, 0x01,0x7e, /* z caron*/ 178 0xb9, 0x01,0x7e, /* z caron*/
178 0xba, 0x01,0xe7, /* g caron*/ 179 0xba, 0x01,0xe7, /* g caron*/
179 180
180 0xbb, 0x00,0x20, /* empty*/ 181 0xbb, 0x00,0x20, /* empty*/
181 0xbc, 0x00,0x20, /* empty*/ 182 0xbc, 0x00,0x20, /* empty*/
182 183
183 0xbd, 0x1e,0x20, /* G macron*/ 184 0xbd, 0x1e,0x20, /* G macron*/
@@ -198,3 +199,3 @@ unsigned char GSM_AlcatelAlphabet[] =
198 0xcc, 0x01,0x0f, /* d caron*/ 199 0xcc, 0x01,0x0f, /* d caron*/
199 200
200 0xcd, 0x00,0x20, /* empty*/ 201 0xcd, 0x00,0x20, /* empty*/
@@ -204,5 +205,5 @@ unsigned char GSM_AlcatelAlphabet[] =
204 0xd0, 0x00,0x5e, /* ^ */ 205 0xd0, 0x00,0x5e, /* ^ */
205 206
206 0xd1, 0x00,0x20, /* empty*/ 207 0xd1, 0x00,0x20, /* empty*/
207 208
208 0xd2, 0x00,0x7b, /* { */ 209 0xd2, 0x00,0x7b, /* { */
@@ -210,7 +211,7 @@ unsigned char GSM_AlcatelAlphabet[] =
210 0xd4, 0x00,0x7d, /* } */ 211 0xd4, 0x00,0x7d, /* } */
211 212
212 0xd5, 0x00,0x20, /* empty*/ 213 0xd5, 0x00,0x20, /* empty*/
213 214
214 0xd6, 0x01,0x63, /* t cedilla*/ 215 0xd6, 0x01,0x63, /* t cedilla*/
215 216
216 0xd7, 0x00,0x20, /* empty*/ 217 0xd7, 0x00,0x20, /* empty*/
@@ -225,5 +226,5 @@ unsigned char GSM_AlcatelAlphabet[] =
225 0xe0, 0x00,0x20, /* empty*/ 226 0xe0, 0x00,0x20, /* empty*/
226 227
227 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */ 228 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */
228 229
229 0xe2, 0x00,0x20, /* empty*/ 230 0xe2, 0x00,0x20, /* empty*/
@@ -231,3 +232,3 @@ unsigned char GSM_AlcatelAlphabet[] =
231 0xe4, 0x00,0x20, /* empty*/ 232 0xe4, 0x00,0x20, /* empty*/
232 233
233 0xe5, 0x01,0xce, /* a caron*/ 234 0xe5, 0x01,0xce, /* a caron*/
@@ -241,8 +242,8 @@ unsigned char GSM_AlcatelAlphabet[] =
241 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */ 242 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */
242 243
243 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */ 244 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */
244 0xef, 0x00,0x20, /* big key*/ /* FIXME */ 245 0xef, 0x00,0x20, /* big key*/ /* FIXME */
245 246
246 0xf0, 0x00,0x20, /* empty*/ 247 0xf0, 0x00,0x20, /* empty*/
247 248
248 0xf1, 0x00,0x31, /* 1 */ 249 0xf1, 0x00,0x31, /* 1 */
@@ -253,12 +254,12 @@ unsigned char GSM_AlcatelAlphabet[] =
253 0xf6, 0x26,0x6a, /* note */ 254 0xf6, 0x26,0x6a, /* note */
254 255
255 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */ 256 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */
256 0xf8, 0x27,0x13, /* okay */ 257 0xf8, 0x27,0x13, /* okay */
257 258
258 0xf9, 0x00,0x20, /* empty*/ 259 0xf9, 0x00,0x20, /* empty*/
259 260
260 0xfa, 0x00,0x20, /* key */ /* FIXME */ 261 0xfa, 0x00,0x20, /* key */ /* FIXME */
261 262
262 0xfb, 0x00,0x20, /* empty*/ 263 0xfb, 0x00,0x20, /* empty*/
263 264
264 0xfc, 0x20,0xac, /* Euro */ 265 0xfc, 0x20,0xac, /* Euro */
@@ -268,3 +269,3 @@ unsigned char GSM_AlcatelAlphabet[] =
268 0xff, 0x00,0x20, /* empty*/ 269 0xff, 0x00,0x20, /* empty*/
269 270
270 0x00, 0x00,0x00 271 0x00, 0x00,0x00
@@ -317,3 +318,3 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
317 if (error != ERR_NONE) return error; 318 if (error != ERR_NONE) return error;
318 319
319 error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol); 320 error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol);
@@ -326,3 +327,3 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
326 } 327 }
327 328
328 if (error == ERR_TIMEOUT && s->Speed != 19200) { 329 if (error == ERR_TIMEOUT && s->Speed != 19200) {
@@ -330,3 +331,3 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
330 } 331 }
331 332
332 if (error != ERR_NONE) return error; 333 if (error != ERR_NONE) return error;
@@ -378,3 +379,3 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
378 unsigned char commit_buffer[] = 379 unsigned char commit_buffer[] =
379 {0x00, 0x04, 380 {0x00, 0x04,
380 0x00, /*type */ 381 0x00, /*type */
@@ -445,3 +446,3 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
445 if (error != ERR_NONE) return error; 446 if (error != ERR_NONE) return error;
446 447
447 switch (Priv->BinaryType) { 448 switch (Priv->BinaryType) {
@@ -546,2 +547,4 @@ static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s)
546 Priv->Mode = ModeAT; 547 Priv->Mode = ModeAT;
548 s->Phone.Data.Priv.ATGEN.PBKCharset= 0;
549 s->Phone.Data.Priv.ATGEN.PBKMemory= 0;
547 550
@@ -630,3 +633,3 @@ static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) {
630 } 633 }
631 634
632 for (i=0; i<*Priv->CurrentCount; i++) { 635 for (i=0; i<*Priv->CurrentCount; i++) {
@@ -634,3 +637,3 @@ static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) {
634 } 637 }
635 638
636 return ERR_EMPTY; 639 return ERR_EMPTY;
@@ -848,3 +851,3 @@ static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateM
848 Priv->ReturnDateTime.Second= buffer[6]; 851 Priv->ReturnDateTime.Second= buffer[6];
849 852
850 Priv->ReturnDateTime.Day= 0; 853 Priv->ReturnDateTime.Day= 0;
@@ -1098,3 +1101,3 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
1098 GSM_Error error; 1101 GSM_Error error;
1099 1102
1100 if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { 1103 if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') {
@@ -1103,3 +1106,3 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
1103 } 1106 }
1104 1107
1105 smprintf(s,"Reading category %d\n", id); 1108 smprintf(s,"Reading category %d\n", id);
@@ -1125,3 +1128,3 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
1125 if (error != ERR_NONE) return error; 1128 if (error != ERR_NONE) return error;
1126 1129
1127 CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); 1130 CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString);
@@ -1215,5 +1218,5 @@ static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_Fi
1215 int len; 1218 int len;
1216 1219
1217 buffer[1] = field & 0xff; 1220 buffer[1] = field & 0xff;
1218 1221
1219 switch(type) { 1222 switch(type) {
@@ -1331,6 +1334,6 @@ static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
1331 if (error != ERR_NONE) return error; 1334 if (error != ERR_NONE) return error;
1332 1335
1333 error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField); 1336 error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField);
1334 if (error != ERR_NONE) return error; 1337 if (error != ERR_NONE) return error;
1335 1338
1336 return ERR_NONE; 1339 return ERR_NONE;
@@ -1344,3 +1347,3 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
1344 0x00, /* type */ 1347 0x00, /* type */
1345 0x26, 0x01, 1348 0x26, 0x01,
1346 0x00, 0x00, 0x00, 0x00,/* id */ 1349 0x00, 0x00, 0x00, 0x00,/* id */
@@ -1352,3 +1355,3 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
1352 smprintf(s,"Updating field (%08x.%02x)\n", id, field); 1355 smprintf(s,"Updating field (%08x.%02x)\n", id, field);
1353 1356
1354 buffer[5] = (id >> 24); 1357 buffer[5] = (id >> 24);
@@ -1371,6 +1374,6 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
1371 if (error != ERR_NONE) return error; 1374 if (error != ERR_NONE) return error;
1372 1375
1373 error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField); 1376 error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField);
1374 if (error != ERR_NONE) return error; 1377 if (error != ERR_NONE) return error;
1375 1378
1376 return ERR_NONE; 1379 return ERR_NONE;
@@ -1745,3 +1748,3 @@ static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *ent
1745 if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; 1748 if (Priv->ContactsItemsCount == 0) return ERR_EMPTY;
1746 1749
1747 if (start) entry->Location = 0; 1750 if (start) entry->Location = 0;
@@ -1770,3 +1773,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1770 switch (entry->Entries[i].EntryType) { 1773 switch (entry->Entries[i].EntryType) {
1771 case PBK_Number_General: 1774 case PBK_Number_General:
1772 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error; 1775 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
@@ -1779,3 +1782,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1779 break; 1782 break;
1780 case PBK_Number_Fax: 1783 case PBK_Number_Fax:
1781 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error; 1784 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
@@ -1811,9 +1814,9 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1811 break; 1814 break;
1812 case PBK_Text_JobTitle: 1815 case PBK_Text_JobTitle:
1813 if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error; 1816 if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error;
1814 break; 1817 break;
1815 case PBK_Category: 1818 case PBK_Category:
1816 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1819 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1817 break; 1820 break;
1818 case PBK_Private: 1821 case PBK_Private:
1819 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1822 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error;
@@ -1842,3 +1845,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1842 case PBK_Text_Custom3: 1845 case PBK_Text_Custom3:
1843 if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error; 1846 if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error;
1844 break; 1847 break;
@@ -1847,3 +1850,3 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1847 break; 1850 break;
1848 case PBK_PictureID: 1851 case PBK_PictureID:
1849 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 1852 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
@@ -1908,5 +1911,5 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1908 if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; 1911 if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error;
1909 1912
1910 for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } 1913 for (i = 0; i < 26; i++) { UpdatedFields[i] = false; }
1911 1914
1912 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error; 1915 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error;
@@ -1914,24 +1917,24 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1914 switch (entry->Entries[i].EntryType) { 1917 switch (entry->Entries[i].EntryType) {
1915 case PBK_Number_General: 1918 case PBK_Number_General:
1916 UpdatedFields[8] = true; 1919 UpdatedFields[8] = true;
1917 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error; 1920 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error;
1918 break; 1921 break;
1919 case PBK_Number_Mobile: 1922 case PBK_Number_Mobile:
1920 UpdatedFields[12] = true; 1923 UpdatedFields[12] = true;
1921 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error; 1924 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error;
1922 break; 1925 break;
1923 case PBK_Number_Work: 1926 case PBK_Number_Work:
1924 UpdatedFields[7] = true; 1927 UpdatedFields[7] = true;
1925 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error; 1928 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error;
1926 break; 1929 break;
1927 case PBK_Number_Fax: 1930 case PBK_Number_Fax:
1928 UpdatedFields[9] = true; 1931 UpdatedFields[9] = true;
1929 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error; 1932 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error;
1930 break; 1933 break;
1931 case PBK_Number_Home: 1934 case PBK_Number_Home:
1932 UpdatedFields[13] = true; 1935 UpdatedFields[13] = true;
1933 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error; 1936 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error;
1934 break; 1937 break;
1935 case PBK_Number_Pager: 1938 case PBK_Number_Pager:
1936 UpdatedFields[11] = true; 1939 UpdatedFields[11] = true;
1937 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error; 1940 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error;
@@ -1940,29 +1943,29 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1940 UpdatedFields[10] = true; 1943 UpdatedFields[10] = true;
1941 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error; 1944 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error;
1942 break; 1945 break;
1943 case PBK_Text_Note: 1946 case PBK_Text_Note:
1944 UpdatedFields[4] = true; 1947 UpdatedFields[4] = true;
1945 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error; 1948 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error;
1946 break; 1949 break;
1947 case PBK_Text_Email: 1950 case PBK_Text_Email:
1948 UpdatedFields[14] = true; 1951 UpdatedFields[14] = true;
1949 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error; 1952 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error;
1950 break; 1953 break;
1951 case PBK_Text_Email2: 1954 case PBK_Text_Email2:
1952 UpdatedFields[15] = true; 1955 UpdatedFields[15] = true;
1953 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error; 1956 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error;
1954 break; 1957 break;
1955 case PBK_Text_LastName: 1958 case PBK_Text_LastName:
1956 UpdatedFields[0] = true; 1959 UpdatedFields[0] = true;
1957 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; 1960 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
1958 break; 1961 break;
1959 case PBK_Text_FirstName: 1962 case PBK_Text_FirstName:
1960 UpdatedFields[1] = true; 1963 UpdatedFields[1] = true;
1961 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; 1964 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true;
1962 break; 1965 break;
1963 case PBK_Text_Company: 1966 case PBK_Text_Company:
1964 UpdatedFields[2] = true; 1967 UpdatedFields[2] = true;
1965 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error; 1968 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error;
1966 break; 1969 break;
1967 case PBK_Text_JobTitle: 1970 case PBK_Text_JobTitle:
1968 UpdatedFields[3] = true; 1971 UpdatedFields[3] = true;
@@ -1971,3 +1974,3 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1971 case PBK_Category: 1974 case PBK_Category:
1972 UpdatedFields[5] = true; 1975 UpdatedFields[5] = true;
1973 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1976 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error;
@@ -1978,17 +1981,17 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1978 break; 1981 break;
1979 case PBK_Text_StreetAddress: 1982 case PBK_Text_StreetAddress:
1980 UpdatedFields[16] = true; 1983 UpdatedFields[16] = true;
1981 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error; 1984 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error;
1982 break; 1985 break;
1983 case PBK_Text_City: 1986 case PBK_Text_City:
1984 UpdatedFields[17] = true; 1987 UpdatedFields[17] = true;
1985 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error; 1988 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error;
1986 break; 1989 break;
1987 case PBK_Text_State: 1990 case PBK_Text_State:
1988 UpdatedFields[18] = true; 1991 UpdatedFields[18] = true;
1989 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error; 1992 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error;
1990 break; 1993 break;
1991 case PBK_Text_Zip: 1994 case PBK_Text_Zip:
1992 UpdatedFields[19] = true; 1995 UpdatedFields[19] = true;
1993 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error; 1996 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error;
1994 break; 1997 break;
@@ -2002,3 +2005,3 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2002 break; 2005 break;
2003 case PBK_Text_Custom2: 2006 case PBK_Text_Custom2:
2004 UpdatedFields[22] = true; 2007 UpdatedFields[22] = true;
@@ -2011,6 +2014,6 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2011 case PBK_Text_Custom4: 2014 case PBK_Text_Custom4:
2012 UpdatedFields[24] = true; 2015 UpdatedFields[24] = true;
2013 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error 2016 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error
2014 ; break; 2017 ; break;
2015 case PBK_PictureID: 2018 case PBK_PictureID:
2016 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 2019 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
@@ -2071,3 +2074,3 @@ static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entr
2071 if (error != ERR_NONE) return error; 2074 if (error != ERR_NONE) return error;
2072 2075
2073 /* Refresh list */ 2076 /* Refresh list */
@@ -2075,3 +2078,3 @@ static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entr
2075 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2078 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2076 2079
2077 return ERR_NONE; 2080 return ERR_NONE;
@@ -2230,3 +2233,3 @@ static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatur
2230} 2233}
2231 2234
2232static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) 2235static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s)
@@ -2339,5 +2342,5 @@ static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStat
2339 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2342 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2340 2343
2341 status->Used = 0; 2344 status->Used = 0;
2342 2345
2343 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2346 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
@@ -2729,3 +2732,3 @@ static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry
2729 if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; 2732 if (Priv->CalendarItemsCount == 0) return ERR_EMPTY;
2730 2733
2731 if (start) Note->Location = 0; 2734 if (start) Note->Location = 0;
@@ -2770,3 +2773,3 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2770 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error; 2773 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error;
2771 2774
2772 for (i = 0; i < Note->EntriesNum; i++) { 2775 for (i = 0; i < Note->EntriesNum; i++) {
@@ -2808,3 +2811,3 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2808 phone_set = true; 2811 phone_set = true;
2809 break; 2812 break;
2810 case CAL_REPEAT_DAYOFWEEK: 2813 case CAL_REPEAT_DAYOFWEEK:
@@ -2844,3 +2847,3 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2844 } 2847 }
2845 2848
2846 switch (Note->Type) { 2849 switch (Note->Type) {
@@ -2902,3 +2905,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2902 if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; 2905 if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error;
2903 2906
2904 for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } 2907 for (i = 0; i < 22; i++) { UpdatedFields[i] = false; }
@@ -2906,3 +2909,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2906 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error; 2909 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error;
2907 2910
2908 for (i = 0; i < Note->EntriesNum; i++) { 2911 for (i = 0; i < Note->EntriesNum; i++) {
@@ -2911,3 +2914,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2911 if (!date_set) { 2914 if (!date_set) {
2912 UpdatedFields[0] = true; 2915 UpdatedFields[0] = true;
2913 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2916 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
@@ -2955,3 +2958,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2955 phone_set = true; 2958 phone_set = true;
2956 break; 2959 break;
2957 case CAL_REPEAT_DAYOFWEEK: 2960 case CAL_REPEAT_DAYOFWEEK:
@@ -2998,3 +3001,3 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2998 } 3001 }
2999 3002
3000 switch (Note->Type) { 3003 switch (Note->Type) {
@@ -3074,3 +3077,3 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
3074 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3077 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3075 3078
3076 for (i=0; i<Priv->CalendarItemsCount; i++) { 3079 for (i=0; i<Priv->CalendarItemsCount; i++) {
@@ -3093,3 +3096,3 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
3093 Note.Location = Priv->CalendarItems[i]; 3096 Note.Location = Priv->CalendarItems[i];
3094 3097
3095 if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; 3098 if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error;
@@ -3101,3 +3104,3 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
3101 } 3104 }
3102 3105
3103 alarm->Text[0] = 0; alarm->Text[1] = 0; 3106 alarm->Text[0] = 0; alarm->Text[1] = 0;
@@ -3148,3 +3151,3 @@ static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm)
3148 } 3151 }
3149 3152
3150 if (Found) { 3153 if (Found) {
@@ -3186,5 +3189,5 @@ static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *stat
3186 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3189 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3187 3190
3188 status->Used = 0; 3191 status->Used = 0;
3189 3192
3190 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3193 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
@@ -3453,3 +3456,3 @@ static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, b
3453 if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; 3456 if (Priv->ToDoItemsCount == 0) return ERR_EMPTY;
3454 3457
3455 if (start) ToDo->Location = 0; 3458 if (start) ToDo->Location = 0;
@@ -3492,3 +3495,3 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3492 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error; 3495 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error;
3493 3496
3494 switch (ToDo->Priority) { 3497 switch (ToDo->Priority) {
@@ -3520,3 +3523,3 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3520 break; 3523 break;
3521 case TODO_ALARM_DATETIME: 3524 case TODO_ALARM_DATETIME:
3522 if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3525 if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
@@ -3581,5 +3584,5 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3581 if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; 3584 if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error;
3582 3585
3583 for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } 3586 for (i = 0; i < 12; i++) { UpdatedFields[i] = false; }
3584 3587
3585 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error; 3588 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error;
@@ -3610,3 +3613,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3610 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;
3611 UpdatedFields[0] = true; 3614 UpdatedFields[0] = true;
3612 break; 3615 break;
@@ -3614,13 +3617,13 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3614 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;
3615 UpdatedFields[1] = true; 3618 UpdatedFields[1] = true;
3616 break; 3619 break;
3617 case TODO_ALARM_DATETIME: 3620 case TODO_ALARM_DATETIME:
3618 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;
3619 UpdatedFields[2] = true; 3622 UpdatedFields[2] = true;
3620 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;
3621 UpdatedFields[3] = true; 3624 UpdatedFields[3] = true;
3622 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;
3623 UpdatedFields[10] = true; 3626 UpdatedFields[10] = true;
3624 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;
3625 UpdatedFields[11] = true; 3628 UpdatedFields[11] = true;
3626 break; 3629 break;
@@ -3628,3 +3631,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3628 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;
3629 UpdatedFields[4] = true; 3632 UpdatedFields[4] = true;
3630 break; 3633 break;
@@ -3632,3 +3635,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3632 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;
3633 UpdatedFields[5] = true; 3636 UpdatedFields[5] = true;
3634 break; 3637 break;
@@ -3636,3 +3639,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3636 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;
3637 UpdatedFields[6] = true; 3640 UpdatedFields[6] = true;
3638 break; 3641 break;
@@ -3640,3 +3643,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3640 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;
3641 UpdatedFields[8] = true; 3644 UpdatedFields[8] = true;
3642 contact_set = true; 3645 contact_set = true;
@@ -3645,3 +3648,3 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3645 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;
3646 UpdatedFields[9] = true; 3649 UpdatedFields[9] = true;
3647 phone_set = true; 3650 phone_set = true;
@@ -3824,2 +3827,10 @@ static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable)
3824 3827
3828static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3829{
3830 GSM_Error error;
3831
3832 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3833 return ATGEN_SetFastSMSSending(s, enable);
3834}
3835
3825static GSM_Reply_Function ALCATELReplyFunctions[] = { 3836static GSM_Reply_Function ALCATELReplyFunctions[] = {
@@ -3915,2 +3926,3 @@ GSM_Phone_Functions ALCATELPhone = {
3915 ALCATEL_SendSavedSMS, 3926 ALCATEL_SendSavedSMS,
3927 ALCATEL_SetFastSMSSending,
3916 ALCATEL_SetIncomingSMS, 3928 ALCATEL_SetIncomingSMS,
@@ -3969,3 +3981,3 @@ GSM_Phone_Functions ALCATELPhone = {
3969 NOTSUPPORTED, /* SetCalendarSettings*/ 3981 NOTSUPPORTED, /* SetCalendarSettings*/
3970 NOTSUPPORTED, /* GetNote */ 3982 NOTSUPPORTED, /* GetNextNote */
3971 NOTSUPPORTED, /* GetProfile */ 3983 NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c
index 1834f15..ba23eb2 100644
--- a/gammu/emb/common/phone/at/atgen.c
+++ b/gammu/emb/common/phone/at/atgen.c
@@ -14,33 +14,13 @@
14#include "../pfunc.h" 14#include "../pfunc.h"
15
15#include "atgen.h" 16#include "atgen.h"
16 17
18#include "samsung.h"
19#include "siemens.h"
20#include "sonyeric.h"
21
17#ifdef GSM_ENABLE_ALCATEL 22#ifdef GSM_ENABLE_ALCATEL
18 extern GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s); 23GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message, GSM_StateMachine *);
19#endif 24#endif
20 25
21 extern GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s);
22 extern GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s);
23 extern GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s);
24 extern GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s);
25 extern GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s);
26 extern GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s);
27 extern GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s);
28 extern GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s);
29
30 extern GSM_Error ATGEN_GetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone);
31 extern GSM_Error ATGEN_SetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength);
32 extern GSM_Error ATGEN_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
33 extern GSM_Error ATGEN_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
34 extern GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
35 extern GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
36 extern GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
37
38 extern GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
39 extern GSM_Error SONYERIC_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start);
40 extern GSM_Error SONYERIC_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status);
41 extern GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
42 extern GSM_Error SONYERIC_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
43 extern GSM_Error SONYERIC_DeleteAllToDo (GSM_StateMachine *s);
44 extern GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
45 extern GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status);
46 26
@@ -177,2 +157,4 @@ GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
177 switch (Priv->ErrorCode) { 157 switch (Priv->ErrorCode) {
158 case -1:
159 return ERR_EMPTY;
178 case 3: 160 case 3:
@@ -258,4 +240,12 @@ void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input)
258{ 240{
259 dt->Year=2000+(*input-'0')*10; input++; 241 /* Samsung phones report year as %d instead of %02d */
242 if (input[2] == '/') {
243 dt->Year=(*input-'0')*10;
244 input++;
245 } else {
246 dt->Year=0;
247 }
248
260 dt->Year=dt->Year+(*input-'0'); input++; 249 dt->Year=dt->Year+(*input-'0'); input++;
250 dt->Year+=2000;
261 251
@@ -324,2 +314,14 @@ GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
324 } 314 }
315
316 /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */
317 if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) {
318 err = line + 11;
319 Priv->ErrorCode = atoi(err);
320
321 if (Priv->ErrorCode == -1) {
322 Priv->ErrorText = "[Samsung] Empty location";
323 return GSM_DispatchMessage(s);
324 }
325 }
326
325 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) { 327 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) {
@@ -372,2 +374,38 @@ GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
372 374
375GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s)
376{
377 unsigned char buffer[2000],buffer2[4000];
378 int i = 10;
379
380 /* Ugly hack */
381 while (msg.Buffer[i]!=13) i++;
382 i = i - 6;
383 memcpy(buffer,msg.Buffer+10,i-11);
384 buffer[i-11] = 0x00;
385
386 smprintf(s, "USSD reply: \"%s\"\n",buffer);
387
388 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
389 EncodeUnicode(buffer2,buffer,strlen(buffer));
390 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
391 }
392
393 return ERR_NONE;
394}
395
396GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
397{
398 GSM_Error error;
399
400 if (enable) {
401 smprintf(s, "Enabling incoming USSD\n");
402 error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD);
403 } else {
404 smprintf(s, "Disabling incoming USSD\n");
405 error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD);
406 }
407 if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable;
408 return error;
409}
410
373GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s) 411GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -396,2 +434,3 @@ GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
396 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;
397 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP; 436 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP;
@@ -400,2 +439,3 @@ GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
400 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");
401 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ"); 441 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ");
@@ -483,2 +523,7 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine
483 } 523 }
524 if (strstr(msg.Buffer,"Samsung")) {
525 smprintf(s, "Samsung\n");
526 strcpy(s->Phone.Data.Manufacturer,"Samsung");
527 Priv->Manufacturer = AT_Samsung;
528 }
484 return ERR_NONE; 529 return ERR_NONE;
@@ -676,8 +721,16 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *
676 */ 721 */
677 s->Phone.Data.Priv.ATGEN.CanSaveSMS = (strstr(msg.Buffer, "), (") != NULL); 722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
724 s->Phone.Data.Priv.ATGEN.CanSaveSMS = true;
725 }
726
678 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;
679 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE; 728 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE;
729
680 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;
681 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE; 731 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE;
682 smprintf(s, "Available SMS memories received, ME = %d, SM = %d\n", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory); 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);
734 if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true");
735 smprintf(s, "\n");
683 return ERR_NONE; 736 return ERR_NONE;
@@ -686,2 +739,4 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *
686 return ATGEN_HandleCMSError(s); 739 return ATGEN_HandleCMSError(s);
740 case AT_Reply_CMEError:
741 return ATGEN_HandleCMEError(s);
687 default: 742 default:
@@ -860,4 +915,5 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
860 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 915 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
861 if (buffer[1]!=NUMBER_UNKNOWN && buffer[1]!=NUMBER_INTERNATIONAL && 916 /* we check for the most often visible */
862 buffer[1]!=NUMBER_ALPHANUMERIC) { 917 if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN &&
918 buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
863 /* Seems to be Delivery Report */ 919 /* Seems to be Delivery Report */
@@ -896,3 +952,3 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
896 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 952 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
897 if (buffer[current+1]==NUMBER_ALPHANUMERIC) { 953 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
898 smprintf(s, "Trying to read alphanumeric number\n"); 954 smprintf(s, "Trying to read alphanumeric number\n");
@@ -927,3 +983,3 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
927 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 983 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
928 if (buffer[current+1]==NUMBER_ALPHANUMERIC) { 984 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
929 smprintf(s, "Trying to read alphanumeric number\n"); 985 smprintf(s, "Trying to read alphanumeric number\n");
@@ -951,3 +1007,3 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
951 sms->InboxFolder = true; 1007 sms->InboxFolder = true;
952 smprintf(s, "TPMR is %02x\n",buffer[current]); 1008 smprintf(s, "TPMR is %d\n",buffer[current]);
953 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++]; 1009 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++];
@@ -1642,3 +1698,3 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1642 if (s->User.SendSMSStatus!=NULL) { 1698 if (s->User.SendSMSStatus!=NULL) {
1643 start = strstr(msg.Buffer, "+CMGW: "); 1699 start = strstr(msg.Buffer, "+CMGS: ");
1644 if (start != NULL) { 1700 if (start != NULL) {
@@ -1646,3 +1702,3 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1646 } else { 1702 } else {
1647 s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); 1703 s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1);
1648 } 1704 }
@@ -1652,3 +1708,3 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1652 smprintf(s, "Error %i\n",Priv->ErrorCode); 1708 smprintf(s, "Error %i\n",Priv->ErrorCode);
1653 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,0); 1709 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,-1);
1654 return ATGEN_HandleCMSError(s); 1710 return ATGEN_HandleCMSError(s);
@@ -1789,2 +1845,15 @@ GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1789 1845
1846/* R320 only takes HH:MM. Do other phones understand full date? */
1847GSM_Error ATGEN_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1848{
1849 char req[20];
1850
1851 if (alarm->Location != 1) return ERR_INVALIDLOCATION;
1852
1853 sprintf(req, "AT+CALA=\"%02i:%02i\"\r",alarm->DateTime.Hour,alarm->DateTime.Minute);
1854
1855 smprintf(s, "Setting Alarm\n");
1856 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetAlarm);
1857}
1858
1790GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 1859GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -2204,2 +2273,4 @@ GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM
2204 error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus); 2273 error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus);
2274 if (Priv->Manufacturer == AT_Samsung)
2275 error = GSM_WaitFor (s, "", 0, 0x00, 4, ID_GetMemoryStatus);
2205 if (error != ERR_NONE) return error; 2276 if (error != ERR_NONE) return error;
@@ -2270,2 +2341,8 @@ GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode)
2270 2341
2342 /* Samsung (and Sagem?) phones use only PCCP437? */
2343 if (Priv->Manufacturer == AT_Samsung) {
2344 Priv->PBKCharset = AT_PBK_PCCP437;
2345 return ERR_NONE;
2346 }
2347
2271 if (PreferUnicode && !Priv->UCS2CharsetFailed) { 2348 if (PreferUnicode && !Priv->UCS2CharsetFailed) {
@@ -2387,3 +2464,33 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
2387 break; 2464 break;
2465 case AT_PBK_PCCP437:
2466 /* FIXME: correctly decode PCCP437 */
2467 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
2468 break;
2469 }
2470
2471 /* Samsung number type */
2472 if (Priv->Manufacturer == AT_Samsung) {
2473 int type;
2474
2475 pos += ATGEN_ExtractOneParameter(pos, buffer);
2476 smprintf(s, "Number type: %s\n",buffer);
2477 type = strtoul(buffer, NULL, 0);
2478 switch (type) {
2479 case 0:
2480 Memory->Entries[0].EntryType = PBK_Number_Mobile;
2481 break;
2482 case 1:
2483 Memory->Entries[0].EntryType = PBK_Number_Work;
2484 break;
2485 case 2:
2486 Memory->Entries[0].EntryType = PBK_Number_Home;
2487 break;
2488 case 3:
2489 Memory->Entries[0].EntryType = PBK_Text_Email;
2490 break;
2491 default:
2492 Memory->Entries[0].EntryType = PBK_Number_General;
2493 }
2388 } 2494 }
2495
2389 return ERR_NONE; 2496 return ERR_NONE;
@@ -2564,2 +2671,4 @@ GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachin
2564 return ATGEN_HandleCMSError(s); 2671 return ATGEN_HandleCMSError(s);
2672 case AT_Reply_CMEError:
2673 return ATGEN_HandleCMEError(s);
2565 default: 2674 default:
@@ -2926,2 +3035,8 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2926 break; 3035 break;
3036 case AT_PBK_PCCP437:
3037 /* FIXME: correctly decode PCCP437 */
3038 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
3039 len = UnicodeLength(entry->Entries[Name].Text);
3040 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
3041 break;
2927 } 3042 }
@@ -3254,2 +3369,39 @@ GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3254 3369
3370
3371GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
3372{
3373 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3374
3375 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetBitmap(s, Bitmap);
3376 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetBitmap(s, Bitmap);
3377 return ERR_NOTSUPPORTED;
3378}
3379
3380GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
3381{
3382 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3383
3384 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetBitmap(s, Bitmap);
3385 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetBitmap(s, Bitmap);
3386 return ERR_NOTSUPPORTED;
3387}
3388
3389GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
3390{
3391 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3392
3393 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetRingtone(s, Ringtone, PhoneRingtone);
3394 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetRingtone(s, Ringtone, PhoneRingtone);
3395 return ERR_NOTSUPPORTED;
3396}
3397
3398GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
3399{
3400 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3401
3402 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetRingtone(s, Ringtone, maxlength);
3403 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetRingtone(s, Ringtone, maxlength);
3404 return ERR_NOTSUPPORTED;
3405}
3406
3255GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 3407GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
@@ -3348,2 +3500,13 @@ GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
3348 3500
3501GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3502{
3503 if (enable) {
3504 smprintf(s, "Enabling fast SMS sending\n");
3505 return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending);
3506 } else {
3507 smprintf(s, "Disabling fast SMS sending\n");
3508 return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending);
3509 }
3510}
3511
3349GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 3512GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -3426,2 +3589,14 @@ GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
3426 3589
3590GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3591{
3592 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale);
3593 return ERR_NOTSUPPORTED;
3594}
3595
3596GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3597{
3598 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale);
3599 return ERR_NOTSUPPORTED;
3600}
3601
3427GSM_Reply_Function ATGENReplyFunctions[] = { 3602GSM_Reply_Function ATGENReplyFunctions[] = {
@@ -3434,2 +3609,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3434 3609
3610 {ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale },
3611 {ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale },
3612 {ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale },
3613 {ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale },
3614
3435#ifdef GSM_ENABLE_CELLBROADCAST 3615#ifdef GSM_ENABLE_CELLBROADCAST
@@ -3464,2 +3644,3 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3464 {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 },
3465 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame }, 3646 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame },
@@ -3471,2 +3652,3 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3471 {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 },
3472 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm }, 3654 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm },
@@ -3486,3 +3668,5 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3486 {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*/
3487 {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 },
3488 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus }, 3672 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus },
@@ -3491,14 +3675,14 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3491 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory }, 3675 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory },
3492 {ATGEN_SL45ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory }, 3676 {SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
3493 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory }, 3677 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory },
3494 3678
3495 {ATGEN_CMS35ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap }, 3679 {SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
3496 {ATGEN_CMS35ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap }, 3680 {SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
3497 3681
3498 {ATGEN_CMS35ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone }, 3682 {SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
3499 {ATGEN_CMS35ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone }, 3683 {SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
3500 3684
3501 {ATGEN_CMS35ReplyGetNextCal, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote }, 3685 {SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
3502 {ATGEN_CMS35ReplySetCalendar, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote }, 3686 {SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
3503 {ATGEN_CMS35ReplyDeleteCalendar,"AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote }, 3687 {SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote },
3504 3688
@@ -3513,2 +3697,4 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3513 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall }, 3697 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall },
3698 {ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
3699 {ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
3514 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame }, 3700 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
@@ -3523,2 +3709,8 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3523 3709
3710 {SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap },
3711 {SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap },
3712
3713 {SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone },
3714 {SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone },
3715
3524#ifdef GSM_ENABLE_ALCATEL 3716#ifdef GSM_ENABLE_ALCATEL
@@ -3540,3 +3732,3 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3540GSM_Phone_Functions ATGENPhone = { 3732GSM_Phone_Functions ATGENPhone = {
3541 "A2D|iPAQ|at|M20|S25|MC35|C35i|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",
3542 ATGENReplyFunctions, 3734 ATGENReplyFunctions,
@@ -3559,5 +3751,5 @@ GSM_Phone_Functions ATGENPhone = {
3559 ATGEN_GetAlarm, 3751 ATGEN_GetAlarm,
3560 NOTIMPLEMENTED, /* SetAlarm */ 3752 ATGEN_SetAlarm,
3561 NOTSUPPORTED, /* GetLocale */ 3753 ATGEN_GetLocale,
3562 NOTSUPPORTED, /* SetLocale */ 3754 ATGEN_SetLocale,
3563 ATGEN_PressKey, 3755 ATGEN_PressKey,
@@ -3594,2 +3786,3 @@ GSM_Phone_Functions ATGENPhone = {
3594 ATGEN_SendSavedSMS, 3786 ATGEN_SendSavedSMS,
3787 ATGEN_SetFastSMSSending,
3595 ATGEN_SetIncomingSMS, 3788 ATGEN_SetIncomingSMS,
@@ -3612,3 +3805,3 @@ GSM_Phone_Functions ATGENPhone = {
3612 NONEFUNCTION, /* SetIncomingCall */ 3805 NONEFUNCTION, /* SetIncomingCall */
3613 NOTSUPPORTED, /* SetIncomingUSSD */ 3806 ATGEN_SetIncomingUSSD,
3614 ATGEN_SendDTMF, 3807 ATGEN_SendDTMF,
@@ -3648,3 +3841,3 @@ GSM_Phone_Functions ATGENPhone = {
3648 NOTSUPPORTED, /* SetCalendarSettings*/ 3841 NOTSUPPORTED, /* SetCalendarSettings*/
3649 NOTSUPPORTED, /* GetNote */ 3842 NOTSUPPORTED, /* GetNextNote */
3650 NOTSUPPORTED, /* GetProfile */ 3843 NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/at/atgen.h b/gammu/emb/common/phone/at/atgen.h
index 0e08ee4..bb5c559 100644
--- a/gammu/emb/common/phone/at/atgen.h
+++ b/gammu/emb/common/phone/at/atgen.h
@@ -44,2 +44,3 @@ typedef enum {
44 AT_Sagem, 44 AT_Sagem,
45 AT_Samsung,
45 AT_Unknown 46 AT_Unknown
@@ -50,3 +51,4 @@ typedef enum {
50 AT_PBK_GSM, 51 AT_PBK_GSM,
51 AT_PBK_UCS2 52 AT_PBK_UCS2,
53 AT_PBK_PCCP437
52} GSM_AT_PBK_Charset; 54} GSM_AT_PBK_Charset;
@@ -105,2 +107,6 @@ typedef struct {
105 107
108 GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *);
109 GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *);
110 GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *);
111
106#endif 112#endif
diff --git a/gammu/emb/common/phone/at/samsung.c b/gammu/emb/common/phone/at/samsung.c
new file mode 100644
index 0000000..55a42e5
--- a/dev/null
+++ b/gammu/emb/common/phone/at/samsung.c
@@ -0,0 +1,447 @@
1/* Samsung-specific functions
2 * Copyright (C) 2004 Claudio Matsuoka <cmatsuoka@gmail.com>
3 * Tested with S300 only!
4 */
5
6#include "../../gsmstate.h"
7
8#ifdef GSM_ENABLE_ATGEN
9
10#include <string.h>
11#include <time.h>
12#include <ctype.h>
13
14#include "../../misc/coding/coding.h"
15#include "../../gsmcomon.h"
16#include "../../service/sms/gsmsms.h"
17#include "../pfunc.h"
18
19#include "atgen.h"
20#include "samsung.h"
21
22/* Binary frame size */
23#define BLKSZ 1024
24
25struct ModelRes {
26 char *model;
27 int width;
28 int height;
29};
30
31static struct ModelRes modres[] = {
32 { "S100", 128, 128 },
33 { "S200", 128, 113 },
34 { "S300", 128, 97 },
35 { "S500", 128, 128 },
36 { "T100", 128, 128 },
37 { "E700", 128, 128 },
38 { NULL, 0, 0 }
39};
40
41/*
42 * CRC functions from the Granch SBNI12 Linux driver by
43 * Denis I. Timofeev <timofeev@granch.ru>
44 */
45static unsigned int crc32tab[] = {
46 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
47 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
48 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605,
49 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C,
50 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53,
51 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A,
52 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661,
53 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278,
54 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF,
55 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6,
56 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD,
57 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4,
58 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B,
59 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82,
60 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9,
61 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0,
62 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7,
63 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE,
64 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795,
65 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C,
66 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3,
67 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA,
68 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1,
69 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8,
70 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F,
71 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76,
72 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D,
73 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344,
74 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B,
75 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12,
76 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739,
77 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320,
78 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17,
79 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E,
80 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525,
81 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C,
82 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73,
83 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A,
84 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541,
85 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158,
86 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF,
87 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6,
88 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED,
89 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4,
90 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB,
91 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2,
92 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589,
93 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190,
94 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87,
95 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E,
96 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5,
97 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC,
98 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3,
99 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA,
100 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1,
101 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8,
102 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F,
103 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856,
104 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D,
105 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064,
106 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B,
107 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832,
108 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419,
109 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000
110};
111
112static unsigned int GetCRC(char *data, int size)
113{
114 unsigned int crc = 0;
115
116 while (size--)
117 crc = crc32tab[(crc ^ *data++) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF);
118
119 return crc;
120}
121
122/*
123 * Frame transfer
124 */
125
126static GSM_Error WaitFor(GSM_StateMachine *s, char *t, int ttl)
127{
128 char readbuf[100];
129 int n;
130 unsigned int sec;
131 GSM_DateTime Date;
132
133 GSM_GetCurrentDateTime (&Date);
134 sec = Date.Second;
135
136 n = s->Device.Functions->ReadDevice(s, readbuf, 80);
137 readbuf[n] = 0;
138 while (strstr(readbuf, t) == NULL && (sec + ttl) >= Date.Second) {
139 my_sleep(5000);
140 n = s->Device.Functions->ReadDevice(s, readbuf, 80);
141 readbuf[n] = 0;
142 GSM_GetCurrentDateTime (&Date);
143 }
144
145 return (sec + ttl) >= Date.Second ? ERR_NONE : ERR_TIMEOUT;
146}
147
148static GSM_Error SetSamsungFrame(GSM_StateMachine *s, unsigned char *buff, int size, GSM_Phone_RequestID id)
149{
150 GSM_Phone_Data *Phone = &s->Phone.Data;
151 GSM_Error error;
152 int i, count;
153
154 count = size / BLKSZ;
155
156 for (i = 0; i < count; i++) {
157 error = WaitFor(s, ">", 4);
158 if (error!=ERR_NONE) return error;
159
160 error = s->Protocol.Functions->WriteMessage(s,
161 buff + i * BLKSZ, BLKSZ, 0x00);
162 if (error!=ERR_NONE) return error;
163 }
164
165 error = WaitFor(s, ">", 4);
166 if (error!=ERR_NONE) return error;
167 error = s->Protocol.Functions->WriteMessage(s,
168 buff + i * BLKSZ, size%BLKSZ, 0x00);
169 if (error!=ERR_NONE) return error;
170
171 error = GSM_WaitFor(s, "", 0, 0x00, 4, id);
172 if (error!=ERR_NONE) return error;
173
174 return Phone->DispatchError;
175}
176
177/* Answer format for binary data transfer
178 *
179 * SDNDCRC = 0xa : RECEIVECRC = 0xcbf53a1c : BINSIZE = 5
180 * CRCERR
181 */
182static GSM_Error ReplySetSamsungFrame(GSM_Protocol_Message msg, GSM_StateMachine *s)
183{
184 unsigned long txcrc, rxcrc;
185 int binsize;
186 char *pos;
187
188 /* Parse SDNDCRC */
189 pos = strchr(msg.Buffer, '=');
190 if (!pos) return ERR_UNKNOWN;
191 pos++;
192 txcrc = strtoul(pos, NULL, 0);
193 smprintf(s, "Sent CRC : 0x%lx\n", txcrc);
194
195 /* Parse RECEIVECRC */
196 pos = strchr(pos, '=');
197 if (!pos) return ERR_UNKNOWN;
198 pos++;
199 rxcrc = strtoul(pos, NULL, 0);
200 smprintf(s, "Reveived CRC : 0x%lx\n", rxcrc);
201
202 /* Parse BINSIZE */
203 pos = strchr(pos, '=');
204 if (!pos) return ERR_UNKNOWN;
205 pos++;
206 binsize = strtoul(pos, NULL, 0);
207 smprintf(s, "Binary size : %d\n", binsize);
208
209 return txcrc == rxcrc ? ERR_NONE : ERR_WRONGCRC;
210}
211
212/*
213 * Bitmaps
214 */
215
216GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
217{
218 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
219 unsigned char buffer[32];
220 char *pos;
221 int location, count;
222
223 switch (Priv->ReplyState) {
224 case AT_Reply_OK:
225 smprintf(s, "Bitmap info received\n");
226 /* Parse +IMGR:location,name,0,0,0,0 */
227
228 /* Parse location */
229 pos = strchr(msg.Buffer, ':');
230 if (!pos) return ERR_UNKNOWN;
231 pos++;
232 location = atoi(pos);
233 smprintf(s, "Location : %d\n", location);
234
235 /* Parse name */
236 pos = strchr(pos, '"');
237 if (!pos) return ERR_UNKNOWN;
238 pos++;
239 for (count = 0; count < 31; count++) {
240 if (pos[count] == '"')
241 break;
242 buffer[count] = pos[count];
243 }
244 buffer[count] = 0;
245 smprintf(s, "Name : %s\n", buffer);
246 s->Phone.Data.Bitmap->Name = malloc((strlen(buffer) + 1) * 2);
247 if (s->Phone.Data.Bitmap->Name == NULL)
248 return ERR_MOREMEMORY;
249 EncodeUnicode(s->Phone.Data.Bitmap->Name, buffer, strlen(buffer));
250
251 s->Phone.Data.Bitmap->Location = location;
252
253 return ERR_NONE;
254 case AT_Reply_Error:
255 return ERR_UNKNOWN;
256 case AT_Reply_CMSError:
257 return ATGEN_HandleCMSError(s);
258 case AT_Reply_CMEError:
259 return ATGEN_HandleCMEError(s);
260 default:
261 return ERR_UNKNOWNRESPONSE;
262 }
263}
264
265GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
266{
267 smprintf(s, "Bitmap sent\n");
268 return ReplySetSamsungFrame(msg, s);
269}
270
271GSM_Error SAMSUNG_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
272{
273 unsigned char req[100];
274
275 s->Phone.Data.Bitmap=Bitmap;
276 smprintf(s, "Getting bitmap\n");
277 sprintf(req, "AT+IMGR=%d\r", Bitmap->Location-1);
278 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
279}
280
281GSM_Error SAMSUNG_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
282{
283 unsigned charreq[100];
284 unsigned longcrc;
285 GSM_Errorerror;
286 char name[50], *dot, *model;
287 GSM_Phone_Data *Data = &s->Phone.Data;
288 int i;
289
290 s->Phone.Data.Bitmap = Bitmap;
291 smprintf(s, "Setting bitmap\n");
292
293 if (Bitmap->Type != GSM_PictureBinary) {
294 smprintf(s, "Invalid picture type\n");
295 return ERR_INVALIDDATA;
296 }
297
298 if (Bitmap->BinaryPic.Type != PICTURE_GIF) {
299 smprintf(s, "Invalid binary picture type\n");
300 return ERR_INVALIDDATA;
301 }
302
303 /* Check if picture size matches phone model */
304 model = GetModelData(NULL,Data->Model,NULL)->model;
305 smprintf(s, "Checking picture size for %s\n", model);
306 for (i = 0; modres[i].model; i++) {
307 if (!strcmp(model, modres[i].model)) {
308 if (Bitmap->BitmapWidth != modres[i].width ||
309 Bitmap->BitmapHeight != modres[i].height) {
310 smprintf(s, "Model %s must use %d x %d picture size\n",
311 modres[i].model, modres[i].width,
312 modres[i].height);
313 return ERR_INVALIDDATA;
314 }
315 break;
316 }
317 }
318 if (modres[i].model == NULL) {
319 smprintf(s, "Model \"%s\" is not supported.\n", Data->Model);
320 return ERR_NOTSUPPORTED;
321 }
322
323 crc = GetCRC(Bitmap->BinaryPic.Buffer, Bitmap->BinaryPic.Length);
324
325 /* Remove extension from file name */
326 strncpy(name, DecodeUnicodeString(Bitmap->Name), 50);
327 if ((dot = strrchr(name, '.')) != NULL)
328 *dot = 0;
329
330 sprintf(req, "AT+IMGW=0,\"%s\",2,0,0,0,0,100,%d,%u\r", name,
331 Bitmap->BinaryPic.Length, (unsigned int)crc);
332
333 error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
334 if (error!=ERR_NONE) return error;
335
336 return SetSamsungFrame(s, Bitmap->BinaryPic.Buffer,
337 Bitmap->BinaryPic.Length, ID_SetBitmap);
338}
339
340/*
341 * Ringtones
342 */
343
344GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
345{
346 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
347 unsigned char buffer[32];
348 char *pos;
349 int location, length, count;
350
351 switch (Priv->ReplyState) {
352 case AT_Reply_OK:
353 smprintf(s, "Ringtone info received\n");
354 /* Parse +MELR:location,name,size */
355
356 /* Parse location */
357 pos = strchr(msg.Buffer, ':');
358 if (!pos) return ERR_UNKNOWN;
359 pos++;
360 location = atoi(pos);
361 smprintf(s, "Location : %d\n", location);
362
363 /* Parse name */
364 pos = strchr(pos, '"');
365 if (!pos) return ERR_UNKNOWN;
366 pos++;
367 /* Ringtone.Name size is 20 chars */
368 for (count = 0; count < 19; count++) {
369 if (pos[count] == '"')
370 break;
371 buffer[count] = pos[count];
372 }
373 buffer[count] = 0;
374 smprintf(s, "Name : %s\n", buffer);
375 EncodeUnicode(s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
376
377 /* Parse ringtone length */
378 pos = strchr(pos, ',');
379 if (!pos) return ERR_UNKNOWN;
380 pos++;
381 length = atoi(pos);
382 smprintf(s, "Length : %d\n", length);
383
384 /* S300 ringtones are always MMF */
385 s->Phone.Data.Ringtone->Format = RING_MMF;
386 s->Phone.Data.Ringtone->Location = location;
387 s->Phone.Data.Ringtone->BinaryTone.Length = length;
388
389 return ERR_NONE;
390 case AT_Reply_Error:
391 return ERR_UNKNOWN;
392 case AT_Reply_CMSError:
393 return ATGEN_HandleCMSError(s);
394 case AT_Reply_CMEError:
395 return ATGEN_HandleCMEError(s);
396 default:
397 return ERR_UNKNOWNRESPONSE;
398 }
399}
400
401GSM_Error SAMSUNG_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
402{
403 unsigned char req[100];
404
405 s->Phone.Data.Ringtone = Ringtone;
406 smprintf(s, "Getting ringtone\n");
407 sprintf(req, "AT+MELR=%d\r", Ringtone->Location-1);
408 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
409}
410
411GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
412{
413 smprintf(s, "Ringtone sent\n");
414 return ReplySetSamsungFrame(msg, s);
415}
416
417GSM_Error SAMSUNG_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
418{
419 unsigned charreq[100];
420 unsigned longcrc;
421 GSM_Errorerror;
422 char name[50], *dot;
423
424 s->Phone.Data.Ringtone = Ringtone;
425 smprintf(s, "Setting ringtone\n");
426
427 if (Ringtone->Format != RING_MMF) {
428 smprintf(s, "Not MMF ringtone\n");
429 return ERR_INVALIDDATA;
430 }
431
432 /* Remove extension from file name */
433 strncpy(name, DecodeUnicodeString(Ringtone->Name), 50);
434 if ((dot = strrchr(name, '.')) != NULL) *dot = 0;
435
436 crc = GetCRC(Ringtone->BinaryTone.Buffer, Ringtone->BinaryTone.Length);
437 sprintf(req, "AT+MELW=0,\"%s\",4,%d,%u\r", name,
438 Ringtone->BinaryTone.Length, (unsigned int)crc);
439
440 error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
441 if (error!=ERR_NONE) return error;
442
443 return SetSamsungFrame(s, Ringtone->BinaryTone.Buffer,
444 Ringtone->BinaryTone.Length, ID_SetRingtone);
445}
446
447#endif
diff --git a/gammu/emb/common/phone/at/samsung.h b/gammu/emb/common/phone/at/samsung.h
new file mode 100644
index 0000000..3b2947c
--- a/dev/null
+++ b/gammu/emb/common/phone/at/samsung.h
@@ -0,0 +1,16 @@
1#ifndef samsung_h
2#define samsung_h
3
4#include "../../gsmstate.h"
5
6 GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message, GSM_StateMachine *);
7 GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message, GSM_StateMachine *);
8 GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message, GSM_StateMachine *);
9 GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message, GSM_StateMachine *);
10 GSM_Error SAMSUNG_GetRingtone (GSM_StateMachine *, GSM_Ringtone *, bool);
11 GSM_Error SAMSUNG_SetRingtone (GSM_StateMachine *, GSM_Ringtone *, int *);
12 GSM_Error SAMSUNG_GetBitmap (GSM_StateMachine *, GSM_Bitmap *);
13 GSM_Error SAMSUNG_SetBitmap (GSM_StateMachine *, GSM_Bitmap *);
14 GSM_Error SAMSUNG_GetCallLogs (GSM_StateMachine *, GSM_MemoryEntry *, int);
15
16#endif
diff --git a/gammu/emb/common/phone/at/siemens.c b/gammu/emb/common/phone/at/siemens.c
index ab7dd2c..7f66cf8 100644
--- a/gammu/emb/common/phone/at/siemens.c
+++ b/gammu/emb/common/phone/at/siemens.c
@@ -15,21 +15,7 @@
15 15
16extern GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s); 16#include "atgen.h"
17#include "siemens.h"
17 18
18GSM_Error ATGEN_CMS35ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
19{
20 if (s->Protocol.Data.AT.EditMode) {
21 s->Protocol.Data.AT.EditMode = false;
22 return ERR_NONE;
23 }
24 dbgprintf ("Written %s",function);
25 if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
26 dbgprintf (" - OK\n");
27 return ERR_NONE;
28 } else {
29 dbgprintf (" - error\n");
30 return ERR_UNKNOWN;
31 }
32}
33 19
34GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ, 20static GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ,
35 unsigned char *buffer, int *len) 21 unsigned char *buffer, int *len)
@@ -59,3 +45,3 @@ GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *t
59 45
60GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ, 46static GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ,
61 int Location, GSM_Phone_RequestID RequestID, int len) 47 int Location, GSM_Phone_RequestID RequestID, int len)
@@ -92,3 +78,3 @@ GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ
92 78
93GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) 79GSM_Error SIEMENS_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
94{ 80{
@@ -106,8 +92,24 @@ GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *
106 92
107GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) 93GSM_Error SIEMENS_ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
108{ 94{
109 return ATGEN_CMS35ReplySetFunction (msg, s, "Operator Logo"); 95 if (s->Protocol.Data.AT.EditMode) {
96 s->Protocol.Data.AT.EditMode = false;
97 return ERR_NONE;
98 }
99 dbgprintf ("Written %s",function);
100 if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
101 dbgprintf (" - OK\n");
102 return ERR_NONE;
103 } else {
104 dbgprintf (" - error\n");
105 return ERR_UNKNOWN;
106 }
110} 107}
111 108
112GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 109GSM_Error SIEMENS_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
110{
111 return SIEMENS_ReplySetFunction (msg, s, "Operator Logo");
112}
113
114GSM_Error SIEMENS_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
113{ 115{
@@ -115,3 +117,2 @@ GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
115 117
116 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
117 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; 118 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
@@ -124,3 +125,3 @@ GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
124 125
125GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 126GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
126{ 127{
@@ -130,3 +131,2 @@ GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
130 131
131 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
132 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; 132 if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
@@ -143,3 +143,3 @@ GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
143 143
144GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) 144GSM_Error SIEMENS_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
145{ 145{
@@ -160,3 +160,3 @@ GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine
160 160
161GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 161GSM_Error SIEMENS_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
162{ 162{
@@ -164,4 +164,2 @@ GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool Ph
164 164
165 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
166
167 s->Phone.Data.Ringtone=Ringtone; 165 s->Phone.Data.Ringtone=Ringtone;
@@ -172,8 +170,8 @@ GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool Ph
172 170
173GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) 171GSM_Error SIEMENS_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
174{ 172{
175 return ATGEN_CMS35ReplySetFunction (msg, s, "Ringtone"); 173 return SIEMENS_ReplySetFunction (msg, s, "Ringtone");
176} 174}
177 175
178GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) 176GSM_Error SIEMENS_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
179{ 177{
@@ -181,4 +179,2 @@ GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *ma
181 179
182 if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
183
184 if (Ringtone->Location==255) Ringtone->Location=1; 180 if (Ringtone->Location==255) Ringtone->Location=1;
@@ -192,3 +188,3 @@ GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *ma
192 188
193GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s) 189GSM_Error SIEMENS_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
194{ 190{
@@ -237,8 +233,8 @@ GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
237 233
238GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) 234GSM_Error SIEMENS_ReplyAddCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
239{ 235{
240 return ATGEN_CMS35ReplySetFunction (msg, s, "Calendar Note"); 236 return SIEMENS_ReplySetFunction (msg, s, "Calendar Note");
241} 237}
242 238
243GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) 239GSM_Error SIEMENS_ReplyDelCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
244{ 240{
@@ -285,3 +281,3 @@ GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
285/* (c) by Timo Teras */ 281/* (c) by Timo Teras */
286GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 282GSM_Error SIEMENS_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
287{ 283{
diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c
index 4b2670a..8eeb39b 100644
--- a/gammu/emb/common/phone/at/sonyeric.c
+++ b/gammu/emb/common/phone/at/sonyeric.c
@@ -13,4 +13,4 @@
13 13
14 extern GSM_Reply_Function ATGENReplyFunctions[]; 14#include "atgen.h"
15 extern GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s); 15#include "sonyeric.h"
16 16
@@ -18,8 +18,6 @@ extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
18 18
19 extern GSM_Reply_Function OBEXGENReplyFunctions[]; 19#include "../obex/obexgen.h"
20 extern GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File);
21 extern GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos);
22 extern GSM_Error OBEXGEN_Disconnect(GSM_StateMachine *s);
23 20
24#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 21 extern GSM_Reply_FunctionOBEXGENReplyFunctions[];
22 extern GSM_Reply_FunctionATGENReplyFunctions[];
25 23
@@ -128,3 +126,3 @@ GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
128{ 126{
129#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 127#ifdef GSM_ENABLE_OBEXGEN
130 GSM_Error error; 128 GSM_Error error;
@@ -164,3 +162,3 @@ GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool st
164{ 162{
165#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 163#ifdef GSM_ENABLE_OBEXGEN
166 GSM_Error error; 164 GSM_Error error;
@@ -203,3 +201,3 @@ GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
203{ 201{
204#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 202#ifdef GSM_ENABLE_OBEXGEN
205 GSM_Error error; 203 GSM_Error error;
@@ -234,3 +232,3 @@ GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
234{ 232{
235#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 233#ifdef GSM_ENABLE_OBEXGEN
236 unsigned char req[5000]; 234 unsigned char req[5000];
@@ -250,3 +248,3 @@ GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
250{ 248{
251#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 249#ifdef GSM_ENABLE_OBEXGEN
252 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 250 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
@@ -269,3 +267,3 @@ GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
269{ 267{
270#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 268#ifdef GSM_ENABLE_OBEXGEN
271 GSM_Error error; 269 GSM_Error error;
@@ -321,3 +319,3 @@ GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
321{ 319{
322#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 320#ifdef GSM_ENABLE_OBEXGEN
323 GSM_Error error; 321 GSM_Error error;
@@ -376,3 +374,3 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St
376{ 374{
377#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 375#ifdef GSM_ENABLE_OBEXGEN
378 GSM_Error error; 376 GSM_Error error;
@@ -405,3 +403,114 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St
405 403
406#endif 404GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
405 { /*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 is an easy way to obtain the source under GPL, otherwise the author's parts
408 of this function are GPL 2.0.
409 */
410 GSM_Locale*locale = s->Phone.Data.Locale;
411 char format;
412
413 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
414 case AT_Reply_OK:
415 smprintf(s, "Date settings received\n");
416 format=atoi(msg.Buffer);
417 switch (format) {
418 case 0: locale->DateFormat = GSM_Date_OFF;
419 locale->DateSeparator = 0;
420 break;
421 case 1: locale->DateFormat = GSM_Date_DDMMMYY;
422 locale->DateSeparator = '-';
423 break;
424 case 2: locale->DateFormat = GSM_Date_DDMMYY;
425 locale->DateSeparator = '-';
426 break;
427 case 3: locale->DateFormat = GSM_Date_MMDDYY;
428 locale->DateSeparator = '/';
429 break;
430 case 4: locale->DateFormat = GSM_Date_DDMMYY;
431 locale->DateSeparator = '/';
432 break;
433 case 5: locale->DateFormat = GSM_Date_DDMMYY;
434 locale->DateSeparator = '.';
435 break;
436 case 6: locale->DateFormat = GSM_Date_YYMMDD;
437 locale->DateSeparator = 0;
438 break;
439 case 7: locale->DateFormat = GSM_Date_YYMMDD;
440 locale->DateSeparator = '-';
441 break;
442 default:return ERR_UNKNOWNRESPONSE;
443 }
444 default:
445 return ERR_NOTSUPPORTED;
446 }
447}
448
449GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
450 { /*Author: Peter Ondraska
451 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 of this function are GPL 2.0.
454 */
455 char format;
456
457 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
458 case AT_Reply_OK:
459 smprintf(s, "Time settings received\n");
460 format=atoi(msg.Buffer);
461 switch (format) {
462 case 1:
463 case 2: s->Phone.Data.Locale->AMPMTime=(format==2);
464 return ERR_NONE;
465 default:return ERR_UNKNOWNRESPONSE;
466 }
467 default: return ERR_NOTSUPPORTED;
468 }
469}
470
471GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
472{
473 GSM_Error error;
474
475 s->Phone.Data.Locale = locale;
476
477 smprintf(s, "Getting date format\n");
478 error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale);
479 if (error!=ERR_NONE) return error;
480
481 smprintf(s, "Getting time format\n");
482 return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale);
483}
484
485
486GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
487 { /*Author: Peter Ondraska
488 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 of this function are GPL 2.0.
491 */
492 /* this is not yet supported by gammu.c */
493 intformat=0;
494 charreq[12];
495
496 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_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else
499 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=5; } else
502 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else
503 if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; }
504 else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */
505
506 sprintf(req,"AT+ESDF=%i\r",format);
507 smprintf(s, "Setting date format\n");
508 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
509
510 if (locale->AMPMTime) { format=2; } else { format=1; }
511 sprintf(req,"AT+ESTF=%i\r",format);
512 smprintf(s, "Setting time format\n");
513 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
514}
515
407#endif 516#endif
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c
index beef33c..17cd0a4 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.c
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c
@@ -1,4 +1,7 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail, Pavel Janik, others and Gnokii */
3/* 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)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
4 7
@@ -396,2 +399,3 @@ GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
396 Data->SMSC->Validity.Relative= msg.Buffer[8]; 399 Data->SMSC->Validity.Relative= msg.Buffer[8];
400 if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
397 401
@@ -444,3 +448,3 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s
444 smprintf(s, "Network info received\n"); 448 smprintf(s, "Network info received\n");
445 smprintf(s, " Status : "); 449 smprintf(s, "Status : ");
446 switch (msg.Buffer[8]) { 450 switch (msg.Buffer[8]) {
@@ -453,3 +457,3 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s
453 smprintf(s, "\n"); 457 smprintf(s, "\n");
454 smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); 458 smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
455 if (msg.Buffer[8]<0x03) { 459 if (msg.Buffer[8]<0x03) {
@@ -461,4 +465,4 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s
461 465
462 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
463 NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode); 466 NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode);
467 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
464 smprintf(s, "Network name for Gammu : %s ", 468 smprintf(s, "Network name for Gammu : %s ",
@@ -1210,3 +1214,3 @@ GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
1210 smprintf(s, "SMS sent OK\n"); 1214 smprintf(s, "SMS sent OK\n");
1211 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); 1215 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[5]);
1212 return ERR_NONE; 1216 return ERR_NONE;
@@ -1214,3 +1218,3 @@ GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
1214 smprintf(s, "Error %i\n",msg.Buffer[6]); 1218 smprintf(s, "Error %i\n",msg.Buffer[6]);
1215 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0); 1219 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],-1);
1216 return ERR_NONE; 1220 return ERR_NONE;
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.h b/gammu/emb/common/phone/nokia/dct3/dct3func.h
index 66b67ec..18b2026 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.h
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.h
@@ -5,2 +5,4 @@
5 5
6#include "../ncommon.h"
7
6 GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s); 8 GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s);
diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c
index 263d12b..dac6c12 100644
--- a/gammu/emb/common/phone/nokia/dct3/n6110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n6110.c
@@ -1,5 +1,7 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail and Gnokii */
3/* Authentication function (c) 1999 or earlier by Pavel Janik */
4/* 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)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
5 7
@@ -129,2 +131,3 @@ static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const
129 131
132/* Pavel Janik */
130/* This function provides Nokia authentication protocol. 133/* This function provides Nokia authentication protocol.
@@ -826,2 +829,3 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
826 case RING_MIDI: 829 case RING_MIDI:
830 case RING_MMF:
827 return ERR_NOTSUPPORTED; 831 return ERR_NOTSUPPORTED;
@@ -1526,2 +1530,3 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
1526 case RING_MIDI: 1530 case RING_MIDI:
1531 case RING_MMF:
1527 return ERR_NOTSUPPORTED; 1532 return ERR_NOTSUPPORTED;
@@ -1563,2 +1568,3 @@ static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
1563 case RING_MIDI: 1568 case RING_MIDI:
1569 case RING_MMF:
1564 return ERR_NOTSUPPORTED; 1570 return ERR_NOTSUPPORTED;
@@ -2445,4 +2451,4 @@ GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
2445 2451
2446 tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, msg.Buffer+8, buffer); 2452 tmp=GSM_UnpackEightBitsToSeven(0, msg.Buffer[7], 82, msg.Buffer+8, buffer);
2447 msg.Buffer[tmp] = 0; 2453 buffer[tmp] = 0;
2448 2454
@@ -2809,2 +2815,3 @@ GSM_Phone_Functions N6110Phone = {
2809 NOTSUPPORTED, /* SendSavedSMS */ 2815 NOTSUPPORTED, /* SendSavedSMS */
2816 NOTSUPPORTED, /* SetFastSMSSending*/
2810 NOKIA_SetIncomingSMS, 2817 NOKIA_SetIncomingSMS,
@@ -2863,3 +2870,3 @@ GSM_Phone_Functions N6110Phone = {
2863 NOTSUPPORTED, /* SetCalendarSettings */ 2870 NOTSUPPORTED, /* SetCalendarSettings */
2864 NOTSUPPORTED, /* GetNote */ 2871 NOTSUPPORTED, /* GetNextNote */
2865 N6110_GetProfile, 2872 N6110_GetProfile,
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c
index 5a02c9c..b597f9b 100644
--- a/gammu/emb/common/phone/nokia/dct3/n7110.c
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.c
@@ -1,3 +1,6 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail and Gnokii */ 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
4 * GNU GPL version 2 or later
5 */
3 6
@@ -528,2 +531,3 @@ static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
528 case RING_MIDI: 531 case RING_MIDI:
532 case RING_MMF:
529 return ERR_NOTSUPPORTED; 533 return ERR_NOTSUPPORTED;
@@ -1649,2 +1653,3 @@ GSM_Phone_Functions N7110Phone = {
1649 NOTSUPPORTED, /* SendSavedSMS */ 1653 NOTSUPPORTED, /* SendSavedSMS */
1654 NOTSUPPORTED, /* SetFastSMSSending*/
1650 N7110_SetIncomingSMS, 1655 N7110_SetIncomingSMS,
@@ -1703,3 +1708,3 @@ GSM_Phone_Functions N7110Phone = {
1703 NOTSUPPORTED, /* SetCalendarSettings*/ 1708 NOTSUPPORTED, /* SetCalendarSettings*/
1704 NOTSUPPORTED, /* GetNote */ 1709 NOTSUPPORTED, /* GetNextNote */
1705 N7110_GetProfile, 1710 N7110_GetProfile,
diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c
index e82d530..ff71ad3 100644
--- a/gammu/emb/common/phone/nokia/dct3/n9210.c
+++ b/gammu/emb/common/phone/nokia/dct3/n9210.c
@@ -321,2 +321,3 @@ GSM_Phone_Functions N9210Phone = {
321 NOTSUPPORTED, /* SendSavedSMS */ 321 NOTSUPPORTED, /* SendSavedSMS */
322 NOTSUPPORTED, /* SetFastSMSSending*/
322 N9210_SetIncomingSMS, 323 N9210_SetIncomingSMS,
@@ -375,3 +376,3 @@ GSM_Phone_Functions N9210Phone = {
375 NOTSUPPORTED, /* SetCalendarSettings*/ 376 NOTSUPPORTED, /* SetCalendarSettings*/
376 NOTSUPPORTED, /* GetNote */ 377 NOTSUPPORTED, /* GetNextNote */
377 NOTIMPLEMENTED, /* GetProfile */ 378 NOTIMPLEMENTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3320.c b/gammu/emb/common/phone/nokia/dct4/n3320.c
index 51e6f18..9b1d6cd 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3320.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3320.c
@@ -196,2 +196,3 @@ GSM_Phone_Functions N3320Phone = {
196 NOTSUPPORTED, /* SendSavedSMS */ 196 NOTSUPPORTED, /* SendSavedSMS */
197 NOTSUPPORTED, /* SetFastSMSSending*/
197 NOTSUPPORTED, /* SetIncomingSMS */ 198 NOTSUPPORTED, /* SetIncomingSMS */
@@ -250,3 +251,3 @@ GSM_Phone_Functions N3320Phone = {
250 NOTSUPPORTED, /* SetCalendarSettings*/ 251 NOTSUPPORTED, /* SetCalendarSettings*/
251 NOTSUPPORTED, /* GetNote */ 252 NOTSUPPORTED, /* GetNextNote */
252 NOTSUPPORTED, /* GetProfile */ 253 NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/dct4/n3650.c b/gammu/emb/common/phone/nokia/dct4/n3650.c
index 2da55bf..d4746a7 100644
--- a/gammu/emb/common/phone/nokia/dct4/n3650.c
+++ b/gammu/emb/common/phone/nokia/dct4/n3650.c
@@ -317,2 +317,3 @@ GSM_Phone_Functions N3650Phone = {
317 NOTSUPPORTED, /* SendSavedSMS */ 317 NOTSUPPORTED, /* SendSavedSMS */
318 NOTSUPPORTED, /* SetFastSMSSending*/
318 NOTSUPPORTED, /* SetIncomingSMS */ 319 NOTSUPPORTED, /* SetIncomingSMS */
@@ -371,3 +372,3 @@ GSM_Phone_Functions N3650Phone = {
371 NOTSUPPORTED, /* SetCalendarSettings*/ 372 NOTSUPPORTED, /* SetCalendarSettings*/
372 NOTSUPPORTED, /* GetNote */ 373 NOTSUPPORTED, /* GetNextNote */
373 NOTSUPPORTED, /* GetProfile */ 374 NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.c b/gammu/emb/common/phone/nokia/dct4/n6510.c
index 67fe492..2208def 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.c
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.c
@@ -1,3 +1,6 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail, Pawel Kot and Gnokii */ 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
4 * GNU GPL version 2 or later
5 */
3/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */ 6/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */
@@ -121,2 +124,4 @@ static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *
121 Data->SMSC->Validity.Relative= msg.Buffer[12]; 124 Data->SMSC->Validity.Relative= msg.Buffer[12];
125 if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
126
122 current = 14; 127 current = 14;
@@ -267,3 +272,3 @@ static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMa
267 272
268 smprintf(s, "Network status: "); 273 smprintf(s, "Network status : ");
269 switch (msg.Buffer[8]) { 274 switch (msg.Buffer[8]) {
@@ -987,2 +992,3 @@ static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateM
987 smprintf(s, "Operator logo received\n"); 992 smprintf(s, "Operator logo received\n");
993 if (msg.Length == 18) return ERR_EMPTY;
988 NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode); 994 NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode);
@@ -991,3 +997,2 @@ static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateM
991 Data->Bitmap->BitmapHeight= msg.Buffer[21]; 997 Data->Bitmap->BitmapHeight= msg.Buffer[21];
992 if (msg.Length == 18) return ERR_EMPTY;
993 PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap); 998 PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap);
@@ -1767,3 +1772,4 @@ static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings
1767 settings->Name[1] = 0; 1772 settings->Name[1] = 0;
1768 //s->Phone.Data.SyncMLSettings = settings; 1773 s->Phone.Data.SyncMLSettings = settings;
1774
1769 //smprintf(s, "Getting SyncML settings name\n"); 1775 //smprintf(s, "Getting SyncML settings name\n");
@@ -2285,3 +2291,3 @@ static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMa
2285 case 0x00: 2291 case 0x00:
2286 smprintf(s, "SMS sent OK, TPMR for sent sms is %02x\n",msg.Buffer[10]); 2292 smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]);
2287 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]); 2293 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]);
@@ -2772,2 +2778,3 @@ static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
2772 case RING_MIDI: 2778 case RING_MIDI:
2779 case RING_MMF:
2773 return ERR_NOTSUPPORTED; 2780 return ERR_NOTSUPPORTED;
@@ -2988,2 +2995,5 @@ static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
2988 } 2995 }
2996 if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) {
2997 return ERR_NOTSUPPORTED;
2998 }
2989 2999
@@ -3117,5 +3127,17 @@ static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShow
3117{ 3127{
3128 unsigned int pos2 = 15;
3118 unsigned intpos = 4; 3129 unsigned intpos = 4;
3130 unsigned char req2[100] = {N6110_FRAME_HEADER,0x01,
3131 0x00,0x02,0x07,0x04,
3132 0x01, // 1 - voice, 2 - data
3133 0x00,0x03,
3134 0x18, // length of rest + 1
3135 0x00,0x00,0x00};
3119 unsigned char req[100] = {N6110_FRAME_HEADER,0x01, 3136 unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
3120 0x0c};/* Number length */ 3137 0x0c};/* Number length */
3138 GSM_Errorerror;
3139
3140 /* USSD not supported */
3141 if (number[0] == '*') return ERR_NOTSUPPORTED;
3142 if (number[0] == '#') return ERR_NOTSUPPORTED;
3121 3143
@@ -3142,5 +3164,17 @@ static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShow
3142 } 3164 }
3165 smprintf(s, "Making voice call\n");
3166 error = GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
3167 if (error != ERR_NOTSUPPORTED) return error;
3168
3169 if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
3170
3171 req2[11] = strlen(number)*2+6;
3172 req2[pos2++] = strlen(number);
3173 EncodeUnicode(req2+pos2,number,strlen(number));
3174 pos2 += strlen(number)*2;
3143 3175
3144 smprintf(s, "Making voice call\n"); 3176 smprintf(s, "Making voice call\n");
3145 return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice); 3177 error = GSM_WaitFor (s, req2, pos2, 0x01, 4, ID_DialVoice);
3178 if (error == ERR_NOTSUPPORTED) return ERR_NONE;
3179 return error;
3146} 3180}
@@ -3176,5 +3210,5 @@ static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_State
3176/* method 3 */ 3210/* method 3 */
3177static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, bool Calendar) 3211static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, char Type)
3178{ 3212{
3179 GSM_Error error; 3213 GSM_Error error = ERR_UNKNOWN;
3180 int i; 3214 int i;
@@ -3182,3 +3216,3 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc
3182 0x00, 0x00,/* First location */ 3216 0x00, 0x00,/* First location */
3183 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style */ 3217 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style, 2 = Notes */
3184 3218
@@ -3187,9 +3221,12 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc
3187 3221
3188 if (Calendar) { 3222 req[10] = Type;
3223 if (Type == 0) {
3189 smprintf(s, "Getting locations for calendar method 3\n"); 3224 smprintf(s, "Getting locations for calendar method 3\n");
3190 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo); 3225 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
3191 } else { 3226 } else if (Type == 1) {
3192 req[10] = 0x01;
3193 smprintf(s, "Getting locations for ToDo method 2\n"); 3227 smprintf(s, "Getting locations for ToDo method 2\n");
3194 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo); 3228 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
3229 } else if (Type == 2) {
3230 smprintf(s, "Getting locations for Notes\n");
3231 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
3195 } 3232 }
@@ -3209,8 +3246,11 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc
3209 req[9] = Last->Location[i-1] % 256; 3246 req[9] = Last->Location[i-1] % 256;
3210 if (Calendar) { 3247 if (Type == 0) {
3211 smprintf(s, "Getting locations for calendar method 3\n"); 3248 smprintf(s, "Getting locations for calendar method 3\n");
3212 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo); 3249 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
3213 } else { 3250 } else if (Type == 1) {
3214 smprintf(s, "Getting locations for todo method 2\n"); 3251 smprintf(s, "Getting locations for todo method 2\n");
3215 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo); 3252 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
3253 } else if (Type == 2) {
3254 smprintf(s, "Getting locations for Notes\n");
3255 error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
3216 } 3256 }
@@ -3352,2 +3392,14 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
3352 3392
3393static GSM_Error N6510_PrivGetGenericCalendar3(GSM_StateMachine *s, int Location, GSM_Phone_RequestID ID)
3394{
3395 unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
3396 0x00,0x99,/* Location */
3397 0xff,0xff,0xff,0xff};
3398
3399 req[8] = Location / 256;
3400 req[9] = Location % 256;
3401
3402 return GSM_WaitFor (s, req, 14, 0x13, 4, ID);
3403}
3404
3353static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear) 3405static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear)
@@ -3356,5 +3408,2 @@ static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *
3356 GSM_DateTime date_time; 3408 GSM_DateTime date_time;
3357 unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
3358 0x00,0x99,/* Location */
3359 0xff,0xff,0xff,0xff,0x01};
3360 3409
@@ -3381,8 +3430,5 @@ static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *
3381 3430
3382 req[8] = Note->Location / 256;
3383 req[9] = Note->Location % 256;
3384
3385 s->Phone.Data.Cal=Note; 3431 s->Phone.Data.Cal=Note;
3386 smprintf(s, "Getting calendar note method 3\n"); 3432 smprintf(s, "Getting calendar note method 3\n");
3387 return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetCalendarNote); 3433 return N6510_PrivGetGenericCalendar3(s, Note->Location, ID_GetCalendarNote);
3388} 3434}
@@ -3396,3 +3442,3 @@ GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, b
3396 if (start) { 3442 if (start) {
3397 error=N6510_GetCalendarInfo3(s,LastCalendar,true); 3443 error=N6510_GetCalendarInfo3(s,LastCalendar,0);
3398 if (error!=ERR_NONE) return error; 3444 if (error!=ERR_NONE) return error;
@@ -3479,3 +3525,3 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr
3479 3525
3480 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true); 3526 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
3481 memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations)); 3527 memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
@@ -3496,3 +3542,3 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr
3496 3542
3497 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true); 3543 error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
3498 memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations)); 3544 memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
@@ -3739,3 +3785,3 @@ static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus
3739 /* Method 3 */ 3785 /* Method 3 */
3740 error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,true); 3786 error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0);
3741 if (error!=ERR_NONE) return error; 3787 if (error!=ERR_NONE) return error;
@@ -3974,2 +4020,38 @@ static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable)
3974 4020
4021static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
4022{
4023 return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote);
4024}
4025
4026static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
4027{
4028 smprintf(s, "Note received\n");
4029 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;
4031 s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0;
4032 return ERR_NONE;
4033}
4034
4035GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start)
4036{
4037 GSM_Error error;
4038 GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
4039
4040 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
4041
4042 if (start) {
4043 error=N6510_GetCalendarInfo3(s,LastNote,2);
4044 if (error!=ERR_NONE) return error;
4045 Note->Location = 1;
4046 } else {
4047 Note->Location++;
4048 }
4049
4050 if (Note->Location > LastNote->Number) return ERR_EMPTY;
4051
4052 s->Phone.Data.Note = Note;
4053 smprintf(s, "Getting note\n");
4054 return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote);
4055}
4056
3975static int N6510_FindFileCheckSum(unsigned char *ptr, int len) 4057static int N6510_FindFileCheckSum(unsigned char *ptr, int len)
@@ -4057,3 +4139,3 @@ static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_Stat
4057 File->Type = GSM_File_Java_JAR; 4139 File->Type = GSM_File_Java_JAR;
4058#if DEVELOP 4140#ifdef DEVELOP
4059 else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01) 4141 else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01)
@@ -4400,3 +4482,3 @@ static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos
4400 error = N6510_SearchForFileName(s,File); 4482 error = N6510_SearchForFileName(s,File);
4401 if (error == ERR_NONE) return ERR_INVALIDLOCATION; 4483 if (error == ERR_NONE) return ERR_FILEALREADYEXIST;
4402 if (error != ERR_EMPTY) return error; 4484 if (error != ERR_EMPTY) return error;
@@ -4816,3 +4898,3 @@ static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *statu
4816 4898
4817 error = N6510_GetCalendarInfo3(s,LastToDo,false); 4899 error = N6510_GetCalendarInfo3(s,LastToDo,1);
4818 if (error!=ERR_NONE) return error; 4900 if (error!=ERR_NONE) return error;
@@ -4946,4 +5028,3 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine
4946 5028
4947 if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) 5029 if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) {
4948 {
4949 smprintf(s, "No alarm\n"); 5030 smprintf(s, "No alarm\n");
@@ -4980,10 +5061,5 @@ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bo
4980 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5061 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4981 /* The same to getting calendar method 3 */
4982 unsigned char req[] = {
4983 N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
4984 0x00,0x99, /* Location */
4985 0xff,0xff,0xff,0xff,0x01};
4986 5062
4987 if (refresh) { 5063 if (refresh) {
4988 error=N6510_GetCalendarInfo3(s,LastToDo,false); 5064 error=N6510_GetCalendarInfo3(s,LastToDo,1);
4989 if (error!=ERR_NONE) return error; 5065 if (error!=ERR_NONE) return error;
@@ -4996,8 +5072,5 @@ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bo
4996 5072
4997 req[8] = LastToDo->Location[ToDo->Location-1] / 256;
4998 req[9] = LastToDo->Location[ToDo->Location-1] % 256;
4999
5000 s->Phone.Data.ToDo = ToDo; 5073 s->Phone.Data.ToDo = ToDo;
5001 smprintf(s, "Getting todo method 2\n"); 5074 smprintf(s, "Getting todo method 2\n");
5002 return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetToDo); 5075 return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo);
5003} 5076}
@@ -5045,3 +5118,3 @@ static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5045 5118
5046 error=N6510_GetCalendarInfo3(s,LastToDo,false); 5119 error=N6510_GetCalendarInfo3(s,LastToDo,1);
5047 if (error!=ERR_NONE) return error; 5120 if (error!=ERR_NONE) return error;
@@ -5453,2 +5526,5 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5453 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame }, 5526 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
5527 {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame },
5528 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice },
5529 {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame },
5454 {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame }, 5530 {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
@@ -5460,2 +5536,5 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5460 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF }, 5536 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
5537 {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame },
5538 {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame },
5539 {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame },
5461 5540
@@ -5510,2 +5589,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5510 {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo }, 5589 {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo },
5590 {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote },
5511 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings }, 5591 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings },
@@ -5517,2 +5597,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5517 {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo }, 5597 {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo },
5598 {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote },
5518 5599
@@ -5653,3 +5734,3 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5653GSM_Phone_Functions N6510Phone = { 5734GSM_Phone_Functions N6510Phone = {
5654 "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6800|7210|7250|7250i|7600|8310|8390|8910|8910i", 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",
5655 N6510ReplyFunctions, 5736 N6510ReplyFunctions,
@@ -5707,2 +5788,3 @@ GSM_Phone_Functions N6510Phone = {
5707 NOTSUPPORTED, /* SendSavedSMS */ 5788 NOTSUPPORTED, /* SendSavedSMS */
5789 NOTSUPPORTED, /* SetFastSMSSending*/
5708 NOKIA_SetIncomingSMS, 5790 NOKIA_SetIncomingSMS,
@@ -5761,3 +5843,3 @@ GSM_Phone_Functions N6510Phone = {
5761 NOTSUPPORTED, /* SetCalendarSettings*/ 5843 NOTSUPPORTED, /* SetCalendarSettings*/
5762 NOTIMPLEMENTED, /* GetNote */ 5844 N6510_GetNextNote,
5763 N6510_GetProfile, 5845 N6510_GetProfile,
diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.h b/gammu/emb/common/phone/nokia/dct4/n6510.h
index 4717aeb..26623d6 100644
--- a/gammu/emb/common/phone/nokia/dct4/n6510.h
+++ b/gammu/emb/common/phone/nokia/dct4/n6510.h
@@ -36,2 +36,4 @@ typedef struct {
36 36
37 GSM_NOKIACalToDoLocationsLastNote;
38
37 unsigned char RingtoneID;/* When set with preview */ 39 unsigned char RingtoneID;/* When set with preview */
diff --git a/gammu/emb/common/phone/nokia/nauto.c b/gammu/emb/common/phone/nokia/nauto.c
index bf74bc9..3bb53ec 100644
--- a/gammu/emb/common/phone/nokia/nauto.c
+++ b/gammu/emb/common/phone/nokia/nauto.c
@@ -123,3 +123,3 @@ GSM_Phone_Functions NAUTOPhone = {
123 NOTSUPPORTED, /* SetCalendarSettings*/ 123 NOTSUPPORTED, /* SetCalendarSettings*/
124 NOTSUPPORTED, /* GetNote */ 124 NOTSUPPORTED, /* GetNextNote */
125 NOTSUPPORTED, /* GetProfile */ 125 NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/nokia/nfunc.c b/gammu/emb/common/phone/nokia/nfunc.c
index 3acfb10..d4d8b03 100644
--- a/gammu/emb/common/phone/nokia/nfunc.c
+++ b/gammu/emb/common/phone/nokia/nfunc.c
@@ -1395,2 +1395,7 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1395 break; 1395 break;
1396 case 0x0f:
1397 case 0x10:
1398 smprintf(s, "Meaning not known\n");
1399 call.CallIDAvailable = false;
1400 break;
1396 case 0x23: 1401 case 0x23:
@@ -1418,2 +1423,8 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1418 break; 1423 break;
1424 case 0xA6:
1425 case 0xD2:
1426 case 0xD3:
1427 smprintf(s, "Meaning not known\n");
1428 call.CallIDAvailable = false;
1429 break;
1419 } 1430 }
@@ -1424,2 +1435,5 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1424 } 1435 }
1436 if (s->Phone.Data.RequestID == ID_DialVoice) {
1437 if (msg.Buffer[3] == 0x10) return ERR_NOTSUPPORTED;
1438 }
1425 if (s->Phone.Data.RequestID == ID_CancelCall) { 1439 if (s->Phone.Data.RequestID == ID_CancelCall) {
diff --git a/gammu/emb/common/phone/obex/obexgen.c b/gammu/emb/common/phone/obex/obexgen.c
index dd14f8e..3106369 100644
--- a/gammu/emb/common/phone/obex/obexgen.c
+++ b/gammu/emb/common/phone/obex/obexgen.c
@@ -776,2 +776,3 @@ GSM_Phone_Functions OBEXGENPhone = {
776 NOTSUPPORTED, /* SendSavedSMS */ 776 NOTSUPPORTED, /* SendSavedSMS */
777 NOTSUPPORTED, /* SetFastSMSSending*/
777 NOTIMPLEMENTED, /* SetIncomingSMS */ 778 NOTIMPLEMENTED, /* SetIncomingSMS */
@@ -830,3 +831,3 @@ GSM_Phone_Functions OBEXGENPhone = {
830 NOTSUPPORTED, /* SetCalendarSettings*/ 831 NOTSUPPORTED, /* SetCalendarSettings*/
831 NOTSUPPORTED, /* GetNote */ 832 NOTSUPPORTED, /* GetNextNote */
832 NOTIMPLEMENTED, /* GetProfile */ 833 NOTIMPLEMENTED, /* GetProfile */
diff --git a/gammu/emb/common/phone/obex/obexgen.h b/gammu/emb/common/phone/obex/obexgen.h
index 466fef5..b7033de 100644
--- a/gammu/emb/common/phone/obex/obexgen.h
+++ b/gammu/emb/common/phone/obex/obexgen.h
@@ -33,2 +33,6 @@ typedef struct {
33 33
34 GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File);
35 GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos);
36 GSM_Error OBEXGEN_Disconnect(GSM_StateMachine *s);
37
34#endif 38#endif
diff --git a/gammu/emb/common/phone/symbian/mroutgen.c b/gammu/emb/common/phone/symbian/mroutgen.c
index 2c339be..a7382cf 100644
--- a/gammu/emb/common/phone/symbian/mroutgen.c
+++ b/gammu/emb/common/phone/symbian/mroutgen.c
@@ -145,2 +145,3 @@ GSM_Phone_Functions MROUTERGENPhone = {
145 NOTSUPPORTED, /* SendSavedSMS */ 145 NOTSUPPORTED, /* SendSavedSMS */
146 NOTSUPPORTED, /* SetFastSMSSending*/
146 NOTSUPPORTED, /* SetIncomingSMS */ 147 NOTSUPPORTED, /* SetIncomingSMS */
@@ -199,3 +200,3 @@ GSM_Phone_Functions MROUTERGENPhone = {
199 NOTSUPPORTED, /* SetCalendarSettings*/ 200 NOTSUPPORTED, /* SetCalendarSettings*/
200 NOTSUPPORTED, /* GetNote */ 201 NOTSUPPORTED, /* GetNextNote */
201 NOTSUPPORTED, /* GetProfile */ 202 NOTSUPPORTED, /* GetProfile */
diff --git a/gammu/emb/common/protocol/at/at.c b/gammu/emb/common/protocol/at/at.c
index f4a75b7..f8ddc06 100644
--- a/gammu/emb/common/protocol/at/at.c
+++ b/gammu/emb/common/protocol/at/at.c
@@ -68,3 +68,3 @@ static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
68 {"+CMTI:" ,1}, {"+CDS:",2}, 68 {"+CMTI:" ,1}, {"+CDS:",2},
69 {"+CREG:",1}, 69 {"+CREG:" ,1}, {"+CUSD",1},
70 70
@@ -74,4 +74,8 @@ static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
74 74
75 {"SDNDCRC =" ,1},/* Samsung binary transfer end */
76
75 {NULL ,1}}; 77 {NULL ,1}};
76 78
79//printf("%c",rx_char);
80
77 /* Ignore leading CR, LF and ESC */ 81 /* Ignore leading CR, LF and ESC */
diff --git a/gammu/emb/common/protocol/nokia/fbus2.c b/gammu/emb/common/protocol/nokia/fbus2.c
index 8b3e024..2b41f8b 100644
--- a/gammu/emb/common/protocol/nokia/fbus2.c
+++ b/gammu/emb/common/protocol/nokia/fbus2.c
@@ -1,3 +1,7 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* based on some work from Gnokii and MyGnokii */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3/* Based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
diff --git a/gammu/emb/common/protocol/nokia/fbus2.h b/gammu/emb/common/protocol/nokia/fbus2.h
index 5dd45d7..8dbcb07 100644
--- a/gammu/emb/common/protocol/nokia/fbus2.h
+++ b/gammu/emb/common/protocol/nokia/fbus2.h
@@ -1,3 +1,7 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* based on some work from Gnokii and MyGnokii */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3/* Based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
diff --git a/gammu/emb/common/protocol/nokia/mbus2.c b/gammu/emb/common/protocol/nokia/mbus2.c
index f07d6c5..8353b46 100644
--- a/gammu/emb/common/protocol/nokia/mbus2.c
+++ b/gammu/emb/common/protocol/nokia/mbus2.c
@@ -1,3 +1,3 @@
1/* (c) 2001-2003 by Marcin Wiacek */ 1/* (c) 2001-2003 by Marcin Wiacek */
2/* based on some work from MyGnokii */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3 3
diff --git a/gammu/emb/common/protocol/nokia/mbus2.h b/gammu/emb/common/protocol/nokia/mbus2.h
index 86fcab6..5dbd8cb 100644
--- a/gammu/emb/common/protocol/nokia/mbus2.h
+++ b/gammu/emb/common/protocol/nokia/mbus2.h
@@ -1,3 +1,3 @@
1/* (c) 2001-2003 by Marcin Wiacek */ 1/* (c) 2001-2003 by Marcin Wiacek */
2/* based on some work from MyGnokii */ 2/* based on some work from MyGnokii (www.mwiacek.com) */
3 3
diff --git a/gammu/emb/common/protocol/nokia/phonet.c b/gammu/emb/common/protocol/nokia/phonet.c
index bc5717d..db5bd72 100644
--- a/gammu/emb/common/protocol/nokia/phonet.c
+++ b/gammu/emb/common/protocol/nokia/phonet.c
@@ -1,3 +1,6 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* based on some work from Gnokii */ 2/* Based on some work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
diff --git a/gammu/emb/common/protocol/nokia/phonet.h b/gammu/emb/common/protocol/nokia/phonet.h
index 2f6e836..e750bbd 100644
--- a/gammu/emb/common/protocol/nokia/phonet.h
+++ b/gammu/emb/common/protocol/nokia/phonet.h
@@ -1,3 +1,6 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2/* based on some work from Gnokii */ 2/* Based on some work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
diff --git a/gammu/emb/common/service/backup/backgen.h b/gammu/emb/common/service/backup/backgen.h
index 9d7d973..9a930fc 100644
--- a/gammu/emb/common/service/backup/backgen.h
+++ b/gammu/emb/common/service/backup/backgen.h
@@ -23,2 +23,4 @@
23 #define GSM_BACKUP_MAX_MMSSETTINGS30 23 #define GSM_BACKUP_MAX_MMSSETTINGS30
24 #define GSM_BACKUP_MAX_SYNCMLSETTINGS10
25 #define GSM_BACKUP_MAX_CHATSETTINGS10
24 #define GSM_BACKUP_MAX_RINGTONES30 26 #define GSM_BACKUP_MAX_RINGTONES30
@@ -45,2 +47,4 @@ typedef struct {
45 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];
49 GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
46 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1]; 50 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1];
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c
index fee0f73..4cb1bb7 100644
--- a/gammu/emb/common/service/backup/backtext.c
+++ b/gammu/emb/common/service/backup/backtext.c
@@ -153,3 +153,3 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
153 153
154 fwrite(myvalue,1,UnicodeLength(myvalue)*2,file); 154 fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
155 155
@@ -159,3 +159,3 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
159 } else { 159 } else {
160 sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10); 160 sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
161 fprintf(file,"%s",buffer); 161 fprintf(file,"%s",buffer);
@@ -170,3 +170,3 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
170{ 170{
171 unsigned char paramname[10000],*readvalue; 171 unsigned char paramname[10000],*readvalue;
172 172
@@ -176,5 +176,6 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
176 if (readvalue!=NULL) { 176 if (readvalue!=NULL) {
177 CopyUnicodeString(myvalue,readvalue+2); 177 CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
178 myvalue[UnicodeLength(readvalue)*2-4]=0; 178 myvalue[UnicodeLength(myvalue)*2-2]=0;
179 myvalue[UnicodeLength(readvalue)*2-3]=0; 179 myvalue[UnicodeLength(myvalue)*2-1]=0;
180
180 dbgprintf("%s\n",DecodeUnicodeString(readvalue)); 181 dbgprintf("%s\n",DecodeUnicodeString(readvalue));
@@ -199,3 +200,3 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
199 if (readvalue!=NULL) { 200 if (readvalue!=NULL) {
200 EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2); 201 EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
201 } else { 202 } else {
@@ -420,2 +421,13 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
420 421
422static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
423{
424 char buffer[1000];
425
426 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
427 SaveBackupText(file, "", buffer, UseUnicode);
428 SaveBackupText(file, "Text", Note->Text, UseUnicode);
429 sprintf(buffer, "%c%c",13,10);
430 SaveBackupText(file, "", buffer, UseUnicode);
431}
432
421static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode) 433static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
@@ -435,5 +447,5 @@ static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnico
435 case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break; 447 case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
436 case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break; 448 case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
437 case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break; 449 case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
438 case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break; 450 case GSM_CAL_DAILY_ALARM: sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
439 case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break; 451 case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
@@ -659,2 +671,44 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
659 671
672static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
673{
674 char buffer[10000];
675
676 sprintf(buffer,"HomePage");
677 SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
678 sprintf(buffer,"User");
679 SaveBackupText(file, buffer, settings->User, UseUnicode);
680 sprintf(buffer,"Password");
681 SaveBackupText(file, buffer, settings->Password, UseUnicode);
682 SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
683}
684
685static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
686{
687 char buffer[10000];
688
689 sprintf(buffer,"User");
690 SaveBackupText(file, buffer, settings->User, UseUnicode);
691 sprintf(buffer,"Password");
692 SaveBackupText(file, buffer, settings->Password, UseUnicode);
693 sprintf(buffer,"PhonebookDB");
694 SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
695 sprintf(buffer,"CalendarDB");
696 SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
697 sprintf(buffer,"Server");
698 SaveBackupText(file, buffer, settings->Server, UseUnicode);
699 if (settings->SyncPhonebook) {
700 sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
701 } else {
702 sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
703 }
704 SaveBackupText(file, "", buffer, UseUnicode);
705 if (settings->SyncCalendar) {
706 sprintf(buffer,"SyncCalendar = True%c%c",13,10);
707 } else {
708 sprintf(buffer,"SyncCalendar = False%c%c",13,10);
709 }
710 SaveBackupText(file, "", buffer, UseUnicode);
711 SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
712}
713
660static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) 714static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
@@ -766,4 +820,3 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
766{ 820{
767 unsigned char buffer[45000]; 821 unsigned char buffer[45000];
768 int i,j;
769 822
@@ -774,3 +827,2 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
774 case RING_NOKIABINARY: 827 case RING_NOKIABINARY:
775 j = 0; i = 0;
776 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); 828 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
@@ -779,3 +831,2 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
779 case RING_MIDI: 831 case RING_MIDI:
780 j = 0; i = 0;
781 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); 832 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
@@ -783,2 +834,6 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
783 break; 834 break;
835 case RING_MMF:
836 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
837 SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
838 break;
784 case RING_NOTETONE: 839 case RING_NOTETONE:
@@ -1077,2 +1132,9 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1077 i=0; 1132 i=0;
1133 while (backup->Note[i]!=NULL) {
1134 sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
1135 SaveBackupText(file, "", buffer, UseUnicode);
1136 SaveNoteEntry(file, backup->Note[i], UseUnicode);
1137 i++;
1138 }
1139 i=0;
1078 while (backup->CallerLogos[i]!=NULL) { 1140 while (backup->CallerLogos[i]!=NULL) {
@@ -1112,2 +1174,16 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1112 i=0; 1174 i=0;
1175 while (backup->SyncMLSettings[i]!=NULL) {
1176 sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
1177 SaveBackupText(file, "", buffer, UseUnicode);
1178 SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
1179 i++;
1180 }
1181 i=0;
1182 while (backup->ChatSettings[i]!=NULL) {
1183 sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
1184 SaveBackupText(file, "", buffer, UseUnicode);
1185 SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
1186 i++;
1187 }
1188 i=0;
1113 while (backup->Ringtone[i]!=NULL) { 1189 while (backup->Ringtone[i]!=NULL) {
@@ -2658,3 +2734,128 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
2658 } 2734 }
2659 2735 for (h = file_info; h != NULL; h = h->Next) {
2736 found = false;
2737 if (UseUnicode) {
2738 EncodeUnicode(buffer,"Backup",4);
2739 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2740 } else {
2741 if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
2742 }
2743 if (UseUnicode) {
2744 EncodeUnicode(buffer,"Checksum",4);
2745 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2746 } else {
2747 if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
2748 }
2749 if (UseUnicode) {
2750 EncodeUnicode(buffer,"Profile",7);
2751 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2752 } else {
2753 if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
2754 }
2755 if (UseUnicode) {
2756 EncodeUnicode(buffer,"PhonePBK",8);
2757 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2758 } else {
2759 if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
2760 }
2761 if (UseUnicode) {
2762 EncodeUnicode(buffer,"SIMPBK",6);
2763 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2764 } else {
2765 if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
2766 }
2767 if (UseUnicode) {
2768 EncodeUnicode(buffer,"Calendar",8);
2769 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2770 } else {
2771 if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
2772 }
2773 if (UseUnicode) {
2774 EncodeUnicode(buffer,"Caller",6);
2775 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2776 } else {
2777 if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
2778 }
2779 if (UseUnicode) {
2780 EncodeUnicode(buffer,"SMSC",4);
2781 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2782 } else {
2783 if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
2784 }
2785 if (UseUnicode) {
2786 EncodeUnicode(buffer,"WAPBookmark",11);
2787 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2788 if (!found) {
2789 EncodeUnicode(buffer,"Bookmark",8);
2790 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2791 }
2792 } else {
2793 if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
2794 if (!found) {
2795 if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
2796 }
2797 }
2798 if (UseUnicode) {
2799 EncodeUnicode(buffer,"WAPSettings",11);
2800 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2801 if (!found) {
2802 EncodeUnicode(buffer,"Settings",8);
2803 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2804 }
2805 } else {
2806 if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
2807 if (!found) {
2808 if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
2809 }
2810 }
2811 if (UseUnicode) {
2812 EncodeUnicode(buffer,"MMSSettings",8);
2813 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2814 } else {
2815 if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
2816 }
2817 if (UseUnicode) {
2818 EncodeUnicode(buffer,"Ringtone",8);
2819 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2820 } else {
2821 if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
2822 }
2823 if (UseUnicode) {
2824 EncodeUnicode(buffer,"TODO",4);
2825 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2826 } else {
2827 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
2828 }
2829 if (UseUnicode) {
2830 EncodeUnicode(buffer,"Startup",7);
2831 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2832 } else {
2833 if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
2834 }
2835 if (UseUnicode) {
2836 EncodeUnicode(buffer,"Operator",7);
2837 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2838 } else {
2839 if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
2840 }
2841 if (UseUnicode) {
2842 EncodeUnicode(buffer,"FMStation",9);
2843 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2844 } else {
2845 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
2846 }
2847 if (UseUnicode) {
2848 EncodeUnicode(buffer,"GPRSPoint",9);
2849 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2850 } else {
2851 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
2852 }
2853 if (UseUnicode) {
2854 EncodeUnicode(buffer,"Note",4);
2855 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2856 } else {
2857 if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
2858 }
2859 if (!found) return ERR_NOTIMPLEMENTED;
2860 }
2660 return ERR_NONE; 2861 return ERR_NONE;
diff --git a/gammu/emb/common/service/backup/gsmback.c b/gammu/emb/common/service/backup/gsmback.c
index 91ac745..c94a4d2 100644
--- a/gammu/emb/common/service/backup/gsmback.c
+++ b/gammu/emb/common/service/backup/gsmback.c
@@ -75,2 +75,14 @@ void GSM_FreeBackup(GSM_Backup *backup)
75 i=0; 75 i=0;
76 while (backup->SyncMLSettings[i]!=NULL) {
77 free(backup->SyncMLSettings[i]);
78 backup->SyncMLSettings[i] = NULL;
79 i++;
80 }
81 i=0;
82 while (backup->ChatSettings[i]!=NULL) {
83 free(backup->ChatSettings[i]);
84 backup->ChatSettings[i] = NULL;
85 i++;
86 }
87 i=0;
76 while (backup->Ringtone[i]!=NULL) { 88 while (backup->Ringtone[i]!=NULL) {
@@ -122,11 +134,11 @@ GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode
122{ 134{
123 if (strstr(FileName,".lmb")) { 135 if (mystrcasestr(FileName,".lmb")) {
124 return SaveLMB(FileName,backup); 136 return SaveLMB(FileName,backup);
125 } else if (strstr(FileName,".vcs")) { 137 } else if (mystrcasestr(FileName,".vcs")) {
126 return SaveVCalendar(FileName,backup); 138 return SaveVCalendar(FileName,backup);
127 } else if (strstr(FileName,".vcf")) { 139 } else if (mystrcasestr(FileName,".vcf")) {
128 return SaveVCard(FileName,backup); 140 return SaveVCard(FileName,backup);
129 } else if (strstr(FileName,".ldif")) { 141 } else if (mystrcasestr(FileName,".ldif")) {
130 return SaveLDIF(FileName,backup); 142 return SaveLDIF(FileName,backup);
131 } else if (strstr(FileName,".ics")) { 143 } else if (mystrcasestr(FileName,".ics")) {
132 return SaveICS(FileName,backup); 144 return SaveICS(FileName,backup);
@@ -150,9 +162,9 @@ GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
150 /* Attempt to identify filetype */ 162 /* Attempt to identify filetype */
151 if (strstr(FileName,".vcs")) { 163 if (mystrcasestr(FileName,".vcs")) {
152 return LoadVCalendar(FileName,backup); 164 return LoadVCalendar(FileName,backup);
153 } else if (strstr(FileName,".vcf")) { 165 } else if (mystrcasestr(FileName,".vcf")) {
154 return LoadVCard(FileName,backup); 166 return LoadVCard(FileName,backup);
155 } else if (strstr(FileName,".ldif")) { 167 } else if (mystrcasestr(FileName,".ldif")) {
156 return LoadLDIF(FileName,backup); 168 return LoadLDIF(FileName,backup);
157 } else if (strstr(FileName,".ics")) { 169 } else if (mystrcasestr(FileName,".ics")) {
158 return LoadICS(FileName,backup); 170 return LoadICS(FileName,backup);
@@ -179,2 +191,4 @@ void GSM_ClearBackup(GSM_Backup *backup)
179 backup->MMSSettings[0] = NULL; 191 backup->MMSSettings[0] = NULL;
192 backup->SyncMLSettings[0] = NULL;
193 backup->ChatSettings[0] = NULL;
180 backup->Ringtone[0] = NULL; 194 backup->Ringtone[0] = NULL;
@@ -211,2 +225,4 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
211 info->MMSSettings = false; 225 info->MMSSettings = false;
226 info->SyncMLSettings = false;
227 info->ChatSettings = false;
212 info->Ringtone = false; 228 info->Ringtone = false;
@@ -248,2 +264,4 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
248 info->MMSSettings = true; 264 info->MMSSettings = true;
265 info->SyncMLSettings = true;
266 info->ChatSettings = true;
249 info->Ringtone = true; 267 info->Ringtone = true;
diff --git a/gammu/emb/common/service/backup/gsmback.h b/gammu/emb/common/service/backup/gsmback.h
index 1fd99b0..791e81d 100644
--- a/gammu/emb/common/service/backup/gsmback.h
+++ b/gammu/emb/common/service/backup/gsmback.h
@@ -31,2 +31,4 @@ typedef struct {
31 bool MMSSettings; 31 bool MMSSettings;
32 bool SyncMLSettings;
33 bool ChatSettings;
32 bool Ringtone; 34 bool Ringtone;
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h
index 067a4a4..0a41b7b 100644
--- a/gammu/emb/common/service/gsmcal.h
+++ b/gammu/emb/common/service/gsmcal.h
@@ -407,3 +407,3 @@ typedef struct {
407 int Location; 407 int Location;
408 char Text[100]; 408 char Text[3000*2];
409} GSM_NoteEntry; 409} GSM_NoteEntry;
diff --git a/gammu/emb/common/service/gsmdata.c b/gammu/emb/common/service/gsmdata.c
index 94e9b7b..9303b57 100644
--- a/gammu/emb/common/service/gsmdata.c
+++ b/gammu/emb/common/service/gsmdata.c
@@ -248,2 +248,4 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W
248/* http://forum.nokia.com: OTA Settings 7.0 */ 248/* http://forum.nokia.com: OTA Settings 7.0 */
249/* first it used default/ISO coding */
250/* Joergen Thomsen changed to UTF8 */
249void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark) 251void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark)
@@ -251,6 +253,6 @@ void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPB
251 unsigned charbuffer[100]; 253 unsigned charbuffer[100];
252 bool UnicodeCoding = false;
253 254
254 EncodeUTF8QuotedPrintable(buffer,bookmark->Title); 255 // bool UnicodeCoding = false;
255 if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true; 256 //EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
257 //if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
256 258
@@ -267,11 +269,18 @@ void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPB
267 269
270 /* removed by Joergen Thomsen */
268 /* Block from sniffs. UNKNOWN */ 271 /* Block from sniffs. UNKNOWN */
269 if (!UnicodeCoding) { 272 //if (!UnicodeCoding) {
270 Buffer[(*Length)++] = 0x00; 273 // Buffer[(*Length)++] = 0x00;
271 Buffer[(*Length)++] = 0x01; 274 // Buffer[(*Length)++] = 0x01;
272 } else { 275 //} else {
273 strcpy(Buffer+(*Length),"\x01\x01\x87\x68"); 276 // strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
274 (*Length)=(*Length)+4; 277 // (*Length)=(*Length)+4;
275 } 278 //}
276 Buffer[(*Length)++] = 0x00; 279 //Buffer[(*Length)++] = 0x00;
280
281 /* added by Joergen Thomsen */
282 Buffer[(*Length)++] = 0x01; // Version WBXML 1.1
283 Buffer[(*Length)++] = 0x01; // Unknown public identifier
284 Buffer[(*Length)++] = 0x6A; // charset UTF-8
285 Buffer[(*Length)++] = 0x00; // string table length
277 286
@@ -282,15 +291,84 @@ void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPB
282 Buffer[(*Length)++] = 0x01; //END PARMeter 291 Buffer[(*Length)++] = 0x01; //END PARMeter
283 if (!UnicodeCoding) { 292
284 /* TITLE */ 293 /* removed by Joergen Thomsen */
285 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title)); 294 // if (!UnicodeCoding) {
286 /* URL */ 295 // /* TITLE */
287 AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address)); 296 // AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
288 } else { 297 // /* URL */
289 /* TITLE */ 298 // AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
290 AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1); 299 // } else {
291 /* URL */ 300 // /* TITLE */
292 AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1); 301 // AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
302 // /* URL */
303 // AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
304 // }
305
306 /* added by Joergen Thomsen */
307 /* TITLE */
308 EncodeUTF8(buffer, bookmark->Title);
309 AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer));
310 /* URL */
311 EncodeUTF8(buffer, bookmark->Address);
312 AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer));
313
314 Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC)
315 Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC-LIST)
316}
317
318void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL)
319{
320 int i;
321
322 Buffer[(*Length)++] = 0x01; //Push ID
323 Buffer[(*Length)++] = 0x06; //PDU Type (push)
324 Buffer[(*Length)++] = 28; //Headers length (content type + headers)
325 strcpy(Buffer+(*Length),"\x1F\x23");
326 (*Length)=(*Length)+2; //Value length
327 strcpy(Buffer+(*Length),"application/vnd.wap.sic");
328 (*Length)=(*Length)+23; //MIME-Type
329 Buffer[(*Length)++] = 0x00; //end inline string
330 strcpy(Buffer+(*Length),"\x81\xEA");
331 (*Length)=(*Length)+2; //charset UTF-8 short int.
332
333 Buffer[(*Length)++] = 0x02; // WBXML 1.2
334 Buffer[(*Length)++] = 0x05; // SI 1.0 Public Identifier
335 Buffer[(*Length)++] = 0x6A; // charset UTF-8
336 Buffer[(*Length)++] = 0x00; // string table length
337 Buffer[(*Length)++] = 0x45; // SI with content
338 Buffer[(*Length)++] = 0xC6; // indication with content and attributes
339 Buffer[(*Length)++] = 0x0B;// address
340 Buffer[(*Length)++] = 0x03; // Inline string
341 for (i=0;i<(int)strlen(URL);i++) {
342 Buffer[(*Length)++] = URL[i];//Text
293 } 343 }
294 Buffer[(*Length)++] = 0x01; //END PARMeter 344 Buffer[(*Length)++] = 0x00; // END Inline string
295 Buffer[(*Length)++] = 0x01; //END PARMeter 345
346#ifdef XXX
347 Buffer[(*Length)++] = 0x0A;// created...
348 Buffer[(*Length)++] = 0xC3;// OPAQUE
349 Buffer[(*Length)++] = 0x07;// length
350 Buffer[(*Length)++] = 0x19;// year
351 Buffer[(*Length)++] = 0x80;// year
352 Buffer[(*Length)++] = 0x21;// month
353 Buffer[(*Length)++] = 0x12;// ..
354 Buffer[(*Length)++] = 0x00;// ..
355 Buffer[(*Length)++] = 0x00;// ..
356 Buffer[(*Length)++] = 0x00;// ..
357 Buffer[(*Length)++] = 0x10;// expires
358 Buffer[(*Length)++] = 0xC3;// OPAQUE
359 Buffer[(*Length)++] = 0x04;// length
360 Buffer[(*Length)++] = 0x20;// year
361 Buffer[(*Length)++] = 0x10;// year
362 Buffer[(*Length)++] = 0x06;// month
363 Buffer[(*Length)++] = 0x25;// day
364#endif
365
366 Buffer[(*Length)++] = 0x01; // END (indication)
367 Buffer[(*Length)++] = 0x03; // Inline string
368 for (i=0;i<(int)strlen(Text);i++) {
369 Buffer[(*Length)++] = Text[i];//Text
370 }
371 Buffer[(*Length)++] = 0x00; // END Inline string
372 Buffer[(*Length)++] = 0x01; // END (indication)
373 Buffer[(*Length)++] = 0x01; // END (SI)
296} 374}
diff --git a/gammu/emb/common/service/gsmdata.h b/gammu/emb/common/service/gsmdata.h
index f5f8e07..e81589f 100644
--- a/gammu/emb/common/service/gsmdata.h
+++ b/gammu/emb/common/service/gsmdata.h
@@ -90,2 +90,4 @@ void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIn
90 90
91void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL);
92
91/* ------------------------------ MMS file --------------------------------- */ 93/* ------------------------------ MMS file --------------------------------- */
diff --git a/gammu/emb/common/service/gsmlogo.c b/gammu/emb/common/service/gsmlogo.c
index c992915..7c19967 100644
--- a/gammu/emb/common/service/gsmlogo.c
+++ b/gammu/emb/common/service/gsmlogo.c
@@ -4,2 +4,3 @@
4#include <stdlib.h> 4#include <stdlib.h>
5#include <sys/stat.h>
5 6
@@ -163,2 +164,3 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B
163 Bitmap->ID = 0; 164 Bitmap->ID = 0;
165 Bitmap->Name = NULL;
164 166
@@ -628,13 +630,13 @@ GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
628 /* Attempt to identify filetype */ 630 /* Attempt to identify filetype */
629 if (strstr(FileName,".nlm")) { 631 if (mystrcasestr(FileName,".nlm")) {
630 error=savenlm(file,bitmap); 632 error=savenlm(file,bitmap);
631 } else if (strstr(FileName,".ngg")) { 633 } else if (mystrcasestr(FileName,".ngg")) {
632 error=savengg(file,bitmap); 634 error=savengg(file,bitmap);
633 } else if (strstr(FileName,".nol")) { 635 } else if (mystrcasestr(FileName,".nol")) {
634 error=savenol(file,bitmap); 636 error=savenol(file,bitmap);
635 } else if (strstr(FileName,".xpm")) { 637 } else if (mystrcasestr(FileName,".xpm")) {
636 error=savexpm(file,bitmap); 638 error=savexpm(file,bitmap);
637 } else if (strstr(FileName,".nsl")) { 639 } else if (mystrcasestr(FileName,".nsl")) {
638 error=savensl(file,bitmap); 640 error=savensl(file,bitmap);
639 } else if (strstr(FileName,".wbmp")) { 641 } else if (mystrcasestr(FileName,".wbmp")) {
640 error=savewbmp(file,bitmap); 642 error=savewbmp(file,bitmap);
@@ -957,2 +959,29 @@ static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
957 959
960static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
961{
962 GSM_Bitmap *bmap = &bitmap->Bitmap[0];
963 char *buffer;
964 struct stat st;
965 int length;
966
967 dbgprintf("loading gif file\n");
968 fstat(fileno(file), &st);
969 bmap->BinaryPic.Length = length = st.st_size;
970 bmap->BinaryPic.Buffer = buffer = malloc(length);
971 if (bmap->BinaryPic.Buffer == NULL)
972 return ERR_MOREMEMORY;
973
974 fread(buffer, 1, length, file);
975 dbgprintf("Length %i name \"%s\"\n", length,
976 DecodeUnicodeString(bmap->Name));
977
978 bmap->Type = GSM_PictureBinary;
979 bmap->BinaryPic.Type = PICTURE_GIF;
980 bmap->BitmapWidth = 256 * buffer[7] + buffer[6];
981 bmap->BitmapHeight = 256 * buffer[9] + buffer[8];
982 bitmap->Number = 1;
983
984 return ERR_NONE;
985}
986
958GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) 987GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
@@ -965,2 +994,6 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
965 994
995 bitmap->Bitmap[0].Name = malloc((strlen(FileName) + 1) * 2);
996 if (bitmap->Bitmap[0].Name == NULL) return ERR_MOREMEMORY;
997 EncodeUnicode(bitmap->Bitmap[0].Name, FileName, strlen(FileName));
998
966 fread(buffer, 1, 9, file); /* Read the header of the file. */ 999 fread(buffer, 1, 9, file); /* Read the header of the file. */
@@ -983,2 +1016,4 @@ GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
983 return loadnsl(file,bitmap); 1016 return loadnsl(file,bitmap);
1017 } else if (memcmp(buffer, "GIF",3)==0) {
1018 return loadgif(file,bitmap);
984 } 1019 }
diff --git a/gammu/emb/common/service/gsmlogo.h b/gammu/emb/common/service/gsmlogo.h
index b1b579d..6c6e2d8 100644
--- a/gammu/emb/common/service/gsmlogo.h
+++ b/gammu/emb/common/service/gsmlogo.h
@@ -7,2 +7,16 @@
7 7
8typedef enum {
9 PICTURE_BMP = 1,
10 PICTURE_GIF,
11 PICTURE_JPG,
12 PICTURE_ICN,
13 PICTURE_PNG
14} GSM_BinaryPicture_Types;
15
16typedef struct {
17 GSM_BinaryPicture_Types Type;
18 unsigned char *Buffer;
19 int Length;
20} GSM_BinaryPicture;
21
8/** 22/**
@@ -47,3 +61,7 @@ typedef enum {
47 */ 61 */
48 GSM_PictureImage 62 GSM_PictureImage,
63 /**
64 * Binary picture (BMP, GIF, etc.)
65 */
66 GSM_PictureBinary
49} GSM_Bitmap_Types; 67} GSM_Bitmap_Types;
@@ -117,2 +135,10 @@ typedef struct {
117 unsigned char ID; 135 unsigned char ID;
136 /**
137 * For binary pictures (GIF, BMP, etc.): frame and length
138 */
139 GSM_BinaryPicture BinaryPic;
140 /**
141 * Bitmap name
142 */
143 char *Name;
118} GSM_Bitmap; 144} GSM_Bitmap;
diff --git a/gammu/emb/common/service/gsmmisc.h b/gammu/emb/common/service/gsmmisc.h
index 37501ad..793d3d1 100644
--- a/gammu/emb/common/service/gsmmisc.h
+++ b/gammu/emb/common/service/gsmmisc.h
@@ -294,3 +294,8 @@ typedef enum {
294 GSM_Date_MMDDYYYY, 294 GSM_Date_MMDDYYYY,
295 GSM_Date_YYYYMMDD 295 GSM_Date_YYYYMMDD,
296 GSM_Date_DDMMMYY,
297 GSM_Date_MMDDYY,
298 GSM_Date_DDMMYY,
299 GSM_Date_YYMMDD,
300 GSM_Date_OFF
296} GSM_DateFormat; 301} GSM_DateFormat;
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index 7df46f1..dab028c 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -1,4 +1,6 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* Based on some work from Ralf Thelen (7110 ringtones), 2/* Based on some work from Ralf Thelen (7110 ringtones) and others */
3 * Gnokii (RTTL and SM) and others 3/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
4 */ 6 */
@@ -9,2 +11,3 @@
9#include <math.h> 11#include <math.h>
12#include <sys/stat.h>
10#ifdef WIN32 13#ifdef WIN32
@@ -158,2 +161,8 @@ static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
158 161
162static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
163{
164 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
165 return ERR_NONE;
166}
167
159GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) 168GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
@@ -487,2 +496,5 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
487 break; 496 break;
497 case RING_MMF:
498 savemmf(file, ringtone);
499 break;
488 } 500 }
@@ -771,2 +783,22 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
771 783
784static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
785{
786 struct stat st;
787 char *buffer;
788 int length;
789
790 dbgprintf("loading smaf file\n");
791 fstat(fileno(file), &st);
792 ringtone->BinaryTone.Length = length = st.st_size;
793 ringtone->BinaryTone.Buffer = buffer = malloc(length);
794 if (buffer == NULL)
795 return ERR_MOREMEMORY;
796 fread(buffer, 1, length, file);
797
798 dbgprintf("Length %i name \"%s\"\n", length,
799 DecodeUnicodeString(ringtone->Name));
800
801 return ERR_NONE;
802}
803
772static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) 804static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
@@ -818,2 +850,6 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
818 } 850 }
851 if (buffer[0]==0x4D && buffer[1]==0x4D &&
852 buffer[2]==0x4D && buffer[3]==0x44) {
853 ringtone->Format = RING_MMF;
854 }
819 } 855 }
@@ -844,2 +880,7 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
844 error = loadpuremidi(file,ringtone); 880 error = loadpuremidi(file,ringtone);
881 break;
882 case RING_MMF:
883 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
884 error = loadmmf(file,ringtone);
885 break;
845 } 886 }
diff --git a/gammu/emb/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h
index 207cf31..2d2dd7a 100644
--- a/gammu/emb/common/service/gsmring.h
+++ b/gammu/emb/common/service/gsmring.h
@@ -122,5 +122,6 @@ typedef struct {
122 122
123/* FIXME: should use BinaryTone instead? */
123/* Structure to hold Nokia binary ringtones. */ 124/* Structure to hold Nokia binary ringtones. */
124typedef struct { 125typedef struct {
125 unsigned char Frame[30000]; 126 unsigned char Frame[50000];
126 int Length; 127 int Length;
@@ -129,3 +130,3 @@ typedef struct {
129typedef struct { 130typedef struct {
130 unsigned char *Frame; 131 unsigned char *Buffer;
131 int Length; 132 int Length;
@@ -136,3 +137,4 @@ typedef enum {
136 RING_NOKIABINARY, 137 RING_NOKIABINARY,
137 RING_MIDI 138 RING_MIDI,
139 RING_MMF
138} GSM_RingtoneFormat; 140} GSM_RingtoneFormat;
diff --git a/gammu/emb/common/service/sms/gsmmulti.c b/gammu/emb/common/service/sms/gsmmulti.c
index 6c1cdcd..bdb5ee9 100644
--- a/gammu/emb/common/service/sms/gsmmulti.c
+++ b/gammu/emb/common/service/sms/gsmmulti.c
@@ -489,2 +489,7 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info,
489 break; 489 break;
490 case SMS_WAPIndicatorLong:
491 Class= 1;
492 UDH= UDH_MMSIndicatorLong;
493 GSM_EncodeWAPIndicatorSMSText(Buffer,&Length,Info->Entries[0].MMSIndicator->Title,Info->Entries[0].MMSIndicator->Address);
494 break;
490 case SMS_NokiaRingtoneLong: 495 case SMS_NokiaRingtoneLong:
diff --git a/gammu/emb/common/service/sms/gsmmulti.h b/gammu/emb/common/service/sms/gsmmulti.h
index c672261..3f70d81 100644
--- a/gammu/emb/common/service/sms/gsmmulti.h
+++ b/gammu/emb/common/service/sms/gsmmulti.h
@@ -5,2 +5,6 @@
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
@@ -174,3 +178,3 @@ typedef enum {
174 SMS_EMSSound10Long, 178 SMS_EMSSound10Long,
175 /*** 179 /**
176 * IMelody 1.2 with UPI. 180 * IMelody 1.2 with UPI.
@@ -192,2 +196,3 @@ typedef enum {
192 SMS_MMSIndicatorLong, 196 SMS_MMSIndicatorLong,
197 SMS_WAPIndicatorLong,
193 /** 198 /**
@@ -266,2 +271,6 @@ GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT,
266 271
272#if defined(_MSC_VER) && defined(__cplusplus)
273 }
274#endif
275
267#endif 276#endif
diff --git a/gammu/emb/common/service/sms/gsmsms.c b/gammu/emb/common/service/sms/gsmsms.c
index 9920835..feceba4 100644
--- a/gammu/emb/common/service/sms/gsmsms.c
+++ b/gammu/emb/common/service/sms/gsmsms.c
@@ -1,3 +1,6 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */ 2/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
diff --git a/gammu/emb/common/service/sms/gsmsms.h b/gammu/emb/common/service/sms/gsmsms.h
index d87ff60..0b950d3 100644
--- a/gammu/emb/common/service/sms/gsmsms.h
+++ b/gammu/emb/common/service/sms/gsmsms.h
@@ -1,3 +1,6 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */ 2/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
diff --git a/gammu/emb/gammu/depend/nokia/dct3.c b/gammu/emb/gammu/depend/nokia/dct3.c
index d4a55da..b9e47ea 100644
--- a/gammu/emb/gammu/depend/nokia/dct3.c
+++ b/gammu/emb/gammu/depend/nokia/dct3.c
@@ -612,6 +612,10 @@ void DCT3GetSecurityCode(int argc, char *argv[])
612{ 612{
613#ifdef GSM_ENABLE_NOKIA6110
613 unsigned char req6110[] = {0x00, 0x01, 0x6e, 614 unsigned char req6110[] = {0x00, 0x01, 0x6e,
614 0x01};/* Code type */ 615 0x01};/* Code type */
616#endif
617#if defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
615 unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee, 618 unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee,
616 0x1c};/* Setting */ 619 0x1c};/* Setting */
620#endif
617 621
@@ -769,4 +773,6 @@ void DCT3DisplayOutput(int argc, char *argv[])
769static GSM_Reply_Function UserReplyFunctions3[] = { 773static GSM_Reply_Function UserReplyFunctions3[] = {
774#ifdef GSM_ENABLE_NOKIA6110
770 {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame}, 775 {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame},
771 {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 }, 776 {DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 },
777#endif
772 778
diff --git a/gammu/emb/gammu/depend/nokia/dct4.c b/gammu/emb/gammu/depend/nokia/dct4.c
index f4ed305..4bf958d 100644
--- a/gammu/emb/gammu/depend/nokia/dct4.c
+++ b/gammu/emb/gammu/depend/nokia/dct4.c
@@ -37,3 +37,4 @@ GSM_Error CheckDCT4Only()
37 s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE && 37 s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE &&
38 s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET) { 38 s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET &&
39 s.ConnectionType!=GCT_FBUS2DKU5) {
39 return ERR_OTHERCONNECTIONREQUIRED; 40 return ERR_OTHERCONNECTIONREQUIRED;
@@ -887,2 +888,4 @@ void DCT4GetT9(int argc, char *argv[])
887 888
889#ifdef GSM_ENABLE_NOKIA6510
890
888extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable); 891extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable);
@@ -923,2 +926,3 @@ void DCT4SetLight(int argc, char *argv[])
923} 926}
927#endif
924 928
@@ -1023,2 +1027,4 @@ void DCT4GetADC(int argc, char *argv[])
1023 1027
1028#ifdef GSM_ENABLE_NOKIA6510
1029
1024 static double RadioFreq; 1030 static double RadioFreq;
@@ -1176,2 +1182,3 @@ void DCT4TuneRadio(int argc, char *argv[])
1176} 1182}
1183#endif
1177 1184
@@ -1315,2 +1322,3 @@ static GSM_Reply_Function UserReplyFunctions4[] = {
1315 1322
1323#ifdef GSM_ENABLE_NOKIA6510
1316 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3}, 1324 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3},
@@ -1319,2 +1327,3 @@ static GSM_Reply_Function UserReplyFunctions4[] = {
1319 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3}, 1327 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3},
1328#endif
1320 1329
diff --git a/gammu/emb/gammu/depend/nokia/dct4.h b/gammu/emb/gammu/depend/nokia/dct4.h
index fde5b08..fae809f 100644
--- a/gammu/emb/gammu/depend/nokia/dct4.h
+++ b/gammu/emb/gammu/depend/nokia/dct4.h
@@ -8,5 +8,2 @@ void DCT4SetVibraLevel (int argc, char *argv[]);
8void DCT4GetSecurityCode (int argc, char *argv[]); 8void DCT4GetSecurityCode (int argc, char *argv[]);
9#ifdef DEBUG
10void DCT4ResetSecurityCode (int argc, char *argv[]);
11#endif
12 void DCT4GetVoiceRecord (int argc, char *argv[]); 9 void DCT4GetVoiceRecord (int argc, char *argv[]);
@@ -14,3 +11,2 @@ void DCT4Info (int argc, char *argv[]);
14 void DCT4GetT9 (int argc, char *argv[]); 11 void DCT4GetT9 (int argc, char *argv[]);
15 void DCT4SetLight (int argc, char *argv[]);
16 void DCT4DisplayTest (int argc, char *argv[]); 12 void DCT4DisplayTest (int argc, char *argv[]);
@@ -18,3 +14,2 @@ void DCT4GetADC (int argc, char *argv[]);
18 void DCT4VibraTest (int argc, char *argv[]); 14 void DCT4VibraTest (int argc, char *argv[]);
19 void DCT4TuneRadio (int argc, char *argv[]);
20void DCT4PlaySavedRingtone (int argc, char *argv[]); 15void DCT4PlaySavedRingtone (int argc, char *argv[]);
@@ -23,2 +18,10 @@ void DCT4GetScreenDump (int argc, char *argv[]);
23 18
19#ifdef DEBUG
20 void DCT4ResetSecurityCode (int argc, char *argv[]);
21#endif
22#ifdef GSM_ENABLE_NOKIA6510
23 void DCT4SetLight (int argc, char *argv[]);
24 void DCT4TuneRadio (int argc, char *argv[]);
25#endif
26
24/* ------------------- features matrix ------------------------------------- */ 27/* ------------------- features matrix ------------------------------------- */
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index 997485a..f49ae36 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -11,3 +11,2 @@
11#include <wchar.h> 11#include <wchar.h>
12#undef HAVE_MYSQL_MYSQL_H
13#ifdef WIN32 12#ifdef WIN32
@@ -50,23 +49,11 @@
50 49
51 //static GSM_StateMachine s; 50 GSM_StateMachine s;
52 //static GSM_Phone_Functions *Phone; 51 GSM_Phone_Functions *Phone;
53 static INI_Section *cfg = NULL; 52 static INI_Section *cfg = NULL;
54 53
55 //static GSM_Error error = ERR_NONE; 54 GSM_Error error = ERR_NONE;
56 static int i; 55 static int i;
57 56
58 //static bool gshutdown = false; 57 volatile bool gshutdown = false;
59typedef struct {
60 unsigned char Connection[50];
61} OneConnectionInfo;
62 58
63typedef struct {
64 unsigned char Device[50];
65 OneConnectionInfo Connections[6];
66 //GSM_StateMachines;
67} OneDeviceInfo;
68
69 static int num;
70 static OneDeviceInfo SearchDevices[100];
71 static bool SearchOutput;
72void interrupt(int sign) 59void interrupt(int sign)
@@ -245,2 +232,3 @@ static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
245} 232}
233
246static void PlayRingtone(int argc, char *argv[]) 234static void PlayRingtone(int argc, char *argv[])
@@ -343,3 +331,2 @@ static void Identify(int argc, char *argv[])
343 331
344//#if 0
345static void GetDateTime(int argc, char *argv[]) 332static void GetDateTime(int argc, char *argv[])
@@ -377,2 +364,3 @@ static void GetDateTime(int argc, char *argv[])
377 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD"); 364 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
365 default :break;
378 } 366 }
@@ -589,4 +577,5 @@ static void GetMemory(int argc, char *argv[])
589{ 577{
590 int j, start, stop; 578 int j, start, stop, emptynum = 0, fillednum = 0;
591 GSM_MemoryEntry entry; 579 GSM_MemoryEntry entry;
580 bool empty = true;
592 581
@@ -609,2 +598,11 @@ static void GetMemory(int argc, char *argv[])
609 598
599 if (argc > 5 && strcmp(argv[5],"")) {
600 if (mystrncasecmp(argv[5],"-nonempty",0)) {
601 empty = false;
602 } else {
603 printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]);
604 exit (-1);
605 }
606 }
607
610 GSM_Init(true); 608 GSM_Init(true);
@@ -616,3 +614,3 @@ static void GetMemory(int argc, char *argv[])
616 for (j=start;j<=stop;j++) { 614 for (j=start;j<=stop;j++) {
617 printmsg("Memory %s, Location %i\n",argv[2],j); 615 if (empty) printmsg("Memory %s, Location %i\n",argv[2],j);
618 616
@@ -624,5 +622,10 @@ static void GetMemory(int argc, char *argv[])
624 if (error == ERR_EMPTY) { 622 if (error == ERR_EMPTY) {
625 printmsg("Entry is empty\n"); 623 emptynum++;
626 printf("\n"); 624 if (empty) {
625 printmsg("Entry is empty\n");
626 printf("\n");
627 }
627 } else { 628 } else {
629 fillednum++;
630 if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j);
628 PrintMemoryEntry(&entry); 631 PrintMemoryEntry(&entry);
@@ -630,2 +633,4 @@ static void GetMemory(int argc, char *argv[])
630 } 633 }
634
635 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
631 636
@@ -676,3 +681,3 @@ static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
676 case PBK_Caller_Group : 681 case PBK_Caller_Group :
677 if (mystrstr(Entry->Entries[i].Text, Text) != NULL) { 682 if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) {
678 fprintf(stderr,"\n"); 683 fprintf(stderr,"\n");
@@ -826,3 +831,3 @@ static void ListMemoryCategory(int argc, char *argv[])
826 count++; 831 count++;
827 if (mystrstr(Category.Name, Text) != NULL) { 832 if (mywstrstr(Category.Name, Text) != NULL) {
828 ListMemoryCategoryEntries(j); 833 ListMemoryCategoryEntries(j);
@@ -849,3 +854,3 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
849 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number)); 854 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
850 printmsg("Reference number: 0x%02X\n",sms.MessageReference); 855 printmsg("Reference number: %d\n",sms.MessageReference);
851 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true)); 856 printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
@@ -896,5 +901,9 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
896 printmsg("SMS message\n"); 901 printmsg("SMS message\n");
897 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number)); 902 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
898 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)"); 903 printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true));
899 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true)); 904 } else {
905 printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
906 if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
907 printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
908 }
900 /* No break. The only difference for SMS_Deliver and SMS_Submit is, 909 /* No break. The only difference for SMS_Deliver and SMS_Submit is,
@@ -908,3 +917,6 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
908 printmsg("SMS message\n"); 917 printmsg("SMS message\n");
909 printmsg("Reference number : 0x%02X\n",sms.MessageReference); 918 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
919 } else {
920 printmsg("Reference number : %d\n",sms.MessageReference);
921 }
910 } 922 }
@@ -922,10 +934,13 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
922 } 934 }
935 if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
936 } else {
937 printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
938 }
923 printmsg("Status : "); 939 printmsg("Status : ");
924 switch (sms.State) { 940 switch (sms.State) {
925 case SMS_Sent : printmsg("Sent");break; 941 case SMS_Sent : printmsg("Sent\n");break;
926 case SMS_Read : printmsg("Read");break; 942 case SMS_Read : printmsg("Read\n");break;
927 case SMS_UnRead : printmsg("UnRead");break; 943 case SMS_UnRead : printmsg("UnRead\n");break;
928 case SMS_UnSent : printmsg("UnSent");break; 944 case SMS_UnSent : printmsg("UnSent\n");break;
929 } 945 }
930 printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
931 if (sms.UDH.Type != UDH_NoUDH) { 946 if (sms.UDH.Type != UDH_NoUDH) {
@@ -980,3 +995,3 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
980} 995}
981//#if 0 996
982static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems) 997static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
@@ -1287,2 +1302,9 @@ static void Monitor(int argc, char *argv[])
1287 1302
1303static void IncomingUSSD2(char *Device, char *Buffer)
1304{
1305 printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
1306
1307 gshutdown = true;
1308}
1309
1288static void GetUSSD(int argc, char *argv[]) 1310static void GetUSSD(int argc, char *argv[])
@@ -1294,3 +1316,3 @@ static void GetUSSD(int argc, char *argv[])
1294 1316
1295 s.User.IncomingUSSD = IncomingUSSD; 1317 s.User.IncomingUSSD = IncomingUSSD2;
1296 1318
@@ -1347,3 +1369,12 @@ static void GetSMSC(int argc, char *argv[])
1347 case SMS_VALID_Max_Time: printmsg("Maximum time"); break; 1369 case SMS_VALID_Max_Time: printmsg("Maximum time"); break;
1348 default : printmsg("Unknown"); 1370 default :
1371 if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) {
1372 printmsg("%i minutes",(smsc.Validity.Relative+1)*5);
1373 } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) {
1374 printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30);
1375 } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) {
1376 printmsg("%i days",smsc.Validity.Relative-166);
1377 } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) {
1378 printmsg("%i weeks",smsc.Validity.Relative-192);
1379 }
1349 } 1380 }
@@ -1430,3 +1461,2 @@ static void GetAllSMS(int argc, char *argv[])
1430 1461
1431 fprintf(stderr,"Reading: ");
1432 while (error == ERR_NONE) { 1462 while (error == ERR_NONE) {
@@ -1450,3 +1480,2 @@ static void GetAllSMS(int argc, char *argv[])
1450 } 1480 }
1451 fprintf(stderr,"*");
1452 start=false; 1481 start=false;
@@ -1581,3 +1610,4 @@ static void GetRingtone(int argc, char *argv[])
1581 case RING_NOKIABINARY : printmsg("Nokia binary");break; 1610 case RING_NOKIABINARY : printmsg("Nokia binary");break;
1582 case RING_MIDI : printmsg("Midi format");break; 1611 case RING_MIDI : printmsg("MIDI"); break;
1612 case RING_MMF : printmsg("SMAF (MMF)");break;
1583 } 1613 }
@@ -2044,4 +2074,4 @@ static void GetAllCalendar(int argc, char *argv[])
2044 if (error == ERR_EMPTY) break; 2074 if (error == ERR_EMPTY) break;
2045 PrintCalendar(&Note);
2046 Print_Error(error); 2075 Print_Error(error);
2076 PrintCalendar(&Note);
2047 refresh=false; 2077 refresh=false;
@@ -2244,2 +2274,4 @@ static void GetBitmap(int argc, char *argv[])
2244 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender)); 2274 printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
2275 if (MultiBitmap.Bitmap[0].Name)
2276 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name));
2245 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); 2277 if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
@@ -2507,3 +2539,3 @@ static void DisplaySMSFrame(GSM_SMSMessage *SMS)
2507static GSM_Error SMSStatus; 2539static GSM_Error SMSStatus;
2508//#if 0 2540
2509static void SendSMSStatus (char *Device, int status, int MessageReference) 2541static void SendSMSStatus (char *Device, int status, int MessageReference)
@@ -2518,3 +2550,3 @@ static void SendSMSStatus (char *Device, int status, int MessageReference)
2518 } 2550 }
2519 printmsg(", message reference=%02x\n",MessageReference); 2551 printmsg(", message reference=%d\n",MessageReference);
2520} 2552}
@@ -2532,3 +2564,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2532 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2; 2564 GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
2533 GSM_MultiPartSMSInfoSMSInfo; 2565 GSM_MultiPartSMSInfo SMSInfo;
2534 GSM_NetworkInfo NetInfo; 2566 GSM_NetworkInfo NetInfo;
@@ -2576,3 +2608,7 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2576 } 2608 }
2577 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) startarg=startarg+2; 2609 if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
2610 startarg=startarg+2;
2611 EncodeUnicode(SMSC,"1234",4);
2612 SMSCSet= 0;
2613 }
2578 2614
@@ -2602,3 +2638,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2602 if (argc<6+startarg) { 2638 if (argc<6+startarg) {
2603 printmsg("Where is ringtone filename ?\n"); 2639 printmsg("Where are parameters ?\n");
2604 exit(-1); 2640 exit(-1);
@@ -2614,2 +2650,15 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2614 startarg += 6; 2650 startarg += 6;
2651 } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) {
2652 if (argc<5+startarg) {
2653 printmsg("Where are parameters ?\n");
2654 exit(-1);
2655 }
2656 SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong;
2657 SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
2658 if (mystrncasecmp(argv[1],"--savesms",0)) {
2659 EncodeUnicode(Sender,"WAP Info",8);
2660 }
2661 strcpy(MMSInfo.Address,argv[3+startarg]);
2662 strcpy(MMSInfo.Title,argv[4+startarg]);
2663 startarg += 5;
2615 } else if (mystrncasecmp(argv[2],"RINGTONE",0)) { 2664 } else if (mystrncasecmp(argv[2],"RINGTONE",0)) {
@@ -2712,3 +2761,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2712 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2761 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2713 Print_Error(error); 2762 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2714 i = 0; 2763 i = 0;
@@ -2735,3 +2784,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2735 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2784 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2736 Print_Error(error); 2785 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2737 i = 0; 2786 i = 0;
@@ -2778,3 +2827,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2778 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2827 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2779 Print_Error(error); 2828 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2780 i = 0; 2829 i = 0;
@@ -2814,3 +2863,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2814 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2863 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2815 Print_Error(error); 2864 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2816 i = 0; 2865 i = 0;
@@ -2836,3 +2885,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2836 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2885 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2837 Print_Error(error); 2886 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2838 i = 0; 2887 i = 0;
@@ -2858,3 +2907,3 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2858 error=GSM_ReadBackupFile(argv[3+startarg],&Backup); 2907 error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
2859 Print_Error(error); 2908 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
2860 i = 0; 2909 i = 0;
@@ -3811,3 +3860,3 @@ static void SaveFile(int argc, char *argv[])
3811 error=GSM_ReadBackupFile(argv[4],&Backup); 3860 error=GSM_ReadBackupFile(argv[4],&Backup);
3812 Print_Error(error); 3861 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3813 i = 0; 3862 i = 0;
@@ -3829,3 +3878,3 @@ static void SaveFile(int argc, char *argv[])
3829 error=GSM_ReadBackupFile(argv[4],&Backup); 3878 error=GSM_ReadBackupFile(argv[4],&Backup);
3830 Print_Error(error); 3879 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3831 i = 0; 3880 i = 0;
@@ -3847,3 +3896,3 @@ static void SaveFile(int argc, char *argv[])
3847 error=GSM_ReadBackupFile(argv[4],&Backup); 3896 error=GSM_ReadBackupFile(argv[4],&Backup);
3848 Print_Error(error); 3897 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3849 i = 0; 3898 i = 0;
@@ -3865,3 +3914,3 @@ static void SaveFile(int argc, char *argv[])
3865 error=GSM_ReadBackupFile(argv[4],&Backup); 3914 error=GSM_ReadBackupFile(argv[4],&Backup);
3866 Print_Error(error); 3915 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3867 i = 0; 3916 i = 0;
@@ -3883,3 +3932,3 @@ static void SaveFile(int argc, char *argv[])
3883 error=GSM_ReadBackupFile(argv[4],&Backup); 3932 error=GSM_ReadBackupFile(argv[4],&Backup);
3884 Print_Error(error); 3933 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
3885 i = 0; 3934 i = 0;
@@ -3932,3 +3981,3 @@ static void Backup(int argc, char *argv[])
3932 GSM_MemoryEntry Pbk; 3981 GSM_MemoryEntry Pbk;
3933 GSM_CalendarEntryNote; 3982 GSM_CalendarEntryCalendar;
3934 GSM_Bitmap Bitmap; 3983 GSM_Bitmap Bitmap;
@@ -3937,2 +3986,4 @@ static void Backup(int argc, char *argv[])
3937 GSM_MultiWAPSettingsSettings; 3986 GSM_MultiWAPSettingsSettings;
3987 GSM_SyncMLSettingsSyncML;
3988 GSM_ChatSettingsChat;
3938 GSM_Ringtone Ringtone; 3989 GSM_Ringtone Ringtone;
@@ -3940,2 +3991,3 @@ static void Backup(int argc, char *argv[])
3940 GSM_Backup Backup; 3991 GSM_Backup Backup;
3992 GSM_NoteEntry Note;
3941 GSM_Backup_Info Info; 3993 GSM_Backup_Info Info;
@@ -4076,3 +4128,3 @@ static void Backup(int argc, char *argv[])
4076 printmsg("Checking calendar\n"); 4128 printmsg("Checking calendar\n");
4077 error=Phone->GetNextCalendar(&s,&Note,true); 4129 error=Phone->GetNextCalendar(&s,&Calendar,true);
4078 if (error==ERR_NONE) { 4130 if (error==ERR_NONE) {
@@ -4094,5 +4146,5 @@ static void Backup(int argc, char *argv[])
4094 } 4146 }
4095 *Backup.Calendar[used]=Note; 4147 *Backup.Calendar[used]=Calendar;
4096 used ++; 4148 used ++;
4097 error=Phone->GetNextCalendar(&s,&Note,false); 4149 error=Phone->GetNextCalendar(&s,&Calendar,false);
4098 printmsgerr("*"); 4150 printmsgerr("*");
@@ -4138,2 +4190,34 @@ static void Backup(int argc, char *argv[])
4138 DoBackup = false; 4190 DoBackup = false;
4191 if (Info.Note) {
4192 printmsg("Checking notes\n");
4193 error=Phone->GetNextNote(&s,&Note,true);
4194 if (error==ERR_NONE) {
4195 if (answer_yes(" Backup notes")) DoBackup = true;
4196 }
4197 }
4198 if (DoBackup) {
4199 used = 0;
4200 printmsgerr(" Reading : ");
4201 while (error == ERR_NONE) {
4202 if (used < GSM_BACKUP_MAX_NOTE) {
4203 Backup.Note[used] = malloc(sizeof(GSM_NoteEntry));
4204 if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY);
4205 Backup.Note[used+1] = NULL;
4206 } else {
4207 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE");
4208 GSM_Terminate();
4209 exit(-1);
4210 }
4211 *Backup.Note[used]=Note;
4212 used ++;
4213 error=Phone->GetNextNote(&s,&Note,false);
4214 printmsgerr("*");
4215 if (gshutdown) {
4216 GSM_Terminate();
4217 exit(0);
4218 }
4219 }
4220 printmsgerr("\n");
4221 }
4222 DoBackup = false;
4139 if (Info.CallerLogos) { 4223 if (Info.CallerLogos) {
@@ -4236,2 +4320,70 @@ static void Backup(int argc, char *argv[])
4236 DoBackup = false; 4320 DoBackup = false;
4321 if (Info.WAPBookmark) {
4322 printmsg("Checking WAP bookmarks\n");
4323 Bookmark.Location = 1;
4324 error=Phone->GetWAPBookmark(&s,&Bookmark);
4325 if (error==ERR_NONE) {
4326 if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
4327 }
4328 }
4329 if (DoBackup) {
4330 used = 0;
4331 printmsgerr(" Reading : ");
4332 while (error == ERR_NONE) {
4333 if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
4334 Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
4335 if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
4336 Backup.WAPBookmark[used+1] = NULL;
4337 } else {
4338 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
4339 GSM_Terminate();
4340 exit(-1);
4341 }
4342 *Backup.WAPBookmark[used]=Bookmark;
4343 used ++;
4344 Bookmark.Location = used+1;
4345 error=Phone->GetWAPBookmark(&s,&Bookmark);
4346 printmsgerr("*");
4347 if (gshutdown) {
4348 GSM_Terminate();
4349 exit(0);
4350 }
4351 }
4352 printmsgerr("\n");
4353 }
4354 DoBackup = false;
4355 if (Info.WAPSettings) {
4356 printmsg("Checking WAP settings\n");
4357 Settings.Location = 1;
4358 error=Phone->GetWAPSettings(&s,&Settings);
4359 if (error==ERR_NONE) {
4360 if (answer_yes(" Backup WAP settings")) DoBackup = true;
4361 }
4362 }
4363 if (DoBackup) {
4364 used = 0;
4365 printmsgerr(" Reading : ");
4366 while (error == ERR_NONE) {
4367 if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
4368 Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
4369 if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4370 Backup.WAPSettings[used+1] = NULL;
4371 } else {
4372 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
4373 GSM_Terminate();
4374 exit(-1);
4375 }
4376 *Backup.WAPSettings[used]=Settings;
4377 used ++;
4378 Settings.Location = used+1;
4379 error=Phone->GetWAPSettings(&s,&Settings);
4380 printmsgerr("*");
4381 if (gshutdown) {
4382 GSM_Terminate();
4383 exit(0);
4384 }
4385 }
4386 printmsgerr("\n");
4387 }
4388 DoBackup = false;
4237 if (Info.MMSSettings) { 4389 if (Info.MMSSettings) {
@@ -4270,8 +4422,8 @@ static void Backup(int argc, char *argv[])
4270 DoBackup = false; 4422 DoBackup = false;
4271 if (Info.WAPBookmark) { 4423 if (Info.ChatSettings) {
4272 printmsg("Checking WAP bookmarks\n"); 4424 printmsg("Checking Chat settings\n");
4273 Bookmark.Location = 1; 4425 Chat.Location = 1;
4274 error=Phone->GetWAPBookmark(&s,&Bookmark); 4426 error=Phone->GetChatSettings(&s,&Chat);
4275 if (error==ERR_NONE) { 4427 if (error==ERR_NONE) {
4276 if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; 4428 if (answer_yes(" Backup Chat settings")) DoBackup = true;
4277 } 4429 }
@@ -4282,8 +4434,8 @@ static void Backup(int argc, char *argv[])
4282 while (error == ERR_NONE) { 4434 while (error == ERR_NONE) {
4283 if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { 4435 if (used < GSM_BACKUP_MAX_CHATSETTINGS) {
4284 Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); 4436 Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings));
4285 if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); 4437 if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4286 Backup.WAPBookmark[used+1] = NULL; 4438 Backup.ChatSettings[used+1] = NULL;
4287 } else { 4439 } else {
4288 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); 4440 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS");
4289 GSM_Terminate(); 4441 GSM_Terminate();
@@ -4291,6 +4443,6 @@ static void Backup(int argc, char *argv[])
4291 } 4443 }
4292 *Backup.WAPBookmark[used]=Bookmark; 4444 *Backup.ChatSettings[used]=Chat;
4293 used ++; 4445 used ++;
4294 Bookmark.Location = used+1; 4446 Chat.Location = used+1;
4295 error=Phone->GetWAPBookmark(&s,&Bookmark); 4447 error=Phone->GetChatSettings(&s,&Chat);
4296 printmsgerr("*"); 4448 printmsgerr("*");
@@ -4304,8 +4456,8 @@ static void Backup(int argc, char *argv[])
4304 DoBackup = false; 4456 DoBackup = false;
4305 if (Info.WAPSettings) { 4457 if (Info.SyncMLSettings) {
4306 printmsg("Checking WAP settings\n"); 4458 printmsg("Checking SyncML settings\n");
4307 Settings.Location = 1; 4459 SyncML.Location = 1;
4308 error=Phone->GetWAPSettings(&s,&Settings); 4460 error=Phone->GetSyncMLSettings(&s,&SyncML);
4309 if (error==ERR_NONE) { 4461 if (error==ERR_NONE) {
4310 if (answer_yes(" Backup WAP settings")) DoBackup = true; 4462 if (answer_yes(" Backup SyncML settings")) DoBackup = true;
4311 } 4463 }
@@ -4316,8 +4468,8 @@ static void Backup(int argc, char *argv[])
4316 while (error == ERR_NONE) { 4468 while (error == ERR_NONE) {
4317 if (used < GSM_BACKUP_MAX_WAPSETTINGS) { 4469 if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) {
4318 Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); 4470 Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings));
4319 if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); 4471 if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
4320 Backup.WAPSettings[used+1] = NULL; 4472 Backup.SyncMLSettings[used+1] = NULL;
4321 } else { 4473 } else {
4322 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); 4474 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS");
4323 GSM_Terminate(); 4475 GSM_Terminate();
@@ -4325,6 +4477,6 @@ static void Backup(int argc, char *argv[])
4325 } 4477 }
4326 *Backup.WAPSettings[used]=Settings; 4478 *Backup.SyncMLSettings[used]=SyncML;
4327 used ++; 4479 used ++;
4328 Settings.Location = used+1; 4480 SyncML.Location = used+1;
4329 error=Phone->GetWAPSettings(&s,&Settings); 4481 error=Phone->GetSyncMLSettings(&s,&SyncML);
4330 printmsgerr("*"); 4482 printmsgerr("*");
@@ -4504,3 +4656,7 @@ static void Restore(int argc, char *argv[])
4504 error=GSM_ReadBackupFile(argv[2],&Backup); 4656 error=GSM_ReadBackupFile(argv[2],&Backup);
4505 Print_Error(error); 4657 if (error!=ERR_NOTIMPLEMENTED) {
4658 Print_Error(error);
4659 } 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");
4661 }
4506 4662
@@ -4509,5 +4665,6 @@ static void Restore(int argc, char *argv[])
4509 4665
4510 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 4666 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
4511 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 4667 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
4512 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 4668 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);
4513 4670
@@ -4620,3 +4777,3 @@ static void Restore(int argc, char *argv[])
4620 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { 4777 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
4621 if (/*answer_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)")*/ true ) { 4778 if (answer_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)")) {
4622 GSM_GetCurrentDateTime(&date_time); 4779 GSM_GetCurrentDateTime(&date_time);
@@ -4629,3 +4786,2 @@ static void Restore(int argc, char *argv[])
4629 if (Backup.Calendar[0] != NULL) { 4786 if (Backup.Calendar[0] != NULL) {
4630 DoRestore = true;
4631 /* N6110 doesn't support getting calendar status */ 4787 /* N6110 doesn't support getting calendar status */
@@ -4636,9 +4792,7 @@ static void Restore(int argc, char *argv[])
4636 printmsgerr("%i entries in backup file\n",max); 4792 printmsgerr("%i entries in backup file\n",max);
4793 // LR
4794 //if (answer_yes("Restore calendar notes")) {
4795 //Past = answer_yes("Restore notes from the past");
4637 DoRestore = true; 4796 DoRestore = true;
4638 /* 4797 //}
4639 if (answer_yes("Restore calendar notes")) {
4640 Past = answer_yes("Restore notes from the past");
4641 DoRestore = true;
4642 }
4643 */
4644 } 4798 }
@@ -4681,4 +4835,2 @@ static void Restore(int argc, char *argv[])
4681 if (error == ERR_NONE) { 4835 if (error == ERR_NONE) {
4682 error == ERR_NOTSUPPORTED;
4683 DoRestore = true;
4684 max = 0; 4836 max = 0;
@@ -4687,3 +4839,4 @@ static void Restore(int argc, char *argv[])
4687 4839
4688 /*if (answer_yes("Restore ToDo")) */DoRestore = true; 4840 //LR if (answer_yes("Restore ToDo"))
4841 DoRestore = true;
4689 } 4842 }
@@ -4691,6 +4844,4 @@ static void Restore(int argc, char *argv[])
4691 if (DoRestore) { 4844 if (DoRestore) {
4692 if ( max > 0 ) {
4693 ToDo = *Backup.ToDo[0]; 4845 ToDo = *Backup.ToDo[0];
4694 error = Phone->SetToDo(&s,&ToDo); 4846 error = Phone->SetToDo(&s,&ToDo);
4695 }
4696 } 4847 }
@@ -4993,3 +5144,3 @@ static void AddNew(int argc, char *argv[])
4993 error=GSM_ReadBackupFile(argv[2],&Backup); 5144 error=GSM_ReadBackupFile(argv[2],&Backup);
4994 Print_Error(error); 5145 if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
4995 5146
@@ -5620,4 +5771,3 @@ static void RestoreSMS(int argc, char *argv[])
5620 if (answer_yes(buffer)) { 5771 if (answer_yes(buffer)) {
5621 Backup.SMS[smsnum]->Location = 0; 5772 error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
5622 error=Phone->SetSMS(&s, Backup.SMS[smsnum]);
5623 Print_Error(error); 5773 Print_Error(error);
@@ -5815,3 +5965,3 @@ static void NokiaComposer(int argc, char *argv[])
5815} 5965}
5816//#if 0 5966
5817static void CopyRingtone(int argc, char *argv[]) 5967static void CopyRingtone(int argc, char *argv[])
@@ -5976,3 +6126,3 @@ static void PrintToDo(GSM_ToDoEntry *ToDo)
5976 6126
5977 printmsg("Location : %i\n",ToDo->Location); 6127 printmsg("Location : %i\n",ToDo->Location);
5978 printmsg("Priority : "); 6128 printmsg("Priority : ");
@@ -6100,3 +6250,3 @@ static void ListToDoCategory(int argc, char *argv[])
6100 count++; 6250 count++;
6101 if (mystrstr(Category.Name, Text) != NULL) { 6251 if (mywstrstr(Category.Name, Text) != NULL) {
6102 ListToDoCategoryEntries(j); 6252 ListToDoCategoryEntries(j);
@@ -6153,9 +6303,9 @@ static void GetAllToDo(int argc, char *argv[])
6153 6303
6154static void GetNote(int argc, char *argv[]) 6304static void GetAllNotes(int argc, char *argv[])
6155{ 6305{
6156 GSM_NoteEntry Note; 6306 GSM_NoteEntry Note;
6157 int start,stop; 6307 bool start = true;
6158 bool refresh=true;
6159 6308
6160 GetStartStop(&start, &stop, 2, argc, argv); 6309 signal(SIGINT, interrupt);
6310 printmsgerr("Press Ctrl+C to break...\n");
6161 6311
@@ -6163,17 +6313,10 @@ static void GetNote(int argc, char *argv[])
6163 6313
6164 for (i=start;i<=stop;i++) { 6314 while (!gshutdown) {
6165 Note.Location=i; 6315 error = Phone->GetNextNote(&s, &Note, start);
6166 printmsg("Location : %i\n",i); 6316 if (error == ERR_EMPTY) break;
6167 error=Phone->GetNote(&s,&Note,refresh); 6317 Print_Error(error);
6168 if (error != ERR_EMPTY) Print_Error(error); 6318 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
6169 6319 printf("\n");
6170 if (error == ERR_EMPTY) { 6320 start = false;
6171 printmsg("Entry is empty\n\n");
6172 } else {
6173 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
6174 printf("\n");
6175 refresh=false;
6176 }
6177 } 6321 }
6178
6179 GSM_Terminate(); 6322 GSM_Terminate();
@@ -6573,7 +6716,30 @@ static void ListNetworks(int argc, char *argv[])
6573 extern unsigned char *GSM_Networks[]; 6716 extern unsigned char *GSM_Networks[];
6717 extern unsigned char *GSM_Countries[];
6574 int i=0; 6718 int i=0;
6719 char country[4]="";
6575 6720
6576 printmsg("Network Name\n\n"); 6721 if (argc>2) {
6722 while (GSM_Countries[i*2]!=NULL) {
6723 if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) {
6724 strcpy(country,GSM_Countries[i*2]);
6725 printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]);
6726 break;
6727 }
6728 i++;
6729 }
6730 if (!*country) {
6731 printmsg("Unknown country name.");
6732 exit(-1);
6733 }
6734 }
6735 printmsg("Network Name\n");
6736 i=0;
6577 while (GSM_Networks[i*2]!=NULL) { 6737 while (GSM_Networks[i*2]!=NULL) {
6578 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); 6738 if (argc>2) {
6739 if (!strncmp(GSM_Networks[i*2],country,strlen(country))) {
6740 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6741 }
6742 } else {
6743 printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
6744 }
6579 i++; 6745 i++;
@@ -6587,3 +6753,5 @@ static void Version(int argc, char *argv[])
6587 6753
6588 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 6754 printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__);
6755 if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler());
6756 printmsg("]\n\n");
6589 6757
@@ -6704,5 +6872,2 @@ static void GetFileSystem(int argc, char *argv[])
6704 printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); 6872 printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
6705 printf("\n");
6706
6707 Start = false;
6708 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { 6873 } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
@@ -6728,7 +6893,4 @@ static void GetFileSystem(int argc, char *argv[])
6728 if (Files.System) printf("S"); 6893 if (Files.System) printf("S");
6729
6730 printf("\n");
6731
6732 Start = false;
6733 } 6894 }
6895 Start = false;
6734 } 6896 }
@@ -7040,2 +7202,4 @@ static struct NokiaFolderInfo Folder[] = {
7040 {"6220", "Gallery", "", "5"}, 7202 {"6220", "Gallery", "", "5"},
7203 {"6610", "Gallery", "", "2"},
7204 {"7210", "Gallery", "", "2"},
7041 {"", "Tones", "Tones","3"}, 7205 {"", "Tones", "Tones","3"},
@@ -7044,2 +7208,4 @@ static struct NokiaFolderInfo Folder[] = {
7044 {"6220", "Tones", "", "6"}, 7208 {"6220", "Tones", "", "6"},
7209 {"6610", "Tones", "", "4"},
7210 {"7210", "Tones", "", "4"},
7045 /* Language indepedent in OBEX */ 7211 /* Language indepedent in OBEX */
@@ -7560,4 +7726,2 @@ static void CallDivert(int argc, char *argv[])
7560 7726
7561
7562//#if 0
7563static void CancelAllDiverts(int argc, char *argv[]) 7727static void CancelAllDiverts(int argc, char *argv[])
@@ -7572,3 +7736,13 @@ static void CancelAllDiverts(int argc, char *argv[])
7572 7736
7737typedef struct {
7738 unsigned char Connection[50];
7739} OneConnectionInfo;
7573 7740
7741typedef struct {
7742 unsigned char Device[50];
7743 OneConnectionInfo Connections[4];
7744} OneDeviceInfo;
7745
7746 int num;
7747 bool SearchOutput;
7574 7748
@@ -7576,33 +7750,31 @@ void SearchPhoneThread(OneDeviceInfo *Info)
7576{ 7750{
7751 //LR
7752#if 0
7577 int j; 7753 int j;
7578 GSM_Error error; 7754 GSM_Error error;
7579 fprintf(stderr,"*********************************** \n"); 7755 GSM_StateMachiness;
7580 fprintf(stderr,"*********************************** \n"); 7756
7581 fprintf(stderr,"*********************************** \n");
7582 fprintf(stderr,"*********************************** \n");
7583 fprintf(stderr,"*********************************** \n");
7584#if 0
7585 j = 0; 7757 j = 0;
7586 while(strlen(Info->Connections[j].Connection) != 0) { 7758 while(strlen(Info->Connections[j].Connection) != 0) {
7587 memcpy(&Info->s.di,&s.di,sizeof(Debug_Info)); 7759 memcpy(&ss.di,&s.di,sizeof(Debug_Info));
7588 Info->s.msg = s.msg; 7760 ss.msg = s.msg;
7589 Info->s.ConfigNum = 1; 7761 ss.ConfigNum = 1;
7590 Info->s.opened = false; 7762 ss.opened = false;
7591 Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile; 7763 ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
7592 Info->s.Config[0].Localize = s.Config[0].Localize; 7764 ss.Config[0].Localize = s.Config[0].Localize;
7593 Info->s.Config[0].Device = Info->Device; 7765 ss.Config[0].Device = Info->Device;
7594 Info->s.Config[0].Connection = Info->Connections[j].Connection; 7766 ss.Config[0].Connection = Info->Connections[j].Connection;
7595 Info->s.Config[0].SyncTime = "no"; 7767 ss.Config[0].SyncTime = "no";
7596 Info->s.Config[0].DebugFile = s.Config[0].DebugFile; 7768 ss.Config[0].DebugFile = s.Config[0].DebugFile;
7597 Info->s.Config[0].Model[0] = 0; 7769 ss.Config[0].Model[0] = 0;
7598 strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel); 7770 strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel);
7599 Info->s.Config[0].LockDevice = "no"; 7771 ss.Config[0].LockDevice = "no";
7600 Info->s.Config[0].StartInfo = "no"; 7772 ss.Config[0].StartInfo = "no";
7601 7773
7602 error = GSM_InitConnection(&Info->s,1); 7774 error = GSM_InitConnection(&ss,1);
7603 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7775 if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
7604 if (error == ERR_NONE) { 7776 if (error == ERR_NONE) {
7605 error=Info->s.Phone.Functions->GetManufacturer(&Info->s); 7777 error=ss.Phone.Functions->GetManufacturer(&ss);
7606 if (error == ERR_NONE) { 7778 if (error == ERR_NONE) {
7607 error=Info->s.Phone.Functions->GetModel(&Info->s); 7779 error=ss.Phone.Functions->GetModel(&ss);
7608 if (error == ERR_NONE) { 7780 if (error == ERR_NONE) {
@@ -7610,20 +7782,20 @@ void SearchPhoneThread(OneDeviceInfo *Info)
7610 printmsg(" Manufacturer : %s\n", 7782 printmsg(" Manufacturer : %s\n",
7611 Info->s.Phone.Data.Manufacturer); 7783 ss.Phone.Data.Manufacturer);
7612 printmsg(" Model : %s (%s)\n", 7784 printmsg(" Model : %s (%s)\n",
7613 Info->s.Phone.Data.ModelInfo->model, 7785 ss.Phone.Data.ModelInfo->model,
7614 Info->s.Phone.Data.Model); 7786 ss.Phone.Data.Model);
7615 } else { 7787 } else {
7616 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); 7788 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7617 } 7789 }
7618 } else { 7790 } else {
7619 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); 7791 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7620 } 7792 }
7621 } else { 7793 } else {
7622 if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg)); 7794 if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
7623 } 7795 }
7624 if (error != ERR_DEVICEOPENERROR) { 7796 if (error != ERR_DEVICEOPENERROR) {
7625 GSM_TerminateConnection(&Info->s); 7797 GSM_TerminateConnection(&ss);
7626 dbgprintf("Closing done\n"); 7798 dbgprintf("Closing done\n");
7627 } 7799 }
7628 if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break; 7800 if (error == ERR_DEVICEOPENERROR) break;
7629 j++; 7801 j++;
@@ -7634,4 +7806,2 @@ void SearchPhoneThread(OneDeviceInfo *Info)
7634 7806
7635//#undef HAVE_PTHREAD
7636//#if 0
7637#if defined(WIN32) || defined(HAVE_PTHREAD) 7807#if defined(WIN32) || defined(HAVE_PTHREAD)
@@ -7641,2 +7811,4 @@ void SearchPhoneThread(OneDeviceInfo *Info)
7641 7811
7812OneDeviceInfo SearchDevices[60];
7813
7642void MakeSearchThread(int i) 7814void MakeSearchThread(int i)
@@ -7659,3 +7831,3 @@ static void SearchPhone(int argc, char *argv[])
7659{ 7831{
7660 int i,dev = 0, dev2 = 0; 7832 int i,dev = 0, dev2 = 0;
7661 7833
@@ -7669,3 +7841,4 @@ static void SearchPhone(int argc, char *argv[])
7669 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet"); 7841 sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
7670 SearchDevices[dev].Connections[1].Connection[0] = 0; 7842 sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat");
7843 SearchDevices[dev].Connections[2].Connection[0] = 0;
7671 dev++; 7844 dev++;
@@ -7674,3 +7847,3 @@ static void SearchPhone(int argc, char *argv[])
7674 dev2 = dev; 7847 dev2 = dev;
7675 for(i=0;i<10;i++) { 7848 for(i=0;i<20;i++) {
7676 sprintf(SearchDevices[dev2].Device,"com%i:",i+1); 7849 sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
@@ -7732,3 +7905,3 @@ static void SearchPhone(int argc, char *argv[])
7732#endif /*Support for threads */ 7905#endif /*Support for threads */
7733// #if 0 7906
7734static void NokiaGetADC(int argc, char *argv[]) 7907static void NokiaGetADC(int argc, char *argv[])
@@ -7795,3 +7968,3 @@ static GSM_Parameters Parameters[] = {
7795 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""}, 7968 {"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
7796 {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""}, 7969 {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"},
7797 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"}, 7970 {"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
@@ -7814,4 +7987,4 @@ static GSM_Parameters Parameters[] = {
7814 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"}, 7987 {"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
7815 {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"}, 7988 {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"},
7816 {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"}, 7989 {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
7817 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"}, 7990 {"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
@@ -7845,2 +8018,3 @@ static GSM_Parameters Parameters[] = {
7845 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8018 {"--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},
7846#ifdef GSM_ENABLE_BACKUP 8020#ifdef GSM_ENABLE_BACKUP
@@ -7864,2 +8038,3 @@ static GSM_Parameters Parameters[] = {
7864 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8038 {"--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},
7865#ifdef GSM_ENABLE_BACKUP 8040#ifdef GSM_ENABLE_BACKUP
@@ -7909,3 +8084,3 @@ static GSM_Parameters Parameters[] = {
7909 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"}, 8084 {"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
7910 {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"}, 8085 {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""},
7911 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"}, 8086 {"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
@@ -7978,4 +8153,6 @@ static GSM_Parameters Parameters[] = {
7978 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"}, 8153 {"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
8154#ifdef GSM_ENABLE_NOKIA6510
7979 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"}, 8155 {"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
7980 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""}, 8156 {"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
8157#endif
7981 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""}, 8158 {"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
@@ -8048,7 +8225,7 @@ static void HelpGeneral(void)
8048 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n"); 8225 printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
8049 printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n"); 8226 printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n");
8050 printmsg("Second parameter optionally controls debug level, next specify actions.\n\n"); 8227 printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n");
8051 8228
8052 /* We might want to put here some most used commands */ 8229 /* We might want to put here some most used commands */
8053 printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n"); 8230 printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n");
8054 8231
@@ -8136,3 +8313,3 @@ static void Help(int argc, char *argv[])
8136 while (HelpDescriptions[i].category != 0) { 8313 while (HelpDescriptions[i].category != 0) {
8137 if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break; 8314 if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break;
8138 i++; 8315 i++;
@@ -8208,18 +8385,13 @@ static void Help(int argc, char *argv[])
8208} 8385}
8209#if 0 8386
8210#endif // 0
8211int main(int argc, char *argv[]) 8387int main(int argc, char *argv[])
8212{ 8388{
8213 8389 int z = 0,start=0,i;
8214 //fprintf(stderr,"HIIIIIIIIIIIII \n"); 8390 intonly_config = -1;
8215 //#if 0 8391#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
8216 static int z ,start,i; 8392 char*locale, locale_file[201];
8217 static intonly_config ;
8218#if !defined(WIN32) && defined(LOCALE_PATH)
8219 static char*locale, locale_file[201];
8220#endif 8393#endif
8221 static char*cp; 8394 char*cp;
8222 static boolcount_failed; 8395 boolcount_failed = false;
8223 z = 0; 8396
8224 start=0;only_config = -1;count_failed = false;
8225 s.opened = false; 8397 s.opened = false;
@@ -8233,3 +8405,3 @@ int main(int argc, char *argv[])
8233#endif 8405#endif
8234 //#if 0 8406
8235 /* Any parameters? */ 8407 /* Any parameters? */
@@ -8248,54 +8420,10 @@ int main(int argc, char *argv[])
8248 /* Is first parameter numeric? If so treat it as config that should be loaded. */ 8420 /* Is first parameter numeric? If so treat it as config that should be loaded. */
8249 //if (isdigit(argv[1][0])) { 8421 if (isdigit(argv[1][0])) {
8250 //only_config = atoi(argv[1]); 8422 only_config = atoi(argv[1]);
8251 //if (only_config >= 0) start++; else only_config = -1; 8423 if (only_config >= 0) start++; else only_config = -1;
8252 //} 8424 }
8253 only_config = 0;;
8254#if 0
8255 GSM_ReadConfig(NULL, &s.Config[0], 0);
8256 s.ConfigNum = 1;
8257 GSM_Config *con = &s.Config[0];
8258
8259 char* tempC;
8260 tempC = argv[argc-1]+2;
8261 if ( *tempC != 0 ) {
8262 fprintf(stderr,"Using model %s \n",tempC);
8263 strcpy(con->Model,tempC );
8264 }
8265 tempC = argv[argc-2]+2;
8266 if ( *tempC != 0 ) {
8267 fprintf(stderr,"Using device %s \n",tempC);
8268 con->Device = strdup(tempC);
8269 con->DefaultDevice = false;
8270 }
8271 tempC = argv[argc-3]+2;
8272 if ( *tempC != 0 ) {
8273 fprintf(stderr,"Using connection %s \n",tempC);
8274 con->Connection = strdup(tempC);
8275 con->DefaultConnection = false;
8276 }
8277 argc = argc-3;
8278 //#if 0
8279 if ( ! mConnection.isEmpty() ) {
8280 cfg->Connection = strdup(mConnection.latin1());
8281 cfg->DefaultConnection = false;
8282 qDebug("Connection set %s ", cfg->Connection );
8283
8284 }
8285 if ( ! mDevice.isEmpty() ) {
8286 cfg->Device = strdup(mDevice.latin1());
8287 cfg->DefaultDevice = false;
8288 qDebug("Device set %s ", cfg->Device);
8289
8290 }
8291 if ( ! mModel.isEmpty() ) {
8292 strcpy(cfg->Model,mModel.latin1() );
8293 cfg->DefaultModel = false;
8294 qDebug("Model set %s ",cfg->Model );
8295 }
8296
8297#endif
8298 8425
8426 cfg = GSM_FindGammuRC();
8427 if (cfg == NULL) printmsg("Warning: No configuration file found!\n");
8299 8428
8300 cfg=GSM_FindGammuRC();
8301 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 8429 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
@@ -8309,3 +8437,3 @@ int main(int argc, char *argv[])
8309 } else { 8437 } else {
8310#if !defined(WIN32) && defined(LOCALE_PATH) 8438#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
8311 locale = setlocale(LC_MESSAGES, NULL); 8439 locale = setlocale(LC_MESSAGES, NULL);
@@ -8323,3 +8451,2 @@ int main(int argc, char *argv[])
8323 /* Wanted user specific configuration? */ 8451 /* Wanted user specific configuration? */
8324
8325 if (only_config != -1) { 8452 if (only_config != -1) {
@@ -8359,26 +8486,3 @@ int main(int argc, char *argv[])
8359 } 8486 }
8360#if 0 8487
8361 GSM_Config *con = &s.Config[0];
8362
8363 char* tempC;
8364 tempC = argv[argc-1]+2;
8365 if ( *tempC != 0 ) {
8366 fprintf(stderr,"Using model %s \n",tempC);
8367 strcpy(con->Model,tempC );
8368 }
8369 tempC = argv[argc-2]+2;
8370 if ( *tempC != 0 ) {
8371 fprintf(stderr,"Using device %s \n",tempC);
8372 con->Device = strdup(tempC);
8373 con->DefaultDevice = false;
8374 }
8375 tempC = argv[argc-3]+2;
8376 if ( *tempC != 0 ) {
8377 fprintf(stderr,"Using connection %s \n",tempC);
8378 con->Connection = strdup(tempC);
8379 con->DefaultConnection = false;
8380 }
8381#endif
8382
8383
8384 /* Do we have enough parameters? */ 8488 /* Do we have enough parameters? */
@@ -8401,3 +8505,2 @@ int main(int argc, char *argv[])
8401 if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) { 8505 if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) {
8402 fprintf(stderr,"Executing \n");
8403 Parameters[z].Function(argc - start, argv + start); 8506 Parameters[z].Function(argc - start, argv + start);
@@ -8423,4 +8526,3 @@ int main(int argc, char *argv[])
8423 if (di.df!=stdout) fclose(di.df); 8526 if (di.df!=stdout) fclose(di.df);
8424 //#endif // 0 8527
8425 fprintf(stderr,"kammu: Success. End. \n");
8426 exit(0); 8528 exit(0);
diff --git a/gammu/emb/gammu/gammu.h b/gammu/emb/gammu/gammu.h
index d3de31b..ff50c9c 100644
--- a/gammu/emb/gammu/gammu.h
+++ b/gammu/emb/gammu/gammu.h
@@ -59,7 +59,7 @@ void GSM_Terminate (void);
59 59
60 static GSM_StateMachines; 60 extern GSM_StateMachines;
61 static GSM_Phone_Functions*Phone; 61 extern GSM_Phone_Functions*Phone;
62 static GSM_Error error; 62 extern GSM_Error error;
63 63
64 static bool gshutdown; 64 extern volatile bool gshutdown;
65 65
diff --git a/gammu/emb/gammu/smsd/s_files.c b/gammu/emb/gammu/smsd/s_files.c
index dac8d9c..b791e58 100644
--- a/gammu/emb/gammu/smsd/s_files.c
+++ b/gammu/emb/gammu/smsd/s_files.c
@@ -1,2 +1,2 @@
1/* (c) 2002-2003 by Joergen Thomsen */ 1/* (c) 2002-2004 by Joergen Thomsen */
2 2
@@ -108,2 +108,10 @@ static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
108 * There is also set ID for SMS 108 * There is also set ID for SMS
109 * File extension convention:
110 * OUTxxxxx.txt : normal text SMS
111 * Options appended to the extension applying to this SMS only:
112 * d: delivery report requested
113 * f: flash SMS
114 * b: WAP bookmark as name,URL
115 * e.g. OUTG20040620_193810_123_+4512345678_xpq.txtdf
116 * is a flash text SMS requesting delivery reports
109 */ 117 */
@@ -113,2 +121,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
113 GSM_MultiPartSMSInfo SMSInfo; 121 GSM_MultiPartSMSInfo SMSInfo;
122 GSM_WAPBookmark Bookmark;
114 unsigned char FileName[100],FullName[400]; 123 unsigned char FileName[100],FullName[400];
@@ -118,3 +127,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
118 int i, len, phlen; 127 int i, len, phlen;
119 char *pos1, *pos2; 128 char *pos1, *pos2, *options;
120#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT 129#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT
@@ -127,6 +136,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
127 m = 0; 136 m = 0;
128 while ((m < n) && ((*(namelist[m]->d_name) == '.') || 137 while ((m < n) && ((*(namelist[m]->d_name) == '.') || // directory and UNIX hidden file
129 !mystrncasecmp(namelist[m]->d_name,"out", 3) || 138 !mystrncasecmp(namelist[m]->d_name,"out", 3) || // must start with 'out'
130 ((strlen(namelist[m]->d_name) >= 4) && 139 ((strlen(namelist[m]->d_name) >= 4) &&
131 !mystrncasecmp(&namelist[m]->d_name[strlen(namelist[m]->d_name)-4],".txt",4) 140 !mystrncasecmp(strrchr(namelist[m]->d_name, '.'),".txt",4)
132 ) 141 )
@@ -146,3 +155,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
146 strcpy(FullName, Config->outboxpath); 155 strcpy(FullName, Config->outboxpath);
147 strcat(FullName, "OUT*.txt"); 156 strcat(FullName, "OUT*.txt*");
148 if((hFile = _findfirst( FullName, &c_file )) == -1L ) { 157 if((hFile = _findfirst( FullName, &c_file )) == -1L ) {
@@ -157,3 +166,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
157 if (error != ERR_NONE) return error; 166 if (error != ERR_NONE) return error;
158 167 options = strrchr(FileName, '.') + 4;
159 strcpy(FullName, Config->outboxpath); 168 strcpy(FullName, Config->outboxpath);
@@ -164,6 +173,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
164 fclose(File); 173 fclose(File);
165 if (len<2) return ERR_EMPTY;
166 174
167 if ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) && 175 if ((len < 2) ||
168 (Buffer[0] != 0xFE || Buffer[1] != 0xFF)) { 176 (len >= 2 && ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) &&
177 (Buffer[0] != 0xFE || Buffer[1] != 0xFF)))) {
169 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;
@@ -178,2 +187,5 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
178 187
188 GSM_ClearMultiPartSMSInfo(&SMSInfo);
189 sms->Number = 0;
190
179 SMSInfo.ReplaceMessage = 0; 191 SMSInfo.ReplaceMessage = 0;
@@ -182,2 +194,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
182 SMSInfo.EntriesNum = 1; 194 SMSInfo.EntriesNum = 1;
195 Config->currdeliveryreport= -1;
196 if (strchr(options, 'd')) Config->currdeliveryreport= 1;
197 if (strchr(options, 'f')) SMSInfo.Class = 0; /* flash SMS */
198
183 if (mystrncasecmp(Config->transmitformat, "unicode", 0)) { 199 if (mystrncasecmp(Config->transmitformat, "unicode", 0)) {
@@ -192,2 +208,28 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
192 } 208 }
209
210 if (strchr(options, 'b')) { // WAP bookmark as title,URL
211 SMSInfo.Entries[0].Buffer = NULL;
212 SMSInfo.Entries[0].Bookmark = &Bookmark;
213 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
214 SMSInfo.Entries[0].Bookmark->Location= 0;
215 pos2 = mywstrstr(Buffer2, "\0,");
216 if (pos2 == NULL) {
217 pos2 = Buffer2;
218 } else {
219 *pos2 = '\0'; pos2++; *pos2 = '\0'; pos2++; // replace comma by zero
220 }
221
222 len = UnicodeLength(Buffer2);
223 if (len > 50) len = 50;
224 memmove(&SMSInfo.Entries[0].Bookmark->Title, Buffer2, len * 2);
225 pos1 = &SMSInfo.Entries[0].Bookmark->Title[0] + len * 2;
226 *pos1 = '\0'; pos1++; *pos1 = '\0';
227
228 len = UnicodeLength(pos2);
229 if (len > 255) len = 255;
230 memmove(&SMSInfo.Entries[0].Bookmark->Address, pos2, len * 2);
231 pos1 = &SMSInfo.Entries[0].Bookmark->Address[0] + len * 2;
232 *pos1 = '\0'; pos1++; *pos1 = '\0';
233 }
234
193 GSM_EncodeMultiPartSMS(&SMSInfo,sms); 235 GSM_EncodeMultiPartSMS(&SMSInfo,sms);
@@ -232,3 +274,3 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
232 DecodeUnicode(sms->SMS[0].Number,Buffer); 274 DecodeUnicode(sms->SMS[0].Number,Buffer);
233 dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i\n", 275 dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i dlr: %i fls: %i",
234 sms->Number, 276 sms->Number,
@@ -239,4 +281,6 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
239 sms->SMS[0].UDH.Type, 281 sms->SMS[0].UDH.Type,
240 sms->SMS[0].UDH.Length); 282 sms->SMS[0].UDH.Length,
241 } else dbgprintf("error\n"); 283 Config->currdeliveryreport,
284 SMSInfo.Class);
285 } else dbgprintf("error: SMS-count = 0");
242#endif 286#endif
@@ -294,5 +338,5 @@ static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Con
294 338
295static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK) 339static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
296{ 340{
297 if (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));
298 342
@@ -303,2 +347,3 @@ GSM_SMSDService SMSDFiles = {
303 NONEFUNCTION, /* Init */ 347 NONEFUNCTION, /* Init */
348 NONEFUNCTION, /* InitAfterConnect */
304 SMSDFiles_SaveInboxSMS, 349 SMSDFiles_SaveInboxSMS,
@@ -307,6 +352,8 @@ GSM_SMSDService SMSDFiles = {
307 NOTSUPPORTED, /* CreateOutboxSMS*/ 352 NOTSUPPORTED, /* CreateOutboxSMS*/
308 SMSDFiles_AddSentSMSInfo 353 SMSDFiles_AddSentSMSInfo,
354 NOTSUPPORTED, /* RefreshSendStatus*/
355 NOTSUPPORTED /* RefreshPhoneStatus*/
309}; 356};
310 357
311/* How should editor hadle tabs in this file? Add editor commands here. 358/* How should editor handle tabs in this file? Add editor commands here.
312 * vim: noexpandtab sw=8 ts=8 sts=8: 359 * vim: noexpandtab sw=8 ts=8 sts=8:
diff --git a/gammu/emb/gammu/smsd/s_files.h b/gammu/emb/gammu/smsd/s_files.h
index 5cfa05f..ed07ef3 100644
--- a/gammu/emb/gammu/smsd/s_files.h
+++ b/gammu/emb/gammu/smsd/s_files.h
@@ -1,2 +1,2 @@
1/* (c) 2002-2003 by Joergen Thomsen */ 1/* (c) 2002-2004 by Joergen Thomsen */
2 2
diff --git a/gammu/emb/gammu/smsd/s_mysql.c b/gammu/emb/gammu/smsd/s_mysql.c
index dacc256..5df15e9 100644
--- a/gammu/emb/gammu/smsd/s_mysql.c
+++ b/gammu/emb/gammu/smsd/s_mysql.c
@@ -17,2 +17,3 @@
17#include "../../common/service/backup/gsmback.h" 17#include "../../common/service/backup/gsmback.h"
18#include "../gammu.h"
18#include "smsdcore.h" 19#include "smsdcore.h"
@@ -22,7 +23,114 @@ static GSM_Error SMSDMySQL_Init(GSM_SMSDConfig *Config)
22{ 23{
24 unsigned char buf[400];
25 MYSQL_RES *Res;
26 MYSQL_ROW Row;
27
23 mysql_init(&Config->DB); 28 mysql_init(&Config->DB);
24 if (!mysql_real_connect(&Config->DB,Config->PC,Config->user,Config->password,Config->database,0,NULL,0)) { 29 if (!mysql_real_connect(&Config->DB,Config->PC,Config->user,Config->password,Config->database,0,NULL,0)) {
25 WriteSMSDLog("Error connecting to database: %s\n", mysql_error(&Config->DB)); 30 WriteSMSDLog("Error connecting to database: %s\n", mysql_error(&Config->DB));
26 return ERR_UNKNOWN; 31 return ERR_UNKNOWN;
32 }
33 sprintf(buf, "SELECT ID FROM `outbox` WHERE 1");
34 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
35 WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
36 return ERR_UNKNOWN;
37 }
38 if (!(Res = mysql_store_result(&Config->DB))) {
39 WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
40 return ERR_UNKNOWN;
27 } 41 }
42 mysql_free_result(Res);
43 sprintf(buf, "SELECT ID FROM `outbox_multipart` WHERE 1");
44 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
45 WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
46 return ERR_UNKNOWN;
47 }
48 if (!(Res = mysql_store_result(&Config->DB))) {
49 WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
50 return ERR_UNKNOWN;
51 }
52 mysql_free_result(Res);
53 sprintf(buf, "SELECT ID FROM `sentitems` WHERE 1");
54 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
55 WriteSMSDLog("No table for sent sms: %s\n", mysql_error(&Config->DB));
56 return ERR_UNKNOWN;
57 }
58 if (!(Res = mysql_store_result(&Config->DB))) {
59 WriteSMSDLog("No table for sent sms: %s\n", mysql_error(&Config->DB));
60 return ERR_UNKNOWN;
61 }
62 mysql_free_result(Res);
63 sprintf(buf, "SELECT ID FROM `inbox` WHERE 1");
64 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
65 WriteSMSDLog("No table for inbox sms: %s\n", mysql_error(&Config->DB));
66 return ERR_UNKNOWN;
67 }
68 if (!(Res = mysql_store_result(&Config->DB))) {
69 WriteSMSDLog("No table for inbox sms: %s\n", mysql_error(&Config->DB));
70 return ERR_UNKNOWN;
71 }
72 mysql_free_result(Res);
73 sprintf(buf, "SELECT Version FROM `gammu` WHERE 1");
74 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
75 WriteSMSDLog("No Gammu table: %s\n", mysql_error(&Config->DB));
76 return ERR_UNKNOWN;
77 }
78 if (!(Res = mysql_store_result(&Config->DB))) {
79 WriteSMSDLog("No Gammu table: %s\n", mysql_error(&Config->DB));
80 return ERR_UNKNOWN;
81 }
82 if (!(Row = mysql_fetch_row(Res))) {
83 mysql_free_result(Res);
84 WriteSMSDLog("No version info in Gammu table: %s\n", mysql_error(&Config->DB));
85 return ERR_UNKNOWN;
86 }
87 if (atoi(Row[0]) > 4) {
88 mysql_free_result(Res);
89 WriteSMSDLog("DataBase structures are from higher Gammu version");
90 WriteSMSDLog("Please update this client application");
91 return ERR_UNKNOWN;
92 }
93 if (atoi(Row[0]) < 4) {
94 mysql_free_result(Res);
95 WriteSMSDLog("DataBase structures are from older Gammu version");
96 WriteSMSDLog("Please update DataBase, if you want to use this client application");
97 return ERR_UNKNOWN;
98 }
99 mysql_free_result(Res);
100
101 return ERR_NONE;
102}
103
104static GSM_Error SMSDMySQL_InitAfterConnect(GSM_SMSDConfig *Config)
105{
106 unsigned char buf[400],buf2[200];
107
108 sprintf(buf,"DELETE FROM `phones` WHERE `IMEI` = '%s'",s.Phone.Data.IMEI);
109#ifdef DEBUG
110 fprintf(stdout,"%s\n",buf);
111#endif
112 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
113 WriteSMSDLog("Error deleting from database (Init): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
114 return ERR_UNKNOWN;
115 }
116
117 sprintf(buf2,"Gammu %s",VERSION);
118 if (strlen(GetOS()) != 0) {
119 strcat(buf2+strlen(buf2),", ");
120 strcat(buf2+strlen(buf2),GetOS());
121 }
122 if (strlen(GetCompiler()) != 0) {
123 strcat(buf2+strlen(buf2),", ");
124 strcat(buf2+strlen(buf2),GetCompiler());
125 }
126
127 sprintf(buf,"INSERT INTO `phones` (`IMEI`,`ID`,`Send`,`Receive`,`InsertIntoDB`,`TimeOut`,`Client`) VALUES ('%s','%s','yes','yes',NOW(),(NOW() + INTERVAL 10 SECOND)+0,'%s')",s.Phone.Data.IMEI,Config->PhoneID,buf2);
128#ifdef DEBUG
129 fprintf(stdout,"%s\n",buf);
130#endif
131 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
132 WriteSMSDLog("Error deleting from database (Init): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
133 return ERR_UNKNOWN;
134 }
135
28 return ERR_NONE; 136 return ERR_NONE;
@@ -33,9 +141,89 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
33{ 141{
34 unsigned charbuffer[10000],buffer2[200],buffer3[2]; 142 MYSQL_RES *Res;
35 int i,j,z; 143 MYSQL_ROW Row;
144 unsigned char buffer[10000],buffer2[200],buffer3[50];
145 int i,j,z;
146 GSM_DateTime DT;
147 time_t t_time1,t_time2;
148 bool found;
149 long diff;
36 150
37 for (i=0;i<sms.Number;i++) { 151 for (i=0;i<sms.Number;i++) {
38 if ((sms.SMS[i].PDU == SMS_Status_Report) && mystrncasecmp(Config->deliveryreport, "log", 3)) { 152 if (sms.SMS[i].PDU == SMS_Status_Report) {
39 strcpy(buffer, DecodeUnicodeString(sms.SMS[i].Number)); 153 strcpy(buffer2, DecodeUnicodeString(sms.SMS[i].Number));
40 WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer); 154 if (mystrncasecmp(Config->deliveryreport, "log", 3)) {
155 WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer2);
156 }
157
158 sprintf(buffer, "SELECT ID,Status,SendingDateTime,DeliveryDateTime,SMSCNumber FROM `sentitems` WHERE \
159 DeliveryDateTime='00000000000000' AND \
160 SenderID='%s' AND TPMR='%i' AND DestinationNumber='%s'",
161 Config->PhoneID, sms.SMS[i].MessageReference, buffer2);
162#ifdef DEBUG
163 fprintf(stdout,"%s\n",buffer);
164#endif
165 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
166 WriteSMSDLog("Error reading from database (SaveInbox): %s %s\n", buffer, mysql_error(&Config->DB));
167 return ERR_UNKNOWN;
168 }
169 if (!(Res = mysql_store_result(&Config->DB))) {
170 WriteSMSDLog("Error reading from database (SaveInbox): %s\n", mysql_error(&Config->DB));
171 return ERR_UNKNOWN;
172 }
173 found = false;
174 while ((Row = mysql_fetch_row(Res))) {
175 if (strcmp(Row[4],DecodeUnicodeString(sms.SMS[i].SMSC.Number))) {
176 if (Config->skipsmscnumber[0] == 0) continue;
177 if (strcmp(Config->skipsmscnumber,Row[4])) continue;
178 }
179 if (!strcmp(Row[1],"SendingOK") || !strcmp(Row[1],"DeliveryPending")) {
180 sprintf(buffer,"%c%c%c%c",Row[2][0],Row[2][1],Row[2][2],Row[2][3]);
181 DT.Year = atoi(buffer);
182 sprintf(buffer,"%c%c",Row[2][4],Row[2][5]);
183 DT.Month = atoi(buffer);
184 sprintf(buffer,"%c%c",Row[2][6],Row[2][7]);
185 DT.Day = atoi(buffer);
186 sprintf(buffer,"%c%c",Row[2][8],Row[2][9]);
187 DT.Hour = atoi(buffer);
188 sprintf(buffer,"%c%c",Row[2][10],Row[2][11]);
189 DT.Minute = atoi(buffer);
190 sprintf(buffer,"%c%c",Row[2][12],Row[2][13]);
191 DT.Second = atoi(buffer);
192 t_time1 = Fill_Time_T(DT,0);
193 t_time2 = Fill_Time_T(sms.SMS[i].DateTime,0);
194 diff = t_time2 - t_time1;
195 // fprintf(stderr,"diff is %i, %i-%i-%i-%i-%i and %i-%i-%i-%i-%i-%i\n",diff,
196 // DT.Year,DT.Month,DT.Day,DT.Hour,DT.Minute,DT.Second,
197 // sms.SMS[i].DateTime.Year,sms.SMS[i].DateTime.Month,sms.SMS[i].DateTime.Day,sms.SMS[i].DateTime.Hour,sms.SMS[i].DateTime.Minute,sms.SMS[i].DateTime.Second);
198 if (diff > -10 && diff < 10) {
199 found = true;
200 break;
201 }
202 }
203 }
204 if (found) {
205 sprintf(buffer,"UPDATE `sentitems` SET `DeliveryDateTime`='%04i%02i%02i%02i%02i%02i', `Status`='",
206 sms.SMS[i].SMSCTime.Year,sms.SMS[i].SMSCTime.Month,sms.SMS[i].SMSCTime.Day,
207 sms.SMS[i].SMSCTime.Hour,sms.SMS[i].SMSCTime.Minute,sms.SMS[i].SMSCTime.Second);
208 sprintf(buffer3,"%s",DecodeUnicodeString(sms.SMS[i].Text));
209 if (!strcmp(buffer3,"Delivered")) {
210 sprintf(buffer+strlen(buffer),"DeliveryOK");
211 } else if (!strcmp(buffer3,"Failed")) {
212 sprintf(buffer+strlen(buffer),"DeliveryFailed");
213 } else if (!strcmp(buffer3,"Pending")) {
214 sprintf(buffer+strlen(buffer),"DeliveryPending");
215 } else if (!strcmp(buffer3,"Unknown")) {
216 sprintf(buffer+strlen(buffer),"DeliveryUnknown");
217 }
218 sprintf(buffer+strlen(buffer),"', `StatusError` = '%i'",sms.SMS[i].DeliveryStatus);
219 sprintf(buffer+strlen(buffer)," WHERE `ID` = '%s' AND `TPMR` = '%i'",Row[0],sms.SMS[i].MessageReference);
220#ifdef DEBUG
221 fprintf(stdout,"%s\n",buffer);
222#endif
223 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
224 WriteSMSDLog("Error writing to database (SaveInboxSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
225 return ERR_UNKNOWN;
226 }
227 }
228 mysql_free_result(Res);
41 continue; 229 continue;
@@ -44,5 +232,5 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
44 buffer[0]=0; 232 buffer[0]=0;
45 sprintf(buffer+strlen(buffer),"INSERT INTO `Inbox` \ 233 sprintf(buffer+strlen(buffer),"INSERT INTO `inbox` \
46 (`DateTime`,`Text`,`SenderNumber`,`Coding`,`SMSCNumber`,`UDH`, \ 234 (`ReceivingDateTime`,`Text`,`SenderNumber`,`Coding`,`SMSCNumber`,`UDH`, \
47 `Class`,`TextDecoded`) VALUES ('%04d%02d%02d%02d%02d%02d','", 235 `Class`,`TextDecoded`,`RecipientID`) VALUES ('%04d%02d%02d%02d%02d%02d','",
48 sms.SMS[i].DateTime.Year,sms.SMS[i].DateTime.Month,sms.SMS[i].DateTime.Day, 236 sms.SMS[i].DateTime.Year,sms.SMS[i].DateTime.Month,sms.SMS[i].DateTime.Day,
@@ -98,5 +286,8 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
98 } 286 }
99 sprintf(buffer+strlen(buffer),"')"); 287 sprintf(buffer+strlen(buffer),"','%s')",Config->PhoneID);
288#ifdef DEBUG
289 fprintf(stdout,"%s\n",buffer);
290#endif
100 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) { 291 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
101 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB)); 292 WriteSMSDLog("Error writing to database (SaveInbox): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
102 return ERR_UNKNOWN; 293 return ERR_UNKNOWN;
@@ -108,2 +299,18 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
108 299
300static GSM_Error SMSDMySQL_RefreshSendStatus(GSM_SMSDConfig *Config, unsigned char *ID)
301{
302 unsigned char buffer[10000];
303
304 sprintf(buffer,"UPDATE `outbox` SET `SendingTimeOut`=(now() + INTERVAL 15 SECOND)+0 WHERE `ID` = '%s' AND `SendingTimeOut` < now()",ID);
305 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
306 WriteSMSDLog("Error writing to database (RefreshSendStatus): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
307 return ERR_UNKNOWN;
308 }
309#ifdef DEBUG
310 fprintf(stdout,"%s\n",buffer);
311 #endif
312 if (mysql_affected_rows(&Config->DB) == 0) return ERR_UNKNOWN;
313 return ERR_NONE;
314}
315
109/* Find one multi SMS to sending and return it (or return ERR_EMPTY) 316/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
@@ -113,10 +320,11 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
113{ 320{
114 unsigned char buf[400]; 321 unsigned char buf[400];
115 MYSQL_RES *Res; 322 MYSQL_RES *Res;
116 MYSQL_ROW Row; 323 MYSQL_ROW Row;
117 int i; 324 int i;
325 bool found = false;
118 326
119 sprintf(buf, "SELECT ID,DateTime FROM `Outbox` WHERE 1"); 327 sprintf(buf, "SELECT ID,InsertIntoDB,SendingDateTime,SenderID FROM `outbox` WHERE SendingDateTime < NOW() AND SendingTimeOut < NOW()");
120 if (mysql_real_query(&Config->DB,buf,strlen(buf))) { 328 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
121 WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB)); 329 WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
122 return ERR_UNKNOWN; 330 return ERR_UNKNOWN;
@@ -124,6 +332,16 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
124 if (!(Res = mysql_store_result(&Config->DB))) { 332 if (!(Res = mysql_store_result(&Config->DB))) {
125 WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB)); 333 WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
126 return ERR_UNKNOWN; 334 return ERR_UNKNOWN;
127 } 335 }
128 if (!(Row = mysql_fetch_row(Res))) { 336 while ((Row = mysql_fetch_row(Res))) {
337 sprintf(ID,"%s",Row[0]);
338 sprintf(Config->DT,"%s",Row[1]);
339 if (strlen(Row[3]) == 0 || !strcmp(Row[3],Config->PhoneID)) {
340 if (SMSDMySQL_RefreshSendStatus(Config, ID)==ERR_NONE) {
341 found = true;
342 break;
343 }
344 }
345 }
346 if (!found) {
129 mysql_free_result(Res); 347 mysql_free_result(Res);
@@ -131,14 +349,20 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
131 } 349 }
132 sprintf(ID,"%s",Row[0]); 350 mysql_free_result(Res);
133 sprintf(Config->DT,"%s",Row[1]);
134 sms->Number = 0; 351 sms->Number = 0;
135 for (i=1;i<10;i++) { 352 for (i=0;i<MAX_MULTI_SMS;i++) {
136 GSM_SetDefaultSMSData(&sms->SMS[sms->Number]); 353 GSM_SetDefaultSMSData(&sms->SMS[i]);
354 sms->SMS[i].SMSC.Number[0] = 0;
355 sms->SMS[i].SMSC.Number[1] = 0;
356 }
357 for (i=1;i<MAX_MULTI_SMS+1;i++) {
137 if (i==1) { 358 if (i==1) {
138 sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,MultiPart FROM `Outbox` WHERE ID='%s'",ID); 359 sprintf(buf, "SELECT Text,Coding,UDH,Class,TextDecoded,ID,DestinationNumber,MultiPart,RelativeValidity,DeliveryReport FROM `outbox` WHERE ID='%s'",ID);
139 } else { 360 } else {
140 sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,SequencePosition FROM `Outbox_MultiPart` WHERE ID='%s' AND SequencePosition='%i'",ID,i); 361 sprintf(buf, "SELECT Text,Coding,UDH,Class,TextDecoded,ID,SequencePosition FROM `outbox_multipart` WHERE ID='%s' AND SequencePosition='%i'",ID,i);
141 } 362 }
363#ifdef DEBUG
364 fprintf(stdout,"%s\n",buf);
365#endif
142 if (mysql_real_query(&Config->DB,buf,strlen(buf))) { 366 if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
143 WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB)); 367 WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
144 return ERR_UNKNOWN; 368 return ERR_UNKNOWN;
@@ -146,3 +370,3 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
146 if (!(Res = mysql_store_result(&Config->DB))) { 370 if (!(Res = mysql_store_result(&Config->DB))) {
147 WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB)); 371 WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
148 return ERR_UNKNOWN; 372 return ERR_UNKNOWN;
@@ -155,7 +379,7 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
155 sms->SMS[sms->Number].Coding=SMS_Coding_Default; 379 sms->SMS[sms->Number].Coding=SMS_Coding_Default;
156 if (!strcmp(Row[2],"Unicode")) sms->SMS[sms->Number].Coding=SMS_Coding_Unicode; 380 if (!strcmp(Row[1],"Unicode")) sms->SMS[sms->Number].Coding=SMS_Coding_Unicode;
157 if (!strcmp(Row[2],"8bit")) sms->SMS[sms->Number].Coding=SMS_Coding_8bit; 381 if (!strcmp(Row[1],"8bit")) sms->SMS[sms->Number].Coding=SMS_Coding_8bit;
158 382
159 if (strlen(Row[0])==0) { 383 if (strlen(Row[0])==0) {
160 EncodeUnicode(sms->SMS[sms->Number].Text,Row[6],strlen(Row[6])); 384 EncodeUnicode(sms->SMS[sms->Number].Text,Row[4],strlen(Row[4]));
161 } else { 385 } else {
@@ -171,16 +395,31 @@ static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
171 } 395 }
172 EncodeUnicode(sms->SMS[sms->Number].Number,Row[1],strlen(Row[1])); 396 if (i == 1) {
397 EncodeUnicode(sms->SMS[sms->Number].Number,Row[6],strlen(Row[6]));
398 } else {
399 CopyUnicodeString(sms->SMS[sms->Number].Number,sms->SMS[0].Number);
400 }
173 sms->SMS[sms->Number].UDH.Type = UDH_NoUDH; 401 sms->SMS[sms->Number].UDH.Type = UDH_NoUDH;
174 if (strlen(Row[3])!=0) { 402 if (strlen(Row[2])!=0) {
175 sms->SMS[sms->Number].UDH.Type = UDH_UserUDH; 403 sms->SMS[sms->Number].UDH.Type = UDH_UserUDH;
176 sms->SMS[sms->Number].UDH.Length = strlen(Row[3])/2; 404 sms->SMS[sms->Number].UDH.Length = strlen(Row[2])/2;
177 DecodeHexBin(sms->SMS[sms->Number].UDH.Text,Row[3],strlen(Row[3])); 405 DecodeHexBin(sms->SMS[sms->Number].UDH.Text,Row[2],strlen(Row[2]));
178 } 406 }
179 EncodeUnicode(sms->SMS[sms->Number].SMSC.Number,Row[4],strlen(Row[4])); 407 sms->SMS[sms->Number].Class = atoi(Row[3]);
180 sms->SMS[sms->Number].Class = atoi(Row[5]);
181 sms->SMS[sms->Number].PDU = SMS_Submit; 408 sms->SMS[sms->Number].PDU = SMS_Submit;
182 sms->SMS[sms->Number].SMSC.Location = 0; 409 sms->Number++;
183 sms->Number++; 410 if (i==1) {
184 if (i == 1 && !strcmp(Row[8],"false")) break; 411 Config->relativevalidity = atoi(Row[8]);
412
413 Config->currdeliveryreport = -1;
414 if (!strcmp(Row[9],"yes")) {
415 Config->currdeliveryreport = 1;
416 } else if (!strcmp(Row[9],"no")) {
417 Config->currdeliveryreport = 0;
418 }
419
420 if (!strcmp(Row[7],"false")) break;
421
422 }
185 } 423 }
424 mysql_free_result(Res);
186 return ERR_NONE; 425 return ERR_NONE;
@@ -191,76 +430,12 @@ static GSM_Error SMSDMySQL_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Con
191{ 430{
192 char *status; 431 unsigned char buffer[10000];
193 unsigned charbuffer[10000],buffer2[200],buffer3[2];
194 int i,j,z;
195
196 if (sent) status = "OK"; else status = "Error";
197
198 for (i=0;i<sms->Number;i++) {
199 buffer[0]=0;
200 sprintf(buffer+strlen(buffer),"UPDATE `SentItems` SET `Text`='");
201
202 switch (sms->SMS[i].Coding) {
203 case SMS_Coding_Unicode:
204 case SMS_Coding_Default:
205 EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[i].Text,UnicodeLength(sms->SMS[i].Text));
206 break;
207 case SMS_Coding_8bit:
208 EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].Text,sms->SMS[i].Length);
209 }
210
211 sprintf(buffer+strlen(buffer),"',`DestinationNumber`='%s',`Coding`='",DecodeUnicodeString(sms->SMS[i].Number));
212
213 switch (sms->SMS[i].Coding) {
214 case SMS_Coding_Unicode:
215 sprintf(buffer+strlen(buffer),"Unicode");
216 break;
217 case SMS_Coding_Default:
218 sprintf(buffer+strlen(buffer),"Default");
219 break;
220 case SMS_Coding_8bit:
221 sprintf(buffer+strlen(buffer),"8bit");
222 break;
223 }
224
225 sprintf(buffer+strlen(buffer),"',`SMSCNumber`='%s',`UDH`='",DecodeUnicodeString(sms->SMS[i].SMSC.Number));
226 if (sms->SMS[i].UDH.Type != UDH_NoUDH) {
227 EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length);
228 }
229 432
230 sprintf(buffer+strlen(buffer),"',`Class`='%i',`TextDecoded`='",sms->SMS[i].Class); 433 sprintf(buffer,"DELETE FROM `outbox` WHERE `ID` = '%s'",ID);
231 switch (sms->SMS[i].Coding) {
232 case SMS_Coding_Unicode:
233 case SMS_Coding_Default:
234 sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[i].Text));
235 for (j=0;j<(int)strlen(buffer2);j++) {
236 sprintf(buffer3,"'");
237 z = strlen(buffer);
238 if (buffer2[j]==buffer3[0]) {
239 buffer[z+2]=0;
240 buffer[z+1]=buffer2[j];
241 buffer[z] ='\\';
242 } else {
243 buffer[z+1]=0;
244 buffer[z] =buffer2[j];
245 }
246 }
247 break;
248 case SMS_Coding_8bit:
249 break;
250 }
251 sprintf(buffer+strlen(buffer),"',`Status`='%s',`DateTime`='%s' ",status,Config->DT);
252 sprintf(buffer+strlen(buffer),"WHERE `ID`='%s' AND `SequencePosition`='%i'",ID,i+1);
253 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
254 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
255 return ERR_UNKNOWN;
256 }
257 }
258 sprintf(buffer,"DELETE FROM `Outbox` WHERE `ID` = '%s'",ID);
259 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) { 434 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
260 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB)); 435 WriteSMSDLog("Error deleting from database (MoveSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
261 return ERR_UNKNOWN; 436 return ERR_UNKNOWN;
262 } 437 }
263 sprintf(buffer,"DELETE FROM `Outbox_MultiPart` WHERE `ID` = '%s'",ID); 438 sprintf(buffer,"DELETE FROM `outbox_multipart` WHERE `ID` = '%s'",ID);
264 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) { 439 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
265 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB)); 440 WriteSMSDLog("Error deleting from database (MoveSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
266 return ERR_UNKNOWN; 441 return ERR_UNKNOWN;
@@ -273,5 +448,23 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
273{ 448{
274 unsigned charbuffer[10000],buffer2[200],buffer3[2],buffer4[10000]; 449 unsigned char buffer[10000],buffer2[200],buffer3[2],buffer4[10000];
275 int i,j,z; 450 int i,j,z,ID;
276 GSM_DateTimetime; 451 MYSQL_RES *Res;
452 MYSQL_ROW Row;
453
454 sprintf(buffer,"SELECT ID FROM outbox ORDER BY ID DESC LIMIT 1");
455 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
456 WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
457 return ERR_UNKNOWN;
458 }
459 if (!(Res = mysql_store_result(&Config->DB))) {
460 WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
461 return ERR_UNKNOWN;
462 }
463 if ((Row = mysql_fetch_row(Res))) {
464 sprintf(buffer,"%s",Row[0]);
465 ID = atoi(buffer);
466 } else {
467 ID = 0;
468 }
469 mysql_free_result(Res);
277 470
@@ -280,9 +473,18 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
280 if (i==0) { 473 if (i==0) {
281 sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox` (`MultiPart`,`DateTime"); 474 sprintf(buffer+strlen(buffer),"INSERT INTO `outbox` (`DeliveryReport`,`MultiPart`,`InsertIntoDB");
282 } else { 475 } else {
283 sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox_MultiPart` (`SequencePosition"); 476 sprintf(buffer+strlen(buffer),"INSERT INTO `outbox_multipart` (`SequencePosition");
284 } 477 }
285 sprintf(buffer+strlen(buffer),"`,`Text`,`DestinationNumber`,`Coding`,`SMSCNumber`,`UDH`, \ 478 sprintf(buffer+strlen(buffer),"`,`Text`,");
479 if (i==0) {
480 sprintf(buffer+strlen(buffer),"`DestinationNumber`,`RelativeValidity`,");
481 }
482 sprintf(buffer+strlen(buffer),"`Coding`,`UDH`, \
286 `Class`,`TextDecoded`,`ID`) VALUES ('"); 483 `Class`,`TextDecoded`,`ID`) VALUES ('");
287 if (i==0) { 484 if (i==0) {
485 if (sms->SMS[i].PDU == SMS_Status_Report) {
486 sprintf(buffer+strlen(buffer),"yes','");
487 } else {
488 sprintf(buffer+strlen(buffer),"default','");
489 }
288 if (sms->Number == 1) { 490 if (sms->Number == 1) {
@@ -306,3 +508,12 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
306 } 508 }
307 sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms->SMS[i].Number)); 509 sprintf(buffer+strlen(buffer),"',");
510 if (i==0) {
511 sprintf(buffer+strlen(buffer),"'%s',",DecodeUnicodeString(sms->SMS[i].Number));
512 if (sms->SMS[i].SMSC.Validity.Format == SMS_Validity_RelativeFormat) {
513 sprintf(buffer+strlen(buffer),"'%i',",sms->SMS[i].SMSC.Validity.Relative);
514 } else {
515 sprintf(buffer+strlen(buffer),"'-1',");
516 }
517 }
518 sprintf(buffer+strlen(buffer),"'");
308 switch (sms->SMS[i].Coding) { 519 switch (sms->SMS[i].Coding) {
@@ -318,11 +529,7 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
318 } 529 }
319 sprintf(buffer+strlen(buffer),"','%s'",DecodeUnicodeString(sms->SMS[i].SMSC.Number)); 530 sprintf(buffer+strlen(buffer),"','");
320 if (sms->SMS[i].UDH.Type == UDH_NoUDH) { 531 if (sms->SMS[i].UDH.Type != UDH_NoUDH) {
321 sprintf(buffer+strlen(buffer),",''");
322 } else {
323 sprintf(buffer+strlen(buffer),",'");
324 EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length); 532 EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length);
325 sprintf(buffer+strlen(buffer),"'");
326 } 533 }
327 sprintf(buffer+strlen(buffer),",'%i','",sms->SMS[i].Class); 534 sprintf(buffer+strlen(buffer),"','%i','",sms->SMS[i].Class);
328 switch (sms->SMS[i].Coding) { 535 switch (sms->SMS[i].Coding) {
@@ -351,18 +558,34 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
351 while (true) { 558 while (true) {
352 GSM_GetCurrentDateTime(&time); 559 ID++;
353 buffer4[0] = 0; 560 sprintf(buffer4,"SELECT ID FROM sentitems WHERE ID='%i'",ID);
354 strcpy(buffer4,buffer); 561#ifdef DEBUG
355 sprintf(buffer4+strlen(buffer4),"%i')", 562 fprintf(stdout,"%s\n",buffer4);
356 time.Hour*1000000+ 563#endif
357 time.Minute*10000+
358 time.Second*100+time.Day);
359 if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) { 564 if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
360 if (mysql_errno(&Config->DB) == ER_DUP_ENTRY) { 565 WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
361 WriteSMSDLog("Duplicated outgoing SMS ID\n");
362 continue;
363 }
364 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
365 return ERR_UNKNOWN; 566 return ERR_UNKNOWN;
366 } 567 }
367 break; 568 if (!(Res = mysql_store_result(&Config->DB))) {
569 WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
570 return ERR_UNKNOWN;
571 }
572 if (!(Row = mysql_fetch_row(Res))) {
573 buffer4[0] = 0;
574 strcpy(buffer4,buffer);
575 sprintf(buffer4+strlen(buffer4),"%i')",ID);
576#ifdef DEBUG
577 fprintf(stdout,"%s\n",buffer4);
578#endif
579 if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
580 if (mysql_errno(&Config->DB) == ER_DUP_ENTRY) {
581 WriteSMSDLog("Duplicated outgoing SMS ID\n");
582 continue;
583 }
584 WriteSMSDLog("Error writing to database (CreateOutbox): %d %s %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB),buffer4);
585 return ERR_UNKNOWN;
586 }
587 mysql_free_result(Res);
588 break;
589 }
590 mysql_free_result(Res);
368 } 591 }
@@ -370,8 +593,8 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
370 strcpy(buffer4,buffer); 593 strcpy(buffer4,buffer);
371 sprintf(buffer4+strlen(buffer4),"%i')", 594 sprintf(buffer4+strlen(buffer4),"%i')",ID);
372 time.Hour*1000000+ 595#ifdef DEBUG
373 time.Minute*10000+ 596 fprintf(stdout,"%s\n",buffer4);
374 time.Second*100+time.Day); 597#endif
375 if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) { 598 if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
376 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB)); 599 WriteSMSDLog("Error writing to database (CreateOutbox): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
377 return ERR_UNKNOWN; 600 return ERR_UNKNOWN;
@@ -383,14 +606,82 @@ static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDCon
383 606
384static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK) 607
608static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
385{ 609{
386 unsigned char buffer[10000]; 610 unsigned charbuffer[10000],buffer2[200],buffer3[2],buff[50];
611 int j,z;
612
613 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));
387 614
388 if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number)); 615 buff[0] = 0;
616 if (err == SMSD_SEND_OK) {
617 if (sms->SMS[Part-1].PDU == SMS_Status_Report) {
618 sprintf(buff,"SendingOK");
619 } else {
620 sprintf(buff,"SendingOKNoReport");
621 }
622 }
623 if (err == SMSD_SEND_SENDING_ERROR) sprintf(buff,"SendingError");
624 if (err == SMSD_SEND_ERROR) sprintf(buff,"Error");
389 625
390 buffer[0] = 0; 626 buffer[0] = 0;
391 sprintf(buffer+strlen(buffer),"INSERT INTO `SentItems` \ 627 sprintf(buffer+strlen(buffer),"INSERT INTO `sentitems` \
392 (`ID`,`SequencePosition`,`Status`,`SendingDateTime`) VALUES ("); 628 (`ID`,`SequencePosition`,`Status`,`SendingDateTime`, `SMSCNumber`, `TPMR`, \
393 sprintf(buffer+strlen(buffer),"'%s','%i','Sending',NOW())",ID,Part); 629 `SenderID`,`Text`,`DestinationNumber`,`Coding`,`UDH`,`Class`,`TextDecoded`,`InsertIntoDB`,`RelativeValidity`) VALUES (");
630 sprintf(buffer+strlen(buffer),"'%s','%i','%s',NOW(),'%s','%i','%s','",ID,Part,buff,DecodeUnicodeString(sms->SMS[Part-1].SMSC.Number),TPMR,Config->PhoneID);
631 switch (sms->SMS[Part-1].Coding) {
632 case SMS_Coding_Unicode:
633 case SMS_Coding_Default:
634 EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[Part-1].Text,UnicodeLength(sms->SMS[Part-1].Text));
635 break;
636 case SMS_Coding_8bit:
637 EncodeHexBin(buffer+strlen(buffer),sms->SMS[Part-1].Text,sms->SMS[Part-1].Length);
638 }
639 sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms->SMS[Part-1].Number));
640 switch (sms->SMS[Part-1].Coding) {
641 case SMS_Coding_Unicode:
642 sprintf(buffer+strlen(buffer),"Unicode");
643 break;
644 case SMS_Coding_Default:
645 sprintf(buffer+strlen(buffer),"Default");
646 break;
647 case SMS_Coding_8bit:
648 sprintf(buffer+strlen(buffer),"8bit");
649 break;
650 }
651 sprintf(buffer+strlen(buffer),"','");
652 if (sms->SMS[Part-1].UDH.Type != UDH_NoUDH) {
653 EncodeHexBin(buffer+strlen(buffer),sms->SMS[Part-1].UDH.Text,sms->SMS[Part-1].UDH.Length);
654 }
655 sprintf(buffer+strlen(buffer),"','%i','",sms->SMS[Part-1].Class);
656 switch (sms->SMS[Part-1].Coding) {
657 case SMS_Coding_Unicode:
658 case SMS_Coding_Default:
659 sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[Part-1].Text));
660 for (j=0;j<(int)strlen(buffer2);j++) {
661 sprintf(buffer3,"'");
662 z = strlen(buffer);
663 if (buffer2[j]==buffer3[0]) {
664 buffer[z+2]=0;
665 buffer[z+1]=buffer2[j];
666 buffer[z] ='\\';
667 } else {
668 buffer[z+1]=0;
669 buffer[z] =buffer2[j];
670 }
671 }
672 break;
673 case SMS_Coding_8bit:
674 break;
675 }
676 sprintf(buffer+strlen(buffer),"','%s','",Config->DT);
677 if (sms->SMS[Part-1].SMSC.Validity.Format == SMS_Validity_RelativeFormat) {
678 sprintf(buffer+strlen(buffer),"%i')",sms->SMS[Part-1].SMSC.Validity.Relative);
679 } else {
680 sprintf(buffer+strlen(buffer),"-1')");
681 }
682#ifdef DEBUG
683 fprintf(stdout,"%s\n",buffer);
684 #endif
394 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) { 685 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
395 WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB)); 686 WriteSMSDLog("Error writing to database (AddSent): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
396 return ERR_UNKNOWN; 687 return ERR_UNKNOWN;
@@ -400,4 +691,21 @@ static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConf
400 691
692static GSM_Error SMSDMySQL_RefreshPhoneStatus(GSM_SMSDConfig *Config)
693{
694 unsigned char buffer[500];
695
696 sprintf(buffer,"UPDATE `phones` SET `TimeOut`= (NOW() + INTERVAL 10 SECOND)+0");
697 sprintf(buffer+strlen(buffer)," WHERE `IMEI` = '%s'",s.Phone.Data.IMEI);
698#ifdef DEBUG
699 fprintf(stdout,"%s\n",buffer);
700#endif
701 if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
702 WriteSMSDLog("Error writing to database (SaveInboxSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
703 return ERR_UNKNOWN;
704 }
705 return ERR_NONE;
706}
707
401GSM_SMSDService SMSDMySQL = { 708GSM_SMSDService SMSDMySQL = {
402 SMSDMySQL_Init, 709 SMSDMySQL_Init,
710 SMSDMySQL_InitAfterConnect,
403 SMSDMySQL_SaveInboxSMS, 711 SMSDMySQL_SaveInboxSMS,
@@ -406,3 +714,5 @@ GSM_SMSDService SMSDMySQL = {
406 SMSDMySQL_CreateOutboxSMS, 714 SMSDMySQL_CreateOutboxSMS,
407 SMSDMySQL_AddSentSMSInfo 715 SMSDMySQL_AddSentSMSInfo,
716 SMSDMySQL_RefreshSendStatus,
717 SMSDMySQL_RefreshPhoneStatus
408}; 718};
diff --git a/gammu/emb/gammu/smsd/smsdcore.c b/gammu/emb/gammu/smsd/smsdcore.c
index fbc55d3..cc9accc 100644
--- a/gammu/emb/gammu/smsd/smsdcore.c
+++ b/gammu/emb/gammu/smsd/smsdcore.c
@@ -1,2 +1,2 @@
1/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */ 1/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
2 2
@@ -16,3 +16,5 @@
16 FILE *smsd_log_file = NULL; 16 FILE *smsd_log_file = NULL;
17 static int TPMR;
17static GSM_Error SendingSMSStatus; 18static GSM_Error SendingSMSStatus;
19
18static void SMSSendingSMSStatus (char *Device, int status, int mr) 20static void SMSSendingSMSStatus (char *Device, int status, int mr)
@@ -20,2 +22,3 @@ static void SMSSendingSMSStatus (char *Device, int status, int mr)
20 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;
21 if (status==0) { 24 if (status==0) {
@@ -75,3 +78,3 @@ void WriteSMSDLog(char *format, ...)
75 78
76void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log) 79void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log, char *service)
77{ 80{
@@ -104,2 +107,3 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
104 memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config)); 107 memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config));
108 error=GSM_SetDebugFile(s.Config[0].DebugFile, &di);
105 } 109 }
@@ -114,11 +118,2 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
114 118
115 Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
116 if (Config->user == NULL) Config->user="root";
117 Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
118 if (Config->password == NULL) Config->password="";
119 Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
120 if (Config->PC == NULL) Config->PC="localhost";
121 Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
122 if (Config->database == NULL) Config->database="sms";
123
124 str = INI_GetValue(smsdcfgfile, "smsd", "commtimeout", false); 119 str = INI_GetValue(smsdcfgfile, "smsd", "commtimeout", false);
@@ -129,3 +124,6 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
129 if (str) Config->receivefrequency=atoi(str); else Config->receivefrequency = 0; 124 if (str) Config->receivefrequency=atoi(str); else Config->receivefrequency = 0;
130 if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i", Config->commtimeout, Config->sendtimeout, Config->receivefrequency); 125 str = INI_GetValue(smsdcfgfile, "smsd", "resetfrequency", false);
126 if (str) Config->resetfrequency=atoi(str); else Config->resetfrequency = 0;
127 if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i, resetfrequency=%i",
128 Config->commtimeout, Config->sendtimeout, Config->receivefrequency, Config->resetfrequency);
131 129
@@ -137,27 +135,48 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
137 135
138 Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false); 136 Config->PhoneID = INI_GetValue(smsdcfgfile, "smsd", "phoneid", false);
139 if (Config->inboxpath == NULL) Config->inboxpath = emptyPath; 137 if (Config->PhoneID == NULL) Config->PhoneID = "";
138 if (log) WriteSMSDLog("phoneid = %s", Config->PhoneID);
140 139
141 Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false); 140 if (!strcmp(service,"FILES")) {
142 if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) { 141 Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false);
143 Config->inboxformat = "standard"; 142 if (Config->inboxpath == NULL) Config->inboxpath = emptyPath;
144 }
145 if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat);
146 143
147 Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false); 144 Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false);
148 if (Config->outboxpath == NULL) Config->outboxpath = emptyPath; 145 if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) {
146 Config->inboxformat = "standard";
147 }
148 if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat);
149 149
150 Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false); 150 Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false);
151 if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) { 151 if (Config->outboxpath == NULL) Config->outboxpath = emptyPath;
152 Config->transmitformat = "7bit";
153 }
154 if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat);
155 152
156 Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false); 153 Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false);
157 if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath; 154 if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) {
158 if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath); 155 Config->transmitformat = "7bit";
156 }
157 if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat);
159 158
160 Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false); 159 Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false);
161 if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath; 160 if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath;
162 if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath); 161 if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath);
162
163 Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false);
164 if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath;
165 if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath);
166 }
167
168#ifdef HAVE_MYSQL_MYSQL_H
169 if (!strcmp(service,"MYSQL")) {
170 Config->skipsmscnumber = INI_GetValue(smsdcfgfile, "smsd", "skipsmscnumber", false);
171 if (Config->skipsmscnumber == NULL) Config->skipsmscnumber="";
172 Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
173 if (Config->user == NULL) Config->user="root";
174 Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
175 if (Config->password == NULL) Config->password="";
176 Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
177 if (Config->PC == NULL) Config->PC="localhost";
178 Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
179 if (Config->database == NULL) Config->database="sms";
180 }
181#endif
163 182
@@ -176,4 +195,6 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
176 195
177 Config->retries = 0; 196 Config->retries = 0;
178 Config->prevSMSID[0] = 0; 197 Config->prevSMSID[0] = 0;
198 Config->SMSC.Location = 0;
199 Config->relativevalidity = -1;
179} 200}
@@ -194,2 +215,3 @@ bool SMSD_CheckSecurity(GSM_SMSDConfig *Config)
194 if (error == ERR_NOTSUPPORTED) return true; 215 if (error == ERR_NOTSUPPORTED) return true;
216
195 /* If PIN, try to enter */ 217 /* If PIN, try to enter */
@@ -328,2 +350,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
328 } 350 }
351 Service->RefreshPhoneStatus(Config);
329 } 352 }
@@ -335,3 +358,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
335 for (i=0;i<sms.Number;i++) { 358 for (i=0;i<sms.Number;i++) {
336 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false); 359 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
337 } 360 }
@@ -340,2 +363,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
340 } 363 }
364
341 if (!gshutdown) { 365 if (!gshutdown) {
@@ -348,3 +372,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
348 for (i=0;i<sms.Number;i++) { 372 for (i=0;i<sms.Number;i++) {
349 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false); 373 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
350 } 374 }
@@ -357,6 +381,30 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
357 } 381 }
358 for (i=0;i<sms.Number;i++) { 382 for (i=0;i<sms.Number;i++) {
359 if (strcmp(Config->deliveryreport, "no") != 0) sms.SMS[i].PDU = SMS_Status_Report; 383 if (sms.SMS[i].SMSC.Location == 1) {
384 if (Config->SMSC.Location == 0) {
385 Config->SMSC.Location = 1;
386 error = Phone->GetSMSC(&s,&Config->SMSC);
387 if (error!=ERR_NONE) {
388 WriteSMSDLog("Error getting SMSC from phone");
389 return false;
390 }
391
392 }
393 memcpy(&sms.SMS[i].SMSC,&Config->SMSC,sizeof(GSM_SMSC));
394 sms.SMS[i].SMSC.Location = 0;
395 if (Config->relativevalidity != -1) {
396 sms.SMS[i].SMSC.Validity.Format = SMS_Validity_RelativeFormat;
397 sms.SMS[i].SMSC.Validity.Relative = Config->relativevalidity;
398 }
399 }
400
401 if (Config->currdeliveryreport == 1) {
402 sms.SMS[i].PDU = SMS_Status_Report;
403 } else {
404 if ((strcmp(Config->deliveryreport, "no") != 0 && (Config->currdeliveryreport == -1))) sms.SMS[i].PDU = SMS_Status_Report;
405 }
406
360 error=Phone->SendSMS(&s, &sms.SMS[i]); 407 error=Phone->SendSMS(&s, &sms.SMS[i]);
361 if (error!=ERR_NONE) { 408 if (error!=ERR_NONE) {
409 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, -1);
362 WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg)); 410 WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg));
@@ -364,3 +412,5 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
364 } 412 }
365 j=0; 413 Service->RefreshPhoneStatus(Config);
414 j = 0;
415 TPMR = -1;
366 SendingSMSStatus = ERR_TIMEOUT; 416 SendingSMSStatus = ERR_TIMEOUT;
@@ -375,2 +425,4 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
375 } 425 }
426 Service->RefreshSendStatus(Config, Config->SMSID);
427 Service->RefreshPhoneStatus(Config);
376 if (SendingSMSStatus != ERR_TIMEOUT) break; 428 if (SendingSMSStatus != ERR_TIMEOUT) break;
@@ -380,2 +432,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
380 if (SendingSMSStatus != ERR_NONE) { 432 if (SendingSMSStatus != ERR_NONE) {
433 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, TPMR);
381 WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg)); 434 WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg));
@@ -383,3 +436,3 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
383 } 436 }
384 error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, true); 437 error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_OK, TPMR);
385 if (error!=ERR_NONE) { 438 if (error!=ERR_NONE) {
@@ -388,6 +441,2 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
388 } 441 }
389 while ((int)i<sms.Number-1) {
390 Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
391 i++;
392 }
393 strcpy(Config->prevSMSID, ""); 442 strcpy(Config->prevSMSID, "");
@@ -405,3 +454,3 @@ void SMSDaemon(int argc, char *argv[])
405 GSM_Error error; 454 GSM_Error error;
406 time_t time1; 455 time_t lastreceive, lastreset = 0;
407 GSM_SMSDConfig Config; 456 GSM_SMSDConfig Config;
@@ -419,3 +468,3 @@ void SMSDaemon(int argc, char *argv[])
419 468
420 SMSD_ReadConfig(argv[3], &Config, true); 469 SMSD_ReadConfig(argv[3], &Config, true, argv[2]);
421 470
@@ -430,3 +479,4 @@ void SMSDaemon(int argc, char *argv[])
430 479
431 time1 = time(NULL); 480 lastreceive = time(NULL);
481 lastreset = time(NULL);
432 SendingSMSStatus = ERR_UNKNOWN; 482 SendingSMSStatus = ERR_UNKNOWN;
@@ -447,3 +497,23 @@ void SMSDaemon(int argc, char *argv[])
447 Phone = s.Phone.Functions; 497 Phone = s.Phone.Functions;
448 errors = 0; 498 if (errors == 255) {
499 errors = 0;
500 s.Phone.Data.IMEI[0] = 0;
501 if (!(Phone->GetIMEI(&s))) {
502 errors++;
503 } else {
504 error = Service->InitAfterConnect(&Config);
505 if (error!=ERR_NONE) {
506 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
507 }
508 Phone->SetFastSMSSending(&s,true);
509 }
510 } else {
511 errors = 0;
512 }
513 if (initerrors > 3 || initerrors < 0) {
514 error=Phone->Reset(&s, false); /* soft reset */
515 WriteSMSDLog("Reset return code: %s (%i) ", error == ERR_NONE? "OK":"ERROR", error);
516 lastreset = time(NULL);
517 my_sleep(5000);
518 }
449 /* Marcin Wiacek: FIXME. To check */ 519 /* Marcin Wiacek: FIXME. To check */
@@ -459,4 +529,4 @@ void SMSDaemon(int argc, char *argv[])
459 } 529 }
460 if ((difftime(time(NULL), time1) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) { 530 if ((difftime(time(NULL), lastreceive) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
461 time1 = time(NULL); 531 lastreceive = time(NULL);
462 532
@@ -470,3 +540,3 @@ void SMSDaemon(int argc, char *argv[])
470 540
471 if (!SMSD_CheckSMSStatus(&Config,Service)) { 541 if (!SMSD_CheckSMSStatus(&Config,Service)) { /* read all incoming SMS */
472 errors++; 542 errors++;
@@ -474,2 +544,7 @@ void SMSDaemon(int argc, char *argv[])
474 } else errors=0; 544 } else errors=0;
545
546 if (Config.resetfrequency > 0 && difftime(time(NULL), lastreset) >= Config.resetfrequency) { /* time for preventive reset */
547 errors = 254; initerrors = -2;
548 continue;
549 }
475 } 550 }
@@ -477,2 +552,3 @@ void SMSDaemon(int argc, char *argv[])
477 } 552 }
553 Phone->SetFastSMSSending(&s,false);
478 GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0); 554 GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0);
@@ -496,3 +572,3 @@ GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *s
496 572
497 SMSD_ReadConfig(filename, &Config, false); 573 SMSD_ReadConfig(filename, &Config, false, service);
498 574
diff --git a/gammu/emb/gammu/smsd/smsdcore.h b/gammu/emb/gammu/smsd/smsdcore.h
index 23e402e..17ffe58 100644
--- a/gammu/emb/gammu/smsd/smsdcore.h
+++ b/gammu/emb/gammu/smsd/smsdcore.h
@@ -1,5 +1,5 @@
1/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */ 1/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
2 2
3#include "../../cfg/config.h" 3#include "../../cfg/config.h"
4#undef HAVE_MYSQL_MYSQL_H 4
5#ifdef HAVE_MYSQL_MYSQL_H 5#ifdef HAVE_MYSQL_MYSQL_H
@@ -26,3 +26,5 @@ typedef struct {
26 unsigned int commtimeout, sendtimeout, receivefrequency; 26 unsigned int commtimeout, sendtimeout, receivefrequency;
27 unsigned intresetfrequency;
27 unsigned char *deliveryreport, *logfilename, *PINCode; 28 unsigned char *deliveryreport, *logfilename, *PINCode;
29 unsigned char*PhoneID;
28 30
@@ -34,7 +36,9 @@ typedef struct {
34 unsigned char *database, *user, *password; 36 unsigned char *database, *user, *password;
35 unsigned char*PC; 37 unsigned char *PC, *skipsmscnumber;
36 38
37 /* private variables required for work */ 39 /* private variables required for work */
38 unsigned int retries; 40 int relativevalidity;
41 unsigned int retries, currdeliveryreport;
39 unsigned char SMSID[200], prevSMSID[200]; 42 unsigned char SMSID[200], prevSMSID[200];
43 GSM_SMSCSMSC;
40#ifdef HAVE_MYSQL_MYSQL_H 44#ifdef HAVE_MYSQL_MYSQL_H
@@ -44,9 +48,22 @@ typedef struct {
44 48
49typedef enum {
50 SMSD_SEND_OK = 1,
51 SMSD_SEND_SENDING_ERROR,
52 SMSD_SEND_DELIVERY_PENDING,
53 SMSD_SEND_DELIVERY_FAILED,
54 SMSD_SEND_DELIVERY_OK,
55 SMSD_SEND_DELIVERY_UNKNOWN,
56 SMSD_SEND_ERROR
57} GSM_SMSDSendingError;
58
45typedef struct { 59typedef struct {
46 GSM_Error (*Init) (GSM_SMSDConfig *Config); 60 GSM_Error (*Init) (GSM_SMSDConfig *Config);
47 GSM_Error(*SaveInboxSMS) (GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config); 61 GSM_Error(*InitAfterConnect) (GSM_SMSDConfig *Config);
48 GSM_Error(*FindOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID); 62 GSM_Error(*SaveInboxSMS) (GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config);
49 GSM_Error (*MoveSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent); 63 GSM_Error(*FindOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID);
50 GSM_Error(*CreateOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config); 64 GSM_Error (*MoveSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent);
51 GSM_Error(*AddSentSMSInfo) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK); 65 GSM_Error(*CreateOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config);
66 GSM_Error(*AddSentSMSInfo) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR);
67 GSM_Error(*RefreshSendStatus) (GSM_SMSDConfig *Config, unsigned char *ID);
68 GSM_Error(*RefreshPhoneStatus) (GSM_SMSDConfig *Config);
52} GSM_SMSDService; 69} GSM_SMSDService;
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index c67dc6a..16c5880 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -382,3 +382,3 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
382#ifdef _WIN32_ 382#ifdef _WIN32_
383 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 383 fileName = locateLocal("tmp", "tempfile.vcs")
384#else 384#else
@@ -586,3 +586,3 @@ bool PhoneFormat::save( Calendar *calendar)
586#ifdef _WIN32_ 586#ifdef _WIN32_
587 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 587 QString fileName = locateLocal("tmp", "tempfile.vcs")
588#else 588#else