summaryrefslogtreecommitdiffabout
Unidiff
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
@@ -138,25 +138,25 @@
138//#define GSM_ENABLE_BEEP 138//#define GSM_ENABLE_BEEP
139 139
140/* ---------------------- C language specific --------------------------- */ 140/* ---------------------- C language specific --------------------------- */
141 141
142#ifndef WIN32 142#ifndef WIN32
143/* are the scandir functions available */ 143/* are the scandir functions available */
144# define HAVE_DIRENT_H 1 144# define HAVE_DIRENT_H 1
145# define HAVE_SCANDIR 1 145# define HAVE_SCANDIR 1
146# define HAVE_ALPHASORT 1 146# define HAVE_ALPHASORT 1
147 147
148# define HAVE_PTHREAD 1 148# define HAVE_PTHREAD 1
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
152 152
153#define HAVE_ISWSPACE 1 153#define HAVE_ISWSPACE 1
154#define HAVE_TOWLOWER 1 154#define HAVE_TOWLOWER 1
155 155
156#ifndef WIN32 156#ifndef WIN32
157/* Will be used Bluez BT stack ? */ 157/* Will be used Bluez BT stack ? */
158// LR bluetooth disabled 158// LR bluetooth disabled
159//# define GSM_ENABLE_BLUEZ 1 159//# define GSM_ENABLE_BLUEZ 1
160/* Will be used Affix BT stack ? */ 160/* Will be used Affix BT stack ? */
161/* # undef GSM_ENABLE_AFFIX */ 161/* # undef GSM_ENABLE_AFFIX */
162#endif 162#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
@@ -147,24 +147,25 @@ device/serial/ser_djg.c \
147device/irda/irda.c \ 147device/irda/irda.c \
148device/devfunc.c \ 148device/devfunc.c \
149protocol/at/at.c \ 149protocol/at/at.c \
150protocol/alcatel/alcabus.c \ 150protocol/alcatel/alcabus.c \
151protocol/nokia/mbus2.c \ 151protocol/nokia/mbus2.c \
152protocol/nokia/fbus2.c \ 152protocol/nokia/fbus2.c \
153protocol/nokia/phonet.c \ 153protocol/nokia/phonet.c \
154protocol/obex/obex.c \ 154protocol/obex/obex.c \
155protocol/symbian/mrouter.c \ 155protocol/symbian/mrouter.c \
156phone/pfunc.c \ 156phone/pfunc.c \
157phone/at/atgen.c \ 157phone/at/atgen.c \
158phone/at/siemens.c \ 158phone/at/siemens.c \
159phone/at/samsung.c \
159phone/at/sonyeric.c \ 160phone/at/sonyeric.c \
160phone/alcatel/alcatel.c \ 161phone/alcatel/alcatel.c \
161phone/nokia/dct3/n6110.c \ 162phone/nokia/dct3/n6110.c \
162phone/nokia/dct3/n7110.c \ 163phone/nokia/dct3/n7110.c \
163phone/nokia/dct3/n9210.c \ 164phone/nokia/dct3/n9210.c \
164phone/nokia/dct3/dct3func.c \ 165phone/nokia/dct3/dct3func.c \
165phone/nokia/dct4/n3320.c \ 166phone/nokia/dct4/n3320.c \
166phone/nokia/dct4/n3650.c \ 167phone/nokia/dct4/n3650.c \
167phone/nokia/dct4/n6510.c \ 168phone/nokia/dct4/n6510.c \
168phone/nokia/dct4/dct4func.c \ 169phone/nokia/dct4/dct4func.c \
169phone/nokia/nauto.c \ 170phone/nokia/nauto.c \
170phone/nokia/nfunc.c \ 171phone/nokia/nfunc.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
@@ -148,24 +148,25 @@ device/serial/ser_djg.c \
148device/irda/irda.c \ 148device/irda/irda.c \
149device/devfunc.c \ 149device/devfunc.c \
150protocol/at/at.c \ 150protocol/at/at.c \
151protocol/alcatel/alcabus.c \ 151protocol/alcatel/alcabus.c \
152protocol/nokia/mbus2.c \ 152protocol/nokia/mbus2.c \
153protocol/nokia/fbus2.c \ 153protocol/nokia/fbus2.c \
154protocol/nokia/phonet.c \ 154protocol/nokia/phonet.c \
155protocol/obex/obex.c \ 155protocol/obex/obex.c \
156protocol/symbian/mrouter.c \ 156protocol/symbian/mrouter.c \
157phone/pfunc.c \ 157phone/pfunc.c \
158phone/at/atgen.c \ 158phone/at/atgen.c \
159phone/at/siemens.c \ 159phone/at/siemens.c \
160phone/at/samsung.c \
160phone/at/sonyeric.c \ 161phone/at/sonyeric.c \
161phone/alcatel/alcatel.c \ 162phone/alcatel/alcatel.c \
162phone/nokia/dct3/n6110.c \ 163phone/nokia/dct3/n6110.c \
163phone/nokia/dct3/n7110.c \ 164phone/nokia/dct3/n7110.c \
164phone/nokia/dct3/n9210.c \ 165phone/nokia/dct3/n9210.c \
165phone/nokia/dct3/dct3func.c \ 166phone/nokia/dct3/dct3func.c \
166phone/nokia/dct4/n3320.c \ 167phone/nokia/dct4/n3320.c \
167phone/nokia/dct4/n3650.c \ 168phone/nokia/dct4/n3650.c \
168phone/nokia/dct4/n6510.c \ 169phone/nokia/dct4/n6510.c \
169phone/nokia/dct4/dct4func.c \ 170phone/nokia/dct4/dct4func.c \
170phone/nokia/nauto.c \ 171phone/nokia/nauto.c \
171phone/nokia/nfunc.c \ 172phone/nokia/nfunc.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,13 +1,22 @@
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
3#include "../../gsmstate.h" 12#include "../../gsmstate.h"
4 13
5#ifdef GSM_ENABLE_BLUETOOTHDEVICE 14#ifdef GSM_ENABLE_BLUETOOTHDEVICE
6#ifdef GSM_ENABLE_BLUEZ 15#ifdef GSM_ENABLE_BLUEZ
7 16
8#include <stdlib.h> 17#include <stdlib.h>
9#include <stdio.h> 18#include <stdio.h>
10#include <fcntl.h> 19#include <fcntl.h>
11#include <errno.h> 20#include <errno.h>
12#include <string.h> 21#include <string.h>
13#include <sys/socket.h> 22#include <sys/socket.h>
@@ -72,54 +81,54 @@ struct search_context {
72}; 81};
73 82
74static void print_service_desc(void *value, void *user) 83static void print_service_desc(void *value, void *user)
75{ 84{
76 sdp_data_t *p = (sdp_data_t *)value; 85 sdp_data_t *p = (sdp_data_t *)value;
77 int i = 0, proto = 0, *channel = (int *)user; 86 int i = 0, proto = 0, *channel = (int *)user;
78 87
79 for (; p; p = p->next, i++) { 88 for (; p; p = p->next, i++) {
80 switch (p->dtd) { 89 switch (p->dtd) {
81 case SDP_UUID16: 90 case SDP_UUID16:
82 case SDP_UUID32: 91 case SDP_UUID32:
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;
86 case SDP_UINT8: 95 case SDP_UINT8:
87 if (proto == RFCOMM_UUID) { 96 if (proto == RFCOMM_UUID) {
88 (*channel) = p->val.uint8; 97 (*channel) = p->val.uint8;
89 return; 98 return;
90 } 99 }
91 break; 100 break;
92 } 101 }
93 } 102 }
94} 103}
95 104
96void print_access_protos(value, user) 105void print_access_protos(value, user)
97{ 106{
98 sdp_list_t *protDescSeq = (sdp_list_t *)value; 107 sdp_list_t *protDescSeq = (sdp_list_t *)value;
99 int *channel = (int *)user; 108 int *channel = (int *)user;
100 109
101 sdp_list_foreach(protDescSeq,print_service_desc,channel); 110 sdp_list_foreach(protDescSeq,print_service_desc,channel);
102} 111}
103 112
104static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context) 113static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context)
105{ 114{
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;
115 124
116 bacpy(&interface,BDADDR_ANY); 125 bacpy(&interface,BDADDR_ANY);
117 126
118 ba2str(bdaddr, str); 127 ba2str(bdaddr, str);
119 smprintf(s,"%s\n", str); 128 smprintf(s,"%s\n", str);
120 129
121 sess = sdp_connect(&interface, bdaddr, SDP_RETRY_IF_BUSY); 130 sess = sdp_connect(&interface, bdaddr, SDP_RETRY_IF_BUSY);
122 if (!sess) { 131 if (!sess) {
123 dbgprintf("Failed to connect to SDP server on %s: %s\n", str, strerror(errno)); 132 dbgprintf("Failed to connect to SDP server on %s: %s\n", str, strerror(errno));
124 return ERR_UNKNOWN; 133 return ERR_UNKNOWN;
125 } 134 }
@@ -133,63 +142,63 @@ static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, st
133 } 142 }
134 sdp_list_free(attrid, 0); 143 sdp_list_free(attrid, 0);
135 sdp_list_free(search, 0); 144 sdp_list_free(search, 0);
136 145
137 channel2 = -1; 146 channel2 = -1;
138 for (; seq; seq = next) { 147 for (; seq; seq = next) {
139 rec = (sdp_record_t *) seq->data; 148 rec = (sdp_record_t *) seq->data;
140 149
141 if (channel2 == -1) { 150 if (channel2 == -1) {
142 if (!context->tree) { 151 if (!context->tree) {
143 d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY); 152 d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY);
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 }
150 smprintf(s,"Channel %i",channel); 159 smprintf(s,"Channel %i",channel);
151 if (d) smprintf(s," - \"%s\"",d->val.str); 160 if (d) smprintf(s," - \"%s\"",d->val.str);
152 smprintf(s,"\n"); 161 smprintf(s,"\n");
153 if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) { 162 if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) {
154 channel2 = channel; 163 channel2 = channel;
155 } 164 }
156 } 165 }
157 if (sdp_get_group_id(rec,&subcontext.group) != -1) { 166 if (sdp_get_group_id(rec,&subcontext.group) != -1) {
158 memcpy(&subcontext, context, sizeof(struct search_context)); 167 memcpy(&subcontext, context, sizeof(struct search_context));
159 if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext); 168 if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext);
160 } 169 }
161 } 170 }
162 171
163 next = seq->next; 172 next = seq->next;
164 free(seq); 173 free(seq);
165 //sdp_record_free(rec); 174 sdp_record_free(rec);
166 } 175 }
167 sdp_close(sess); 176 sdp_close(sess);
168 177
169 if (channel2 != -1) return bluetooth_connect(s, channel2, str); 178 if (channel2 != -1) return bluetooth_connect(s, channel2, str);
170 179
171 return ERR_UNKNOWN; 180 return ERR_NOTSUPPORTED;
172} 181}
173 182
174GSM_Error bluetooth_findchannel(GSM_StateMachine *s) 183GSM_Error bluetooth_findchannel(GSM_StateMachine *s)
175{ 184{
176 inquiry_info ii[20]; 185 inquiry_info ii[20];
177 uint8_t count = 0; 186 uint8_t count = 0;
178 int i; 187 int i;
179 struct search_context context; 188 struct search_context context;
180 GSM_Error error = ERR_NOTSUPPORTED; 189 GSM_Error error = ERR_NOTSUPPORTED;
181 190
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
185 if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) { 194 if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) {
186 dbgprintf("Searching for devices\n"); 195 dbgprintf("Searching for devices\n");
187 if (sdp_general_inquiry(ii, 20, 8, &count) < 0) { 196 if (sdp_general_inquiry(ii, 20, 8, &count) < 0) {
188 return ERR_UNKNOWN; 197 return ERR_UNKNOWN;
189 } 198 }
190 } else { 199 } else {
191 count = 1; 200 count = 1;
192 str2ba(s->CurrentConfig->Device,&ii[0].bdaddr); 201 str2ba(s->CurrentConfig->Device,&ii[0].bdaddr);
193 } 202 }
194 for (i=0;i<count;i++) { 203 for (i=0;i<count;i++) {
195 error = bluetooth_checkdevice(s,&ii[i].bdaddr,&context); 204 error = bluetooth_checkdevice(s,&ii[i].bdaddr,&context);
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,12 +1,20 @@
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
2#include <string.h> 10#include <string.h>
3#ifdef WIN32 11#ifdef WIN32
4# include <io.h> 12# include <io.h>
5#else 13#else
6# include <errno.h> 14# include <errno.h>
7# include <signal.h> 15# include <signal.h>
8#endif 16#endif
9 17
10#include "../gsmstate.h" 18#include "../gsmstate.h"
11 19
12#ifdef GSM_ENABLE_BLUETOOTHDEVICE 20#ifdef GSM_ENABLE_BLUETOOTHDEVICE
@@ -96,25 +104,25 @@ bool unlock_device(char **lock_file)
96} 104}
97 105
98#else 106#else
99 107
100 #define max_buf_len 128 108 #define max_buf_len 128
101 #define lock_path "/var/lock/LCK.." 109 #define lock_path "/var/lock/LCK.."
102 110
103/* Lock the device. Allocated string with a lock name is returned 111/* Lock the device. Allocated string with a lock name is returned
104 * in lock_device 112 * in lock_device
105 */ 113 */
106GSM_Error lock_device(const char* port, char **lock_device) 114GSM_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;
110 char buffer[max_buf_len]; 118 char buffer[max_buf_len];
111 const char *aux; 119 const char *aux;
112 int fd, len; 120 int fd, len;
113 GSM_Errorerror = ERR_NONE; 121 GSM_Errorerror = ERR_NONE;
114 122
115 dbgprintf("Locking device\n"); 123 dbgprintf("Locking device\n");
116 124
117 aux = strrchr(port, '/'); 125 aux = strrchr(port, '/');
118 /* Remove leading '/' */ 126 /* Remove leading '/' */
119 if (aux) { 127 if (aux) {
120 aux++; 128 aux++;
@@ -209,25 +217,25 @@ failed:
209 free(lock_file); 217 free(lock_file);
210 *lock_device = 0; 218 *lock_device = 0;
211 return error; 219 return error;
212#else 220#else
213 *lock_device = 0; 221 *lock_device = 0;
214 return ERR_NONE; 222 return ERR_NONE;
215#endif 223#endif
216} 224}
217 225
218/* Removes lock and frees memory */ 226/* Removes lock and frees memory */
219bool unlock_device(char **lock_file) 227bool unlock_device(char **lock_file)
220{ 228{
221#ifndef WIN32 229#if !defined(WIN32) && !defined(DJGPP)
222 int err; 230 int err;
223 231
224 if (!lock_file) { 232 if (!lock_file) {
225 dbgprintf("Cannot unlock device\n"); 233 dbgprintf("Cannot unlock device\n");
226 return false; 234 return false;
227 } 235 }
228 err = unlink(*lock_file); 236 err = unlink(*lock_file);
229 free(*lock_file); 237 free(*lock_file);
230 *lock_file = NULL; 238 *lock_file = NULL;
231 return (err + 1); 239 return (err + 1);
232#else 240#else
233 return true; 241 return true;
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,15 +1,19 @@
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
5/* You have to include wsock32.lib library to MS VC project to compile it */ 9/* You have to include wsock32.lib library to MS VC project to compile it */
6 10
7#include "../../gsmstate.h" 11#include "../../gsmstate.h"
8 12
9#ifdef GSM_ENABLE_IRDADEVICE 13#ifdef GSM_ENABLE_IRDADEVICE
10#ifndef DJGPP 14#ifndef DJGPP
11 15
12#ifndef WIN32 16#ifndef WIN32
13# include <stdlib.h> 17# include <stdlib.h>
14# include <unistd.h> 18# include <unistd.h>
15# include <stdio.h> 19# include <stdio.h>
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,13 +1,13 @@
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
3/********************************************************************* 3/*********************************************************************
4 * 4 *
5 * Filename: irda.h 5 * Filename: irda.h
6 * Version: 6 * Version:
7 * Description: 7 * Description:
8 * Status: Experimental. 8 * Status: Experimental.
9 * Author: Dag Brattli <dagb@cs.uit.no> 9 * Author: Dag Brattli <dagb@cs.uit.no>
10 * Created at: Mon Mar 8 14:06:12 1999 10 * Created at: Mon Mar 8 14:06:12 1999
11 * Modified at: Sat Dec 25 16:06:42 1999 11 * Modified at: Sat Dec 25 16:06:42 1999
12 * Modified by: Dag Brattli <dagb@cs.uit.no> 12 * Modified by: Dag Brattli <dagb@cs.uit.no>
13 * 13 *
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
@@ -2,53 +2,53 @@
2#include "../../gsmstate.h" 2#include "../../gsmstate.h"
3 3
4#ifdef GSM_ENABLE_SERIALDEVICE 4#ifdef GSM_ENABLE_SERIALDEVICE
5#ifdef DJGPP 5#ifdef DJGPP
6 6
7#include "../../gsmcomon.h" 7#include "../../gsmcomon.h"
8#include "ser_djg.h" 8#include "ser_djg.h"
9 9
10static GSM_Error serial_close(GSM_StateMachine *s) 10static GSM_Error serial_close(GSM_StateMachine *s)
11{ 11{
12 GSM_Device_SerialData *d = &s->Device.Data.Serial; 12 GSM_Device_SerialData *d = &s->Device.Data.Serial;
13 13
14 return ERR_NONE; 14 return ERR_NOTIMPLEMENTED;
15} 15}
16 16
17static GSM_Error serial_open (GSM_StateMachine *s) 17static GSM_Error serial_open (GSM_StateMachine *s)
18{ 18{
19 GSM_Device_SerialData *d = &s->Device.Data.Serial; 19 GSM_Device_SerialData *d = &s->Device.Data.Serial;
20 20
21 return ERR_NONE; 21 return ERR_NOTIMPLEMENTED;
22} 22}
23 23
24static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) 24static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
25{ 25{
26 GSM_Device_SerialData *d = &s->Device.Data.Serial; 26 GSM_Device_SerialData *d = &s->Device.Data.Serial;
27 27
28 return ERR_NONE; 28 return ERR_NOTIMPLEMENTED;
29} 29}
30 30
31static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) 31static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
32{ 32{
33 GSM_Device_SerialData *d = &s->Device.Data.Serial; 33 GSM_Device_SerialData *d = &s->Device.Data.Serial;
34 34
35 return ERR_NONE; 35 return ERR_NOTIMPLEMENTED;
36} 36}
37 37
38static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) 38static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
39{ 39{
40 GSM_Device_SerialData *d = &s->Device.Data.Serial; 40 GSM_Device_SerialData *d = &s->Device.Data.Serial;
41 41
42 return ERR_NONE; 42 return ERR_NOTIMPLEMENTED;
43} 43}
44 44
45static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) 45static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes)
46{ 46{
47 GSM_Device_SerialData *d = &s->Device.Data.Serial; 47 GSM_Device_SerialData *d = &s->Device.Data.Serial;
48 48
49 return 0; 49 return 0;
50} 50}
51 51
52static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) 52static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes)
53{ 53{
54 GSM_Device_SerialData *d = &s->Device.Data.Serial; 54 GSM_Device_SerialData *d = &s->Device.Data.Serial;
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
@@ -1,47 +1,71 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* locking device and settings all speeds by Michal Cihar */ 2/* locking device and settings all speeds by Michal Cihar */
3/* based on some work from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
6 */
3 7
4#include "../../gsmstate.h" 8#include "../../gsmstate.h"
5 9
6#ifdef GSM_ENABLE_SERIALDEVICE 10#ifdef GSM_ENABLE_SERIALDEVICE
7#ifndef WIN32 11#ifndef WIN32
8#ifndef DJGPP 12#ifndef DJGPP
9 13
10#include <sys/file.h> 14#include <sys/file.h>
11#include <sys/time.h> 15#include <sys/time.h>
12#include <string.h> 16#include <string.h>
13#include <termios.h> 17#include <termios.h>
14#include <errno.h> 18#include <errno.h>
15 19
16#include "../../gsmcomon.h" 20#include "../../gsmcomon.h"
17#include "ser_unx.h" 21#include "ser_unx.h"
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)
20{ 48{
21 GSM_Device_SerialData *d = &s->Device.Data.Serial; 49 GSM_Device_SerialData *d = &s->Device.Data.Serial;
22 50
23 /* Restores old settings */ 51 /* Restores old settings */
24 tcsetattr(d->hPhone, TCSANOW, &d->old_settings); 52 tcsetattr(d->hPhone, TCSANOW, &d->old_settings);
25 53
26 /* Closes device */ 54 /* Closes device */
27 close(d->hPhone); 55 close(d->hPhone);
28 56
29 return ERR_NONE; 57 return ERR_NONE;
30} 58}
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)
37{ 61{
38 GSM_Device_SerialData *d = &s->Device.Data.Serial; 62 GSM_Device_SerialData *d = &s->Device.Data.Serial;
39 struct termios t; 63 struct termios t;
40 int i; 64 int i;
41 65
42 /* O_NONBLOCK MUST is required to avoid waiting for DCD */ 66 /* O_NONBLOCK MUST is required to avoid waiting for DCD */
43 d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK); 67 d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK);
44 if (d->hPhone < 0) { 68 if (d->hPhone < 0) {
45 i = errno; 69 i = errno;
46 GSM_OSErrorInfo(s,"open in serial_open"); 70 GSM_OSErrorInfo(s,"open in serial_open");
47 if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory 71 if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory
@@ -168,64 +192,68 @@ static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
168 dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down"); 192 dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down");
169 dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down"); 193 dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down");
170 if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR; 194 if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR;
171 if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR; 195 if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR;
172 196
173 return ERR_NONE; 197 return ERR_NONE;
174} 198}
175 199
176static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) 200static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
177{ 201{
178 GSM_Device_SerialData *d = &s->Device.Data.Serial; 202 GSM_Device_SerialData *d = &s->Device.Data.Serial;
179 struct termios t; 203 struct termios t;
180 int speed2 = B19200; 204 int speed2 = B19200;
181 205
182 if (tcgetattr(d->hPhone, &t)) { 206 if (tcgetattr(d->hPhone, &t)) {
183 GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed"); 207 GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed");
184 return ERR_DEVICEREADERROR; 208 return ERR_DEVICEREADERROR;
185 } 209 }
186 210
187 smprintf(s, "Setting speed to %d\n", speed); 211 smprintf(s, "Setting speed to %d\n", speed);
188 212
189 switch (speed) { 213 switch (speed) {
190 case 50: speed2 = B50; break; 214 case 50: speed2 = B50; break;
191 case 75: speed2 = B75; break; 215 case 75: speed2 = B75; break;
192 case 110: speed2 = B110; break; 216 case 110: speed2 = B110; break;
193 case 134: speed2 = B134; break; 217 case 134: speed2 = B134; break;
194 case 150: speed2 = B150; break; 218 case 150: speed2 = B150; break;
195 case 200: speed2 = B200; break; 219 case 200: speed2 = B200; break;
196 case 300: speed2 = B300; break; 220 case 300: speed2 = B300; break;
197 case 600: speed2 = B600; break; 221 case 600: speed2 = B600; break;
198 case 1200: speed2 = B1200; break; 222 case 1200: speed2 = B1200; break;
199 case 1800: speed2 = B1800; break; 223 case 1800: speed2 = B1800; break;
200 case 2400: speed2 = B2400; break; 224 case 2400: speed2 = B2400; break;
201 case 4800: speed2 = B4800; break; 225 case 4800: speed2 = B4800; break;
202 case 9600: speed2 = B9600; break; 226 case 9600: speed2 = B9600; break;
203 case 19200: speed2 = B19200;break; 227 case 19200: speed2 = B19200;break;
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;
206 case 115200: speed2 = B115200;break; 231 case 115200: speed2 = B115200;break;
207 case 230400: speed2 = B230400;break; 232 case 230400: speed2 = B230400;break;
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;
210 case 576000: speed2 = B576000;break; 236 case 576000: speed2 = B576000;break;
211 case 921600: speed2 = B921600;break; 237 case 921600: speed2 = B921600;break;
212 case 1000000: speed2 = B1000000;break; 238 case 1000000: speed2 = B1000000;break;
213 case 1152000: speed2 = B1152000;break; 239 case 1152000: speed2 = B1152000;break;
214 case 1500000: speed2 = B1500000;break; 240 case 1500000: speed2 = B1500000;break;
215 case 2000000: speed2 = B2000000;break; 241 case 2000000: speed2 = B2000000;break;
216 case 2500000: speed2 = B2500000;break; 242 case 2500000: speed2 = B2500000;break;
217 case 3000000: speed2 = B3000000;break; 243 case 3000000: speed2 = B3000000;break;
218 case 3500000: speed2 = B3500000;break; 244 case 3500000: speed2 = B3500000;break;
219 case 4000000: speed2 = B4000000; break; 245 case 4000000: speed2 = B4000000; break;
246#endif
247#endif
220 } 248 }
221 249
222 /* This should work on all systems because it is done according to POSIX */ 250 /* This should work on all systems because it is done according to POSIX */
223 cfsetispeed(&t, speed2); 251 cfsetispeed(&t, speed2);
224 cfsetospeed(&t, speed2); 252 cfsetospeed(&t, speed2);
225 253
226 if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) { 254 if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) {
227 serial_close(s); 255 serial_close(s);
228 GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed"); 256 GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed");
229 return ERR_DEVICECHANGESPEEDERROR; 257 return ERR_DEVICECHANGESPEEDERROR;
230 } 258 }
231 259
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,14 +1,18 @@
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
4#include "../../gsmstate.h" 8#include "../../gsmstate.h"
5 9
6#ifdef GSM_ENABLE_SERIALDEVICE 10#ifdef GSM_ENABLE_SERIALDEVICE
7#ifdef WIN32 11#ifdef WIN32
8 12
9#include <windows.h> 13#include <windows.h>
10#include <string.h> 14#include <string.h>
11#include <stdio.h> 15#include <stdio.h>
12#include <io.h> 16#include <io.h>
13#include <memory.h> 17#include <memory.h>
14 18
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
@@ -112,65 +112,66 @@ unsigned char *GetMsg (INI_Section *cfg, unsigned char *default_string)
112 return default_string; 112 return default_string;
113} 113}
114 114
115typedef struct { 115typedef struct {
116 GSM_Error ErrorNum; 116 GSM_Error ErrorNum;
117 unsigned char *ErrorText; 117 unsigned char *ErrorText;
118} PrintErrorEntry; 118} PrintErrorEntry;
119 119
120static PrintErrorEntry PrintErrorEntries[] = { 120static PrintErrorEntry PrintErrorEntries[] = {
121 {ERR_NONE, "No error."}, 121 {ERR_NONE, "No error."},
122 {ERR_DEVICEOPENERROR, "Error opening device. Unknown/busy or no permissions."}, 122 {ERR_DEVICEOPENERROR, "Error opening device. Unknown/busy or no permissions."},
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."},
126 {ERR_DEVICENOPERMISSION,"Error opening device. No permissions."}, 126 {ERR_DEVICENOPERMISSION,"Error opening device. No permissions."},
127 {ERR_DEVICENODRIVER, "Error opening device. No required driver in operating system."}, 127 {ERR_DEVICENODRIVER, "Error opening device. No required driver in operating system."},
128 {ERR_DEVICENOTWORK, "Error opening device. Some hardware not connected/wrong configured."}, 128 {ERR_DEVICENOTWORK, "Error opening device. Some hardware not connected/wrong configured."},
129 {ERR_DEVICEDTRRTSERROR, "Error setting device DTR or RTS."}, 129 {ERR_DEVICEDTRRTSERROR, "Error setting device DTR or RTS."},
130 {ERR_DEVICECHANGESPEEDERROR,"Error setting device speed. Maybe speed not supported."}, 130 {ERR_DEVICECHANGESPEEDERROR,"Error setting device speed. Maybe speed not supported."},
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."},
135 /* Some missed */ 135 /* Some missed */
136 {ERR_UNKNOWNRESPONSE, "Unknown response from phone. See readme.txt, how to report it."}, 136 {ERR_UNKNOWNRESPONSE, "Unknown response from phone. See readme.txt, how to report it."},
137 /* Some missed */ 137 /* Some missed */
138 {ERR_UNKNOWNCONNECTIONTYPESTRING,"Unknown connection type string. Check config file."}, 138 {ERR_UNKNOWNCONNECTIONTYPESTRING,"Unknown connection type string. Check config file."},
139 {ERR_UNKNOWNMODELSTRING,"Unknown model type string. Check config file."}, 139 {ERR_UNKNOWNMODELSTRING,"Unknown model type string. Check config file."},
140 {ERR_SOURCENOTAVAILABLE,"Some required functions not compiled for your OS. Please contact."}, 140 {ERR_SOURCENOTAVAILABLE,"Some required functions not compiled for your OS. Please contact."},
141 {ERR_NOTSUPPORTED, "Function not supported by phone."}, 141 {ERR_NOTSUPPORTED, "Function not supported by phone."},
142 {ERR_EMPTY, "Entry is empty"}, 142 {ERR_EMPTY, "Entry is empty"},
143 {ERR_SECURITYERROR, "Security error. Maybe no PIN ?"}, 143 {ERR_SECURITYERROR, "Security error. Maybe no PIN ?"},
144 {ERR_INVALIDLOCATION, "Invalid location. Maybe too high ?"}, 144 {ERR_INVALIDLOCATION, "Invalid location. Maybe too high ?"},
145 {ERR_NOTIMPLEMENTED, "Function not implemented. Help required."}, 145 {ERR_NOTIMPLEMENTED, "Function not implemented. Help required."},
146 {ERR_FULL, "Memory full."}, 146 {ERR_FULL, "Memory full."},
147 {ERR_UNKNOWN, "Unknown error."}, 147 {ERR_UNKNOWN, "Unknown error."},
148 /* Some missed */ 148 /* Some missed */
149 {ERR_CANTOPENFILE, "Can't open specified file. Read only ?"}, 149 {ERR_CANTOPENFILE, "Can't open specified file. Read only ?"},
150 {ERR_MOREMEMORY, "More memory required..."}, 150 {ERR_MOREMEMORY, "More memory required..."},
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
166 {0, ""} 167 {0, ""}
167}; 168};
168 169
169unsigned char *print_error(GSM_Error e, FILE *df, INI_Section *cfg) 170unsigned char *print_error(GSM_Error e, FILE *df, INI_Section *cfg)
170{ 171{
171 unsigned char *def = NULL; 172 unsigned char *def = NULL;
172 int i= 0; 173 int i= 0;
173 174
174 while (PrintErrorEntries[i].ErrorNum != 0) { 175 while (PrintErrorEntries[i].ErrorNum != 0) {
175 if (PrintErrorEntries[i].ErrorNum == e) { 176 if (PrintErrorEntries[i].ErrorNum == e) {
176 def = PrintErrorEntries[i].ErrorText; 177 def = PrintErrorEntries[i].ErrorText;
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
@@ -57,25 +57,26 @@ typedef enum {
57 ERR_INSIDEPHONEMENU, /* Inside phone menu - can't make something */ 57 ERR_INSIDEPHONEMENU, /* Inside phone menu - can't make something */
58 ERR_NOTCONNECTED, /* Phone NOT connected - can't make something */ 58 ERR_NOTCONNECTED, /* Phone NOT connected - can't make something */
59 ERR_WORKINPROGRESS, /* Work in progress */ 59 ERR_WORKINPROGRESS, /* Work in progress */
60 ERR_PHONEOFF, /* Phone is disabled and connected to charger */ 60 ERR_PHONEOFF, /* Phone is disabled and connected to charger */
61 ERR_FILENOTSUPPORTED, /* File format not supported by Gammu */ 61 ERR_FILENOTSUPPORTED, /* File format not supported by Gammu */
62 ERR_BUG, /* Found bug in implementation or phone */ 62 ERR_BUG, /* Found bug in implementation or phone */
63 ERR_CANCELED, /* Action was canceled by user */ 63 ERR_CANCELED, /* Action was canceled by user */
64 ERR_NEEDANOTHERANSWER, /* Inside Gammu: phone module need to send another answer frame */ 64 ERR_NEEDANOTHERANSWER, /* Inside Gammu: phone module need to send another answer frame */
65 /*40*/ERR_OTHERCONNECTIONREQUIRED, 65 /*40*/ERR_OTHERCONNECTIONREQUIRED,
66 ERR_WRONGCRC, 66 ERR_WRONGCRC,
67 ERR_INVALIDDATETIME, /* Invalid date/time */ 67 ERR_INVALIDDATETIME, /* Invalid date/time */
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;
71 72
72 extern GSM_Error NoneFunction (void); 73 extern GSM_Error NoneFunction (void);
73 extern GSM_Error NotImplementedFunction(void); 74 extern GSM_Error NotImplementedFunction(void);
74 extern GSM_Error NotSupportedFunction(void); 75 extern GSM_Error NotSupportedFunction(void);
75 76
76 #define NONEFUNCTION (void *) NoneFunction 77 #define NONEFUNCTION (void *) NoneFunction
77 #define NOTIMPLEMENTED (void *) NotImplementedFunction 78 #define NOTIMPLEMENTED (void *) NotImplementedFunction
78 #define NOTSUPPORTED (void *) NotSupportedFunction 79 #define NOTSUPPORTED (void *) NotSupportedFunction
79 80
80 unsigned char *GetMsg (INI_Section *cfg, unsigned char *default_string); 81 unsigned char *GetMsg (INI_Section *cfg, unsigned char *default_string);
81 unsigned char *print_error(GSM_Error e, FILE *df, INI_Section *cfg); 82 unsigned char *print_error(GSM_Error e, FILE *df, INI_Section *cfg);
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
@@ -177,49 +177,51 @@ GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s)
177#ifdef GSM_ENABLE_OBEXGEN 177#ifdef GSM_ENABLE_OBEXGEN
178 GSM_RegisterModule(s,&OBEXGENPhone); 178 GSM_RegisterModule(s,&OBEXGENPhone);
179#endif 179#endif
180#ifdef GSM_ENABLE_MROUTERGEN 180#ifdef GSM_ENABLE_MROUTERGEN
181 GSM_RegisterModule(s,&MROUTERGENPhone); 181 GSM_RegisterModule(s,&MROUTERGENPhone);
182#endif 182#endif
183#ifdef GSM_ENABLE_NOKIA3320 183#ifdef GSM_ENABLE_NOKIA3320
184 GSM_RegisterModule(s,&N3320Phone); 184 GSM_RegisterModule(s,&N3320Phone);
185#endif 185#endif
186#ifdef GSM_ENABLE_NOKIA3650 186#ifdef GSM_ENABLE_NOKIA3650
187 GSM_RegisterModule(s,&N3650Phone); 187 GSM_RegisterModule(s,&N3650Phone);
188#endif 188#endif
189#ifdef GSM_ENABLE_NOKIA650
190 GSM_RegisterModule(s,&N650Phone);
191#endif
189#ifdef GSM_ENABLE_NOKIA6110 192#ifdef GSM_ENABLE_NOKIA6110
190 GSM_RegisterModule(s,&N6110Phone); 193 GSM_RegisterModule(s,&N6110Phone);
191#endif 194#endif
192#ifdef GSM_ENABLE_NOKIA6510 195#ifdef GSM_ENABLE_NOKIA6510
193 GSM_RegisterModule(s,&N6510Phone); 196 GSM_RegisterModule(s,&N6510Phone);
194#endif 197#endif
195#ifdef GSM_ENABLE_NOKIA7110 198#ifdef GSM_ENABLE_NOKIA7110
196 GSM_RegisterModule(s,&N7110Phone); 199 GSM_RegisterModule(s,&N7110Phone);
197#endif 200#endif
198#ifdef GSM_ENABLE_NOKIA9210 201#ifdef GSM_ENABLE_NOKIA9210
199 GSM_RegisterModule(s,&N9210Phone); 202 GSM_RegisterModule(s,&N9210Phone);
200#endif 203#endif
201#ifdef GSM_ENABLE_ALCATEL 204#ifdef GSM_ENABLE_ALCATEL
202 GSM_RegisterModule(s,&ALCATELPhone); 205 GSM_RegisterModule(s,&ALCATELPhone);
203#endif 206#endif
204 if (s->Phone.Functions==NULL) return ERR_UNKNOWNMODELSTRING; 207 if (s->Phone.Functions==NULL) return ERR_UNKNOWNMODELSTRING;
205 return ERR_NONE; 208 return ERR_NONE;
206} 209}
207 210
208GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum) 211GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
209{ 212{
210 GSM_Errorerror; 213 GSM_Errorerror;
211 GSM_DateTimetime; 214 GSM_DateTimetime;
212 int i; 215 int i;
213 char Buffer[80];
214 216
215 for (i=0;i<s->ConfigNum;i++) { 217 for (i=0;i<s->ConfigNum;i++) {
216 s->CurrentConfig = &s->Config[i]; 218 s->CurrentConfig = &s->Config[i];
217 219
218 s->Speed = 0; 220 s->Speed = 0;
219 s->ReplyNum = ReplyNum; 221 s->ReplyNum = ReplyNum;
220 s->Phone.Data.ModelInfo = GetModelData("unknown",NULL,NULL); 222 s->Phone.Data.ModelInfo = GetModelData("unknown",NULL,NULL);
221 s->Phone.Data.Manufacturer[0] = 0; 223 s->Phone.Data.Manufacturer[0] = 0;
222 s->Phone.Data.Model[0] = 0; 224 s->Phone.Data.Model[0] = 0;
223 s->Phone.Data.Version[0] = 0; 225 s->Phone.Data.Version[0] = 0;
224 s->Phone.Data.VerDate[0] = 0; 226 s->Phone.Data.VerDate[0] = 0;
225 s->Phone.Data.VerNum = 0; 227 s->Phone.Data.VerNum = 0;
@@ -241,36 +243,34 @@ GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
241 s->LockFile = NULL; 243 s->LockFile = NULL;
242 s->opened = false; 244 s->opened = false;
243 s->Phone.Functions = NULL; 245 s->Phone.Functions = NULL;
244 246
245 s->di = di; 247 s->di = di;
246 s->di.use_global = s->CurrentConfig->UseGlobalDebugFile; 248 s->di.use_global = s->CurrentConfig->UseGlobalDebugFile;
247 GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, &s->di); 249 GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, &s->di);
248 error=GSM_SetDebugFile(s->CurrentConfig->DebugFile, &s->di); 250 error=GSM_SetDebugFile(s->CurrentConfig->DebugFile, &s->di);
249 if (error != ERR_NONE) return error; 251 if (error != ERR_NONE) return error;
250 252
251 if (s->di.dl == DL_TEXTALL || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTERROR || 253 if (s->di.dl == DL_TEXTALL || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTERROR ||
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 }
266 if (s->di.dl==DL_BINARY) { 266 if (s->di.dl==DL_BINARY) {
267 smprintf(s,"%c",((unsigned char)strlen(VERSION))); 267 smprintf(s,"%c",((unsigned char)strlen(VERSION)));
268 smprintf(s,"%s",VERSION); 268 smprintf(s,"%s",VERSION);
269 } 269 }
270 270
271 error=GSM_RegisterAllConnections(s, s->CurrentConfig->Connection); 271 error=GSM_RegisterAllConnections(s, s->CurrentConfig->Connection);
272 if (error!=ERR_NONE) return error; 272 if (error!=ERR_NONE) return error;
273 273
274 /* Model auto */ 274 /* Model auto */
275 if (s->CurrentConfig->Model[0]==0) { 275 if (s->CurrentConfig->Model[0]==0) {
276 if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) { 276 if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) {
@@ -545,40 +545,51 @@ GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer,
545 } 545 }
546 546
547 return Phone->DispatchError; 547 return Phone->DispatchError;
548} 548}
549 549
550static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Reply, int *reply) 550static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Reply, int *reply)
551{ 551{
552 GSM_Phone_Data *Data = &s->Phone.Data; 552 GSM_Phone_Data *Data = &s->Phone.Data;
553 GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg; 553 GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg;
554 bool execute; 554 bool execute;
555 bool available = false; 555 bool available = false;
556 int i = 0; 556 int i = 0;
557 //int j;
557 558
558 while (Reply[i].requestID!=ID_None) { 559 while (Reply[i].requestID!=ID_None) {
559 execute=false; 560 execute=false;
560 /* Binary frames like in Nokia */ 561 /* Binary frames like in Nokia */
561 if (strlen(Reply[i].msgtype) < 2) { 562 if (strlen(Reply[i].msgtype) < 2) {
562 if (Reply[i].msgtype[0]==msg->Type) { 563 if (Reply[i].msgtype[0]==msg->Type) {
563 if (Reply[i].subtypechar!=0) { 564 if (Reply[i].subtypechar!=0) {
564 if (Reply[i].subtypechar<=msg->Length) { 565 if (Reply[i].subtypechar<=msg->Length) {
565 if (msg->Buffer[Reply[i].subtypechar]==Reply[i].subtype) 566 if (msg->Buffer[Reply[i].subtypechar]==Reply[i].subtype)
566 execute=true; 567 execute=true;
567 } 568 }
568 } else execute=true; 569 } else execute=true;
569 } 570 }
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 }
574 } 585 }
575 586
576 if (execute) { 587 if (execute) {
577 *reply=i; 588 *reply=i;
578 if (Reply[i].requestID == ID_IncomingFrame || 589 if (Reply[i].requestID == ID_IncomingFrame ||
579 Reply[i].requestID == Data->RequestID || 590 Reply[i].requestID == Data->RequestID ||
580 Data->RequestID== ID_EachFrame) { 591 Data->RequestID== ID_EachFrame) {
581 return ERR_NONE; 592 return ERR_NONE;
582 } 593 }
583 available=true; 594 available=true;
584 } 595 }
@@ -836,46 +847,49 @@ bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num)
836 } 847 }
837 cfg->StartInfo = INI_GetValue(cfg_info, section, "startinfo", false); 848 cfg->StartInfo = INI_GetValue(cfg_info, section, "startinfo", false);
838 if (!cfg->StartInfo) { 849 if (!cfg->StartInfo) {
839 free(cfg->StartInfo); 850 free(cfg->StartInfo);
840 cfg->StartInfo = strdup(DefaultStartInfo); 851 cfg->StartInfo = strdup(DefaultStartInfo);
841 } else { 852 } else {
842 cfg->DefaultStartInfo = false; 853 cfg->DefaultStartInfo = false;
843 } 854 }
844 return true; 855 return true;
845} 856}
846 857
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}},
851 {"1100b","RH-36" ,"", {0}}, 865 {"1100b","RH-36" ,"", {0}},
852#endif 866#endif
853#ifdef GSM_ENABLE_NOKIA6110 867#ifdef GSM_ENABLE_NOKIA6110
854 {"2100" ,"NAM-2" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess 868 {"2100" ,"NAM-2" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess
855#endif 869#endif
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
863#ifdef GSM_ENABLE_NOKIA6110 877#ifdef GSM_ENABLE_NOKIA6110
864 {"3210" ,"NSE-8" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 878 {"3210" ,"NSE-8" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
865 {"3210" ,"NSE-9" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 879 {"3210" ,"NSE-9" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
866#endif 880#endif
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
871#ifdef GSM_ENABLE_NOKIA6110 885#ifdef GSM_ENABLE_NOKIA6110
872 {"3310" ,"NHM-5" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}}, 886 {"3310" ,"NHM-5" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},
873#endif 887#endif
874#ifdef GSM_ENABLE_NOKIA3320 888#ifdef GSM_ENABLE_NOKIA3320
875 {"3320" ,"NPC-1" ,"Nokia 3320", {F_CAL62,F_DAYMONTH,0}},//fixme 889 {"3320" ,"NPC-1" ,"Nokia 3320", {F_CAL62,F_DAYMONTH,0}},//fixme
876#endif 890#endif
877#ifdef GSM_ENABLE_NOKIA6110 891#ifdef GSM_ENABLE_NOKIA6110
878 {"3330" ,"NHM-6" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 892 {"3330" ,"NHM-6" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
879 {"3390" ,"NPB-1" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}}, 893 {"3390" ,"NPB-1" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
880 {"3410" ,"NHM-2" ,"", {F_RING_SM,F_CAL33,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}}, 894 {"3410" ,"NHM-2" ,"", {F_RING_SM,F_CAL33,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},
881#endif 895#endif
@@ -889,69 +903,75 @@ static OnePhoneModel allmodels[] = {
889#endif 903#endif
890#ifdef GSM_ENABLE_NOKIA6110 904#ifdef GSM_ENABLE_NOKIA6110
891 {"3610" ,"NAM-1" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess 905 {"3610" ,"NAM-1" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess
892#endif 906#endif
893#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA3650) 907#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA3650)
894 {"3650" ,"NHL-8" ,"Nokia 3650", {0}}, 908 {"3650" ,"NHL-8" ,"Nokia 3650", {0}},
895 {"NGAGE","NEM-4" ,"", {F_RADIO,0}}, 909 {"NGAGE","NEM-4" ,"", {F_RADIO,0}},
896#endif 910#endif
897#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 911#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
898 {"5100" ,"NPM-6" ,"Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 912 {"5100" ,"NPM-6" ,"Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
899 {"5100" ,"NPM-6U","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}}, 913 {"5100" ,"NPM-6U","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
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
902#ifdef GSM_ENABLE_NOKIA6110 918#ifdef GSM_ENABLE_NOKIA6110
903 {"5110" ,"NSE-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 919 {"5110" ,"NSE-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
904 {"5110i","NSE-2" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 920 {"5110i","NSE-2" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
905 {"5130" ,"NSK-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 921 {"5130" ,"NSK-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
906 {"5190" ,"NSB-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}}, 922 {"5190" ,"NSB-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
907#endif 923#endif
908#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110) 924#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
909 {"5210" ,"NSM-5" ,"Nokia 5210", {F_CAL52,F_NOSTARTANI,F_NOPICTUREUNI,F_NODTMF,0}}, 925 {"5210" ,"NSM-5" ,"Nokia 5210", {F_CAL52,F_NOSTARTANI,F_NOPICTUREUNI,F_NODTMF,0}},
910#endif 926#endif
911#ifdef GSM_ENABLE_NOKIA6110 927#ifdef GSM_ENABLE_NOKIA6110
912 {"5510" ,"NPM-5" ,"", {F_NOCALLER,F_PROFILES33,F_NOPICTUREUNI,0}}, 928 {"5510" ,"NPM-5" ,"", {F_NOCALLER,F_PROFILES33,F_NOPICTUREUNI,0}},
913#endif 929#endif
914#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 930#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
915 {"6100" ,"NPL-2" ,"Nokia 6100", {F_PBKTONEGAL,F_TODO66,0}}, 931 {"6100" ,"NPL-2" ,"Nokia 6100", {F_PBKTONEGAL,F_TODO66,0}},
916#endif 932#endif
917#ifdef GSM_ENABLE_NOKIA6110 933#ifdef GSM_ENABLE_NOKIA6110
918 {"6110" ,"NSE-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}}, 934 {"6110" ,"NSE-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
919 {"6130" ,"NSK-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}}, 935 {"6130" ,"NSK-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
920 {"6150" ,"NSM-1" ,"", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,F_NOPICTUREUNI,0}}, 936 {"6150" ,"NSM-1" ,"", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,F_NOPICTUREUNI,0}},
921 {"6190" ,"NSB-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}}, 937 {"6190" ,"NSB-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
922#endif 938#endif
923#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 939#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
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
927#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110) 943#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110)
928 {"6210" ,"NPE-3" ,"Nokia 6210", {F_VOICETAGS,F_CAL62,0}}, 944 {"6210" ,"NPE-3" ,"Nokia 6210", {F_VOICETAGS,F_CAL62,0}},
929 {"6250" ,"NHM-3" ,"Nokia 6250", {F_VOICETAGS,F_CAL62,0}}, 945 {"6250" ,"NHM-3" ,"Nokia 6250", {F_VOICETAGS,F_CAL62,0}},
930#endif 946#endif
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}},
934 {"6310i","NPL-1" ,"Nokia 6310i",{F_TODO63,F_CAL65,F_NOMIDI,F_BLUETOOTH,F_NOMMS,F_VOICETAGS,0}}, 950 {"6310i","NPL-1" ,"Nokia 6310i",{F_TODO63,F_CAL65,F_NOMIDI,F_BLUETOOTH,F_NOMMS,F_VOICETAGS,0}},
935 {"6385" ,"NHP-2AX","Nokia 6385",{F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}}, 951 {"6385" ,"NHP-2AX","Nokia 6385",{F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
936 {"6510" ,"NPM-9" ,"Nokia 6510", {F_TODO63,F_CAL65,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}}, 952 {"6510" ,"NPM-9" ,"Nokia 6510", {F_TODO63,F_CAL65,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
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
941#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110) 960#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110)
942 {"7110" ,"NSE-5" ,"Nokia 7110", {F_CAL62,0}}, 961 {"7110" ,"NSE-5" ,"Nokia 7110", {F_CAL62,0}},
943 {"7190" ,"NSB-5" ,"Nokia 7190", {F_CAL62,0}}, 962 {"7190" ,"NSB-5" ,"Nokia 7190", {F_CAL62,0}},
944#endif 963#endif
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}},
947 {"7250" ,"NHL-4J","Nokia 7250", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}}, 967 {"7250" ,"NHL-4J","Nokia 7250", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}},
948 {"7250i","NHL-4JX","Nokia 7250i",{F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}}, 968 {"7250i","NHL-4JX","Nokia 7250i",{F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}},
949 {"7600", "NMM-3", "Nokia 7600", {F_TODO66,0}}, 969 {"7600", "NMM-3", "Nokia 7600", {F_TODO66,0}},
950#endif 970#endif
951#if defined(GSM_ENABLE_ATGEN) 971#if defined(GSM_ENABLE_ATGEN)
952 {"7650" ,"NHL-2" ,"Nokia 7650", {0}}, 972 {"7650" ,"NHL-2" ,"Nokia 7650", {0}},
953#endif 973#endif
954#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110) 974#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
955 {"8210" ,"NSM-3" ,"Nokia 8210", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}}, 975 {"8210" ,"NSM-3" ,"Nokia 8210", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}},
956 {"8250" ,"NSM-3D","Nokia 8250", {F_NOWAP,F_NOSTARTANI,F_CAL82,F_NOPICTUREUNI,0}}, 976 {"8250" ,"NSM-3D","Nokia 8250", {F_NOWAP,F_NOSTARTANI,F_CAL82,F_NOPICTUREUNI,0}},
957 {"8290" ,"NSB-7" ,"Nokia 8290", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}}, 977 {"8290" ,"NSB-7" ,"Nokia 8290", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}},
@@ -966,53 +986,65 @@ static OnePhoneModel allmodels[] = {
966 {"8890" ,"NSB-6" ,"Nokia 8890", {0}}, 986 {"8890" ,"NSB-6" ,"Nokia 8890", {0}},
967#endif 987#endif
968#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510) 988#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
969 {"8910" ,"NHM-4" ,"Nokia 8910", {F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}}, 989 {"8910" ,"NHM-4" ,"Nokia 8910", {F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}},
970 {"8910i","NHM-4" ,"Nokia 8910i",{F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}}, 990 {"8910i","NHM-4" ,"Nokia 8910i",{F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}},
971#endif 991#endif
972#ifdef GSM_ENABLE_NOKIA9210 992#ifdef GSM_ENABLE_NOKIA9210
973 {"9210" ,"RAE-3" ,"", {0}}, 993 {"9210" ,"RAE-3" ,"", {0}},
974 {"9210i","RAE-5" ,"", {0}}, 994 {"9210i","RAE-5" ,"", {0}},
975#endif 995#endif
976#ifdef GSM_ENABLE_ATGEN 996#ifdef GSM_ENABLE_ATGEN
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}},
981 {"C35i" , "C35i", "", {0}}, 1003 {"C35i" , "C35i", "", {0}},
982 {"S35i" , "S35i", "", {0}}, 1004 {"S35i" , "S35i", "", {0}},
983 {"M35i" , "M35i", "", {0}}, 1005 {"M35i" , "M35i", "", {0}},
984 {"S40" , "Siemens S40", "", {0}}, 1006 {"S40" , "Siemens S40", "", {0}},
985 {"C45" , "C45", "", {0}}, 1007 {"C45" , "C45", "", {0}},
986 {"S45" , "S45", "", {0}}, 1008 {"S45" , "S45", "", {0}},
987 {"ME45" , "ME45", "", {0}}, 1009 {"ME45" , "ME45", "", {0}},
988 {"SL45" , "SL45", "", {0}}, 1010 {"SL45" , "SL45", "", {0}},
989 {"SL45i" , "SL45i", "", {0}}, 1011 {"SL45i" , "SL45i", "", {0}},
990 {"M50" , "M50", "", {0}}, 1012 {"M50" , "M50", "", {0}},
991 {"S45" , "6618" , "", {0}}, 1013 {"S45" , "6618" , "", {0}},
992 {"ME45" , "3618" , "", {0}}, 1014 {"ME45" , "3618" , "", {0}},
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}},
995 {"R320s" , "1101201-BV R320s","", {0}}, 1026 {"R320s" , "1101201-BV R320s","", {0}},
996 {"R380s", "7100101-BVR380s" ,"", {0}}, 1027 {"R380s", "7100101-BVR380s" ,"", {0}},
997 {"R520m", "1130101-BVR520m" ,"", {0}}, 1028 {"R520m", "1130101-BVR520m" ,"", {0}},
998 {"T39m", "1130102-BVT39m" ,"", {0}}, 1029 {"T39m", "1130102-BVT39m" ,"", {0}},
999 {"T65", "1101901-BVT65" , "", {0}}, 1030 {"T65", "1101901-BVT65" , "", {0}},
1000 {"T68", "1130201-BVT68" , "", {0}}, 1031 {"T68", "1130201-BVT68" , "", {0}},
1001 {"T68i", "1130202-BVT68" , "", {0}}, 1032 {"T68i", "1130202-BVT68" , "", {0}},
1002 {"R600", "102001-BVR600" , "", {0}}, 1033 {"R600", "102001-BVR600" , "", {0}},
1003 {"T200", "1130501-BVT200" ,"", {0}}, 1034 {"T200", "1130501-BVT200" ,"", {0}},
1004 {"T300", "1130601-BVT300" ,"T300", {0}}, 1035 {"T300", "1130601-BVT300" ,"T300", {0}},
1005 {"T310", "1130602-BVT310" ,"", {0}}, 1036 {"T310", "1130602-BVT310" ,"", {0}},
1006 {"P800", "7130501-BVP800" ,"", {0}}, 1037 {"P800", "7130501-BVP800" ,"", {0}},
1038 /* Other */
1007 {"iPAQ" , "iPAQ" , "" , {0}}, 1039 {"iPAQ" , "iPAQ" , "" , {0}},
1008 {"A2D" , "A2D" , "" , {0}}, 1040 {"A2D" , "A2D" , "" , {0}},
1009 {"9210" , "RAE-3", "Nokia Communicator GSM900/1800",{0}}, 1041 {"9210" , "RAE-3", "Nokia Communicator GSM900/1800",{0}},
1010 {"myV-65", "myV-65 GPRS", "", {F_SMSME900,0}}, 1042 {"myV-65", "myV-65 GPRS", "", {F_SMSME900,0}},
1011#endif 1043#endif
1012#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_ALCATEL) 1044#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_ALCATEL)
1013 {"BE5", "ONE TOUCH 500","", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}}, 1045 {"BE5", "ONE TOUCH 500","", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}},
1014 {"BH4", "ONE TOUCH 535","ALCATEL OT535", {F_ALCATEL,F_SMSONLYSENT,0}}, 1046 {"BH4", "ONE TOUCH 535","ALCATEL OT535", {F_ALCATEL,F_SMSONLYSENT,0}},
1015 {"BF5", "ONE TOUCH 715","ALCATEL OT715", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}}, 1047 {"BF5", "ONE TOUCH 715","ALCATEL OT715", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}},
1016#endif 1048#endif
1017 {"unknown", "" ,"", {0}} 1049 {"unknown", "" ,"", {0}}
1018}; 1050};
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
@@ -1,28 +1,36 @@
1/* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */
2 2
3#ifndef __gsm_state_h 3#ifndef __gsm_state_h
4#define __gsm_state_h 4#define __gsm_state_h
5 5
6#include <time.h> 6#include <time.h>
7 7
8#include "config.h" 8#include "config.h"
9#include "misc/cfg.h" 9#include "misc/cfg.h"
10 10
11 typedef struct _GSM_StateMachine GSM_StateMachine;
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
12# include "phone/nokia/dct4/n3320.h" 17# include "phone/nokia/dct4/n3320.h"
13#endif 18#endif
14#ifdef GSM_ENABLE_NOKIA3650 19#ifdef GSM_ENABLE_NOKIA3650
15# include "phone/nokia/dct4/n3650.h" 20# include "phone/nokia/dct4/n3650.h"
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
18# include "phone/nokia/dct3/n6110.h" 26# include "phone/nokia/dct3/n6110.h"
19#endif 27#endif
20#ifdef GSM_ENABLE_NOKIA6510 28#ifdef GSM_ENABLE_NOKIA6510
21# include "phone/nokia/dct4/n6510.h" 29# include "phone/nokia/dct4/n6510.h"
22#endif 30#endif
23#ifdef GSM_ENABLE_NOKIA7110 31#ifdef GSM_ENABLE_NOKIA7110
24# include "phone/nokia/dct3/n7110.h" 32# include "phone/nokia/dct3/n7110.h"
25#endif 33#endif
26#ifdef GSM_ENABLE_NOKIA9210 34#ifdef GSM_ENABLE_NOKIA9210
27# include "phone/nokia/dct3/n9210.h" 35# include "phone/nokia/dct3/n9210.h"
28#endif 36#endif
@@ -85,25 +93,25 @@
85# undef GSM_ENABLE_BLUEPHONET 93# undef GSM_ENABLE_BLUEPHONET
86#endif 94#endif
87#ifndef GSM_USED_BLUEAT 95#ifndef GSM_USED_BLUEAT
88# undef GSM_ENABLE_BLUEAT 96# undef GSM_ENABLE_BLUEAT
89#endif 97#endif
90#ifndef GSM_USED_IRDAAT 98#ifndef GSM_USED_IRDAAT
91# undef GSM_ENABLE_IRDAAT 99# undef GSM_ENABLE_IRDAAT
92#endif 100#endif
93#ifndef GSM_USED_MROUTERBLUE 101#ifndef GSM_USED_MROUTERBLUE
94# undef GSM_ENABLE_MROUTERBLUE 102# undef GSM_ENABLE_MROUTERBLUE
95#endif 103#endif
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
99#endif 107#endif
100#if defined(GSM_ENABLE_NOKIA3650) || defined(GSM_ENABLE_NOKIA6510) 108#if defined(GSM_ENABLE_NOKIA3650) || defined(GSM_ENABLE_NOKIA6510)
101# define GSM_ENABLE_NOKIA_DCT4 109# define GSM_ENABLE_NOKIA_DCT4
102#endif 110#endif
103 111
104#include "protocol/protocol.h" 112#include "protocol/protocol.h"
105#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) 113#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303)
106# include "protocol/nokia/fbus2.h" 114# include "protocol/nokia/fbus2.h"
107#endif 115#endif
108#ifdef GSM_ENABLE_MBUS2 116#ifdef GSM_ENABLE_MBUS2
109# include "protocol/nokia/mbus2.h" 117# include "protocol/nokia/mbus2.h"
@@ -190,27 +198,24 @@
190#include "service/gsmring.h" 198#include "service/gsmring.h"
191#include "service/gsmcal.h" 199#include "service/gsmcal.h"
192#include "service/gsmdata.h" 200#include "service/gsmdata.h"
193#include "service/gsmlogo.h" 201#include "service/gsmlogo.h"
194#include "service/gsmmisc.h" 202#include "service/gsmmisc.h"
195#include "service/gsmprof.h" 203#include "service/gsmprof.h"
196#include "service/gsmcall.h" 204#include "service/gsmcall.h"
197#include "service/sms/gsmsms.h" 205#include "service/sms/gsmsms.h"
198#include "service/sms/gsmems.h" 206#include "service/sms/gsmems.h"
199#include "service/sms/gsmmulti.h" 207#include "service/sms/gsmmulti.h"
200#include "service/backup/gsmback.h" 208#include "service/backup/gsmback.h"
201 209
202typedef struct _GSM_StateMachine GSM_StateMachine;
203 typedef struct _GSM_User GSM_User;
204 typedef struct _OnePhoneModel OnePhoneModel;
205 210
206/* ------------------------- Device layer ---------------------------------- */ 211/* ------------------------- Device layer ---------------------------------- */
207 212
208/** 213/**
209 * Device functions, each device has to provide these. 214 * Device functions, each device has to provide these.
210 */ 215 */
211typedef struct { 216typedef struct {
212 /** 217 /**
213 * Opens device. 218 * Opens device.
214 */ 219 */
215 GSM_Error (*OpenDevice) (GSM_StateMachine *s); 220 GSM_Error (*OpenDevice) (GSM_StateMachine *s);
216 /** 221 /**
@@ -362,24 +367,26 @@ typedef enum {
362 ID_GetFirmware, 367 ID_GetFirmware,
363 ID_EnableSecurity, 368 ID_EnableSecurity,
364 ID_GetIMEI, 369 ID_GetIMEI,
365 ID_GetDateTime, 370 ID_GetDateTime,
366 ID_GetAlarm, 371 ID_GetAlarm,
367 ID_GetMemory, 372 ID_GetMemory,
368 ID_GetMemoryStatus, 373 ID_GetMemoryStatus,
369 ID_GetSMSC, 374 ID_GetSMSC,
370 ID_GetSMSMessage, 375 ID_GetSMSMessage,
371 ID_EnableEcho, 376 ID_EnableEcho,
372 ID_EnableErrorInfo, 377 ID_EnableErrorInfo,
373 ID_SetOBEX, 378 ID_SetOBEX,
379 ID_SetUSSD,
380 ID_GetNote,
374 ID_GetSignalQuality, 381 ID_GetSignalQuality,
375 ID_GetBatteryCharge, 382 ID_GetBatteryCharge,
376 ID_GetSMSFolders, 383 ID_GetSMSFolders,
377 ID_GetSMSFolderStatus, 384 ID_GetSMSFolderStatus,
378 ID_GetSMSStatus, 385 ID_GetSMSStatus,
379 ID_AddSMSFolder, 386 ID_AddSMSFolder,
380 ID_GetNetworkInfo, 387 ID_GetNetworkInfo,
381 ID_GetRingtone, 388 ID_GetRingtone,
382 ID_DialVoice, 389 ID_DialVoice,
383 ID_GetCalendarNotesInfo, 390 ID_GetCalendarNotesInfo,
384 ID_GetCalendarNote, 391 ID_GetCalendarNote,
385 ID_GetSecurityCode, 392 ID_GetSecurityCode,
@@ -429,24 +436,25 @@ typedef enum {
429 ID_GetHardware, 436 ID_GetHardware,
430 ID_GetPPM, 437 ID_GetPPM,
431 ID_GetSMSMode, 438 ID_GetSMSMode,
432 ID_GetSMSMemories, 439 ID_GetSMSMemories,
433 ID_GetManufacturer, 440 ID_GetManufacturer,
434 ID_SetMemoryType, 441 ID_SetMemoryType,
435 ID_SetMemoryCharset, 442 ID_SetMemoryCharset,
436 ID_GetMMSSettings, 443 ID_GetMMSSettings,
437 ID_SetSMSParameters, 444 ID_SetSMSParameters,
438 ID_GetFMStation, 445 ID_GetFMStation,
439 ID_SetFMStation, 446 ID_SetFMStation,
440 ID_GetLanguage, 447 ID_GetLanguage,
448 ID_SetFastSMSSending,
441 ID_Reset, 449 ID_Reset,
442 ID_GetToDo, 450 ID_GetToDo,
443 ID_PressKey, 451 ID_PressKey,
444 ID_DeleteAllToDo, 452 ID_DeleteAllToDo,
445 ID_SetLight, 453 ID_SetLight,
446 ID_Divert, 454 ID_Divert,
447 ID_SetToDo, 455 ID_SetToDo,
448 ID_PlayTone, 456 ID_PlayTone,
449 ID_GetChatSettings, 457 ID_GetChatSettings,
450 ID_GetSyncMLSettings, 458 ID_GetSyncMLSettings,
451 ID_GetSyncMLName, 459 ID_GetSyncMLName,
452 ID_GetSecurityStatus, 460 ID_GetSecurityStatus,
@@ -660,24 +668,25 @@ typedef struct {
660 /** 668 /**
661 * Used internally by phone drivers. 669 * Used internally by phone drivers.
662 */ 670 */
663 unsigned char *Netmonitor; 671 unsigned char *Netmonitor;
664 /** 672 /**
665 * Pointer to structure used internally by phone drivers. 673 * Pointer to structure used internally by phone drivers.
666 */ 674 */
667 GSM_MultiCallDivert*Divert; 675 GSM_MultiCallDivert*Divert;
668 /** 676 /**
669 * Pointer to structure used internally by phone drivers. 677 * Pointer to structure used internally by phone drivers.
670 */ 678 */
671 GSM_ToDoEntry *ToDo; 679 GSM_ToDoEntry *ToDo;
680 GSM_NoteEntry *Note;
672 /** 681 /**
673 * Used internally by phone drivers. 682 * Used internally by phone drivers.
674 */ 683 */
675 bool PressKey; 684 bool PressKey;
676 /** 685 /**
677 * Pointer to structure used internally by phone drivers. 686 * Pointer to structure used internally by phone drivers.
678 */ 687 */
679 GSM_SecurityCodeType*SecurityStatus; 688 GSM_SecurityCodeType*SecurityStatus;
680 /** 689 /**
681 * Pointer to structure used internally by phone drivers. 690 * Pointer to structure used internally by phone drivers.
682 */ 691 */
683 GSM_Profile *Profile; 692 GSM_Profile *Profile;
@@ -761,24 +770,27 @@ typedef struct {
761 770
762 /** 771 /**
763 * Structure with private phone modules data. 772 * Structure with private phone modules data.
764 */ 773 */
765 struct { 774 struct {
766 int fake; 775 int fake;
767#ifdef GSM_ENABLE_NOKIA3320 776#ifdef GSM_ENABLE_NOKIA3320
768 GSM_Phone_N3320Data N3320; 777 GSM_Phone_N3320Data N3320;
769#endif 778#endif
770#ifdef GSM_ENABLE_NOKIA3650 779#ifdef GSM_ENABLE_NOKIA3650
771 GSM_Phone_N3650Data N3650; 780 GSM_Phone_N3650Data N3650;
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
774 GSM_Phone_N6110Data N6110; 786 GSM_Phone_N6110Data N6110;
775#endif 787#endif
776#ifdef GSM_ENABLE_NOKIA6510 788#ifdef GSM_ENABLE_NOKIA6510
777 GSM_Phone_N6510Data N6510; 789 GSM_Phone_N6510Data N6510;
778#endif 790#endif
779#ifdef GSM_ENABLE_NOKIA7110 791#ifdef GSM_ENABLE_NOKIA7110
780 GSM_Phone_N7110Data N7110; 792 GSM_Phone_N7110Data N7110;
781#endif 793#endif
782#ifdef GSM_ENABLE_ATGEN 794#ifdef GSM_ENABLE_ATGEN
783 GSM_Phone_ATGENData ATGEN; 795 GSM_Phone_ATGENData ATGEN;
784#endif 796#endif
@@ -795,49 +807,49 @@ typedef struct {
795} GSM_Phone_Data; 807} GSM_Phone_Data;
796 808
797/** 809/**
798 * Structure for defining reply functions. 810 * Structure for defining reply functions.
799 * 811 *
800 * Function is called when requestID matches current operation or is 812 * Function is called when requestID matches current operation or is
801 * ID_IncomingFrame and msgtype matches start message and (if msgtype is just 813 * ID_IncomingFrame and msgtype matches start message and (if msgtype is just
802 * one character) subtypechar is zero or subtypechar-th character of message 814 * one character) subtypechar is zero or subtypechar-th character of message
803 * matches subtype. 815 * matches subtype.
804 * 816 *
805 * Should be used in array with last element containing ID_None as requestID. 817 * Should be used in array with last element containing ID_None as requestID.
806 */ 818 */
807typedef struct { 819struct _GSM_Reply_Function {
808 /** 820 /**
809 * Pointer to function that should be executed. 821 * Pointer to function that should be executed.
810 */ 822 */
811 GSM_Error (*Function)(GSM_Protocol_Message msg, GSM_StateMachine *s); 823 GSM_Error (*Function)(GSM_Protocol_Message msg, GSM_StateMachine *s);
812 /** 824 /**
813 * Message type, if it is longer than 1 character, it disables subtype 825 * Message type, if it is longer than 1 character, it disables subtype
814 * checking. 826 * checking.
815 */ 827 */
816 unsigned char *msgtype; 828 unsigned char *msgtype;
817 /** 829 /**
818 * Which character of message should be checked as subtype. Zero to 830 * Which character of message should be checked as subtype. Zero to
819 * disable subtype checking. 831 * disable subtype checking.
820 */ 832 */
821 int subtypechar; 833 int subtypechar;
822 /** 834 /**
823 * Subtype to be checked. 835 * Subtype to be checked.
824 */ 836 */
825 unsigned char subtype; 837 unsigned char subtype;
826 /** 838 /**
827 * Phone request when this can be called, use ID_IncomingFrame when 839 * Phone request when this can be called, use ID_IncomingFrame when
828 * you want to use this in any state. 840 * you want to use this in any state.
829 */ 841 */
830 GSM_Phone_RequestIDrequestID; 842 GSM_Phone_RequestIDrequestID;
831} GSM_Reply_Function; 843};
832 844
833/** 845/**
834 * Structure defining phone functions. 846 * Structure defining phone functions.
835 */ 847 */
836typedef struct { 848typedef struct {
837 /** 849 /**
838 * Names of supported models separated by |. Must contain at least one 850 * Names of supported models separated by |. Must contain at least one
839 * name. 851 * name.
840 */ 852 */
841 char *models; 853 char *models;
842 /** 854 /**
843 * Array of reply functions for the phone, see 855 * Array of reply functions for the phone, see
@@ -1050,24 +1062,25 @@ typedef struct {
1050 /** 1062 /**
1051 * Deletes SMS. 1063 * Deletes SMS.
1052 */ 1064 */
1053 GSM_Error (*DeleteSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1065 GSM_Error (*DeleteSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
1054 /** 1066 /**
1055 * Sends SMS. 1067 * Sends SMS.
1056 */ 1068 */
1057 GSM_Error (*SendSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms); 1069 GSM_Error (*SendSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
1058 /** 1070 /**
1059 * Sends SMS already saved in phone. 1071 * Sends SMS already saved in phone.
1060 */ 1072 */
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 /**
1063 * Enable/disable notification on incoming SMS. 1076 * Enable/disable notification on incoming SMS.
1064 */ 1077 */
1065 GSM_Error (*SetIncomingSMS) (GSM_StateMachine *s, bool enable); 1078 GSM_Error (*SetIncomingSMS) (GSM_StateMachine *s, bool enable);
1066 /** 1079 /**
1067 * Gets network information from phone. 1080 * Gets network information from phone.
1068 */ 1081 */
1069 GSM_Error (*SetIncomingCB) (GSM_StateMachine *s, bool enable); 1082 GSM_Error (*SetIncomingCB) (GSM_StateMachine *s, bool enable);
1070 /** 1083 /**
1071 * Returns SMS folders information. 1084 * Returns SMS folders information.
1072 */ 1085 */
1073 GSM_Error (*GetSMSFolders) (GSM_StateMachine *s, GSM_SMSFolders *folders); 1086 GSM_Error (*GetSMSFolders) (GSM_StateMachine *s, GSM_SMSFolders *folders);
@@ -1270,25 +1283,25 @@ typedef struct {
1270 GSM_Error (*DeleteAllCalendar) (GSM_StateMachine *s); 1283 GSM_Error (*DeleteAllCalendar) (GSM_StateMachine *s);
1271 /** 1284 /**
1272 * Reads calendar settings. 1285 * Reads calendar settings.
1273 */ 1286 */
1274 GSM_Error (*GetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings); 1287 GSM_Error (*GetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings);
1275 /** 1288 /**
1276 * Sets calendar settings. 1289 * Sets calendar settings.
1277 */ 1290 */
1278 GSM_Error (*SetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings); 1291 GSM_Error (*SetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings);
1279 /** 1292 /**
1280 * Gets note. 1293 * Gets note.
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 /**
1284 * Reads profile. 1297 * Reads profile.
1285 */ 1298 */
1286 GSM_Error (*GetProfile) (GSM_StateMachine *s, GSM_Profile *Profile); 1299 GSM_Error (*GetProfile) (GSM_StateMachine *s, GSM_Profile *Profile);
1287 /** 1300 /**
1288 * Updates profile. 1301 * Updates profile.
1289 */ 1302 */
1290 GSM_Error (*SetProfile) (GSM_StateMachine *s, GSM_Profile *Profile); 1303 GSM_Error (*SetProfile) (GSM_StateMachine *s, GSM_Profile *Profile);
1291 /** 1304 /**
1292 * Reads FM station. 1305 * Reads FM station.
1293 */ 1306 */
1294 GSM_Error (*GetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation); 1307 GSM_Error (*GetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation);
@@ -1335,24 +1348,27 @@ typedef struct {
1335} GSM_Phone_Functions; 1348} GSM_Phone_Functions;
1336 1349
1337 extern GSM_Phone_Functions NAUTOPhone; 1350 extern GSM_Phone_Functions NAUTOPhone;
1338#ifdef GSM_ENABLE_NOKIA3320 1351#ifdef GSM_ENABLE_NOKIA3320
1339 extern GSM_Phone_Functions N3320Phone; 1352 extern GSM_Phone_Functions N3320Phone;
1340#endif 1353#endif
1341#ifdef GSM_ENABLE_NOKIA3650 1354#ifdef GSM_ENABLE_NOKIA3650
1342 extern GSM_Phone_Functions N3650Phone; 1355 extern GSM_Phone_Functions N3650Phone;
1343#endif 1356#endif
1344#ifdef GSM_ENABLE_NOKIA6110 1357#ifdef GSM_ENABLE_NOKIA6110
1345 extern GSM_Phone_Functions N6110Phone; 1358 extern GSM_Phone_Functions N6110Phone;
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
1348 extern GSM_Phone_Functions N6510Phone; 1364 extern GSM_Phone_Functions N6510Phone;
1349#endif 1365#endif
1350#ifdef GSM_ENABLE_NOKIA7110 1366#ifdef GSM_ENABLE_NOKIA7110
1351 extern GSM_Phone_Functions N7110Phone; 1367 extern GSM_Phone_Functions N7110Phone;
1352#endif 1368#endif
1353#ifdef GSM_ENABLE_NOKIA9210 1369#ifdef GSM_ENABLE_NOKIA9210
1354 extern GSM_Phone_Functions N9210Phone; 1370 extern GSM_Phone_Functions N9210Phone;
1355#endif 1371#endif
1356#ifdef GSM_ENABLE_ATGEN 1372#ifdef GSM_ENABLE_ATGEN
1357 extern GSM_Phone_Functions ATGENPhone; 1373 extern GSM_Phone_Functions ATGENPhone;
1358#endif 1374#endif
@@ -1514,24 +1530,25 @@ typedef enum {
1514 F_NOMIDI, /* No ringtones in MIDI */ 1530 F_NOMIDI, /* No ringtones in MIDI */
1515 F_BLUETOOTH, /* Bluetooth support */ 1531 F_BLUETOOTH, /* Bluetooth support */
1516 F_NOFILESYSTEM, /* No images, ringtones, java saved in special filesystem*/ 1532 F_NOFILESYSTEM, /* No images, ringtones, java saved in special filesystem*/
1517 F_NOMMS, /* No MMS sets in phone */ 1533 F_NOMMS, /* No MMS sets in phone */
1518 F_NOGPRSPOINT, /* GPRS point are not useable */ 1534 F_NOGPRSPOINT, /* GPRS point are not useable */
1519 F_CAL35, /* Calendar,3510 style - Reminder,Call,Birthday */ 1535 F_CAL35, /* Calendar,3510 style - Reminder,Call,Birthday */
1520 F_CAL65, /* Calendar,6510 style - CBMM, method 3 */ 1536 F_CAL65, /* Calendar,6510 style - CBMM, method 3 */
1521 F_WAPMMSPROXY, /* WAP & MMS settings contains first & second proxy */ 1537 F_WAPMMSPROXY, /* WAP & MMS settings contains first & second proxy */
1522 1538
1523 /* n6510.c && n7110.c */ 1539 /* n6510.c && n7110.c */
1524 F_VOICETAGS, /* Voice tags available */ 1540 F_VOICETAGS, /* Voice tags available */
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
1527 /* AT modules */ 1544 /* AT modules */
1528 F_SMSONLYSENT, /* Phone supports only sent/unsent messages */ 1545 F_SMSONLYSENT, /* Phone supports only sent/unsent messages */
1529 F_BROKENCPBS, /* CPBS on some memories can hang phone */ 1546 F_BROKENCPBS, /* CPBS on some memories can hang phone */
1530 F_M20SMS, /* Siemens M20 like SMS handling */ 1547 F_M20SMS, /* Siemens M20 like SMS handling */
1531 F_SLOWWRITE, /* Use slower writing which some phone need */ 1548 F_SLOWWRITE, /* Use slower writing which some phone need */
1532 F_SMSME900, /* SMS in ME start from location 900 - case of Sagem */ 1549 F_SMSME900, /* SMS in ME start from location 900 - case of Sagem */
1533 F_ALCATEL /* Phone supports Alcatel protocol */ 1550 F_ALCATEL /* Phone supports Alcatel protocol */
1534} Feature; 1551} Feature;
1535 1552
1536/* For models table */ 1553/* For models table */
1537struct _OnePhoneModel { 1554struct _OnePhoneModel {
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,30 +1,183 @@
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
4#include <stdio.h> 8#include <stdio.h>
5#include <stdlib.h> 9#include <stdlib.h>
6#include <string.h> 10#include <string.h>
7#include <ctype.h> 11#include <ctype.h>
8#include <locale.h> 12#include <locale.h>
9#ifndef __OpenBSD__ 13#ifndef __OpenBSD__
10# include <wctype.h> 14# include <wctype.h>
11#endif 15#endif
12#ifdef WIN32 16#ifdef WIN32
13# include "windows.h" 17# include "windows.h"
14#endif 18#endif
15 19
16#include "../misc.h" 20#include "../misc.h"
17#include "coding.h" 21#include "coding.h"
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)
20{ 173{
21 unsigned int len = 0; 174 unsigned int len = 0;
22 175
23 if (str == NULL) return 0; 176 if (str == NULL) return 0;
24 177
25 while(str[len*2] != 0 || str[len*2+1] != 0) len++; 178 while(str[len*2] != 0 || str[len*2+1] != 0) len++;
26 179
27 return len; 180 return len;
28} 181}
29 182
30/* Convert Unicode char saved in src to dest */ 183/* Convert Unicode char saved in src to dest */
@@ -577,32 +730,32 @@ void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, boo
577 unsigned char Buffer[50]= ""; 730 unsigned char Buffer[50]= "";
578 int length = Number[0]; 731 int length = Number[0];
579 732
580 if (semioctet) { 733 if (semioctet) {
581 /* Convert number of semioctets to number of chars */ 734 /* Convert number of semioctets to number of chars */
582 if (length % 2) length++; 735 if (length % 2) length++;
583 length=length / 2 + 1; 736 length=length / 2 + 1;
584 } 737 }
585 738
586 /*without leading byte with format of number*/ 739 /*without leading byte with format of number*/
587 length--; 740 length--;
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++;
592 dbgprintf("Alphanumeric number, length %i\n",length); 745 dbgprintf("Alphanumeric number, length %i\n",length);
593 GSM_UnpackEightBitsToSeven(0, length, length, Number+2, Buffer); 746 GSM_UnpackEightBitsToSeven(0, length, length, Number+2, Buffer);
594 Buffer[length]=0; 747 Buffer[length]=0;
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");
598 Buffer[0]='+'; 751 Buffer[0]='+';
599 DecodeBCD(Buffer+1,Number+2, length); 752 DecodeBCD(Buffer+1,Number+2, length);
600 break; 753 break;
601 default: 754 default:
602 dbgprintf("Default number %02x\n",Number[1]); 755 dbgprintf("Default number %02x\n",Number[1]);
603 DecodeBCD (Buffer, Number+2, length); 756 DecodeBCD (Buffer, Number+2, length);
604 break; 757 break;
605 } 758 }
606 759
607 EncodeUnicode(retval,Buffer,strlen(Buffer)); 760 EncodeUnicode(retval,Buffer,strlen(Buffer));
608} 761}
@@ -622,48 +775,48 @@ void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, boo
622 * 775 *
623 * 1 semioctet = 4 bits = half of byte 776 * 1 semioctet = 4 bits = half of byte
624 */ 777 */
625int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool semioctet) 778int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool semioctet)
626{ 779{
627 unsigned charformat, buffer[50]; 780 unsigned charformat, buffer[50];
628 int length, i; 781 int length, i;
629 782
630 length=UnicodeLength(Number); 783 length=UnicodeLength(Number);
631 memcpy(buffer,DecodeUnicodeString(Number),length+1); 784 memcpy(buffer,DecodeUnicodeString(Number),length+1);
632 785
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++) {
636 /* first byte is '+'. Number can be international */ 789 /* first byte is '+'. Number can be international */
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 }
643 } 796 }
644 797
645 /** 798 /**
646 * First byte is used for saving type of number. See GSM 03.40 799 * First byte is used for saving type of number. See GSM 03.40
647 * section 9.1.2.5 800 * section 9.1.2.5
648 */ 801 */
649 Output[0]=format; 802 Output[0]=format;
650 803
651 /* After number type we will have number. GSM 03.40 section 9.1.2 */ 804 /* After number type we will have number. GSM 03.40 section 9.1.2 */
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;
655 if (strlen(buffer)==7) length--; 808 if (strlen(buffer)==7) length--;
656 break; 809 break;
657 case NUMBER_INTERNATIONAL: 810 case NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN:
658 length--; 811 length--;
659 EncodeBCD (Output+1, buffer+1, length, true); 812 EncodeBCD (Output+1, buffer+1, length, true);
660 break; 813 break;
661 default: 814 default:
662 EncodeBCD (Output+1, buffer, length, true); 815 EncodeBCD (Output+1, buffer, length, true);
663 break; 816 break;
664 } 817 }
665 818
666 if (semioctet) return length; 819 if (semioctet) return length;
667 820
668 /* Convert number of semioctets to number of chars */ 821 /* Convert number of semioctets to number of chars */
669 if (length % 2) length++; 822 if (length % 2) length++;
@@ -910,45 +1063,45 @@ void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *sr
910 } 1063 }
911 } 1064 }
912 dest[current++] = 0x00; 1065 dest[current++] = 0x00;
913 dest[current++] = 0x00; 1066 dest[current++] = 0x00;
914} 1067}
915 1068
916bool mystrncasecmp(unsigned const char *a, unsigned const char *b, int num) 1069bool mystrncasecmp(unsigned const char *a, unsigned const char *b, int num)
917{ 1070{
918 int i; 1071 int i;
919 1072
920 if (a == NULL || b == NULL) return false; 1073 if (a == NULL || b == NULL) return false;
921 1074
922 num--; 1075 if (num == 0) num = -1;
923 1076
924 for (i = 0; i != num; i++) { 1077 for (i = 0; i != num; i++) {
925 if (a[i] == 0x00 && b[i] == 0x00) return true; 1078 if (a[i] == 0x00 && b[i] == 0x00) return true;
926 if (a[i] == 0x00 || b[i] == 0x00) return false; 1079 if (a[i] == 0x00 || b[i] == 0x00) return false;
927 if (tolower(a[i]) != tolower(b[i])) return false; 1080 if (tolower(a[i]) != tolower(b[i])) return false;
928 } 1081 }
929 return true; 1082 return true;
930} 1083}
931 1084
932/* Compares two Unicode strings without regarding to case. 1085/* Compares two Unicode strings without regarding to case.
933 * Return true, when they're equal 1086 * Return true, when they're equal
934 */ 1087 */
935bool mywstrncasecmp(unsigned const char *a, unsigned const char *b, int num) 1088bool mywstrncasecmp(unsigned const char *a, unsigned const char *b, int num)
936{ 1089{
937 int i; 1090 int i;
938 wchar_t wc,wc2; 1091 wchar_t wc,wc2;
939 1092
940 if (a == NULL || b == NULL) return false; 1093 if (a == NULL || b == NULL) return false;
941 1094
942 num--; 1095 if (num == 0) num = -1;
943 1096
944 for (i = 0; i != num; i++) { 1097 for (i = 0; i != num; i++) {
945 if ((a[i*2] == 0x00 && a[i*2+1] == 0x00) && (b[i*2] == 0x00 && b[i*2+1] == 0x00)) return true; 1098 if ((a[i*2] == 0x00 && a[i*2+1] == 0x00) && (b[i*2] == 0x00 && b[i*2+1] == 0x00)) return true;
946 if ((a[i*2] == 0x00 && a[i*2+1] == 0x00) || (b[i*2] == 0x00 && b[i*2+1] == 0x00)) return false; 1099 if ((a[i*2] == 0x00 && a[i*2+1] == 0x00) || (b[i*2] == 0x00 && b[i*2+1] == 0x00)) return false;
947 wc = a[i*2+1] | (a[i*2] << 8); 1100 wc = a[i*2+1] | (a[i*2] << 8);
948 wc2 = b[i*2+1] | (b[i*2] << 8); 1101 wc2 = b[i*2+1] | (b[i*2] << 8);
949 if (mytowlower(wc) != mytowlower(wc2)) return false; 1102 if (mytowlower(wc) != mytowlower(wc2)) return false;
950 } 1103 }
951 return true; 1104 return true;
952} 1105}
953 1106
954/* wcscmp in Mandrake 9.0 is wrong */ 1107/* wcscmp in Mandrake 9.0 is wrong */
@@ -1006,25 +1159,25 @@ int mytowlower(wchar_t c)
1006 */ 1159 */
1007/* 1160/*
1008 * The original strstr() file contains the following comment: 1161 * The original strstr() file contains the following comment:
1009 * 1162 *
1010 * My personal strstr() implementation that beats most other algorithms. 1163 * My personal strstr() implementation that beats most other algorithms.
1011 * Until someone tells me otherwise, I assume that this is the 1164 * Until someone tells me otherwise, I assume that this is the
1012 * fastest implementation of strstr() in C. 1165 * fastest implementation of strstr() in C.
1013 * I deliberately chose not to comment it. You should have at least 1166 * I deliberately chose not to comment it. You should have at least
1014 * as much fun trying to understand it, as I had to write it :-). 1167 * as much fun trying to understand it, as I had to write it :-).
1015 * 1168 *
1016 * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */ 1169 * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
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{
1020/* One crazy define to convert unicode used in Gammu to standard wchar_t */ 1173/* One crazy define to convert unicode used in Gammu to standard wchar_t */
1021#define tolowerwchar(x) (mytowlower((wchar_t)( (((&(x))[0] & 0xff) << 8) | (((&(x))[1] & 0xff)) ))) 1174#define tolowerwchar(x) (mytowlower((wchar_t)( (((&(x))[0] & 0xff) << 8) | (((&(x))[1] & 0xff)) )))
1022 register wchar_t b, c; 1175 register wchar_t b, c;
1023 1176
1024 if ((b = tolowerwchar(*needle)) != L'\0') { 1177 if ((b = tolowerwchar(*needle)) != L'\0') {
1025 haystack -= 2; /* possible ANSI violation */ 1178 haystack -= 2; /* possible ANSI violation */
1026 do { 1179 do {
1027 haystack += 2; 1180 haystack += 2;
1028 if ((c = tolowerwchar(*haystack)) == L'\0') 1181 if ((c = tolowerwchar(*haystack)) == L'\0')
1029 goto ret0; 1182 goto ret0;
1030 } while (c != b); 1183 } while (c != b);
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
@@ -1,49 +1,56 @@
1/* (c) 2002-2004 by Marcin Wiacek and others */ 1/* (c) 2002-2004 by Marcin Wiacek and others */
2 2
3#ifndef __coding_h 3#ifndef __coding_h
4#define __coding_h 4#define __coding_h
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include <stdlib.h> 10#include <stdlib.h>
7 11
8#include "../misc.h" 12#include "../misc.h"
9 13
10#ifdef __OpenBSD__ 14#ifdef __OpenBSD__
11 typedef int wint_t; 15 typedef int wint_t;
12#endif 16#endif
13 17
14/* ---------------------------- Unicode ------------------------------------ */ 18/* ---------------------------- Unicode ------------------------------------ */
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);
18 bool myiswspace (unsigned const char *src); 22 bool myiswspace (unsigned const char *src);
19 int mytowlower (wchar_t c); 23 int mytowlower (wchar_t c);
20 24
21 unsigned int EncodeWithUnicodeAlphabet(const unsigned char *value, wchar_t *dest); 25 unsigned int EncodeWithUnicodeAlphabet(const unsigned char *value, wchar_t *dest);
22 unsigned int DecodeWithUnicodeAlphabet(wchar_t value, unsigned char *dest); 26 unsigned int DecodeWithUnicodeAlphabet(wchar_t value, unsigned char *dest);
23 27
24 unsigned int UnicodeLength (const unsigned char *str); 28 unsigned int UnicodeLength (const unsigned char *str);
25 unsigned char *DecodeUnicodeString (const unsigned char *src); 29 unsigned char *DecodeUnicodeString (const unsigned char *src);
26 unsigned char *DecodeUnicodeConsole (const unsigned char *src); 30 unsigned char *DecodeUnicodeConsole (const unsigned char *src);
27 void DecodeUnicode (const unsigned char *src, unsigned char *dest); 31 void DecodeUnicode (const unsigned char *src, unsigned char *dest);
28 void EncodeUnicode (unsigned char *dest, const unsigned char *src, int len); 32 void EncodeUnicode (unsigned char *dest, const unsigned char *src, int len);
29 33
30 void CopyUnicodeString (unsigned char *Dest, unsigned char *Source); 34 void CopyUnicodeString (unsigned char *Dest, unsigned char *Source);
31 void ReverseUnicodeString (unsigned char *String); 35 void ReverseUnicodeString (unsigned char *String);
32 36
33 void ReadUnicodeFile (unsigned char *Dest, unsigned char *Source); 37 void ReadUnicodeFile (unsigned char *Dest, unsigned char *Source);
34 38
35 void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len); 39 void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len);
36 void EncodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len); 40 void EncodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, int len);
37 41
42 char *EncodeUnicodeSpecialChars(unsigned char *buffer);
43 char *DecodeUnicodeSpecialChars(unsigned char *buffer);
44
38/* ------------------------------- BCD ------------------------------------- */ 45/* ------------------------------- BCD ------------------------------------- */
39 unsigned char EncodeWithBCDAlphabet (int value); 46 unsigned char EncodeWithBCDAlphabet (int value);
40 int DecodeWithBCDAlphabet (unsigned char value); 47 int DecodeWithBCDAlphabet (unsigned char value);
41 48
42 void DecodeBCD (unsigned char *dest, const unsigned char *src, int len); 49 void DecodeBCD (unsigned char *dest, const unsigned char *src, int len);
43 void EncodeBCD (unsigned char *dest, const unsigned char *src, int len, bool fill); 50 void EncodeBCD (unsigned char *dest, const unsigned char *src, int len, bool fill);
44 51
45/* ------------------------------ UTF7 ------------------------------------- */ 52/* ------------------------------ UTF7 ------------------------------------- */
46 void DecodeUTF7 (unsigned char *dest, const unsigned char *src, int len); 53 void DecodeUTF7 (unsigned char *dest, const unsigned char *src, int len);
47 54
48/* ------------------------------ UTF8 ------------------------------------- */ 55/* ------------------------------ UTF8 ------------------------------------- */
49 wchar_t DecodeWithUTF8Alphabet (unsigned char mychar3, unsigned char mychar4); 56 wchar_t DecodeWithUTF8Alphabet (unsigned char mychar3, unsigned char mychar4);
@@ -77,33 +84,33 @@ int GSM_UnpackEightBitsToSeven (int offset, int in_length, int out_length,
77 unsigned char *input, unsigned char *output); 84 unsigned char *input, unsigned char *output);
78 85
79/* ----------------- Phone numbers according to GSM specs ------------------ */ 86/* ----------------- Phone numbers according to GSM specs ------------------ */
80 87
81/** 88/**
82 * Enum to handle types of phones numbers like 89 * Enum to handle types of phones numbers like
83 * specified in GSM 03.40 section 9.1.2.5 90 * specified in GSM 03.40 section 9.1.2.5
84 */ 91 */
85typedef enum { 92typedef enum {
86 /** 93 /**
87 * Unknown number type 94 * Unknown number type
88 */ 95 */
89 NUMBER_UNKNOWN = 0x81, 96 NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN = 0x81,
90 /** 97 /**
91 * International number (full number with code of country) 98 * International number (full number with code of country)
92 */ 99 */
93 NUMBER_INTERNATIONAL= 0x91, 100 NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN= 0x91,
94 /** 101 /**
95 * Alphanumeric number (with chars too) 102 * Alphanumeric number (with chars too)
96 */ 103 */
97 NUMBER_ALPHANUMERIC= 0xD0 104 NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN= 0xD0
98 105
99 /* specification give also other values */ 106 /* specification give also other values */
100} GSM_NumberType; 107} GSM_NumberType;
101 108
102 void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, bool semioctet); 109 void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, bool semioctet);
103 int GSM_PackSemiOctetNumber (unsigned char *Number, unsigned char *Output, bool semioctet); 110 int GSM_PackSemiOctetNumber (unsigned char *Number, unsigned char *Output, bool semioctet);
104 111
105/* ---------------------------- Bits --------------------------------------- */ 112/* ---------------------------- Bits --------------------------------------- */
106 113
107void BufferAlign (unsigned char *Destination, int *CurrentBit); 114void BufferAlign (unsigned char *Destination, int *CurrentBit);
108void BufferAlignNumber(int *CurrentBit); 115void BufferAlignNumber(int *CurrentBit);
109 116
@@ -113,21 +120,29 @@ void AddBufferByte(unsigned char *Destination, int *CurrentBit, unsigned char So
113void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess); 120void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess);
114void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess); 121void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess);
115void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess); 122void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess);
116 123
117int GetBit (unsigned char *Buffer, int BitNum); 124int GetBit (unsigned char *Buffer, int BitNum);
118int SetBit (unsigned char *Buffer, int BitNum); 125int SetBit (unsigned char *Buffer, int BitNum);
119int ClearBit (unsigned char *Buffer, int BitNum); 126int ClearBit (unsigned char *Buffer, int BitNum);
120 127
121/* ---------------------------- Other -------------------------------------- */ 128/* ---------------------------- Other -------------------------------------- */
122 129
123 void StringToDouble(char *text, double *d); 130 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
129#endif 144#endif
130 145
131/* How should editor hadle tabs in this file? Add editor commands here. 146/* How should editor hadle tabs in this file? Add editor commands here.
132 * vim: noexpandtab sw=8 ts=8 sts=8: 147 * vim: noexpandtab sw=8 ts=8 sts=8:
133 */ 148 */
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,13 +1,13 @@
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
3 * Dominik Reichl <dominik.reichl@t-online.de>, Germany 3 * Dominik Reichl <dominik.reichl@t-online.de>, Germany
4 */ 4 */
5 5
6/* 6/*
7 ********************************************************************** 7 **********************************************************************
8 ** MD5.cpp ** 8 ** MD5.cpp **
9 ** ** 9 ** **
10 ** - Style modified by Tony Ray, January 2001 ** 10 ** - Style modified by Tony Ray, January 2001 **
11 ** Added support for randomizing initialization constants ** 11 ** Added support for randomizing initialization constants **
12 ** - Style modified by Dominik Reichl, April 2003 ** 12 ** - Style modified by Dominik Reichl, April 2003 **
13 ** Optimized code ** 13 ** Optimized code **
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
@@ -2,24 +2,27 @@
2/* Checking used compiler (c) 2002 by Michal Cihar */ 2/* Checking used compiler (c) 2002 by Michal Cihar */
3 3
4#include <string.h> 4#include <string.h>
5#include <ctype.h> 5#include <ctype.h>
6#include <time.h> 6#include <time.h>
7#include <stdarg.h> 7#include <stdarg.h>
8#include <stdio.h> 8#include <stdio.h>
9#include <locale.h> 9#include <locale.h>
10#include <sys/timeb.h> 10#include <sys/timeb.h>
11#ifdef WIN32 11#ifdef WIN32
12# include "windows.h" 12# include "windows.h"
13#endif 13#endif
14#if defined(linux) || defined(__linux) || defined(__linux__)
15# include <sys/utsname.h>
16#endif
14 17
15#include "../gsmstate.h" 18#include "../gsmstate.h"
16#include "misc.h" 19#include "misc.h"
17 20
18/* Based on article in Polish PC-Kurier 8/1998 page 104 21/* Based on article in Polish PC-Kurier 8/1998 page 104
19 * Archive on http://www.pckurier.pl 22 * Archive on http://www.pckurier.pl
20 */ 23 */
21char *DayOfWeek (int year, int month, int day) 24char *DayOfWeek (int year, int month, int day)
22{ 25{
23 int p,q,r,w; 26 int p,q,r,w;
24 static char DayOfWeekChar[10]; 27 static char DayOfWeekChar[10];
25 28
@@ -221,29 +224,31 @@ char *OSDate (GSM_DateTime dt)
221 strcat(retval2,")"); 224 strcat(retval2,")");
222 } 225 }
223 } 226 }
224 227
225#ifdef WIN32 228#ifdef WIN32
226 setlocale(LC_ALL, ".ACP"); 229 setlocale(LC_ALL, ".ACP");
227#endif 230#endif
228 231
229 return retval2; 232 return retval2;
230} 233}
231 234
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}
239 244
240bool CheckTime(GSM_DateTime *date) 245bool CheckTime(GSM_DateTime *date)
241{ 246{
242 return date->Hour <= 23 && date->Hour >= 0 && 247 return date->Hour <= 23 && date->Hour >= 0 &&
243 date->Minute <= 59 && date->Minute >= 0 && 248 date->Minute <= 59 && date->Minute >= 0 &&
244 date->Second <= 59 && date->Second >= 0; 249 date->Second <= 59 && date->Second >= 0;
245} 250}
246 251
247int GetLine(FILE *File, char *Line, int count) 252int GetLine(FILE *File, char *Line, int count)
248{ 253{
249 int num; 254 int num;
@@ -442,24 +447,27 @@ void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int mes
442 j++; 447 j++;
443 } 448 }
444 } 449 }
445 if (j != 0) smfprintf(df, dl, "%s\n", buffer); 450 if (j != 0) smfprintf(df, dl, "%s\n", buffer);
446} 451}
447 452
448char *GetOS(void) 453char *GetOS(void)
449{ 454{
450#ifdef WIN32 455#ifdef WIN32
451 OSVERSIONINFOEX Ver; 456 OSVERSIONINFOEX Ver;
452 bool Extended = true; 457 bool Extended = true;
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};
455 463
456#ifdef WIN32 464#ifdef WIN32
457 memset(&Ver,sizeof(OSVERSIONINFOEX),0); 465 memset(&Ver,sizeof(OSVERSIONINFOEX),0);
458 Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 466 Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
459 467
460 if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { 468 if (!GetVersionEx((OSVERSIONINFO *)&Ver)) {
461 Extended = false; 469 Extended = false;
462 Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 470 Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
463 if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { 471 if (!GetVersionEx((OSVERSIONINFO *)&Ver)) {
464//#ifdef _MSC_VER 472//#ifdef _MSC_VER
465 // Ver.dwMajorVersion = _winmajor; 473 // Ver.dwMajorVersion = _winmajor;
@@ -511,25 +519,26 @@ char *GetOS(void)
511 519
512 } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 2) { 520 } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 2) {
513 sprintf(Buffer,"Win 2003"); 521 sprintf(Buffer,"Win 2003");
514 522
515 } else { 523 } else {
516 sprintf(Buffer, "Windows %i.%i.%i",Ver.dwMajorVersion,Ver.dwMinorVersion,Ver.dwBuildNumber); 524 sprintf(Buffer, "Windows %i.%i.%i",Ver.dwMajorVersion,Ver.dwMinorVersion,Ver.dwBuildNumber);
517 } 525 }
518 526
519 if (Extended && Ver.wServicePackMajor != 0) { 527 if (Extended && Ver.wServicePackMajor != 0) {
520 sprintf(Buffer+strlen(Buffer)," SP%i",Ver.wServicePackMajor); 528 sprintf(Buffer+strlen(Buffer)," SP%i",Ver.wServicePackMajor);
521 } 529 }
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__)
525 sprintf(Buffer, "FreeBSD"); 534 sprintf(Buffer, "FreeBSD");
526#elif defined(__NetBSD__) 535#elif defined(__NetBSD__)
527 sprintf(Buffer, "NetBSD"); 536 sprintf(Buffer, "NetBSD");
528#elif defined(__OpenBSD__) 537#elif defined(__OpenBSD__)
529 sprintf(Buffer, "OpenBSD"); 538 sprintf(Buffer, "OpenBSD");
530#elif defined(__GNU__) 539#elif defined(__GNU__)
531 sprintf(Buffer, "GNU/Hurd"); 540 sprintf(Buffer, "GNU/Hurd");
532#elif defined(sun) || defined(__sun) || defined(__sun__) 541#elif defined(sun) || defined(__sun) || defined(__sun__)
533# ifdef __SVR4 542# ifdef __SVR4
534 sprintf(Buffer, "Sun Solaris"); 543 sprintf(Buffer, "Sun Solaris");
535# else 544# else
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
@@ -1,17 +1,21 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __misc_h 3#ifndef __misc_h
4#define __misc_h 4#define __misc_h
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include <stdio.h> 10#include <stdio.h>
7#include <time.h> 11#include <time.h>
8#ifdef WIN32 12#ifdef WIN32
9# include <windows.h> 13# include <windows.h>
10#endif 14#endif
11 15
12#include "../config.h" 16#include "../config.h"
13 17
14#ifndef __cplusplus 18#ifndef __cplusplus
15#ifndef false 19#ifndef false
16# define false 0 20# define false 0
17#endif 21#endif
@@ -121,17 +125,21 @@ void GSM_GetCurrentDateTime (GSM_DateTime *Date);
121 char *OSDateTime (GSM_DateTime dt, bool TimeZone); 125 char *OSDateTime (GSM_DateTime dt, bool TimeZone);
122 char *OSDate (GSM_DateTime dt); 126 char *OSDate (GSM_DateTime dt);
123 char *DayOfWeek (int year, int month, int day); 127 char *DayOfWeek (int year, int month, int day);
124 time_t Fill_Time_T (GSM_DateTime DT, int TZ); 128 time_t Fill_Time_T (GSM_DateTime DT, int TZ);
125 void GetTimeDifference (unsigned long diff, GSM_DateTime *DT, bool Plus, int multi); 129 void GetTimeDifference (unsigned long diff, GSM_DateTime *DT, bool Plus, int multi);
126 void Fill_GSM_DateTime (GSM_DateTime *Date, time_t timet); 130 void Fill_GSM_DateTime (GSM_DateTime *Date, time_t timet);
127 bool CheckDate (GSM_DateTime *date); 131 bool CheckDate (GSM_DateTime *date);
128 bool CheckTime (GSM_DateTime *date); 132 bool CheckTime (GSM_DateTime *date);
129 133
130 char *GetCompiler(void); 134 char *GetCompiler(void);
131 char *GetOS(void); 135 char *GetOS(void);
132 136
137#if defined(_MSC_VER) && defined(__cplusplus)
138 }
139#endif
140
133#endif 141#endif
134 142
135/* How should editor hadle tabs in this file? Add editor commands here. 143/* How should editor hadle tabs in this file? Add editor commands here.
136 * vim: noexpandtab sw=8 ts=8 sts=8: 144 * vim: noexpandtab sw=8 ts=8 sts=8:
137 */ 145 */
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
@@ -1,26 +1,26 @@
1/* (c) 2002-2004 by Michal Cihar */ 1/* (c) 2002-2004 by Michal Cihar */
2 2
3/* 3/*
4 * High level functions for communication with Alcatel One Touch 501 and 4 * High level functions for communication with Alcatel One Touch 501 and
5 * compatible mobile phone. 5 * compatible mobile phone.
6 * 6 *
7 * This code implements functions to communicate with Alcatel phones, 7 * This code implements functions to communicate with Alcatel phones,
8 * currently seem to work: 8 * currently seem to work:
9 * - BE5 series (501/701) 9 * - BE5 series (501/701)
10 * - BF5 series (715) 10 * - BF5 series (715)
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...
16 * 16 *
17 * Notes for future features: 17 * Notes for future features:
18 * - max phone number length is 61 (BE5) 18 * - max phone number length is 61 (BE5)
19 * - max name length is 50 (BE5) 19 * - max name length is 50 (BE5)
20 */ 20 */
21 21
22#include "../../gsmstate.h" 22#include "../../gsmstate.h"
23 23
24#ifdef GSM_ENABLE_ALCATEL 24#ifdef GSM_ENABLE_ALCATEL
25#ifdef GSM_ENABLE_ATGEN 25#ifdef GSM_ENABLE_ATGEN
26 26
@@ -92,40 +92,41 @@ extern GSM_Error ATGEN_GetSecurityStatus (GSM_StateMachine *s, GSM_SecurityCodeT
92 extern GSM_Error ATGEN_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type); 92 extern GSM_Error ATGEN_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type);
93 extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence); 93 extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence);
94 extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); 94 extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI);
95 extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s); 95 extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s);
96 extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); 96 extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo);
97 extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard); 97 extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard);
98 extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); 98 extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press);
99 extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features); 99 extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features);
100 extern GSM_Error ATGEN_SetAutoNetworkLogin(GSM_StateMachine *s); 100 extern GSM_Error ATGEN_SetAutoNetworkLogin(GSM_StateMachine *s);
101 extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type); 101 extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type);
102 102
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);
105 extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); 106 extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable);
106 107
107/** 108/**
108 * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table 109 * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table
109 * attempts to decode it, it is probably not complete, here are just chars 110 * attempts to decode it, it is probably not complete, here are just chars
110 * that I found... 111 * that I found...
111 */ 112 */
112unsigned char GSM_AlcatelAlphabet[] = 113unsigned char GSM_AlcatelAlphabet[] =
113{ 114{
114 /* in phone unicode description*/ 115 /* in phone unicode description*/
115 0x80, 0x00,0x20, /* empty */ 116 0x80, 0x00,0x20, /* empty */
116 0x81, 0x00,0x20, /* empty*/ 117 0x81, 0x00,0x20, /* empty*/
117 0x82, 0x00,0x20, /* empty*/ 118 0x82, 0x00,0x20, /* empty*/
118 0x83, 0x00,0x20, /* empty*/ 119 0x83, 0x00,0x20, /* empty*/
119 120
120 0x84, 0x00,0xe7, /* c cedilla*/ 121 0x84, 0x00,0xe7, /* c cedilla*/
121 0x85, 0x20,0x26, /* ... */ 122 0x85, 0x20,0x26, /* ... */
122 0x86, 0x03,0xc0, /* pi */ 123 0x86, 0x03,0xc0, /* pi */
123 0x87, 0x01,0x3e, /* l caron*/ 124 0x87, 0x01,0x3e, /* l caron*/
124 0x88, 0x00,0xc0, /* A grave*/ 125 0x88, 0x00,0xc0, /* A grave*/
125 0x89, 0x00,0xc1, /* A acute*/ 126 0x89, 0x00,0xc1, /* A acute*/
126 0x8a, 0x00,0xc2, /* A circumflex*/ 127 0x8a, 0x00,0xc2, /* A circumflex*/
127 0x8b, 0x00,0xc3, /* A tilde*/ 128 0x8b, 0x00,0xc3, /* A tilde*/
128 0x8c, 0x00,0xc8, /* E grave*/ 129 0x8c, 0x00,0xc8, /* E grave*/
129 0x8d, 0x00,0xca, /* E circumflex*/ 130 0x8d, 0x00,0xca, /* E circumflex*/
130 0x8e, 0x00,0xcb, /* E diaresis*/ 131 0x8e, 0x00,0xcb, /* E diaresis*/
131 0x8f, 0x00,0xcc, /* I grave*/ 132 0x8f, 0x00,0xcc, /* I grave*/
@@ -159,123 +160,123 @@ unsigned char GSM_AlcatelAlphabet[] =
159 0xab, 0x00,0xfd, /* y acute*/ 160 0xab, 0x00,0xfd, /* y acute*/
160 0xac, 0x00,0xf0, /* eth */ 161 0xac, 0x00,0xf0, /* eth */
161 0xad, 0x01,0x07, /* c acute*/ 162 0xad, 0x01,0x07, /* c acute*/
162 0xae, 0x01,0x19, /* e ogonek*/ 163 0xae, 0x01,0x19, /* e ogonek*/
163 0xaf, 0x01,0x05, /* a ogonek*/ 164 0xaf, 0x01,0x05, /* a ogonek*/
164 0xb0, 0x01,0x7c, /* z dot*/ 165 0xb0, 0x01,0x7c, /* z dot*/
165 0xb1, 0x01,0x7a, /* z acute*/ 166 0xb1, 0x01,0x7a, /* z acute*/
166 0xb2, 0x01,0x5b, /* s acute*/ 167 0xb2, 0x01,0x5b, /* s acute*/
167 0xb3, 0x01,0x44, /* n acute*/ 168 0xb3, 0x01,0x44, /* n acute*/
168 0xb4, 0x01,0x42, /* l stroke*/ 169 0xb4, 0x01,0x42, /* l stroke*/
169 170
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*/
184 0xbe, 0x1e,0x21, /* g macron*/ 185 0xbe, 0x1e,0x21, /* g macron*/
185 0xbf, 0x01,0x5e, /* S cedilla*/ 186 0xbf, 0x01,0x5e, /* S cedilla*/
186 0xc0, 0x01,0x5f, /* s cedilla*/ 187 0xc0, 0x01,0x5f, /* s cedilla*/
187 0xc1, 0x01,0x2f, /* i ogonek*/ /* FIXME: not sure with this, it look like normal i */ 188 0xc1, 0x01,0x2f, /* i ogonek*/ /* FIXME: not sure with this, it look like normal i */
188 0xc2, 0x01,0x31, /* i dotless*/ 189 0xc2, 0x01,0x31, /* i dotless*/
189 0xc3, 0x01,0x68, /* U tilde*/ 190 0xc3, 0x01,0x68, /* U tilde*/
190 0xc4, 0x01,0x50, /* O dbl acute*/ 191 0xc4, 0x01,0x50, /* O dbl acute*/
191 0xc5, 0x01,0x69, /* u tilde*/ 192 0xc5, 0x01,0x69, /* u tilde*/
192 0xc6, 0x01,0x51, /* o dbl acute*/ 193 0xc6, 0x01,0x51, /* o dbl acute*/
193 0xc7, 0x27,0xa9, /* => */ 194 0xc7, 0x27,0xa9, /* => */
194 0xc8, 0x27,0xa8, /* filled =>*/ 195 0xc8, 0x27,0xa8, /* filled =>*/
195 0xc9, 0x00,0xd7, /* x */ 196 0xc9, 0x00,0xd7, /* x */
196 0xca, 0x00,0x5d, /* ] */ 197 0xca, 0x00,0x5d, /* ] */
197 0xcb, 0x26,0x0f, /* phone*/ 198 0xcb, 0x26,0x0f, /* phone*/
198 0xcc, 0x01,0x0f, /* d caron*/ 199 0xcc, 0x01,0x0f, /* d caron*/
199 200
200 0xcd, 0x00,0x20, /* empty*/ 201 0xcd, 0x00,0x20, /* empty*/
201 202
202 0xce, 0x00,0x7e, /* ~ */ 203 0xce, 0x00,0x7e, /* ~ */
203 0xcf, 0x00,0x5c, /* \ */ 204 0xcf, 0x00,0x5c, /* \ */
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, /* { */
209 0xd3, 0x00,0x7c, /* | */ 210 0xd3, 0x00,0x7c, /* | */
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*/
217 0xd8, 0x00,0x20, /* empty*/ 218 0xd8, 0x00,0x20, /* empty*/
218 0xd9, 0x00,0x20, /* empty*/ 219 0xd9, 0x00,0x20, /* empty*/
219 0xda, 0x00,0x20, /* empty*/ 220 0xda, 0x00,0x20, /* empty*/
220 0xdb, 0x00,0x20, /* empty*/ 221 0xdb, 0x00,0x20, /* empty*/
221 0xdc, 0x00,0x20, /* empty*/ 222 0xdc, 0x00,0x20, /* empty*/
222 0xdd, 0x00,0x20, /* empty*/ 223 0xdd, 0x00,0x20, /* empty*/
223 0xde, 0x00,0x20, /* empty*/ 224 0xde, 0x00,0x20, /* empty*/
224 0xdf, 0x00,0x20, /* empty*/ 225 0xdf, 0x00,0x20, /* empty*/
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*/
230 0xe3, 0x00,0x20, /* empty*/ 231 0xe3, 0x00,0x20, /* empty*/
231 0xe4, 0x00,0x20, /* empty*/ 232 0xe4, 0x00,0x20, /* empty*/
232 233
233 0xe5, 0x01,0xce, /* a caron*/ 234 0xe5, 0x01,0xce, /* a caron*/
234 0xe6, 0x01,0x01, /* a macron*/ 235 0xe6, 0x01,0x01, /* a macron*/
235 0xe7, 0x01,0x13, /* e macron*/ 236 0xe7, 0x01,0x13, /* e macron*/
236 0xe8, 0x01,0x2b, /* i macron*/ 237 0xe8, 0x01,0x2b, /* i macron*/
237 0xe9, 0x01,0x4d, /* o macron*/ 238 0xe9, 0x01,0x4d, /* o macron*/
238 0xea, 0x01,0x6b, /* u macron*/ 239 0xea, 0x01,0x6b, /* u macron*/
239 0xeb, 0x00,0x41, /* A */ 240 0xeb, 0x00,0x41, /* A */
240 0xec, 0x00,0x40, /* @ */ 241 0xec, 0x00,0x40, /* @ */
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 */
249 0xf2, 0x00,0x21, /* bold !*/ 250 0xf2, 0x00,0x21, /* bold !*/
250 0xf3, 0x26,0x0e, /* black phone*/ 251 0xf3, 0x26,0x0e, /* black phone*/
251 0xf4, 0x00,0x26, /* & */ 252 0xf4, 0x00,0x26, /* & */
252 0xf5, 0x23,0x7e, /* bell */ 253 0xf5, 0x23,0x7e, /* bell */
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 */
265 0xfd, 0x21,0x97, /* NE arrow*/ 266 0xfd, 0x21,0x97, /* NE arrow*/
266 0xfe, 0x21,0x98, /* SE arrow*/ 267 0xfe, 0x21,0x98, /* SE arrow*/
267 268
268 0xff, 0x00,0x20, /* empty*/ 269 0xff, 0x00,0x20, /* empty*/
269 270
270 0x00, 0x00,0x00 271 0x00, 0x00,0x00
271}; 272};
272 273
273/* This is being called from atgen */ 274/* This is being called from atgen */
274 GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s) 275 GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
275{ 276{
276 char *str, *str2; 277 char *str, *str2;
277/* 278/*
278 * Reply received here looks like: 279 * Reply received here looks like:
279 * 1 "AT+CPROT=?" 280 * 1 "AT+CPROT=?"
280 * 2 "+CPROT: 0,"V1.0",1" 281 * 2 "+CPROT: 0,"V1.0",1"
281 * 3 "+CPROT: 16,"V1.1",16" 282 * 3 "+CPROT: 16,"V1.1",16"
@@ -306,38 +307,38 @@ GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message msg, GSM_StateMachi
306 307
307static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) 308static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s)
308{ 309{
309 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 310 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
310 GSM_Error error; 311 GSM_Error error;
311 312
312 if (Priv->Mode == ModeBinary) return ERR_NONE; 313 if (Priv->Mode == ModeBinary) return ERR_NONE;
313 314
314 dbgprintf ("Changing to binary mode\n"); 315 dbgprintf ("Changing to binary mode\n");
315 316
316 error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl); 317 error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl);
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);
320 if (error != ERR_NONE) return error; 321 if (error != ERR_NONE) return error;
321 322
322 if (Priv->ProtocolVersion == V_1_0) { 323 if (Priv->ProtocolVersion == V_1_0) {
323 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.0\",16\r", 22, 0x00, 4, ID_AlcatelConnect); 324 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.0\",16\r", 22, 0x00, 4, ID_AlcatelConnect);
324 } else { 325 } else {
325 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect); 326 error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect);
326 } 327 }
327 328
328 if (error == ERR_TIMEOUT && s->Speed != 19200) { 329 if (error == ERR_TIMEOUT && s->Speed != 19200) {
329 smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n"); 330 smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n");
330 } 331 }
331 332
332 if (error != ERR_NONE) return error; 333 if (error != ERR_NONE) return error;
333 334
334 dbgprintf ("Changing protocol to Alcabus\n"); 335 dbgprintf ("Changing protocol to Alcabus\n");
335 336
336 s->Protocol.Functions = &ALCABUSProtocol; 337 s->Protocol.Functions = &ALCABUSProtocol;
337 error = s->Protocol.Functions->Initialise(s); 338 error = s->Protocol.Functions->Initialise(s);
338 if (error != ERR_NONE) { 339 if (error != ERR_NONE) {
339 s->Protocol.Functions = &ATProtocol; 340 s->Protocol.Functions = &ATProtocol;
340 return error; 341 return error;
341 } 342 }
342 s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions; 343 s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions;
343 Priv->Mode = ModeBinary; 344 Priv->Mode = ModeBinary;
@@ -367,25 +368,25 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
367 {0x00, 0x00, 368 {0x00, 0x00,
368 0x00, /*type */ 369 0x00, /*type */
369 0x20}; 370 0x20};
370 unsigned char select2_buffer[] = 371 unsigned char select2_buffer[] =
371 {0x00, 0x04, 372 {0x00, 0x04,
372 0x00, /*type */ 373 0x00, /*type */
373 0x22, 0x01, 0x00}; 374 0x22, 0x01, 0x00};
374 unsigned char begin_buffer[] = 375 unsigned char begin_buffer[] =
375 {0x00, 0x04, 0x7C, 0x81, 376 {0x00, 0x04, 0x7C, 0x81,
376 0x00, /*type */ 377 0x00, /*type */
377 0x00, 0x85, 0x00}; 378 0x00, 0x85, 0x00};
378 unsigned char commit_buffer[] = 379 unsigned char commit_buffer[] =
379 {0x00, 0x04, 380 {0x00, 0x04,
380 0x00, /*type */ 381 0x00, /*type */
381 0x20, 0x01}; 382 0x20, 0x01};
382 383
383 smprintf(s, "Alcatel state switcher: %d -> %d, %d -> %d, %d -> %d\n", Priv->BinaryState, state, Priv->BinaryType, type, Priv->BinaryItem, item); 384 smprintf(s, "Alcatel state switcher: %d -> %d, %d -> %d, %d -> %d\n", Priv->BinaryState, state, Priv->BinaryType, type, Priv->BinaryItem, item);
384 error = ALCATEL_SetBinaryMode(s); 385 error = ALCATEL_SetBinaryMode(s);
385 if (error != ERR_NONE) return error; 386 if (error != ERR_NONE) return error;
386 387
387 /* Do we need to do anything? */ 388 /* Do we need to do anything? */
388 if ((state == Priv->BinaryState) && (type == Priv->BinaryType) && (item == Priv->BinaryItem)) return ERR_NONE; 389 if ((state == Priv->BinaryState) && (type == Priv->BinaryType) && (item == Priv->BinaryItem)) return ERR_NONE;
389 390
390 /* We're editing, but the next state is not the same. so commit editing */ 391 /* We're editing, but the next state is not the same. so commit editing */
391 if (Priv->BinaryState == StateEdit) { 392 if (Priv->BinaryState == StateEdit) {
@@ -434,25 +435,25 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
434 case TypeCalendar: 435 case TypeCalendar:
435 end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; 436 end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR;
436 break; 437 break;
437 case TypeContacts: 438 case TypeContacts:
438 end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; 439 end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS;
439 break; 440 break;
440 case TypeToDo: 441 case TypeToDo:
441 end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; 442 end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO;
442 break; 443 break;
443 } 444 }
444 error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd); 445 error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd);
445 if (error != ERR_NONE) return error; 446 if (error != ERR_NONE) return error;
446 447
447 switch (Priv->BinaryType) { 448 switch (Priv->BinaryType) {
448 case TypeCalendar: 449 case TypeCalendar:
449 close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 450 close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
450 break; 451 break;
451 case TypeContacts: 452 case TypeContacts:
452 close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 453 close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
453 break; 454 break;
454 case TypeToDo: 455 case TypeToDo:
455 close_buffer[2] = ALCATEL_SYNC_TYPE_TODO; 456 close_buffer[2] = ALCATEL_SYNC_TYPE_TODO;
456 break; 457 break;
457 } 458 }
458 dbgprintf ("Closing session\n"); 459 dbgprintf ("Closing session\n");
@@ -535,24 +536,26 @@ static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s)
535 if (Priv->Mode == ModeAT) return ERR_NONE; 536 if (Priv->Mode == ModeAT) return ERR_NONE;
536 537
537 error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); 538 error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0);
538 if (error != ERR_NONE) return error; 539 if (error != ERR_NONE) return error;
539 540
540 error = s->Protocol.Functions->Terminate(s); 541 error = s->Protocol.Functions->Terminate(s);
541 if (error != ERR_NONE) return error; 542 if (error != ERR_NONE) return error;
542 543
543 dbgprintf ("Changing protocol to AT\n"); 544 dbgprintf ("Changing protocol to AT\n");
544 s->Protocol.Functions = &ATProtocol; 545 s->Protocol.Functions = &ATProtocol;
545 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; 546 s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions;
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
548 my_sleep(100); 551 my_sleep(100);
549 552
550 /* In case we don't send AT command short after closing binary mode, 553 /* In case we don't send AT command short after closing binary mode,
551 * phone takes VERY long to react next time. The error code in 554 * phone takes VERY long to react next time. The error code in
552 * intetionally ignored. 555 * intetionally ignored.
553 */ 556 */
554 GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); 557 GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame);
555 558
556 return ERR_NONE; 559 return ERR_NONE;
557} 560}
558 561
@@ -619,29 +622,29 @@ static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) {
619 Priv->CurrentList = &(Priv->CalendarItems); 622 Priv->CurrentList = &(Priv->CalendarItems);
620 Priv->CurrentCount = &(Priv->CalendarItemsCount); 623 Priv->CurrentCount = &(Priv->CalendarItemsCount);
621 break; 624 break;
622 case TypeContacts: 625 case TypeContacts:
623 Priv->CurrentList = &(Priv->ContactsItems); 626 Priv->CurrentList = &(Priv->ContactsItems);
624 Priv->CurrentCount = &(Priv->ContactsItemsCount); 627 Priv->CurrentCount = &(Priv->ContactsItemsCount);
625 break; 628 break;
626 case TypeToDo: 629 case TypeToDo:
627 Priv->CurrentList = &(Priv->ToDoItems); 630 Priv->CurrentList = &(Priv->ToDoItems);
628 Priv->CurrentCount = &(Priv->ToDoItemsCount); 631 Priv->CurrentCount = &(Priv->ToDoItemsCount);
629 break; 632 break;
630 } 633 }
631 634
632 for (i=0; i<*Priv->CurrentCount; i++) { 635 for (i=0; i<*Priv->CurrentCount; i++) {
633 if ((*Priv->CurrentList)[i] == id) return ERR_NONE; 636 if ((*Priv->CurrentList)[i] == id) return ERR_NONE;
634 } 637 }
635 638
636 return ERR_EMPTY; 639 return ERR_EMPTY;
637} 640}
638 641
639/* finds next id that is available in the phone */ 642/* finds next id that is available in the phone */
640static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) { 643static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) {
641 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 644 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
642 int i = 0; 645 int i = 0;
643 int next = ALCATEL_MAX_LOCATION; 646 int next = ALCATEL_MAX_LOCATION;
644 647
645 switch (Priv->BinaryType) { 648 switch (Priv->BinaryType) {
646 case TypeCalendar: 649 case TypeCalendar:
647 Priv->CurrentList = &(Priv->CalendarItems); 650 Priv->CurrentList = &(Priv->CalendarItems);
@@ -837,25 +840,25 @@ static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateM
837 Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8); 840 Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8);
838 Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */ 841 Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */
839 842
840 Priv->ReturnDateTime.Hour= 0; 843 Priv->ReturnDateTime.Hour= 0;
841 Priv->ReturnDateTime.Minute= 0; 844 Priv->ReturnDateTime.Minute= 0;
842 Priv->ReturnDateTime.Second= 0; 845 Priv->ReturnDateTime.Second= 0;
843 } else if (buffer[1] == 0x06 && buffer[2] == 0x68) { 846 } else if (buffer[1] == 0x06 && buffer[2] == 0x68) {
844 /* time */ 847 /* time */
845 Priv->ReturnType = Alcatel_time; 848 Priv->ReturnType = Alcatel_time;
846 Priv->ReturnDateTime.Hour= buffer[4]; 849 Priv->ReturnDateTime.Hour= buffer[4];
847 Priv->ReturnDateTime.Minute= buffer[5]; 850 Priv->ReturnDateTime.Minute= buffer[5];
848 Priv->ReturnDateTime.Second= buffer[6]; 851 Priv->ReturnDateTime.Second= buffer[6];
849 852
850 Priv->ReturnDateTime.Day= 0; 853 Priv->ReturnDateTime.Day= 0;
851 Priv->ReturnDateTime.Month= 0; 854 Priv->ReturnDateTime.Month= 0;
852 Priv->ReturnDateTime.Year= 0; 855 Priv->ReturnDateTime.Year= 0;
853 Priv->ReturnDateTime.Timezone= 0; 856 Priv->ReturnDateTime.Timezone= 0;
854 } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) { 857 } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) {
855 /* string */ 858 /* string */
856 Priv->ReturnType = Alcatel_string; 859 Priv->ReturnType = Alcatel_string;
857 if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) 860 if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3])
858 smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); 861 smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1);
859 if (Priv->ProtocolVersion == V_1_0) { 862 if (Priv->ProtocolVersion == V_1_0) {
860 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); 863 DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet);
861 } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { 864 } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) {
@@ -1087,52 +1090,52 @@ static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_Stat
1087 Priv->ReturnString[len + 2] = 0; 1090 Priv->ReturnString[len + 2] = 0;
1088 ReverseUnicodeString(Priv->ReturnString); 1091 ReverseUnicodeString(Priv->ReturnString);
1089 } else { 1092 } else {
1090 DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); 1093 DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet);
1091 } 1094 }
1092 return ERR_NONE; 1095 return ERR_NONE;
1093} 1096}
1094 1097
1095static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { 1098static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) {
1096 unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ }; 1099 unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ };
1097 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1100 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
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') {
1101 CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); 1104 CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]);
1102 return ERR_NONE; 1105 return ERR_NONE;
1103 } 1106 }
1104 1107
1105 smprintf(s,"Reading category %d\n", id); 1108 smprintf(s,"Reading category %d\n", id);
1106 1109
1107 switch (Priv->BinaryType) { 1110 switch (Priv->BinaryType) {
1108 case TypeContacts: 1111 case TypeContacts:
1109 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1112 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1110 buffer[4] = ALCATEL_LIST_CONTACTS_CAT; 1113 buffer[4] = ALCATEL_LIST_CONTACTS_CAT;
1111 break; 1114 break;
1112 case TypeToDo: 1115 case TypeToDo:
1113 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1116 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1114 buffer[4] = ALCATEL_LIST_TODO_CAT; 1117 buffer[4] = ALCATEL_LIST_TODO_CAT;
1115 break; 1118 break;
1116 default: 1119 default:
1117 return ERR_NOTSUPPORTED; 1120 return ERR_NOTSUPPORTED;
1118 } 1121 }
1119 1122
1120 buffer[7] = (id & 0xff); 1123 buffer[7] = (id & 0xff);
1121 1124
1122 error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1); 1125 error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1);
1123 if (error != ERR_NONE) return error; 1126 if (error != ERR_NONE) return error;
1124 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); 1127 error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2);
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);
1128 1131
1129 return ERR_NONE; 1132 return ERR_NONE;
1130} 1133}
1131 1134
1132static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) { 1135static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) {
1133 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1136 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1134 GSM_Error error; 1137 GSM_Error error;
1135 unsigned char buffer[] = 1138 unsigned char buffer[] =
1136 {0x00, 0x04, 1139 {0x00, 0x04,
1137 0x00, /* type */ 1140 0x00, /* type */
1138 0x26, 0x01, 1141 0x26, 0x01,
@@ -1204,27 +1207,27 @@ static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) {
1204 1207
1205 return ERR_NONE; 1208 return ERR_NONE;
1206} 1209}
1207 1210
1208static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s) 1211static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s)
1209{ 1212{
1210 if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE; 1213 if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE;
1211 return ERR_NONE; 1214 return ERR_NONE;
1212} 1215}
1213 1216
1214static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { 1217static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) {
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) {
1220 case Alcatel_date: 1223 case Alcatel_date:
1221 if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; 1224 if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME;
1222 1225
1223 buffer[3] = 0x05; 1226 buffer[3] = 0x05;
1224 buffer[4] = 0x67; 1227 buffer[4] = 0x67;
1225 1228
1226 buffer[0] = 0x09; 1229 buffer[0] = 0x09;
1227 buffer[5] = 0x04; 1230 buffer[5] = 0x04;
1228 buffer[6] = ((GSM_DateTime *)data)->Day & 0xff; 1231 buffer[6] = ((GSM_DateTime *)data)->Day & 0xff;
1229 buffer[7] = ((GSM_DateTime *)data)->Month & 0xff; 1232 buffer[7] = ((GSM_DateTime *)data)->Month & 0xff;
1230 buffer[8] = ((GSM_DateTime *)data)->Year >> 8; 1233 buffer[8] = ((GSM_DateTime *)data)->Year >> 8;
@@ -1320,68 +1323,68 @@ static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType
1320 case TypeCalendar: 1323 case TypeCalendar:
1321 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 1324 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
1322 break; 1325 break;
1323 case TypeContacts: 1326 case TypeContacts:
1324 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1327 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1325 break; 1328 break;
1326 case TypeToDo: 1329 case TypeToDo:
1327 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1330 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1328 break; 1331 break;
1329 } 1332 }
1330 error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); 1333 error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data);
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;
1337} 1340}
1338 1341
1339static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) { 1342static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) {
1340 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1343 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1341 GSM_Error error; 1344 GSM_Error error;
1342 unsigned char buffer[200] = 1345 unsigned char buffer[200] =
1343 {0x00, 0x04, 1346 {0x00, 0x04,
1344 0x00, /* type */ 1347 0x00, /* type */
1345 0x26, 0x01, 1348 0x26, 0x01,
1346 0x00, 0x00, 0x00, 0x00,/* id */ 1349 0x00, 0x00, 0x00, 0x00,/* id */
1347 0x65, 1350 0x65,
1348 0x00, /* length of remaining part */ 1351 0x00, /* length of remaining part */
1349 0x00, /* field */ 1352 0x00, /* field */
1350 0x37}; /* data follows here */ 1353 0x37}; /* data follows here */
1351 1354
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);
1355 buffer[6] = ((id >> 16) & 0xff); 1358 buffer[6] = ((id >> 16) & 0xff);
1356 buffer[7] = ((id >> 8) & 0xff); 1359 buffer[7] = ((id >> 8) & 0xff);
1357 buffer[8] = (id & 0xff); 1360 buffer[8] = (id & 0xff);
1358 1361
1359 switch (Priv->BinaryType) { 1362 switch (Priv->BinaryType) {
1360 case TypeCalendar: 1363 case TypeCalendar:
1361 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; 1364 buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR;
1362 break; 1365 break;
1363 case TypeContacts: 1366 case TypeContacts:
1364 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; 1367 buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS;
1365 break; 1368 break;
1366 case TypeToDo: 1369 case TypeToDo:
1367 buffer[2] = ALCATEL_SYNC_TYPE_TODO; 1370 buffer[2] = ALCATEL_SYNC_TYPE_TODO;
1368 break; 1371 break;
1369 } 1372 }
1370 error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); 1373 error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data);
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;
1377} 1380}
1378 1381
1379static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s) 1382static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s)
1380{ 1383{
1381 strcpy(s->Phone.Data.Manufacturer, "Alcatel"); 1384 strcpy(s->Phone.Data.Manufacturer, "Alcatel");
1382 return ERR_NONE; 1385 return ERR_NONE;
1383} 1386}
1384 1387
1385static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s) 1388static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s)
1386{ 1389{
1387 GSM_Error error; 1390 GSM_Error error;
@@ -1734,59 +1737,59 @@ static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1734 } 1737 }
1735} 1738}
1736 1739
1737static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start) 1740static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start)
1738{ 1741{
1739 GSM_Error error; 1742 GSM_Error error;
1740 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1743 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1741 1744
1742 if (entry->MemoryType == MEM_ME) { 1745 if (entry->MemoryType == MEM_ME) {
1743 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1746 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1744 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 1747 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
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;
1748 if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; 1751 if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error;
1749 1752
1750 return ALCATEL_GetMemory(s, entry); 1753 return ALCATEL_GetMemory(s, entry);
1751 } else { 1754 } else {
1752 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 1755 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
1753 return ATGEN_GetNextMemory(s, entry, start); 1756 return ATGEN_GetNextMemory(s, entry, start);
1754 } 1757 }
1755} 1758}
1756 1759
1757static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1760static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1758{ 1761{
1759 GSM_Error error; 1762 GSM_Error error;
1760 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 1763 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
1761 int NamePosition = -1; 1764 int NamePosition = -1;
1762 bool NameSet = false; 1765 bool NameSet = false;
1763 int i; 1766 int i;
1764 1767
1765 1768
1766 if (entry->MemoryType == MEM_ME) { 1769 if (entry->MemoryType == MEM_ME) {
1767 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1770 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1768 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error; 1771 if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error;
1769 for (i = 0; i < entry->EntriesNum; i++) { 1772 for (i = 0; i < entry->EntriesNum; i++) {
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;
1773 break; 1776 break;
1774 case PBK_Number_Mobile: 1777 case PBK_Number_Mobile:
1775 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 12, entry->Entries[i].Text)) != ERR_NONE) return error; 1778 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 12, entry->Entries[i].Text)) != ERR_NONE) return error;
1776 break; 1779 break;
1777 case PBK_Number_Work: 1780 case PBK_Number_Work:
1778 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error; 1781 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error;
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;
1782 break; 1785 break;
1783 case PBK_Number_Home: 1786 case PBK_Number_Home:
1784 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 13, entry->Entries[i].Text)) != ERR_NONE) return error; 1787 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 13, entry->Entries[i].Text)) != ERR_NONE) return error;
1785 break; 1788 break;
1786 case PBK_Number_Pager: 1789 case PBK_Number_Pager:
1787 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 11, entry->Entries[i].Text)) != ERR_NONE) return error; 1790 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 11, entry->Entries[i].Text)) != ERR_NONE) return error;
1788 break; 1791 break;
1789 case PBK_Number_Other: 1792 case PBK_Number_Other:
1790 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 10, entry->Entries[i].Text)) != ERR_NONE) return error; 1793 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 10, entry->Entries[i].Text)) != ERR_NONE) return error;
1791 break; 1794 break;
1792 case PBK_Text_Note: 1795 case PBK_Text_Note:
@@ -1800,61 +1803,61 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1800 break; 1803 break;
1801 case PBK_Text_LastName: 1804 case PBK_Text_LastName:
1802 if ((error = ALCATEL_CreateField(s, Alcatel_string, 0, entry->Entries[i].Text)) != ERR_NONE) return error; 1805 if ((error = ALCATEL_CreateField(s, Alcatel_string, 0, entry->Entries[i].Text)) != ERR_NONE) return error;
1803 NameSet = true; 1806 NameSet = true;
1804 break; 1807 break;
1805 case PBK_Text_FirstName: 1808 case PBK_Text_FirstName:
1806 if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; 1809 if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error;
1807 NameSet = true; 1810 NameSet = true;
1808 break; 1811 break;
1809 case PBK_Text_Company: 1812 case PBK_Text_Company:
1810 if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error; 1813 if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error;
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;
1820 break; 1823 break;
1821 case PBK_Text_StreetAddress: 1824 case PBK_Text_StreetAddress:
1822 if ((error = ALCATEL_CreateField(s, Alcatel_string, 16, entry->Entries[i].Text)) != ERR_NONE) return error; 1825 if ((error = ALCATEL_CreateField(s, Alcatel_string, 16, entry->Entries[i].Text)) != ERR_NONE) return error;
1823 break; 1826 break;
1824 case PBK_Text_City: 1827 case PBK_Text_City:
1825 if ((error = ALCATEL_CreateField(s, Alcatel_string, 17, entry->Entries[i].Text)) != ERR_NONE) return error; 1828 if ((error = ALCATEL_CreateField(s, Alcatel_string, 17, entry->Entries[i].Text)) != ERR_NONE) return error;
1826 break; 1829 break;
1827 case PBK_Text_State: 1830 case PBK_Text_State:
1828 if ((error = ALCATEL_CreateField(s, Alcatel_string, 18, entry->Entries[i].Text)) != ERR_NONE) return error; 1831 if ((error = ALCATEL_CreateField(s, Alcatel_string, 18, entry->Entries[i].Text)) != ERR_NONE) return error;
1829 break; 1832 break;
1830 case PBK_Text_Zip: 1833 case PBK_Text_Zip:
1831 if ((error = ALCATEL_CreateField(s, Alcatel_string, 19, entry->Entries[i].Text)) != ERR_NONE) return error; 1834 if ((error = ALCATEL_CreateField(s, Alcatel_string, 19, entry->Entries[i].Text)) != ERR_NONE) return error;
1832 break; 1835 break;
1833 case PBK_Text_Country: 1836 case PBK_Text_Country:
1834 if ((error = ALCATEL_CreateField(s, Alcatel_string, 20, entry->Entries[i].Text)) != ERR_NONE) return error; 1837 if ((error = ALCATEL_CreateField(s, Alcatel_string, 20, entry->Entries[i].Text)) != ERR_NONE) return error;
1835 break; 1838 break;
1836 case PBK_Text_Custom1: 1839 case PBK_Text_Custom1:
1837 if ((error = ALCATEL_CreateField(s, Alcatel_string, 21, entry->Entries[i].Text)) != ERR_NONE) return error; 1840 if ((error = ALCATEL_CreateField(s, Alcatel_string, 21, entry->Entries[i].Text)) != ERR_NONE) return error;
1838 break; 1841 break;
1839 case PBK_Text_Custom2: 1842 case PBK_Text_Custom2:
1840 if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error; 1843 if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error;
1841 break; 1844 break;
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;
1845 case PBK_Text_Custom4: 1848 case PBK_Text_Custom4:
1846 if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error; 1849 if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error;
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) {
1850 if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1853 if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error;
1851 } else { 1854 } else {
1852 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); 1855 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType);
1853 } 1856 }
1854 break; 1857 break;
1855 1858
1856 case PBK_Text_Name: NamePosition = i; break; 1859 case PBK_Text_Name: NamePosition = i; break;
1857 /* Following fields are not supported: */ 1860 /* Following fields are not supported: */
1858 case PBK_Text_UserID: 1861 case PBK_Text_UserID:
1859 case PBK_SMSListID: 1862 case PBK_SMSListID:
1860 case PBK_RingtoneFileSystemID: 1863 case PBK_RingtoneFileSystemID:
@@ -1897,131 +1900,131 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1897 if (entry->Location == 0) return ERR_INVALIDLOCATION; 1900 if (entry->Location == 0) return ERR_INVALIDLOCATION;
1898 1901
1899 if (entry->MemoryType == MEM_ME) { 1902 if (entry->MemoryType == MEM_ME) {
1900 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 1903 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
1901 /* Save modified entry */ 1904 /* Save modified entry */
1902 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 1905 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
1903 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { 1906 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) {
1904 /* Entry doesn't exist, we will create new one */ 1907 /* Entry doesn't exist, we will create new one */
1905 return ALCATEL_AddMemory(s, entry); 1908 return ALCATEL_AddMemory(s, entry);
1906 } 1909 }
1907 /* Get fields for current item */ 1910 /* Get fields for current item */
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;
1913 for (i = 0; i < entry->EntriesNum; i++) { 1916 for (i = 0; i < entry->EntriesNum; i++) {
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;
1938 break; 1941 break;
1939 case PBK_Number_Other: 1942 case PBK_Number_Other:
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;
1969 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error; 1972 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error;
1970 break; 1973 break;
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;
1974 break; 1977 break;
1975 case PBK_Private: 1978 case PBK_Private:
1976 UpdatedFields[6] = true; 1979 UpdatedFields[6] = true;
1977 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; 1980 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error;
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;
1995 case PBK_Text_Country: 1998 case PBK_Text_Country:
1996 UpdatedFields[20] = true; 1999 UpdatedFields[20] = true;
1997 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 20, entry->Entries[i].Text)) != ERR_NONE) return error; 2000 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 20, entry->Entries[i].Text)) != ERR_NONE) return error;
1998 break; 2001 break;
1999 case PBK_Text_Custom1: 2002 case PBK_Text_Custom1:
2000 UpdatedFields[21] = true; 2003 UpdatedFields[21] = true;
2001 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error; 2004 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error;
2002 break; 2005 break;
2003 case PBK_Text_Custom2: 2006 case PBK_Text_Custom2:
2004 UpdatedFields[22] = true; 2007 UpdatedFields[22] = true;
2005 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error; 2008 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error;
2006 break; 2009 break;
2007 case PBK_Text_Custom3: 2010 case PBK_Text_Custom3:
2008 UpdatedFields[23] = true; 2011 UpdatedFields[23] = true;
2009 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error; 2012 if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error;
2010 break; 2013 break;
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) {
2017 UpdatedFields[25] = true; 2020 UpdatedFields[25] = true;
2018 if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; 2021 if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error;
2019 } else { 2022 } else {
2020 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); 2023 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType);
2021 } 2024 }
2022 break; 2025 break;
2023 2026
2024 case PBK_Text_Name: NamePosition = i; break; 2027 case PBK_Text_Name: NamePosition = i; break;
2025 /* Following fields are not supported: */ 2028 /* Following fields are not supported: */
2026 case PBK_SMSListID: 2029 case PBK_SMSListID:
2027 case PBK_Text_UserID: 2030 case PBK_Text_UserID:
@@ -2060,29 +2063,29 @@ static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entr
2060 GSM_Error error; 2063 GSM_Error error;
2061 2064
2062 if (entry->MemoryType == MEM_ME) { 2065 if (entry->MemoryType == MEM_ME) {
2063 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2066 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
2064 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2067 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2065 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { 2068 if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) {
2066 /* Entry was empty => no error */ 2069 /* Entry was empty => no error */
2067 return ERR_NONE; 2070 return ERR_NONE;
2068 } 2071 }
2069 /* Do real delete */ 2072 /* Do real delete */
2070 error = ALCATEL_DeleteItem(s, entry->Location); 2073 error = ALCATEL_DeleteItem(s, entry->Location);
2071 if (error != ERR_NONE) return error; 2074 if (error != ERR_NONE) return error;
2072 2075
2073 /* Refresh list */ 2076 /* Refresh list */
2074 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; 2077 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error;
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;
2078 } else { 2081 } else {
2079 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2082 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2080 return ATGEN_DeleteMemory(s, entry); 2083 return ATGEN_DeleteMemory(s, entry);
2081 } 2084 }
2082} 2085}
2083 2086
2084static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) 2087static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type)
2085{ 2088{
2086 GSM_Error error; 2089 GSM_Error error;
2087 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2090 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2088 int i; 2091 int i;
@@ -2219,25 +2222,25 @@ static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *ne
2219 2222
2220 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2223 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2221 return ATGEN_GetNetworkInfo(s, netinfo); 2224 return ATGEN_GetNetworkInfo(s, netinfo);
2222} 2225}
2223 2226
2224static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features) 2227static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features)
2225{ 2228{
2226 GSM_Error error; 2229 GSM_Error error;
2227 2230
2228 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2231 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2229 return ATGEN_GetDisplayStatus(s, features); 2232 return ATGEN_GetDisplayStatus(s, features);
2230} 2233}
2231 2234
2232static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) 2235static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s)
2233{ 2236{
2234 GSM_Error error; 2237 GSM_Error error;
2235 2238
2236 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2239 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2237 return ATGEN_SetAutoNetworkLogin(s); 2240 return ATGEN_SetAutoNetworkLogin(s);
2238} 2241}
2239 2242
2240static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 2243static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
2241{ 2244{
2242 GSM_Error error; 2245 GSM_Error error;
2243 2246
@@ -2328,27 +2331,27 @@ static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence)
2328static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI) 2331static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI)
2329{ 2332{
2330 GSM_Error error; 2333 GSM_Error error;
2331 2334
2332 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 2335 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
2333 return ATGEN_GetSIMIMSI(s, IMSI); 2336 return ATGEN_GetSIMIMSI(s, IMSI);
2334} 2337}
2335 2338
2336static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status) 2339static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status)
2337{ 2340{
2338 GSM_Error error; 2341 GSM_Error error;
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;
2344 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 2347 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
2345 2348
2346 status->Used = Priv->CalendarItemsCount; 2349 status->Used = Priv->CalendarItemsCount;
2347 return ERR_NONE; 2350 return ERR_NONE;
2348} 2351}
2349 2352
2350static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 2353static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2351{ 2354{
2352 GSM_Error error; 2355 GSM_Error error;
2353 GSM_DateTime *dt = NULL; 2356 GSM_DateTime *dt = NULL;
2354 GSM_DateTime evdate; 2357 GSM_DateTime evdate;
@@ -2718,25 +2721,25 @@ static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2718 } 2721 }
2719 return ERR_NONE; 2722 return ERR_NONE;
2720} 2723}
2721 2724
2722static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 2725static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
2723{ 2726{
2724 GSM_Error error; 2727 GSM_Error error;
2725 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2728 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2726 2729
2727 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2730 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2728 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2731 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
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;
2732 if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; 2735 if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error;
2733 2736
2734 return ALCATEL_GetCalendar(s, Note); 2737 return ALCATEL_GetCalendar(s, Note);
2735} 2738}
2736 2739
2737 2740
2738static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 2741static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2739{ 2742{
2740 GSM_Error error; 2743 GSM_Error error;
2741 2744
2742 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2745 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
@@ -2759,25 +2762,25 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2759{ 2762{
2760 GSM_Error error; 2763 GSM_Error error;
2761 unsigned int val; 2764 unsigned int val;
2762 bool contact_set = false; 2765 bool contact_set = false;
2763 bool phone_set = false; 2766 bool phone_set = false;
2764 bool date_set = false; 2767 bool date_set = false;
2765 bool repeating = false; 2768 bool repeating = false;
2766 int i; 2769 int i;
2767 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2770 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2768 2771
2769 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2772 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
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++) {
2773 switch (Note->Entries[i].EntryType) { 2776 switch (Note->Entries[i].EntryType) {
2774 case CAL_START_DATETIME: 2777 case CAL_START_DATETIME:
2775 if (!date_set) { 2778 if (!date_set) {
2776 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2779 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2777 date_set = true; 2780 date_set = true;
2778 } 2781 }
2779 if ((error = ALCATEL_CreateField(s, Alcatel_time, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2782 if ((error = ALCATEL_CreateField(s, Alcatel_time, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2780 break; 2783 break;
2781 case CAL_END_DATETIME: 2784 case CAL_END_DATETIME:
2782 if (!date_set) { 2785 if (!date_set) {
2783 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2786 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
@@ -2797,25 +2800,25 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2797 if ((error = ALCATEL_CreateField(s, Alcatel_string, 5, Note->Entries[i].Text)) != ERR_NONE) return error; 2800 if ((error = ALCATEL_CreateField(s, Alcatel_string, 5, Note->Entries[i].Text)) != ERR_NONE) return error;
2798 break; 2801 break;
2799 case CAL_PRIVATE: 2802 case CAL_PRIVATE:
2800 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2803 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2801 break; 2804 break;
2802 case CAL_CONTACTID: 2805 case CAL_CONTACTID:
2803 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2806 if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2804 contact_set = true; 2807 contact_set = true;
2805 break; 2808 break;
2806 case CAL_PHONE: 2809 case CAL_PHONE:
2807 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error; 2810 if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error;
2808 phone_set = true; 2811 phone_set = true;
2809 break; 2812 break;
2810 case CAL_REPEAT_DAYOFWEEK: 2813 case CAL_REPEAT_DAYOFWEEK:
2811 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2814 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2812 repeating = true; 2815 repeating = true;
2813 break; 2816 break;
2814 case CAL_REPEAT_DAY: 2817 case CAL_REPEAT_DAY:
2815 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2818 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2816 repeating = true; 2819 repeating = true;
2817 break; 2820 break;
2818 case CAL_REPEAT_WEEKOFMONTH: 2821 case CAL_REPEAT_WEEKOFMONTH:
2819 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2822 if ((error = ALCATEL_CreateField(s, Alcatel_byte, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2820 repeating = true; 2823 repeating = true;
2821 break; 2824 break;
@@ -2833,25 +2836,25 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2833 break; 2836 break;
2834 case CAL_REPEAT_STOPDATE: 2837 case CAL_REPEAT_STOPDATE:
2835 if ((error = ALCATEL_CreateField(s, Alcatel_date, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2838 if ((error = ALCATEL_CreateField(s, Alcatel_date, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2836 repeating = true; 2839 repeating = true;
2837 break; 2840 break;
2838 case CAL_SILENT_ALARM_DATETIME: 2841 case CAL_SILENT_ALARM_DATETIME:
2839 case CAL_RECURRANCE: 2842 case CAL_RECURRANCE:
2840 case CAL_LOCATION: 2843 case CAL_LOCATION:
2841 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); 2844 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType);
2842 break; 2845 break;
2843 } 2846 }
2844 } 2847 }
2845 2848
2846 switch (Note->Type) { 2849 switch (Note->Type) {
2847 case GSM_CAL_CALL: 2850 case GSM_CAL_CALL:
2848 val = 3; 2851 val = 3;
2849 break; 2852 break;
2850 case GSM_CAL_BIRTHDAY: 2853 case GSM_CAL_BIRTHDAY:
2851 val = 2; 2854 val = 2;
2852 break; 2855 break;
2853 case GSM_CAL_ALARM: 2856 case GSM_CAL_ALARM:
2854 val = 4; 2857 val = 4;
2855 break; 2858 break;
2856 case GSM_CAL_DAILY_ALARM: 2859 case GSM_CAL_DAILY_ALARM:
2857 val = 5; 2860 val = 5;
@@ -2891,34 +2894,34 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2891 int i; 2894 int i;
2892 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 2895 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
2893 bool UpdatedFields[22]; 2896 bool UpdatedFields[22];
2894 2897
2895 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 2898 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
2896 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 2899 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
2897 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { 2900 if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) {
2898 /* Entry doesn't exist, we will create new one */ 2901 /* Entry doesn't exist, we will create new one */
2899 return ALCATEL_AddCalendar(s, Note); 2902 return ALCATEL_AddCalendar(s, Note);
2900 } 2903 }
2901 /* Get fields for current item */ 2904 /* Get fields for current item */
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; }
2905 2908
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++) {
2909 switch (Note->Entries[i].EntryType) { 2912 switch (Note->Entries[i].EntryType) {
2910 case CAL_START_DATETIME: 2913 case CAL_START_DATETIME:
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;
2914 date_set = true; 2917 date_set = true;
2915 } 2918 }
2916 UpdatedFields[1] = true; 2919 UpdatedFields[1] = true;
2917 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2920 if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2918 break; 2921 break;
2919 case CAL_END_DATETIME: 2922 case CAL_END_DATETIME:
2920 if (!date_set) { 2923 if (!date_set) {
2921 UpdatedFields[0] = true; 2924 UpdatedFields[0] = true;
2922 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2925 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2923 date_set = true; 2926 date_set = true;
2924 } 2927 }
@@ -2944,25 +2947,25 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2944 UpdatedFields[6] = true; 2947 UpdatedFields[6] = true;
2945 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, Note->Location, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2948 if ((error = ALCATEL_UpdateField(s, Alcatel_bool, Note->Location, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2946 break; 2949 break;
2947 case CAL_CONTACTID: 2950 case CAL_CONTACTID:
2948 UpdatedFields[8] = true; 2951 UpdatedFields[8] = true;
2949 if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2952 if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2950 contact_set = true; 2953 contact_set = true;
2951 break; 2954 break;
2952 case CAL_PHONE: 2955 case CAL_PHONE:
2953 UpdatedFields[9] = true; 2956 UpdatedFields[9] = true;
2954 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error; 2957 if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error;
2955 phone_set = true; 2958 phone_set = true;
2956 break; 2959 break;
2957 case CAL_REPEAT_DAYOFWEEK: 2960 case CAL_REPEAT_DAYOFWEEK:
2958 UpdatedFields[10] = true; 2961 UpdatedFields[10] = true;
2959 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2962 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2960 repeating = true; 2963 repeating = true;
2961 break; 2964 break;
2962 case CAL_REPEAT_DAY: 2965 case CAL_REPEAT_DAY:
2963 UpdatedFields[11] = true; 2966 UpdatedFields[11] = true;
2964 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; 2967 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error;
2965 repeating = true; 2968 repeating = true;
2966 break; 2969 break;
2967 case CAL_REPEAT_WEEKOFMONTH: 2970 case CAL_REPEAT_WEEKOFMONTH:
2968 UpdatedFields[12] = true; 2971 UpdatedFields[12] = true;
@@ -2987,25 +2990,25 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not
2987 case CAL_REPEAT_STOPDATE: 2990 case CAL_REPEAT_STOPDATE:
2988 UpdatedFields[19] = true; 2991 UpdatedFields[19] = true;
2989 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; 2992 if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error;
2990 repeating = true; 2993 repeating = true;
2991 break; 2994 break;
2992 case CAL_SILENT_ALARM_DATETIME: 2995 case CAL_SILENT_ALARM_DATETIME:
2993 case CAL_RECURRANCE: 2996 case CAL_RECURRANCE:
2994 case CAL_LOCATION: 2997 case CAL_LOCATION:
2995 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); 2998 smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType);
2996 break; 2999 break;
2997 } 3000 }
2998 } 3001 }
2999 3002
3000 switch (Note->Type) { 3003 switch (Note->Type) {
3001 case GSM_CAL_CALL: 3004 case GSM_CAL_CALL:
3002 val = 3; 3005 val = 3;
3003 break; 3006 break;
3004 case GSM_CAL_BIRTHDAY: 3007 case GSM_CAL_BIRTHDAY:
3005 val = 2; 3008 val = 2;
3006 break; 3009 break;
3007 case GSM_CAL_ALARM: 3010 case GSM_CAL_ALARM:
3008 val = 4; 3011 val = 4;
3009 break; 3012 break;
3010 case GSM_CAL_DAILY_ALARM: 3013 case GSM_CAL_DAILY_ALARM:
3011 val = 5; 3014 val = 5;
@@ -3063,52 +3066,52 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
3063{ 3066{
3064 GSM_Error error; 3067 GSM_Error error;
3065 GSM_CalendarEntryNote; 3068 GSM_CalendarEntryNote;
3066 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3069 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3067 int i; 3070 int i;
3068 bool Found = false; 3071 bool Found = false;
3069 bool DateSet = false; 3072 bool DateSet = false;
3070 int alarm_number = alarm->Location; 3073 int alarm_number = alarm->Location;
3071 static GSM_DateTimenulldt = {0,0,0,0,0,0,0}; 3074 static GSM_DateTimenulldt = {0,0,0,0,0,0,0};
3072 3075
3073 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; 3076 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error;
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++) {
3077 if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; 3080 if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error;
3078 if (Priv->ReturnType != Alcatel_enum) { 3081 if (Priv->ReturnType != Alcatel_enum) {
3079 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 3082 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
3080 continue; 3083 continue;
3081 } 3084 }
3082 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { 3085 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) {
3083 alarm_number--; 3086 alarm_number--;
3084 if (alarm_number == 0) { 3087 if (alarm_number == 0) {
3085 Found = true; 3088 Found = true;
3086 break; 3089 break;
3087 } 3090 }
3088 } 3091 }
3089 } 3092 }
3090 3093
3091 if (!Found) return ERR_EMPTY; 3094 if (!Found) return ERR_EMPTY;
3092 3095
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;
3096 3099
3097 if (Note.Type == GSM_CAL_ALARM) { 3100 if (Note.Type == GSM_CAL_ALARM) {
3098 alarm->Repeating = false; 3101 alarm->Repeating = false;
3099 } else { 3102 } else {
3100 alarm->Repeating = true; 3103 alarm->Repeating = true;
3101 } 3104 }
3102 3105
3103 alarm->Text[0] = 0; alarm->Text[1] = 0; 3106 alarm->Text[0] = 0; alarm->Text[1] = 0;
3104 3107
3105 3108
3106 for (i = 0; i < Note.EntriesNum; i++) { 3109 for (i = 0; i < Note.EntriesNum; i++) {
3107 if (Note.Entries[i].EntryType == CAL_TEXT) { 3110 if (Note.Entries[i].EntryType == CAL_TEXT) {
3108 CopyUnicodeString(alarm->Text, Note.Entries[i].Text); 3111 CopyUnicodeString(alarm->Text, Note.Entries[i].Text);
3109 } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) { 3112 } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) {
3110 alarm->DateTime = Note.Entries[i].Date; 3113 alarm->DateTime = Note.Entries[i].Date;
3111 DateSet = false; 3114 DateSet = false;
3112 } 3115 }
3113 } 3116 }
3114 if (!DateSet) { 3117 if (!DateSet) {
@@ -3137,25 +3140,25 @@ static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm)
3137 if (Priv->ReturnType != Alcatel_enum) { 3140 if (Priv->ReturnType != Alcatel_enum) {
3138 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); 3141 smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType);
3139 continue; 3142 continue;
3140 } 3143 }
3141 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { 3144 if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) {
3142 alarm_number--; 3145 alarm_number--;
3143 if (alarm_number == 0) { 3146 if (alarm_number == 0) {
3144 Found = true; 3147 Found = true;
3145 break; 3148 break;
3146 } 3149 }
3147 } 3150 }
3148 } 3151 }
3149 3152
3150 if (Found) { 3153 if (Found) {
3151 Note.Location = Priv->CalendarItems[i]; 3154 Note.Location = Priv->CalendarItems[i];
3152 } 3155 }
3153 3156
3154 Note.EntriesNum = 1; 3157 Note.EntriesNum = 1;
3155 3158
3156 Note.Entries[0].EntryType = CAL_ALARM_DATETIME; 3159 Note.Entries[0].EntryType = CAL_ALARM_DATETIME;
3157 Note.Entries[0].Date = alarm->DateTime; 3160 Note.Entries[0].Date = alarm->DateTime;
3158 3161
3159 if (alarm->Repeating) { 3162 if (alarm->Repeating) {
3160 Note.Type = GSM_CAL_DAILY_ALARM; 3163 Note.Type = GSM_CAL_DAILY_ALARM;
3161 GSM_GetCurrentDateTime(&dt); 3164 GSM_GetCurrentDateTime(&dt);
@@ -3175,27 +3178,27 @@ static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm)
3175 if (Found) { 3178 if (Found) {
3176 return ALCATEL_SetCalendar(s, &Note); 3179 return ALCATEL_SetCalendar(s, &Note);
3177 } else { 3180 } else {
3178 return ALCATEL_AddCalendar(s, &Note); 3181 return ALCATEL_AddCalendar(s, &Note);
3179 } 3182 }
3180} 3183}
3181 3184
3182 3185
3183static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 3186static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
3184{ 3187{
3185 GSM_Error error; 3188 GSM_Error error;
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;
3191 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; 3194 if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error;
3192 3195
3193 status->Used = Priv->ToDoItemsCount; 3196 status->Used = Priv->ToDoItemsCount;
3194 return ERR_NONE; 3197 return ERR_NONE;
3195} 3198}
3196 3199
3197static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3200static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3198{ 3201{
3199 GSM_Error error; 3202 GSM_Error error;
3200 GSM_DateTime *dt = NULL; 3203 GSM_DateTime *dt = NULL;
3201 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3204 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
@@ -3442,25 +3445,25 @@ static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3442 } 3445 }
3443 return ERR_NONE; 3446 return ERR_NONE;
3444} 3447}
3445 3448
3446static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 3449static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
3447{ 3450{
3448 GSM_Error error; 3451 GSM_Error error;
3449 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3452 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3450 3453
3451 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3454 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3452 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3455 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
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;
3456 if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; 3459 if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error;
3457 3460
3458 return ALCATEL_GetToDo(s, ToDo); 3461 return ALCATEL_GetToDo(s, ToDo);
3459} 3462}
3460 3463
3461static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s) 3464static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s)
3462{ 3465{
3463 GSM_Error error; 3466 GSM_Error error;
3464 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3467 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3465 int i; 3468 int i;
3466 3469
@@ -3481,25 +3484,25 @@ static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s)
3481 3484
3482static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 3485static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3483{ 3486{
3484 GSM_Error error; 3487 GSM_Error error;
3485 unsigned int val; 3488 unsigned int val;
3486 bool contact_set = false; 3489 bool contact_set = false;
3487 bool phone_set = false; 3490 bool phone_set = false;
3488 int i; 3491 int i;
3489 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3492 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3490 3493
3491 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3494 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
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) {
3495 case GSM_Priority_High: 3498 case GSM_Priority_High:
3496 val = 0; 3499 val = 0;
3497 break; 3500 break;
3498 case GSM_Priority_Low: 3501 case GSM_Priority_Low:
3499 val = 2; 3502 val = 2;
3500 break; 3503 break;
3501 case GSM_Priority_Medium: 3504 case GSM_Priority_Medium:
3502 default: 3505 default:
3503 val = 1; 3506 val = 1;
3504 break; 3507 break;
3505 } 3508 }
@@ -3509,25 +3512,25 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3509 } else { 3512 } else {
3510 if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; 3513 if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error;
3511 } 3514 }
3512 3515
3513 for (i = 0; i < ToDo->EntriesNum; i++) { 3516 for (i = 0; i < ToDo->EntriesNum; i++) {
3514 switch (ToDo->Entries[i].EntryType) { 3517 switch (ToDo->Entries[i].EntryType) {
3515 case TODO_END_DATETIME: 3518 case TODO_END_DATETIME:
3516 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3519 if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3517 break; 3520 break;
3518 case TODO_COMPLETED: 3521 case TODO_COMPLETED:
3519 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3522 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
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;
3523 if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3526 if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3524 if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3527 if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3525 if ((error = ALCATEL_CreateField(s, Alcatel_time, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; 3528 if ((error = ALCATEL_CreateField(s, Alcatel_time, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error;
3526 break; 3529 break;
3527 case TODO_TEXT: 3530 case TODO_TEXT:
3528 if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; 3531 if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error;
3529 break; 3532 break;
3530 case TODO_PRIVATE: 3533 case TODO_PRIVATE:
3531 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; 3534 if ((error = ALCATEL_CreateField(s, Alcatel_bool, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error;
3532 break; 3535 break;
3533 case TODO_CATEGORY: 3536 case TODO_CATEGORY:
@@ -3570,27 +3573,27 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3570 int i; 3573 int i;
3571 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; 3574 GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL;
3572 3575
3573 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; 3576 if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error;
3574 /* Save modified ToDo */ 3577 /* Save modified ToDo */
3575 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; 3578 if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error;
3576 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { 3579 if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) {
3577 /* Entry doesn't exist, we will create new one */ 3580 /* Entry doesn't exist, we will create new one */
3578 return ALCATEL_AddToDo(s, ToDo); 3581 return ALCATEL_AddToDo(s, ToDo);
3579 } 3582 }
3580 /* Get fields for current item */ 3583 /* Get fields for current item */
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;
3586 3589
3587 switch (ToDo->Priority) { 3590 switch (ToDo->Priority) {
3588 case GSM_Priority_High: 3591 case GSM_Priority_High:
3589 val = 0; 3592 val = 0;
3590 break; 3593 break;
3591 case GSM_Priority_Low: 3594 case GSM_Priority_Low:
3592 val = 2; 3595 val = 2;
3593 break; 3596 break;
3594 case GSM_Priority_Medium: 3597 case GSM_Priority_Medium:
3595 default: 3598 default:
3596 val = 1; 3599 val = 1;
@@ -3599,60 +3602,60 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
3599 /* This one seems to be byte for BF5 and enum for BE5 */ 3602 /* This one seems to be byte for BF5 and enum for BE5 */
3600 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { 3603 if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) {
3601 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error; 3604 if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error;
3602 } else { 3605 } else {
3603 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error; 3606 if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error;
3604 } 3607 }
3605 UpdatedFields[7] = true; 3608 UpdatedFields[7] = true;
3606 3609
3607 for (i = 0; i < ToDo->EntriesNum; i++) { 3610 for (i = 0; i < ToDo->EntriesNum; i++) {
3608 switch (ToDo->Entries[i].EntryType) { 3611 switch (ToDo->Entries[i].EntryType) {
3609 case TODO_END_DATETIME: 3612 case TODO_END_DATETIME:
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;
3613 case TODO_COMPLETED: 3616 case TODO_COMPLETED:
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;
3627 case TODO_TEXT: 3630 case TODO_TEXT:
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;
3631 case TODO_PRIVATE: 3634 case TODO_PRIVATE:
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;
3635 case TODO_CATEGORY: 3638 case TODO_CATEGORY:
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;
3639 case TODO_CONTACTID: 3642 case TODO_CONTACTID:
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;
3643 break; 3646 break;
3644 case TODO_PHONE: 3647 case TODO_PHONE:
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;
3648 break; 3651 break;
3649 default: 3652 default:
3650 break; 3653 break;
3651 } 3654 }
3652 } 3655 }
3653 if (!contact_set) { 3656 if (!contact_set) {
3654 if (phone_set) { 3657 if (phone_set) {
3655 val = 0xffffffff; 3658 val = 0xffffffff;
3656 } else { 3659 } else {
3657 val = 0; 3660 val = 0;
3658 } 3661 }
@@ -3813,24 +3816,32 @@ static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable)
3813 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3816 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3814 return ATGEN_SetIncomingCB(s, enable); 3817 return ATGEN_SetIncomingCB(s, enable);
3815} 3818}
3816 3819
3817static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) 3820static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable)
3818{ 3821{
3819 GSM_Error error; 3822 GSM_Error error;
3820 3823
3821 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; 3824 if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
3822 return ATGEN_SetIncomingSMS(s, enable); 3825 return ATGEN_SetIncomingSMS(s, enable);
3823} 3826}
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[] = {
3826 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, 3837 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach },
3827 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, 3838 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach },
3828 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, 3839 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit },
3829 {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, 3840 {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 },
3830 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, 3841 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd },
3831 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, 3842 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose },
3832 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, 3843 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart },
3833 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, 3844 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 },
3834 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, 3845 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 },
3835 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, 3846 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 },
3836 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, 3847 {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 },
@@ -3904,24 +3915,25 @@ GSM_Phone_Functions ALCATELPhone = {
3904 NOTSUPPORTED, /* GetSpeedDial */ 3915 NOTSUPPORTED, /* GetSpeedDial */
3905 NOTSUPPORTED, /* SetSpeedDial */ 3916 NOTSUPPORTED, /* SetSpeedDial */
3906 ALCATEL_GetSMSC, 3917 ALCATEL_GetSMSC,
3907 ALCATEL_SetSMSC, 3918 ALCATEL_SetSMSC,
3908 ALCATEL_GetSMSStatus, 3919 ALCATEL_GetSMSStatus,
3909 ALCATEL_GetSMS, 3920 ALCATEL_GetSMS,
3910 ALCATEL_GetNextSMS, 3921 ALCATEL_GetNextSMS,
3911 NOTSUPPORTED, /* SetSMS */ 3922 NOTSUPPORTED, /* SetSMS */
3912 ALCATEL_AddSMS, 3923 ALCATEL_AddSMS,
3913 ALCATEL_DeleteSMS, 3924 ALCATEL_DeleteSMS,
3914 ALCATEL_SendSMS, 3925 ALCATEL_SendSMS,
3915 ALCATEL_SendSavedSMS, 3926 ALCATEL_SendSavedSMS,
3927 ALCATEL_SetFastSMSSending,
3916 ALCATEL_SetIncomingSMS, 3928 ALCATEL_SetIncomingSMS,
3917 ALCATEL_SetIncomingCB, 3929 ALCATEL_SetIncomingCB,
3918 ALCATEL_GetSMSFolders, 3930 ALCATEL_GetSMSFolders,
3919 NOTSUPPORTED, /* AddSMSFolder */ 3931 NOTSUPPORTED, /* AddSMSFolder */
3920 NOTSUPPORTED, /* DeleteSMSFolder */ 3932 NOTSUPPORTED, /* DeleteSMSFolder */
3921 ALCATEL_DialVoice, 3933 ALCATEL_DialVoice,
3922 ALCATEL_AnswerCall, 3934 ALCATEL_AnswerCall,
3923 ALCATEL_CancelCall, 3935 ALCATEL_CancelCall,
3924 NOTSUPPORTED, /* HoldCall */ 3936 NOTSUPPORTED, /* HoldCall */
3925 NOTSUPPORTED, /* UnholdCall */ 3937 NOTSUPPORTED, /* UnholdCall */
3926 NOTSUPPORTED, /* ConferenceCall */ 3938 NOTSUPPORTED, /* ConferenceCall */
3927 NOTSUPPORTED, /* SplitCall */ 3939 NOTSUPPORTED, /* SplitCall */
@@ -3958,25 +3970,25 @@ GSM_Phone_Functions ALCATELPhone = {
3958 ALCATEL_AddToDo, 3970 ALCATEL_AddToDo,
3959 ALCATEL_DeleteToDo, 3971 ALCATEL_DeleteToDo,
3960 ALCATEL_DeleteAllToDo, 3972 ALCATEL_DeleteAllToDo,
3961 ALCATEL_GetCalendarStatus, 3973 ALCATEL_GetCalendarStatus,
3962 ALCATEL_GetCalendar, 3974 ALCATEL_GetCalendar,
3963 ALCATEL_GetNextCalendar, 3975 ALCATEL_GetNextCalendar,
3964 ALCATEL_SetCalendar, 3976 ALCATEL_SetCalendar,
3965 ALCATEL_AddCalendar, 3977 ALCATEL_AddCalendar,
3966 ALCATEL_DeleteCalendar, 3978 ALCATEL_DeleteCalendar,
3967 ALCATEL_DeleteAllCalendar, 3979 ALCATEL_DeleteAllCalendar,
3968 NOTSUPPORTED, /* GetCalendarSettings*/ 3980 NOTSUPPORTED, /* GetCalendarSettings*/
3969 NOTSUPPORTED, /* SetCalendarSettings*/ 3981 NOTSUPPORTED, /* SetCalendarSettings*/
3970 NOTSUPPORTED, /* GetNote */ 3982 NOTSUPPORTED, /* GetNextNote */
3971 NOTSUPPORTED, /* GetProfile */ 3983 NOTSUPPORTED, /* GetProfile */
3972 NOTSUPPORTED, /* SetProfile */ 3984 NOTSUPPORTED, /* SetProfile */
3973 NOTSUPPORTED, /* GetFMStation */ 3985 NOTSUPPORTED, /* GetFMStation */
3974 NOTSUPPORTED, /* SetFMStation */ 3986 NOTSUPPORTED, /* SetFMStation */
3975 NOTSUPPORTED, /* ClearFMStations */ 3987 NOTSUPPORTED, /* ClearFMStations */
3976 NOTSUPPORTED, /* GetNextFileFolder*/ 3988 NOTSUPPORTED, /* GetNextFileFolder*/
3977 NOTSUPPORTED, /* GetFilePart */ 3989 NOTSUPPORTED, /* GetFilePart */
3978 NOTSUPPORTED, /* AddFilePart */ 3990 NOTSUPPORTED, /* AddFilePart */
3979 NOTSUPPORTED, /* GetFileSystemStatus*/ 3991 NOTSUPPORTED, /* GetFileSystemStatus*/
3980 NOTSUPPORTED, /* DeleteFile */ 3992 NOTSUPPORTED, /* DeleteFile */
3981 NOTSUPPORTED, /* AddFolder */ 3993 NOTSUPPORTED, /* AddFolder */
3982 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 3994 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -3,55 +3,35 @@
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13#include "../../service/sms/gsmsms.h" 13#include "../../service/sms/gsmsms.h"
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
47typedef struct { 27typedef struct {
48 int Number; 28 int Number;
49 char Text[60]; 29 char Text[60];
50} ATErrorCode; 30} ATErrorCode;
51 31
52static ATErrorCode CMSErrorCodes[] = { 32static ATErrorCode CMSErrorCodes[] = {
53 /* 33 /*
54 * Error codes not specified here were either undefined or reserved in my 34 * Error codes not specified here were either undefined or reserved in my
55 * copy of specifications, if you have newer one, please fill in the gaps. 35 * copy of specifications, if you have newer one, please fill in the gaps.
56 */ 36 */
57 /* 0...127 from GSM 04.11 Annex E-2 */ 37 /* 0...127 from GSM 04.11 Annex E-2 */
@@ -166,24 +146,26 @@ GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
166{ 146{
167 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 147 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
168 148
169 if (Priv->ErrorCode == 0) { 149 if (Priv->ErrorCode == 0) {
170 smprintf(s, "CME Error occured, but it's type not detected\n"); 150 smprintf(s, "CME Error occured, but it's type not detected\n");
171 } else if (Priv->ErrorText == NULL) { 151 } else if (Priv->ErrorText == NULL) {
172 smprintf(s, "CME Error %i, no description available\n", Priv->ErrorCode); 152 smprintf(s, "CME Error %i, no description available\n", Priv->ErrorCode);
173 } else { 153 } else {
174 smprintf(s, "CME Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText); 154 smprintf(s, "CME Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText);
175 } 155 }
176 /* For error codes descriptions see table a bit above */ 156 /* For error codes descriptions see table a bit above */
177 switch (Priv->ErrorCode) { 157 switch (Priv->ErrorCode) {
158 case -1:
159 return ERR_EMPTY;
178 case 3: 160 case 3:
179 return ERR_PERMISSION; 161 return ERR_PERMISSION;
180 case 4: 162 case 4:
181 return ERR_NOTSUPPORTED; 163 return ERR_NOTSUPPORTED;
182 case 5: 164 case 5:
183 case 11: 165 case 11:
184 case 12: 166 case 12:
185 case 16: 167 case 16:
186 case 17: 168 case 17:
187 case 18: 169 case 18:
188 return ERR_SECURITYERROR; 170 return ERR_SECURITYERROR;
189 case 20: 171 case 20:
@@ -247,26 +229,34 @@ int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output)
247 *output=*input; 229 *output=*input;
248 input++; 230 input++;
249 output++; 231 output++;
250 position++; 232 position++;
251 } 233 }
252 *output=0; 234 *output=0;
253 position++; 235 position++;
254 return position; 236 return position;
255} 237}
256 238
257void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input) 239void 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
262 input++; 252 input++;
263 dt->Month=(*input-'0')*10; input++; 253 dt->Month=(*input-'0')*10; input++;
264 dt->Month=dt->Month+(*input-'0'); input++; 254 dt->Month=dt->Month+(*input-'0'); input++;
265 255
266 input++; 256 input++;
267 dt->Day=(*input-'0')*10; input++; 257 dt->Day=(*input-'0')*10; input++;
268 dt->Day=dt->Day+(*input-'0'); input++; 258 dt->Day=dt->Day+(*input-'0'); input++;
269 259
270 input++; 260 input++;
271 dt->Hour=(*input-'0')*10; input++; 261 dt->Hour=(*input-'0')*10; input++;
272 dt->Hour=dt->Hour+(*input-'0'); input++; 262 dt->Hour=dt->Hour+(*input-'0'); input++;
@@ -313,24 +303,36 @@ GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
313 if (!strcmp(line,"OK")) Priv->ReplyState = AT_Reply_OK; 303 if (!strcmp(line,"OK")) Priv->ReplyState = AT_Reply_OK;
314 if (!strcmp(line,"> ")) Priv->ReplyState = AT_Reply_SMSEdit; 304 if (!strcmp(line,"> ")) Priv->ReplyState = AT_Reply_SMSEdit;
315 if (!strcmp(line,"CONNECT"))Priv->ReplyState = AT_Reply_Connect; 305 if (!strcmp(line,"CONNECT"))Priv->ReplyState = AT_Reply_Connect;
316 if (!strcmp(line,"ERROR" ))Priv->ReplyState = AT_Reply_Error; 306 if (!strcmp(line,"ERROR" ))Priv->ReplyState = AT_Reply_Error;
317 if (!strncmp(line,"+CME ERROR:",11)) { 307 if (!strncmp(line,"+CME ERROR:",11)) {
318 Priv->ReplyState = AT_Reply_CMEError; 308 Priv->ReplyState = AT_Reply_CMEError;
319 ErrorCodes = CMEErrorCodes; 309 ErrorCodes = CMEErrorCodes;
320 } 310 }
321 if (!strncmp(line,"+CMS ERROR:",11)) { 311 if (!strncmp(line,"+CMS ERROR:",11)) {
322 Priv->ReplyState = AT_Reply_CMSError; 312 Priv->ReplyState = AT_Reply_CMSError;
323 ErrorCodes = CMSErrorCodes; 313 ErrorCodes = CMSErrorCodes;
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) {
326 j = 0; 328 j = 0;
327 /* One char behind +CM[SE] ERROR */ 329 /* One char behind +CM[SE] ERROR */
328 err = line + 12; 330 err = line + 12;
329 while (err[j] && !isalnum(err[j])) j++; 331 while (err[j] && !isalnum(err[j])) j++;
330 if (isdigit(err[j])) { 332 if (isdigit(err[j])) {
331 Priv->ErrorCode = atoi(&(err[j])); 333 Priv->ErrorCode = atoi(&(err[j]));
332 k = 0; 334 k = 0;
333 while (ErrorCodes[k].Number != -1) { 335 while (ErrorCodes[k].Number != -1) {
334 if (ErrorCodes[k].Number == Priv->ErrorCode) { 336 if (ErrorCodes[k].Number == Priv->ErrorCode) {
335 Priv->ErrorText = (char *)&(ErrorCodes[k].Text); 337 Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
336 break; 338 break;
@@ -361,52 +363,90 @@ GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
361 case AT_Reply_Error: 363 case AT_Reply_Error:
362 return ERR_UNKNOWN; 364 return ERR_UNKNOWN;
363 case AT_Reply_CMSError: 365 case AT_Reply_CMSError:
364 return ATGEN_HandleCMSError(s); 366 return ATGEN_HandleCMSError(s);
365 case AT_Reply_CMEError: 367 case AT_Reply_CMEError:
366 return ATGEN_HandleCMEError(s); 368 return ATGEN_HandleCMEError(s);
367 default: 369 default:
368 break; 370 break;
369 } 371 }
370 return ERR_UNKNOWNRESPONSE; 372 return ERR_UNKNOWNRESPONSE;
371} 373}
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)
374{ 412{
375 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 413 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
376 GSM_Phone_Data *Data = &s->Phone.Data; 414 GSM_Phone_Data *Data = &s->Phone.Data;
377 415
378 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED; 416 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED;
379 417
380 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) { 418 if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) {
381 CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2); 419 CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2);
382 420
383 /* Sometimes phone adds this before manufacturer (Sagem) */ 421 /* Sometimes phone adds this before manufacturer (Sagem) */
384 if (strncmp("+CGMM: ", Data->Model, 7) == 0) { 422 if (strncmp("+CGMM: ", Data->Model, 7) == 0) {
385 memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1); 423 memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1);
386 } 424 }
387 425
388 Data->ModelInfo = GetModelData(NULL,Data->Model,NULL); 426 Data->ModelInfo = GetModelData(NULL,Data->Model,NULL);
389 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model); 427 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model);
390 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL); 428 if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL);
391 429
392 if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number); 430 if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number);
393 431
394 if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia; 432 if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia;
395 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens; 433 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens;
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;
398 437
399 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20"); 438 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20");
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");
402 } else { 442 } else {
403 smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); 443 smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2)));
404 } 444 }
405 445
406 return ERR_NONE; 446 return ERR_NONE;
407} 447}
408 448
409GSM_Error ATGEN_GetModel(GSM_StateMachine *s) 449GSM_Error ATGEN_GetModel(GSM_StateMachine *s)
410{ 450{
411 GSM_Error error; 451 GSM_Error error;
412 452
@@ -472,24 +512,29 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine
472 Priv->Manufacturer = AT_HP; 512 Priv->Manufacturer = AT_HP;
473 } 513 }
474 if (strstr(msg.Buffer,"ALCATEL")) { 514 if (strstr(msg.Buffer,"ALCATEL")) {
475 smprintf(s, "Alcatel\n"); 515 smprintf(s, "Alcatel\n");
476 strcpy(s->Phone.Data.Manufacturer,"Alcatel"); 516 strcpy(s->Phone.Data.Manufacturer,"Alcatel");
477 Priv->Manufacturer = AT_Alcatel; 517 Priv->Manufacturer = AT_Alcatel;
478 } 518 }
479 if (strstr(msg.Buffer,"SAGEM")) { 519 if (strstr(msg.Buffer,"SAGEM")) {
480 smprintf(s, "Sagem\n"); 520 smprintf(s, "Sagem\n");
481 strcpy(s->Phone.Data.Manufacturer,"Sagem"); 521 strcpy(s->Phone.Data.Manufacturer,"Sagem");
482 Priv->Manufacturer = AT_Sagem; 522 Priv->Manufacturer = AT_Sagem;
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;
485 case AT_Reply_CMSError: 530 case AT_Reply_CMSError:
486 return ATGEN_HandleCMSError(s); 531 return ATGEN_HandleCMSError(s);
487 default: 532 default:
488 break; 533 break;
489 } 534 }
490 return ERR_UNKNOWNRESPONSE; 535 return ERR_UNKNOWNRESPONSE;
491} 536}
492 537
493GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s) 538GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s)
494{ 539{
495 if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE; 540 if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE;
@@ -665,34 +710,44 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *
665 case AT_Reply_OK: 710 case AT_Reply_OK:
666 /* Reply here is: 711 /* Reply here is:
667 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]] 712 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]]
668 * each memory is in quotes, 713 * each memory is in quotes,
669 * Example: ("SM"), ("SM"), ("SM") 714 * Example: ("SM"), ("SM"), ("SM")
670 * 715 *
671 * We need to get from this supported memories. For this case 716 * We need to get from this supported memories. For this case
672 * we assume, that just appearence of memory makes it 717 * we assume, that just appearence of memory makes it
673 * available for everything. Then we need to find out whether 718 * available for everything. Then we need to find out whether
674 * phone supports writing to memory. This is done by searching 719 * phone supports writing to memory. This is done by searching
675 * for "), (", which will appear between lists. 720 * for "), (", which will appear between lists.
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;
684 case AT_Reply_Error: 737 case AT_Reply_Error:
685 case AT_Reply_CMSError: 738 case AT_Reply_CMSError:
686 return ATGEN_HandleCMSError(s); 739 return ATGEN_HandleCMSError(s);
740 case AT_Reply_CMEError:
741 return ATGEN_HandleCMEError(s);
687 default: 742 default:
688 return ERR_UNKNOWNRESPONSE; 743 return ERR_UNKNOWNRESPONSE;
689 } 744 }
690} 745}
691 746
692GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s) 747GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s)
693{ 748{
694 smprintf(s, "Getting available SMS memories\n"); 749 smprintf(s, "Getting available SMS memories\n");
695 return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories); 750 return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories);
696} 751}
697 752
698GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM) 753GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM)
@@ -849,26 +904,27 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
849 CopyLineString(buffer, msg.Buffer, Priv->Lines, 2); 904 CopyLineString(buffer, msg.Buffer, Priv->Lines, 2);
850 switch (buffer[7]) { 905 switch (buffer[7]) {
851 case '0': sms->State = SMS_UnRead; break; 906 case '0': sms->State = SMS_UnRead; break;
852 case '1': sms->State = SMS_Read;break; 907 case '1': sms->State = SMS_Read;break;
853 case '2': sms->State = SMS_UnSent;break; 908 case '2': sms->State = SMS_UnSent;break;
854 default : sms->State = SMS_Sent;break;//case '3' 909 default : sms->State = SMS_Sent;break;//case '3'
855 } 910 }
856 DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3))); 911 DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3)));
857 /* Siemens MC35 (only ?) */ 912 /* Siemens MC35 (only ?) */
858 if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY; 913 if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY;
859 /* Siemens M20 */ 914 /* Siemens M20 */
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 */
864 smprintf(s, "SMS type - status report (M20 style)\n"); 920 smprintf(s, "SMS type - status report (M20 style)\n");
865 sms->PDU = SMS_Status_Report; 921 sms->PDU = SMS_Status_Report;
866 sms->Folder = 1;/*INBOX SIM*/ 922 sms->Folder = 1;/*INBOX SIM*/
867 sms->InboxFolder = true; 923 sms->InboxFolder = true;
868 924
869 smsframe[12]=buffer[current++]; 925 smsframe[12]=buffer[current++];
870 smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++]; 926 smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++];
871 current2=((buffer[current])+1)/2+1; 927 current2=((buffer[current])+1)/2+1;
872 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; 928 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
873 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; 929 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
874 smsframe[0] = 0; 930 smsframe[0] = 0;
@@ -885,25 +941,25 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
885 switch (smsframe[12] & 0x03) { 941 switch (smsframe[12] & 0x03) {
886 case 0x00: 942 case 0x00:
887 smprintf(s, "SMS type - deliver\n"); 943 smprintf(s, "SMS type - deliver\n");
888 sms->PDU = SMS_Deliver; 944 sms->PDU = SMS_Deliver;
889 if (Priv->SMSMemory == MEM_SM) { 945 if (Priv->SMSMemory == MEM_SM) {
890 sms->Folder = 1; /*INBOX SIM*/ 946 sms->Folder = 1; /*INBOX SIM*/
891 } else { 947 } else {
892 sms->Folder = 3; /*INBOX ME*/ 948 sms->Folder = 3; /*INBOX ME*/
893 } 949 }
894 sms->InboxFolder = true; 950 sms->InboxFolder = true;
895 current2=((buffer[current])+1)/2+1; 951 current2=((buffer[current])+1)/2+1;
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");
899 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 955 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
900 current+=6; 956 current+=6;
901 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++]; 957 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++];
902 } else { 958 } else {
903 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 959 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
904 } 960 }
905 } else { 961 } else {
906 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 962 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
907 } 963 }
908 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; 964 smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++];
909 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; 965 smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++];
@@ -916,49 +972,49 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
916 smprintf(s, "SMS type - submit\n"); 972 smprintf(s, "SMS type - submit\n");
917 sms->PDU = SMS_Submit; 973 sms->PDU = SMS_Submit;
918 if (Priv->SMSMemory == MEM_SM) { 974 if (Priv->SMSMemory == MEM_SM) {
919 sms->Folder = 2; /*OUTBOX SIM*/ 975 sms->Folder = 2; /*OUTBOX SIM*/
920 smprintf(s, "Outbox SIM\n"); 976 smprintf(s, "Outbox SIM\n");
921 } else { 977 } else {
922 sms->Folder = 4; /*OUTBOX ME*/ 978 sms->Folder = 4; /*OUTBOX ME*/
923 } 979 }
924 sms->InboxFolder = false; 980 sms->InboxFolder = false;
925 smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++]; 981 smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++];
926 current2=((buffer[current])+1)/2+1; 982 current2=((buffer[current])+1)/2+1;
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");
930 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 986 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
931 current+=6; 987 current+=6;
932 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++]; 988 for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++];
933 } else { 989 } else {
934 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 990 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
935 } 991 }
936 } else { 992 } else {
937 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 993 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
938 } 994 }
939 smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++]; 995 smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++];
940 smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++]; 996 smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++];
941 /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */ 997 /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */
942 if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now 998 if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now
943 smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++]; 999 smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++];
944 for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++]; 1000 for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++];
945 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit); 1001 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit);
946 return ERR_NONE; 1002 return ERR_NONE;
947 case 0x02: 1003 case 0x02:
948 smprintf(s, "SMS type - status report\n"); 1004 smprintf(s, "SMS type - status report\n");
949 sms->PDU = SMS_Status_Report; 1005 sms->PDU = SMS_Status_Report;
950 sms->Folder = 1;/*INBOX SIM*/ 1006 sms->Folder = 1;/*INBOX SIM*/
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++];
954 current2=((buffer[current])+1)/2+1; 1010 current2=((buffer[current])+1)/2+1;
955 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; 1011 for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
956 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; 1012 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
957 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; 1013 for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
958 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; 1014 smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
959 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); 1015 GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
960 return ERR_NONE; 1016 return ERR_NONE;
961 } 1017 }
962 break; 1018 break;
963 case SMS_AT_TXT: 1019 case SMS_AT_TXT:
964 current = 0; 1020 current = 0;
@@ -1631,35 +1687,35 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1631 if (s->Protocol.Data.AT.EditMode) { 1687 if (s->Protocol.Data.AT.EditMode) {
1632 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_SMSEdit) { 1688 if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_SMSEdit) {
1633 return ERR_UNKNOWN; 1689 return ERR_UNKNOWN;
1634 } 1690 }
1635 s->Protocol.Data.AT.EditMode = false; 1691 s->Protocol.Data.AT.EditMode = false;
1636 return ERR_NONE; 1692 return ERR_NONE;
1637 } 1693 }
1638 1694
1639 switch (Priv->ReplyState) { 1695 switch (Priv->ReplyState) {
1640 case AT_Reply_OK: 1696 case AT_Reply_OK:
1641 smprintf(s, "SMS sent OK\n"); 1697 smprintf(s, "SMS sent OK\n");
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) {
1645 s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7)); 1701 s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7));
1646 } else { 1702 } else {
1647 s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); 1703 s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1);
1648 } 1704 }
1649 } 1705 }
1650 return ERR_NONE; 1706 return ERR_NONE;
1651 case AT_Reply_CMSError: 1707 case AT_Reply_CMSError:
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);
1655 case AT_Reply_Error: 1711 case AT_Reply_Error:
1656 return ERR_UNKNOWN; 1712 return ERR_UNKNOWN;
1657 default: 1713 default:
1658 return ERR_UNKNOWNRESPONSE; 1714 return ERR_UNKNOWNRESPONSE;
1659 } 1715 }
1660} 1716}
1661 1717
1662GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) 1718GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
1663{ 1719{
1664 GSM_Error error,error2; 1720 GSM_Error error,error2;
1665 int current, current2, Replies; 1721 int current, current2, Replies;
@@ -1778,24 +1834,37 @@ GSM_Error ATGEN_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
1778GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 1834GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1779{ 1835{
1780 if (alarm->Location != 1) return ERR_NOTSUPPORTED; 1836 if (alarm->Location != 1) return ERR_NOTSUPPORTED;
1781 1837
1782 alarm->Repeating = true; 1838 alarm->Repeating = true;
1783 alarm->Text[0] = 0; alarm->Text[1] = 0; 1839 alarm->Text[0] = 0; alarm->Text[1] = 0;
1784 1840
1785 s->Phone.Data.Alarm = alarm; 1841 s->Phone.Data.Alarm = alarm;
1786 smprintf(s, "Getting alarm\n"); 1842 smprintf(s, "Getting alarm\n");
1787 return GSM_WaitFor (s, "AT+CALA?\r", 9, 0x00, 4, ID_GetAlarm); 1843 return GSM_WaitFor (s, "AT+CALA?\r", 9, 0x00, 4, ID_GetAlarm);
1788} 1844}
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)
1791{ 1860{
1792 GSM_SMSC *SMSC = s->Phone.Data.SMSC; 1861 GSM_SMSC *SMSC = s->Phone.Data.SMSC;
1793 int current; 1862 int current;
1794 int len; 1863 int len;
1795 unsigned char buffer[100]; 1864 unsigned char buffer[100];
1796 1865
1797 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 1866 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
1798 case AT_Reply_OK: 1867 case AT_Reply_OK:
1799 smprintf(s, "SMSC info received\n"); 1868 smprintf(s, "SMSC info received\n");
1800 1869
1801 current = 0; 1870 current = 0;
@@ -2193,24 +2262,26 @@ GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM
2193 char req[20]; 2262 char req[20];
2194 int start; 2263 int start;
2195 int end; 2264 int end;
2196 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 2265 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
2197 2266
2198 smprintf(s, "Getting memory information\n"); 2267 smprintf(s, "Getting memory information\n");
2199 2268
2200 Priv->MemorySize = 0; 2269 Priv->MemorySize = 0;
2201 Priv->TextLength = 0; 2270 Priv->TextLength = 0;
2202 Priv->NumberLength = 0; 2271 Priv->NumberLength = 0;
2203 2272
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;
2206 if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE; 2277 if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE;
2207 2278
2208 smprintf(s, "Getting memory status by reading values\n"); 2279 smprintf(s, "Getting memory status by reading values\n");
2209 2280
2210 s->Phone.Data.MemoryStatus= Status; 2281 s->Phone.Data.MemoryStatus= Status;
2211 Status->MemoryUsed = 0; 2282 Status->MemoryUsed = 0;
2212 Status->MemoryFree = 0; 2283 Status->MemoryFree = 0;
2213 start = Priv->FirstMemoryEntry; 2284 start = Priv->FirstMemoryEntry;
2214 Priv->NextMemoryEntry = 0; 2285 Priv->NextMemoryEntry = 0;
2215 while (1) { 2286 while (1) {
2216 end= start + 20; 2287 end= start + 20;
@@ -2259,24 +2330,30 @@ GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode)
2259 /* If we want unicode charset and we have it already or setting of it 2330 /* If we want unicode charset and we have it already or setting of it
2260 * failed, we have nothing to do. */ 2331 * failed, we have nothing to do. */
2261 if (PreferUnicode && (Priv->PBKCharset==AT_PBK_UCS2 || Priv->UCS2CharsetFailed)) return ERR_NONE; 2332 if (PreferUnicode && (Priv->PBKCharset==AT_PBK_UCS2 || Priv->UCS2CharsetFailed)) return ERR_NONE;
2262 2333
2263 /* If we don't need unicode charset and we have some (or have unicode 2334 /* If we don't need unicode charset and we have some (or have unicode
2264 * charset when other failed), we have nothing to do. */ 2335 * charset when other failed), we have nothing to do. */
2265 if (!PreferUnicode && (Priv->PBKCharset!=AT_PBK_UCS2 || Priv->NonUCS2CharsetFailed)) return ERR_NONE; 2336 if (!PreferUnicode && (Priv->PBKCharset!=AT_PBK_UCS2 || Priv->NonUCS2CharsetFailed)) return ERR_NONE;
2266 } 2337 }
2267 2338
2268 error=ATGEN_GetManufacturer(s); 2339 error=ATGEN_GetManufacturer(s);
2269 if (error != ERR_NONE) return error; 2340 if (error != ERR_NONE) return error;
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) {
2272 smprintf(s, "Setting charset to UCS2\n"); 2349 smprintf(s, "Setting charset to UCS2\n");
2273 error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset); 2350 error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset);
2274 if (error == ERR_NONE) { 2351 if (error == ERR_NONE) {
2275 Priv->PBKCharset = AT_PBK_UCS2; 2352 Priv->PBKCharset = AT_PBK_UCS2;
2276 return ERR_NONE; 2353 return ERR_NONE;
2277 } else { 2354 } else {
2278 Priv->UCS2CharsetFailed = true; 2355 Priv->UCS2CharsetFailed = true;
2279 } 2356 }
2280 } 2357 }
2281 2358
2282 smprintf(s, "Setting charset to HEX\n"); 2359 smprintf(s, "Setting charset to HEX\n");
@@ -2376,25 +2453,55 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
2376 Memory->Entries[1].EntryType=PBK_Text_Name; 2453 Memory->Entries[1].EntryType=PBK_Text_Name;
2377 switch (Priv->PBKCharset) { 2454 switch (Priv->PBKCharset) {
2378 case AT_PBK_HEX: 2455 case AT_PBK_HEX:
2379 DecodeHexBin(buffer2,buffer+1,strlen(buffer)-2); 2456 DecodeHexBin(buffer2,buffer+1,strlen(buffer)-2);
2380 DecodeDefault(Memory->Entries[1].Text,buffer2,strlen(buffer2),false,NULL); 2457 DecodeDefault(Memory->Entries[1].Text,buffer2,strlen(buffer2),false,NULL);
2381 break; 2458 break;
2382 case AT_PBK_GSM: 2459 case AT_PBK_GSM:
2383 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL); 2460 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
2384 break; 2461 break;
2385 case AT_PBK_UCS2: 2462 case AT_PBK_UCS2:
2386 DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1); 2463 DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1);
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;
2390 case AT_Reply_CMEError: 2497 case AT_Reply_CMEError:
2391 return ATGEN_HandleCMEError(s); 2498 return ATGEN_HandleCMEError(s);
2392 case AT_Reply_Error: 2499 case AT_Reply_Error:
2393 smprintf(s, "Error - too high location ?\n"); 2500 smprintf(s, "Error - too high location ?\n");
2394 return ERR_INVALIDLOCATION; 2501 return ERR_INVALIDLOCATION;
2395 case AT_Reply_CMSError: 2502 case AT_Reply_CMSError:
2396 return ATGEN_HandleCMSError(s); 2503 return ATGEN_HandleCMSError(s);
2397 default: 2504 default:
2398 break; 2505 break;
2399 } 2506 }
2400 return ERR_UNKNOWNRESPONSE; 2507 return ERR_UNKNOWNRESPONSE;
@@ -2553,24 +2660,26 @@ GSM_Error ATGEN_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber
2553 2660
2554GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) 2661GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
2555{ 2662{
2556 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 2663 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
2557 case AT_Reply_OK: 2664 case AT_Reply_OK:
2558 smprintf(s, "Security code was OK\n"); 2665 smprintf(s, "Security code was OK\n");
2559 return ERR_NONE; 2666 return ERR_NONE;
2560 case AT_Reply_Error: 2667 case AT_Reply_Error:
2561 smprintf(s, "Incorrect security code\n"); 2668 smprintf(s, "Incorrect security code\n");
2562 return ERR_SECURITYERROR; 2669 return ERR_SECURITYERROR;
2563 case AT_Reply_CMSError: 2670 case AT_Reply_CMSError:
2564 return ATGEN_HandleCMSError(s); 2671 return ATGEN_HandleCMSError(s);
2672 case AT_Reply_CMEError:
2673 return ATGEN_HandleCMEError(s);
2565 default: 2674 default:
2566 break; 2675 break;
2567 } 2676 }
2568 return ERR_UNKNOWNRESPONSE; 2677 return ERR_UNKNOWNRESPONSE;
2569} 2678}
2570 2679
2571GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) 2680GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
2572{ 2681{
2573 unsigned char req[50]; 2682 unsigned char req[50];
2574 2683
2575 switch (Code.Type) { 2684 switch (Code.Type) {
2576 case SEC_Pin : 2685 case SEC_Pin :
@@ -2915,24 +3024,30 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2915 EncodeHexBin(name, DecodeUnicodeString(entry->Entries[Name].Text), UnicodeLength(entry->Entries[Name].Text)); 3024 EncodeHexBin(name, DecodeUnicodeString(entry->Entries[Name].Text), UnicodeLength(entry->Entries[Name].Text));
2916 len = strlen(name); 3025 len = strlen(name);
2917 break; 3026 break;
2918 case AT_PBK_GSM: 3027 case AT_PBK_GSM:
2919 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text)); 3028 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
2920 len = UnicodeLength(entry->Entries[Name].Text); 3029 len = UnicodeLength(entry->Entries[Name].Text);
2921 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL); 3030 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
2922 break; 3031 break;
2923 case AT_PBK_UCS2: 3032 case AT_PBK_UCS2:
2924 EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text)); 3033 EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text));
2925 len = strlen(name); 3034 len = strlen(name);
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 }
2928 } else { 3043 } else {
2929 smprintf(s, "WARNING: No usable name found!\n"); 3044 smprintf(s, "WARNING: No usable name found!\n");
2930 len = 0; 3045 len = 0;
2931 } 3046 }
2932 3047
2933 if (Number != -1) { 3048 if (Number != -1) {
2934 GSM_PackSemiOctetNumber(entry->Entries[Number].Text, number, false); 3049 GSM_PackSemiOctetNumber(entry->Entries[Number].Text, number, false);
2935 NumberType = number[0]; 3050 NumberType = number[0];
2936 sprintf(number,"%s",DecodeUnicodeString(entry->Entries[Number].Text)); 3051 sprintf(number,"%s",DecodeUnicodeString(entry->Entries[Number].Text));
2937 } else { 3052 } else {
2938 smprintf(s, "WARNING: No usable number found!\n"); 3053 smprintf(s, "WARNING: No usable number found!\n");
@@ -3243,24 +3358,61 @@ GSM_Error ATGEN_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3243 return ERR_NOTSUPPORTED; 3358 return ERR_NOTSUPPORTED;
3244} 3359}
3245 3360
3246GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 3361GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3247{ 3362{
3248 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 3363 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
3249 3364
3250 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_DelCalendarNote(s, Note); 3365 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_DelCalendarNote(s, Note);
3251 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_DelCalendarNote(s, Note); 3366 if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_DelCalendarNote(s, Note);
3252 return ERR_NOTSUPPORTED; 3367 return ERR_NOTSUPPORTED;
3253} 3368}
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)
3256{ 3408{
3257 GSM_Errorerror; 3409 GSM_Errorerror;
3258 unsigned char Frame[] = "AT+CKPD=\"?\"\r"; 3410 unsigned char Frame[] = "AT+CKPD=\"?\"\r";
3259 3411
3260 if (Press) { 3412 if (Press) {
3261 switch (Key) { 3413 switch (Key) {
3262 case GSM_KEY_1 : Frame[9] = '1'; break; 3414 case GSM_KEY_1 : Frame[9] = '1'; break;
3263 case GSM_KEY_2 : Frame[9] = '2'; break; 3415 case GSM_KEY_2 : Frame[9] = '2'; break;
3264 case GSM_KEY_3 : Frame[9] = '3'; break; 3416 case GSM_KEY_3 : Frame[9] = '3'; break;
3265 case GSM_KEY_4 : Frame[9] = '4'; break; 3417 case GSM_KEY_4 : Frame[9] = '4'; break;
3266 case GSM_KEY_5 : Frame[9] = '5'; break; 3418 case GSM_KEY_5 : Frame[9] = '5'; break;
@@ -3337,24 +3489,35 @@ GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
3337 return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB); 3489 return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB);
3338 } else { 3490 } else {
3339 smprintf(s, "Disabling incoming CB\n"); 3491 smprintf(s, "Disabling incoming CB\n");
3340 return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB); 3492 return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB);
3341 } 3493 }
3342 } 3494 }
3343 return ERR_NONE; 3495 return ERR_NONE;
3344#else 3496#else
3345 return ERR_SOURCENOTAVAILABLE; 3497 return ERR_SOURCENOTAVAILABLE;
3346#endif 3498#endif
3347} 3499}
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)
3350{ 3513{
3351 smprintf(s, "Incoming SMS\n"); 3514 smprintf(s, "Incoming SMS\n");
3352 return ERR_NONE; 3515 return ERR_NONE;
3353} 3516}
3354 3517
3355GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s) 3518GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s)
3356{ 3519{
3357 GSM_Phone_Data *Data = &s->Phone.Data; 3520 GSM_Phone_Data *Data = &s->Phone.Data;
3358 GSM_SMSMessage sms; 3521 GSM_SMSMessage sms;
3359 int current = 0, current2, i=0; 3522 int current = 0, current2, i=0;
3360 unsigned char buffer[300],smsframe[800]; 3523 unsigned char buffer[300],smsframe[800];
@@ -3415,32 +3578,49 @@ GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
3415 GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS); 3578 GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS);
3416 3579
3417 /* SMS deliver */ 3580 /* SMS deliver */
3418 return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS); 3581 return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS);
3419 } else { 3582 } else {
3420 smprintf(s, "Disabling incoming SMS\n"); 3583 smprintf(s, "Disabling incoming SMS\n");
3421 return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS); 3584 return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS);
3422 } 3585 }
3423 } 3586 }
3424 return ERR_NONE; 3587 return ERR_NONE;
3425} 3588}
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[] = {
3428 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame }, 3603 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame },
3429 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho }, 3604 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho },
3430 {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo }, 3605 {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo },
3431 {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey }, 3606 {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey },
3432 {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI }, 3607 {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI },
3433 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX }, 3608 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX },
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
3436 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame }, 3616 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame },
3437 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB }, 3617 {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB },
3438#endif 3618#endif
3439 3619
3440 {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame }, 3620 {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame },
3441 {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge }, 3621 {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge },
3442 3622
3443 {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel }, 3623 {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel },
3444 {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer }, 3624 {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer },
3445 {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware }, 3625 {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware },
3446 {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware }, 3626 {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware },
@@ -3453,122 +3633,134 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3453 {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode }, 3633 {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode },
3454 {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage }, 3634 {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage },
3455 {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType }, 3635 {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType },
3456 {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus }, 3636 {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus },
3457 {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories }, 3637 {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories },
3458 {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage }, 3638 {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage },
3459 {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters }, 3639 {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters },
3460 {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC }, 3640 {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC },
3461 {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC }, 3641 {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC },
3462 {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage }, 3642 {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage },
3463 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters }, 3643 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters },
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 },
3466 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame }, 3647 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame },
3467 {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame }, 3648 {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame },
3468 {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame }, 3649 {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame },
3469 3650
3470 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime }, 3651 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime },
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 },
3473 3655
3474 {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo }, 3656 {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo },
3475 {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo }, 3657 {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo },
3476 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo }, 3658 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo },
3477 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin}, 3659 {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin},
3478 {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo }, 3660 {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo },
3479 {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality }, 3661 {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality },
3480 {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame }, 3662 {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame },
3481 {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame }, 3663 {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame },
3482 {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame }, 3664 {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame },
3483 3665
3484 {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType }, 3666 {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType },
3485 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType }, 3667 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType },
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 },
3489 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset }, 3673 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset },
3490 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory }, 3674 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory },
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
3505 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode }, 3689 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode },
3506 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode }, 3690 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode },
3507 {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus }, 3691 {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus },
3508 {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame }, 3692 {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame },
3509 3693
3510 {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF }, 3694 {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF },
3511 {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall }, 3695 {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall },
3512 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice }, 3696 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice },
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 },
3515 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame }, 3701 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
3516 {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame }, 3702 {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame },
3517 {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame }, 3703 {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame },
3518 {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame }, 3704 {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame },
3519 3705
3520 {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset }, 3706 {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset },
3521 {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset }, 3707 {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset },
3522 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings }, 3708 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings },
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
3525/* Why do I give Alcatel specific things here? It's simple, Alcatel needs 3717/* Why do I give Alcatel specific things here? It's simple, Alcatel needs
3526 * some AT commands to start it's binary mode, so this needs to be in AT 3718 * some AT commands to start it's binary mode, so this needs to be in AT
3527 * related stuff. 3719 * related stuff.
3528 * 3720 *
3529 * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel 3721 * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel
3530 * specific and it's part of ETSI specifications 3722 * specific and it's part of ETSI specifications
3531 */ 3723 */
3532 {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl }, 3724 {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl },
3533 {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol }, 3725 {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol },
3534 {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect }, 3726 {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect },
3535#endif 3727#endif
3536 3728
3537 {NULL, "\x00" ,0x00,0x00,ID_None } 3729 {NULL, "\x00" ,0x00,0x00,ID_None }
3538}; 3730};
3539 3731
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,
3543 ATGEN_Initialise, 3735 ATGEN_Initialise,
3544 ATGEN_Terminate, 3736 ATGEN_Terminate,
3545 ATGEN_DispatchMessage, 3737 ATGEN_DispatchMessage,
3546 NOTSUPPORTED, /* ShowStartInfo */ 3738 NOTSUPPORTED, /* ShowStartInfo */
3547 ATGEN_GetManufacturer, 3739 ATGEN_GetManufacturer,
3548 ATGEN_GetModel, 3740 ATGEN_GetModel,
3549 ATGEN_GetFirmware, 3741 ATGEN_GetFirmware,
3550 ATGEN_GetIMEI, 3742 ATGEN_GetIMEI,
3551 NOTSUPPORTED, /* GetOriginalIMEI */ 3743 NOTSUPPORTED, /* GetOriginalIMEI */
3552 NOTSUPPORTED, /* GetManufactureMonth*/ 3744 NOTSUPPORTED, /* GetManufactureMonth*/
3553 NOTSUPPORTED, /* GetProductCode */ 3745 NOTSUPPORTED, /* GetProductCode */
3554 NOTSUPPORTED, /* GetHardware */ 3746 NOTSUPPORTED, /* GetHardware */
3555 NOTSUPPORTED, /* GetPPM */ 3747 NOTSUPPORTED, /* GetPPM */
3556 ATGEN_GetSIMIMSI, 3748 ATGEN_GetSIMIMSI,
3557 ATGEN_GetDateTime, 3749 ATGEN_GetDateTime,
3558 ATGEN_SetDateTime, 3750 ATGEN_SetDateTime,
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,
3564 ATGEN_Reset, 3756 ATGEN_Reset,
3565 ATGEN_ResetPhoneSettings, 3757 ATGEN_ResetPhoneSettings,
3566 ATGEN_EnterSecurityCode, 3758 ATGEN_EnterSecurityCode,
3567 ATGEN_GetSecurityStatus, 3759 ATGEN_GetSecurityStatus,
3568 ATGEN_GetDisplayStatus, 3760 ATGEN_GetDisplayStatus,
3569 ATGEN_SetAutoNetworkLogin, 3761 ATGEN_SetAutoNetworkLogin,
3570 ATGEN_GetBatteryCharge, 3762 ATGEN_GetBatteryCharge,
3571 ATGEN_GetSignalQuality, 3763 ATGEN_GetSignalQuality,
3572 ATGEN_GetNetworkInfo, 3764 ATGEN_GetNetworkInfo,
3573 NOTSUPPORTED, /* GetCategory */ 3765 NOTSUPPORTED, /* GetCategory */
3574 NOTSUPPORTED, /* AddCategory */ 3766 NOTSUPPORTED, /* AddCategory */
@@ -3583,43 +3775,44 @@ GSM_Phone_Functions ATGENPhone = {
3583 NOTSUPPORTED, /* GetSpeedDial */ 3775 NOTSUPPORTED, /* GetSpeedDial */
3584 NOTSUPPORTED, /* SetSpeedDial */ 3776 NOTSUPPORTED, /* SetSpeedDial */
3585 ATGEN_GetSMSC, 3777 ATGEN_GetSMSC,
3586 ATGEN_SetSMSC, 3778 ATGEN_SetSMSC,
3587 ATGEN_GetSMSStatus, 3779 ATGEN_GetSMSStatus,
3588 ATGEN_GetSMS, 3780 ATGEN_GetSMS,
3589 ATGEN_GetNextSMS, 3781 ATGEN_GetNextSMS,
3590 NOTSUPPORTED, /* SetSMS */ 3782 NOTSUPPORTED, /* SetSMS */
3591 ATGEN_AddSMS, 3783 ATGEN_AddSMS,
3592 ATGEN_DeleteSMS, 3784 ATGEN_DeleteSMS,
3593 ATGEN_SendSMS, 3785 ATGEN_SendSMS,
3594 ATGEN_SendSavedSMS, 3786 ATGEN_SendSavedSMS,
3787 ATGEN_SetFastSMSSending,
3595 ATGEN_SetIncomingSMS, 3788 ATGEN_SetIncomingSMS,
3596 ATGEN_SetIncomingCB, 3789 ATGEN_SetIncomingCB,
3597 ATGEN_GetSMSFolders, 3790 ATGEN_GetSMSFolders,
3598 NOTSUPPORTED, /* AddSMSFolder */ 3791 NOTSUPPORTED, /* AddSMSFolder */
3599 NOTSUPPORTED, /* DeleteSMSFolder */ 3792 NOTSUPPORTED, /* DeleteSMSFolder */
3600 ATGEN_DialVoice, 3793 ATGEN_DialVoice,
3601 ATGEN_AnswerCall, 3794 ATGEN_AnswerCall,
3602 ATGEN_CancelCall, 3795 ATGEN_CancelCall,
3603 NOTSUPPORTED, /* HoldCall */ 3796 NOTSUPPORTED, /* HoldCall */
3604 NOTSUPPORTED, /* UnholdCall */ 3797 NOTSUPPORTED, /* UnholdCall */
3605 NOTSUPPORTED, /* ConferenceCall */ 3798 NOTSUPPORTED, /* ConferenceCall */
3606 NOTSUPPORTED, /* SplitCall */ 3799 NOTSUPPORTED, /* SplitCall */
3607 NOTSUPPORTED, /* TransferCall */ 3800 NOTSUPPORTED, /* TransferCall */
3608 NOTSUPPORTED, /* SwitchCall */ 3801 NOTSUPPORTED, /* SwitchCall */
3609 NOTSUPPORTED, /* GetCallDivert */ 3802 NOTSUPPORTED, /* GetCallDivert */
3610 NOTSUPPORTED, /* SetCallDivert */ 3803 NOTSUPPORTED, /* SetCallDivert */
3611 NOTSUPPORTED, /* CancelAllDiverts*/ 3804 NOTSUPPORTED, /* CancelAllDiverts*/
3612 NONEFUNCTION, /* SetIncomingCall */ 3805 NONEFUNCTION, /* SetIncomingCall */
3613 NOTSUPPORTED, /* SetIncomingUSSD */ 3806 ATGEN_SetIncomingUSSD,
3614 ATGEN_SendDTMF, 3807 ATGEN_SendDTMF,
3615 ATGEN_GetRingtone, 3808 ATGEN_GetRingtone,
3616 ATGEN_SetRingtone, 3809 ATGEN_SetRingtone,
3617 NOTSUPPORTED, /* GetRingtonesInfo*/ 3810 NOTSUPPORTED, /* GetRingtonesInfo*/
3618 NOTSUPPORTED, /* DeleteUserRingtones*/ 3811 NOTSUPPORTED, /* DeleteUserRingtones*/
3619 NOTSUPPORTED, /* PlayTone */ 3812 NOTSUPPORTED, /* PlayTone */
3620 NOTSUPPORTED, /* GetWAPBookmark */ 3813 NOTSUPPORTED, /* GetWAPBookmark */
3621 NOTSUPPORTED, /* SetWAPBookmark */ 3814 NOTSUPPORTED, /* SetWAPBookmark */
3622 NOTSUPPORTED, /* DeleteWAPBookmark */ 3815 NOTSUPPORTED, /* DeleteWAPBookmark */
3623 NOTSUPPORTED, /* GetWAPSettings */ 3816 NOTSUPPORTED, /* GetWAPSettings */
3624 NOTSUPPORTED, /* SetWAPSettings */ 3817 NOTSUPPORTED, /* SetWAPSettings */
3625 NOTSUPPORTED, /* GetMMSSettings */ 3818 NOTSUPPORTED, /* GetMMSSettings */
@@ -3637,25 +3830,25 @@ GSM_Phone_Functions ATGENPhone = {
3637 SONYERIC_AddToDo, 3830 SONYERIC_AddToDo,
3638 NOTSUPPORTED, /* DeleteToDo */ 3831 NOTSUPPORTED, /* DeleteToDo */
3639 SONYERIC_DeleteAllToDo, 3832 SONYERIC_DeleteAllToDo,
3640 SONYERIC_GetCalendarStatus, 3833 SONYERIC_GetCalendarStatus,
3641 NOTIMPLEMENTED, /* GetCalendar */ 3834 NOTIMPLEMENTED, /* GetCalendar */
3642 ATGEN_GetNextCalendar, 3835 ATGEN_GetNextCalendar,
3643 NOTIMPLEMENTED, /* SetCalendar */ 3836 NOTIMPLEMENTED, /* SetCalendar */
3644 ATGEN_AddCalendarNote, 3837 ATGEN_AddCalendarNote,
3645 ATGEN_DelCalendarNote, 3838 ATGEN_DelCalendarNote,
3646 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 3839 NOTIMPLEMENTED, /* DeleteAllCalendar*/
3647 NOTSUPPORTED, /* GetCalendarSettings*/ 3840 NOTSUPPORTED, /* GetCalendarSettings*/
3648 NOTSUPPORTED, /* SetCalendarSettings*/ 3841 NOTSUPPORTED, /* SetCalendarSettings*/
3649 NOTSUPPORTED, /* GetNote */ 3842 NOTSUPPORTED, /* GetNextNote */
3650 NOTSUPPORTED, /* GetProfile */ 3843 NOTSUPPORTED, /* GetProfile */
3651 NOTSUPPORTED, /* SetProfile */ 3844 NOTSUPPORTED, /* SetProfile */
3652 NOTSUPPORTED, /* GetFMStation */ 3845 NOTSUPPORTED, /* GetFMStation */
3653 NOTSUPPORTED, /* SetFMStation */ 3846 NOTSUPPORTED, /* SetFMStation */
3654 NOTSUPPORTED, /* ClearFMStations */ 3847 NOTSUPPORTED, /* ClearFMStations */
3655 NOTSUPPORTED, /* GetNextFileFolder*/ 3848 NOTSUPPORTED, /* GetNextFileFolder*/
3656 NOTSUPPORTED, /* GetFilePart */ 3849 NOTSUPPORTED, /* GetFilePart */
3657 NOTSUPPORTED, /* AddFile */ 3850 NOTSUPPORTED, /* AddFile */
3658 NOTSUPPORTED, /* GetFileSystemStatus*/ 3851 NOTSUPPORTED, /* GetFileSystemStatus*/
3659 NOTSUPPORTED, /* DeleteFile */ 3852 NOTSUPPORTED, /* DeleteFile */
3660 NOTSUPPORTED, /* AddFolder */ 3853 NOTSUPPORTED, /* AddFolder */
3661 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 3854 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -33,31 +33,33 @@ typedef enum {
33 AT_Reply_CMEError, 33 AT_Reply_CMEError,
34 AT_Reply_SMSEdit 34 AT_Reply_SMSEdit
35} GSM_AT_Reply_State; 35} GSM_AT_Reply_State;
36 36
37typedef enum { 37typedef enum {
38 AT_Nokia = 1, 38 AT_Nokia = 1,
39 AT_Alcatel, 39 AT_Alcatel,
40 AT_Siemens, 40 AT_Siemens,
41 AT_HP, 41 AT_HP,
42 AT_Falcom, 42 AT_Falcom,
43 AT_Ericsson, 43 AT_Ericsson,
44 AT_Sagem, 44 AT_Sagem,
45 AT_Samsung,
45 AT_Unknown 46 AT_Unknown
46} GSM_AT_Manufacturer; 47} GSM_AT_Manufacturer;
47 48
48typedef enum { 49typedef enum {
49 AT_PBK_HEX = 1, 50 AT_PBK_HEX = 1,
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;
53 55
54typedef enum { 56typedef enum {
55 AT_AVAILABLE = 1, 57 AT_AVAILABLE = 1,
56 AT_NOTAVAILABLE 58 AT_NOTAVAILABLE
57} GSM_AT_SMSMemory; 59} GSM_AT_SMSMemory;
58 60
59typedef enum { 61typedef enum {
60 AT_SBNR_AVAILABLE = 1, 62 AT_SBNR_AVAILABLE = 1,
61 AT_SBNR_NOTAVAILABLE 63 AT_SBNR_NOTAVAILABLE
62} GSM_AT_SBNR; 64} GSM_AT_SBNR;
63 65
@@ -94,17 +96,21 @@ typedef struct {
94 int LastSMSRead; 96 int LastSMSRead;
95 int FirstCalendarPos; 97 int FirstCalendarPos;
96 bool CanSaveSMS; 98 bool CanSaveSMS;
97 GSM_AT_SMSMemory PhoneSMSMemory; /* Is phone SMS memory available ? */ 99 GSM_AT_SMSMemory PhoneSMSMemory; /* Is phone SMS memory available ? */
98 GSM_AT_SMSMemory SIMSMSMemory; /* Is SIM SMS memory available ? */ 100 GSM_AT_SMSMemory SIMSMSMemory; /* Is SIM SMS memory available ? */
99 GSM_MemoryType SMSMemory; /* Last read SMS memory */ 101 GSM_MemoryType SMSMemory; /* Last read SMS memory */
100 GSM_AT_SMS_Modes SMSMode; /* PDU or TEXT mode for SMS ? */ 102 GSM_AT_SMS_Modes SMSMode; /* PDU or TEXT mode for SMS ? */
101 103
102 bool OBEX; 104 bool OBEX;
103 GSM_File file; 105 GSM_File file;
104} GSM_Phone_ATGENData; 106} GSM_Phone_ATGENData;
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
107 113
108/* How should editor hadle tabs in this file? Add editor commands here. 114/* How should editor hadle tabs in this file? Add editor commands here.
109 * vim: noexpandtab sw=8 ts=8 sts=8: 115 * vim: noexpandtab sw=8 ts=8 sts=8:
110 */ 116 */
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
@@ -4,43 +4,29 @@
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../misc/coding/coding.h" 11#include "../../misc/coding/coding.h"
12#include "../../gsmcomon.h" 12#include "../../gsmcomon.h"
13#include "../../service/sms/gsmsms.h" 13#include "../../service/sms/gsmsms.h"
14#include "../pfunc.h" 14#include "../pfunc.h"
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)
36{ 22{
37 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 23 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
38 int i=2, pos=0, length=0; 24 int i=2, pos=0, length=0;
39 unsigned char buf[512]; 25 unsigned char buf[512];
40 26
41 if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY; 27 if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY;
42 if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN; 28 if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN;
43 29
44 while (1) { 30 while (1) {
45 if (Priv->Lines.numbers[i*2+1]==0) break; 31 if (Priv->Lines.numbers[i*2+1]==0) break;
46 if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) && 32 if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) &&
@@ -48,25 +34,25 @@ GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *t
48 length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1)); 34 length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1));
49 DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length); 35 DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length);
50 length = length/2; 36 length = length/2;
51 memcpy (buffer+pos,buf,length); 37 memcpy (buffer+pos,buf,length);
52 pos+=length; 38 pos+=length;
53 } 39 }
54 i++; 40 i++;
55 } 41 }
56 *len = pos; 42 *len = pos;
57 return ERR_NONE; 43 return ERR_NONE;
58} 44}
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)
62{ 48{
63 GSM_Phone_Data *Phone = &s->Phone.Data; 49 GSM_Phone_Data *Phone = &s->Phone.Data;
64 GSM_Error error; 50 GSM_Error error;
65 unsigned char req[20],req1[512],hexreq[2096]; 51 unsigned char req[20],req1[512],hexreq[2096];
66 int MaxFrame,CurrentFrame,size,sz,pos=0; 52 int MaxFrame,CurrentFrame,size,sz,pos=0;
67 53
68 EncodeHexBin(hexreq,buff,len); 54 EncodeHexBin(hexreq,buff,len);
69 size = len * 2; 55 size = len * 2;
70 MaxFrame = size / 352; 56 MaxFrame = size / 352;
71 if (size % 352) MaxFrame++; 57 if (size % 352) MaxFrame++;
72 58
@@ -81,125 +67,135 @@ GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ
81 if (error!=ERR_NONE) return error; 67 if (error!=ERR_NONE) return error;
82 memcpy (req1,hexreq+pos,sz); 68 memcpy (req1,hexreq+pos,sz);
83 error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00); 69 error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00);
84 if (error!=ERR_NONE) return error; 70 if (error!=ERR_NONE) return error;
85 error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00); 71 error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00);
86 if (error!=ERR_NONE) return error; 72 if (error!=ERR_NONE) return error;
87 error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); 73 error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4);
88 if (error == ERR_TIMEOUT) return error; 74 if (error == ERR_TIMEOUT) return error;
89 } 75 }
90 return Phone->DispatchError; 76 return Phone->DispatchError;
91} 77}
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{
95 unsigned char buffer[4096]; 81 unsigned char buffer[4096];
96 int length; 82 int length;
97 GSM_Error error; 83 GSM_Error error;
98 84
99 error = GetSiemensFrame(msg,s,"bmp",buffer,&length); 85 error = GetSiemensFrame(msg,s,"bmp",buffer,&length);
100 if (error!=ERR_NONE) return error; 86 if (error!=ERR_NONE) return error;
101 dbgprintf ("Operator logo received lenght=%i\n",length); 87 dbgprintf ("Operator logo received lenght=%i\n",length);
102 error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap); 88 error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap);
103 if (error==ERR_NONE) return error; 89 if (error==ERR_NONE) return error;
104 else return ERR_UNKNOWN; 90 else return ERR_UNKNOWN;
105} 91}
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{
114 unsigned char req[32]; 116 unsigned char req[32];
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;
118 if (Bitmap->Location-1 < 0) Bitmap->Location++; 119 if (Bitmap->Location-1 < 0) Bitmap->Location++;
119 s->Phone.Data.Bitmap=Bitmap; 120 s->Phone.Data.Bitmap=Bitmap;
120 sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1); 121 sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1);
121 smprintf(s, "Getting Bitmap\n"); 122 smprintf(s, "Getting Bitmap\n");
122 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap); 123 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
123} 124}
124 125
125GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 126GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
126{ 127{
127 unsigned char buffer[4096]; 128 unsigned char buffer[4096];
128 int length; 129 int length;
129 GSM_Errorerror; 130 GSM_Errorerror;
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;
133 133
134 error = Bitmap2BMP (buffer,NULL,Bitmap); 134 error = Bitmap2BMP (buffer,NULL,Bitmap);
135 if (error!=ERR_NONE) return error; 135 if (error!=ERR_NONE) return error;
136 length = 0x100 * buffer[3] + buffer[2]; 136 length = 0x100 * buffer[3] + buffer[2];
137 buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff; 137 buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff;
138 if (Bitmap->Location-1 < 0) Bitmap->Location++; 138 if (Bitmap->Location-1 < 0) Bitmap->Location++;
139 s->Phone.Data.Bitmap=Bitmap; 139 s->Phone.Data.Bitmap=Bitmap;
140 return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1, 140 return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1,
141 ID_SetBitmap,length); 141 ID_SetBitmap,length);
142} 142}
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{
146 unsigned char buffer[32]; 146 unsigned char buffer[32];
147 int length; 147 int length;
148 GSM_Error error; 148 GSM_Error error;
149 149
150 error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length); 150 error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length);
151 if (error!=ERR_NONE) return error; 151 if (error!=ERR_NONE) return error;
152 dbgprintf ("Midi ringtone received\n"); 152 dbgprintf ("Midi ringtone received\n");
153 153
154 s->Phone.Data.Ringtone->Format = RING_MIDI; 154 s->Phone.Data.Ringtone->Format = RING_MIDI;
155 s->Phone.Data.Ringtone->NokiaBinary.Length= length; 155 s->Phone.Data.Ringtone->NokiaBinary.Length= length;
156 sprintf(buffer,"Individual"); 156 sprintf(buffer,"Individual");
157 EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer)); 157 EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
158 return ERR_NONE; 158 return ERR_NONE;
159} 159}
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{
163 unsigned char req[32]; 163 unsigned char req[32];
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;
168 sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1); 166 sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1);
169 smprintf(s, "Getting RingTone\n"); 167 smprintf(s, "Getting RingTone\n");
170 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone); 168 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
171} 169}
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{
180 GSM_Phone_Data *Phone = &s->Phone.Data; 178 GSM_Phone_Data *Phone = &s->Phone.Data;
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;
185 if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION; 181 if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION;
186 182
187 s->Phone.Data.Ringtone= Ringtone; 183 s->Phone.Data.Ringtone= Ringtone;
188 Phone->Ringtone = Ringtone; 184 Phone->Ringtone = Ringtone;
189 return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1, 185 return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1,
190 ID_SetRingtone,Ringtone->NokiaBinary.Length); 186 ID_SetRingtone,Ringtone->NokiaBinary.Length);
191} 187}
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{
195 GSM_Phone_Data *Data = &s->Phone.Data; 191 GSM_Phone_Data *Data = &s->Phone.Data;
196 GSM_CalendarEntry*Calendar = Data->Cal; 192 GSM_CalendarEntry*Calendar = Data->Cal;
197 GSM_ToDoEntry ToDo; 193 GSM_ToDoEntry ToDo;
198 GSM_Error error; 194 GSM_Error error;
199 unsigned char buffer[354]; 195 unsigned char buffer[354];
200 int len, pos=0; 196 int len, pos=0;
201 197
202 if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN; 198 if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN;
203 199
204 error = GetSiemensFrame(msg,s,"vcs",buffer,&len); 200 error = GetSiemensFrame(msg,s,"vcs",buffer,&len);
205 if (error!=ERR_NONE) return error; 201 if (error!=ERR_NONE) return error;
@@ -226,30 +222,30 @@ GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
226 Location++; 222 Location++;
227 sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location); 223 sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location);
228 error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote); 224 error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote);
229 if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION; 225 if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION;
230 Note->Location = Location; 226 Note->Location = Location;
231 Priv->FirstCalendarPos = Location; 227 Priv->FirstCalendarPos = Location;
232 if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY; 228 if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY;
233 if (error==ERR_NONE) return error; 229 if (error==ERR_NONE) return error;
234 } 230 }
235 return error; 231 return error;
236} 232}
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{
245 GSM_Phone_Data *Data = &s->Phone.Data; 241 GSM_Phone_Data *Data = &s->Phone.Data;
246 242
247 if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN; 243 if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN;
248 244
249 if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) { 245 if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) {
250 smprintf(s, "Calendar note deleted\n"); 246 smprintf(s, "Calendar note deleted\n");
251 return ERR_NONE; 247 return ERR_NONE;
252 } else { 248 } else {
253 smprintf(s, "Can't delete calendar note\n"); 249 smprintf(s, "Can't delete calendar note\n");
254 return ERR_UNKNOWN; 250 return ERR_UNKNOWN;
255 } 251 }
@@ -274,25 +270,25 @@ GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
274 int size=0; 270 int size=0;
275 271
276 if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; 272 if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
277 // if (Note->Location==0x00) return ERR_INVALIDLOCATION; 273 // if (Note->Location==0x00) return ERR_INVALIDLOCATION;
278 274
279 s->Phone.Data.Cal = Note; 275 s->Phone.Data.Cal = Note;
280 error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar); 276 error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar);
281 277
282 return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size); 278 return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size);
283} 279}
284 280
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{
288#ifndef ENABLE_LGPL 284#ifndef ENABLE_LGPL
289 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; 285 GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
290 GSM_MemoryEntry *Memory = s->Phone.Data.Memory; 286 GSM_MemoryEntry *Memory = s->Phone.Data.Memory;
291 unsigned char buffer[500],buffer2[500]; 287 unsigned char buffer[500],buffer2[500];
292 288
293 switch (Priv->ReplyState) { 289 switch (Priv->ReplyState) {
294 case AT_Reply_OK: 290 case AT_Reply_OK:
295 smprintf(s, "Phonebook entry received\n"); 291 smprintf(s, "Phonebook entry received\n");
296 CopyLineString(buffer, msg.Buffer, Priv->Lines, 3); 292 CopyLineString(buffer, msg.Buffer, Priv->Lines, 3);
297 DecodeHexBin(buffer2,buffer,strlen(buffer)); 293 DecodeHexBin(buffer2,buffer,strlen(buffer));
298 Memory->EntriesNum = 0; 294 Memory->EntriesNum = 0;
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
@@ -2,35 +2,33 @@
2 2
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13 13
14 extern GSM_Reply_Function ATGENReplyFunctions[]; 14#include "atgen.h"
15 extern GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s); 15#include "sonyeric.h"
16 16
17#ifdef GSM_ENABLE_OBEXGEN 17#ifdef GSM_ENABLE_OBEXGEN
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
26static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s) 24static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
27{ 25{
28 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 26 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
29 GSM_Error error; 27 GSM_Error error;
30 28
31 if (Priv->OBEX) return ERR_NONE; 29 if (Priv->OBEX) return ERR_NONE;
32 30
33 dbgprintf ("Changing to OBEX\n"); 31 dbgprintf ("Changing to OBEX\n");
34 32
35 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX); 33 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX);
36 if (error != ERR_NONE) return error; 34 if (error != ERR_NONE) return error;
@@ -117,25 +115,25 @@ static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName,
117 error = ERR_NONE; 115 error = ERR_NONE;
118 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos); 116 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos);
119 free(File.Buffer); 117 free(File.Buffer);
120 if (error != ERR_EMPTY) return error; 118 if (error != ERR_EMPTY) return error;
121 119
122 return SONYERIC_SetATMode(s); 120 return SONYERIC_SetATMode(s);
123} 121}
124 122
125#endif 123#endif
126 124
127GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 125GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
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;
131 GSM_ToDoEntry ToDo; 129 GSM_ToDoEntry ToDo;
132 int Pos, num, Loc; 130 int Pos, num, Loc;
133 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 131 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
134 132
135 if (start) { 133 if (start) {
136 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 134 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
137 if (error != ERR_NONE) return error; 135 if (error != ERR_NONE) return error;
138 136
139 Note->Location = 1; 137 Note->Location = 1;
140 } else { 138 } else {
141 Note->Location++; 139 Note->Location++;
@@ -153,25 +151,25 @@ GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note,
153 num++; 151 num++;
154 if (num == Loc) return ERR_NONE; 152 if (num == Loc) return ERR_NONE;
155 } 153 }
156 } 154 }
157 return ERR_EMPTY; 155 return ERR_EMPTY;
158#else 156#else
159 return ERR_SOURCENOTAVAILABLE; 157 return ERR_SOURCENOTAVAILABLE;
160#endif 158#endif
161} 159}
162 160
163GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 161GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
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;
167 GSM_CalendarEntryCalendar; 165 GSM_CalendarEntryCalendar;
168 int Pos, num, Loc; 166 int Pos, num, Loc;
169 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 167 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
170 168
171 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 169 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
172 170
173 if (start) { 171 if (start) {
174 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 172 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
175 if (error != ERR_NONE) return error; 173 if (error != ERR_NONE) return error;
176 174
177 ToDo->Location = 1; 175 ToDo->Location = 1;
@@ -192,25 +190,25 @@ GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool st
192 if (num == Loc) return ERR_NONE; 190 if (num == Loc) return ERR_NONE;
193 } 191 }
194 } 192 }
195 193
196 return ERR_EMPTY; 194 return ERR_EMPTY;
197#else 195#else
198 return ERR_SOURCENOTAVAILABLE; 196 return ERR_SOURCENOTAVAILABLE;
199#endif 197#endif
200} 198}
201 199
202GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 200GSM_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;
206 GSM_ToDoEntry ToDo; 204 GSM_ToDoEntry ToDo;
207 GSM_CalendarEntry Calendar; 205 GSM_CalendarEntry Calendar;
208 int Pos; 206 int Pos;
209 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 207 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
210 208
211 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 209 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
212 210
213 smprintf(s,"Getting ToDo status\n"); 211 smprintf(s,"Getting ToDo status\n");
214 212
215 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 213 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
216 if (error != ERR_NONE) return error; 214 if (error != ERR_NONE) return error;
@@ -223,60 +221,60 @@ GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
223 if (error != ERR_NONE) return error; 221 if (error != ERR_NONE) return error;
224 if (ToDo.EntriesNum != 0) status->Used++; 222 if (ToDo.EntriesNum != 0) status->Used++;
225 } 223 }
226 224
227 return ERR_NONE; 225 return ERR_NONE;
228#else 226#else
229 return ERR_SOURCENOTAVAILABLE; 227 return ERR_SOURCENOTAVAILABLE;
230#endif 228#endif
231} 229}
232 230
233GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 231GSM_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];
237 int size=0; 235 int size=0;
238 236
239 smprintf(s,"Adding calendar note\n"); 237 smprintf(s,"Adding calendar note\n");
240 238
241 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar); 239 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar);
242 240
243 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 241 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
244#else 242#else
245 return ERR_SOURCENOTAVAILABLE; 243 return ERR_SOURCENOTAVAILABLE;
246#endif 244#endif
247} 245}
248 246
249GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 247GSM_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;
253 unsigned char req[5000]; 251 unsigned char req[5000];
254 int size=0; 252 int size=0;
255 253
256 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 254 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
257 255
258 smprintf(s,"Adding ToDo\n"); 256 smprintf(s,"Adding ToDo\n");
259 257
260 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo); 258 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo);
261 259
262 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 260 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
263#else 261#else
264 return ERR_SOURCENOTAVAILABLE; 262 return ERR_SOURCENOTAVAILABLE;
265#endif 263#endif
266} 264}
267 265
268GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) 266GSM_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;
272 int Pos,Level = 0,Used; 270 int Pos,Level = 0,Used;
273 unsigned char *Buf; 271 unsigned char *Buf;
274 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 272 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
275 unsigned char Line[2000]; 273 unsigned char Line[2000];
276 274
277 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 275 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
278 276
279 smprintf(s,"Deleting all ToDo\n"); 277 smprintf(s,"Deleting all ToDo\n");
280 278
281 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 279 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
282 if (error != ERR_NONE) return error; 280 if (error != ERR_NONE) return error;
@@ -310,25 +308,25 @@ GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
310 } 308 }
311 309
312 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 310 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
313 //if (Buf != NULL) free(Buf); 311 //if (Buf != NULL) free(Buf);
314 return error; 312 return error;
315#else 313#else
316 return ERR_SOURCENOTAVAILABLE; 314 return ERR_SOURCENOTAVAILABLE;
317#endif 315#endif
318} 316}
319 317
320GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 318GSM_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;
324 int Pos,Level = 0,Loc=0,Used; 322 int Pos,Level = 0,Loc=0,Used;
325 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 323 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
326 unsigned char Line[2000]; 324 unsigned char Line[2000];
327 unsigned char *Buf; 325 unsigned char *Buf;
328 326
329 smprintf(s, "Deleting calendar note %i\n",Note->Location); 327 smprintf(s, "Deleting calendar note %i\n",Note->Location);
330 328
331 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 329 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
332 if (error != ERR_NONE) return error; 330 if (error != ERR_NONE) return error;
333 331
334 Pos = 0; 332 Pos = 0;
@@ -365,25 +363,25 @@ GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
365 DumpMessage(s->di.df, s->di.dl, Buf, Used); 363 DumpMessage(s->di.df, s->di.dl, Buf, Used);
366 364
367 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 365 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
368 if (Buf != NULL) free(Buf); 366 if (Buf != NULL) free(Buf);
369 return error; 367 return error;
370#else 368#else
371 return ERR_SOURCENOTAVAILABLE; 369 return ERR_SOURCENOTAVAILABLE;
372#endif 370#endif
373} 371}
374 372
375GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 373GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
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;
379 GSM_ToDoEntry ToDo; 377 GSM_ToDoEntry ToDo;
380 GSM_CalendarEntry Calendar; 378 GSM_CalendarEntry Calendar;
381 int Pos; 379 int Pos;
382 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 380 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
383 381
384 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 382 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
385 383
386 smprintf(s, "Getting calendar status\n"); 384 smprintf(s, "Getting calendar status\n");
387 385
388 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 386 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
389 if (error != ERR_NONE) return error; 387 if (error != ERR_NONE) return error;
@@ -394,18 +392,129 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St
394 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 392 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
395 if (error == ERR_EMPTY) break; 393 if (error == ERR_EMPTY) break;
396 if (error != ERR_NONE) return error; 394 if (error != ERR_NONE) return error;
397 if (Calendar.EntriesNum != 0) Status->Used++; 395 if (Calendar.EntriesNum != 0) Status->Used++;
398 } 396 }
399 397
400 return ERR_NONE; 398 return ERR_NONE;
401#else 399#else
402 return ERR_SOURCENOTAVAILABLE; 400 return ERR_SOURCENOTAVAILABLE;
403#endif 401#endif
404} 402}
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
408 517
409/* How should editor hadle tabs in this file? Add editor commands here. 518/* How should editor hadle tabs in this file? Add editor commands here.
410 * vim: noexpandtab sw=8 ts=8 sts=8: 519 * vim: noexpandtab sw=8 ts=8 sts=8:
411 */ 520 */
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,15 +1,18 @@
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
5#include <string.h> /* memcpy only */ 8#include <string.h> /* memcpy only */
6#include <stdio.h> 9#include <stdio.h>
7#include <ctype.h> 10#include <ctype.h>
8 11
9#include "../../../gsmstate.h" 12#include "../../../gsmstate.h"
10#include "../../../misc/coding/coding.h" 13#include "../../../misc/coding/coding.h"
11#include "../../../service/sms/gsmsms.h" 14#include "../../../service/sms/gsmsms.h"
12#include "../../pfunc.h" 15#include "../../pfunc.h"
13#include "../nfunc.h" 16#include "../nfunc.h"
14#include "dct3func.h" 17#include "dct3func.h"
15 18
@@ -385,24 +388,25 @@ GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
385 switch (msg.Buffer[3]) { 388 switch (msg.Buffer[3]) {
386 case 0x34: 389 case 0x34:
387 smprintf(s, "SMSC received\n"); 390 smprintf(s, "SMSC received\n");
388 Data->SMSC->Format = SMS_FORMAT_Text; 391 Data->SMSC->Format = SMS_FORMAT_Text;
389 switch (msg.Buffer[6]) { 392 switch (msg.Buffer[6]) {
390 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; 393 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
391 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; 394 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
392 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; 395 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break;
393 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; 396 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break;
394 } 397 }
395 Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; 398 Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat;
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
398 i=33; 402 i=33;
399 while (msg.Buffer[i]!=0) {i++;} 403 while (msg.Buffer[i]!=0) {i++;}
400 i=i-33; 404 i=i-33;
401 if (i>GSM_MAX_SMSC_NAME_LENGTH) { 405 if (i>GSM_MAX_SMSC_NAME_LENGTH) {
402 smprintf(s, "Too long name\n"); 406 smprintf(s, "Too long name\n");
403 return ERR_UNKNOWNRESPONSE; 407 return ERR_UNKNOWNRESPONSE;
404 } 408 }
405 EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i); 409 EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i);
406 smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); 410 smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
407 411
408 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true); 412 GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true);
@@ -433,43 +437,43 @@ GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
433 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); 437 return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC);
434} 438}
435 439
436GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 440GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
437{ 441{
438 int count; 442 int count;
439 GSM_Phone_Data*Data = &s->Phone.Data; 443 GSM_Phone_Data*Data = &s->Phone.Data;
440#ifdef DEBUG 444#ifdef DEBUG
441 GSM_NetworkInfo NetInfo; 445 GSM_NetworkInfo NetInfo;
442 char name[100]; 446 char name[100];
443 447
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]) {
447 case 0x01: smprintf(s, "home network"); break; 451 case 0x01: smprintf(s, "home network"); break;
448 case 0x02: smprintf(s, "roaming network"); break; 452 case 0x02: smprintf(s, "roaming network"); break;
449 case 0x03: smprintf(s, "requesting network"); break; 453 case 0x03: smprintf(s, "requesting network"); break;
450 case 0x04: smprintf(s, "not registered in the network");break; 454 case 0x04: smprintf(s, "not registered in the network");break;
451 default : smprintf(s, "unknown"); 455 default : smprintf(s, "unknown");
452 } 456 }
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) {
456 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); 460 sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]);
457 smprintf(s, "CID : %s\n", NetInfo.CID); 461 smprintf(s, "CID : %s\n", NetInfo.CID);
458 462
459 sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); 463 sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]);
460 smprintf(s, "LAC : %s\n", NetInfo.LAC); 464 smprintf(s, "LAC : %s\n", NetInfo.LAC);
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 ",
465 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); 469 DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
466 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); 470 smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
467 471
468 if (msg.Length>18) { 472 if (msg.Length>18) {
469 if (msg.Buffer[18]==0x00) { 473 if (msg.Buffer[18]==0x00) {
470 /* In 6210 name is in "normal" Unicode */ 474 /* In 6210 name is in "normal" Unicode */
471 memcpy(name,msg.Buffer+18,msg.Buffer[17]*2); 475 memcpy(name,msg.Buffer+18,msg.Buffer[17]*2);
472 name[msg.Buffer[17]*2]=0x00; 476 name[msg.Buffer[17]*2]=0x00;
473 name[msg.Buffer[17]*2+1]=0x00; 477 name[msg.Buffer[17]*2+1]=0x00;
474 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); 478 smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
475 } else { 479 } else {
@@ -1199,29 +1203,29 @@ GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *setting
1199 } 1203 }
1200 error = DCT3DCT4_SetActiveConnectSet(s, settings); 1204 error = DCT3DCT4_SetActiveConnectSet(s, settings);
1201 if (error != ERR_NONE) return error; 1205 if (error != ERR_NONE) return error;
1202 1206
1203 return DCT3DCT4_DisableConnectionFunctions(s); 1207 return DCT3DCT4_DisableConnectionFunctions(s);
1204} 1208}
1205 1209
1206GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 1210GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
1207{ 1211{
1208 switch (msg.Buffer[3]) { 1212 switch (msg.Buffer[3]) {
1209 case 0x02: 1213 case 0x02:
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;
1213 case 0x03: 1217 case 0x03:
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;
1217 } 1221 }
1218 return ERR_UNKNOWNRESPONSE; 1222 return ERR_UNKNOWNRESPONSE;
1219} 1223}
1220 1224
1221GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 1225GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
1222{ 1226{
1223 int length; 1227 int length;
1224 GSM_Error error; 1228 GSM_Error error;
1225 unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00}; 1229 unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00};
1226 1230
1227 error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true); 1231 error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true);
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
@@ -1,17 +1,19 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2 2
3#ifndef phone_nokia_dct3_h 3#ifndef phone_nokia_dct3_h
4#define phone_nokia_dct3_h 4#define phone_nokia_dct3_h
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);
7 GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s); 9 GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s);
8 GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s); 10 GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg, GSM_StateMachine *s);
9 GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s); 11 GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s);
10 GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s); 12 GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
11 GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s); 13 GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s);
12 GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s); 14 GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s);
13 GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s); 15 GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
14 GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s); 16 GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
15 GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s); 17 GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
16 GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s); 18 GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
17 GSM_Error DCT3_ReplyDialCommand (GSM_Protocol_Message msg, GSM_StateMachine *s); 19 GSM_Error DCT3_ReplyDialCommand (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,16 +1,18 @@
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
6#include "../../../gsmstate.h" 8#include "../../../gsmstate.h"
7 9
8#ifdef GSM_ENABLE_NOKIA6110 10#ifdef GSM_ENABLE_NOKIA6110
9 11
10#include <string.h> 12#include <string.h>
11 13
12#include "../../../../cfg/config.h" 14#include "../../../../cfg/config.h"
13#include "../../../misc/coding/coding.h" 15#include "../../../misc/coding/coding.h"
14#include "../../../service/sms/gsmsms.h" 16#include "../../../service/sms/gsmsms.h"
15#include "../../../gsmcomon.h" 17#include "../../../gsmcomon.h"
16#include "../../pfunc.h" 18#include "../../pfunc.h"
@@ -118,24 +120,25 @@ static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const
118 if (!found) { 120 if (!found) {
119 i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc); 121 i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc);
120 dest[o_len*2] = (wc >> 8) & 0xff; 122 dest[o_len*2] = (wc >> 8) & 0xff;
121 dest[(o_len*2)+1] = wc & 0xff; 123 dest[(o_len*2)+1] = wc & 0xff;
122 } 124 }
123 } 125 }
124 dest[o_len*2] = 0; 126 dest[o_len*2] = 0;
125 dest[(o_len*2)+1] = 0; 127 dest[(o_len*2)+1] = 0;
126} 128}
127 129
128#ifndef ENABLE_LGPL 130#ifndef ENABLE_LGPL
129 131
132/* Pavel Janik */
130/* This function provides Nokia authentication protocol. 133/* This function provides Nokia authentication protocol.
131 * Nokia authentication protocol is used in the communication between Nokia 134 * Nokia authentication protocol is used in the communication between Nokia
132 * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software, 135 * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
133 * commercially sold by Nokia Corp. 136 * commercially sold by Nokia Corp.
134 * The authentication scheme is based on the token send by the phone to the 137 * The authentication scheme is based on the token send by the phone to the
135 * software. The software does it's magic (see the function 138 * software. The software does it's magic (see the function
136 * N6110_GetNokiaAuthentication) and returns the result back to the phone. 139 * N6110_GetNokiaAuthentication) and returns the result back to the phone.
137 * If the result is correct the phone responds with the message "Accessory 140 * If the result is correct the phone responds with the message "Accessory
138 * connected!" displayed on the LCD. Otherwise it will display "Accessory not 141 * connected!" displayed on the LCD. Otherwise it will display "Accessory not
139 * supported" and some functions will not be available for use (?). 142 * supported" and some functions will not be available for use (?).
140 * The specification of the protocol is not publicly available, no comment. 143 * The specification of the protocol is not publicly available, no comment.
141 */ 144 */
@@ -815,24 +818,25 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
815 memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name)); 818 memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name));
816 current += UnicodeLength(Ringtone->Name); 819 current += UnicodeLength(Ringtone->Name);
817 reqBin[current++] = 0x00; 820 reqBin[current++] = 0x00;
818 reqBin[current++] = 0x00; 821 reqBin[current++] = 0x00;
819 reqBin[current++] = 0x00;/*xxx*/ 822 reqBin[current++] = 0x00;/*xxx*/
820 memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); 823 memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
821 current=current+Ringtone->NokiaBinary.Length; 824 current=current+Ringtone->NokiaBinary.Length;
822 reqBin[3]=Ringtone->Location-1; 825 reqBin[3]=Ringtone->Location-1;
823 if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10; 826 if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10;
824 smprintf(s, "Setting binary ringtone\n"); 827 smprintf(s, "Setting binary ringtone\n");
825 return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone); 828 return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone);
826 case RING_MIDI: 829 case RING_MIDI:
830 case RING_MMF:
827 return ERR_NOTSUPPORTED; 831 return ERR_NOTSUPPORTED;
828 } 832 }
829 return ERR_NOTSUPPORTED; 833 return ERR_NOTSUPPORTED;
830} 834}
831 835
832static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 836static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
833{ 837{
834 int count=5; 838 int count=5;
835 GSM_Phone_Data *Data = &s->Phone.Data; 839 GSM_Phone_Data *Data = &s->Phone.Data;
836 840
837 smprintf(s, "Operator logo received\n"); 841 smprintf(s, "Operator logo received\n");
838 NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode); 842 NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode);
@@ -1515,24 +1519,25 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
1515 } 1519 }
1516 i++; 1520 i++;
1517 if (i==msg.Length-3) return ERR_EMPTY; 1521 if (i==msg.Length-3) return ERR_EMPTY;
1518 } 1522 }
1519 /* Copying frame */ 1523 /* Copying frame */
1520 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start); 1524 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start);
1521 Data->Ringtone->NokiaBinary.Length=end-start; 1525 Data->Ringtone->NokiaBinary.Length=end-start;
1522#ifdef DEBUG 1526#ifdef DEBUG
1523 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length); 1527 if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length);
1524#endif 1528#endif
1525 return ERR_NONE; 1529 return ERR_NONE;
1526 case RING_MIDI: 1530 case RING_MIDI:
1531 case RING_MMF:
1527 return ERR_NOTSUPPORTED; 1532 return ERR_NOTSUPPORTED;
1528 } 1533 }
1529 smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format); 1534 smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format);
1530 break; 1535 break;
1531 default: 1536 default:
1532 smprintf(s, "Invalid location. Too high ?\n"); 1537 smprintf(s, "Invalid location. Too high ?\n");
1533 return ERR_INVALIDLOCATION; 1538 return ERR_INVALIDLOCATION;
1534 } 1539 }
1535 return ERR_UNKNOWNRESPONSE; 1540 return ERR_UNKNOWNRESPONSE;
1536} 1541}
1537 1542
1538static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) 1543static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
@@ -1552,24 +1557,25 @@ static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
1552 Ringtone->Format = RING_NOKIABINARY; 1557 Ringtone->Format = RING_NOKIABINARY;
1553 } 1558 }
1554 } 1559 }
1555 1560
1556 switch (Ringtone->Format) { 1561 switch (Ringtone->Format) {
1557 case RING_NOTETONE: 1562 case RING_NOTETONE:
1558 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; 1563 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
1559 break; 1564 break;
1560 case RING_NOKIABINARY: 1565 case RING_NOKIABINARY:
1561 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; 1566 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
1562 break; 1567 break;
1563 case RING_MIDI: 1568 case RING_MIDI:
1569 case RING_MMF:
1564 return ERR_NOTSUPPORTED; 1570 return ERR_NOTSUPPORTED;
1565 } 1571 }
1566 1572
1567 error=DCT3_EnableSecurity (s, 0x01); 1573 error=DCT3_EnableSecurity (s, 0x01);
1568 if (error!=ERR_NONE) return error; 1574 if (error!=ERR_NONE) return error;
1569 1575
1570 req[3]=Ringtone->Location-1; 1576 req[3]=Ringtone->Location-1;
1571 s->Phone.Data.Ringtone=Ringtone; 1577 s->Phone.Data.Ringtone=Ringtone;
1572 smprintf(s, "Getting (binary) ringtone\n"); 1578 smprintf(s, "Getting (binary) ringtone\n");
1573 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone); 1579 return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone);
1574} 1580}
1575 1581
@@ -2434,26 +2440,26 @@ static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntr
2434 if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) { 2440 if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) {
2435 error=N6110_GetDateTime(s, &date_time); 2441 error=N6110_GetDateTime(s, &date_time);
2436 if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year; 2442 if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year;
2437 } 2443 }
2438 return error; 2444 return error;
2439} 2445}
2440 2446
2441GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 2447GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
2442{ 2448{
2443 unsigned char buffer[2000],buffer2[4000]; 2449 unsigned char buffer[2000],buffer2[4000];
2444 int tmp; 2450 int tmp;
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
2449 smprintf(s, "USSD reply: \"%s\"\n",buffer); 2455 smprintf(s, "USSD reply: \"%s\"\n",buffer);
2450 2456
2451 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) { 2457 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
2452 EncodeUnicode(buffer2,buffer,strlen(buffer)); 2458 EncodeUnicode(buffer2,buffer,strlen(buffer));
2453 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2); 2459 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
2454 } 2460 }
2455 2461
2456 return ERR_NONE; 2462 return ERR_NONE;
2457} 2463}
2458 2464
2459GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all) 2465GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
@@ -2798,24 +2804,25 @@ GSM_Phone_Functions N6110Phone = {
2798 N6110_GetSpeedDial, 2804 N6110_GetSpeedDial,
2799 NOTIMPLEMENTED, /* SetSpeedDial */ 2805 NOTIMPLEMENTED, /* SetSpeedDial */
2800 DCT3_GetSMSC, 2806 DCT3_GetSMSC,
2801 DCT3_SetSMSC, 2807 DCT3_SetSMSC,
2802 DCT3_GetSMSStatus, 2808 DCT3_GetSMSStatus,
2803 N6110_GetSMSMessage, 2809 N6110_GetSMSMessage,
2804 N6110_GetNextSMSMessage, 2810 N6110_GetNextSMSMessage,
2805 N6110_SetSMS, 2811 N6110_SetSMS,
2806 N6110_AddSMS, 2812 N6110_AddSMS,
2807 N6110_DeleteSMSMessage, 2813 N6110_DeleteSMSMessage,
2808 DCT3_SendSMSMessage, 2814 DCT3_SendSMSMessage,
2809 NOTSUPPORTED, /* SendSavedSMS */ 2815 NOTSUPPORTED, /* SendSavedSMS */
2816 NOTSUPPORTED, /* SetFastSMSSending*/
2810 NOKIA_SetIncomingSMS, 2817 NOKIA_SetIncomingSMS,
2811 DCT3_SetIncomingCB, 2818 DCT3_SetIncomingCB,
2812 PHONE_GetSMSFolders, 2819 PHONE_GetSMSFolders,
2813 NOTSUPPORTED, /* AddSMSFolder */ 2820 NOTSUPPORTED, /* AddSMSFolder */
2814 NOTSUPPORTED, /* DeleteSMSFolder */ 2821 NOTSUPPORTED, /* DeleteSMSFolder */
2815 N6110_DialVoice, 2822 N6110_DialVoice,
2816 N6110_AnswerCall, 2823 N6110_AnswerCall,
2817 DCT3_CancelCall, 2824 DCT3_CancelCall,
2818 N6110_HoldCall, 2825 N6110_HoldCall,
2819 N6110_UnholdCall, 2826 N6110_UnholdCall,
2820 N6110_ConferenceCall, 2827 N6110_ConferenceCall,
2821 N6110_SplitCall, 2828 N6110_SplitCall,
@@ -2852,25 +2859,25 @@ GSM_Phone_Functions N6110Phone = {
2852 NOTSUPPORTED, /* AddToDo */ 2859 NOTSUPPORTED, /* AddToDo */
2853 NOTSUPPORTED, /* DeleteToDo */ 2860 NOTSUPPORTED, /* DeleteToDo */
2854 NOTSUPPORTED, /* DeleteAllToDo */ 2861 NOTSUPPORTED, /* DeleteAllToDo */
2855 NOTIMPLEMENTED, /* GetCalendarStatus */ 2862 NOTIMPLEMENTED, /* GetCalendarStatus */
2856 NOTIMPLEMENTED, /* GetCalendar */ 2863 NOTIMPLEMENTED, /* GetCalendar */
2857 N6110_GetNextCalendarNote, 2864 N6110_GetNextCalendarNote,
2858 NOTIMPLEMENTED, /* SetCalendar */ 2865 NOTIMPLEMENTED, /* SetCalendar */
2859 N6110_AddCalendarNote, 2866 N6110_AddCalendarNote,
2860 N6110_DeleteCalendarNote, 2867 N6110_DeleteCalendarNote,
2861 NOTIMPLEMENTED, /* DeleteAllCalendar */ 2868 NOTIMPLEMENTED, /* DeleteAllCalendar */
2862 NOTSUPPORTED, /* GetCalendarSettings */ 2869 NOTSUPPORTED, /* GetCalendarSettings */
2863 NOTSUPPORTED, /* SetCalendarSettings */ 2870 NOTSUPPORTED, /* SetCalendarSettings */
2864 NOTSUPPORTED, /* GetNote */ 2871 NOTSUPPORTED, /* GetNextNote */
2865 N6110_GetProfile, 2872 N6110_GetProfile,
2866 N6110_SetProfile, 2873 N6110_SetProfile,
2867 NOTSUPPORTED, /* GetFMStation */ 2874 NOTSUPPORTED, /* GetFMStation */
2868 NOTSUPPORTED, /* SetFMStation */ 2875 NOTSUPPORTED, /* SetFMStation */
2869 NOTSUPPORTED, /* ClearFMStations */ 2876 NOTSUPPORTED, /* ClearFMStations */
2870 NOTSUPPORTED, /* GetNextFileFolder */ 2877 NOTSUPPORTED, /* GetNextFileFolder */
2871 NOTSUPPORTED, /* GetFilePart */ 2878 NOTSUPPORTED, /* GetFilePart */
2872 NOTSUPPORTED, /* AddFile */ 2879 NOTSUPPORTED, /* AddFile */
2873 NOTSUPPORTED, /* GetFileSystemStatus */ 2880 NOTSUPPORTED, /* GetFileSystemStatus */
2874 NOTSUPPORTED, /* DeleteFile */ 2881 NOTSUPPORTED, /* DeleteFile */
2875 NOTSUPPORTED, /* AddFolder */ 2882 NOTSUPPORTED, /* AddFolder */
2876 NOTSUPPORTED, /* GetGPRSAccessPoint */ 2883 NOTSUPPORTED, /* GetGPRSAccessPoint */
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,14 +1,17 @@
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
4#include "../../../gsmstate.h" 7#include "../../../gsmstate.h"
5 8
6#ifdef GSM_ENABLE_NOKIA7110 9#ifdef GSM_ENABLE_NOKIA7110
7 10
8#include <string.h> 11#include <string.h>
9#include <time.h> 12#include <time.h>
10 13
11#include "../../../misc/coding/coding.h" 14#include "../../../misc/coding/coding.h"
12#include "../../../gsmcomon.h" 15#include "../../../gsmcomon.h"
13#include "../../../service/gsmlogo.h" 16#include "../../../service/gsmlogo.h"
14#include "../../pfunc.h" 17#include "../../pfunc.h"
@@ -517,24 +520,25 @@ static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
517 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY; 520 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
518 521
519 switch (Ringtone->Format) { 522 switch (Ringtone->Format) {
520 case RING_NOTETONE: 523 case RING_NOTETONE:
521 /* In the future get binary and convert */ 524 /* In the future get binary and convert */
522 return ERR_NOTSUPPORTED; 525 return ERR_NOTSUPPORTED;
523 case RING_NOKIABINARY: 526 case RING_NOKIABINARY:
524 req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location; 527 req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
525 s->Phone.Data.Ringtone=Ringtone; 528 s->Phone.Data.Ringtone=Ringtone;
526 smprintf(s, "Getting binary ringtone\n"); 529 smprintf(s, "Getting binary ringtone\n");
527 return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone); 530 return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone);
528 case RING_MIDI: 531 case RING_MIDI:
532 case RING_MMF:
529 return ERR_NOTSUPPORTED; 533 return ERR_NOTSUPPORTED;
530 } 534 }
531 return ERR_NOTSUPPORTED; 535 return ERR_NOTSUPPORTED;
532} 536}
533 537
534static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 538static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
535{ 539{
536 int i; 540 int i;
537 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110; 541 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
538 542
539 smprintf(s, "Received info for Picture Images\n"); 543 smprintf(s, "Received info for Picture Images\n");
540 smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]); 544 smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]);
@@ -1638,24 +1642,25 @@ GSM_Phone_Functions N7110Phone = {
1638 N7110_GetSpeedDial, 1642 N7110_GetSpeedDial,
1639 NOTIMPLEMENTED, /* SetSpeedDial */ 1643 NOTIMPLEMENTED, /* SetSpeedDial */
1640 DCT3_GetSMSC, 1644 DCT3_GetSMSC,
1641 DCT3_SetSMSC, 1645 DCT3_SetSMSC,
1642 N7110_GetSMSStatus, 1646 N7110_GetSMSStatus,
1643 N7110_GetSMSMessage, 1647 N7110_GetSMSMessage,
1644 N7110_GetNextSMSMessage, 1648 N7110_GetNextSMSMessage,
1645 N7110_SetSMS, 1649 N7110_SetSMS,
1646 N7110_AddSMS, 1650 N7110_AddSMS,
1647 N7110_DeleteSMS, 1651 N7110_DeleteSMS,
1648 DCT3_SendSMSMessage, 1652 DCT3_SendSMSMessage,
1649 NOTSUPPORTED, /* SendSavedSMS */ 1653 NOTSUPPORTED, /* SendSavedSMS */
1654 NOTSUPPORTED, /* SetFastSMSSending*/
1650 N7110_SetIncomingSMS, 1655 N7110_SetIncomingSMS,
1651 DCT3_SetIncomingCB, 1656 DCT3_SetIncomingCB,
1652 N7110_GetSMSFolders, 1657 N7110_GetSMSFolders,
1653 NOTIMPLEMENTED, /* AddSMSFolder */ 1658 NOTIMPLEMENTED, /* AddSMSFolder */
1654 NOTIMPLEMENTED, /* DeleteSMSFolder */ 1659 NOTIMPLEMENTED, /* DeleteSMSFolder */
1655 DCT3_DialVoice, 1660 DCT3_DialVoice,
1656 N7110_AnswerCall, 1661 N7110_AnswerCall,
1657 DCT3_CancelCall, 1662 DCT3_CancelCall,
1658 NOTIMPLEMENTED, /* HoldCall */ 1663 NOTIMPLEMENTED, /* HoldCall */
1659 NOTIMPLEMENTED, /* UnholdCall */ 1664 NOTIMPLEMENTED, /* UnholdCall */
1660 NOTIMPLEMENTED, /* ConferenceCall */ 1665 NOTIMPLEMENTED, /* ConferenceCall */
1661 NOTIMPLEMENTED, /* SplitCall */ 1666 NOTIMPLEMENTED, /* SplitCall */
@@ -1692,25 +1697,25 @@ GSM_Phone_Functions N7110Phone = {
1692 NOTSUPPORTED, /* AddToDo */ 1697 NOTSUPPORTED, /* AddToDo */
1693 NOTSUPPORTED, /* DeleteToDo */ 1698 NOTSUPPORTED, /* DeleteToDo */
1694 NOTSUPPORTED, /* DeleteAllToDo */ 1699 NOTSUPPORTED, /* DeleteAllToDo */
1695 N7110_GetCalendarStatus, 1700 N7110_GetCalendarStatus,
1696 NOTIMPLEMENTED, /* GetCalendar */ 1701 NOTIMPLEMENTED, /* GetCalendar */
1697 N7110_GetNextCalendar, 1702 N7110_GetNextCalendar,
1698 NOTIMPLEMENTED, /* SetCalendar */ 1703 NOTIMPLEMENTED, /* SetCalendar */
1699 N7110_AddCalendar, 1704 N7110_AddCalendar,
1700 N71_65_DelCalendar, 1705 N71_65_DelCalendar,
1701 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 1706 NOTIMPLEMENTED, /* DeleteAllCalendar*/
1702 NOTSUPPORTED, /* GetCalendarSettings*/ 1707 NOTSUPPORTED, /* GetCalendarSettings*/
1703 NOTSUPPORTED, /* SetCalendarSettings*/ 1708 NOTSUPPORTED, /* SetCalendarSettings*/
1704 NOTSUPPORTED, /* GetNote */ 1709 NOTSUPPORTED, /* GetNextNote */
1705 N7110_GetProfile, 1710 N7110_GetProfile,
1706 N7110_SetProfile, 1711 N7110_SetProfile,
1707 NOTSUPPORTED, /* GetFMStation */ 1712 NOTSUPPORTED, /* GetFMStation */
1708 NOTSUPPORTED, /* SetFMStation */ 1713 NOTSUPPORTED, /* SetFMStation */
1709 NOTSUPPORTED, /* ClearFMStations */ 1714 NOTSUPPORTED, /* ClearFMStations */
1710 NOTSUPPORTED, /* GetNextFileFolder*/ 1715 NOTSUPPORTED, /* GetNextFileFolder*/
1711 NOTSUPPORTED, /* GetFilePart */ 1716 NOTSUPPORTED, /* GetFilePart */
1712 NOTSUPPORTED, /* AddFile */ 1717 NOTSUPPORTED, /* AddFile */
1713 NOTSUPPORTED, /* GetFileSystemStatus*/ 1718 NOTSUPPORTED, /* GetFileSystemStatus*/
1714 NOTSUPPORTED, /* DeleteFile */ 1719 NOTSUPPORTED, /* DeleteFile */
1715 NOTSUPPORTED, /* AddFolder */ 1720 NOTSUPPORTED, /* AddFolder */
1716 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 1721 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -310,24 +310,25 @@ GSM_Phone_Functions N9210Phone = {
310 NOTIMPLEMENTED, /* GetSpeedDial */ 310 NOTIMPLEMENTED, /* GetSpeedDial */
311 NOTIMPLEMENTED, /* SetSpeedDial */ 311 NOTIMPLEMENTED, /* SetSpeedDial */
312 DCT3_GetSMSC, 312 DCT3_GetSMSC,
313 DCT3_SetSMSC, /* FIXME: test it */ 313 DCT3_SetSMSC, /* FIXME: test it */
314 NOTIMPLEMENTED, /* GetSMSStatus */ 314 NOTIMPLEMENTED, /* GetSMSStatus */
315 NOTIMPLEMENTED, /* GetSMS */ 315 NOTIMPLEMENTED, /* GetSMS */
316 NOTIMPLEMENTED, /* GetNextSMS */ 316 NOTIMPLEMENTED, /* GetNextSMS */
317 NOTIMPLEMENTED, /* SetSMS */ 317 NOTIMPLEMENTED, /* SetSMS */
318 NOTIMPLEMENTED, /* AddSMS */ 318 NOTIMPLEMENTED, /* AddSMS */
319 NOTIMPLEMENTED, /* DeleteSMS */ 319 NOTIMPLEMENTED, /* DeleteSMS */
320 DCT3_SendSMSMessage, 320 DCT3_SendSMSMessage,
321 NOTSUPPORTED, /* SendSavedSMS */ 321 NOTSUPPORTED, /* SendSavedSMS */
322 NOTSUPPORTED, /* SetFastSMSSending*/
322 N9210_SetIncomingSMS, 323 N9210_SetIncomingSMS,
323 DCT3_SetIncomingCB, 324 DCT3_SetIncomingCB,
324 NOTIMPLEMENTED, /* GetSMSFolders */ 325 NOTIMPLEMENTED, /* GetSMSFolders */
325 NOTSUPPORTED, /* AddSMSFolder */ 326 NOTSUPPORTED, /* AddSMSFolder */
326 NOTSUPPORTED, /* DeleteSMSFolder */ 327 NOTSUPPORTED, /* DeleteSMSFolder */
327 DCT3_DialVoice, 328 DCT3_DialVoice,
328 N9210_AnswerCall, 329 N9210_AnswerCall,
329 DCT3_CancelCall, 330 DCT3_CancelCall,
330 NOTSUPPORTED, /* HoldCall */ 331 NOTSUPPORTED, /* HoldCall */
331 NOTSUPPORTED, /* UnholdCall */ 332 NOTSUPPORTED, /* UnholdCall */
332 NOTSUPPORTED, /* ConferenceCall */ 333 NOTSUPPORTED, /* ConferenceCall */
333 NOTSUPPORTED, /* SplitCall */ 334 NOTSUPPORTED, /* SplitCall */
@@ -364,25 +365,25 @@ GSM_Phone_Functions N9210Phone = {
364 NOTSUPPORTED, /* AddToDo */ 365 NOTSUPPORTED, /* AddToDo */
365 NOTSUPPORTED, /* DeleteToDo */ 366 NOTSUPPORTED, /* DeleteToDo */
366 NOTSUPPORTED, /* DeleteAllToDo */ 367 NOTSUPPORTED, /* DeleteAllToDo */
367 NOTSUPPORTED, /* GetCalendarStatus*/ 368 NOTSUPPORTED, /* GetCalendarStatus*/
368 NOTSUPPORTED, /* GetCalendar */ 369 NOTSUPPORTED, /* GetCalendar */
369 NOTSUPPORTED, /* GetNextCalendar */ 370 NOTSUPPORTED, /* GetNextCalendar */
370 NOTSUPPORTED, /* SetCalendar */ 371 NOTSUPPORTED, /* SetCalendar */
371 NOTSUPPORTED, /* AddCalendar */ 372 NOTSUPPORTED, /* AddCalendar */
372 NOTSUPPORTED, /* DeleteCalendar */ 373 NOTSUPPORTED, /* DeleteCalendar */
373 NOTSUPPORTED, /* DeleteAllCalendar*/ 374 NOTSUPPORTED, /* DeleteAllCalendar*/
374 NOTSUPPORTED, /* GetCalendarSettings*/ 375 NOTSUPPORTED, /* GetCalendarSettings*/
375 NOTSUPPORTED, /* SetCalendarSettings*/ 376 NOTSUPPORTED, /* SetCalendarSettings*/
376 NOTSUPPORTED, /* GetNote */ 377 NOTSUPPORTED, /* GetNextNote */
377 NOTIMPLEMENTED, /* GetProfile */ 378 NOTIMPLEMENTED, /* GetProfile */
378 NOTSUPPORTED, /* SetProfile */ 379 NOTSUPPORTED, /* SetProfile */
379 NOTSUPPORTED, /* GetFMStation */ 380 NOTSUPPORTED, /* GetFMStation */
380 NOTSUPPORTED, /* SetFMStation */ 381 NOTSUPPORTED, /* SetFMStation */
381 NOTSUPPORTED, /* ClearFMStations */ 382 NOTSUPPORTED, /* ClearFMStations */
382 NOTSUPPORTED, /* GetNextFileFolder*/ 383 NOTSUPPORTED, /* GetNextFileFolder*/
383 NOTSUPPORTED, /* GetFilePart */ 384 NOTSUPPORTED, /* GetFilePart */
384 NOTSUPPORTED, /* AddFile */ 385 NOTSUPPORTED, /* AddFile */
385 NOTSUPPORTED, /* GetFileSystemStatus*/ 386 NOTSUPPORTED, /* GetFileSystemStatus*/
386 NOTSUPPORTED, /* DeleteFile */ 387 NOTSUPPORTED, /* DeleteFile */
387 NOTSUPPORTED, /* AddFolder */ 388 NOTSUPPORTED, /* AddFolder */
388 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 389 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -185,24 +185,25 @@ GSM_Phone_Functions N3320Phone = {
185 NOTSUPPORTED, /* GetSpeedDial */ 185 NOTSUPPORTED, /* GetSpeedDial */
186 NOTSUPPORTED, /* SetSpeedDial */ 186 NOTSUPPORTED, /* SetSpeedDial */
187 NOTSUPPORTED, /* GetSMSC */ 187 NOTSUPPORTED, /* GetSMSC */
188 NOTSUPPORTED, /* SetSMSC */ 188 NOTSUPPORTED, /* SetSMSC */
189 NOTSUPPORTED, /* GetSMSStatus */ 189 NOTSUPPORTED, /* GetSMSStatus */
190 NOTSUPPORTED, /* GetSMS */ 190 NOTSUPPORTED, /* GetSMS */
191 NOTSUPPORTED, /* GetNextSMS */ 191 NOTSUPPORTED, /* GetNextSMS */
192 NOTSUPPORTED, /* SetSMS */ 192 NOTSUPPORTED, /* SetSMS */
193 NOTSUPPORTED, /* AddSMS */ 193 NOTSUPPORTED, /* AddSMS */
194 NOTSUPPORTED, /* DeleteSMS */ 194 NOTSUPPORTED, /* DeleteSMS */
195 NOTSUPPORTED, /* SendSMS */ 195 NOTSUPPORTED, /* SendSMS */
196 NOTSUPPORTED, /* SendSavedSMS */ 196 NOTSUPPORTED, /* SendSavedSMS */
197 NOTSUPPORTED, /* SetFastSMSSending*/
197 NOTSUPPORTED, /* SetIncomingSMS */ 198 NOTSUPPORTED, /* SetIncomingSMS */
198 NOTSUPPORTED, /* SetIncomingCB */ 199 NOTSUPPORTED, /* SetIncomingCB */
199 NOTSUPPORTED, /* GetSMSFolders */ 200 NOTSUPPORTED, /* GetSMSFolders */
200 NOTSUPPORTED, /* AddSMSFolder */ 201 NOTSUPPORTED, /* AddSMSFolder */
201 NOTSUPPORTED, /* DeleteSMSFolder */ 202 NOTSUPPORTED, /* DeleteSMSFolder */
202 NOTIMPLEMENTED, /* DialVoice */ 203 NOTIMPLEMENTED, /* DialVoice */
203 NOTIMPLEMENTED, /* AnswerCall */ 204 NOTIMPLEMENTED, /* AnswerCall */
204 NOTIMPLEMENTED, /* CancelCall */ 205 NOTIMPLEMENTED, /* CancelCall */
205 NOTIMPLEMENTED, /* HoldCall */ 206 NOTIMPLEMENTED, /* HoldCall */
206 NOTIMPLEMENTED, /* UnholdCall */ 207 NOTIMPLEMENTED, /* UnholdCall */
207 NOTIMPLEMENTED, /* ConferenceCall */ 208 NOTIMPLEMENTED, /* ConferenceCall */
208 NOTIMPLEMENTED, /* SplitCall */ 209 NOTIMPLEMENTED, /* SplitCall */
@@ -239,25 +240,25 @@ GSM_Phone_Functions N3320Phone = {
239 NOTSUPPORTED, /* AddToDo */ 240 NOTSUPPORTED, /* AddToDo */
240 NOTSUPPORTED, /* DeleteToDo */ 241 NOTSUPPORTED, /* DeleteToDo */
241 NOTSUPPORTED, /* DeleteAllToDo */ 242 NOTSUPPORTED, /* DeleteAllToDo */
242 N3320_GetCalendarStatus, 243 N3320_GetCalendarStatus,
243 NOTIMPLEMENTED, /* GetCalendar */ 244 NOTIMPLEMENTED, /* GetCalendar */
244 N3320_GetNextCalendar, 245 N3320_GetNextCalendar,
245 NOTIMPLEMENTED, /* SetCalendar */ 246 NOTIMPLEMENTED, /* SetCalendar */
246 NOTSUPPORTED, /* AddCalendar */ 247 NOTSUPPORTED, /* AddCalendar */
247 NOTSUPPORTED, /* DeleteCalendar */ 248 NOTSUPPORTED, /* DeleteCalendar */
248 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 249 NOTIMPLEMENTED, /* DeleteAllCalendar*/
249 NOTSUPPORTED, /* GetCalendarSettings*/ 250 NOTSUPPORTED, /* GetCalendarSettings*/
250 NOTSUPPORTED, /* SetCalendarSettings*/ 251 NOTSUPPORTED, /* SetCalendarSettings*/
251 NOTSUPPORTED, /* GetNote */ 252 NOTSUPPORTED, /* GetNextNote */
252 NOTSUPPORTED, /* GetProfile */ 253 NOTSUPPORTED, /* GetProfile */
253 NOTSUPPORTED, /* SetProfile */ 254 NOTSUPPORTED, /* SetProfile */
254 NOTSUPPORTED, /* GetFMStation */ 255 NOTSUPPORTED, /* GetFMStation */
255 NOTSUPPORTED, /* SetFMStation */ 256 NOTSUPPORTED, /* SetFMStation */
256 NOTSUPPORTED, /* ClearFMStations */ 257 NOTSUPPORTED, /* ClearFMStations */
257 NOTSUPPORTED, /* GetNextFileFolder*/ 258 NOTSUPPORTED, /* GetNextFileFolder*/
258 NOTSUPPORTED, /* GetFilePart */ 259 NOTSUPPORTED, /* GetFilePart */
259 NOTIMPLEMENTED, /* AddFilePart */ 260 NOTIMPLEMENTED, /* AddFilePart */
260 NOTSUPPORTED, /* GetFileSystemStatus*/ 261 NOTSUPPORTED, /* GetFileSystemStatus*/
261 NOTIMPLEMENTED, /* DeleteFile */ 262 NOTIMPLEMENTED, /* DeleteFile */
262 NOTIMPLEMENTED, /* AddFolder */ 263 NOTIMPLEMENTED, /* AddFolder */
263 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 264 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -306,24 +306,25 @@ GSM_Phone_Functions N3650Phone = {
306 NOTSUPPORTED, /* GetSpeedDial */ 306 NOTSUPPORTED, /* GetSpeedDial */
307 NOTSUPPORTED, /* SetSpeedDial */ 307 NOTSUPPORTED, /* SetSpeedDial */
308 NOTSUPPORTED, /* GetSMSC */ 308 NOTSUPPORTED, /* GetSMSC */
309 NOTSUPPORTED, /* SetSMSC */ 309 NOTSUPPORTED, /* SetSMSC */
310 NOTSUPPORTED, /* GetSMSStatus */ 310 NOTSUPPORTED, /* GetSMSStatus */
311 NOTSUPPORTED, /* GetSMS */ 311 NOTSUPPORTED, /* GetSMS */
312 NOTSUPPORTED, /* GetNextSMS */ 312 NOTSUPPORTED, /* GetNextSMS */
313 NOTSUPPORTED, /* SetSMS */ 313 NOTSUPPORTED, /* SetSMS */
314 NOTSUPPORTED, /* AddSMS */ 314 NOTSUPPORTED, /* AddSMS */
315 NOTSUPPORTED, /* DeleteSMS */ 315 NOTSUPPORTED, /* DeleteSMS */
316 NOTSUPPORTED, /* SendSMS */ 316 NOTSUPPORTED, /* SendSMS */
317 NOTSUPPORTED, /* SendSavedSMS */ 317 NOTSUPPORTED, /* SendSavedSMS */
318 NOTSUPPORTED, /* SetFastSMSSending*/
318 NOTSUPPORTED, /* SetIncomingSMS */ 319 NOTSUPPORTED, /* SetIncomingSMS */
319 NOTSUPPORTED, /* SetIncomingCB */ 320 NOTSUPPORTED, /* SetIncomingCB */
320 NOTSUPPORTED, /* GetSMSFolders */ 321 NOTSUPPORTED, /* GetSMSFolders */
321 NOTSUPPORTED, /* AddSMSFolder */ 322 NOTSUPPORTED, /* AddSMSFolder */
322 NOTSUPPORTED, /* DeleteSMSFolder */ 323 NOTSUPPORTED, /* DeleteSMSFolder */
323 NOTIMPLEMENTED, /* DialVoice */ 324 NOTIMPLEMENTED, /* DialVoice */
324 NOTIMPLEMENTED, /* AnswerCall */ 325 NOTIMPLEMENTED, /* AnswerCall */
325 NOTIMPLEMENTED, /* CancelCall */ 326 NOTIMPLEMENTED, /* CancelCall */
326 NOTIMPLEMENTED, /* HoldCall */ 327 NOTIMPLEMENTED, /* HoldCall */
327 NOTIMPLEMENTED, /* UnholdCall */ 328 NOTIMPLEMENTED, /* UnholdCall */
328 NOTIMPLEMENTED, /* ConferenceCall */ 329 NOTIMPLEMENTED, /* ConferenceCall */
329 NOTIMPLEMENTED, /* SplitCall */ 330 NOTIMPLEMENTED, /* SplitCall */
@@ -360,25 +361,25 @@ GSM_Phone_Functions N3650Phone = {
360 NOTSUPPORTED, /* AddToDo */ 361 NOTSUPPORTED, /* AddToDo */
361 NOTSUPPORTED, /* DeleteToDo */ 362 NOTSUPPORTED, /* DeleteToDo */
362 NOTSUPPORTED, /* DeleteAllToDo */ 363 NOTSUPPORTED, /* DeleteAllToDo */
363 NOTIMPLEMENTED, /* GetCalendarStatus*/ 364 NOTIMPLEMENTED, /* GetCalendarStatus*/
364 NOTIMPLEMENTED, /* GetCalendar */ 365 NOTIMPLEMENTED, /* GetCalendar */
365 NOTSUPPORTED, /* GetNextCalendar */ 366 NOTSUPPORTED, /* GetNextCalendar */
366 NOTIMPLEMENTED, /* SetCalendar */ 367 NOTIMPLEMENTED, /* SetCalendar */
367 NOTSUPPORTED, /* AddCalendar */ 368 NOTSUPPORTED, /* AddCalendar */
368 NOTSUPPORTED, /* DeleteCalendar */ 369 NOTSUPPORTED, /* DeleteCalendar */
369 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 370 NOTIMPLEMENTED, /* DeleteAllCalendar*/
370 NOTSUPPORTED, /* GetCalendarSettings*/ 371 NOTSUPPORTED, /* GetCalendarSettings*/
371 NOTSUPPORTED, /* SetCalendarSettings*/ 372 NOTSUPPORTED, /* SetCalendarSettings*/
372 NOTSUPPORTED, /* GetNote */ 373 NOTSUPPORTED, /* GetNextNote */
373 NOTSUPPORTED, /* GetProfile */ 374 NOTSUPPORTED, /* GetProfile */
374 NOTSUPPORTED, /* SetProfile */ 375 NOTSUPPORTED, /* SetProfile */
375 NOTSUPPORTED, /* GetFMStation */ 376 NOTSUPPORTED, /* GetFMStation */
376 NOTSUPPORTED, /* SetFMStation */ 377 NOTSUPPORTED, /* SetFMStation */
377 NOTSUPPORTED, /* ClearFMStations */ 378 NOTSUPPORTED, /* ClearFMStations */
378 N3650_GetNextFileFolder, 379 N3650_GetNextFileFolder,
379 N3650_GetFilePart, 380 N3650_GetFilePart,
380 NOTIMPLEMENTED, /* AddFilePart */ 381 NOTIMPLEMENTED, /* AddFilePart */
381 NOTSUPPORTED, /* GetFileSystemStatus*/ 382 NOTSUPPORTED, /* GetFileSystemStatus*/
382 NOTIMPLEMENTED, /* DeleteFile */ 383 NOTIMPLEMENTED, /* DeleteFile */
383 NOTIMPLEMENTED, /* AddFolder */ 384 NOTIMPLEMENTED, /* AddFolder */
384 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 385 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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,14 +1,17 @@
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 */
4 7
5#include "../../../gsmstate.h" 8#include "../../../gsmstate.h"
6 9
7#ifdef GSM_ENABLE_NOKIA6510 10#ifdef GSM_ENABLE_NOKIA6510
8 11
9#include <string.h> 12#include <string.h>
10#include <time.h> 13#include <time.h>
11 14
12#include "../../../misc/coding/coding.h" 15#include "../../../misc/coding/coding.h"
13#include "../../../gsmcomon.h" 16#include "../../../gsmcomon.h"
14#include "../../../service/gsmlogo.h" 17#include "../../../service/gsmlogo.h"
@@ -110,24 +113,26 @@ static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *
110 } 113 }
111 memset(Data->SMSC,0,sizeof(GSM_SMSC)); 114 memset(Data->SMSC,0,sizeof(GSM_SMSC));
112 Data->SMSC->Location = msg.Buffer[8]; 115 Data->SMSC->Location = msg.Buffer[8];
113 Data->SMSC->Format = SMS_FORMAT_Text; 116 Data->SMSC->Format = SMS_FORMAT_Text;
114 switch (msg.Buffer[10]) { 117 switch (msg.Buffer[10]) {
115 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; 118 case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
116 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; 119 case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
117 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; 120 case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break;
118 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; 121 case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break;
119 } 122 }
120 Data->SMSC->Validity.Format= SMS_Validity_RelativeFormat; 123 Data->SMSC->Validity.Format= SMS_Validity_RelativeFormat;
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;
123 for (i=0;i<msg.Buffer[13];i++) { 128 for (i=0;i<msg.Buffer[13];i++) {
124 switch (msg.Buffer[current]) { 129 switch (msg.Buffer[current]) {
125 case 0x81: 130 case 0x81:
126 j=current+4; 131 j=current+4;
127 while (msg.Buffer[j]!=0) {j++;} 132 while (msg.Buffer[j]!=0) {j++;}
128 j=j-33; 133 j=j-33;
129 if (j>GSM_MAX_SMSC_NAME_LENGTH) { 134 if (j>GSM_MAX_SMSC_NAME_LENGTH) {
130 smprintf(s, "Too long name\n"); 135 smprintf(s, "Too long name\n");
131 return ERR_UNKNOWNRESPONSE; 136 return ERR_UNKNOWNRESPONSE;
132 } 137 }
133 CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4); 138 CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4);
@@ -256,25 +261,25 @@ static GSM_Error N6510_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
256 smprintf(s, "Setting SMSC\n"); 261 smprintf(s, "Setting SMSC\n");
257 return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC); 262 return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC);
258} 263}
259 264
260static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 265static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
261{ 266{
262 int current = msg.Buffer[7]+7, tmp; 267 int current = msg.Buffer[7]+7, tmp;
263 GSM_Phone_Data*Data = &s->Phone.Data; 268 GSM_Phone_Data*Data = &s->Phone.Data;
264#ifdef DEBUG 269#ifdef DEBUG
265 char name[100]; 270 char name[100];
266 GSM_NetworkInfo NetInfo; 271 GSM_NetworkInfo NetInfo;
267 272
268 smprintf(s, "Network status: "); 273 smprintf(s, "Network status : ");
269 switch (msg.Buffer[8]) { 274 switch (msg.Buffer[8]) {
270 case 0x00 : smprintf(s, "home network\n"); break; 275 case 0x00 : smprintf(s, "home network\n"); break;
271 case 0x01 : smprintf(s, "roaming network\n"); break; 276 case 0x01 : smprintf(s, "roaming network\n"); break;
272 case 0x04 : smprintf(s, "not logged"); break; 277 case 0x04 : smprintf(s, "not logged"); break;
273 case 0x06 : smprintf(s, "SIM card rejected\n"); break; 278 case 0x06 : smprintf(s, "SIM card rejected\n"); break;
274 case 0x09 : smprintf(s, "not logged"); break; 279 case 0x09 : smprintf(s, "not logged"); break;
275 default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break; 280 default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break;
276 } 281 }
277 if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) { 282 if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) {
278 NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode); 283 NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode);
279 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); 284 smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
280 smprintf(s, "Network name for Gammu : %s ", 285 smprintf(s, "Network name for Gammu : %s ",
@@ -976,29 +981,29 @@ static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *
976} 981}
977 982
978static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s) 983static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s)
979{ 984{
980 return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true); 985 return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true);
981} 986}
982 987
983static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) 988static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
984{ 989{
985 GSM_Phone_Data *Data = &s->Phone.Data; 990 GSM_Phone_Data *Data = &s->Phone.Data;
986 991
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);
989 smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode); 995 smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode);
990 Data->Bitmap->BitmapWidth= msg.Buffer[20]; 996 Data->Bitmap->BitmapWidth= msg.Buffer[20];
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);
994 return ERR_NONE; 999 return ERR_NONE;
995} 1000}
996 1001
997GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 1002GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
998{ 1003{
999 smprintf(s, "Phonebook entry deleted\n"); 1004 smprintf(s, "Phonebook entry deleted\n");
1000 return ERR_NONE; 1005 return ERR_NONE;
1001} 1006}
1002 1007
1003GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 1008GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1004{ 1009{
@@ -1756,25 +1761,26 @@ static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings
1756 0x00, 0x00, 0x00, 0x31, 0x00, 1761 0x00, 0x00, 0x00, 0x31, 0x00,
1757 0x01, //location 1762 0x01, //location
1758 0x00, 0x00, 0x02, 0x46, 0x00, 0x00}; 1763 0x00, 0x00, 0x02, 0x46, 0x00, 0x00};
1759 1764
1760 settings->Connection.Location = settings->Location; 1765 settings->Connection.Location = settings->Location;
1761 error = N6510_GetConnectionSettings(s, &settings->Connection, N6510_SYNCML_SETTINGS); 1766 error = N6510_GetConnectionSettings(s, &settings->Connection, N6510_SYNCML_SETTINGS);
1762 if (error != ERR_NONE) return error; 1767 if (error != ERR_NONE) return error;
1763 1768
1764 settings->Active = settings->Connection.Active; 1769 settings->Active = settings->Connection.Active;
1765 1770
1766 settings->Name[0] = 0; 1771 settings->Name[0] = 0;
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");
1770 //error = GSM_WaitFor (s, NameReq, 16, 0x43, 4, ID_GetSyncMLName); 1776 //error = GSM_WaitFor (s, NameReq, 16, 0x43, 4, ID_GetSyncMLName);
1771 //if (error != ERR_NONE) return error; 1777 //if (error != ERR_NONE) return error;
1772 1778
1773 req[9] = settings->Location - 1; 1779 req[9] = settings->Location - 1;
1774 smprintf(s, "Getting additional SyncML settings\n"); 1780 smprintf(s, "Getting additional SyncML settings\n");
1775 return GSM_WaitFor (s, req, 16, 0x43, 4, ID_GetSyncMLSettings); 1781 return GSM_WaitFor (s, req, 16, 0x43, 4, ID_GetSyncMLSettings);
1776} 1782}
1777 1783
1778static GSM_Error N6510_ReplyGetChatSettings(GSM_Protocol_Message msg, GSM_StateMachine *s) 1784static GSM_Error N6510_ReplyGetChatSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
1779{ 1785{
1780 GSM_ChatSettings *Sett = s->Phone.Data.ChatSettings; 1786 GSM_ChatSettings *Sett = s->Phone.Data.ChatSettings;
@@ -2274,25 +2280,25 @@ static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms
2274 } 2280 }
2275 req[6]=location / 256; 2281 req[6]=location / 256;
2276 req[7]=location; 2282 req[7]=location;
2277 2283
2278 smprintf(s, "Deleting sms\n"); 2284 smprintf(s, "Deleting sms\n");
2279 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage); 2285 return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage);
2280} 2286}
2281 2287
2282static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) 2288static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
2283{ 2289{
2284 switch (msg.Buffer[8]) { 2290 switch (msg.Buffer[8]) {
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]);
2288 return ERR_NONE; 2294 return ERR_NONE;
2289 default: 2295 default:
2290 smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]); 2296 smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]);
2291 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]); 2297 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]);
2292 return ERR_NONE; 2298 return ERR_NONE;
2293 } 2299 }
2294} 2300}
2295 2301
2296static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) 2302static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
2297{ 2303{
2298 int length = 11; 2304 int length = 11;
@@ -2761,24 +2767,25 @@ static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
2761 return ERR_NOTSUPPORTED; 2767 return ERR_NOTSUPPORTED;
2762 case RING_NOKIABINARY: 2768 case RING_NOKIABINARY:
2763 s->Phone.Data.Ringtone= Ringtone; 2769 s->Phone.Data.Ringtone= Ringtone;
2764 Info.Number = 0; 2770 Info.Number = 0;
2765 error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone); 2771 error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone);
2766 if (error != ERR_NONE) return error; 2772 if (error != ERR_NONE) return error;
2767 if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION; 2773 if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION;
2768 req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256; 2774 req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256;
2769 req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256; 2775 req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256;
2770 smprintf(s, "Getting binary ringtone\n"); 2776 smprintf(s, "Getting binary ringtone\n");
2771 return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone); 2777 return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone);
2772 case RING_MIDI: 2778 case RING_MIDI:
2779 case RING_MMF:
2773 return ERR_NOTSUPPORTED; 2780 return ERR_NOTSUPPORTED;
2774 } 2781 }
2775 return ERR_NOTSUPPORTED; 2782 return ERR_NOTSUPPORTED;
2776} 2783}
2777 2784
2778static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start) 2785static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start)
2779{ 2786{
2780 GSM_Error error; 2787 GSM_Error error;
2781 unsigned char reqStart[] = { 2788 unsigned char reqStart[] = {
2782 0x00,0x06,0x01,0x00,0x07,0x00 }; 2789 0x00,0x06,0x01,0x00,0x07,0x00 };
2783 unsigned char reqPlay[] = { 2790 unsigned char reqPlay[] = {
2784 0x00,0x06,0x01,0x14,0x05,0x04, 2791 0x00,0x06,0x01,0x14,0x05,0x04,
@@ -2977,24 +2984,27 @@ static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
2977 unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01}; 2984 unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01};
2978 unsigned charreqActive[] = {N6110_FRAME_HEADER, 0x05}; 2985 unsigned charreqActive[] = {N6110_FRAME_HEADER, 0x05};
2979 int i, length = 7; 2986 int i, length = 7;
2980 GSM_Errorerror; 2987 GSM_Errorerror;
2981 2988
2982 /* For now !!! */ 2989 /* For now !!! */
2983 if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) { 2990 if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) {
2984 if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED; 2991 if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED;
2985 } 2992 }
2986 if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) { 2993 if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) {
2987 return ERR_NOTSUPPORTED; 2994 return ERR_NOTSUPPORTED;
2988 } 2995 }
2996 if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) {
2997 return ERR_NOTSUPPORTED;
2998 }
2989 2999
2990 if (Profile->Location>5) return ERR_INVALIDLOCATION; 3000 if (Profile->Location>5) return ERR_INVALIDLOCATION;
2991 3001
2992 for (i = 0; i < 0x0a; i++) { 3002 for (i = 0; i < 0x0a; i++) {
2993 req[length++] = 0x04; 3003 req[length++] = 0x04;
2994 req[length++] = Profile->Location; 3004 req[length++] = Profile->Location;
2995 req[length++] = i; 3005 req[length++] = i;
2996 req[length++] = 0x01; 3006 req[length++] = 0x01;
2997 } 3007 }
2998 3008
2999 req[length++] = 0x04; 3009 req[length++] = 0x04;
3000 req[length++] = Profile->Location; 3010 req[length++] = Profile->Location;
@@ -3106,52 +3116,76 @@ static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachi
3106 sms.State = SMS_UnRead; 3116 sms.State = SMS_UnRead;
3107 sms.InboxFolder = true; 3117 sms.InboxFolder = true;
3108 3118
3109 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); 3119 N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
3110 3120
3111 s->User.IncomingSMS(s->CurrentConfig->Device,sms); 3121 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
3112 } 3122 }
3113 return ERR_NONE; 3123 return ERR_NONE;
3114} 3124}
3115 3125
3116static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) 3126static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
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
3122 req[pos++] = strlen(number); 3144 req[pos++] = strlen(number);
3123 EncodeUnicode(req+pos,number,strlen(number)); 3145 EncodeUnicode(req+pos,number,strlen(number));
3124 pos += strlen(number)*2; 3146 pos += strlen(number)*2;
3125 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ 3147 req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
3126 req[pos++] = 0x01; 3148 req[pos++] = 0x01;
3127 req[pos++] = 0x05; 3149 req[pos++] = 0x05;
3128 req[pos++] = 0x00; 3150 req[pos++] = 0x00;
3129 req[pos++] = 0x02; 3151 req[pos++] = 0x02;
3130 req[pos++] = 0x00; 3152 req[pos++] = 0x00;
3131 req[pos++] = 0x00; 3153 req[pos++] = 0x00;
3132 switch (ShowNumber) { 3154 switch (ShowNumber) {
3133 case GSM_CALL_HideNumber: 3155 case GSM_CALL_HideNumber:
3134 req[pos++] = 0x02; 3156 req[pos++] = 0x02;
3135 break; 3157 break;
3136 case GSM_CALL_ShowNumber: 3158 case GSM_CALL_ShowNumber:
3137 req[pos++] = 0x03; 3159 req[pos++] = 0x03;
3138 break; 3160 break;
3139 case GSM_CALL_DefaultNumberPresence: 3161 case GSM_CALL_DefaultNumberPresence:
3140 req[pos++] = 0x01; 3162 req[pos++] = 0x01;
3141 break; 3163 break;
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}
3147 3181
3148/* method 3 */ 3182/* method 3 */
3149static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last) 3183static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last)
3150{ 3184{
3151 int i=0,j=0; 3185 int i=0,j=0;
3152 3186
3153 while (Last->Location[j] != 0x00) j++; 3187 while (Last->Location[j] != 0x00) j++;
3154 if (j >= GSM_MAXCALENDARTODONOTES) { 3188 if (j >= GSM_MAXCALENDARTODONOTES) {
3155 smprintf(s, "Increase GSM_MAXCALENDARTODONOTES\n"); 3189 smprintf(s, "Increase GSM_MAXCALENDARTODONOTES\n");
3156 return ERR_UNKNOWN; 3190 return ERR_UNKNOWN;
3157 } 3191 }
@@ -3165,63 +3199,69 @@ static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_State
3165 smprintf(s, "%i ",Last->Location[j-1]); 3199 smprintf(s, "%i ",Last->Location[j-1]);
3166 i++; 3200 i++;
3167 } 3201 }
3168 smprintf(s, "\nNumber of Entries in frame: %i\n",i); 3202 smprintf(s, "\nNumber of Entries in frame: %i\n",i);
3169 Last->Location[j] = 0; 3203 Last->Location[j] = 0;
3170 smprintf(s, "\n"); 3204 smprintf(s, "\n");
3171 if (i == 1 && msg.Buffer[12+0*4]*256+msg.Buffer[13+0*4] == 0) return ERR_EMPTY; 3205 if (i == 1 && msg.Buffer[12+0*4]*256+msg.Buffer[13+0*4] == 0) return ERR_EMPTY;
3172 if (i == 0) return ERR_EMPTY; 3206 if (i == 0) return ERR_EMPTY;
3173 return ERR_NONE; 3207 return ERR_NONE;
3174} 3208}
3175 3209
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;
3181 unsigned char req[] = {N6110_FRAME_HEADER, 0x9E, 0xFF, 0xFF, 0x00, 0x00, 3215 unsigned char req[] = {N6110_FRAME_HEADER, 0x9E, 0xFF, 0xFF, 0x00, 0x00,
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
3185 Last->Location[0] = 0x00; 3219 Last->Location[0] = 0x00;
3186 Last->Number = 0; 3220 Last->Number = 0;
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 }
3196 if (error != ERR_NONE && error != ERR_EMPTY) return error; 3233 if (error != ERR_NONE && error != ERR_EMPTY) return error;
3197 3234
3198 while (1) { 3235 while (1) {
3199 i=0; 3236 i=0;
3200 while (Last->Location[i] != 0x00) i++; 3237 while (Last->Location[i] != 0x00) i++;
3201 smprintf(s, "i = %i %i\n",i,Last->Number); 3238 smprintf(s, "i = %i %i\n",i,Last->Number);
3202 if (i == Last->Number) break; 3239 if (i == Last->Number) break;
3203 if (i != Last->Number && error == ERR_EMPTY) { 3240 if (i != Last->Number && error == ERR_EMPTY) {
3204 smprintf(s, "Phone doesn't support some notes with this method. Workaround\n"); 3241 smprintf(s, "Phone doesn't support some notes with this method. Workaround\n");
3205 Last->Number = i; 3242 Last->Number = i;
3206 break; 3243 break;
3207 } 3244 }
3208 req[8] = Last->Location[i-1] / 256; 3245 req[8] = Last->Location[i-1] / 256;
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 }
3217 if (error != ERR_NONE && error != ERR_EMPTY) return error; 3257 if (error != ERR_NONE && error != ERR_EMPTY) return error;
3218 } 3258 }
3219 return ERR_NONE; 3259 return ERR_NONE;
3220} 3260}
3221 3261
3222/* method 3 */ 3262/* method 3 */
3223GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) 3263GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
3224{ 3264{
3225 GSM_CalendarEntry *entry = s->Phone.Data.Cal; 3265 GSM_CalendarEntry *entry = s->Phone.Data.Cal;
3226 GSM_DateTime Date; 3266 GSM_DateTime Date;
3227 unsigned long diff; 3267 unsigned long diff;
@@ -3341,69 +3381,75 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
3341 } 3381 }
3342 if (entry->Type == GSM_CAL_MEETING) { 3382 if (entry->Type == GSM_CAL_MEETING) {
3343 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2); 3383 memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2);
3344 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0; 3384 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0;
3345 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0; 3385 entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0;
3346 entry->Entries[entry->EntriesNum].EntryType = CAL_LOCATION; 3386 entry->Entries[entry->EntriesNum].EntryType = CAL_LOCATION;
3347 entry->EntriesNum++; 3387 entry->EntriesNum++;
3348 } 3388 }
3349 3389
3350 return ERR_NONE; 3390 return ERR_NONE;
3351} 3391}
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)
3354{ 3406{
3355 GSM_Error error; 3407 GSM_Error error;
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
3361 if (start) { 3410 if (start) {
3362 /* We have to get current year. It's NOT written in frame for 3411 /* We have to get current year. It's NOT written in frame for
3363 * Birthday 3412 * Birthday
3364 */ 3413 */
3365 error=s->Phone.Functions->GetDateTime(s,&date_time); 3414 error=s->Phone.Functions->GetDateTime(s,&date_time);
3366 switch (error) { 3415 switch (error) {
3367 case ERR_EMPTY: 3416 case ERR_EMPTY:
3368 case ERR_NOTIMPLEMENTED: 3417 case ERR_NOTIMPLEMENTED:
3369 GSM_GetCurrentDateTime(&date_time); 3418 GSM_GetCurrentDateTime(&date_time);
3370 break; 3419 break;
3371 case ERR_NONE: 3420 case ERR_NONE:
3372 break; 3421 break;
3373 default: 3422 default:
3374 return error; 3423 return error;
3375 } 3424 }
3376 *LastCalendarYear = date_time.Year; 3425 *LastCalendarYear = date_time.Year;
3377 } 3426 }
3378 3427
3379 Note->EntriesNum = 0; 3428 Note->EntriesNum = 0;
3380 Note->Entries[0].Date.Year = *LastCalendarYear; 3429 Note->Entries[0].Date.Year = *LastCalendarYear;
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}
3389 3435
3390/* method 3 */ 3436/* method 3 */
3391GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos) 3437GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos)
3392{ 3438{
3393 GSM_Error error; 3439 GSM_Error error;
3394 bool start2; 3440 bool start2;
3395 3441
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;
3399 if (LastCalendar->Number == 0) return ERR_EMPTY; 3445 if (LastCalendar->Number == 0) return ERR_EMPTY;
3400 3446
3401 *LastCalendarPos = 0; 3447 *LastCalendarPos = 0;
3402 } else { 3448 } else {
3403 (*LastCalendarPos)++; 3449 (*LastCalendarPos)++;
3404 } 3450 }
3405 3451
3406 error = ERR_EMPTY; 3452 error = ERR_EMPTY;
3407 start2 = start; 3453 start2 = start;
3408 while (error == ERR_EMPTY) { 3454 while (error == ERR_EMPTY) {
3409 if (*LastCalendarPos >= LastCalendar->Number) return ERR_EMPTY; 3455 if (*LastCalendarPos >= LastCalendar->Number) return ERR_EMPTY;
@@ -3468,42 +3514,42 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr
3468 GSM_Error error; 3514 GSM_Error error;
3469 bool found; 3515 bool found;
3470 3516
3471 for(i=0;i<Priv->CalendarIconsNum;i++) { 3517 for(i=0;i<Priv->CalendarIconsNum;i++) {
3472 if (Priv->CalendarIconsTypes[i] == Entry->Type) { 3518 if (Priv->CalendarIconsTypes[i] == Entry->Type) {
3473 *ID = Priv->CalendarIcons[i]; 3519 *ID = Priv->CalendarIcons[i];
3474 return ERR_NONE; 3520 return ERR_NONE;
3475 } 3521 }
3476 } 3522 }
3477 3523
3478 smprintf(s, "Starting finding note ID\n"); 3524 smprintf(s, "Starting finding note ID\n");
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));
3482 if (error != ERR_NONE) return error; 3528 if (error != ERR_NONE) return error;
3483 3529
3484 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35) || 3530 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35) ||
3485 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) || 3531 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) ||
3486 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3532 IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3487 error=N71_65_AddCalendar2(s,Entry); 3533 error=N71_65_AddCalendar2(s,Entry);
3488 } else { 3534 } else {
3489 if (Entry->Type == GSM_CAL_MEETING) { 3535 if (Entry->Type == GSM_CAL_MEETING) {
3490 error=N71_65_AddCalendar1(s, Entry, &s->Phone.Data.Priv.N6510.FirstCalendarPos); 3536 error=N71_65_AddCalendar1(s, Entry, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
3491 } else { 3537 } else {
3492 error=N71_65_AddCalendar2(s,Entry); 3538 error=N71_65_AddCalendar2(s,Entry);
3493 } 3539 }
3494 } 3540 }
3495 if (error != ERR_NONE) return error; 3541 if (error != ERR_NONE) return error;
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));
3499 if (error != ERR_NONE) return error; 3545 if (error != ERR_NONE) return error;
3500 3546
3501 smprintf(s,"Number of entries: %i %i\n",LastCalendar1.Number,LastCalendar2.Number); 3547 smprintf(s,"Number of entries: %i %i\n",LastCalendar1.Number,LastCalendar2.Number);
3502 3548
3503 for(i=0;i<LastCalendar2.Number;i++) { 3549 for(i=0;i<LastCalendar2.Number;i++) {
3504 found = true; 3550 found = true;
3505 for(j=0;j<LastCalendar1.Number;j++) { 3551 for(j=0;j<LastCalendar1.Number;j++) {
3506 if (LastCalendar1.Location[j] == LastCalendar2.Location[i]) { 3552 if (LastCalendar1.Location[j] == LastCalendar2.Location[i]) {
3507 found = false; 3553 found = false;
3508 break; 3554 break;
3509 } 3555 }
@@ -3728,25 +3774,25 @@ static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus
3728 3774
3729 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { 3775 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
3730 /* Method 1 */ 3776 /* Method 1 */
3731 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); 3777 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
3732 if (error!=ERR_NONE) return error; 3778 if (error!=ERR_NONE) return error;
3733 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3779 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3734 return ERR_NONE; 3780 return ERR_NONE;
3735 3781
3736 /* Method 2 */ 3782 /* Method 2 */
3737 // return ERR_NOTSUPPORTED; 3783 // return ERR_NOTSUPPORTED;
3738 } else { 3784 } else {
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;
3742 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; 3788 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
3743 return ERR_NONE; 3789 return ERR_NONE;
3744 } 3790 }
3745} 3791}
3746 3792
3747static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) 3793static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3748{ 3794{
3749#ifdef GSM_FORCE_DCT4_CALENDAR_6210 3795#ifdef GSM_FORCE_DCT4_CALENDAR_6210
3750 return N71_65_AddCalendar2(s,Note); 3796 return N71_65_AddCalendar2(s,Note);
3751#endif 3797#endif
3752 3798
@@ -3963,24 +4009,60 @@ static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable)
3963 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true); 4009 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true);
3964 } else { 4010 } else {
3965 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false); 4011 error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false);
3966 if (error != ERR_NONE) return error; 4012 if (error != ERR_NONE) return error;
3967 4013
3968 error=N6510_SetLight(s,N6510_LIGHT_TORCH,false); 4014 error=N6510_SetLight(s,N6510_LIGHT_TORCH,false);
3969 if (error != ERR_NONE) return error; 4015 if (error != ERR_NONE) return error;
3970 4016
3971 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false); 4017 return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false);
3972 } 4018 }
3973} 4019}
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)
3976{ 4058{
3977 int acc, i, accx; 4059 int acc, i, accx;
3978 4060
3979 accx = 0; 4061 accx = 0;
3980 acc = 0xffff; 4062 acc = 0xffff;
3981 while (len--) { 4063 while (len--) {
3982 accx = (accx & 0xffff00ff) | (acc & 0xff00); 4064 accx = (accx & 0xffff00ff) | (acc & 0xff00);
3983 acc = (acc & 0xffff00ff) | *ptr++ << 8; 4065 acc = (acc & 0xffff00ff) | *ptr++ << 8;
3984 for (i = 0; i < 8; i++) { 4066 for (i = 0; i < 8; i++) {
3985 acc <<= 1; 4067 acc <<= 1;
3986 if (acc & 0x10000) acc ^= 0x1021; 4068 if (acc & 0x10000) acc ^= 0x1021;
@@ -4046,25 +4128,25 @@ static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_Stat
4046 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05) 4128 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05)
4047 File->Type = GSM_File_Image_GIF; 4129 File->Type = GSM_File_Image_GIF;
4048 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09) 4130 else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09)
4049 File->Type = GSM_File_Image_WBMP; 4131 File->Type = GSM_File_Image_WBMP;
4050 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01) 4132 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01)
4051 File->Type = GSM_File_Sound_AMR; 4133 File->Type = GSM_File_Sound_AMR;
4052 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02) 4134 else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02)
4053 File->Type = GSM_File_Sound_MIDI; 4135 File->Type = GSM_File_Sound_MIDI;
4054 else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05) 4136 else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05)
4055 File->Type = GSM_File_Video_3GP; 4137 File->Type = GSM_File_Video_3GP;
4056 else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01) 4138 else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01)
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)
4060 File->Type = GSM_File_MMS; 4142 File->Type = GSM_File_MMS;
4061#endif 4143#endif
4062 } 4144 }
4063 return ERR_NONE; 4145 return ERR_NONE;
4064 case 0x2F: 4146 case 0x2F:
4065 smprintf(s,"File or folder used bytes received\n"); 4147 smprintf(s,"File or folder used bytes received\n");
4066 File->Used = msg.Buffer[6]*256*256*256+ 4148 File->Used = msg.Buffer[6]*256*256*256+
4067 msg.Buffer[7]*256*256+ 4149 msg.Buffer[7]*256*256+
4068 msg.Buffer[8]*256+ 4150 msg.Buffer[8]*256+
4069 msg.Buffer[9]; 4151 msg.Buffer[9];
4070 return ERR_NONE; 4152 return ERR_NONE;
@@ -4389,25 +4471,25 @@ static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos
4389 0x01, 0x28}; /* length */ 4471 0x01, 0x28}; /* length */
4390 unsigned char end[30] = { 4472 unsigned char end[30] = {
4391 N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01, 4473 N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01,
4392 0x00, 0x04, /* file ID */ 4474 0x00, 0x04, /* file ID */
4393 0x00, 0x00, 0x00, 0x00}; 4475 0x00, 0x00, 0x00, 0x00};
4394 4476
4395 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; 4477 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
4396 4478
4397 s->Phone.Data.File = File; 4479 s->Phone.Data.File = File;
4398 4480
4399 if (*Pos == 0) { 4481 if (*Pos == 0) {
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;
4403 4485
4404 Header[8] = atoi(File->ID_FullName) / 256; 4486 Header[8] = atoi(File->ID_FullName) / 256;
4405 Header[9] = atoi(File->ID_FullName) % 256; 4487 Header[9] = atoi(File->ID_FullName) % 256;
4406 memset(Header+14, 0x00, 300); 4488 memset(Header+14, 0x00, 300);
4407 CopyUnicodeString(Header+14,File->Name); 4489 CopyUnicodeString(Header+14,File->Name);
4408 Header[222] = File->Used / (256*256*256); 4490 Header[222] = File->Used / (256*256*256);
4409 Header[223] = File->Used / (256*256); 4491 Header[223] = File->Used / (256*256);
4410 Header[224] = File->Used / 256; 4492 Header[224] = File->Used / 256;
4411 Header[225] = File->Used % 256; 4493 Header[225] = File->Used % 256;
4412 switch(File->Type) { 4494 switch(File->Type) {
4413 case GSM_File_Image_JPG : Header[231]=0x02; Header[233]=0x01; break; 4495 case GSM_File_Image_JPG : Header[231]=0x02; Header[233]=0x01; break;
@@ -4805,25 +4887,25 @@ static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *statu
4805 error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo); 4887 error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo);
4806 if (error != ERR_NONE) return error; 4888 if (error != ERR_NONE) return error;
4807 4889
4808 status->Used = LastToDo->Number; 4890 status->Used = LastToDo->Number;
4809 return ERR_NONE; 4891 return ERR_NONE;
4810} 4892}
4811 4893
4812static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status) 4894static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status)
4813{ 4895{
4814 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 4896 GSM_NOKIACalToDoLocations*LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
4815 GSM_Error error; 4897 GSM_Error error;
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;
4819 4901
4820 status->Used = LastToDo->Number; 4902 status->Used = LastToDo->Number;
4821 return ERR_NONE; 4903 return ERR_NONE;
4822} 4904}
4823 4905
4824static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 4906static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
4825{ 4907{
4826 status->Used = 0; 4908 status->Used = 0;
4827 4909
4828 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 4910 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
4829 return N6510_GetToDoStatus1(s, status); 4911 return N6510_GetToDoStatus1(s, status);
@@ -4935,26 +5017,25 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine
4935 Date.Minute = msg.Buffer[33]; 5017 Date.Minute = msg.Buffer[33];
4936 Date.Second= 0; 5018 Date.Second= 0;
4937 5019
4938 Last->EntriesNum = 2; 5020 Last->EntriesNum = 2;
4939 5021
4940 if (msg.Buffer[45] == 0x01) { 5022 if (msg.Buffer[45] == 0x01) {
4941 Last->Entries[2].Number = msg.Buffer[45]; 5023 Last->Entries[2].Number = msg.Buffer[45];
4942 Last->Entries[2].EntryType = TODO_COMPLETED; 5024 Last->Entries[2].EntryType = TODO_COMPLETED;
4943 Last->EntriesNum++; 5025 Last->EntriesNum++;
4944 smprintf(s,"Completed\n"); 5026 smprintf(s,"Completed\n");
4945 } 5027 }
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");
4950 } else { 5031 } else {
4951 diff = ((unsigned int)msg.Buffer[14]) << 24; 5032 diff = ((unsigned int)msg.Buffer[14]) << 24;
4952 diff += ((unsigned int)msg.Buffer[15]) << 16; 5033 diff += ((unsigned int)msg.Buffer[15]) << 16;
4953 diff += ((unsigned int)msg.Buffer[16]) << 8; 5034 diff += ((unsigned int)msg.Buffer[16]) << 8;
4954 diff += msg.Buffer[17]; 5035 diff += msg.Buffer[17];
4955 5036
4956 memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime)); 5037 memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime));
4957 GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60); 5038 GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60);
4958 smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n", 5039 smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n",
4959 Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month, 5040 Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month,
4960 Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour, 5041 Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour,
@@ -4969,46 +5050,38 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine
4969 } 5050 }
4970 Last->EntriesNum++; 5051 Last->EntriesNum++;
4971 } 5052 }
4972 5053
4973 return ERR_NONE; 5054 return ERR_NONE;
4974} 5055}
4975 5056
4976/* ToDo support - 6610 style */ 5057/* ToDo support - 6610 style */
4977static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5058static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
4978{ 5059{
4979 GSM_Error error; 5060 GSM_Error error;
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;
4990 ToDo->Location = 1; 5066 ToDo->Location = 1;
4991 } else { 5067 } else {
4992 ToDo->Location++; 5068 ToDo->Location++;
4993 } 5069 }
4994 5070
4995 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY; 5071 if (ToDo->Location > LastToDo->Number) return ERR_EMPTY;
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}
5004 5077
5005static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) 5078static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
5006{ 5079{
5007 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { 5080 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
5008 return N6510_GetNextToDo1(s, ToDo, refresh); 5081 return N6510_GetNextToDo1(s, ToDo, refresh);
5009 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5082 } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5010 return N6510_GetNextToDo2(s, ToDo, refresh); 5083 return N6510_GetNextToDo2(s, ToDo, refresh);
5011 } else { 5084 } else {
5012 return ERR_NOTSUPPORTED; 5085 return ERR_NOTSUPPORTED;
5013 } 5086 }
5014} 5087}
@@ -5034,25 +5107,25 @@ static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s)
5034} 5107}
5035 5108
5036static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 5109static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
5037{ 5110{
5038 GSM_Error error; 5111 GSM_Error error;
5039 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; 5112 GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
5040 GSM_CalendarEntry Note; 5113 GSM_CalendarEntry Note;
5041 5114
5042 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { 5115 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
5043 return ERR_NOTSUPPORTED; 5116 return ERR_NOTSUPPORTED;
5044 } 5117 }
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;
5048 5121
5049 smprintf(s, "Deleting ToDo method 2\n"); 5122 smprintf(s, "Deleting ToDo method 2\n");
5050 5123
5051 if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION; 5124 if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION;
5052 5125
5053 Note.Location = LastToDo->Location[ToDo->Location-1]; 5126 Note.Location = LastToDo->Location[ToDo->Location-1];
5054 return N71_65_DelCalendar(s,&Note); 5127 return N71_65_DelCalendar(s,&Note);
5055} 5128}
5056 5129
5057/* ToDo support - 6310 style */ 5130/* ToDo support - 6310 style */
5058static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s) 5131static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -5442,31 +5515,37 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5442 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame }, 5515 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
5443 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame }, 5516 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
5444 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame }, 5517 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
5445 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame }, 5518 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
5446 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall }, 5519 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
5447 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame }, 5520 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
5448 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall }, 5521 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
5449 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame }, 5522 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
5450 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame }, 5523 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
5451 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame }, 5524 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
5452 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice }, 5525 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice },
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 },
5455 {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame }, 5531 {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
5456 {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame }, 5532 {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
5457 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF }, 5533 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
5458 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame }, 5534 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
5459 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF }, 5535 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
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
5462 {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame }, 5541 {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
5463 {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame }, 5542 {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame },
5464 {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC }, 5543 {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC },
5465 {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC }, 5544 {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC },
5466 5545
5467 {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, 5546 {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
5468 {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, 5547 {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
5469 {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory }, 5548 {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
5470 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap }, 5549 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
5471 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory }, 5550 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
5472 5551
@@ -5499,31 +5578,33 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5499 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote }, 5578 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
5500 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ 5579 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
5501 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/ 5580 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
5502 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ 5581 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
5503#ifdef DEBUG 5582#ifdef DEBUG
5504 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote }, 5583 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },
5505#endif 5584#endif
5506 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/ 5585 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
5507 {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/ 5586 {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/
5508 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo }, 5587 {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo },
5509 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/ 5588 {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/
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 },
5512 {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale }, 5592 {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale },
5513 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings }, 5593 {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings },
5514 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/ 5594 {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/
5515 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo }, 5595 {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo },
5516 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/ 5596 {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/
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
5519 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage }, 5600 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage },
5520 {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap }, 5601 {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap },
5521 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage }, 5602 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage },
5522 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage }, 5603 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage },
5523 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage }, 5604 {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage },
5524 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus }, 5605 {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus },
5525 {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus }, 5606 {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus },
5526 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage }, 5607 {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage },
5527 {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder }, 5608 {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder },
5528 {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders }, 5609 {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders },
5529 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage }, 5610 {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage },
@@ -5642,25 +5723,25 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
5642 5723
5643 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, 5724 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
5644 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, 5725 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
5645 5726
5646 /* 0xD7 - Bluetooth */ 5727 /* 0xD7 - Bluetooth */
5647 5728
5648 {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone }, 5729 {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone },
5649 5730
5650 {NULL, "\x00",0x00,0x00,ID_None } 5731 {NULL, "\x00",0x00,0x00,ID_None }
5651}; 5732};
5652 5733
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,
5656 N6510_Initialise, 5737 N6510_Initialise,
5657 NONEFUNCTION, /* Terminate */ 5738 NONEFUNCTION, /* Terminate */
5658 GSM_DispatchMessage, 5739 GSM_DispatchMessage,
5659 N6510_ShowStartInfo, 5740 N6510_ShowStartInfo,
5660 NOKIA_GetManufacturer, 5741 NOKIA_GetManufacturer,
5661 DCT3DCT4_GetModel, 5742 DCT3DCT4_GetModel,
5662 DCT3DCT4_GetFirmware, 5743 DCT3DCT4_GetFirmware,
5663 DCT4_GetIMEI, 5744 DCT4_GetIMEI,
5664 N6510_GetOriginalIMEI, 5745 N6510_GetOriginalIMEI,
5665 N6510_GetManufactureMonth, 5746 N6510_GetManufactureMonth,
5666 DCT4_GetProductCode, 5747 DCT4_GetProductCode,
@@ -5696,24 +5777,25 @@ GSM_Phone_Functions N6510Phone = {
5696 N6510_GetSpeedDial, 5777 N6510_GetSpeedDial,
5697 NOTIMPLEMENTED, /* SetSpeedDial */ 5778 NOTIMPLEMENTED, /* SetSpeedDial */
5698 N6510_GetSMSC, 5779 N6510_GetSMSC,
5699 N6510_SetSMSC, 5780 N6510_SetSMSC,
5700 N6510_GetSMSStatus, 5781 N6510_GetSMSStatus,
5701 N6510_GetSMSMessage, 5782 N6510_GetSMSMessage,
5702 N6510_GetNextSMSMessage, 5783 N6510_GetNextSMSMessage,
5703 N6510_SetSMS, 5784 N6510_SetSMS,
5704 N6510_AddSMS, 5785 N6510_AddSMS,
5705 N6510_DeleteSMSMessage, 5786 N6510_DeleteSMSMessage,
5706 N6510_SendSMSMessage, 5787 N6510_SendSMSMessage,
5707 NOTSUPPORTED, /* SendSavedSMS */ 5788 NOTSUPPORTED, /* SendSavedSMS */
5789 NOTSUPPORTED, /* SetFastSMSSending*/
5708 NOKIA_SetIncomingSMS, 5790 NOKIA_SetIncomingSMS,
5709 NOTIMPLEMENTED, /* SetIncomingCB */ 5791 NOTIMPLEMENTED, /* SetIncomingCB */
5710 N6510_GetSMSFolders, 5792 N6510_GetSMSFolders,
5711 N6510_AddSMSFolder, 5793 N6510_AddSMSFolder,
5712 NOTIMPLEMENTED, /* DeleteSMSFolder */ 5794 NOTIMPLEMENTED, /* DeleteSMSFolder */
5713 N6510_DialVoice, 5795 N6510_DialVoice,
5714 N6510_AnswerCall, 5796 N6510_AnswerCall,
5715 N6510_CancelCall, 5797 N6510_CancelCall,
5716 NOTIMPLEMENTED, /* HoldCall */ 5798 NOTIMPLEMENTED, /* HoldCall */
5717 NOTIMPLEMENTED, /* UnholdCall */ 5799 NOTIMPLEMENTED, /* UnholdCall */
5718 NOTIMPLEMENTED, /* ConferenceCall */ 5800 NOTIMPLEMENTED, /* ConferenceCall */
5719 NOTIMPLEMENTED, /* SplitCall */ 5801 NOTIMPLEMENTED, /* SplitCall */
@@ -5750,25 +5832,25 @@ GSM_Phone_Functions N6510Phone = {
5750 N6510_AddToDo, 5832 N6510_AddToDo,
5751 N6510_DeleteToDo2, 5833 N6510_DeleteToDo2,
5752 N6510_DeleteAllToDo1, 5834 N6510_DeleteAllToDo1,
5753 N6510_GetCalendarStatus, 5835 N6510_GetCalendarStatus,
5754 NOTIMPLEMENTED, /* GetCalendar */ 5836 NOTIMPLEMENTED, /* GetCalendar */
5755 N6510_GetNextCalendar, 5837 N6510_GetNextCalendar,
5756 NOTIMPLEMENTED, /* SetCalendar */ 5838 NOTIMPLEMENTED, /* SetCalendar */
5757 N6510_AddCalendar, 5839 N6510_AddCalendar,
5758 N71_65_DelCalendar, 5840 N71_65_DelCalendar,
5759 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 5841 NOTIMPLEMENTED, /* DeleteAllCalendar*/
5760 N6510_GetCalendarSettings, 5842 N6510_GetCalendarSettings,
5761 NOTSUPPORTED, /* SetCalendarSettings*/ 5843 NOTSUPPORTED, /* SetCalendarSettings*/
5762 NOTIMPLEMENTED, /* GetNote */ 5844 N6510_GetNextNote,
5763 N6510_GetProfile, 5845 N6510_GetProfile,
5764 N6510_SetProfile, 5846 N6510_SetProfile,
5765 N6510_GetFMStation, 5847 N6510_GetFMStation,
5766 N6510_SetFMStation, 5848 N6510_SetFMStation,
5767 N6510_ClearFMStations, 5849 N6510_ClearFMStations,
5768 N6510_GetNextFileFolder, 5850 N6510_GetNextFileFolder,
5769 N6510_GetFilePart, 5851 N6510_GetFilePart,
5770 N6510_AddFilePart, 5852 N6510_AddFilePart,
5771 N6510_GetFileSystemStatus, 5853 N6510_GetFileSystemStatus,
5772 N6510_DeleteFile, 5854 N6510_DeleteFile,
5773 N6510_AddFolder, 5855 N6510_AddFolder,
5774 N6510_GetGPRSAccessPoint, 5856 N6510_GetGPRSAccessPoint,
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
@@ -25,24 +25,26 @@ typedef struct {
25 int LastCalendarPos; 25 int LastCalendarPos;
26 GSM_NOKIACalToDoLocationsLastCalendar; 26 GSM_NOKIACalToDoLocationsLastCalendar;
27 int FirstCalendarPos; 27 int FirstCalendarPos;
28 unsigned char CalendarIcons[10]; 28 unsigned char CalendarIcons[10];
29 GSM_CalendarNoteType CalendarIconsTypes[10]; 29 GSM_CalendarNoteType CalendarIconsTypes[10];
30 int CalendarIconsNum; 30 int CalendarIconsNum;
31 31
32 GSM_NOKIASMSFolder LastSMSFolder; 32 GSM_NOKIASMSFolder LastSMSFolder;
33 GSM_SMSFolders LastSMSFolders; 33 GSM_SMSFolders LastSMSFolders;
34 34
35 GSM_NOKIACalToDoLocationsLastToDo; 35 GSM_NOKIACalToDoLocationsLastToDo;
36 36
37 GSM_NOKIACalToDoLocationsLastNote;
38
37 unsigned char RingtoneID;/* When set with preview */ 39 unsigned char RingtoneID;/* When set with preview */
38 40
39 int FilesLocations[1000]; 41 int FilesLocations[1000];
40 int FilesLevels[1000]; 42 int FilesLevels[1000];
41 int FilesLocationsUsed; 43 int FilesLocationsUsed;
42 int FilesLocationsCurrent; 44 int FilesLocationsCurrent;
43 int FileToken; 45 int FileToken;
44 int ParentID; 46 int ParentID;
45 int FileCheckSum; 47 int FileCheckSum;
46 48
47 unsigned char FMStatus[4000]; 49 unsigned char FMStatus[4000];
48 int FMStatusLength; 50 int FMStatusLength;
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
@@ -112,25 +112,25 @@ GSM_Phone_Functions NAUTOPhone = {
112 NOTSUPPORTED, /* AddToDo */ 112 NOTSUPPORTED, /* AddToDo */
113 NOTSUPPORTED, /* DeleteToDo */ 113 NOTSUPPORTED, /* DeleteToDo */
114 NOTSUPPORTED, /* DeleteAllToDo */ 114 NOTSUPPORTED, /* DeleteAllToDo */
115 NOTSUPPORTED, /* GetCalendarStatus*/ 115 NOTSUPPORTED, /* GetCalendarStatus*/
116 NOTSUPPORTED, /* GetCalendar */ 116 NOTSUPPORTED, /* GetCalendar */
117 NOTSUPPORTED, /* GetNextCalendar */ 117 NOTSUPPORTED, /* GetNextCalendar */
118 NOTSUPPORTED, /* SetCalendar */ 118 NOTSUPPORTED, /* SetCalendar */
119 NOTSUPPORTED, /* AddCalendar */ 119 NOTSUPPORTED, /* AddCalendar */
120 NOTSUPPORTED, /* DeleteCalendar */ 120 NOTSUPPORTED, /* DeleteCalendar */
121 NOTSUPPORTED, /* DeleteAllCalendar*/ 121 NOTSUPPORTED, /* DeleteAllCalendar*/
122 NOTSUPPORTED, /* GetCalendarSettings*/ 122 NOTSUPPORTED, /* GetCalendarSettings*/
123 NOTSUPPORTED, /* SetCalendarSettings*/ 123 NOTSUPPORTED, /* SetCalendarSettings*/
124 NOTSUPPORTED, /* GetNote */ 124 NOTSUPPORTED, /* GetNextNote */
125 NOTSUPPORTED, /* GetProfile */ 125 NOTSUPPORTED, /* GetProfile */
126 NOTSUPPORTED, /* SetProfile */ 126 NOTSUPPORTED, /* SetProfile */
127 NOTSUPPORTED, /* GetFMStation */ 127 NOTSUPPORTED, /* GetFMStation */
128 NOTSUPPORTED, /* SetFMStation */ 128 NOTSUPPORTED, /* SetFMStation */
129 NOTSUPPORTED, /* ClearFMStations */ 129 NOTSUPPORTED, /* ClearFMStations */
130 NOTSUPPORTED, /* GetNextFileFolder*/ 130 NOTSUPPORTED, /* GetNextFileFolder*/
131 NOTSUPPORTED, /* GetFilePart */ 131 NOTSUPPORTED, /* GetFilePart */
132 NOTSUPPORTED, /* AddFilePart */ 132 NOTSUPPORTED, /* AddFilePart */
133 NOTSUPPORTED, /* GetFileSystemStatus*/ 133 NOTSUPPORTED, /* GetFileSystemStatus*/
134 NOTSUPPORTED, /* DeleteFile */ 134 NOTSUPPORTED, /* DeleteFile */
135 NOTSUPPORTED, /* AddFolder */ 135 NOTSUPPORTED, /* AddFolder */
136 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 136 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -1384,53 +1384,67 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1384 smprintf(s, "Call is being released\n"); 1384 smprintf(s, "Call is being released\n");
1385 break; 1385 break;
1386 case 0x0b: 1386 case 0x0b:
1387 smprintf(s, "Meaning not known\n"); 1387 smprintf(s, "Meaning not known\n");
1388 call.CallIDAvailable = false; 1388 call.CallIDAvailable = false;
1389 break; 1389 break;
1390 case 0x0c: 1390 case 0x0c:
1391 smprintf(s, "Audio status\n"); 1391 smprintf(s, "Audio status\n");
1392 if (msg.Buffer[4] == 0x01) smprintf(s, "Audio enabled\n"); 1392 if (msg.Buffer[4] == 0x01) smprintf(s, "Audio enabled\n");
1393 else smprintf(s, "Audio disabled\n"); 1393 else smprintf(s, "Audio disabled\n");
1394 call.CallIDAvailable = false; 1394 call.CallIDAvailable = false;
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:
1397 smprintf(s, "Call held\n"); 1402 smprintf(s, "Call held\n");
1398 call.Status = GSM_CALL_CallHeld; 1403 call.Status = GSM_CALL_CallHeld;
1399 break; 1404 break;
1400 case 0x25: 1405 case 0x25:
1401 smprintf(s, "Call resumed\n"); 1406 smprintf(s, "Call resumed\n");
1402 call.Status = GSM_CALL_CallResumed; 1407 call.Status = GSM_CALL_CallResumed;
1403 break; 1408 break;
1404 case 0x27: 1409 case 0x27:
1405 smprintf(s, "Call switched\n"); 1410 smprintf(s, "Call switched\n");
1406 call.Status = GSM_CALL_CallSwitched; 1411 call.Status = GSM_CALL_CallSwitched;
1407 break; 1412 break;
1408 case 0x53: 1413 case 0x53:
1409 smprintf(s, "Outgoing call\n"); 1414 smprintf(s, "Outgoing call\n");
1410 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii 1415 smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
1411 tmp = 6; 1416 tmp = 6;
1412 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); 1417 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false);
1413 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); 1418 smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer));
1414 /* FIXME: read name from frame */ 1419 /* FIXME: read name from frame */
1415 call.Status = GSM_CALL_OutgoingCall; 1420 call.Status = GSM_CALL_OutgoingCall;
1416 tmp = 6; 1421 tmp = 6;
1417 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false); 1422 NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false);
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 }
1420 if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]); 1431 if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]);
1421 if (s->Phone.Data.EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) { 1432 if (s->Phone.Data.EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) {
1422 if (call.CallIDAvailable) call.CallID = msg.Buffer[4]; 1433 if (call.CallIDAvailable) call.CallID = msg.Buffer[4];
1423 s->User.IncomingCall(s->CurrentConfig->Device, call); 1434 s->User.IncomingCall(s->CurrentConfig->Device, call);
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) {
1426 if (msg.Buffer[3] == 0x09) { 1440 if (msg.Buffer[3] == 0x09) {
1427 if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE; 1441 if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
1428 /* when we canceled call and see frame about other 1442 /* when we canceled call and see frame about other
1429 * call releasing, we don't give ERR_NONE for "our" 1443 * call releasing, we don't give ERR_NONE for "our"
1430 * call release command 1444 * call release command
1431 */ 1445 */
1432 return ERR_NEEDANOTHERANSWER; 1446 return ERR_NEEDANOTHERANSWER;
1433 } 1447 }
1434 } 1448 }
1435 if (s->Phone.Data.RequestID == ID_AnswerCall) { 1449 if (s->Phone.Data.RequestID == ID_AnswerCall) {
1436 if (msg.Buffer[3] == 0x07) { 1450 if (msg.Buffer[3] == 0x07) {
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
@@ -765,24 +765,25 @@ GSM_Phone_Functions OBEXGENPhone = {
765 NOTIMPLEMENTED, /* GetSpeedDial */ 765 NOTIMPLEMENTED, /* GetSpeedDial */
766 NOTIMPLEMENTED, /* SetSpeedDial */ 766 NOTIMPLEMENTED, /* SetSpeedDial */
767 NOTIMPLEMENTED, /* GetSMSC */ 767 NOTIMPLEMENTED, /* GetSMSC */
768 NOTIMPLEMENTED, /* SetSMSC */ 768 NOTIMPLEMENTED, /* SetSMSC */
769 NOTIMPLEMENTED, /* GetSMSStatus */ 769 NOTIMPLEMENTED, /* GetSMSStatus */
770 NOTIMPLEMENTED, /* GetSMS */ 770 NOTIMPLEMENTED, /* GetSMS */
771 NOTIMPLEMENTED, /* GetNextSMS */ 771 NOTIMPLEMENTED, /* GetNextSMS */
772 NOTIMPLEMENTED, /* SetSMS */ 772 NOTIMPLEMENTED, /* SetSMS */
773 NOTIMPLEMENTED, /* AddSMS */ 773 NOTIMPLEMENTED, /* AddSMS */
774 NOTIMPLEMENTED, /* DeleteSMS */ 774 NOTIMPLEMENTED, /* DeleteSMS */
775 NOTIMPLEMENTED, /* SendSMSMessage */ 775 NOTIMPLEMENTED, /* SendSMSMessage */
776 NOTSUPPORTED, /* SendSavedSMS */ 776 NOTSUPPORTED, /* SendSavedSMS */
777 NOTSUPPORTED, /* SetFastSMSSending*/
777 NOTIMPLEMENTED, /* SetIncomingSMS */ 778 NOTIMPLEMENTED, /* SetIncomingSMS */
778 NOTIMPLEMENTED, /* SetIncomingCB */ 779 NOTIMPLEMENTED, /* SetIncomingCB */
779 NOTIMPLEMENTED, /* GetSMSFolders */ 780 NOTIMPLEMENTED, /* GetSMSFolders */
780 NOTIMPLEMENTED, /* AddSMSFolder */ 781 NOTIMPLEMENTED, /* AddSMSFolder */
781 NOTIMPLEMENTED, /* DeleteSMSFolder */ 782 NOTIMPLEMENTED, /* DeleteSMSFolder */
782 NOTIMPLEMENTED, /* DialVoice */ 783 NOTIMPLEMENTED, /* DialVoice */
783 NOTIMPLEMENTED, /* AnswerCall */ 784 NOTIMPLEMENTED, /* AnswerCall */
784 NOTIMPLEMENTED, /* CancelCall */ 785 NOTIMPLEMENTED, /* CancelCall */
785 NOTIMPLEMENTED, /* HoldCall */ 786 NOTIMPLEMENTED, /* HoldCall */
786 NOTIMPLEMENTED, /* UnholdCall */ 787 NOTIMPLEMENTED, /* UnholdCall */
787 NOTIMPLEMENTED, /* ConferenceCall */ 788 NOTIMPLEMENTED, /* ConferenceCall */
788 NOTIMPLEMENTED, /* SplitCall */ 789 NOTIMPLEMENTED, /* SplitCall */
@@ -819,25 +820,25 @@ GSM_Phone_Functions OBEXGENPhone = {
819 NOTIMPLEMENTED, /* AddToDo */ 820 NOTIMPLEMENTED, /* AddToDo */
820 NOTIMPLEMENTED, /* DeleteToDo */ 821 NOTIMPLEMENTED, /* DeleteToDo */
821 NOTIMPLEMENTED, /* DeleteAllToDo */ 822 NOTIMPLEMENTED, /* DeleteAllToDo */
822 NOTIMPLEMENTED, /* GetCalendarStatus*/ 823 NOTIMPLEMENTED, /* GetCalendarStatus*/
823 NOTIMPLEMENTED, /* GetCalendar */ 824 NOTIMPLEMENTED, /* GetCalendar */
824 NOTIMPLEMENTED, /* GetNextCalendar */ 825 NOTIMPLEMENTED, /* GetNextCalendar */
825 NOTIMPLEMENTED, /* SetCalendar */ 826 NOTIMPLEMENTED, /* SetCalendar */
826 NOTIMPLEMENTED, /* AddCalendar */ 827 NOTIMPLEMENTED, /* AddCalendar */
827 NOTIMPLEMENTED, /* DeleteCalendar */ 828 NOTIMPLEMENTED, /* DeleteCalendar */
828 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 829 NOTIMPLEMENTED, /* DeleteAllCalendar*/
829 NOTSUPPORTED, /* GetCalendarSettings*/ 830 NOTSUPPORTED, /* GetCalendarSettings*/
830 NOTSUPPORTED, /* SetCalendarSettings*/ 831 NOTSUPPORTED, /* SetCalendarSettings*/
831 NOTSUPPORTED, /* GetNote */ 832 NOTSUPPORTED, /* GetNextNote */
832 NOTIMPLEMENTED, /* GetProfile */ 833 NOTIMPLEMENTED, /* GetProfile */
833 NOTIMPLEMENTED, /* SetProfile */ 834 NOTIMPLEMENTED, /* SetProfile */
834 NOTIMPLEMENTED, /* GetFMStation */ 835 NOTIMPLEMENTED, /* GetFMStation */
835 NOTIMPLEMENTED, /* SetFMStation */ 836 NOTIMPLEMENTED, /* SetFMStation */
836 NOTIMPLEMENTED, /* ClearFMStations */ 837 NOTIMPLEMENTED, /* ClearFMStations */
837 OBEXGEN_GetNextFileFolder, 838 OBEXGEN_GetNextFileFolder,
838 OBEXGEN_GetFilePart, 839 OBEXGEN_GetFilePart,
839 OBEXGEN_AddFilePart, 840 OBEXGEN_AddFilePart,
840 NOTIMPLEMENTED, /* GetFileSystemStatus*/ 841 NOTIMPLEMENTED, /* GetFileSystemStatus*/
841 OBEXGEN_DeleteFile, 842 OBEXGEN_DeleteFile,
842 OBEXGEN_AddFolder, 843 OBEXGEN_AddFolder,
843 NOTIMPLEMENTED, /* GetGPRSAccessPoint*/ 844 NOTIMPLEMENTED, /* GetGPRSAccessPoint*/
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
@@ -22,17 +22,21 @@ typedef enum {
22 22
23typedef struct { 23typedef struct {
24 int FileLev; 24 int FileLev;
25 int FilesLocationsUsed; 25 int FilesLocationsUsed;
26 int FilesLocationsCurrent; 26 int FilesLocationsCurrent;
27 GSM_File Files[500]; 27 GSM_File Files[500];
28 bool FileLastPart; 28 bool FileLastPart;
29 29
30 int FrameSize; 30 int FrameSize;
31 OBEX_Service Service; 31 OBEX_Service Service;
32} GSM_Phone_OBEXGENData; 32} GSM_Phone_OBEXGENData;
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
35 39
36/* How should editor hadle tabs in this file? Add editor commands here. 40/* How should editor hadle tabs in this file? Add editor commands here.
37 * vim: noexpandtab sw=8 ts=8 sts=8: 41 * vim: noexpandtab sw=8 ts=8 sts=8:
38 */ 42 */
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
@@ -134,24 +134,25 @@ GSM_Phone_Functions MROUTERGENPhone = {
134 NOTSUPPORTED, /* GetSpeedDial */ 134 NOTSUPPORTED, /* GetSpeedDial */
135 NOTSUPPORTED, /* SetSpeedDial */ 135 NOTSUPPORTED, /* SetSpeedDial */
136 NOTSUPPORTED, /* GetSMSC */ 136 NOTSUPPORTED, /* GetSMSC */
137 NOTSUPPORTED, /* SetSMSC */ 137 NOTSUPPORTED, /* SetSMSC */
138 NOTSUPPORTED, /* GetSMSStatus */ 138 NOTSUPPORTED, /* GetSMSStatus */
139 NOTSUPPORTED, /* GetSMS */ 139 NOTSUPPORTED, /* GetSMS */
140 NOTSUPPORTED, /* GetNextSMS */ 140 NOTSUPPORTED, /* GetNextSMS */
141 NOTSUPPORTED, /* SetSMS */ 141 NOTSUPPORTED, /* SetSMS */
142 NOTSUPPORTED, /* AddSMS */ 142 NOTSUPPORTED, /* AddSMS */
143 NOTSUPPORTED, /* DeleteSMS */ 143 NOTSUPPORTED, /* DeleteSMS */
144 NOTSUPPORTED, /* SendSMSMessage */ 144 NOTSUPPORTED, /* SendSMSMessage */
145 NOTSUPPORTED, /* SendSavedSMS */ 145 NOTSUPPORTED, /* SendSavedSMS */
146 NOTSUPPORTED, /* SetFastSMSSending*/
146 NOTSUPPORTED, /* SetIncomingSMS */ 147 NOTSUPPORTED, /* SetIncomingSMS */
147 NOTSUPPORTED, /* SetIncomingCB */ 148 NOTSUPPORTED, /* SetIncomingCB */
148 NOTSUPPORTED, /* GetSMSFolders */ 149 NOTSUPPORTED, /* GetSMSFolders */
149 NOTSUPPORTED, /* AddSMSFolder */ 150 NOTSUPPORTED, /* AddSMSFolder */
150 NOTSUPPORTED, /* DeleteSMSFolder */ 151 NOTSUPPORTED, /* DeleteSMSFolder */
151 NOTSUPPORTED, /* DialVoice */ 152 NOTSUPPORTED, /* DialVoice */
152 NOTSUPPORTED, /* AnswerCall */ 153 NOTSUPPORTED, /* AnswerCall */
153 NOTSUPPORTED, /* CancelCall */ 154 NOTSUPPORTED, /* CancelCall */
154 NOTSUPPORTED, /* HoldCall */ 155 NOTSUPPORTED, /* HoldCall */
155 NOTSUPPORTED, /* UnholdCall */ 156 NOTSUPPORTED, /* UnholdCall */
156 NOTSUPPORTED, /* ConferenceCall */ 157 NOTSUPPORTED, /* ConferenceCall */
157 NOTSUPPORTED, /* SplitCall */ 158 NOTSUPPORTED, /* SplitCall */
@@ -188,25 +189,25 @@ GSM_Phone_Functions MROUTERGENPhone = {
188 NOTSUPPORTED, /* AddToDo */ 189 NOTSUPPORTED, /* AddToDo */
189 NOTSUPPORTED, /* DeleteToDo */ 190 NOTSUPPORTED, /* DeleteToDo */
190 NOTSUPPORTED, /* DeleteAllToDo */ 191 NOTSUPPORTED, /* DeleteAllToDo */
191 NOTSUPPORTED, /* GetCalendarStatus*/ 192 NOTSUPPORTED, /* GetCalendarStatus*/
192 NOTSUPPORTED, /* GetCalendar */ 193 NOTSUPPORTED, /* GetCalendar */
193 NOTSUPPORTED, /* GetNextCalendar */ 194 NOTSUPPORTED, /* GetNextCalendar */
194 NOTSUPPORTED, /* SetCalendar */ 195 NOTSUPPORTED, /* SetCalendar */
195 NOTSUPPORTED, /* AddCalendar */ 196 NOTSUPPORTED, /* AddCalendar */
196 NOTSUPPORTED, /* DeleteCalendar */ 197 NOTSUPPORTED, /* DeleteCalendar */
197 NOTSUPPORTED, /* DeleteAllCalendar*/ 198 NOTSUPPORTED, /* DeleteAllCalendar*/
198 NOTSUPPORTED, /* GetCalendarSettings*/ 199 NOTSUPPORTED, /* GetCalendarSettings*/
199 NOTSUPPORTED, /* SetCalendarSettings*/ 200 NOTSUPPORTED, /* SetCalendarSettings*/
200 NOTSUPPORTED, /* GetNote */ 201 NOTSUPPORTED, /* GetNextNote */
201 NOTSUPPORTED, /* GetProfile */ 202 NOTSUPPORTED, /* GetProfile */
202 NOTSUPPORTED, /* SetProfile */ 203 NOTSUPPORTED, /* SetProfile */
203 NOTSUPPORTED, /* GetFMStation */ 204 NOTSUPPORTED, /* GetFMStation */
204 NOTSUPPORTED, /* SetFMStation */ 205 NOTSUPPORTED, /* SetFMStation */
205 NOTSUPPORTED, /* ClearFMStations */ 206 NOTSUPPORTED, /* ClearFMStations */
206 NOTSUPPORTED, /* GetNextFileFolder*/ 207 NOTSUPPORTED, /* GetNextFileFolder*/
207 NOTSUPPORTED, /* GetFilePart */ 208 NOTSUPPORTED, /* GetFilePart */
208 NOTSUPPORTED, /* AddFilePart */ 209 NOTSUPPORTED, /* AddFilePart */
209 NOTSUPPORTED, /* GetFileSystemStatus*/ 210 NOTSUPPORTED, /* GetFileSystemStatus*/
210 NOTSUPPORTED, /* DeleteFile */ 211 NOTSUPPORTED, /* DeleteFile */
211 NOTSUPPORTED, /* AddFolder */ 212 NOTSUPPORTED, /* AddFolder */
212 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 213 NOTSUPPORTED, /* GetGPRSAccessPoint*/
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
@@ -57,32 +57,36 @@ static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
57 "+CPIN: " ,/*A2D issue*/ 57 "+CPIN: " ,/*A2D issue*/
58 58
59 NULL}; 59 NULL};
60 60
61 /* Some info from phone can be inside "normal" answers 61 /* Some info from phone can be inside "normal" answers
62 * It starts with strings written here 62 * It starts with strings written here
63 */ 63 */
64 static SpecialAnswersStructSpecialAnswers[] = { 64 static SpecialAnswersStructSpecialAnswers[] = {
65 {"_OSIGQ:" ,1}, {"_OBS:",1}, 65 {"_OSIGQ:" ,1}, {"_OBS:",1},
66 {"^SCN:" ,1}, {"+CGREG:",1}, 66 {"^SCN:" ,1}, {"+CGREG:",1},
67 {"+CBM:" ,1}, {"+CMT:",2}, 67 {"+CBM:" ,1}, {"+CMT:",2},
68 {"+CMTI:" ,1}, {"+CDS:",2}, 68 {"+CMTI:" ,1}, {"+CDS:",2},
69 {"+CREG:",1}, 69 {"+CREG:" ,1}, {"+CUSD",1},
70 70
71 {"RING" ,1}, {"NO CARRIER",1}, 71 {"RING" ,1}, {"NO CARRIER",1},
72 {"NO ANSWER" ,1}, {"+COLP",1}, 72 {"NO ANSWER" ,1}, {"+COLP",1},
73 {"+CLIP",1}, 73 {"+CLIP",1},
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 */
78 if (d->Msg.Length == 0) { 82 if (d->Msg.Length == 0) {
79 if (rx_char == 10 || rx_char == 13 || rx_char == 27) return ERR_NONE; 83 if (rx_char == 10 || rx_char == 13 || rx_char == 27) return ERR_NONE;
80 d->LineStart = d->Msg.Length; 84 d->LineStart = d->Msg.Length;
81 } 85 }
82 86
83 if (d->Msg.BufferUsed < d->Msg.Length + 2) { 87 if (d->Msg.BufferUsed < d->Msg.Length + 2) {
84 d->Msg.BufferUsed= d->Msg.Length + 2; 88 d->Msg.BufferUsed= d->Msg.Length + 2;
85 d->Msg.Buffer = (unsigned char *)realloc(d->Msg.Buffer,d->Msg.BufferUsed); 89 d->Msg.Buffer = (unsigned char *)realloc(d->Msg.Buffer,d->Msg.BufferUsed);
86 } 90 }
87 d->Msg.Buffer[d->Msg.Length++] = rx_char; 91 d->Msg.Buffer[d->Msg.Length++] = rx_char;
88 d->Msg.Buffer[d->Msg.Length ] = 0; 92 d->Msg.Buffer[d->Msg.Length ] = 0;
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,14 +1,18 @@
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
4#include "../../gsmstate.h" 8#include "../../gsmstate.h"
5 9
6#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) 10#if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303)
7 11
8#include <stdio.h> 12#include <stdio.h>
9#include <string.h> 13#include <string.h>
10 14
11#include "../../gsmcomon.h" 15#include "../../gsmcomon.h"
12#include "fbus2.h" 16#include "fbus2.h"
13 17
14 static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s, 18 static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s,
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,14 +1,18 @@
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
4#ifndef fbus2_h 8#ifndef fbus2_h
5#define fbus2_h 9#define fbus2_h
6 10
7#include "../protocol.h" 11#include "../protocol.h"
8 12
9 #define FBUS2_FRAME_ID 0x1e 13 #define FBUS2_FRAME_ID 0x1e
10 #define FBUS2_IRDA_FRAME_ID 0x1c 14 #define FBUS2_IRDA_FRAME_ID 0x1c
11 #define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ 15 #define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */
12 #define FBUS2_DEVICE_PC 0x0c /* Our PC */ 16 #define FBUS2_DEVICE_PC 0x0c /* Our PC */
13 #define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ 17 #define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */
14 18
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,14 +1,14 @@
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
4#include "../../gsmstate.h" 4#include "../../gsmstate.h"
5 5
6#ifdef GSM_ENABLE_MBUS2 6#ifdef GSM_ENABLE_MBUS2
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <string.h> 9#include <string.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "mbus2.h" 12#include "mbus2.h"
13 13
14 static GSM_Error MBUS2_WriteMessage (GSM_StateMachine *s, 14 static GSM_Error MBUS2_WriteMessage (GSM_StateMachine *s,
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,14 +1,14 @@
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
4#ifndef mbus2_h 4#ifndef mbus2_h
5#define mbus2_h 5#define mbus2_h
6 6
7#include "../protocol.h" 7#include "../protocol.h"
8 8
9#define MBUS2_FRAME_ID 0x1f 9#define MBUS2_FRAME_ID 0x1f
10#define MBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */ 10#define MBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */
11#define MBUS2_DEVICE_PC 0x10 /* Our PC (MBUS) */ 11#define MBUS2_DEVICE_PC 0x10 /* Our PC (MBUS) */
12 #define MBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */ 12 #define MBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */
13 13
14typedef struct { 14typedef struct {
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,14 +1,17 @@
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
4#include "../../gsmstate.h" 7#include "../../gsmstate.h"
5 8
6#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET) 9#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET)
7 10
8#include <stdio.h> 11#include <stdio.h>
9#include <string.h> 12#include <string.h>
10 13
11#include "../../gsmcomon.h" 14#include "../../gsmcomon.h"
12#include "phonet.h" 15#include "phonet.h"
13 16
14 static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s, 17 static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s,
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,14 +1,17 @@
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
4#ifndef PHONET_h 7#ifndef PHONET_h
5#define PHONET_h 8#define PHONET_h
6 9
7#include "../protocol.h" 10#include "../protocol.h"
8 11
9 #define PHONET_FRAME_ID 0x14 12 #define PHONET_FRAME_ID 0x14
10 #define PHONET_BLUE_FRAME_ID0x19 13 #define PHONET_BLUE_FRAME_ID0x19
11 #define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */ 14 #define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */
12 #define PHONET_DEVICE_PC 0x0c /* Our PC */ 15 #define PHONET_DEVICE_PC 0x0c /* Our PC */
13#define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */ 16#define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */
14 17
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
@@ -12,46 +12,50 @@
12#include "../gsmdata.h" 12#include "../gsmdata.h"
13#include "../gsmprof.h" 13#include "../gsmprof.h"
14#include "../gsmmisc.h" 14#include "../gsmmisc.h"
15#include "../sms/gsmsms.h" 15#include "../sms/gsmsms.h"
16 16
17 #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501 17 #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501
18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251 18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251
19 #define GSM_BACKUP_MAX_CALLER 6 19 #define GSM_BACKUP_MAX_CALLER 6
20 #define GSM_BACKUP_MAX_SMSC 10 20 #define GSM_BACKUP_MAX_SMSC 10
21 #define GSM_BACKUP_MAX_WAPBOOKMARK40 21 #define GSM_BACKUP_MAX_WAPBOOKMARK40
22 #define GSM_BACKUP_MAX_WAPSETTINGS30 22 #define GSM_BACKUP_MAX_WAPSETTINGS30
23 #define GSM_BACKUP_MAX_MMSSETTINGS30 23 #define GSM_BACKUP_MAX_MMSSETTINGS30
24 #define GSM_BACKUP_MAX_SYNCMLSETTINGS10
25 #define GSM_BACKUP_MAX_CHATSETTINGS10
24 #define GSM_BACKUP_MAX_RINGTONES30 26 #define GSM_BACKUP_MAX_RINGTONES30
25 #define GSM_BACKUP_MAX_PROFILES 10 27 #define GSM_BACKUP_MAX_PROFILES 10
26 #define GSM_BACKUP_MAX_FMSTATIONS20 28 #define GSM_BACKUP_MAX_FMSTATIONS20
27 #define GSM_BACKUP_MAX_GPRSPOINT10 29 #define GSM_BACKUP_MAX_GPRSPOINT10
28 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */ 30 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */
29 31
30typedef struct { 32typedef struct {
31 char IMEI [MAX_IMEI_LENGTH]; 33 char IMEI [MAX_IMEI_LENGTH];
32 char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH]; 34 char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH];
33 char Creator [80]; 35 char Creator [80];
34 GSM_DateTime DateTime; 36 GSM_DateTime DateTime;
35 bool DateTimeAvailable; 37 bool DateTimeAvailable;
36 char MD5Original[100]; 38 char MD5Original[100];
37 char MD5Calculated[100]; 39 char MD5Calculated[100];
38 GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1]; 40 GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1];
39 GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1]; 41 GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1];
40 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1]; 42 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1];
41 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1]; 43 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1];
42 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1]; 44 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1];
43 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1]; 45 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1];
44 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1]; 46 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1];
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];
47 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1]; 51 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1];
48 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1]; 52 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1];
49 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1]; 53 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1];
50 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1]; 54 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1];
51 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1]; 55 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1];
52 GSM_Bitmap *StartupLogo; 56 GSM_Bitmap *StartupLogo;
53 GSM_Bitmap *OperatorLogo; 57 GSM_Bitmap *OperatorLogo;
54} GSM_Backup; 58} GSM_Backup;
55 59
56 #define GSM_BACKUP_MAX_SMS500 60 #define GSM_BACKUP_MAX_SMS500
57 61
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
@@ -142,71 +142,72 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
142 142
143 if (myname[0] == 0x00) { 143 if (myname[0] == 0x00) {
144 if (UseUnicode) { 144 if (UseUnicode) {
145 EncodeUnicode(buffer,myvalue,strlen(myvalue)); 145 EncodeUnicode(buffer,myvalue,strlen(myvalue));
146 fwrite(buffer,1,strlen(myvalue)*2,file); 146 fwrite(buffer,1,strlen(myvalue)*2,file);
147 } else fprintf(file,"%s",myvalue); 147 } else fprintf(file,"%s",myvalue);
148 } else { 148 } else {
149 if (UseUnicode) { 149 if (UseUnicode) {
150 sprintf(buffer,"%s = \"",myname); 150 sprintf(buffer,"%s = \"",myname);
151 EncodeUnicode(buffer2,buffer,strlen(buffer)); 151 EncodeUnicode(buffer2,buffer,strlen(buffer));
152 fwrite(buffer2,1,strlen(buffer)*2,file); 152 fwrite(buffer2,1,strlen(buffer)*2,file);
153 153
154 fwrite(myvalue,1,UnicodeLength(myvalue)*2,file); 154 fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
155 155
156 sprintf(buffer,"\"%c%c",13,10); 156 sprintf(buffer,"\"%c%c",13,10);
157 EncodeUnicode(buffer2,buffer,strlen(buffer)); 157 EncodeUnicode(buffer2,buffer,strlen(buffer));
158 fwrite(buffer2,1,strlen(buffer)*2,file); 158 fwrite(buffer2,1,strlen(buffer)*2,file);
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);
162 162
163 EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2); 163 EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2);
164 fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10); 164 fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10);
165 } 165 }
166 } 166 }
167} 167}
168 168
169static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) 169static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode)
170{ 170{
171 unsigned char paramname[10000],*readvalue; 171 unsigned char paramname[10000],*readvalue;
172 172
173 if (UseUnicode) { 173 if (UseUnicode) {
174 EncodeUnicode(paramname,myname,strlen(myname)); 174 EncodeUnicode(paramname,myname,strlen(myname));
175 readvalue = INI_GetValue(file_info, section, paramname, UseUnicode); 175 readvalue = INI_GetValue(file_info, section, paramname, UseUnicode);
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));
181 } else { 182 } else {
182 myvalue[0]=0; 183 myvalue[0]=0;
183 myvalue[1]=0; 184 myvalue[1]=0;
184 return false; 185 return false;
185 } 186 }
186 } else { 187 } else {
187 strcpy(paramname,myname); 188 strcpy(paramname,myname);
188 strcat(paramname,"Unicode"); 189 strcat(paramname,"Unicode");
189 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); 190 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
190 if (readvalue!=NULL) { 191 if (readvalue!=NULL) {
191 dbgprintf("%s %i\n",readvalue,strlen(readvalue)); 192 dbgprintf("%s %i\n",readvalue,strlen(readvalue));
192 DecodeHexBin (myvalue, readvalue, strlen(readvalue)); 193 DecodeHexBin (myvalue, readvalue, strlen(readvalue));
193 myvalue[strlen(readvalue)/2]=0; 194 myvalue[strlen(readvalue)/2]=0;
194 myvalue[strlen(readvalue)/2+1]=0; 195 myvalue[strlen(readvalue)/2+1]=0;
195 dbgprintf("%s\n",DecodeUnicodeString(myvalue)); 196 dbgprintf("%s\n",DecodeUnicodeString(myvalue));
196 } else { 197 } else {
197 strcpy(paramname,myname); 198 strcpy(paramname,myname);
198 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); 199 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
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 {
202 myvalue[0]=0; 203 myvalue[0]=0;
203 myvalue[1]=0; 204 myvalue[1]=0;
204 return false; 205 return false;
205 } 206 }
206 } 207 }
207 } 208 }
208 return true; 209 return true;
209} 210}
210 211
211static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode) 212static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode)
212{ 213{
@@ -409,42 +410,53 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
409 SaveBackupText(file, "", buffer, UseUnicode); 410 SaveBackupText(file, "", buffer, UseUnicode);
410 i++; 411 i++;
411 } 412 }
412 break; 413 break;
413 default: 414 default:
414 break; 415 break;
415 } 416 }
416 } 417 }
417 sprintf(buffer,"%c%c",13,10); 418 sprintf(buffer,"%c%c",13,10);
418 SaveBackupText(file, "", buffer, UseUnicode); 419 SaveBackupText(file, "", buffer, UseUnicode);
419} 420}
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)
422{ 434{
423 int i; 435 int i;
424 charbuffer[1000]; 436 charbuffer[1000];
425 437
426 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10); 438 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
427 SaveBackupText(file, "", buffer, UseUnicode); 439 SaveBackupText(file, "", buffer, UseUnicode);
428 SaveBackupText(file, "", "Type = ", UseUnicode); 440 SaveBackupText(file, "", "Type = ", UseUnicode);
429 switch (Note->Type) { 441 switch (Note->Type) {
430 case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break; 442 case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break;
431 case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break; 443 case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break;
432 case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break; 444 case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break;
433 case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break; 445 case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break;
434 case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break; 446 case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break;
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;
440 case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break; 452 case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break;
441 case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break; 453 case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break;
442 case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break; 454 case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break;
443 case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break; 455 case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break;
444 case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break; 456 case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break;
445 case GSM_CAL_T_FOOT : sprintf(buffer,"Training/Football%c%c", 13,10); break; 457 case GSM_CAL_T_FOOT : sprintf(buffer,"Training/Football%c%c", 13,10); break;
446 case GSM_CAL_T_GOLF : sprintf(buffer,"Training/Golf%c%c", 13,10); break; 458 case GSM_CAL_T_GOLF : sprintf(buffer,"Training/Golf%c%c", 13,10); break;
447 case GSM_CAL_T_GYM : sprintf(buffer,"Training/Gym%c%c", 13,10); break; 459 case GSM_CAL_T_GYM : sprintf(buffer,"Training/Gym%c%c", 13,10); break;
448 case GSM_CAL_T_HORS : sprintf(buffer,"Training/HorseRaces%c%c", 13,10); break; 460 case GSM_CAL_T_HORS : sprintf(buffer,"Training/HorseRaces%c%c", 13,10); break;
449 case GSM_CAL_T_HOCK : sprintf(buffer,"Training/Hockey%c%c", 13,10); break; 461 case GSM_CAL_T_HOCK : sprintf(buffer,"Training/Hockey%c%c", 13,10); break;
450 case GSM_CAL_T_RACE : sprintf(buffer,"Training/Races%c%c", 13,10); break; 462 case GSM_CAL_T_RACE : sprintf(buffer,"Training/Races%c%c", 13,10); break;
@@ -648,24 +660,66 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
648 if (settings->Settings[i].IsIP) { 660 if (settings->Settings[i].IsIP) {
649 sprintf(buffer,"IP%02i",i); 661 sprintf(buffer,"IP%02i",i);
650 } else { 662 } else {
651 sprintf(buffer,"Number%02i",i); 663 sprintf(buffer,"Number%02i",i);
652 } 664 }
653 SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode); 665 SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode);
654 } 666 }
655 sprintf(buffer,"%c%c",13,10); 667 sprintf(buffer,"%c%c",13,10);
656 SaveBackupText(file, "", buffer, UseUnicode); 668 SaveBackupText(file, "", buffer, UseUnicode);
657 } 669 }
658} 670}
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)
661{ 715{
662 unsigned char buffer[10000],buffer2[10000]; 716 unsigned char buffer[10000],buffer2[10000];
663 int x,y; 717 int x,y;
664 718
665 sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10); 719 sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10);
666 SaveBackupText(file, "", buffer, UseUnicode); 720 SaveBackupText(file, "", buffer, UseUnicode);
667 sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10); 721 sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10);
668 SaveBackupText(file, "", buffer, UseUnicode); 722 SaveBackupText(file, "", buffer, UseUnicode);
669 for (y=0;y<bitmap->BitmapHeight;y++) { 723 for (y=0;y<bitmap->BitmapHeight;y++) {
670 for (x=0;x<bitmap->BitmapWidth;x++) { 724 for (x=0;x<bitmap->BitmapWidth;x++) {
671 buffer[x] = ' '; 725 buffer[x] = ' ';
@@ -755,41 +809,42 @@ static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode)
755 case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break; 809 case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break;
756 case SMS_VALID_1_Week : sprintf(buffer, "1week"); break; 810 case SMS_VALID_1_Week : sprintf(buffer, "1week"); break;
757 case SMS_VALID_Max_Time: 811 case SMS_VALID_Max_Time:
758 default : sprintf(buffer,"MaximumTime"); break; 812 default : sprintf(buffer,"MaximumTime"); break;
759 } 813 }
760 SaveBackupText(file, "", buffer, UseUnicode); 814 SaveBackupText(file, "", buffer, UseUnicode);
761 sprintf(buffer,"%c%c%c%c",13,10,13,10); 815 sprintf(buffer,"%c%c%c%c",13,10,13,10);
762 SaveBackupText(file, "", buffer, UseUnicode); 816 SaveBackupText(file, "", buffer, UseUnicode);
763} 817}
764 818
765static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode) 819static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode)
766{ 820{
767 unsigned char buffer[45000]; 821 unsigned char buffer[45000];
768 int i,j;
769 822
770 sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10); 823 sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10);
771 SaveBackupText(file, "", buffer, UseUnicode); 824 SaveBackupText(file, "", buffer, UseUnicode);
772 SaveBackupText(file, "Name", ringtone->Name, UseUnicode); 825 SaveBackupText(file, "Name", ringtone->Name, UseUnicode);
773 switch (ringtone->Format) { 826 switch (ringtone->Format) {
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);
777 SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode); 829 SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode);
778 break; 830 break;
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);
782 SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode); 833 SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode);
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:
785 break; 840 break;
786 } 841 }
787 sprintf(buffer,"%c%c",13,10); 842 sprintf(buffer,"%c%c",13,10);
788 SaveBackupText(file, "", buffer, UseUnicode); 843 SaveBackupText(file, "", buffer, UseUnicode);
789} 844}
790 845
791static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) 846static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
792{ 847{
793 unsigned char buffer[1000]; 848 unsigned char buffer[1000];
794 849
795 sprintf(buffer,"[Operator]%c%c",13,10); 850 sprintf(buffer,"[Operator]%c%c",13,10);
@@ -1066,24 +1121,31 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1066 SaveBackupText(file, "", buffer, UseUnicode); 1121 SaveBackupText(file, "", buffer, UseUnicode);
1067 SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode); 1122 SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode);
1068 i++; 1123 i++;
1069 } 1124 }
1070 i=0; 1125 i=0;
1071 while (backup->Calendar[i]!=NULL) { 1126 while (backup->Calendar[i]!=NULL) {
1072 sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10); 1127 sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10);
1073 SaveBackupText(file, "", buffer, UseUnicode); 1128 SaveBackupText(file, "", buffer, UseUnicode);
1074 SaveCalendarEntry(file, backup->Calendar[i], UseUnicode); 1129 SaveCalendarEntry(file, backup->Calendar[i], UseUnicode);
1075 i++; 1130 i++;
1076 } 1131 }
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) {
1079 sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10); 1141 sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10);
1080 SaveBackupText(file, "", buffer, UseUnicode); 1142 SaveBackupText(file, "", buffer, UseUnicode);
1081 SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode); 1143 SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode);
1082 i++; 1144 i++;
1083 } 1145 }
1084 i=0; 1146 i=0;
1085 while (backup->SMSC[i]!=NULL) { 1147 while (backup->SMSC[i]!=NULL) {
1086 sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10); 1148 sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10);
1087 SaveBackupText(file, "", buffer, UseUnicode); 1149 SaveBackupText(file, "", buffer, UseUnicode);
1088 SaveSMSCEntry(file, backup->SMSC[i], UseUnicode); 1150 SaveSMSCEntry(file, backup->SMSC[i], UseUnicode);
1089 i++; 1151 i++;
@@ -1101,24 +1163,38 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1101 SaveBackupText(file, "", buffer, UseUnicode); 1163 SaveBackupText(file, "", buffer, UseUnicode);
1102 SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode); 1164 SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode);
1103 i++; 1165 i++;
1104 } 1166 }
1105 i=0; 1167 i=0;
1106 while (backup->MMSSettings[i]!=NULL) { 1168 while (backup->MMSSettings[i]!=NULL) {
1107 sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10); 1169 sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10);
1108 SaveBackupText(file, "", buffer, UseUnicode); 1170 SaveBackupText(file, "", buffer, UseUnicode);
1109 SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode); 1171 SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode);
1110 i++; 1172 i++;
1111 } 1173 }
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) {
1114 sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10); 1190 sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10);
1115 SaveBackupText(file, "", buffer, UseUnicode); 1191 SaveBackupText(file, "", buffer, UseUnicode);
1116 SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode); 1192 SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode);
1117 i++; 1193 i++;
1118 } 1194 }
1119 i=0; 1195 i=0;
1120 while (backup->ToDo[i]!=NULL) { 1196 while (backup->ToDo[i]!=NULL) {
1121 sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10); 1197 sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10);
1122 SaveBackupText(file, "", buffer, UseUnicode); 1198 SaveBackupText(file, "", buffer, UseUnicode);
1123 SaveToDoEntry(file, backup->ToDo[i], UseUnicode); 1199 SaveToDoEntry(file, backup->ToDo[i], UseUnicode);
1124 i++; 1200 i++;
@@ -2647,25 +2723,150 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
2647 backup->Note[num + 1] = NULL; 2723 backup->Note[num + 1] = NULL;
2648 } else { 2724 } else {
2649 dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n"); 2725 dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n");
2650 return ERR_MOREMEMORY; 2726 return ERR_MOREMEMORY;
2651 } 2727 }
2652 ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode); 2728 ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode);
2653 num++; 2729 num++;
2654 } 2730 }
2655 } 2731 }
2656 if (backup->MD5Original[0]!=0) { 2732 if (backup->MD5Original[0]!=0) {
2657 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated); 2733 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated);
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;
2661} 2862}
2662 2863
2663/* ---------------------- backup files for SMS ----------------------------- */ 2864/* ---------------------- backup files for SMS ----------------------------- */
2664 2865
2665static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) 2866static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS)
2666{ 2867{
2667 unsigned char buffer[10000], *readvalue; 2868 unsigned char buffer[10000], *readvalue;
2668 2869
2669 GSM_SetDefaultSMSData(SMS); 2870 GSM_SetDefaultSMSData(SMS);
2670 2871
2671 SMS->PDU = SMS_Submit; 2872 SMS->PDU = SMS_Submit;
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
@@ -64,24 +64,36 @@ void GSM_FreeBackup(GSM_Backup *backup)
64 while (backup->WAPSettings[i]!=NULL) { 64 while (backup->WAPSettings[i]!=NULL) {
65 free(backup->WAPSettings[i]); 65 free(backup->WAPSettings[i]);
66 backup->WAPSettings[i] = NULL; 66 backup->WAPSettings[i] = NULL;
67 i++; 67 i++;
68 } 68 }
69 i=0; 69 i=0;
70 while (backup->MMSSettings[i]!=NULL) { 70 while (backup->MMSSettings[i]!=NULL) {
71 free(backup->MMSSettings[i]); 71 free(backup->MMSSettings[i]);
72 backup->MMSSettings[i] = NULL; 72 backup->MMSSettings[i] = NULL;
73 i++; 73 i++;
74 } 74 }
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) {
77 free(backup->Ringtone[i]); 89 free(backup->Ringtone[i]);
78 backup->Ringtone[i] = NULL; 90 backup->Ringtone[i] = NULL;
79 i++; 91 i++;
80 } 92 }
81 i=0; 93 i=0;
82 while (backup->ToDo[i]!=NULL) { 94 while (backup->ToDo[i]!=NULL) {
83 free(backup->ToDo[i]); 95 free(backup->ToDo[i]);
84 backup->ToDo[i] = NULL; 96 backup->ToDo[i] = NULL;
85 i++; 97 i++;
86 } 98 }
87 i=0; 99 i=0;
@@ -111,81 +123,83 @@ void GSM_FreeBackup(GSM_Backup *backup)
111 i++; 123 i++;
112 } 124 }
113 i=0; 125 i=0;
114 while (backup->Note[i]!=NULL) { 126 while (backup->Note[i]!=NULL) {
115 free(backup->Note[i]); 127 free(backup->Note[i]);
116 backup->Note[i] = NULL; 128 backup->Note[i] = NULL;
117 i++; 129 i++;
118 } 130 }
119} 131}
120 132
121GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode) 133GSM_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);
133 } else { 145 } else {
134 return SaveBackup(FileName,backup, UseUnicode); 146 return SaveBackup(FileName,backup, UseUnicode);
135 } 147 }
136} 148}
137 149
138GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup) 150GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
139{ 151{
140 FILE *file; 152 FILE *file;
141 unsigned charbuffer[300]; 153 unsigned charbuffer[300];
142 154
143 file = fopen(FileName, "rb"); 155 file = fopen(FileName, "rb");
144 if (file == NULL) return ERR_CANTOPENFILE; 156 if (file == NULL) return ERR_CANTOPENFILE;
145 fread(buffer, 1, 9, file); /* Read the header of the file. */ 157 fread(buffer, 1, 9, file); /* Read the header of the file. */
146 fclose(file); 158 fclose(file);
147 159
148 GSM_ClearBackup(backup); 160 GSM_ClearBackup(backup);
149 161
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);
159 } else if (memcmp(buffer, "LMB ",4)==0) { 171 } else if (memcmp(buffer, "LMB ",4)==0) {
160 return LoadLMB(FileName,backup); 172 return LoadLMB(FileName,backup);
161 } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) { 173 } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) {
162 return LoadBackup(FileName,backup,true); 174 return LoadBackup(FileName,backup,true);
163 } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) { 175 } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) {
164 return LoadBackup(FileName,backup,true); 176 return LoadBackup(FileName,backup,true);
165 } else { 177 } else {
166 return LoadBackup(FileName,backup,false); 178 return LoadBackup(FileName,backup,false);
167 } 179 }
168} 180}
169 181
170void GSM_ClearBackup(GSM_Backup *backup) 182void GSM_ClearBackup(GSM_Backup *backup)
171{ 183{
172 backup->PhonePhonebook[0] = NULL; 184 backup->PhonePhonebook[0] = NULL;
173 backup->SIMPhonebook[0] = NULL; 185 backup->SIMPhonebook[0] = NULL;
174 backup->Calendar[0] = NULL; 186 backup->Calendar[0] = NULL;
175 backup->CallerLogos[0] = NULL; 187 backup->CallerLogos[0] = NULL;
176 backup->SMSC [0] = NULL; 188 backup->SMSC [0] = NULL;
177 backup->WAPBookmark[0] = NULL; 189 backup->WAPBookmark[0] = NULL;
178 backup->WAPSettings[0] = NULL; 190 backup->WAPSettings[0] = NULL;
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;
181 backup->Profiles[0] = NULL; 195 backup->Profiles[0] = NULL;
182 backup->ToDo [0] = NULL; 196 backup->ToDo [0] = NULL;
183 backup->GPRSPoint[0] = NULL; 197 backup->GPRSPoint[0] = NULL;
184 backup->FMStation[0] = NULL; 198 backup->FMStation[0] = NULL;
185 backup->Note [0] = NULL; 199 backup->Note [0] = NULL;
186 backup->StartupLogo = NULL; 200 backup->StartupLogo = NULL;
187 backup->OperatorLogo = NULL; 201 backup->OperatorLogo = NULL;
188 202
189 backup->Creator [0] = 0; 203 backup->Creator [0] = 0;
190 backup->IMEI [0] = 0; 204 backup->IMEI [0] = 0;
191 backup->Model [0] = 0; 205 backup->Model [0] = 0;
@@ -200,24 +214,26 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
200 info->IMEI = false; 214 info->IMEI = false;
201 info->Model = false; 215 info->Model = false;
202 info->DateTime = false; 216 info->DateTime = false;
203 info->PhonePhonebook = false; 217 info->PhonePhonebook = false;
204 info->SIMPhonebook = false; 218 info->SIMPhonebook = false;
205 info->ToDo = false; 219 info->ToDo = false;
206 info->Calendar = false; 220 info->Calendar = false;
207 info->CallerLogos = false; 221 info->CallerLogos = false;
208 info->SMSC = false; 222 info->SMSC = false;
209 info->WAPBookmark = false; 223 info->WAPBookmark = false;
210 info->WAPSettings = false; 224 info->WAPSettings = false;
211 info->MMSSettings = false; 225 info->MMSSettings = false;
226 info->SyncMLSettings = false;
227 info->ChatSettings = false;
212 info->Ringtone = false; 228 info->Ringtone = false;
213 info->StartupLogo = false; 229 info->StartupLogo = false;
214 info->OperatorLogo = false; 230 info->OperatorLogo = false;
215 info->Profiles = false; 231 info->Profiles = false;
216 info->FMStation = false; 232 info->FMStation = false;
217 info->GPRSPoint = false; 233 info->GPRSPoint = false;
218 info->Note = false; 234 info->Note = false;
219 235
220 if (strstr(FileName,".lmb")) { 236 if (strstr(FileName,".lmb")) {
221 info->PhonePhonebook = true; 237 info->PhonePhonebook = true;
222 info->SIMPhonebook = true; 238 info->SIMPhonebook = true;
223 info->CallerLogos = true; 239 info->CallerLogos = true;
@@ -237,24 +253,26 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
237 info->IMEI = true; 253 info->IMEI = true;
238 info->Model = true; 254 info->Model = true;
239 info->DateTime = true; 255 info->DateTime = true;
240 info->PhonePhonebook = true; 256 info->PhonePhonebook = true;
241 info->SIMPhonebook = true; 257 info->SIMPhonebook = true;
242 info->ToDo = true; 258 info->ToDo = true;
243 info->Calendar = true; 259 info->Calendar = true;
244 info->CallerLogos = true; 260 info->CallerLogos = true;
245 info->SMSC = true; 261 info->SMSC = true;
246 info->WAPBookmark = true; 262 info->WAPBookmark = true;
247 info->WAPSettings = true; 263 info->WAPSettings = true;
248 info->MMSSettings = true; 264 info->MMSSettings = true;
265 info->SyncMLSettings = true;
266 info->ChatSettings = true;
249 info->Ringtone = true; 267 info->Ringtone = true;
250 info->StartupLogo = true; 268 info->StartupLogo = true;
251 info->OperatorLogo = true; 269 info->OperatorLogo = true;
252 info->Profiles = true; 270 info->Profiles = true;
253 info->FMStation = true; 271 info->FMStation = true;
254 info->GPRSPoint = true; 272 info->GPRSPoint = true;
255 info->Note = true; 273 info->Note = true;
256 } 274 }
257} 275}
258 276
259void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup) 277void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup)
260{ 278{
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
@@ -20,24 +20,26 @@ typedef struct {
20 bool Model; 20 bool Model;
21 bool DateTime; 21 bool DateTime;
22 bool ToDo; 22 bool ToDo;
23 bool PhonePhonebook; 23 bool PhonePhonebook;
24 bool SIMPhonebook; 24 bool SIMPhonebook;
25 bool Calendar; 25 bool Calendar;
26 bool CallerLogos; 26 bool CallerLogos;
27 bool SMSC; 27 bool SMSC;
28 bool WAPBookmark; 28 bool WAPBookmark;
29 bool Profiles; 29 bool Profiles;
30 bool WAPSettings; 30 bool WAPSettings;
31 bool MMSSettings; 31 bool MMSSettings;
32 bool SyncMLSettings;
33 bool ChatSettings;
32 bool Ringtone; 34 bool Ringtone;
33 bool StartupLogo; 35 bool StartupLogo;
34 bool OperatorLogo; 36 bool OperatorLogo;
35 bool FMStation; 37 bool FMStation;
36 bool GPRSPoint; 38 bool GPRSPoint;
37 bool Note; 39 bool Note;
38} GSM_Backup_Info; 40} GSM_Backup_Info;
39 41
40void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info); 42void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info);
41void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup); 43void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup);
42 44
43#endif 45#endif
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
@@ -396,25 +396,25 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool h
396 */ 396 */
397typedef struct { 397typedef struct {
398 /** 398 /**
399 * Number of used positions. 399 * Number of used positions.
400 */ 400 */
401 int Used; 401 int Used;
402} GSM_ToDoStatus; 402} GSM_ToDoStatus;
403 403
404/* --------------------------- note ---------------------------------------- */ 404/* --------------------------- note ---------------------------------------- */
405 405
406typedef struct { 406typedef struct {
407 int Location; 407 int Location;
408 char Text[100]; 408 char Text[3000*2];
409} GSM_NoteEntry; 409} GSM_NoteEntry;
410 410
411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); 411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note);
412 412
413/* --------------------------- alarm --------------------------------------- */ 413/* --------------------------- alarm --------------------------------------- */
414 414
415/** 415/**
416 * Alarm values. 416 * Alarm values.
417 */ 417 */
418typedef struct { 418typedef struct {
419 /** 419 /**
420 * Location where it is stored. 420 * Location where it is stored.
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
@@ -237,71 +237,149 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W
237 237
238 /* ISP_NAME (name) */ 238 /* ISP_NAME (name) */
239 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes 239 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
240 Buffer[(*Length)++] = 0x08; //TYPE=NAME 240 Buffer[(*Length)++] = 0x08; //TYPE=NAME
241 Buffer[(*Length)++] = 0x01; //END PARMeter 241 Buffer[(*Length)++] = 0x01; //END PARMeter
242 /* Settings name */ 242 /* Settings name */
243 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title)); 243 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title));
244 Buffer[(*Length)++] = 0x01; //END PARMeter 244 Buffer[(*Length)++] = 0x01; //END PARMeter
245 Buffer[(*Length)++] = 0x01; //END PARMeter 245 Buffer[(*Length)++] = 0x01; //END PARMeter
246} 246}
247 247
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)
250{ 252{
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
257 Buffer[(*Length)++] = 0x01; //Push ID 259 Buffer[(*Length)++] = 0x01; //Push ID
258 Buffer[(*Length)++] = 0x06; //PDU Type (push) 260 Buffer[(*Length)++] = 0x06; //PDU Type (push)
259 Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers) 261 Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers)
260 strcpy(Buffer+(*Length),"\x1F\x2B"); 262 strcpy(Buffer+(*Length),"\x1F\x2B");
261 (*Length)=(*Length)+2; //Value length 263 (*Length)=(*Length)+2; //Value length
262 strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks"); 264 strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks");
263 (*Length)=(*Length)+40; //MIME-Type 265 (*Length)=(*Length)+40; //MIME-Type
264 Buffer[(*Length)++] = 0x00; //end inline string 266 Buffer[(*Length)++] = 0x00; //end inline string
265 strcpy(Buffer+(*Length),"\x81\xEA"); 267 strcpy(Buffer+(*Length),"\x81\xEA");
266 (*Length)=(*Length)+2; //charset UTF-8 short int. 268 (*Length)=(*Length)+2; //charset UTF-8 short int.
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
278 Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content 287 Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content
279 /* URL */ 288 /* URL */
280 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes 289 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
281 Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK 290 Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK
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}
297 375
298void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) 376void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length)
299{ 377{
300 int i; 378 int i;
301 379
302 strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F"); 380 strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F");
303 (*Length)=(*Length)+4; 381 (*Length)=(*Length)+4;
304 382
305 /* Unique MMS ID ? */ 383 /* Unique MMS ID ? */
306 strcpy(Buffer+(*Length),"123456789"); 384 strcpy(Buffer+(*Length),"123456789");
307 (*Length)=(*Length)+9; 385 (*Length)=(*Length)+9;
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
@@ -79,24 +79,26 @@ void NOKIA_EncodeWAPBookmarkSMSText (unsigned char *Buffer, int *Length, GSM_W
79 GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); 79 GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark);
80 80
81/* ------------------------------ MMS Indicator ---------------------------- */ 81/* ------------------------------ MMS Indicator ---------------------------- */
82 82
83typedef struct { 83typedef struct {
84 unsigned char Address[500]; 84 unsigned char Address[500];
85 unsigned char Title[200]; 85 unsigned char Title[200];
86 unsigned char Sender[200]; 86 unsigned char Sender[200];
87} GSM_MMSIndicator; 87} GSM_MMSIndicator;
88 88
89void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator); 89void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator);
90 90
91void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL);
92
91/* ------------------------------ MMS file --------------------------------- */ 93/* ------------------------------ MMS file --------------------------------- */
92 94
93#define MAX_MULTI_MMS 20 95#define MAX_MULTI_MMS 20
94 96
95typedef enum { 97typedef enum {
96 MMS_Text = 1, 98 MMS_Text = 1,
97 MMS_Bitmap_JPG 99 MMS_Bitmap_JPG
98} EncodeMultiPartMMSID; 100} EncodeMultiPartMMSID;
99 101
100typedef struct { 102typedef struct {
101 EncodeMultiPartMMSID ID; 103 EncodeMultiPartMMSID ID;
102 104
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
@@ -1,16 +1,17 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <sys/stat.h>
5 6
6#include "../misc/misc.h" 7#include "../misc/misc.h"
7#include "../misc/coding/coding.h" 8#include "../misc/coding/coding.h"
8#include "gsmlogo.h" 9#include "gsmlogo.h"
9#include "gsmnet.h" 10#include "gsmnet.h"
10 11
11void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height) 12void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height)
12{ 13{
13 *width = 0; 14 *width = 0;
14 *height= 0; 15 *height= 0;
15 switch (Type) { 16 switch (Type) {
16 case GSM_EMSSmallPicture: *width=8; *height=8; break; 17 case GSM_EMSSmallPicture: *width=8; *height=8; break;
@@ -152,24 +153,25 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B
152 Bitmap->Location = 0; 153 Bitmap->Location = 0;
153 Bitmap->Text[0] = 0; 154 Bitmap->Text[0] = 0;
154 Bitmap->Text[1] = 0; 155 Bitmap->Text[1] = 0;
155 Bitmap->BitmapEnabled = false; 156 Bitmap->BitmapEnabled = false;
156 Bitmap->DefaultName = false; 157 Bitmap->DefaultName = false;
157 Bitmap->DefaultBitmap = false; 158 Bitmap->DefaultBitmap = false;
158 Bitmap->DefaultRingtone = false; 159 Bitmap->DefaultRingtone = false;
159 Bitmap->RingtoneID = 0; 160 Bitmap->RingtoneID = 0;
160 Bitmap->NetworkCode[0] = 0; 161 Bitmap->NetworkCode[0] = 0;
161 Bitmap->Sender[0] = 0; 162 Bitmap->Sender[0] = 0;
162 Bitmap->Sender[1] = 0; 163 Bitmap->Sender[1] = 0;
163 Bitmap->ID = 0; 164 Bitmap->ID = 0;
165 Bitmap->Name = NULL;
164 166
165 GSM_ClearBitmap(Bitmap); 167 GSM_ClearBitmap(Bitmap);
166 for (x=0;x<Bitmap->BitmapWidth;x++) { 168 for (x=0;x<Bitmap->BitmapWidth;x++) {
167 for (y=0;y<Bitmap->BitmapHeight;y++) { 169 for (y=0;y<Bitmap->BitmapHeight;y++) {
168 if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) { 170 if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) {
169 GSM_SetPointBitmap(Bitmap,x,y); 171 GSM_SetPointBitmap(Bitmap,x,y);
170 } 172 }
171 } 173 }
172 } 174 }
173} 175}
174 176
175void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height) 177void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height)
@@ -617,35 +619,35 @@ static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap)
617 return ERR_NONE; 619 return ERR_NONE;
618} 620}
619 621
620GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) 622GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
621{ 623{
622 FILE *file; 624 FILE *file;
623 GSM_Error error=ERR_NONE; 625 GSM_Error error=ERR_NONE;
624 626
625 file = fopen(FileName, "wb"); 627 file = fopen(FileName, "wb");
626 if (file == NULL) return ERR_CANTOPENFILE; 628 if (file == NULL) return ERR_CANTOPENFILE;
627 629
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);
641 } else { 643 } else {
642 error=savebmp(file,bitmap); 644 error=savebmp(file,bitmap);
643 } 645 }
644 fclose(file); 646 fclose(file);
645 647
646 return error; 648 return error;
647} 649}
648 650
649GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap) 651GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap)
650{ 652{
651 bool first_white,isfile=false; 653 bool first_white,isfile=false;
@@ -946,50 +948,83 @@ static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
946 fread(buffer,1,4,file); 948 fread(buffer,1,4,file);
947 bitmap->Bitmap[0].BitmapWidth = buffer[2]; 949 bitmap->Bitmap[0].BitmapWidth = buffer[2];
948 bitmap->Bitmap[0].BitmapHeight = buffer[3]; 950 bitmap->Bitmap[0].BitmapHeight = buffer[3];
949 bitmap->Number = 1; 951 bitmap->Number = 1;
950 952
951 fread(buffer,1,10000,file); 953 fread(buffer,1,10000,file);
952 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]); 954 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]);
953 GSM_ReverseBitmap(&bitmap->Bitmap[0]); 955 GSM_ReverseBitmap(&bitmap->Bitmap[0]);
954 956
955 return ERR_NONE; 957 return ERR_NONE;
956} 958}
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)
959{ 988{
960 FILE *file; 989 FILE *file;
961 unsigned charbuffer[300]; 990 unsigned charbuffer[300];
962 991
963 file = fopen(FileName, "rb"); 992 file = fopen(FileName, "rb");
964 if (file == NULL) return ERR_CANTOPENFILE; 993 if (file == NULL) return ERR_CANTOPENFILE;
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. */
967 rewind(file); 1000 rewind(file);
968 1001
969 bitmap->Bitmap[0].DefaultBitmap = false; 1002 bitmap->Bitmap[0].DefaultBitmap = false;
970 1003
971 /* Attempt to identify filetype */ 1004 /* Attempt to identify filetype */
972 if (memcmp(buffer, "BM",2)==0) { 1005 if (memcmp(buffer, "BM",2)==0) {
973 return loadbmp(file,bitmap); 1006 return loadbmp(file,bitmap);
974 } else if (buffer[0] == 0x00 && buffer[1] == 0x00) { 1007 } else if (buffer[0] == 0x00 && buffer[1] == 0x00) {
975 return loadwbmp(file,bitmap); 1008 return loadwbmp(file,bitmap);
976 } else if (memcmp(buffer, "NLM",3)==0) { 1009 } else if (memcmp(buffer, "NLM",3)==0) {
977 return loadnlm(file,bitmap); 1010 return loadnlm(file,bitmap);
978 } else if (memcmp(buffer, "NOL",3)==0) { 1011 } else if (memcmp(buffer, "NOL",3)==0) {
979 return loadnolngg(file,bitmap,true); 1012 return loadnolngg(file,bitmap,true);
980 } else if (memcmp(buffer, "NGG",3)==0) { 1013 } else if (memcmp(buffer, "NGG",3)==0) {
981 return loadnolngg(file,bitmap,false); 1014 return loadnolngg(file,bitmap,false);
982 } else if (memcmp(buffer, "FORM",4)==0) { 1015 } else if (memcmp(buffer, "FORM",4)==0) {
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 }
985 return ERR_UNKNOWN; 1020 return ERR_UNKNOWN;
986} 1021}
987 1022
988void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) 1023void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length)
989{ 1024{
990 int Width, Height; 1025 int Width, Height;
991 1026
992 Buffer[(*Length)++] = 0x00; 1027 Buffer[(*Length)++] = 0x00;
993 PHONE_GetBitmapWidthHeight(Type, &Width, &Height); 1028 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
994 Buffer[(*Length)++] = Width; 1029 Buffer[(*Length)++] = Width;
995 Buffer[(*Length)++] = Height; 1030 Buffer[(*Length)++] = Height;
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
@@ -1,19 +1,33 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_bitmaps_h 3#ifndef __gsm_bitmaps_h
4#define __gsm_bitmaps_h 4#define __gsm_bitmaps_h
5 5
6#include "../gsmcomon.h" 6#include "../gsmcomon.h"
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/**
9 * Enum to handle all possible bitmaps, which are not saved in various filesystems. 23 * Enum to handle all possible bitmaps, which are not saved in various filesystems.
10 */ 24 */
11typedef enum { 25typedef enum {
12 GSM_None = 1, 26 GSM_None = 1,
13 /** 27 /**
14 * ID of static file in filesystem displayed during startup 28 * ID of static file in filesystem displayed during startup
15 */ 29 */
16 GSM_ColourStartupLogo_ID, 30 GSM_ColourStartupLogo_ID,
17 /** 31 /**
18 * Static mono bitmap/ID of animated mono bitmap displayed during startup 32 * Static mono bitmap/ID of animated mono bitmap displayed during startup
19 */ 33 */
@@ -36,25 +50,29 @@ typedef enum {
36 GSM_CallerGroupLogo, 50 GSM_CallerGroupLogo,
37 /** 51 /**
38 * Text displayed during startup, which can't be removed from phone menu 52 * Text displayed during startup, which can't be removed from phone menu
39 */ 53 */
40 GSM_DealerNote_Text, 54 GSM_DealerNote_Text,
41 /** 55 /**
42 * Text displayed during startup 56 * Text displayed during startup
43 */ 57 */
44 GSM_WelcomeNote_Text, 58 GSM_WelcomeNote_Text,
45 /** 59 /**
46 * Image defined in Smart Messaging specification 60 * Image defined in Smart Messaging specification
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;
50 68
51 #define GSM_BITMAP_SIZE(65+7)/8*96 69 #define GSM_BITMAP_SIZE(65+7)/8*96
52#define GSM_BITMAP_TEXT_LENGTH 128 70#define GSM_BITMAP_TEXT_LENGTH 128
53 71
54/** 72/**
55 * Structure for all possible bitmaps, which are not saved in various filesystems 73 * Structure for all possible bitmaps, which are not saved in various filesystems
56 */ 74 */
57typedef struct { 75typedef struct {
58 /** 76 /**
59 * For all: bitmap type 77 * For all: bitmap type
60 */ 78 */
@@ -106,24 +124,32 @@ typedef struct {
106 /** 124 /**
107 * For operator logos: Network operator code 125 * For operator logos: Network operator code
108 */ 126 */
109 char NetworkCode[7]; 127 char NetworkCode[7];
110 /** 128 /**
111 * For picture images: number of sender 129 * For picture images: number of sender
112 */ 130 */
113 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)]; 131 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)];
114 /** 132 /**
115 * For colour bitmaps: ID 133 * For colour bitmaps: ID
116 */ 134 */
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;
119 145
120#define MAX_MULTI_BITMAP 6 146#define MAX_MULTI_BITMAP 6
121 147
122/** 148/**
123 * Structure to handle more than one bitmap 149 * Structure to handle more than one bitmap
124 */ 150 */
125typedef struct { 151typedef struct {
126 /** 152 /**
127 * Number of bitmaps 153 * Number of bitmaps
128 */ 154 */
129 unsigned char Number; 155 unsigned char Number;
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
@@ -283,25 +283,30 @@ typedef struct {
283typedef struct { 283typedef struct {
284 int Location; 284 int Location;
285 unsigned char Name[300]; 285 unsigned char Name[300];
286 unsigned char URL[500]; 286 unsigned char URL[500];
287 bool Active; 287 bool Active;
288} GSM_GPRSAccessPoint; 288} GSM_GPRSAccessPoint;
289 289
290/* ------------------------------------------------------------------------ */ 290/* ------------------------------------------------------------------------ */
291 291
292typedef enum { 292typedef enum {
293 GSM_Date_DDMMYYYY = 1, 293 GSM_Date_DDMMYYYY = 1,
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;
297 302
298typedef struct { 303typedef struct {
299 unsigned char DateSeparator; 304 unsigned char DateSeparator;
300 GSM_DateFormatDateFormat; 305 GSM_DateFormatDateFormat;
301 bool AMPMTime; 306 bool AMPMTime;
302} GSM_Locale; 307} GSM_Locale;
303 308
304/* ------------------------------------------------------------------------ */ 309/* ------------------------------------------------------------------------ */
305 310
306void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt); 311void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt);
307void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start); 312void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start);
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,21 +1,24 @@
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 */
5 7
6#include <stdlib.h> 8#include <stdlib.h>
7#include <string.h> 9#include <string.h>
8#include <ctype.h> 10#include <ctype.h>
9#include <math.h> 11#include <math.h>
12#include <sys/stat.h>
10#ifdef WIN32 13#ifdef WIN32
11# include <windows.h> 14# include <windows.h>
12#endif 15#endif
13 16
14#include "../gsmcomon.h" 17#include "../gsmcomon.h"
15#include "../misc/coding/coding.h" 18#include "../misc/coding/coding.h"
16#include "../gsmstate.h" 19#include "../gsmstate.h"
17#include "gsmring.h" 20#include "gsmring.h"
18#include "sms/gsmsms.h" 21#include "sms/gsmsms.h"
19 22
20int GSM_RingNoteGetFrequency(GSM_RingNote Note) 23int GSM_RingNoteGetFrequency(GSM_RingNote Note)
21{ 24{
@@ -147,24 +150,30 @@ static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone)
147 fwrite(&nullchar,1,1,file); 150 fwrite(&nullchar,1,1,file);
148 fwrite(&nullchar,1,1,file); 151 fwrite(&nullchar,1,1,file);
149 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); 152 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
150 return ERR_NONE; 153 return ERR_NONE;
151} 154}
152 155
153static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone) 156static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
154{ 157{
155 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); 158 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
156 return ERR_NONE; 159 return ERR_NONE;
157} 160}
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)
160{ 169{
161 GSM_RingNoteScaleDefNoteScale; 170 GSM_RingNoteScaleDefNoteScale;
162 GSM_RingNoteDurationDefNoteDuration; 171 GSM_RingNoteDurationDefNoteDuration;
163 172
164 GSM_RingNoteStyleDefNoteStyle=0; 173 GSM_RingNoteStyleDefNoteStyle=0;
165 int DefNoteTempo=0; 174 int DefNoteTempo=0;
166 175
167 bool started = false, firstcomma = true; 176 bool started = false, firstcomma = true;
168 GSM_RingNote *Note; 177 GSM_RingNote *Note;
169 178
170 unsigned char buffer[15]; 179 unsigned char buffer[15];
@@ -476,24 +485,27 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
476 } else if (strstr(FileName,".wav")) { 485 } else if (strstr(FileName,".wav")) {
477 savewav(file,ringtone); 486 savewav(file,ringtone);
478 } else { 487 } else {
479 saverttl(file, ringtone); 488 saverttl(file, ringtone);
480 } 489 }
481 break; 490 break;
482 case RING_NOKIABINARY: 491 case RING_NOKIABINARY:
483 savebin(file, ringtone); 492 savebin(file, ringtone);
484 break; 493 break;
485 case RING_MIDI: 494 case RING_MIDI:
486 savepuremidi(file, ringtone); 495 savepuremidi(file, ringtone);
487 break; 496 break;
497 case RING_MMF:
498 savemmf(file, ringtone);
499 break;
488 } 500 }
489 501
490 fclose(file); 502 fclose(file);
491 503
492 return ERR_NONE; 504 return ERR_NONE;
493} 505}
494 506
495static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone) 507static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone)
496{ 508{
497 GSM_RingNoteScale DefNoteScale= Scale_880; 509 GSM_RingNoteScale DefNoteScale= Scale_880;
498 GSM_RingNoteDuration DefNoteDuration= Duration_1_4; 510 GSM_RingNoteDuration DefNoteDuration= Duration_1_4;
499 GSM_RingNoteStyle DefNoteStyle= NaturalStyle; 511 GSM_RingNoteStyle DefNoteStyle= NaturalStyle;
@@ -760,24 +772,44 @@ static GSM_Error loadbin(FILE *file, GSM_Ringtone *ringtone)
760static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone) 772static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
761{ 773{
762 unsigned char buffer[30000]; 774 unsigned char buffer[30000];
763 775
764 dbgprintf("loading midi\n"); 776 dbgprintf("loading midi\n");
765 EncodeUnicode(ringtone->Name,"MIDI",4); 777 EncodeUnicode(ringtone->Name,"MIDI",4);
766 ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file); 778 ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file);
767 memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length); 779 memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length);
768 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name)); 780 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
769 return ERR_NONE; 781 return ERR_NONE;
770} 782}
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)
773{ 805{
774 unsigned char buffer[2000]; 806 unsigned char buffer[2000];
775 807
776 ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file); 808 ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file);
777 809
778 if (buffer[18]==0x00 && buffer[21]!=0x02) { 810 if (buffer[18]==0x00 && buffer[21]!=0x02) {
779 /* DCT3, Unicode subformat, 62xx & 7110 */ 811 /* DCT3, Unicode subformat, 62xx & 7110 */
780 CopyUnicodeString(ringtone->Name,buffer+18); 812 CopyUnicodeString(ringtone->Name,buffer+18);
781 ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2); 813 ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2);
782 memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length); 814 memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length);
783 } else { 815 } else {
@@ -807,24 +839,28 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
807 if (buffer[0]==0x00 && buffer[1]==0x00 && 839 if (buffer[0]==0x00 && buffer[1]==0x00 &&
808 buffer[2]==0x0C && buffer[3]==0x01) { 840 buffer[2]==0x0C && buffer[3]==0x01) {
809 ringtone->Format = RING_NOKIABINARY; 841 ringtone->Format = RING_NOKIABINARY;
810 } 842 }
811 if (buffer[0]==0x00 && buffer[1]==0x00 && 843 if (buffer[0]==0x00 && buffer[1]==0x00 &&
812 buffer[2]==0x00) { 844 buffer[2]==0x00) {
813 ringtone->Format = RING_NOKIABINARY; 845 ringtone->Format = RING_NOKIABINARY;
814 } 846 }
815 if (buffer[0]==0x4D && buffer[1]==0x54 && 847 if (buffer[0]==0x4D && buffer[1]==0x54 &&
816 buffer[2]==0x68 && buffer[3]==0x64) { 848 buffer[2]==0x68 && buffer[3]==0x64) {
817 ringtone->Format = RING_MIDI; 849 ringtone->Format = RING_MIDI;
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 }
820 rewind(file); 856 rewind(file);
821 switch (ringtone->Format) { 857 switch (ringtone->Format) {
822 case RING_NOTETONE: 858 case RING_NOTETONE:
823 if (buffer[0]==0x02 && buffer[1]==0x4A) { 859 if (buffer[0]==0x02 && buffer[1]==0x4A) {
824 error=loadott(file,ringtone); 860 error=loadott(file,ringtone);
825 } else if (buffer[0]==0xC7 && buffer[1]==0x45) { 861 } else if (buffer[0]==0xC7 && buffer[1]==0x45) {
826 error=loadcommunicator(file,ringtone); 862 error=loadcommunicator(file,ringtone);
827 } else { 863 } else {
828 error=loadrttl(file,ringtone); 864 error=loadrttl(file,ringtone);
829 } 865 }
830 ringtone->NoteTone.AllNotesScale=false; 866 ringtone->NoteTone.AllNotesScale=false;
@@ -833,24 +869,29 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
833 if (buffer[0]==0x00 && buffer[1]==0x00 && 869 if (buffer[0]==0x00 && buffer[1]==0x00 &&
834 buffer[2]==0x0C && buffer[3]==0x01) { 870 buffer[2]==0x0C && buffer[3]==0x01) {
835 error=loadbin(file,ringtone); 871 error=loadbin(file,ringtone);
836 } 872 }
837 if (buffer[0]==0x00 && buffer[1]==0x00 && 873 if (buffer[0]==0x00 && buffer[1]==0x00 &&
838 buffer[2]==0x00) { 874 buffer[2]==0x00) {
839 error=loadre(file,ringtone); 875 error=loadre(file,ringtone);
840 } 876 }
841 break; 877 break;
842 case RING_MIDI: 878 case RING_MIDI:
843 EncodeUnicode(ringtone->Name,FileName,strlen(FileName)); 879 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
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 }
846 fclose(file); 887 fclose(file);
847 return(error); 888 return(error);
848} 889}
849 890
850/* -------------------------- required with Nokia & RTTL ------------------- */ 891/* -------------------------- required with Nokia & RTTL ------------------- */
851 892
852/* Beats per Minute like written in Smart Messaging */ 893/* Beats per Minute like written in Smart Messaging */
853static int SM_BeatsPerMinute[] = { 894static int SM_BeatsPerMinute[] = {
854 25, 28, 31, 35, 40, 45, 50, 56, 63,70, 895 25, 28, 31, 35, 40, 45, 50, 56, 63,70,
855 80, 90, 100, 112, 125, 140, 160, 180, 200,225, 896 80, 90, 100, 112, 125, 140, 160, 180, 200,225,
856 250, 285, 320, 355, 400, 450, 500, 565, 635,715, 897 250, 285, 320, 355, 400, 450, 500, 565, 635,715,
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
@@ -111,39 +111,41 @@ typedef enum {
111typedef struct { 111typedef struct {
112 GSM_RingCommandType Type; 112 GSM_RingCommandType Type;
113 GSM_RingNote Note; 113 GSM_RingNote Note;
114 unsigned char Value; 114 unsigned char Value;
115} GSM_RingCommand; 115} GSM_RingCommand;
116 116
117typedef struct { 117typedef struct {
118 int NrCommands; 118 int NrCommands;
119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES]; 119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
120 bool AllNotesScale; 120 bool AllNotesScale;
121} GSM_NoteRingtone; 121} GSM_NoteRingtone;
122 122
123/* FIXME: should use BinaryTone instead? */
123/* 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;
127} GSM_NokiaBinaryRingtone; 128} GSM_NokiaBinaryRingtone;
128 129
129typedef struct { 130typedef struct {
130 unsigned char *Frame; 131 unsigned char *Buffer;
131 int Length; 132 int Length;
132} GSM_BinaryTone; 133} GSM_BinaryTone;
133 134
134typedef enum { 135typedef enum {
135 RING_NOTETONE = 1, 136 RING_NOTETONE = 1,
136 RING_NOKIABINARY, 137 RING_NOKIABINARY,
137 RING_MIDI 138 RING_MIDI,
139 RING_MMF
138} GSM_RingtoneFormat; 140} GSM_RingtoneFormat;
139 141
140/** 142/**
141 * Structure for saving various ringtones formats 143 * Structure for saving various ringtones formats
142 */ 144 */
143typedef struct { 145typedef struct {
144 /** 146 /**
145 * Ringtone saved in one of three formats 147 * Ringtone saved in one of three formats
146 */ 148 */
147 GSM_NokiaBinaryRingtone NokiaBinary; 149 GSM_NokiaBinaryRingtone NokiaBinary;
148 GSM_BinaryTone BinaryTone; 150 GSM_BinaryTone BinaryTone;
149 GSM_NoteRingtone NoteTone; 151 GSM_NoteRingtone NoteTone;
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
@@ -478,24 +478,29 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info,
478 for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { 478 for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
479 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth; 479 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth;
480 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight; 480 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight;
481 PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]); 481 PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]);
482 Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight); 482 Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight);
483 } 483 }
484 return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION); 484 return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION);
485 case SMS_MMSIndicatorLong: 485 case SMS_MMSIndicatorLong:
486 Class= 1; 486 Class= 1;
487 UDH= UDH_MMSIndicatorLong; 487 UDH= UDH_MMSIndicatorLong;
488 GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator); 488 GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator);
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:
491 case SMS_NokiaRingtone: 496 case SMS_NokiaRingtone:
492 UDH= UDH_NokiaRingtone; 497 UDH= UDH_NokiaRingtone;
493 Class= 1; 498 Class= 1;
494 /* 7 = length of UDH_NokiaRingtone UDH header */ 499 /* 7 = length of UDH_NokiaRingtone UDH header */
495 Length = GSM_MAX_8BIT_SMS_LENGTH-7; 500 Length = GSM_MAX_8BIT_SMS_LENGTH-7;
496 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); 501 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length);
497 if (Info->Entries[0].ID == SMS_NokiaRingtone) break; 502 if (Info->Entries[0].ID == SMS_NokiaRingtone) break;
498 if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) { 503 if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) {
499 UDH = UDH_NokiaRingtoneLong; 504 UDH = UDH_NokiaRingtoneLong;
500 Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3; 505 Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3;
501 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); 506 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length);
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
@@ -1,17 +1,21 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_multi_h 3#ifndef __gsm_multi_h
4#define __gsm_multi_h 4#define __gsm_multi_h
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
7#include "../gsmlogo.h" 11#include "../gsmlogo.h"
8#include "../gsmcal.h" 12#include "../gsmcal.h"
9#include "../gsmpbk.h" 13#include "../gsmpbk.h"
10#include "../gsmdata.h" 14#include "../gsmdata.h"
11#include "../gsmring.h" 15#include "../gsmring.h"
12#include "gsmsms.h" 16#include "gsmsms.h"
13 17
14/* ---------------------- multi SMS --------------------------------------- */ 18/* ---------------------- multi SMS --------------------------------------- */
15 19
16/* Identifiers for Smart Messaging 3.0 multipart SMS */ 20/* Identifiers for Smart Messaging 3.0 multipart SMS */
17 21
@@ -163,42 +167,43 @@ typedef enum {
163 /** 167 /**
164 * IMelody 1.2 168 * IMelody 1.2
165 */ 169 */
166 SMS_EMSSound12, 170 SMS_EMSSound12,
167 /** 171 /**
168 * IMelody without header - SonyEricsson extension 172 * IMelody without header - SonyEricsson extension
169 */ 173 */
170 SMS_EMSSonyEricssonSound, 174 SMS_EMSSonyEricssonSound,
171 /** 175 /**
172 * IMelody 1.0 with UPI. 176 * IMelody 1.0 with UPI.
173 */ 177 */
174 SMS_EMSSound10Long, 178 SMS_EMSSound10Long,
175 /*** 179 /**
176 * IMelody 1.2 with UPI. 180 * IMelody 1.2 with UPI.
177 */ 181 */
178 SMS_EMSSound12Long, 182 SMS_EMSSound12Long,
179 /** 183 /**
180 * IMelody without header with UPI. 184 * IMelody without header with UPI.
181 */ 185 */
182 SMS_EMSSonyEricssonSoundLong, 186 SMS_EMSSonyEricssonSoundLong,
183 SMS_EMSPredefinedSound, 187 SMS_EMSPredefinedSound,
184 SMS_EMSPredefinedAnimation, 188 SMS_EMSPredefinedAnimation,
185 SMS_EMSAnimation, 189 SMS_EMSAnimation,
186 /** 190 /**
187 * Fixed bitmap of size 16x16 or 32x32. 191 * Fixed bitmap of size 16x16 or 32x32.
188 */ 192 */
189 SMS_EMSFixedBitmap, 193 SMS_EMSFixedBitmap,
190 SMS_EMSVariableBitmap, 194 SMS_EMSVariableBitmap,
191 SMS_EMSVariableBitmapLong, 195 SMS_EMSVariableBitmapLong,
192 SMS_MMSIndicatorLong, 196 SMS_MMSIndicatorLong,
197 SMS_WAPIndicatorLong,
193 /** 198 /**
194 * Variable bitmap with black and white colors 199 * Variable bitmap with black and white colors
195 */ 200 */
196 SMS_AlcatelMonoBitmapLong, 201 SMS_AlcatelMonoBitmapLong,
197 /** 202 /**
198 * Variable animation with black and white colors 203 * Variable animation with black and white colors
199 */ 204 */
200 SMS_AlcatelMonoAnimationLong, 205 SMS_AlcatelMonoAnimationLong,
201 SMS_AlcatelSMSTemplateName 206 SMS_AlcatelSMSTemplateName
202} EncodeMultiPartSMSID; 207} EncodeMultiPartSMSID;
203 208
204typedef struct { 209typedef struct {
@@ -255,17 +260,21 @@ bool GSM_DecodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SM
255void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); 260void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
256 261
257/** 262/**
258 * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo. 263 * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo.
259 */ 264 */
260void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); 265void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
261 266
262/** 267/**
263 * Links SMS messages according to IDs. 268 * Links SMS messages according to IDs.
264 */ 269 */
265GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems); 270GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems);
266 271
272#if defined(_MSC_VER) && defined(__cplusplus)
273 }
274#endif
275
267#endif 276#endif
268 277
269/* How should editor hadle tabs in this file? Add editor commands here. 278/* How should editor hadle tabs in this file? Add editor commands here.
270 * vim: noexpandtab sw=8 ts=8 sts=8: 279 * vim: noexpandtab sw=8 ts=8 sts=8:
271 */ 280 */
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,14 +1,17 @@
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
4#include <ctype.h> 7#include <ctype.h>
5#include <string.h> 8#include <string.h>
6#include <time.h> 9#include <time.h>
7 10
8#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
9#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
10#include "../gsmcal.h" 13#include "../gsmcal.h"
11#include "../gsmpbk.h" 14#include "../gsmpbk.h"
12#include "../gsmlogo.h" 15#include "../gsmlogo.h"
13#include "../gsmring.h" 16#include "../gsmring.h"
14#include "../gsmdata.h" 17#include "../gsmdata.h"
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,14 +1,17 @@
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
4#ifndef __gsm_sms_h 7#ifndef __gsm_sms_h
5#define __gsm_sms_h 8#define __gsm_sms_h
6 9
7#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
8#include "../gsmlogo.h" 11#include "../gsmlogo.h"
9#include "../gsmcal.h" 12#include "../gsmcal.h"
10#include "../gsmpbk.h" 13#include "../gsmpbk.h"
11#include "../gsmdata.h" 14#include "../gsmdata.h"
12#include "../gsmring.h" 15#include "../gsmring.h"
13 16
14/* --------------------- Some general definitions ------------------------- */ 17/* --------------------- Some general definitions ------------------------- */
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
@@ -601,28 +601,32 @@ static GSM_Error DCT3_Reply61GetSecurityCode(GSM_Protocol_Message msg, GSM_State
601 printf("Security Code is \"%s\"\n",msg.Buffer+5); 601 printf("Security Code is \"%s\"\n",msg.Buffer+5);
602 return ERR_NONE; 602 return ERR_NONE;
603} 603}
604 604
605static GSM_Error DCT3_Reply7191GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) 605static GSM_Error DCT3_Reply7191GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
606{ 606{
607 printf("Security Code is \"%s\"\n",msg.Buffer+6); 607 printf("Security Code is \"%s\"\n",msg.Buffer+6);
608 return ERR_NONE; 608 return ERR_NONE;
609} 609}
610 610
611void DCT3GetSecurityCode(int argc, char *argv[]) 611void 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
618 if (CheckDCT3Only()!=ERR_NONE) return; 622 if (CheckDCT3Only()!=ERR_NONE) return;
619 623
620 error=DCT3_EnableSecurity (&s, 0x01); 624 error=DCT3_EnableSecurity (&s, 0x01);
621 Print_Error(error); 625 Print_Error(error);
622 626
623 s.User.UserReplyFunctions=UserReplyFunctions3; 627 s.User.UserReplyFunctions=UserReplyFunctions3;
624 628
625#ifdef GSM_ENABLE_NOKIA6110 629#ifdef GSM_ENABLE_NOKIA6110
626 if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) { 630 if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
627 error=GSM_WaitFor (&s, req6110, 4, 0x40, 4, ID_User6); 631 error=GSM_WaitFor (&s, req6110, 4, 0x40, 4, ID_User6);
628 } 632 }
@@ -758,26 +762,28 @@ void DCT3DisplayOutput(int argc, char *argv[])
758 my_sleep(10); 762 my_sleep(10);
759 } 763 }
760 764
761 req[4] = 0x02; 765 req[4] = 0x02;
762 error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7); 766 error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7);
763 Print_Error(error); 767 Print_Error(error);
764 768
765 GSM_Terminate(); 769 GSM_Terminate();
766} 770}
767#endif 771#endif
768 772
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
773 {DCT3_ReplyEnableSecurity2, "\x40",0x02,0x64,ID_EnableSecurity}, 779 {DCT3_ReplyEnableSecurity2, "\x40",0x02,0x64,ID_EnableSecurity},
774 {DCT3_ReplyResetTest36, "\x40",0x02,0x65,ID_User2 }, 780 {DCT3_ReplyResetTest36, "\x40",0x02,0x65,ID_User2 },
775 {DCT3_ReplyGetADC, "\x40",0x02,0x68,ID_User3 }, 781 {DCT3_ReplyGetADC, "\x40",0x02,0x68,ID_User3 },
776 {DCT3_ReplyGetPPS, "\x40",0x02,0x6A,ID_User4 }, 782 {DCT3_ReplyGetPPS, "\x40",0x02,0x6A,ID_User4 },
777 {DCT3_ReplySetPPS, "\x40",0x02,0x6B,ID_User4 }, 783 {DCT3_ReplySetPPS, "\x40",0x02,0x6B,ID_User4 },
778 {DCT3_Reply61GetSecurityCode, "\x40",0x02,0x6E,ID_User6 }, 784 {DCT3_Reply61GetSecurityCode, "\x40",0x02,0x6E,ID_User6 },
779 {DCT3_ReplySimlockInfo, "\x40",0x02,0x8A,ID_User3 }, 785 {DCT3_ReplySimlockInfo, "\x40",0x02,0x8A,ID_User3 },
780#ifdef GSM_ENABLE_NOKIA6110 786#ifdef GSM_ENABLE_NOKIA6110
781 {DCT3_ReplySetOperatorName, "\x40",0x02,0x8B,ID_User7 }, 787 {DCT3_ReplySetOperatorName, "\x40",0x02,0x8B,ID_User7 },
782 {DCT3_ReplyGetOperatorName, "\x40",0x02,0x8C,ID_User5 }, 788 {DCT3_ReplyGetOperatorName, "\x40",0x02,0x8C,ID_User5 },
783#endif 789#endif
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
@@ -26,25 +26,26 @@ GSM_Error CheckDCT4Only()
26 if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; 26 if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
27#endif 27#endif
28#ifdef GSM_ENABLE_NOKIA6510 28#ifdef GSM_ENABLE_NOKIA6510
29 if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; 29 if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
30#endif 30#endif
31#ifdef GSM_ENABLE_NOKIA3320 31#ifdef GSM_ENABLE_NOKIA3320
32 if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; 32 if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
33#endif 33#endif
34 if (!found) return ERR_NOTSUPPORTED; 34 if (!found) return ERR_NOTSUPPORTED;
35 35
36 if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 && 36 if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 &&
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;
40 } 41 }
41 return ERR_NONE; 42 return ERR_NONE;
42} 43}
43 44
44static void CheckDCT4() 45static void CheckDCT4()
45{ 46{
46 GSM_Error error; 47 GSM_Error error;
47 48
48 error = CheckDCT4Only(); 49 error = CheckDCT4Only();
49 switch (error) { 50 switch (error) {
50 case ERR_NOTSUPPORTED: 51 case ERR_NOTSUPPORTED:
@@ -876,24 +877,26 @@ void DCT4GetT9(int argc, char *argv[])
876 error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3); 877 error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3);
877 Print_Error(error); 878 Print_Error(error);
878 if (i==0) { 879 if (i==0) {
879 T9Dictionary = T9FullSize; 880 T9Dictionary = T9FullSize;
880 dbgprintf("T9 dictionary size is %i\n",T9Dictionary); 881 dbgprintf("T9 dictionary size is %i\n",T9Dictionary);
881 } 882 }
882 i+=T9Size; 883 i+=T9Size;
883 } 884 }
884 885
885 fclose(T9File); 886 fclose(T9File);
886} 887}
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);
889 892
890void DCT4SetLight(int argc, char *argv[]) 893void DCT4SetLight(int argc, char *argv[])
891{ 894{
892 int i; 895 int i;
893 N6510_PHONE_LIGHTS type; 896 N6510_PHONE_LIGHTS type;
894 bool enable; 897 bool enable;
895 898
896 if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY; 899 if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY;
897 } else if (mystrncasecmp(argv[2],"keypad",0)) {type = N6510_LIGHT_KEYPAD; 900 } else if (mystrncasecmp(argv[2],"keypad",0)) {type = N6510_LIGHT_KEYPAD;
898 } else if (mystrncasecmp(argv[2],"torch",0)) {type = N6510_LIGHT_TORCH; 901 } else if (mystrncasecmp(argv[2],"torch",0)) {type = N6510_LIGHT_TORCH;
899 } else { 902 } else {
@@ -912,24 +915,25 @@ void DCT4SetLight(int argc, char *argv[])
912 s.Config[i].StartInfo = "false"; 915 s.Config[i].StartInfo = "false";
913 } 916 }
914 917
915 GSM_Init(true); 918 GSM_Init(true);
916 919
917 CheckDCT4(); 920 CheckDCT4();
918 921
919 error=N6510_SetLight(&s, type, enable); 922 error=N6510_SetLight(&s, type, enable);
920 Print_Error(error); 923 Print_Error(error);
921 924
922 GSM_Terminate(); 925 GSM_Terminate();
923} 926}
927#endif
924 928
925void DCT4DisplayTest(int argc, char *argv[]) 929void DCT4DisplayTest(int argc, char *argv[])
926{ 930{
927 unsigned char ans[200]; 931 unsigned char ans[200];
928 unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00}; 932 unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00};
929 unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04, 933 unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04,
930 0x09, /* test number */ 934 0x09, /* test number */
931 0x00}; 935 0x00};
932 936
933 if (CheckDCT4Only()!=ERR_NONE) return; 937 if (CheckDCT4Only()!=ERR_NONE) return;
934 938
935 s.User.UserReplyFunctions=UserReplyFunctions4; 939 s.User.UserReplyFunctions=UserReplyFunctions4;
@@ -1012,24 +1016,26 @@ void DCT4GetADC(int argc, char *argv[])
1012 error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3); 1016 error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3);
1013 Print_Error(error); 1017 Print_Error(error);
1014 GetUnit[4] = i; 1018 GetUnit[4] = i;
1015 ADC = DCT4ADC[i].x; 1019 ADC = DCT4ADC[i].x;
1016 error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3); 1020 error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3);
1017 Print_Error(error); 1021 Print_Error(error);
1018 printf("%s\n",DCT4ADC[i].unit); 1022 printf("%s\n",DCT4ADC[i].unit);
1019 i++; 1023 i++;
1020 if (DCT4ADC[i].name[0] == 0x00) break; 1024 if (DCT4ADC[i].name[0] == 0x00) break;
1021 } 1025 }
1022} 1026}
1023 1027
1028#ifdef GSM_ENABLE_NOKIA6510
1029
1024 static double RadioFreq; 1030 static double RadioFreq;
1025 static unsigned char RadioName[100]; 1031 static unsigned char RadioName[100];
1026 1032
1027static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s) 1033static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s)
1028{ 1034{
1029 int length; 1035 int length;
1030 unsigned char name[100]; 1036 unsigned char name[100];
1031 1037
1032 switch (msg.Buffer[3]) { 1038 switch (msg.Buffer[3]) {
1033 case 0x09: 1039 case 0x09:
1034 N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16); 1040 N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16);
1035 1041
@@ -1165,24 +1171,25 @@ void DCT4TuneRadio(int argc, char *argv[])
1165 error=Phone->SetFMStation(&s,&FMStation[i]); 1171 error=Phone->SetFMStation(&s,&FMStation[i]);
1166 Print_Error(error); 1172 Print_Error(error);
1167 fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num); 1173 fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num);
1168 } 1174 }
1169 fprintf(stderr,"\n"); 1175 fprintf(stderr,"\n");
1170 } 1176 }
1171 1177
1172 error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3); 1178 error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3);
1173 Print_Error(error); 1179 Print_Error(error);
1174 1180
1175 GSM_Terminate(); 1181 GSM_Terminate();
1176} 1182}
1183#endif
1177 1184
1178void DCT4PlaySavedRingtone(int argc, char *argv[]) 1185void DCT4PlaySavedRingtone(int argc, char *argv[])
1179{ 1186{
1180 unsigned char req[] = {N6110_FRAME_HEADER, 1187 unsigned char req[] = {N6110_FRAME_HEADER,
1181 0x01, 1188 0x01,
1182 0x00,0x64,//id 1189 0x00,0x64,//id
1183 0x01, //group 1190 0x01, //group
1184 0x01,0x00,0x00, 1191 0x01,0x00,0x00,
1185 0x0A, //volume 1192 0x0A, //volume
1186 0x00,0x00,0x00,0x00,0x00,0x00,0x00}; 1193 0x00,0x00,0x00,0x00,0x00,0x00,0x00};
1187 GSM_AllRingtonesInfo Info; 1194 GSM_AllRingtonesInfo Info;
1188 1195
@@ -1304,28 +1311,30 @@ static GSM_Reply_Function UserReplyFunctions4[] = {
1304 1311
1305 {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1}, 1312 {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1},
1306 {DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3}, 1313 {DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3},
1307 {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4}, 1314 {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4},
1308 {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4}, 1315 {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4},
1309 {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1}, 1316 {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1},
1310 1317
1311 {DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3}, 1318 {DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3},
1312 {DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3}, 1319 {DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3},
1313 {DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1}, 1320 {DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1},
1314 {DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2}, 1321 {DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2},
1315 1322
1323#ifdef GSM_ENABLE_NOKIA6510
1316 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3}, 1324 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3},
1317 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3}, 1325 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3},
1318 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation}, 1326 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation},
1319 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3}, 1327 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3},
1328#endif
1320 1329
1321 {DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4}, 1330 {DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4},
1322 1331
1323 {DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6}, 1332 {DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6},
1324 {DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6}, 1333 {DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6},
1325 1334
1326 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3}, 1335 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3},
1327 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3}, 1336 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3},
1328 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3}, 1337 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3},
1329 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3}, 1338 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3},
1330 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3}, 1339 {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3},
1331 1340
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
@@ -1,35 +1,38 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#include "../../../common/gsmstate.h" 3#include "../../../common/gsmstate.h"
4 4
5 void DCT4SetPhoneMenus (int argc, char *argv[]); 5 void DCT4SetPhoneMenus (int argc, char *argv[]);
6 void DCT4SelfTests (int argc, char *argv[]); 6 void DCT4SelfTests (int argc, char *argv[]);
7 void DCT4SetVibraLevel (int argc, char *argv[]); 7 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[]);
13 void DCT4Info (int argc, char *argv[]); 10 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[]);
17 void DCT4GetADC (int argc, char *argv[]); 13 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[]);
21void DCT4MakeCameraShoot (int argc, char *argv[]); 16void DCT4MakeCameraShoot (int argc, char *argv[]);
22 void DCT4GetScreenDump (int argc, char *argv[]); 17 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 ------------------------------------- */
25 28
26typedef enum { 29typedef enum {
27 DCT4_ALWAYS_ONLINE = 1, 30 DCT4_ALWAYS_ONLINE = 1,
28 DCT4_GPRS_PCCH, 31 DCT4_GPRS_PCCH,
29 DCT4_GEA1, 32 DCT4_GEA1,
30 DCT4_EOTD, 33 DCT4_EOTD,
31 DCT4_WAP_PUSH, 34 DCT4_WAP_PUSH,
32 DCT4_USE_PREF_SIM_NET, 35 DCT4_USE_PREF_SIM_NET,
33 DCT4_JAVA_TCK, 36 DCT4_JAVA_TCK,
34 37
35 DCT4_ALS, 38 DCT4_ALS,
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
@@ -1,24 +1,23 @@
1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ 1/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
2/* FM stuff by Walek */ 2/* FM stuff by Walek */
3 3
4#include <string.h> 4#include <string.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <stdarg.h> 7#include <stdarg.h>
8#include <locale.h> 8#include <locale.h>
9#include <signal.h> 9#include <signal.h>
10#include <ctype.h> 10#include <ctype.h>
11#include <wchar.h> 11#include <wchar.h>
12#undef HAVE_MYSQL_MYSQL_H
13#ifdef WIN32 12#ifdef WIN32
14# include <windows.h> 13# include <windows.h>
15# include <process.h> 14# include <process.h>
16# ifdef _MSC_VER 15# ifdef _MSC_VER
17# include <sys/utime.h> 16# include <sys/utime.h>
18# else 17# else
19# include <utime.h> 18# include <utime.h>
20# endif 19# endif
21#else 20#else
22# include <utime.h> 21# include <utime.h>
23#endif 22#endif
24 23
@@ -39,45 +38,33 @@
39# include "depend/siemens/dsiemens.h" 38# include "depend/siemens/dsiemens.h"
40#endif 39#endif
41 40
42#ifdef HAVE_PTHREAD 41#ifdef HAVE_PTHREAD
43# include <pthread.h> 42# include <pthread.h>
44#endif 43#endif
45 44
46#ifdef HAVE_SYS_IOCTL_H 45#ifdef HAVE_SYS_IOCTL_H
47# include <sys/ioctl.h> 46# include <sys/ioctl.h>
48#endif 47#endif
49 48
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)
73{ 60{
74 signal(sign, SIG_IGN); 61 signal(sign, SIG_IGN);
75 gshutdown = true; 62 gshutdown = true;
76} 63}
77 64
78#ifdef __GNUC__ 65#ifdef __GNUC__
79__attribute__((format(printf, 1, 2))) 66__attribute__((format(printf, 1, 2)))
80#endif 67#endif
81int printmsg(char *format, ...) 68int printmsg(char *format, ...)
82{ 69{
83 va_list argp; 70 va_list argp;
@@ -234,24 +221,25 @@ static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
234 221
235 for (i=0;i<ringtone.NoteTone.NrCommands;i++) { 222 for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
236 if (gshutdown) break; 223 if (gshutdown) break;
237 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue; 224 if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue;
238 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first); 225 error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first);
239 if (error!=ERR_NONE) return error; 226 if (error!=ERR_NONE) return error;
240 first = false; 227 first = false;
241 } 228 }
242 229
243 /* Disables buzzer */ 230 /* Disables buzzer */
244 return s.Phone.Functions->PlayTone(&s,255*255,0,false); 231 return s.Phone.Functions->PlayTone(&s,255*255,0,false);
245} 232}
233
246static void PlayRingtone(int argc, char *argv[]) 234static void PlayRingtone(int argc, char *argv[])
247{ 235{
248 GSM_Ringtone ringtone,ringtone2; 236 GSM_Ringtone ringtone,ringtone2;
249 237
250 ringtone.Format= 0; 238 ringtone.Format= 0;
251 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 239 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
252 Print_Error(error); 240 Print_Error(error);
253 241
254 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE); 242 error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE);
255 Print_Error(error); 243 Print_Error(error);
256 244
257 GSM_Init(true); 245 GSM_Init(true);
@@ -332,25 +320,24 @@ static void Identify(int argc, char *argv[])
332 } 320 }
333 321
334#ifdef GSM_ENABLE_NOKIA_DCT3 322#ifdef GSM_ENABLE_NOKIA_DCT3
335 DCT3Info(argc, argv); 323 DCT3Info(argc, argv);
336#endif 324#endif
337#ifdef GSM_ENABLE_NOKIA_DCT4 325#ifdef GSM_ENABLE_NOKIA_DCT4
338 DCT4Info(argc, argv); 326 DCT4Info(argc, argv);
339#endif 327#endif
340 328
341 GSM_Terminate(); 329 GSM_Terminate();
342} 330}
343 331
344//#if 0
345static void GetDateTime(int argc, char *argv[]) 332static void GetDateTime(int argc, char *argv[])
346{ 333{
347 GSM_DateTime date_time; 334 GSM_DateTime date_time;
348 GSM_Localelocale; 335 GSM_Localelocale;
349 336
350 GSM_Init(true); 337 GSM_Init(true);
351 338
352 error=Phone->GetDateTime(&s, &date_time); 339 error=Phone->GetDateTime(&s, &date_time);
353 switch (error) { 340 switch (error) {
354 case ERR_EMPTY: 341 case ERR_EMPTY:
355 printmsg("Date and time not set in phone\n"); 342 printmsg("Date and time not set in phone\n");
356 break; 343 break;
@@ -366,24 +353,25 @@ static void GetDateTime(int argc, char *argv[])
366 case ERR_NOTSUPPORTED: 353 case ERR_NOTSUPPORTED:
367 case ERR_NOTIMPLEMENTED: 354 case ERR_NOTIMPLEMENTED:
368 break; 355 break;
369 default: 356 default:
370 Print_Error(error); 357 Print_Error(error);
371 printmsg("Time format is "); 358 printmsg("Time format is ");
372 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n"); 359 if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n");
373 printmsg("Date format is "); 360 printmsg("Date format is ");
374 switch (locale.DateFormat) { 361 switch (locale.DateFormat) {
375 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break; 362 case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break;
376 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break; 363 case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break;
377 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD"); 364 case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
365 default :break;
378 } 366 }
379 printmsg(", date separator is %c\n",locale.DateSeparator); 367 printmsg(", date separator is %c\n",locale.DateSeparator);
380 } 368 }
381 369
382 GSM_Terminate(); 370 GSM_Terminate();
383} 371}
384 372
385static void SetDateTime(int argc, char *argv[]) 373static void SetDateTime(int argc, char *argv[])
386{ 374{
387 GSM_DateTime date_time; 375 GSM_DateTime date_time;
388 376
389 GSM_GetCurrentDateTime(&date_time); 377 GSM_GetCurrentDateTime(&date_time);
@@ -578,65 +566,82 @@ static void GetAllMemory(int argc, char *argv[])
578 if (error == ERR_EMPTY) break; 566 if (error == ERR_EMPTY) break;
579 Print_Error(error); 567 Print_Error(error);
580 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location); 568 printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
581 PrintMemoryEntry(&Entry); 569 PrintMemoryEntry(&Entry);
582 start = false; 570 start = false;
583 } 571 }
584 572
585 GSM_Terminate(); 573 GSM_Terminate();
586} 574}
587 575
588static void GetMemory(int argc, char *argv[]) 576static 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
593 entry.MemoryType=0; 582 entry.MemoryType=0;
594 583
595 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC; 584 if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC;
596 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON; 585 if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON;
597 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC; 586 if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC;
598 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC; 587 if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC;
599 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME; 588 if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME;
600 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM; 589 if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM;
601 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM; 590 if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM;
602 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD; 591 if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD;
603 if (entry.MemoryType==0) { 592 if (entry.MemoryType==0) {
604 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]); 593 printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
605 exit (-1); 594 exit (-1);
606 } 595 }
607 596
608 GetStartStop(&start, &stop, 3, argc, argv); 597 GetStartStop(&start, &stop, 3, argc, 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);
611 609
612 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) { 610 if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) {
613 if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n"); 611 if (s.Phone.Data.VerNum<=4.06) printmsg("WARNING: you will have null names in entries. Upgrade firmware in phone to higher than 4.06\n");
614 } 612 }
615 613
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
619 entry.Location=j; 617 entry.Location=j;
620 618
621 error=Phone->GetMemory(&s, &entry); 619 error=Phone->GetMemory(&s, &entry);
622 if (error != ERR_EMPTY) Print_Error(error); 620 if (error != ERR_EMPTY) Print_Error(error);
623 621
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);
629 } 632 }
630 } 633 }
634
635 printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
631 636
632 GSM_Terminate(); 637 GSM_Terminate();
633} 638}
634 639
635#define MemoryLocationToString(x) ( \ 640#define MemoryLocationToString(x) ( \
636 x == MEM_ON ? "ON" : \ 641 x == MEM_ON ? "ON" : \
637 x == MEM_RC ? "RC" : \ 642 x == MEM_RC ? "RC" : \
638 x == MEM_MC ? "MC" : \ 643 x == MEM_MC ? "MC" : \
639 x == MEM_ME ? "ME" : \ 644 x == MEM_ME ? "ME" : \
640 x == MEM_SM ? "SM" : \ 645 x == MEM_SM ? "SM" : \
641 x == MEM_VM ? "VM" : \ 646 x == MEM_VM ? "VM" : \
642 x == MEM_FD ? "FD" : "XX") 647 x == MEM_FD ? "FD" : "XX")
@@ -665,25 +670,25 @@ static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
665 case PBK_Text_Company : 670 case PBK_Text_Company :
666 case PBK_Text_JobTitle : 671 case PBK_Text_JobTitle :
667 case PBK_Text_StreetAddress : 672 case PBK_Text_StreetAddress :
668 case PBK_Text_City : 673 case PBK_Text_City :
669 case PBK_Text_State : 674 case PBK_Text_State :
670 case PBK_Text_Zip : 675 case PBK_Text_Zip :
671 case PBK_Text_Country : 676 case PBK_Text_Country :
672 case PBK_Text_Custom1 : 677 case PBK_Text_Custom1 :
673 case PBK_Text_Custom2 : 678 case PBK_Text_Custom2 :
674 case PBK_Text_Custom3 : 679 case PBK_Text_Custom3 :
675 case PBK_Text_Custom4 : 680 case PBK_Text_Custom4 :
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");
679 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location); 684 printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location);
680 PrintMemoryEntry(Entry); 685 PrintMemoryEntry(Entry);
681 return; 686 return;
682 } 687 }
683 break; 688 break;
684 default: 689 default:
685 break; 690 break;
686 } 691 }
687 } 692 }
688 } 693 }
689 694
@@ -815,48 +820,48 @@ static void ListMemoryCategory(int argc, char *argv[])
815 EncodeUnicode(Text, argv[2], Length); 820 EncodeUnicode(Text, argv[2], Length);
816 821
817 Category.Type = Category_Phonebook; 822 Category.Type = Category_Phonebook;
818 Status.Type = Category_Phonebook; 823 Status.Type = Category_Phonebook;
819 824
820 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 825 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
821 for (count=0,j=1;count<Status.Used;j++) { 826 for (count=0,j=1;count<Status.Used;j++) {
822 Category.Location=j; 827 Category.Location=j;
823 error=Phone->GetCategory(&s, &Category); 828 error=Phone->GetCategory(&s, &Category);
824 829
825 if (error != ERR_EMPTY) { 830 if (error != ERR_EMPTY) {
826 count++; 831 count++;
827 if (mystrstr(Category.Name, Text) != NULL) { 832 if (mywstrstr(Category.Name, Text) != NULL) {
828 ListMemoryCategoryEntries(j); 833 ListMemoryCategoryEntries(j);
829 } 834 }
830 } 835 }
831 } 836 }
832 } 837 }
833 } 838 }
834 GSM_Terminate(); 839 GSM_Terminate();
835} 840}
836 841
837static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh) 842static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh)
838{ 843{
839 switch (sms.PDU) { 844 switch (sms.PDU) {
840 case SMS_Status_Report: 845 case SMS_Status_Report:
841 printmsg("SMS status report\n"); 846 printmsg("SMS status report\n");
842 printmsg("Status : "); 847 printmsg("Status : ");
843 switch (sms.State) { 848 switch (sms.State) {
844 case SMS_Sent : printmsg("Sent");break; 849 case SMS_Sent : printmsg("Sent");break;
845 case SMS_Read : printmsg("Read");break; 850 case SMS_Read : printmsg("Read");break;
846 case SMS_UnRead : printmsg("UnRead");break; 851 case SMS_UnRead : printmsg("UnRead");break;
847 case SMS_UnSent : printmsg("UnSent");break; 852 case SMS_UnSent : printmsg("UnSent");break;
848 } 853 }
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));
852 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number)); 857 printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number));
853 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true)); 858 printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true));
854 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text)); 859 printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text));
855 printmsg("Details : "); 860 printmsg("Details : ");
856 if (sms.DeliveryStatus & 0x40) { 861 if (sms.DeliveryStatus & 0x40) {
857 if (sms.DeliveryStatus & 0x20) { 862 if (sms.DeliveryStatus & 0x20) {
858 printmsg("Temporary error, "); 863 printmsg("Temporary error, ");
859 } else { 864 } else {
860 printmsg("Permanent error, "); 865 printmsg("Permanent error, ");
861 } 866 }
862 } else if (sms.DeliveryStatus & 0x20) { 867 } else if (sms.DeliveryStatus & 0x20) {
@@ -885,58 +890,68 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
885 case 0x60: printmsg("Congestion"); break; 890 case 0x60: printmsg("Congestion"); break;
886 case 0x61: printmsg("SME busy"); break; 891 case 0x61: printmsg("SME busy"); break;
887 case 0x62: printmsg("No response from SME"); break; 892 case 0x62: printmsg("No response from SME"); break;
888 case 0x63: printmsg("Service rejected"); break; 893 case 0x63: printmsg("Service rejected"); break;
889 case 0x64: printmsg("Quality of service not available"); break; 894 case 0x64: printmsg("Quality of service not available"); break;
890 case 0x65: printmsg("Error in SME"); break; 895 case 0x65: printmsg("Error in SME"); break;
891 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break; 896 default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus);break;
892 } 897 }
893 printf("\n"); 898 printf("\n");
894 break; 899 break;
895 case SMS_Deliver: 900 case SMS_Deliver:
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,
901 * that SMS_Deliver contains additional data. We wrote them and then go 910 * that SMS_Deliver contains additional data. We wrote them and then go
902 * for data shared with SMS_Submit 911 * for data shared with SMS_Submit
903 */ 912 */
904 case SMS_Submit: 913 case SMS_Submit:
905 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage); 914 if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage);
906 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */ 915 /* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
907 if (sms.PDU==SMS_Submit) { 916 if (sms.PDU==SMS_Submit) {
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 }
911 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) { 923 if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) {
912 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name)); 924 printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name));
913 } 925 }
914 if (sms.Class != -1) { 926 if (sms.Class != -1) {
915 printmsg("Class : %i\n",sms.Class); 927 printmsg("Class : %i\n",sms.Class);
916 } 928 }
917 printmsg("Coding : "); 929 printmsg("Coding : ");
918 switch (sms.Coding) { 930 switch (sms.Coding) {
919 case SMS_Coding_Unicode : printmsg("Unicode\n"); break; 931 case SMS_Coding_Unicode : printmsg("Unicode\n"); break;
920 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break; 932 case SMS_Coding_Default : printmsg("Default GSM alphabet\n");break;
921 case SMS_Coding_8bit : printmsg("8 bit\n"); break; 933 case SMS_Coding_8bit : printmsg("8 bit\n"); break;
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) {
932 printmsg("User Data Header : "); 947 printmsg("User Data Header : ");
933 switch (sms.UDH.Type) { 948 switch (sms.UDH.Type) {
934 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break; 949 case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break;
935 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break; 950 case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break;
936 case UDH_DisableVoice : printmsg("Disables voice indicator"); break; 951 case UDH_DisableVoice : printmsg("Disables voice indicator"); break;
937 case UDH_EnableVoice : printmsg("Enables voice indicator"); break; 952 case UDH_EnableVoice : printmsg("Enables voice indicator"); break;
938 case UDH_DisableFax : printmsg("Disables fax indicator"); break; 953 case UDH_DisableFax : printmsg("Disables fax indicator"); break;
939 case UDH_EnableFax : printmsg("Enables fax indicator"); break; 954 case UDH_EnableFax : printmsg("Enables fax indicator"); break;
940 case UDH_DisableEmail : printmsg("Disables email indicator"); break; 955 case UDH_DisableEmail : printmsg("Disables email indicator"); break;
941 case UDH_EnableEmail : printmsg("Enables email indicator"); break; 956 case UDH_EnableEmail : printmsg("Enables email indicator"); break;
942 case UDH_VoidSMS : printmsg("Void SMS"); break; 957 case UDH_VoidSMS : printmsg("Void SMS"); break;
@@ -969,25 +984,25 @@ static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool disp
969 } 984 }
970 if (displaytext) { 985 if (displaytext) {
971 printf("\n"); 986 printf("\n");
972 if (sms.Coding!=SMS_Coding_8bit) { 987 if (sms.Coding!=SMS_Coding_8bit) {
973 printmsg("%s\n",DecodeUnicodeConsole(sms.Text)); 988 printmsg("%s\n",DecodeUnicodeConsole(sms.Text));
974 } else { 989 } else {
975 printmsg("8 bit SMS, cannot be displayed here\n"); 990 printmsg("8 bit SMS, cannot be displayed here\n");
976 } 991 }
977 } 992 }
978 break; 993 break;
979 } 994 }
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)
983{ 998{
984 GSM_MultiPartSMSInfoSMSInfo; 999 GSM_MultiPartSMSInfoSMSInfo;
985 bool RetVal,udhinfo=true; 1000 bool RetVal,udhinfo=true;
986 int j; 1001 int j;
987 1002
988 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */ 1003 /* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
989 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems); 1004 RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems);
990 1005
991 if (eachsms) { 1006 if (eachsms) {
992 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false; 1007 if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false;
993 if (RetVal && !udhinfo) { 1008 if (RetVal && !udhinfo) {
@@ -1276,32 +1291,39 @@ static void Monitor(int argc, char *argv[])
1276 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName)); 1291 printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
1277 } 1292 }
1278 } 1293 }
1279 } 1294 }
1280 printf("\n"); 1295 printf("\n");
1281 } 1296 }
1282 1297
1283 printmsg("Leaving monitor mode...\n"); 1298 printmsg("Leaving monitor mode...\n");
1284 1299
1285 GSM_Terminate(); 1300 GSM_Terminate();
1286} 1301}
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[])
1289{ 1311{
1290 GSM_Init(true); 1312 GSM_Init(true);
1291 1313
1292 signal(SIGINT, interrupt); 1314 signal(SIGINT, interrupt);
1293 printmsgerr("Press Ctrl+C to break...\n"); 1315 printmsgerr("Press Ctrl+C to break...\n");
1294 1316
1295 s.User.IncomingUSSD = IncomingUSSD; 1317 s.User.IncomingUSSD = IncomingUSSD2;
1296 1318
1297 error=Phone->SetIncomingUSSD(&s,true); 1319 error=Phone->SetIncomingUSSD(&s,true);
1298 Print_Error(error); 1320 Print_Error(error);
1299 1321
1300 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence); 1322 error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence);
1301 Print_Error(error); 1323 Print_Error(error);
1302 1324
1303 while (!gshutdown) GSM_ReadDevice(&s,true); 1325 while (!gshutdown) GSM_ReadDevice(&s,true);
1304 1326
1305 GSM_Terminate(); 1327 GSM_Terminate();
1306} 1328}
1307 1329
@@ -1336,25 +1358,34 @@ static void GetSMSC(int argc, char *argv[])
1336 case SMS_FORMAT_Pager : printmsg("Pager");break; 1358 case SMS_FORMAT_Pager : printmsg("Pager");break;
1337 } 1359 }
1338 printf("\n"); 1360 printf("\n");
1339 1361
1340 printmsg("Validity : "); 1362 printmsg("Validity : ");
1341 switch (smsc.Validity.Relative) { 1363 switch (smsc.Validity.Relative) {
1342 case SMS_VALID_1_Hour : printmsg("1 hour"); break; 1364 case SMS_VALID_1_Hour : printmsg("1 hour"); break;
1343 case SMS_VALID_6_Hours : printmsg("6 hours"); break; 1365 case SMS_VALID_6_Hours : printmsg("6 hours"); break;
1344 case SMS_VALID_1_Day : printmsg("24 hours"); break; 1366 case SMS_VALID_1_Day : printmsg("24 hours"); break;
1345 case SMS_VALID_3_Days : printmsg("72 hours"); break; 1367 case SMS_VALID_3_Days : printmsg("72 hours"); break;
1346 case SMS_VALID_1_Week : printmsg("1 week"); break; 1368 case SMS_VALID_1_Week : printmsg("1 week"); break;
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 }
1350 printf("\n"); 1381 printf("\n");
1351 } 1382 }
1352 1383
1353 GSM_Terminate(); 1384 GSM_Terminate();
1354} 1385}
1355 1386
1356static void GetSMS(int argc, char *argv[]) 1387static void GetSMS(int argc, char *argv[])
1357{ 1388{
1358 GSM_MultiSMSMessagesms; 1389 GSM_MultiSMSMessagesms;
1359 GSM_SMSFolders folders; 1390 GSM_SMSFolders folders;
1360 int start, stop; 1391 int start, stop;
@@ -1419,45 +1450,43 @@ static void DeleteSMS(int argc, char *argv[])
1419 1450
1420static void GetAllSMS(int argc, char *argv[]) 1451static void GetAllSMS(int argc, char *argv[])
1421{ 1452{
1422 GSM_MultiSMSMessage sms; 1453 GSM_MultiSMSMessage sms;
1423 GSM_SMSFolders folders; 1454 GSM_SMSFolders folders;
1424 bool start = true; 1455 bool start = true;
1425 1456
1426 GSM_Init(true); 1457 GSM_Init(true);
1427 1458
1428 error=Phone->GetSMSFolders(&s, &folders); 1459 error=Phone->GetSMSFolders(&s, &folders);
1429 Print_Error(error); 1460 Print_Error(error);
1430 1461
1431 fprintf(stderr,"Reading: ");
1432 while (error == ERR_NONE) { 1462 while (error == ERR_NONE) {
1433 sms.SMS[0].Folder=0x00; 1463 sms.SMS[0].Folder=0x00;
1434 error=Phone->GetNextSMS(&s, &sms, start); 1464 error=Phone->GetNextSMS(&s, &sms, start);
1435 switch (error) { 1465 switch (error) {
1436 case ERR_EMPTY: 1466 case ERR_EMPTY:
1437 break; 1467 break;
1438 default: 1468 default:
1439 Print_Error(error); 1469 Print_Error(error);
1440 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name)); 1470 printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
1441 switch(sms.SMS[0].Memory) { 1471 switch(sms.SMS[0].Memory) {
1442 case MEM_SM: printmsg(", SIM memory"); break; 1472 case MEM_SM: printmsg(", SIM memory"); break;
1443 case MEM_ME: printmsg(", phone memory"); break; 1473 case MEM_ME: printmsg(", phone memory"); break;
1444 case MEM_MT: printmsg(", phone or SIM memory"); break; 1474 case MEM_MT: printmsg(", phone or SIM memory"); break;
1445 default : break; 1475 default : break;
1446 } 1476 }
1447 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder"); 1477 if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
1448 printf("\n"); 1478 printf("\n");
1449 displaymultismsinfo(sms,false,false); 1479 displaymultismsinfo(sms,false,false);
1450 } 1480 }
1451 fprintf(stderr,"*");
1452 start=false; 1481 start=false;
1453 } 1482 }
1454 fprintf(stderr,"\n"); 1483 fprintf(stderr,"\n");
1455 1484
1456#ifdef GSM_ENABLE_BEEP 1485#ifdef GSM_ENABLE_BEEP
1457 GSM_PhoneBeep(); 1486 GSM_PhoneBeep();
1458#endif 1487#endif
1459 GSM_Terminate(); 1488 GSM_Terminate();
1460} 1489}
1461 1490
1462static void GetEachSMS(int argc, char *argv[]) 1491static void GetEachSMS(int argc, char *argv[])
1463{ 1492{
@@ -1570,25 +1599,26 @@ static void GetRingtone(int argc, char *argv[])
1570 GetStartStop(&ringtone.Location, NULL, 2, argc, argv); 1599 GetStartStop(&ringtone.Location, NULL, 2, argc, argv);
1571 1600
1572 GSM_Init(true); 1601 GSM_Init(true);
1573 1602
1574 ringtone.Format=0; 1603 ringtone.Format=0;
1575 1604
1576 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone); 1605 error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone);
1577 Print_Error(error); 1606 Print_Error(error);
1578 1607
1579 switch (ringtone.Format) { 1608 switch (ringtone.Format) {
1580 case RING_NOTETONE : printmsg("Smart Messaging");break; 1609 case RING_NOTETONE : printmsg("Smart Messaging");break;
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 }
1584 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name)); 1614 printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name));
1585 1615
1586 if (argc==4) { 1616 if (argc==4) {
1587 error=GSM_SaveRingtoneFile(argv[3], &ringtone); 1617 error=GSM_SaveRingtoneFile(argv[3], &ringtone);
1588 Print_Error(error); 1618 Print_Error(error);
1589 } 1619 }
1590 1620
1591 GSM_Terminate(); 1621 GSM_Terminate();
1592} 1622}
1593 1623
1594static void GetRingtonesList(int argc, char *argv[]) 1624static void GetRingtonesList(int argc, char *argv[])
@@ -2033,26 +2063,26 @@ static void GetAllCalendar(int argc, char *argv[])
2033{ 2063{
2034 GSM_CalendarEntryNote; 2064 GSM_CalendarEntryNote;
2035 bool refresh= true; 2065 bool refresh= true;
2036 2066
2037 signal(SIGINT, interrupt); 2067 signal(SIGINT, interrupt);
2038 printmsgerr("Press Ctrl+C to break...\n"); 2068 printmsgerr("Press Ctrl+C to break...\n");
2039 2069
2040 GSM_Init(true); 2070 GSM_Init(true);
2041 2071
2042 while (!gshutdown) { 2072 while (!gshutdown) {
2043 error=Phone->GetNextCalendar(&s,&Note,refresh); 2073 error=Phone->GetNextCalendar(&s,&Note,refresh);
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;
2048 } 2078 }
2049 2079
2050 GSM_Terminate(); 2080 GSM_Terminate();
2051} 2081}
2052 2082
2053static void GetCalendarSettings(int argc, char *argv[]) 2083static void GetCalendarSettings(int argc, char *argv[])
2054{ 2084{
2055 GSM_CalendarSettings settings; 2085 GSM_CalendarSettings settings;
2056 2086
2057 GSM_Init(true); 2087 GSM_Init(true);
2058 2088
@@ -2233,24 +2263,26 @@ static void GetBitmap(int argc, char *argv[])
2233 case GSM_OperatorLogo: 2263 case GSM_OperatorLogo:
2234 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) { 2264 if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) {
2235 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2265 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2236 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); 2266 if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
2237 } else { 2267 } else {
2238 printmsg("No operator logo in phone\n"); 2268 printmsg("No operator logo in phone\n");
2239 } 2269 }
2240 break; 2270 break;
2241 case GSM_PictureImage: 2271 case GSM_PictureImage:
2242 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); 2272 GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
2243 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2273 printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
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);
2246 break; 2278 break;
2247 case GSM_WelcomeNote_Text: 2279 case GSM_WelcomeNote_Text:
2248 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2280 printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2249 break; 2281 break;
2250 case GSM_DealerNote_Text: 2282 case GSM_DealerNote_Text:
2251 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); 2283 printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
2252 break; 2284 break;
2253 default: 2285 default:
2254 break; 2286 break;
2255 } 2287 }
2256 Print_Error(error); 2288 Print_Error(error);
@@ -2496,50 +2528,50 @@ static void DisplaySMSFrame(GSM_SMSMessage *SMS)
2496 req[current++]=buffer[PHONE_SMSSubmit.TPDCS]; 2528 req[current++]=buffer[PHONE_SMSSubmit.TPDCS];
2497 req[current++]=buffer[PHONE_SMSSubmit.TPVP]; 2529 req[current++]=buffer[PHONE_SMSSubmit.TPVP];
2498 req[current++]=buffer[PHONE_SMSSubmit.TPUDL]; 2530 req[current++]=buffer[PHONE_SMSSubmit.TPUDL];
2499 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i]; 2531 for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i];
2500 EncodeHexBin(hexreq, req, current); 2532 EncodeHexBin(hexreq, req, current);
2501 printmsg("%s\n\n",hexreq); 2533 printmsg("%s\n\n",hexreq);
2502#endif 2534#endif
2503} 2535}
2504 2536
2505#define SEND_SAVE_SMS_BUFFER_SIZE 10000 2537#define SEND_SAVE_SMS_BUFFER_SIZE 10000
2506 2538
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)
2510{ 2542{
2511 dbgprintf("Sent SMS on device: \"%s\"\n",Device); 2543 dbgprintf("Sent SMS on device: \"%s\"\n",Device);
2512 if (status==0) { 2544 if (status==0) {
2513 printmsg("..OK"); 2545 printmsg("..OK");
2514 SMSStatus = ERR_NONE; 2546 SMSStatus = ERR_NONE;
2515 } else { 2547 } else {
2516 printmsg("..error %i",status); 2548 printmsg("..error %i",status);
2517 SMSStatus = ERR_UNKNOWN; 2549 SMSStatus = ERR_UNKNOWN;
2518 } 2550 }
2519 printmsg(", message reference=%02x\n",MessageReference); 2551 printmsg(", message reference=%d\n",MessageReference);
2520} 2552}
2521 2553
2522static void SendSaveDisplaySMS(int argc, char *argv[]) 2554static void SendSaveDisplaySMS(int argc, char *argv[])
2523{ 2555{
2524#ifdef GSM_ENABLE_BACKUP 2556#ifdef GSM_ENABLE_BACKUP
2525 GSM_Backup Backup; 2557 GSM_Backup Backup;
2526#endif 2558#endif
2527 int i,j,z,FramesNum = 0; 2559 int i,j,z,FramesNum = 0;
2528 int Protected = 0; 2560 int Protected = 0;
2529 GSM_SMSFolders folders; 2561 GSM_SMSFolders folders;
2530 GSM_MultiSMSMessage sms; 2562 GSM_MultiSMSMessage sms;
2531 GSM_Ringtone ringtone[MAX_MULTI_SMS]; 2563 GSM_Ringtone ringtone[MAX_MULTI_SMS];
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;
2535 GSM_MMSIndicator MMSInfo; 2567 GSM_MMSIndicator MMSInfo;
2536 FILE *ReplaceFile,*f; 2568 FILE *ReplaceFile,*f;
2537 char ReplaceBuffer2[200],ReplaceBuffer[200]; 2569 char ReplaceBuffer2[200],ReplaceBuffer[200];
2538 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1]; 2570 char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1];
2539 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE]; 2571 char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE];
2540 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2572 char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2];
2541 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2573 char Name [(GSM_MAX_NUMBER_LENGTH+1)*2];
2542 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2]; 2574 char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2];
2543 int startarg = 0; 2575 int startarg = 0;
2544 int chars_read = 0; 2576 int chars_read = 0;
2545 int nextlong = 0; 2577 int nextlong = 0;
@@ -2565,25 +2597,29 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2565 SMSInfo.EntriesNum = 1; 2597 SMSInfo.EntriesNum = 1;
2566 2598
2567 if (mystrncasecmp(argv[1],"--savesms",0)) { 2599 if (mystrncasecmp(argv[1],"--savesms",0)) {
2568 EncodeUnicode(Sender,"Gammu",5); 2600 EncodeUnicode(Sender,"Gammu",5);
2569 Name[0] = 0; 2601 Name[0] = 0;
2570 Name[1] = 0; 2602 Name[1] = 0;
2571 startarg = 0; 2603 startarg = 0;
2572 } else { 2604 } else {
2573 EncodeUnicode(Sender,argv[3],strlen(argv[3])); 2605 EncodeUnicode(Sender,argv[3],strlen(argv[3]));
2574 startarg = 1; 2606 startarg = 1;
2575 Validity.Format = 0; 2607 Validity.Format = 0;
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
2579 if (mystrncasecmp(argv[2],"TEXT",0)) { 2615 if (mystrncasecmp(argv[2],"TEXT",0)) {
2580 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin); 2616 chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin);
2581 if (chars_read == 0) printmsg("Warning: 0 chars read !\n"); 2617 if (chars_read == 0) printmsg("Warning: 0 chars read !\n");
2582 InputBuffer[chars_read] = 0x00; 2618 InputBuffer[chars_read] = 0x00;
2583 InputBuffer[chars_read+1] = 0x00; 2619 InputBuffer[chars_read+1] = 0x00;
2584 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer)); 2620 EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer));
2585 SMSInfo.Entries[0].Buffer = Buffer[0]; 2621 SMSInfo.Entries[0].Buffer = Buffer[0];
2586 SMSInfo.Entries[0].ID = SMS_Text; 2622 SMSInfo.Entries[0].ID = SMS_Text;
2587 SMSInfo.UnicodeCoding = false; 2623 SMSInfo.UnicodeCoding = false;
2588 startarg += 3; 2624 startarg += 3;
2589 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { 2625 } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
@@ -2591,36 +2627,49 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2591 SMSInfo.EntriesNum = 1; 2627 SMSInfo.EntriesNum = 1;
2592 Buffer[0][0] = 0x00; 2628 Buffer[0][0] = 0x00;
2593 Buffer[0][1] = 0x00; 2629 Buffer[0][1] = 0x00;
2594 SMSInfo.Entries[0].Buffer = Buffer[0]; 2630 SMSInfo.Entries[0].Buffer = Buffer[0];
2595 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName; 2631 SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName;
2596 startarg += 3; 2632 startarg += 3;
2597 } else if (mystrncasecmp(argv[2],"EMS",0)) { 2633 } else if (mystrncasecmp(argv[2],"EMS",0)) {
2598 SMSInfo.UnicodeCoding = false; 2634 SMSInfo.UnicodeCoding = false;
2599 SMSInfo.EntriesNum = 0; 2635 SMSInfo.EntriesNum = 0;
2600 startarg += 3; 2636 startarg += 3;
2601 } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) { 2637 } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) {
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);
2605 } 2641 }
2606 SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong; 2642 SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong;
2607 SMSInfo.Entries[0].MMSIndicator = &MMSInfo; 2643 SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
2608 if (mystrncasecmp(argv[1],"--savesms",0)) { 2644 if (mystrncasecmp(argv[1],"--savesms",0)) {
2609 EncodeUnicode(Sender,"MMS Info",8); 2645 EncodeUnicode(Sender,"MMS Info",8);
2610 } 2646 }
2611 strcpy(MMSInfo.Address,argv[3+startarg]); 2647 strcpy(MMSInfo.Address,argv[3+startarg]);
2612 strcpy(MMSInfo.Title,argv[4+startarg]); 2648 strcpy(MMSInfo.Title,argv[4+startarg]);
2613 strcpy(MMSInfo.Sender,argv[5+startarg]); 2649 strcpy(MMSInfo.Sender,argv[5+startarg]);
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)) {
2616 if (argc<4+startarg) { 2665 if (argc<4+startarg) {
2617 printmsg("Where is ringtone filename ?\n"); 2666 printmsg("Where is ringtone filename ?\n");
2618 exit(-1); 2667 exit(-1);
2619 } 2668 }
2620 ringtone[0].Format=RING_NOTETONE; 2669 ringtone[0].Format=RING_NOTETONE;
2621 error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]); 2670 error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]);
2622 Print_Error(error); 2671 Print_Error(error);
2623 SMSInfo.Entries[0].ID = SMS_NokiaRingtone; 2672 SMSInfo.Entries[0].ID = SMS_NokiaRingtone;
2624 SMSInfo.Entries[0].Ringtone = &ringtone[0]; 2673 SMSInfo.Entries[0].Ringtone = &ringtone[0];
2625 if (mystrncasecmp(argv[1],"--savesms",0)) { 2674 if (mystrncasecmp(argv[1],"--savesms",0)) {
2626 CopyUnicodeString(Sender, ringtone[0].Name); 2675 CopyUnicodeString(Sender, ringtone[0].Name);
@@ -2701,48 +2750,48 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2701 if (mystrncasecmp(argv[1],"--savesms",0)) { 2750 if (mystrncasecmp(argv[1],"--savesms",0)) {
2702 EncodeUnicode(Sender, "Picture",7); 2751 EncodeUnicode(Sender, "Picture",7);
2703 EncodeUnicode(Name,"Picture Image",13); 2752 EncodeUnicode(Name,"Picture Image",13);
2704 } 2753 }
2705 startarg += 4; 2754 startarg += 4;
2706#ifdef GSM_ENABLE_BACKUP 2755#ifdef GSM_ENABLE_BACKUP
2707 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { 2756 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
2708 if (argc<5+startarg) { 2757 if (argc<5+startarg) {
2709 printmsg("Where is backup filename and location ?\n"); 2758 printmsg("Where is backup filename and location ?\n");
2710 exit(-1); 2759 exit(-1);
2711 } 2760 }
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;
2715 while (Backup.WAPBookmark[i]!=NULL) { 2764 while (Backup.WAPBookmark[i]!=NULL) {
2716 if (i == atoi(argv[4+startarg])-1) break; 2765 if (i == atoi(argv[4+startarg])-1) break;
2717 i++; 2766 i++;
2718 } 2767 }
2719 if (i != atoi(argv[4+startarg])-1) { 2768 if (i != atoi(argv[4+startarg])-1) {
2720 printmsg("Bookmark not found in file\n"); 2769 printmsg("Bookmark not found in file\n");
2721 exit(-1); 2770 exit(-1);
2722 } 2771 }
2723 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong; 2772 SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
2724 SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i]; 2773 SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i];
2725 if (mystrncasecmp(argv[1],"--savesms",0)) { 2774 if (mystrncasecmp(argv[1],"--savesms",0)) {
2726 EncodeUnicode(Sender, "Bookmark",8); 2775 EncodeUnicode(Sender, "Bookmark",8);
2727 EncodeUnicode(Name,"WAP Bookmark",12); 2776 EncodeUnicode(Name,"WAP Bookmark",12);
2728 } 2777 }
2729 startarg += 5; 2778 startarg += 5;
2730 } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) { 2779 } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) {
2731 if (argc<6+startarg) { 2780 if (argc<6+startarg) {
2732 printmsg("Where is backup filename and location ?\n"); 2781 printmsg("Where is backup filename and location ?\n");
2733 exit(-1); 2782 exit(-1);
2734 } 2783 }
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;
2738 while (Backup.WAPSettings[i]!=NULL) { 2787 while (Backup.WAPSettings[i]!=NULL) {
2739 if (i == atoi(argv[4+startarg])-1) break; 2788 if (i == atoi(argv[4+startarg])-1) break;
2740 i++; 2789 i++;
2741 } 2790 }
2742 if (i != atoi(argv[4+startarg])-1) { 2791 if (i != atoi(argv[4+startarg])-1) {
2743 printmsg("WAP settings not found in file\n"); 2792 printmsg("WAP settings not found in file\n");
2744 exit(-1); 2793 exit(-1);
2745 } 2794 }
2746 SMSInfo.Entries[0].Settings = NULL; 2795 SMSInfo.Entries[0].Settings = NULL;
2747 for (j=0;j<Backup.WAPSettings[i]->Number;j++) { 2796 for (j=0;j<Backup.WAPSettings[i]->Number;j++) {
2748 switch (Backup.WAPSettings[i]->Settings[j].Bearer) { 2797 switch (Backup.WAPSettings[i]->Settings[j].Bearer) {
@@ -2767,25 +2816,25 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2767 SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong; 2816 SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong;
2768 if (mystrncasecmp(argv[1],"--savesms",0)) { 2817 if (mystrncasecmp(argv[1],"--savesms",0)) {
2769 EncodeUnicode(Sender, "Settings",8); 2818 EncodeUnicode(Sender, "Settings",8);
2770 EncodeUnicode(Name,"WAP Settings",12); 2819 EncodeUnicode(Name,"WAP Settings",12);
2771 } 2820 }
2772 startarg += 6; 2821 startarg += 6;
2773 } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) { 2822 } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) {
2774 if (argc<5+startarg) { 2823 if (argc<5+startarg) {
2775 printmsg("Where is backup filename and location ?\n"); 2824 printmsg("Where is backup filename and location ?\n");
2776 exit(-1); 2825 exit(-1);
2777 } 2826 }
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;
2781 while (Backup.MMSSettings[i]!=NULL) { 2830 while (Backup.MMSSettings[i]!=NULL) {
2782 if (i == atoi(argv[4+startarg])-1) break; 2831 if (i == atoi(argv[4+startarg])-1) break;
2783 i++; 2832 i++;
2784 } 2833 }
2785 if (i != atoi(argv[4+startarg])-1) { 2834 if (i != atoi(argv[4+startarg])-1) {
2786 printmsg("MMS settings not found in file\n"); 2835 printmsg("MMS settings not found in file\n");
2787 exit(-1); 2836 exit(-1);
2788 } 2837 }
2789 SMSInfo.Entries[0].Settings = NULL; 2838 SMSInfo.Entries[0].Settings = NULL;
2790 for (j=0;j<Backup.MMSSettings[i]->Number;j++) { 2839 for (j=0;j<Backup.MMSSettings[i]->Number;j++) {
2791 switch (Backup.MMSSettings[i]->Settings[j].Bearer) { 2840 switch (Backup.MMSSettings[i]->Settings[j].Bearer) {
@@ -2803,69 +2852,69 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
2803 SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong; 2852 SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong;
2804 if (mystrncasecmp(argv[1],"--savesms",0)) { 2853 if (mystrncasecmp(argv[1],"--savesms",0)) {
2805 EncodeUnicode(Sender, "Settings",8); 2854 EncodeUnicode(Sender, "Settings",8);
2806 EncodeUnicode(Name,"MMS Settings",12); 2855 EncodeUnicode(Name,"MMS Settings",12);
2807 } 2856 }
2808 startarg += 5; 2857 startarg += 5;
2809 } else if (mystrncasecmp(argv[2],"CALENDAR",0)) { 2858 } else if (mystrncasecmp(argv[2],"CALENDAR",0)) {
2810 if (argc<5+startarg) { 2859 if (argc<5+startarg) {
2811 printmsg("Where is backup filename and location ?\n"); 2860 printmsg("Where is backup filename and location ?\n");
2812 exit(-1); 2861 exit(-1);
2813 } 2862 }
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;
2817 while (Backup.Calendar[i]!=NULL) { 2866 while (Backup.Calendar[i]!=NULL) {
2818 if (i == atoi(argv[4+startarg])-1) break; 2867 if (i == atoi(argv[4+startarg])-1) break;
2819 i++; 2868 i++;
2820 } 2869 }
2821 if (i != atoi(argv[4+startarg])-1) { 2870 if (i != atoi(argv[4+startarg])-1) {
2822 printmsg("Calendar note not found in file\n"); 2871 printmsg("Calendar note not found in file\n");
2823 exit(-1); 2872 exit(-1);
2824 } 2873 }
2825 SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long; 2874 SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long;
2826 SMSInfo.Entries[0].Calendar = Backup.Calendar[i]; 2875 SMSInfo.Entries[0].Calendar = Backup.Calendar[i];
2827 if (mystrncasecmp(argv[1],"--savesms",0)) { 2876 if (mystrncasecmp(argv[1],"--savesms",0)) {
2828 EncodeUnicode(Sender, "Calendar",8); 2877 EncodeUnicode(Sender, "Calendar",8);
2829 } 2878 }
2830 startarg += 5; 2879 startarg += 5;
2831 } else if (mystrncasecmp(argv[2],"TODO",0)) { 2880 } else if (mystrncasecmp(argv[2],"TODO",0)) {
2832 if (argc<5+startarg) { 2881 if (argc<5+startarg) {
2833 printmsg("Where is backup filename and location ?\n"); 2882 printmsg("Where is backup filename and location ?\n");
2834 exit(-1); 2883 exit(-1);
2835 } 2884 }
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;
2839 while (Backup.ToDo[i]!=NULL) { 2888 while (Backup.ToDo[i]!=NULL) {
2840 if (i == atoi(argv[4+startarg])-1) break; 2889 if (i == atoi(argv[4+startarg])-1) break;
2841 i++; 2890 i++;
2842 } 2891 }
2843 if (i != atoi(argv[4+startarg])-1) { 2892 if (i != atoi(argv[4+startarg])-1) {
2844 printmsg("ToDo note not found in file\n"); 2893 printmsg("ToDo note not found in file\n");
2845 exit(-1); 2894 exit(-1);
2846 } 2895 }
2847 SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong; 2896 SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong;
2848 SMSInfo.Entries[0].ToDo = Backup.ToDo[i]; 2897 SMSInfo.Entries[0].ToDo = Backup.ToDo[i];
2849 if (mystrncasecmp(argv[1],"--savesms",0)) { 2898 if (mystrncasecmp(argv[1],"--savesms",0)) {
2850 EncodeUnicode(Sender, "ToDo",8); 2899 EncodeUnicode(Sender, "ToDo",8);
2851 } 2900 }
2852 startarg += 5; 2901 startarg += 5;
2853 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { 2902 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
2854 if (argc<6+startarg) { 2903 if (argc<6+startarg) {
2855 printmsg("Where is backup filename and location and memory type ?\n"); 2904 printmsg("Where is backup filename and location and memory type ?\n");
2856 exit(-1); 2905 exit(-1);
2857 } 2906 }
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;
2861 if (mystrncasecmp(argv[4+startarg],"SM",0)) { 2910 if (mystrncasecmp(argv[4+startarg],"SM",0)) {
2862 while (Backup.SIMPhonebook[i]!=NULL) { 2911 while (Backup.SIMPhonebook[i]!=NULL) {
2863 if (i == atoi(argv[5+startarg])-1) break; 2912 if (i == atoi(argv[5+startarg])-1) break;
2864 i++; 2913 i++;
2865 } 2914 }
2866 if (i != atoi(argv[5+startarg])-1) { 2915 if (i != atoi(argv[5+startarg])-1) {
2867 printmsg("Phonebook entry not found in file\n"); 2916 printmsg("Phonebook entry not found in file\n");
2868 exit(-1); 2917 exit(-1);
2869 } 2918 }
2870 SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i]; 2919 SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i];
2871 } else if (mystrncasecmp(argv[4+startarg],"ME",0)) { 2920 } else if (mystrncasecmp(argv[4+startarg],"ME",0)) {
@@ -3800,97 +3849,97 @@ static void SaveFile(int argc, char *argv[])
3800 GSM_Backup Backup; 3849 GSM_Backup Backup;
3801 int i,j; 3850 int i,j;
3802 FILE *file; 3851 FILE *file;
3803 unsigned char Buffer[10000]; 3852 unsigned char Buffer[10000];
3804 GSM_MemoryEntry *pbk; 3853 GSM_MemoryEntry *pbk;
3805 3854
3806 if (mystrncasecmp(argv[2],"CALENDAR",0)) { 3855 if (mystrncasecmp(argv[2],"CALENDAR",0)) {
3807 if (argc<5) { 3856 if (argc<5) {
3808 printmsg("Where is backup filename and location ?\n"); 3857 printmsg("Where is backup filename and location ?\n");
3809 exit(-1); 3858 exit(-1);
3810 } 3859 }
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;
3814 while (Backup.Calendar[i]!=NULL) { 3863 while (Backup.Calendar[i]!=NULL) {
3815 if (i == atoi(argv[5])-1) break; 3864 if (i == atoi(argv[5])-1) break;
3816 i++; 3865 i++;
3817 } 3866 }
3818 if (i != atoi(argv[5])-1) { 3867 if (i != atoi(argv[5])-1) {
3819 printmsg("Calendar note not found in file\n"); 3868 printmsg("Calendar note not found in file\n");
3820 exit(-1); 3869 exit(-1);
3821 } 3870 }
3822 j = 0; 3871 j = 0;
3823 GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar); 3872 GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar);
3824 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { 3873 } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
3825 if (argc<5) { 3874 if (argc<5) {
3826 printmsg("Where is backup filename and location ?\n"); 3875 printmsg("Where is backup filename and location ?\n");
3827 exit(-1); 3876 exit(-1);
3828 } 3877 }
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;
3832 while (Backup.WAPBookmark[i]!=NULL) { 3881 while (Backup.WAPBookmark[i]!=NULL) {
3833 if (i == atoi(argv[5])-1) break; 3882 if (i == atoi(argv[5])-1) break;
3834 i++; 3883 i++;
3835 } 3884 }
3836 if (i != atoi(argv[5])-1) { 3885 if (i != atoi(argv[5])-1) {
3837 printmsg("WAP bookmark not found in file\n"); 3886 printmsg("WAP bookmark not found in file\n");
3838 exit(-1); 3887 exit(-1);
3839 } 3888 }
3840 j = 0; 3889 j = 0;
3841 GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]); 3890 GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]);
3842 } else if (mystrncasecmp(argv[2],"NOTE",0)) { 3891 } else if (mystrncasecmp(argv[2],"NOTE",0)) {
3843 if (argc<5) { 3892 if (argc<5) {
3844 printmsg("Where is backup filename and location ?\n"); 3893 printmsg("Where is backup filename and location ?\n");
3845 exit(-1); 3894 exit(-1);
3846 } 3895 }
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;
3850 while (Backup.Note[i]!=NULL) { 3899 while (Backup.Note[i]!=NULL) {
3851 if (i == atoi(argv[5])-1) break; 3900 if (i == atoi(argv[5])-1) break;
3852 i++; 3901 i++;
3853 } 3902 }
3854 if (i != atoi(argv[5])-1) { 3903 if (i != atoi(argv[5])-1) {
3855 printmsg("Note not found in file\n"); 3904 printmsg("Note not found in file\n");
3856 exit(-1); 3905 exit(-1);
3857 } 3906 }
3858 j = 0; 3907 j = 0;
3859 GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]); 3908 GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]);
3860 } else if (mystrncasecmp(argv[2],"TODO",0)) { 3909 } else if (mystrncasecmp(argv[2],"TODO",0)) {
3861 if (argc<5) { 3910 if (argc<5) {
3862 printmsg("Where is backup filename and location ?\n"); 3911 printmsg("Where is backup filename and location ?\n");
3863 exit(-1); 3912 exit(-1);
3864 } 3913 }
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;
3868 while (Backup.ToDo[i]!=NULL) { 3917 while (Backup.ToDo[i]!=NULL) {
3869 if (i == atoi(argv[5])-1) break; 3918 if (i == atoi(argv[5])-1) break;
3870 i++; 3919 i++;
3871 } 3920 }
3872 if (i != atoi(argv[5])-1) { 3921 if (i != atoi(argv[5])-1) {
3873 printmsg("ToDo note not found in file\n"); 3922 printmsg("ToDo note not found in file\n");
3874 exit(-1); 3923 exit(-1);
3875 } 3924 }
3876 j = 0; 3925 j = 0;
3877 GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); 3926 GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo);
3878 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { 3927 } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
3879 if (argc<6) { 3928 if (argc<6) {
3880 printmsg("Where is backup filename and location and memory type ?\n"); 3929 printmsg("Where is backup filename and location and memory type ?\n");
3881 exit(-1); 3930 exit(-1);
3882 } 3931 }
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;
3886 if (mystrncasecmp(argv[5],"SM",0)) { 3935 if (mystrncasecmp(argv[5],"SM",0)) {
3887 while (Backup.SIMPhonebook[i]!=NULL) { 3936 while (Backup.SIMPhonebook[i]!=NULL) {
3888 if (i == atoi(argv[6])-1) break; 3937 if (i == atoi(argv[6])-1) break;
3889 i++; 3938 i++;
3890 } 3939 }
3891 if (i != atoi(argv[6])-1) { 3940 if (i != atoi(argv[6])-1) {
3892 printmsg("Phonebook entry not found in file\n"); 3941 printmsg("Phonebook entry not found in file\n");
3893 exit(-1); 3942 exit(-1);
3894 } 3943 }
3895 pbk = Backup.SIMPhonebook[i]; 3944 pbk = Backup.SIMPhonebook[i];
3896 } else if (mystrncasecmp(argv[5],"ME",0)) { 3945 } else if (mystrncasecmp(argv[5],"ME",0)) {
@@ -3921,32 +3970,35 @@ static void SaveFile(int argc, char *argv[])
3921 file = fopen(argv[3],"wb"); 3970 file = fopen(argv[3],"wb");
3922 fwrite(Buffer,1,j,file); 3971 fwrite(Buffer,1,j,file);
3923 fclose(file); 3972 fclose(file);
3924} 3973}
3925 3974
3926static void Backup(int argc, char *argv[]) 3975static void Backup(int argc, char *argv[])
3927{ 3976{
3928 int i, used; 3977 int i, used;
3929 GSM_MemoryStatusMemStatus; 3978 GSM_MemoryStatusMemStatus;
3930 GSM_ToDoEntry ToDo; 3979 GSM_ToDoEntry ToDo;
3931 GSM_ToDoStatus ToDoStatus; 3980 GSM_ToDoStatus ToDoStatus;
3932 GSM_MemoryEntry Pbk; 3981 GSM_MemoryEntry Pbk;
3933 GSM_CalendarEntryNote; 3982 GSM_CalendarEntryCalendar;
3934 GSM_Bitmap Bitmap; 3983 GSM_Bitmap Bitmap;
3935 GSM_WAPBookmark Bookmark; 3984 GSM_WAPBookmark Bookmark;
3936 GSM_Profile Profile; 3985 GSM_Profile Profile;
3937 GSM_MultiWAPSettingsSettings; 3986 GSM_MultiWAPSettingsSettings;
3987 GSM_SyncMLSettingsSyncML;
3988 GSM_ChatSettingsChat;
3938 GSM_Ringtone Ringtone; 3989 GSM_Ringtone Ringtone;
3939 GSM_SMSC SMSC; 3990 GSM_SMSC SMSC;
3940 GSM_Backup Backup; 3991 GSM_Backup Backup;
3992 GSM_NoteEntry Note;
3941 GSM_Backup_Info Info; 3993 GSM_Backup_Info Info;
3942 GSM_FMStation FMStation; 3994 GSM_FMStation FMStation;
3943 GSM_GPRSAccessPointGPRSPoint; 3995 GSM_GPRSAccessPointGPRSPoint;
3944 bool DoBackup; 3996 bool DoBackup;
3945 3997
3946 if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; 3998 if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true;
3947 3999
3948 GSM_ClearBackup(&Backup); 4000 GSM_ClearBackup(&Backup);
3949 GSM_GetBackupFormatFeatures(argv[2],&Info); 4001 GSM_GetBackupFormatFeatures(argv[2],&Info);
3950 4002
3951 sprintf(Backup.Creator,"Gammu %s",VERSION); 4003 sprintf(Backup.Creator,"Gammu %s",VERSION);
3952 if (strlen(GetOS()) != 0) { 4004 if (strlen(GetOS()) != 0) {
@@ -4065,45 +4117,45 @@ static void Backup(int argc, char *argv[])
4065 printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); 4117 printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed);
4066 i++; 4118 i++;
4067 if (gshutdown) { 4119 if (gshutdown) {
4068 GSM_Terminate(); 4120 GSM_Terminate();
4069 exit(0); 4121 exit(0);
4070 } 4122 }
4071 } 4123 }
4072 printmsgerr("\n"); 4124 printmsgerr("\n");
4073 } 4125 }
4074 DoBackup = false; 4126 DoBackup = false;
4075 if (Info.Calendar) { 4127 if (Info.Calendar) {
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) {
4079 if (answer_yes(" Backup calendar notes")) DoBackup = true; 4131 if (answer_yes(" Backup calendar notes")) DoBackup = true;
4080 } 4132 }
4081 } 4133 }
4082 if (DoBackup) { 4134 if (DoBackup) {
4083 used = 0; 4135 used = 0;
4084 printmsgerr(" Reading : "); 4136 printmsgerr(" Reading : ");
4085 while (error == ERR_NONE) { 4137 while (error == ERR_NONE) {
4086 if (used < GSM_MAXCALENDARTODONOTES) { 4138 if (used < GSM_MAXCALENDARTODONOTES) {
4087 Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); 4139 Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry));
4088 if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); 4140 if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY);
4089 Backup.Calendar[used+1] = NULL; 4141 Backup.Calendar[used+1] = NULL;
4090 } else { 4142 } else {
4091 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); 4143 printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
4092 GSM_Terminate(); 4144 GSM_Terminate();
4093 exit(-1); 4145 exit(-1);
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("*");
4099 if (gshutdown) { 4151 if (gshutdown) {
4100 GSM_Terminate(); 4152 GSM_Terminate();
4101 exit(0); 4153 exit(0);
4102 } 4154 }
4103 } 4155 }
4104 printmsgerr("\n"); 4156 printmsgerr("\n");
4105 } 4157 }
4106 DoBackup = false; 4158 DoBackup = false;
4107 if (Info.ToDo) { 4159 if (Info.ToDo) {
4108 printmsg("Checking ToDo\n"); 4160 printmsg("Checking ToDo\n");
4109 error=Phone->GetToDoStatus(&s,&ToDoStatus); 4161 error=Phone->GetToDoStatus(&s,&ToDoStatus);
@@ -4127,24 +4179,56 @@ static void Backup(int argc, char *argv[])
4127 *Backup.ToDo[used]=ToDo; 4179 *Backup.ToDo[used]=ToDo;
4128 used ++; 4180 used ++;
4129 error=Phone->GetNextToDo(&s,&ToDo,false); 4181 error=Phone->GetNextToDo(&s,&ToDo,false);
4130 printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); 4182 printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used);
4131 if (gshutdown) { 4183 if (gshutdown) {
4132 GSM_Terminate(); 4184 GSM_Terminate();
4133 exit(0); 4185 exit(0);
4134 } 4186 }
4135 } 4187 }
4136 printmsgerr("\n"); 4188 printmsgerr("\n");
4137 } 4189 }
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) {
4140 printmsg("Checking caller logos\n"); 4224 printmsg("Checking caller logos\n");
4141 Bitmap.Type = GSM_CallerGroupLogo; 4225 Bitmap.Type = GSM_CallerGroupLogo;
4142 Bitmap.Location = 1; 4226 Bitmap.Location = 1;
4143 error=Phone->GetBitmap(&s,&Bitmap); 4227 error=Phone->GetBitmap(&s,&Bitmap);
4144 if (error == ERR_NONE) { 4228 if (error == ERR_NONE) {
4145 if (answer_yes(" Backup caller groups and logos")) DoBackup = true; 4229 if (answer_yes(" Backup caller groups and logos")) DoBackup = true;
4146 } 4230 }
4147 } 4231 }
4148 if (DoBackup) { 4232 if (DoBackup) {
4149 printmsgerr(" Reading : "); 4233 printmsgerr(" Reading : ");
4150 error = ERR_NONE; 4234 error = ERR_NONE;
@@ -4225,24 +4309,92 @@ static void Backup(int argc, char *argv[])
4225 if (error == ERR_NONE) { 4309 if (error == ERR_NONE) {
4226 if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { 4310 if (strcmp(Bitmap.NetworkCode,"000 00")!=0) {
4227 if (answer_yes(" Backup operator logo")) DoBackup = true; 4311 if (answer_yes(" Backup operator logo")) DoBackup = true;
4228 } 4312 }
4229 } 4313 }
4230 } 4314 }
4231 if (DoBackup) { 4315 if (DoBackup) {
4232 Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); 4316 Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap));
4233 if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); 4317 if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY);
4234 *Backup.OperatorLogo = Bitmap; 4318 *Backup.OperatorLogo = Bitmap;
4235 } 4319 }
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) {
4238 printmsg("Checking MMS settings\n"); 4390 printmsg("Checking MMS settings\n");
4239 Settings.Location = 1; 4391 Settings.Location = 1;
4240 error=Phone->GetMMSSettings(&s,&Settings); 4392 error=Phone->GetMMSSettings(&s,&Settings);
4241 if (error==ERR_NONE) { 4393 if (error==ERR_NONE) {
4242 if (answer_yes(" Backup MMS settings")) DoBackup = true; 4394 if (answer_yes(" Backup MMS settings")) DoBackup = true;
4243 } 4395 }
4244 } 4396 }
4245 if (DoBackup) { 4397 if (DoBackup) {
4246 used = 0; 4398 used = 0;
4247 printmsgerr(" Reading : "); 4399 printmsgerr(" Reading : ");
4248 while (error == ERR_NONE) { 4400 while (error == ERR_NONE) {
@@ -4259,83 +4411,83 @@ static void Backup(int argc, char *argv[])
4259 used ++; 4411 used ++;
4260 Settings.Location = used+1; 4412 Settings.Location = used+1;
4261 error=Phone->GetMMSSettings(&s,&Settings); 4413 error=Phone->GetMMSSettings(&s,&Settings);
4262 printmsgerr("*"); 4414 printmsgerr("*");
4263 if (gshutdown) { 4415 if (gshutdown) {
4264 GSM_Terminate(); 4416 GSM_Terminate();
4265 exit(0); 4417 exit(0);
4266 } 4418 }
4267 } 4419 }
4268 printmsgerr("\n"); 4420 printmsgerr("\n");
4269 } 4421 }
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 }
4278 } 4430 }
4279 if (DoBackup) { 4431 if (DoBackup) {
4280 used = 0; 4432 used = 0;
4281 printmsgerr(" Reading : "); 4433 printmsgerr(" Reading : ");
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();
4290 exit(-1); 4442 exit(-1);
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("*");
4297 if (gshutdown) { 4449 if (gshutdown) {
4298 GSM_Terminate(); 4450 GSM_Terminate();
4299 exit(0); 4451 exit(0);
4300 } 4452 }
4301 } 4453 }
4302 printmsgerr("\n"); 4454 printmsgerr("\n");
4303 } 4455 }
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 }
4312 } 4464 }
4313 if (DoBackup) { 4465 if (DoBackup) {
4314 used = 0; 4466 used = 0;
4315 printmsgerr(" Reading : "); 4467 printmsgerr(" Reading : ");
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();
4324 exit(-1); 4476 exit(-1);
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("*");
4331 if (gshutdown) { 4483 if (gshutdown) {
4332 GSM_Terminate(); 4484 GSM_Terminate();
4333 exit(0); 4485 exit(0);
4334 } 4486 }
4335 } 4487 }
4336 printmsgerr("\n"); 4488 printmsgerr("\n");
4337 } 4489 }
4338 DoBackup = false; 4490 DoBackup = false;
4339 if (Info.Ringtone) { 4491 if (Info.Ringtone) {
4340 printmsg("Checking user ringtones\n"); 4492 printmsg("Checking user ringtones\n");
4341 Ringtone.Location = 1; 4493 Ringtone.Location = 1;
@@ -4493,32 +4645,37 @@ static void Restore(int argc, char *argv[])
4493 GSM_MemoryStatusMemStatus; 4645 GSM_MemoryStatusMemStatus;
4494 GSM_ToDoEntry ToDo; 4646 GSM_ToDoEntry ToDo;
4495 GSM_ToDoStatus ToDoStatus; 4647 GSM_ToDoStatus ToDoStatus;
4496 GSM_Profile Profile; 4648 GSM_Profile Profile;
4497 GSM_MultiWAPSettingsSettings; 4649 GSM_MultiWAPSettingsSettings;
4498 GSM_GPRSAccessPointGPRSPoint; 4650 GSM_GPRSAccessPointGPRSPoint;
4499 GSM_WAPBookmark Bookmark; 4651 GSM_WAPBookmark Bookmark;
4500 int i, used, max = 0; 4652 int i, used, max = 0;
4501 bool Past = true; 4653 bool Past = true;
4502 bool Found, DoRestore; 4654 bool Found, DoRestore;
4503 4655
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
4507 signal(SIGINT, interrupt); 4663 signal(SIGINT, interrupt);
4508 printmsgerr("Press Ctrl+C to break...\n"); 4664 printmsgerr("Press Ctrl+C to break...\n");
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
4514 if (Backup.MD5Calculated[0]!=0) { 4671 if (Backup.MD5Calculated[0]!=0) {
4515 dbgprintf("\"%s\"\n",Backup.MD5Original); 4672 dbgprintf("\"%s\"\n",Backup.MD5Original);
4516 dbgprintf("\"%s\"\n",Backup.MD5Calculated); 4673 dbgprintf("\"%s\"\n",Backup.MD5Calculated);
4517 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { 4674 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) {
4518 if (!answer_yes("Checksum in backup file do not match. Continue")) return; 4675 if (!answer_yes("Checksum in backup file do not match. Continue")) return;
4519 } 4676 }
4520 } 4677 }
4521 4678
4522 GSM_Init(true); 4679 GSM_Init(true);
4523 4680
4524 DoRestore = false; 4681 DoRestore = false;
@@ -4609,47 +4766,44 @@ static void Restore(int argc, char *argv[])
4609 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); 4766 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]);
4610 Print_Error(error); 4767 Print_Error(error);
4611 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4768 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4612 if (gshutdown) { 4769 if (gshutdown) {
4613 GSM_Terminate(); 4770 GSM_Terminate();
4614 exit(0); 4771 exit(0);
4615 } 4772 }
4616 } 4773 }
4617 printmsgerr("\n"); 4774 printmsgerr("\n");
4618 } 4775 }
4619 4776
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);
4623 4780
4624 error=Phone->SetDateTime(&s, &date_time); 4781 error=Phone->SetDateTime(&s, &date_time);
4625 Print_Error(error); 4782 Print_Error(error);
4626 } 4783 }
4627 } 4784 }
4628 DoRestore = false; 4785 DoRestore = false;
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 */
4632 error = Phone->GetNextCalendar(&s,&Calendar,true); 4788 error = Phone->GetNextCalendar(&s,&Calendar,true);
4633 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { 4789 if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
4634 max = 0; 4790 max = 0;
4635 while (Backup.Calendar[max] != NULL) max++; 4791 while (Backup.Calendar[max] != NULL) max++;
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 }
4645 } 4799 }
4646 if (DoRestore) { 4800 if (DoRestore) {
4647 printmsgerr("Deleting old notes: "); 4801 printmsgerr("Deleting old notes: ");
4648 error = Phone->DeleteAllCalendar(&s); 4802 error = Phone->DeleteAllCalendar(&s);
4649 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4803 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4650 while (1) { 4804 while (1) {
4651 error = Phone->GetNextCalendar(&s,&Calendar,true); 4805 error = Phone->GetNextCalendar(&s,&Calendar,true);
4652 if (error != ERR_NONE) break; 4806 if (error != ERR_NONE) break;
4653 error = Phone->DeleteCalendar(&s,&Calendar); 4807 error = Phone->DeleteCalendar(&s,&Calendar);
4654 Print_Error(error); 4808 Print_Error(error);
4655 printmsgerr("*"); 4809 printmsgerr("*");
@@ -4670,38 +4824,35 @@ static void Restore(int argc, char *argv[])
4670 if (gshutdown) { 4824 if (gshutdown) {
4671 GSM_Terminate(); 4825 GSM_Terminate();
4672 exit(0); 4826 exit(0);
4673 } 4827 }
4674 } 4828 }
4675 printmsgerr("\n"); 4829 printmsgerr("\n");
4676 } 4830 }
4677 4831
4678 DoRestore = false; 4832 DoRestore = false;
4679 if (Backup.ToDo[0] != NULL) { 4833 if (Backup.ToDo[0] != NULL) {
4680 error = Phone->GetToDoStatus(&s,&ToDoStatus); 4834 error = Phone->GetToDoStatus(&s,&ToDoStatus);
4681 if (error == ERR_NONE) { 4835 if (error == ERR_NONE) {
4682 error == ERR_NOTSUPPORTED;
4683 DoRestore = true;
4684 max = 0; 4836 max = 0;
4685 while (Backup.ToDo[max]!=NULL) max++; 4837 while (Backup.ToDo[max]!=NULL) max++;
4686 printmsgerr("%i entries in backup file\n",max); 4838 printmsgerr("%i entries in backup file\n",max);
4687 4839
4688 /*if (answer_yes("Restore ToDo")) */DoRestore = true; 4840 //LR if (answer_yes("Restore ToDo"))
4841 DoRestore = true;
4689 } 4842 }
4690 } 4843 }
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 }
4697 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { 4848 if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) {
4698 printmsgerr("Deleting old ToDo: "); 4849 printmsgerr("Deleting old ToDo: ");
4699 error=Phone->DeleteAllToDo(&s); 4850 error=Phone->DeleteAllToDo(&s);
4700 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { 4851 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
4701 while (1) { 4852 while (1) {
4702 error = Phone->GetNextToDo(&s,&ToDo,true); 4853 error = Phone->GetNextToDo(&s,&ToDo,true);
4703 if (error != ERR_NONE) break; 4854 if (error != ERR_NONE) break;
4704 error = Phone->DeleteToDo(&s,&ToDo); 4855 error = Phone->DeleteToDo(&s,&ToDo);
4705 Print_Error(error); 4856 Print_Error(error);
4706 printmsgerr("*"); 4857 printmsgerr("*");
4707 } 4858 }
@@ -4982,25 +5133,25 @@ static void AddNew(int argc, char *argv[])
4982{ 5133{
4983 GSM_Backup Backup; 5134 GSM_Backup Backup;
4984 GSM_DateTime date_time; 5135 GSM_DateTime date_time;
4985 GSM_MemoryEntry Pbk; 5136 GSM_MemoryEntry Pbk;
4986 GSM_MemoryStatusMemStatus; 5137 GSM_MemoryStatusMemStatus;
4987 GSM_ToDoEntry ToDo; 5138 GSM_ToDoEntry ToDo;
4988 GSM_ToDoStatus ToDoStatus; 5139 GSM_ToDoStatus ToDoStatus;
4989 GSM_CalendarEntryCalendar; 5140 GSM_CalendarEntryCalendar;
4990 GSM_WAPBookmark Bookmark; 5141 GSM_WAPBookmark Bookmark;
4991 int i, max, j; 5142 int i, max, j;
4992 5143
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
4996 signal(SIGINT, interrupt); 5147 signal(SIGINT, interrupt);
4997 printmsgerr("Press Ctrl+C to break...\n"); 5148 printmsgerr("Press Ctrl+C to break...\n");
4998 5149
4999 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 5150 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
5000 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 5151 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
5001 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 5152 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
5002 5153
5003 GSM_Init(true); 5154 GSM_Init(true);
5004 5155
5005 if (Backup.PhonePhonebook[0] != NULL) { 5156 if (Backup.PhonePhonebook[0] != NULL) {
5006 MemStatus.MemoryType = MEM_ME; 5157 MemStatus.MemoryType = MEM_ME;
@@ -5609,26 +5760,25 @@ static void RestoreSMS(int argc, char *argv[])
5609 5760
5610 GSM_Init(true); 5761 GSM_Init(true);
5611 5762
5612 error=Phone->GetSMSFolders(&s, &folders); 5763 error=Phone->GetSMSFolders(&s, &folders);
5613 Print_Error(error); 5764 Print_Error(error);
5614 5765
5615 while (Backup.SMS[smsnum] != NULL) { 5766 while (Backup.SMS[smsnum] != NULL) {
5616 SMS.Number = 1; 5767 SMS.Number = 1;
5617 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); 5768 memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
5618 displaymultismsinfo(SMS,false,false); 5769 displaymultismsinfo(SMS,false,false);
5619 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); 5770 sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
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);
5624 } 5774 }
5625 smsnum++; 5775 smsnum++;
5626 } 5776 }
5627 5777
5628 GSM_Terminate(); 5778 GSM_Terminate();
5629} 5779}
5630#endif 5780#endif
5631 5781
5632static void CopyBitmap(int argc, char *argv[]) 5782static void CopyBitmap(int argc, char *argv[])
5633{ 5783{
5634 GSM_MultiBitmap Bitmap; 5784 GSM_MultiBitmap Bitmap;
@@ -5804,25 +5954,25 @@ static void NokiaComposer(int argc, char *argv[])
5804 while (DefNoteDuration != Duration) { 5954 while (DefNoteDuration != Duration) {
5805 printmsg("8"); 5955 printmsg("8");
5806 DefNoteDuration = DefNoteDuration / 2; 5956 DefNoteDuration = DefNoteDuration / 2;
5807 } 5957 }
5808 } 5958 }
5809 printmsg(" "); 5959 printmsg(" ");
5810 } 5960 }
5811 } 5961 }
5812 } 5962 }
5813 5963
5814 printf("\n"); 5964 printf("\n");
5815} 5965}
5816//#if 0 5966
5817static void CopyRingtone(int argc, char *argv[]) 5967static void CopyRingtone(int argc, char *argv[])
5818{ 5968{
5819 GSM_Ringtone ringtone, ringtone2; 5969 GSM_Ringtone ringtone, ringtone2;
5820 GSM_RingtoneFormatFormat; 5970 GSM_RingtoneFormatFormat;
5821 5971
5822 ringtone.Format= 0; 5972 ringtone.Format= 0;
5823 error=GSM_ReadRingtoneFile(argv[2],&ringtone); 5973 error=GSM_ReadRingtoneFile(argv[2],&ringtone);
5824 Print_Error(error); 5974 Print_Error(error);
5825 5975
5826 Format = ringtone.Format; 5976 Format = ringtone.Format;
5827 if (argc == 5) { 5977 if (argc == 5) {
5828 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; 5978 if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
@@ -5965,25 +6115,25 @@ static void DeleteToDo(int argc, char *argv[])
5965 } 6115 }
5966 6116
5967 GSM_Terminate(); 6117 GSM_Terminate();
5968} 6118}
5969 6119
5970static void PrintToDo(GSM_ToDoEntry *ToDo) 6120static void PrintToDo(GSM_ToDoEntry *ToDo)
5971{ 6121{
5972 int j; 6122 int j;
5973 GSM_MemoryEntry entry; 6123 GSM_MemoryEntry entry;
5974 unsigned char *name; 6124 unsigned char *name;
5975 GSM_Category Category; 6125 GSM_Category Category;
5976 6126
5977 printmsg("Location : %i\n",ToDo->Location); 6127 printmsg("Location : %i\n",ToDo->Location);
5978 printmsg("Priority : "); 6128 printmsg("Priority : ");
5979 switch (ToDo->Priority) { 6129 switch (ToDo->Priority) {
5980 case GSM_Priority_Low : printmsg("Low\n"); break; 6130 case GSM_Priority_Low : printmsg("Low\n"); break;
5981 case GSM_Priority_Medium : printmsg("Medium\n"); break; 6131 case GSM_Priority_Medium : printmsg("Medium\n"); break;
5982 case GSM_Priority_High : printmsg("High\n"); break; 6132 case GSM_Priority_High : printmsg("High\n"); break;
5983 default : printmsg("Unknown\n");break; 6133 default : printmsg("Unknown\n");break;
5984 } 6134 }
5985 for (j=0;j<ToDo->EntriesNum;j++) { 6135 for (j=0;j<ToDo->EntriesNum;j++) {
5986 switch (ToDo->Entries[j].EntryType) { 6136 switch (ToDo->Entries[j].EntryType) {
5987 case TODO_END_DATETIME: 6137 case TODO_END_DATETIME:
5988 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); 6138 printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false));
5989 break; 6139 break;
@@ -6089,25 +6239,25 @@ static void ListToDoCategory(int argc, char *argv[])
6089 EncodeUnicode(Text, argv[2], Length); 6239 EncodeUnicode(Text, argv[2], Length);
6090 6240
6091 Category.Type = Category_ToDo; 6241 Category.Type = Category_ToDo;
6092 Status.Type = Category_ToDo; 6242 Status.Type = Category_ToDo;
6093 6243
6094 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { 6244 if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
6095 for (count=0,j=1;count<Status.Used;j++) { 6245 for (count=0,j=1;count<Status.Used;j++) {
6096 Category.Location=j; 6246 Category.Location=j;
6097 error=Phone->GetCategory(&s, &Category); 6247 error=Phone->GetCategory(&s, &Category);
6098 6248
6099 if (error != ERR_EMPTY) { 6249 if (error != ERR_EMPTY) {
6100 count++; 6250 count++;
6101 if (mystrstr(Category.Name, Text) != NULL) { 6251 if (mywstrstr(Category.Name, Text) != NULL) {
6102 ListToDoCategoryEntries(j); 6252 ListToDoCategoryEntries(j);
6103 } 6253 }
6104 } 6254 }
6105 } 6255 }
6106 } 6256 }
6107 } 6257 }
6108 GSM_Terminate(); 6258 GSM_Terminate();
6109} 6259}
6110 6260
6111 6261
6112static void GetToDo(int argc, char *argv[]) 6262static void GetToDo(int argc, char *argv[])
6113{ 6263{
@@ -6142,49 +6292,42 @@ static void GetAllToDo(int argc, char *argv[])
6142 6292
6143 while (!gshutdown) { 6293 while (!gshutdown) {
6144 error = Phone->GetNextToDo(&s, &ToDo, start); 6294 error = Phone->GetNextToDo(&s, &ToDo, start);
6145 if (error == ERR_EMPTY) break; 6295 if (error == ERR_EMPTY) break;
6146 Print_Error(error); 6296 Print_Error(error);
6147 PrintToDo(&ToDo); 6297 PrintToDo(&ToDo);
6148 start = false; 6298 start = false;
6149 } 6299 }
6150 6300
6151 GSM_Terminate(); 6301 GSM_Terminate();
6152} 6302}
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
6162 GSM_Init(true); 6312 GSM_Init(true);
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();
6180} 6323}
6181 6324
6182static void GetSecurityStatus(int argc, char *argv[]) 6325static void GetSecurityStatus(int argc, char *argv[])
6183{ 6326{
6184 GSM_Init(true); 6327 GSM_Init(true);
6185 6328
6186 PrintSecurityStatus(); 6329 PrintSecurityStatus();
6187 6330
6188 GSM_Terminate(); 6331 GSM_Terminate();
6189} 6332}
6190 6333
@@ -6562,39 +6705,64 @@ static void MakeConvertTable(int argc, char *argv[])
6562 printf("\"\\\n\""); 6705 printf("\"\\\n\"");
6563 j=0; 6706 j=0;
6564 } 6707 }
6565 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); 6708 printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
6566 } 6709 }
6567 printf("\\x00\\x00"); 6710 printf("\\x00\\x00");
6568} 6711}
6569#endif 6712#endif
6570 6713
6571static void ListNetworks(int argc, char *argv[]) 6714static void ListNetworks(int argc, char *argv[])
6572{ 6715{
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++;
6580 } 6746 }
6581} 6747}
6582 6748
6583static void Version(int argc, char *argv[]) 6749static void Version(int argc, char *argv[])
6584{ 6750{
6585 // unsigned char buff[10]; 6751 // unsigned char buff[10];
6586 // int len; 6752 // int len;
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
6590#ifdef DEBUG 6758#ifdef DEBUG
6591 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); 6759 printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
6592 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); 6760 printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
6593 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); 6761 printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
6594 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); 6762 printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
6595 printf("bool - %i\n",sizeof(bool)); 6763 printf("bool - %i\n",sizeof(bool));
6596 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); 6764 printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
6597 printf("int - %i\n",sizeof(int)); 6765 printf("int - %i\n",sizeof(int));
6598 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); 6766 printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
6599#endif 6767#endif
6600 6768
@@ -6693,53 +6861,47 @@ static void GetFileSystem(int argc, char *argv[])
6693 printf(" %9i",Files.Used); 6861 printf(" %9i",Files.Used);
6694 printf(" "); 6862 printf(" ");
6695 } else printf("|-- "); 6863 } else printf("|-- ");
6696 } else printf("Folder "); 6864 } else printf("Folder ");
6697 } else { 6865 } else {
6698 if (Files.Level != 1) { 6866 if (Files.Level != 1) {
6699 for (j=0;j<Files.Level-2;j++) printf(" | "); 6867 for (j=0;j<Files.Level-2;j++) printf(" | ");
6700 printf(" |-- "); 6868 printf(" |-- ");
6701 } 6869 }
6702 if (Files.Folder) printf("Folder "); 6870 if (Files.Folder) printf("Folder ");
6703 } 6871 }
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)) {
6709 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] 6874 /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS]
6710 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ 6875 * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */
6711 if (!Files.Folder) { 6876 if (!Files.Folder) {
6712 printf("%s;File;",Files.ID_FullName); 6877 printf("%s;File;",Files.ID_FullName);
6713 printf("\"%s\";",FolderName); 6878 printf("\"%s\";",FolderName);
6714 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6879 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6715 if (!Files.ModifiedEmpty) { 6880 if (!Files.ModifiedEmpty) {
6716 printf("\"%s\";",OSDateTime(Files.Modified,false)); 6881 printf("\"%s\";",OSDateTime(Files.Modified,false));
6717 } else printf("\"%c\";",0x20); 6882 } else printf("\"%c\";",0x20);
6718 printf("%i;",Files.Used); 6883 printf("%i;",Files.Used);
6719 } else { 6884 } else {
6720 printf("%s;Folder;",Files.ID_FullName); 6885 printf("%s;Folder;",Files.ID_FullName);
6721 printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); 6886 printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
6722 strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); 6887 strcpy(FolderName,DecodeUnicodeConsole(Files.Name));
6723 } 6888 }
6724 6889
6725 if (Files.Protected) printf("P"); 6890 if (Files.Protected) printf("P");
6726 if (Files.ReadOnly) printf("R"); 6891 if (Files.ReadOnly) printf("R");
6727 if (Files.Hidden) printf("H"); 6892 if (Files.Hidden) printf("H");
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 }
6735 6897
6736 error = Phone->GetFileSystemStatus(&s,&Status); 6898 error = Phone->GetFileSystemStatus(&s,&Status);
6737 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { 6899 if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
6738 Print_Error(error); 6900 Print_Error(error);
6739 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); 6901 printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
6740 } 6902 }
6741 6903
6742 GSM_Terminate(); 6904 GSM_Terminate();
6743} 6905}
6744 6906
6745static void GetOneFile(GSM_File *File, bool newtime, int i) 6907static void GetOneFile(GSM_File *File, bool newtime, int i)
@@ -7029,28 +7191,32 @@ static struct NokiaFolderInfo Folder[] = {
7029 {"", "MMSSent", "SENT", "3"}, 7191 {"", "MMSSent", "SENT", "3"},
7030 {"", "MMSDrafts", "DRAFTS","3"}, 7192 {"", "MMSDrafts", "DRAFTS","3"},
7031 {"", "Application", "applications","3"}, 7193 {"", "Application", "applications","3"},
7032 {"", "Game", "games","3"}, 7194 {"", "Game", "games","3"},
7033 /* Language depedent in DCT4 */ 7195 /* Language depedent in DCT4 */
7034 {"", "Gallery", "Pictures","2"}, /* 3510 */ 7196 {"", "Gallery", "Pictures","2"}, /* 3510 */
7035 {"", "Gallery", "Graphics","3"}, /* 3510i */ 7197 {"", "Gallery", "Graphics","3"}, /* 3510i */
7036 {"", "Gallery", "Images","3"}, /* 6610 */ 7198 {"", "Gallery", "Images","3"}, /* 6610 */
7037 {"3510", "Gallery", "", "8"}, 7199 {"3510", "Gallery", "", "8"},
7038 {"3510i","Gallery", "", "3"}, 7200 {"3510i","Gallery", "", "3"},
7039 {"5100", "Gallery", "", "3"}, 7201 {"5100", "Gallery", "", "3"},
7040 {"6220", "Gallery", "", "5"}, 7202 {"6220", "Gallery", "", "5"},
7203 {"6610", "Gallery", "", "2"},
7204 {"7210", "Gallery", "", "2"},
7041 {"", "Tones", "Tones","3"}, 7205 {"", "Tones", "Tones","3"},
7042 {"3510i","Tones", "", "4"}, 7206 {"3510i","Tones", "", "4"},
7043 {"5100", "Tones", "", "4"}, 7207 {"5100", "Tones", "", "4"},
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 */
7046 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"}, 7212 {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"},
7047 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"}, 7213 {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"},
7048 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"}, 7214 {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"},
7049 {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, 7215 {"obex", "MMSSent", "", "predefMessages\\predefSENT" },
7050 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"}, 7216 {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"},
7051 // {"obex", "Application, "", "predefjava\\predefapplications"}, 7217 // {"obex", "Application, "", "predefjava\\predefapplications"},
7052 // {"obex", "Game", "", "predefjava\\predefgames"}, 7218 // {"obex", "Game", "", "predefjava\\predefgames"},
7053 {"obex", "Gallery", "", "predefgallery\\predefgraphics"}, 7219 {"obex", "Gallery", "", "predefgallery\\predefgraphics"},
7054 {"obex", "Tones", "", "predefgallery\\predeftones"}, 7220 {"obex", "Tones", "", "predefgallery\\predeftones"},
7055 7221
7056 /* End of list */ 7222 /* End of list */
@@ -7549,139 +7715,146 @@ static void CallDivert(int argc, char *argv[])
7549 case GSM_DIVERT_DataCalls : printmsg("data"); break; 7715 case GSM_DIVERT_DataCalls : printmsg("data"); break;
7550 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; 7716 default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
7551 } 7717 }
7552 printf("\n"); 7718 printf("\n");
7553 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); 7719 printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
7554 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); 7720 printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
7555 } 7721 }
7556 printf("\n"); 7722 printf("\n");
7557 7723
7558 GSM_Terminate(); 7724 GSM_Terminate();
7559} 7725}
7560 7726
7561
7562//#if 0
7563static void CancelAllDiverts(int argc, char *argv[]) 7727static void CancelAllDiverts(int argc, char *argv[])
7564{ 7728{
7565 GSM_Init(true); 7729 GSM_Init(true);
7566 7730
7567 error = Phone->CancelAllDiverts(&s); 7731 error = Phone->CancelAllDiverts(&s);
7568 Print_Error(error); 7732 Print_Error(error);
7569 7733
7570 GSM_Terminate(); 7734 GSM_Terminate();
7571} 7735}
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
7575void SearchPhoneThread(OneDeviceInfo *Info) 7749void 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) {
7609 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device); 7781 if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
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++;
7630 } 7802 }
7631 num--; 7803 num--;
7632#endif 7804#endif
7633} 7805}
7634 7806
7635//#undef HAVE_PTHREAD
7636//#if 0
7637#if defined(WIN32) || defined(HAVE_PTHREAD) 7807#if defined(WIN32) || defined(HAVE_PTHREAD)
7638#ifdef HAVE_PTHREAD 7808#ifdef HAVE_PTHREAD
7639 pthread_t Thread[100]; 7809 pthread_t Thread[100];
7640#endif 7810#endif
7641 7811
7812OneDeviceInfo SearchDevices[60];
7813
7642void MakeSearchThread(int i) 7814void MakeSearchThread(int i)
7643{ 7815{
7644 num++; 7816 num++;
7645#ifdef HAVE_PTHREAD 7817#ifdef HAVE_PTHREAD
7646 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) { 7818 if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) {
7647 dbgprintf("Error creating thread\n"); 7819 dbgprintf("Error creating thread\n");
7648 } 7820 }
7649#else 7821#else
7650 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, 7822 if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0,
7651 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i], 7823 (LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i],
7652 0,NULL)==NULL) { 7824 0,NULL)==NULL) {
7653 dbgprintf("Error creating thread\n"); 7825 dbgprintf("Error creating thread\n");
7654 } 7826 }
7655#endif 7827#endif
7656} 7828}
7657 7829
7658static void SearchPhone(int argc, char *argv[]) 7830static void SearchPhone(int argc, char *argv[])
7659{ 7831{
7660 int i,dev = 0, dev2 = 0; 7832 int i,dev = 0, dev2 = 0;
7661 7833
7662 SearchOutput = false; 7834 SearchOutput = false;
7663 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true; 7835 if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true;
7664 7836
7665 num = 0; 7837 num = 0;
7666#ifdef WIN32 7838#ifdef WIN32
7667# ifdef GSM_ENABLE_IRDADEVICE 7839# ifdef GSM_ENABLE_IRDADEVICE
7668 sprintf(SearchDevices[dev].Device,""); 7840 sprintf(SearchDevices[dev].Device,"");
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++;
7672# endif 7845# endif
7673# ifdef GSM_ENABLE_SERIALDEVICE 7846# ifdef GSM_ENABLE_SERIALDEVICE
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);
7677 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3"); 7850 sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
7678 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus"); 7851 sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
7679 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200"); 7852 sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
7680 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7853 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7681 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7854 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7682 dev2++; 7855 dev2++;
7683 } 7856 }
7684# endif 7857# endif
7685#endif 7858#endif
7686#ifdef __linux__ 7859#ifdef __linux__
7687# ifdef GSM_ENABLE_IRDADEVICE 7860# ifdef GSM_ENABLE_IRDADEVICE
@@ -7721,25 +7894,25 @@ static void SearchPhone(int argc, char *argv[])
7721 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus"); 7894 sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
7722 SearchDevices[dev2].Connections[4].Connection[0] = 0; 7895 SearchDevices[dev2].Connections[4].Connection[0] = 0;
7723 dev2++; 7896 dev2++;
7724 } 7897 }
7725# endif 7898# endif
7726#endif 7899#endif
7727 for(i=0;i<dev;i++) MakeSearchThread(i); 7900 for(i=0;i<dev;i++) MakeSearchThread(i);
7728 while (num != 0) my_sleep(5); 7901 while (num != 0) my_sleep(5);
7729 for(i=dev;i<dev2;i++) MakeSearchThread(i); 7902 for(i=dev;i<dev2;i++) MakeSearchThread(i);
7730 while (num != 0) my_sleep(5); 7903 while (num != 0) my_sleep(5);
7731} 7904}
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[])
7735{ 7908{
7736 GSM_Init(true); 7909 GSM_Init(true);
7737 7910
7738#ifdef GSM_ENABLE_NOKIA_DCT3 7911#ifdef GSM_ENABLE_NOKIA_DCT3
7739 DCT3GetADC(argc,argv); 7912 DCT3GetADC(argc,argv);
7740#endif 7913#endif
7741#ifdef GSM_ENABLE_NOKIA_DCT4 7914#ifdef GSM_ENABLE_NOKIA_DCT4
7742 DCT4GetADC(argc, argv); 7915 DCT4GetADC(argc, argv);
7743#endif 7916#endif
7744 7917
7745 GSM_Terminate(); 7918 GSM_Terminate();
@@ -7784,45 +7957,45 @@ static void NokiaVibraTest(int argc, char *argv[])
7784 DCT4VibraTest(argc, argv); 7957 DCT4VibraTest(argc, argv);
7785#endif 7958#endif
7786 7959
7787 GSM_Terminate(); 7960 GSM_Terminate();
7788} 7961}
7789 7962
7790static GSM_Parameters Parameters[] = { 7963static GSM_Parameters Parameters[] = {
7791 {"--identify", 0, 0, Identify, {H_Info,0}, ""}, 7964 {"--identify", 0, 0, Identify, {H_Info,0}, ""},
7792 {"--version", 0, 0, Version, {H_Other,0}, ""}, 7965 {"--version", 0, 0, Version, {H_Other,0}, ""},
7793 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""}, 7966 {"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
7794 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"}, 7967 {"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0},"[times]"},
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]"},
7798 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"}, 7971 {"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"},
7799 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"}, 7972 {"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"},
7800 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""}, 7973 {"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""},
7801 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."}, 7974 {"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."},
7802 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."}, 7975 {"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."},
7803 {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"}, 7976 {"--addfile", 2, 6, AddFile, {H_Filesystem,0}, "folderID name [-type JAR|BMP|PNG|GIF|JPG|MIDI|WBMP|AMR|3GP|NRT][-readonly][-protected][-system][-hidden][-newtime]"},
7804 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"}, 7977 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
7805 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"}, 7978 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Application|Game file [-readonly]"},
7806 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"}, 7979 {"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0},"Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
7807 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"}, 7980 {"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
7808 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"}, 7981 {"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
7809 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""}, 7982 {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""},
7810 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""}, 7983 {"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
7811 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""}, 7984 {"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
7812 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""}, 7985 {"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},
7813 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"}, 7986 {"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"},
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"},
7818 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"}, 7991 {"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0},"text|number"},
7819 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"}, 7992 {"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"},
7820 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"}, 7993 {"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"},
7821 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"}, 7994 {"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"},
7822 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"}, 7995 {"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"},
7823 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"}, 7996 {"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"},
7824 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""}, 7997 {"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""},
7825 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""}, 7998 {"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""},
7826 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""}, 7999 {"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""},
7827 8000
7828 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]" 8001 #define SMS_TEXT_OPTIONS"[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
@@ -7834,43 +8007,45 @@ static GSM_Parameters Parameters[] = {
7834 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]" 8007 #define SMS_OPERATOR_OPTIONS"[-netcode netcode][-biglogo]"
7835 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]" 8008 #define SMS_SAVE_OPTIONS"[-folder id][-unread][-read][-unsent][-sent][-sender number]"
7836 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]" 8009 #define SMS_SEND_OPTIONS"[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]"
7837 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]" 8010 #define SMS_COMMON_OPTIONS"[-smscset number][-smscnumber number][-reply][-maxsms num]"
7838 8011
7839 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 8012 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
7840 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8013 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7841 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 8014 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
7842 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8015 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7843 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 8016 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
7844 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 8017 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
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
7847 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8021 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7848 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8022 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7849 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8023 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7850 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8024 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7851 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8025 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7852 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS}, 8026 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
7853#endif 8027#endif
7854 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS}, 8028 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS},
7855 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 8029 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
7856 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 8030 {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
7857 8031
7858 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS}, 8032 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
7859 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8033 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7860 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS}, 8034 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
7861 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8035 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7862 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS}, 8036 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
7863 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS}, 8037 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
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
7866 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8041 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7867 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8042 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7868 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8043 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7869 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8044 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7870 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8045 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7871 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS}, 8046 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
7872#endif 8047#endif
7873 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS}, 8048 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS},
7874 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS}, 8049 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
7875 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS}, 8050 {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
7876 8051
@@ -7898,25 +8073,25 @@ static GSM_Parameters Parameters[] = {
7898 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"}, 8073 {"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"},
7899 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"}, 8074 {"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"},
7900 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"}, 8075 {"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"},
7901 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"}, 8076 {"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"},
7902 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"}, 8077 {"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
7903 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""}, 8078 {"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""},
7904 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"}, 8079 {"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"},
7905 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""}, 8080 {"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0},""},
7906 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""}, 8081 {"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""},
7907 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"}, 8082 {"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"},
7908 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"}, 8083 {"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"},
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]"},
7912 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""}, 8087 {"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""},
7913 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"}, 8088 {"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"},
7914 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"}, 8089 {"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK start [stop]"},
7915 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"}, 8090 {"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0},"TODO|PHONEBOOK"},
7916 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"}, 8091 {"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"},
7917 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"}, 8092 {"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"},
7918 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""}, 8093 {"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""},
7919 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"}, 8094 {"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"},
7920 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"}, 8095 {"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"},
7921 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"}, 8096 {"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"},
7922 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"}, 8097 {"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"},
@@ -7967,26 +8142,28 @@ static GSM_Parameters Parameters[] = {
7967 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""}, 8142 {"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""},
7968 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"}, 8143 {"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"},
7969 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""}, 8144 {"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""},
7970#endif 8145#endif
7971#ifdef GSM_ENABLE_NOKIA_DCT3 8146#ifdef GSM_ENABLE_NOKIA_DCT3
7972 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"}, 8147 {"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"},
7973 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""}, 8148 {"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""},
7974 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"}, 8149 {"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"},
7975#endif 8150#endif
7976#ifdef GSM_ENABLE_NOKIA_DCT4 8151#ifdef GSM_ENABLE_NOKIA_DCT4
7977 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"}, 8152 {"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"},
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}, ""},
7982 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""}, 8159 {"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""},
7983#endif 8160#endif
7984#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) 8161#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
7985 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""}, 8162 {"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""},
7986 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""}, 8163 {"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""},
7987 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"}, 8164 {"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"},
7988 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""}, 8165 {"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""},
7989 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""}, 8166 {"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""},
7990 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""}, 8167 {"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""},
7991 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""}, 8168 {"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""},
7992#endif 8169#endif
@@ -8037,29 +8214,29 @@ static HelpCategoryDescriptions HelpDescriptions[] = {
8037void HelpHeader(void) 8214void HelpHeader(void)
8038{ 8215{
8039 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__); 8216 printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
8040} 8217}
8041 8218
8042static void HelpGeneral(void) 8219static void HelpGeneral(void)
8043{ 8220{
8044 inti=0; 8221 inti=0;
8045 8222
8046 HelpHeader(); 8223 HelpHeader();
8047 8224
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
8055 while (HelpDescriptions[i].category != 0) { 8232 while (HelpDescriptions[i].category != 0) {
8056 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description); 8233 printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description);
8057 i++; 8234 i++;
8058 } 8235 }
8059 printf("\n"); 8236 printf("\n");
8060} 8237}
8061 8238
8062static void HelpSplit(int cols, int len, unsigned char *buff) 8239static void HelpSplit(int cols, int len, unsigned char *buff)
8063{ 8240{
8064 int l, len2, pos, split; 8241 int l, len2, pos, split;
8065 bool in_opt,first=true; 8242 bool in_opt,first=true;
@@ -8125,25 +8302,25 @@ static void Help(int argc, char *argv[])
8125#endif 8302#endif
8126 8303
8127 /* Just --help */ 8304 /* Just --help */
8128 if (argc == 2) { 8305 if (argc == 2) {
8129 HelpGeneral(); 8306 HelpGeneral();
8130 return; 8307 return;
8131 } 8308 }
8132 8309
8133 if (!strcmp(argv[2],"all")) { 8310 if (!strcmp(argv[2],"all")) {
8134 HelpHeader(); 8311 HelpHeader();
8135 } else { 8312 } else {
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++;
8139 } 8316 }
8140 if (HelpDescriptions[i].category == 0) { 8317 if (HelpDescriptions[i].category == 0) {
8141 HelpGeneral(); 8318 HelpGeneral();
8142 printmsg("Unknown help topic specified!\n"); 8319 printmsg("Unknown help topic specified!\n");
8143 return; 8320 return;
8144 } 8321 }
8145 HelpHeader(); 8322 HelpHeader();
8146 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description); 8323 printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description);
8147 } 8324 }
8148 8325
8149#if defined(WIN32) || defined(DJGPP) 8326#if defined(WIN32) || defined(DJGPP)
@@ -8197,140 +8374,90 @@ static void Help(int argc, char *argv[])
8197 } 8374 }
8198 if (disp) { 8375 if (disp) {
8199 printf("%s", Parameters[j].parameter); 8376 printf("%s", Parameters[j].parameter);
8200 if (Parameters[j].help[0] == 0) { 8377 if (Parameters[j].help[0] == 0) {
8201 printf("\n"); 8378 printf("\n");
8202 } else { 8379 } else {
8203 HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help); 8380 HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help);
8204 } 8381 }
8205 } 8382 }
8206 j++; 8383 j++;
8207 } 8384 }
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;
8226 s.msg = NULL; 8398 s.msg = NULL;
8227 s.ConfigNum = 0; 8399 s.ConfigNum = 0;
8228 8400
8229 setlocale(LC_ALL, ""); 8401 setlocale(LC_ALL, "");
8230#ifdef DEBUG 8402#ifdef DEBUG
8231 di.dl = DL_TEXTALL; 8403 di.dl = DL_TEXTALL;
8232 di.df = stdout; 8404 di.df = stdout;
8233#endif 8405#endif
8234 //#if 0 8406
8235 /* Any parameters? */ 8407 /* Any parameters? */
8236 if (argc == 1) { 8408 if (argc == 1) {
8237 HelpGeneral(); 8409 HelpGeneral();
8238 printmsg("Too few parameters!\n"); 8410 printmsg("Too few parameters!\n");
8239 exit(1); 8411 exit(1);
8240 } 8412 }
8241 8413
8242 /* Help? */ 8414 /* Help? */
8243 if (strncmp(argv[1 + start], "--help", 6) == 0) { 8415 if (strncmp(argv[1 + start], "--help", 6) == 0) {
8244 Help(argc - start, argv + start); 8416 Help(argc - start, argv + start);
8245 exit(1); 8417 exit(1);
8246 } 8418 }
8247 8419
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++) {
8302 if (cfg!=NULL) { 8430 if (cfg!=NULL) {
8303 cp = INI_GetValue(cfg, "gammu", "gammucoding", false); 8431 cp = INI_GetValue(cfg, "gammu", "gammucoding", false);
8304 if (cp) di.coding = cp; 8432 if (cp) di.coding = cp;
8305 8433
8306 s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false); 8434 s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false);
8307 if (s.Config[i].Localize) { 8435 if (s.Config[i].Localize) {
8308 s.msg=INI_ReadFile(s.Config[i].Localize, true); 8436 s.msg=INI_ReadFile(s.Config[i].Localize, true);
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);
8312 if (locale != NULL) { 8440 if (locale != NULL) {
8313 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 8441 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
8314 LOCALE_PATH, 8442 LOCALE_PATH,
8315 tolower(locale[0]), 8443 tolower(locale[0]),
8316 tolower(locale[1])); 8444 tolower(locale[1]));
8317 s.msg = INI_ReadFile(locale_file, true); 8445 s.msg = INI_ReadFile(locale_file, true);
8318 } 8446 }
8319#endif 8447#endif
8320 } 8448 }
8321 } 8449 }
8322 8450
8323 /* Wanted user specific configuration? */ 8451 /* Wanted user specific configuration? */
8324
8325 if (only_config != -1) { 8452 if (only_config != -1) {
8326 /* Here we get only in first for loop */ 8453 /* Here we get only in first for loop */
8327 if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break; 8454 if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break;
8328 } else { 8455 } else {
8329 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 8456 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
8330 } 8457 }
8331 s.ConfigNum++; 8458 s.ConfigNum++;
8332 8459
8333 /* We want to use only one file descriptor for global and state machine debug output */ 8460 /* We want to use only one file descriptor for global and state machine debug output */
8334 s.Config[i].UseGlobalDebugFile = true; 8461 s.Config[i].UseGlobalDebugFile = true;
8335 8462
8336 /* It makes no sense to open several debug logs... */ 8463 /* It makes no sense to open several debug logs... */
@@ -8348,85 +8475,60 @@ int main(int argc, char *argv[])
8348 } else { 8475 } else {
8349 /* Try to set debug level from config file */ 8476 /* Try to set debug level from config file */
8350 GSM_SetDebugLevel(s.Config[i].DebugLevel, &di); 8477 GSM_SetDebugLevel(s.Config[i].DebugLevel, &di);
8351 } 8478 }
8352 /* If user gave debug file in gammurc, we will use it */ 8479 /* If user gave debug file in gammurc, we will use it */
8353 error=GSM_SetDebugFile(s.Config[i].DebugFile, &di); 8480 error=GSM_SetDebugFile(s.Config[i].DebugFile, &di);
8354 Print_Error(error); 8481 Print_Error(error);
8355 } 8482 }
8356 8483
8357 /* We wanted to read just user specified configuration. */ 8484 /* We wanted to read just user specified configuration. */
8358 if (only_config != -1) {break;} 8485 if (only_config != -1) {break;}
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? */
8385 if (argc == 1 + start) { 8489 if (argc == 1 + start) {
8386 HelpGeneral(); 8490 HelpGeneral();
8387 printmsg("Too few parameters!\n"); 8491 printmsg("Too few parameters!\n");
8388 exit(-2); 8492 exit(-2);
8389 } 8493 }
8390 8494
8391 /* Check used version vs. compiled */ 8495 /* Check used version vs. compiled */
8392 if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) { 8496 if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) {
8393 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n", 8497 printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n",
8394 GetGammuVersion(),VERSION); 8498 GetGammuVersion(),VERSION);
8395 exit(-1); 8499 exit(-1);
8396 } 8500 }
8397 8501
8398 /* Check parameters */ 8502 /* Check parameters */
8399 while (Parameters[z].Function != NULL) { 8503 while (Parameters[z].Function != NULL) {
8400 if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) { 8504 if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) {
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);
8404 break; 8507 break;
8405 } else { 8508 } else {
8406 count_failed = true; 8509 count_failed = true;
8407 } 8510 }
8408 } 8511 }
8409 z++; 8512 z++;
8410 } 8513 }
8411 8514
8412 /* Tell user when we did nothing */ 8515 /* Tell user when we did nothing */
8413 if (Parameters[z].Function == NULL) { 8516 if (Parameters[z].Function == NULL) {
8414 HelpGeneral(); 8517 HelpGeneral();
8415 if (count_failed) { 8518 if (count_failed) {
8416 printmsg("Bad parameter count!\n"); 8519 printmsg("Bad parameter count!\n");
8417 } else { 8520 } else {
8418 printmsg("Bad option!\n"); 8521 printmsg("Bad option!\n");
8419 } 8522 }
8420 } 8523 }
8421 8524
8422 /* Close debug output if opened */ 8525 /* Close debug output if opened */
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);
8427} 8529}
8428 8530
8429/* How should editor hadle tabs in this file? Add editor commands here. 8531/* How should editor hadle tabs in this file? Add editor commands here.
8430 * vim: noexpandtab sw=8 ts=8 sts=8: 8532 * vim: noexpandtab sw=8 ts=8 sts=8:
8431 */ 8533 */
8432 8534
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
@@ -48,27 +48,27 @@ typedef struct {
48 char *parameter; 48 char *parameter;
49 int min_arg; 49 int min_arg;
50 int max_arg; 50 int max_arg;
51 void (*Function) (int argc, char *argv[]); 51 void (*Function) (int argc, char *argv[]);
52 HelpCategoryhelp_cat[10]; 52 HelpCategoryhelp_cat[10];
53 char *help; 53 char *help;
54} GSM_Parameters; 54} GSM_Parameters;
55 55
56 void Print_Error (GSM_Error error); 56 void Print_Error (GSM_Error error);
57 void GSM_Init (bool checkerror); 57 void GSM_Init (bool checkerror);
58 void GSM_Terminate (void); 58 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
66void interrupt(int sign); 66void interrupt(int sign);
67 67
68#ifdef GSM_ENABLE_BEEP 68#ifdef GSM_ENABLE_BEEP
69 void GSM_PhoneBeep (void); 69 void GSM_PhoneBeep (void);
70#endif 70#endif
71 71
72/* How should editor hadle tabs in this file? Add editor commands here. 72/* How should editor hadle tabs in this file? Add editor commands here.
73 * vim: noexpandtab sw=8 ts=8 sts=8: 73 * vim: noexpandtab sw=8 ts=8 sts=8:
74 */ 74 */
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,13 +1,13 @@
1/* (c) 2002-2003 by Joergen Thomsen */ 1/* (c) 2002-2004 by Joergen Thomsen */
2 2
3#include "../../cfg/config.h" 3#include "../../cfg/config.h"
4 4
5#include <string.h> 5#include <string.h>
6#include <stdio.h> 6#include <stdio.h>
7#include <errno.h> 7#include <errno.h>
8#include <time.h> 8#include <time.h>
9#ifdef WIN32 9#ifdef WIN32
10# include <io.h> 10# include <io.h>
11#endif 11#endif
12#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR && defined HAVE_ALPHASORT 12#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR && defined HAVE_ALPHASORT
13# include <dirent.h> 13# include <dirent.h>
@@ -97,108 +97,150 @@ static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
97 WriteSMSDLog("%s %s", (sms.SMS[i].PDU == SMS_Status_Report?"Delivery report":"Received"), FileName); 97 WriteSMSDLog("%s %s", (sms.SMS[i].PDU == SMS_Status_Report?"Delivery report":"Received"), FileName);
98 } else { 98 } else {
99 WriteSMSDLog("Cannot save %s (%i)", FileName, errno); 99 WriteSMSDLog("Cannot save %s (%i)", FileName, errno);
100 return ERR_CANTOPENFILE; 100 return ERR_CANTOPENFILE;
101 } 101 }
102 } 102 }
103 } 103 }
104 return ERR_NONE; 104 return ERR_NONE;
105} 105}
106 106
107/* Find one multi SMS to sending and return it (or return ERR_EMPTY) 107/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
108 * There is also set ID for SMS 108 * There is also set ID for SMS
109 * File extension convention:
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 */
110static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID) 118static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
111{ 119{
112 GSM_Error error = ERR_NOTSUPPORTED; 120 GSM_Error error = ERR_NOTSUPPORTED;
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];
115 unsigned char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2]; 124 unsigned char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
116 unsigned char Buffer2[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2]; 125 unsigned char Buffer2[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
117 FILE *File; 126 FILE *File;
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
121 struct dirent **namelist = NULL; 130 struct dirent **namelist = NULL;
122 int l, m ,n; 131 int l, m ,n;
123 132
124 strcpy(FullName, Config->outboxpath); 133 strcpy(FullName, Config->outboxpath);
125 FullName[strlen(Config->outboxpath)-1] = '\0'; 134 FullName[strlen(Config->outboxpath)-1] = '\0';
126 n = scandir(FullName, &namelist, 0, alphasort); 135 n = scandir(FullName, &namelist, 0, alphasort);
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 )
133 ) 142 )
134 ) m++; 143 ) m++;
135 if (m < n) strcpy(FileName,namelist[m]->d_name); 144 if (m < n) strcpy(FileName,namelist[m]->d_name);
136 for (l=0; l < n; l++) free(namelist[l]); 145 for (l=0; l < n; l++) free(namelist[l]);
137 free(namelist); 146 free(namelist);
138 namelist = NULL; 147 namelist = NULL;
139 if (m >= n) return ERR_EMPTY; 148 if (m >= n) return ERR_EMPTY;
140 error = ERR_NONE; 149 error = ERR_NONE;
141#else 150#else
142#ifdef WIN32 151#ifdef WIN32
143 struct _finddata_t c_file; 152 struct _finddata_t c_file;
144 long hFile; 153 long hFile;
145 154
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 ) {
149 return ERR_EMPTY; 158 return ERR_EMPTY;
150 } else { 159 } else {
151 strcpy(FileName,c_file.name); 160 strcpy(FileName,c_file.name);
152 } 161 }
153 _findclose( hFile ); 162 _findclose( hFile );
154 error = ERR_NONE; 163 error = ERR_NONE;
155#endif 164#endif
156#endif 165#endif
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);
160 strcat(FullName, FileName); 169 strcat(FullName, FileName);
161 170
162 File = fopen(FullName, "rb"); 171 File = fopen(FullName, "rb");
163 len = fread(Buffer, 1, sizeof(Buffer)-2, File); 172 len = fread(Buffer, 1, sizeof(Buffer)-2, File);
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;
170 EncodeUnicode(Buffer2, Buffer, len); 179 EncodeUnicode(Buffer2, Buffer, len);
171 len = len*2; 180 len = len*2;
172 memmove(Buffer, Buffer2, len); 181 memmove(Buffer, Buffer2, len);
173 } 182 }
174 183
175 Buffer[len] = 0; 184 Buffer[len] = 0;
176 Buffer[len+1] = 0; 185 Buffer[len+1] = 0;
177 ReadUnicodeFile(Buffer2,Buffer); 186 ReadUnicodeFile(Buffer2,Buffer);
178 187
188 GSM_ClearMultiPartSMSInfo(&SMSInfo);
189 sms->Number = 0;
190
179 SMSInfo.ReplaceMessage = 0; 191 SMSInfo.ReplaceMessage = 0;
180 SMSInfo.Entries[0].Buffer= Buffer2; 192 SMSInfo.Entries[0].Buffer= Buffer2;
181 SMSInfo.Class = -1; 193 SMSInfo.Class = -1;
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)) {
184 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; 200 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
185 SMSInfo.UnicodeCoding = true; 201 SMSInfo.UnicodeCoding = true;
186 } else if (mystrncasecmp(Config->transmitformat, "7bit", 0)) { 202 } else if (mystrncasecmp(Config->transmitformat, "7bit", 0)) {
187 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; 203 SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
188 SMSInfo.UnicodeCoding = false; 204 SMSInfo.UnicodeCoding = false;
189 } else { 205 } else {
190 /* auto */ 206 /* auto */
191 SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong; 207 SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
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);
194 236
195 pos1 = FileName; 237 pos1 = FileName;
196 strcpy(ID,FileName); 238 strcpy(ID,FileName);
197 for (i = 1; i <= 3 && pos1 != NULL ; i++) pos1 = strchr(++pos1, '_'); 239 for (i = 1; i <= 3 && pos1 != NULL ; i++) pos1 = strchr(++pos1, '_');
198 if (pos1 != NULL) { 240 if (pos1 != NULL) {
199 /* OUT<priority><date>_<time>_<serialno>_<phone number>_<anything>.txt */ 241 /* OUT<priority><date>_<time>_<serialno>_<phone number>_<anything>.txt */
200 pos2 = strchr(++pos1, '_'); 242 pos2 = strchr(++pos1, '_');
201 if (pos2 != NULL) { 243 if (pos2 != NULL) {
202 phlen = strlen(pos1) - strlen(pos2); 244 phlen = strlen(pos1) - strlen(pos2);
203 } else { 245 } else {
204 /* something wrong */ 246 /* something wrong */
@@ -221,33 +263,35 @@ static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfi
221 } else { 263 } else {
222 /* something wrong */ 264 /* something wrong */
223 return ERR_UNKNOWN; 265 return ERR_UNKNOWN;
224 } 266 }
225 267
226 for (len=0;len<sms->Number;len++) { 268 for (len=0;len<sms->Number;len++) {
227 EncodeUnicode(sms->SMS[len].Number, pos1, phlen); 269 EncodeUnicode(sms->SMS[len].Number, pos1, phlen);
228 } 270 }
229 271
230#ifdef DEBUG 272#ifdef DEBUG
231 if (sms->Number != 0) { 273 if (sms->Number != 0) {
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,
235 Buffer, 277 Buffer,
236 DecodeUnicodeString(sms->SMS[0].Text), 278 DecodeUnicodeString(sms->SMS[0].Text),
237 sms->SMS[0].Coding, 279 sms->SMS[0].Coding,
238 sms->SMS[0].Length, 280 sms->SMS[0].Length,
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
243 287
244 return ERR_NONE; 288 return ERR_NONE;
245} 289}
246 290
247/* After sending SMS is moved to Sent Items or Error Items. */ 291/* After sending SMS is moved to Sent Items or Error Items. */
248static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent) 292static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
249{ 293{
250 FILE *oFile,*iFile; 294 FILE *oFile,*iFile;
251 int ilen = 0, olen = 0; 295 int ilen = 0, olen = 0;
252 char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2],ifilename[400],ofilename[400]; 296 char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2],ifilename[400],ofilename[400];
253 char*sourcepath, *destpath; 297 char*sourcepath, *destpath;
@@ -283,31 +327,34 @@ static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Con
283 } 327 }
284 return ERR_NONE; 328 return ERR_NONE;
285 } else { 329 } else {
286 WriteSMSDLog("Error copying SMS %s -> %s", ifilename, ofilename); 330 WriteSMSDLog("Error copying SMS %s -> %s", ifilename, ofilename);
287 if (alwaysDelete) { 331 if (alwaysDelete) {
288 if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0)) 332 if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0))
289 WriteSMSDLog("Could not delete %s (%i)", ifilename, errno); 333 WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
290 } 334 }
291 return ERR_UNKNOWN; 335 return ERR_UNKNOWN;
292 } 336 }
293} 337}
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
299 return ERR_NONE; 343 return ERR_NONE;
300} 344}
301 345
302GSM_SMSDService SMSDFiles = { 346GSM_SMSDService SMSDFiles = {
303 NONEFUNCTION, /* Init */ 347 NONEFUNCTION, /* Init */
348 NONEFUNCTION, /* InitAfterConnect */
304 SMSDFiles_SaveInboxSMS, 349 SMSDFiles_SaveInboxSMS,
305 SMSDFiles_FindOutboxSMS, 350 SMSDFiles_FindOutboxSMS,
306 SMSDFiles_MoveSMS, 351 SMSDFiles_MoveSMS,
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:
313 */ 360 */
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,7 +1,7 @@
1/* (c) 2002-2003 by Joergen Thomsen */ 1/* (c) 2002-2004 by Joergen Thomsen */
2 2
3extern GSM_SMSDService SMSDFiles; 3extern GSM_SMSDService SMSDFiles;
4 4
5/* How should editor hadle tabs in this file? Add editor commands here. 5/* How should editor hadle tabs in this file? Add editor commands here.
6 * vim: noexpandtab sw=8 ts=8 sts=8: 6 * vim: noexpandtab sw=8 ts=8 sts=8:
7 */ 7 */
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
@@ -6,54 +6,242 @@
6 6
7#include <string.h> 7#include <string.h>
8#include <stdio.h> 8#include <stdio.h>
9#include <errno.h> 9#include <errno.h>
10#include <time.h> 10#include <time.h>
11#ifdef WIN32 11#ifdef WIN32
12# include <windows.h> 12# include <windows.h>
13# pragma comment(lib, "libmysql.lib") 13# pragma comment(lib, "libmysql.lib")
14#endif 14#endif
15 15
16#include "../../common/misc/coding/coding.h" 16#include "../../common/misc/coding/coding.h"
17#include "../../common/service/backup/gsmback.h" 17#include "../../common/service/backup/gsmback.h"
18#include "../gammu.h"
18#include "smsdcore.h" 19#include "smsdcore.h"
19 20
20/* Connects to database */ 21/* Connects to database */
21static GSM_Error SMSDMySQL_Init(GSM_SMSDConfig *Config) 22static 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;
29} 137}
30 138
31/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */ 139/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */
32static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config) 140static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config)
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;
42 } 230 }
43 if (sms.SMS[i].PDU != SMS_Deliver) continue; 231 if (sms.SMS[i].PDU != SMS_Deliver) continue;
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,
49 sms.SMS[i].DateTime.Hour,sms.SMS[i].DateTime.Minute,sms.SMS[i].DateTime.Second); 237 sms.SMS[i].DateTime.Hour,sms.SMS[i].DateTime.Minute,sms.SMS[i].DateTime.Second);
50 switch (sms.SMS[i].Coding) { 238 switch (sms.SMS[i].Coding) {
51 case SMS_Coding_Unicode: 239 case SMS_Coding_Unicode:
52 case SMS_Coding_Default: 240 case SMS_Coding_Default:
53 EncodeHexUnicode(buffer+strlen(buffer),sms.SMS[i].Text,UnicodeLength(sms.SMS[i].Text)); 241 EncodeHexUnicode(buffer+strlen(buffer),sms.SMS[i].Text,UnicodeLength(sms.SMS[i].Text));
54 break; 242 break;
55 case SMS_Coding_8bit: 243 case SMS_Coding_8bit:
56 EncodeHexBin(buffer+strlen(buffer),sms.SMS[i].Text,sms.SMS[i].Length); 244 EncodeHexBin(buffer+strlen(buffer),sms.SMS[i].Text,sms.SMS[i].Length);
57 } 245 }
58 sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms.SMS[i].Number)); 246 sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms.SMS[i].Number));
59 switch (sms.SMS[i].Coding) { 247 switch (sms.SMS[i].Coding) {
@@ -87,328 +275,450 @@ static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
87 buffer[z+2]=0; 275 buffer[z+2]=0;
88 buffer[z+1]=buffer2[j]; 276 buffer[z+1]=buffer2[j];
89 buffer[z] ='\\'; 277 buffer[z] ='\\';
90 } else { 278 } else {
91 buffer[z+1]=0; 279 buffer[z+1]=0;
92 buffer[z] =buffer2[j]; 280 buffer[z] =buffer2[j];
93 } 281 }
94 } 282 }
95 break; 283 break;
96 case SMS_Coding_8bit: 284 case SMS_Coding_8bit:
97 break; 285 break;
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;
103 } 294 }
104 } 295 }
105 296
106 return ERR_NONE; 297 return ERR_NONE;
107} 298}
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)
110 * There is also set ID for SMS 317 * There is also set ID for SMS
111 */ 318 */
112static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID) 319static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
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;
123 } 331 }
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);
130 return ERR_EMPTY; 348 return ERR_EMPTY;
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;
145 } 369 }
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;
149 } 373 }
150 if (!(Row = mysql_fetch_row(Res))) { 374 if (!(Row = mysql_fetch_row(Res))) {
151 mysql_free_result(Res); 375 mysql_free_result(Res);
152 return ERR_NONE; 376 return ERR_NONE;
153 } 377 }
154 378
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 {
162 switch (sms->SMS[sms->Number].Coding) { 386 switch (sms->SMS[sms->Number].Coding) {
163 case SMS_Coding_Unicode: 387 case SMS_Coding_Unicode:
164 case SMS_Coding_Default: 388 case SMS_Coding_Default:
165 DecodeHexUnicode(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0])); 389 DecodeHexUnicode(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0]));
166 break; 390 break;
167 case SMS_Coding_8bit: 391 case SMS_Coding_8bit:
168 DecodeHexBin(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0])); 392 DecodeHexBin(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0]));
169 sms->SMS[sms->Number].Length=strlen(Row[0])/2; 393 sms->SMS[sms->Number].Length=strlen(Row[0])/2;
170 } 394 }
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;
187} 426}
188 427
189/* After sending SMS is moved to Sent Items or Error Items. */ 428/* After sending SMS is moved to Sent Items or Error Items. */
190static GSM_Error SMSDMySQL_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent) 429static GSM_Error SMSDMySQL_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
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;
267 } 442 }
268 return ERR_NONE; 443 return ERR_NONE;
269} 444}
270 445
271/* Adds SMS to Outbox */ 446/* Adds SMS to Outbox */
272static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config) 447static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config)
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
278 for (i=0;i<sms->Number;i++) { 471 for (i=0;i<sms->Number;i++) {
279 buffer[0]=0; 472 buffer[0]=0;
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) {
289 sprintf(buffer+strlen(buffer),"false"); 491 sprintf(buffer+strlen(buffer),"false");
290 } else { 492 } else {
291 sprintf(buffer+strlen(buffer),"true"); 493 sprintf(buffer+strlen(buffer),"true");
292 } 494 }
293 sprintf(buffer+strlen(buffer),"',NOW()"); 495 sprintf(buffer+strlen(buffer),"',NOW()");
294 } else { 496 } else {
295 sprintf(buffer+strlen(buffer),"%i'",i+1); 497 sprintf(buffer+strlen(buffer),"%i'",i+1);
296 } 498 }
297 sprintf(buffer+strlen(buffer),",'"); 499 sprintf(buffer+strlen(buffer),",'");
298 500
299 switch (sms->SMS[i].Coding) { 501 switch (sms->SMS[i].Coding) {
300 case SMS_Coding_Unicode: 502 case SMS_Coding_Unicode:
301 case SMS_Coding_Default: 503 case SMS_Coding_Default:
302 EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[i].Text,UnicodeLength(sms->SMS[i].Text)); 504 EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[i].Text,UnicodeLength(sms->SMS[i].Text));
303 break; 505 break;
304 case SMS_Coding_8bit: 506 case SMS_Coding_8bit:
305 EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].Text,sms->SMS[i].Length); 507 EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].Text,sms->SMS[i].Length);
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) {
309 case SMS_Coding_Unicode: 520 case SMS_Coding_Unicode:
310 sprintf(buffer+strlen(buffer),"Unicode"); 521 sprintf(buffer+strlen(buffer),"Unicode");
311 break; 522 break;
312 case SMS_Coding_Default: 523 case SMS_Coding_Default:
313 sprintf(buffer+strlen(buffer),"Default"); 524 sprintf(buffer+strlen(buffer),"Default");
314 break; 525 break;
315 case SMS_Coding_8bit: 526 case SMS_Coding_8bit:
316 sprintf(buffer+strlen(buffer),"8bit"); 527 sprintf(buffer+strlen(buffer),"8bit");
317 break; 528 break;
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) {
329 case SMS_Coding_Unicode: 536 case SMS_Coding_Unicode:
330 case SMS_Coding_Default: 537 case SMS_Coding_Default:
331 sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[i].Text)); 538 sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[i].Text));
332 for (j=0;j<(int)strlen(buffer2);j++) { 539 for (j=0;j<(int)strlen(buffer2);j++) {
333 sprintf(buffer3,"'"); 540 sprintf(buffer3,"'");
334 z = strlen(buffer); 541 z = strlen(buffer);
335 if (buffer2[j]==buffer3[0]) { 542 if (buffer2[j]==buffer3[0]) {
336 buffer[z+2]=0; 543 buffer[z+2]=0;
337 buffer[z+1]=buffer2[j]; 544 buffer[z+1]=buffer2[j];
338 buffer[z] ='\\'; 545 buffer[z] ='\\';
339 } else { 546 } else {
340 buffer[z+1]=0; 547 buffer[z+1]=0;
341 buffer[z] =buffer2[j]; 548 buffer[z] =buffer2[j];
342 } 549 }
343 } 550 }
344 break; 551 break;
345 case SMS_Coding_8bit: 552 case SMS_Coding_8bit:
346 553
347 break; 554 break;
348 } 555 }
349 sprintf(buffer+strlen(buffer),"','"); 556 sprintf(buffer+strlen(buffer),"','");
350 if (i==0) { 557 if (i==0) {
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 }
369 } else { 592 } else {
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;
378 } 601 }
379 } 602 }
380 } 603 }
381 return ERR_NONE; 604 return ERR_NONE;
382} 605}
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;
397 } 688 }
398 return ERR_NONE; 689 return ERR_NONE;
399} 690}
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,
404 SMSDMySQL_FindOutboxSMS, 712 SMSDMySQL_FindOutboxSMS,
405 SMSDMySQL_MoveSMS, 713 SMSDMySQL_MoveSMS,
406 SMSDMySQL_CreateOutboxSMS, 714 SMSDMySQL_CreateOutboxSMS,
407 SMSDMySQL_AddSentSMSInfo 715 SMSDMySQL_AddSentSMSInfo,
716 SMSDMySQL_RefreshSendStatus,
717 SMSDMySQL_RefreshPhoneStatus
408}; 718};
409 719
410#endif 720#endif
411 721
412/* How should editor hadle tabs in this file? Add editor commands here. 722/* How should editor hadle tabs in this file? Add editor commands here.
413 * vim: noexpandtab sw=8 ts=8 sts=8: 723 * vim: noexpandtab sw=8 ts=8 sts=8:
414 */ 724 */
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,32 +1,35 @@
1/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */ 1/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
2 2
3#include <string.h> 3#include <string.h>
4#include <signal.h> 4#include <signal.h>
5#include <stdarg.h> 5#include <stdarg.h>
6#include <time.h> 6#include <time.h>
7 7
8#include "../../common/misc/coding/coding.h" 8#include "../../common/misc/coding/coding.h"
9#include "../gammu.h" 9#include "../gammu.h"
10#include "smsdcore.h" 10#include "smsdcore.h"
11#include "s_files.h" 11#include "s_files.h"
12#ifdef HAVE_MYSQL_MYSQL_H 12#ifdef HAVE_MYSQL_MYSQL_H
13# include "s_mysql.h" 13# include "s_mysql.h"
14#endif 14#endif
15 15
16 FILE *smsd_log_file = NULL; 16 FILE *smsd_log_file = NULL;
17 static int TPMR;
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)
19{ 21{
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) {
22 SendingSMSStatus = ERR_NONE; 25 SendingSMSStatus = ERR_NONE;
23 } else { 26 } else {
24 SendingSMSStatus = ERR_UNKNOWN; 27 SendingSMSStatus = ERR_UNKNOWN;
25 } 28 }
26} 29}
27 30
28void GSM_Terminate_SMSD(char *msg, int error, bool exitprogram, int rc) 31void GSM_Terminate_SMSD(char *msg, int error, bool exitprogram, int rc)
29{ 32{
30 int ret = ERR_NONE; 33 int ret = ERR_NONE;
31 34
32 if (s.opened) { 35 if (s.opened) {
@@ -64,25 +67,25 @@ void WriteSMSDLog(char *format, ...)
64 va_end(argp); 67 va_end(argp);
65 68
66 GSM_GetCurrentDateTime(&date_time); 69 GSM_GetCurrentDateTime(&date_time);
67 70
68 fprintf(smsd_log_file,"%s %4d/%02d/%02d %02d:%02d:%02d : %s\n", 71 fprintf(smsd_log_file,"%s %4d/%02d/%02d %02d:%02d:%02d : %s\n",
69 DayOfWeek(date_time.Year, date_time.Month, date_time.Day), 72 DayOfWeek(date_time.Year, date_time.Month, date_time.Day),
70 date_time.Year, date_time.Month, date_time.Day, 73 date_time.Year, date_time.Month, date_time.Day,
71 date_time.Hour, date_time.Minute, date_time.Second,Buffer); 74 date_time.Hour, date_time.Minute, date_time.Second,Buffer);
72 fflush(smsd_log_file); 75 fflush(smsd_log_file);
73 } 76 }
74} 77}
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{
78 INI_Section *smsdcfgfile = NULL; 81 INI_Section *smsdcfgfile = NULL;
79 GSM_Config smsdcfg; 82 GSM_Config smsdcfg;
80 unsigned char *str; 83 unsigned char *str;
81 static unsigned charemptyPath[1] = "\0"; 84 static unsigned charemptyPath[1] = "\0";
82 85
83 smsdcfgfile=INI_ReadFile(filename, false); 86 smsdcfgfile=INI_ReadFile(filename, false);
84 if (smsdcfgfile==NULL) { 87 if (smsdcfgfile==NULL) {
85 fprintf(stderr,"Can't find file \"%s\"\n",filename); 88 fprintf(stderr,"Can't find file \"%s\"\n",filename);
86 exit(-1); 89 exit(-1);
87 } 90 }
88 91
@@ -93,114 +96,133 @@ void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
93 fprintf(stderr,"Can't open file \"%s\"\n",Config->logfilename); 96 fprintf(stderr,"Can't open file \"%s\"\n",Config->logfilename);
94 exit(-1); 97 exit(-1);
95 } 98 }
96 fprintf(stderr,"Log filename is \"%s\"\n",Config->logfilename); 99 fprintf(stderr,"Log filename is \"%s\"\n",Config->logfilename);
97 } 100 }
98 if (log) WriteSMSDLog("Start GAMMU smsd"); 101 if (log) WriteSMSDLog("Start GAMMU smsd");
99 102
100 /* Include Numbers used, because we don't want create new variable */ 103 /* Include Numbers used, because we don't want create new variable */
101 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "gammu", false); 104 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "gammu", false);
102 if (Config->IncludeNumbers) { 105 if (Config->IncludeNumbers) {
103 GSM_ReadConfig(smsdcfgfile, &smsdcfg, 0); 106 GSM_ReadConfig(smsdcfgfile, &smsdcfg, 0);
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 }
106 110
107 Config->PINCode=INI_GetValue(smsdcfgfile, "smsd", "PIN", false); 111 Config->PINCode=INI_GetValue(smsdcfgfile, "smsd", "PIN", false);
108 if (Config->PINCode == NULL) { 112 if (Config->PINCode == NULL) {
109 if (log) WriteSMSDLog("No PIN code in %s file",filename); 113 if (log) WriteSMSDLog("No PIN code in %s file",filename);
110 fprintf(stderr,"No PIN code in %s file\n",filename); 114 fprintf(stderr,"No PIN code in %s file\n",filename);
111 exit(-1); 115 exit(-1);
112 } 116 }
113 if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode); 117 if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode);
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);
125 if (str) Config->commtimeout=atoi(str); else Config->commtimeout = 1; 120 if (str) Config->commtimeout=atoi(str); else Config->commtimeout = 1;
126 str = INI_GetValue(smsdcfgfile, "smsd", "sendtimeout", false); 121 str = INI_GetValue(smsdcfgfile, "smsd", "sendtimeout", false);
127 if (str) Config->sendtimeout=atoi(str); else Config->sendtimeout = 10; 122 if (str) Config->sendtimeout=atoi(str); else Config->sendtimeout = 10;
128 str = INI_GetValue(smsdcfgfile, "smsd", "receivefrequency", false); 123 str = INI_GetValue(smsdcfgfile, "smsd", "receivefrequency", false);
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
132 Config->deliveryreport = INI_GetValue(smsdcfgfile, "smsd", "deliveryreport", false); 130 Config->deliveryreport = INI_GetValue(smsdcfgfile, "smsd", "deliveryreport", false);
133 if (Config->deliveryreport == NULL || (!mystrncasecmp(Config->deliveryreport, "log", 3) && !mystrncasecmp(Config->deliveryreport, "sms", 3))) { 131 if (Config->deliveryreport == NULL || (!mystrncasecmp(Config->deliveryreport, "log", 3) && !mystrncasecmp(Config->deliveryreport, "sms", 3))) {
134 Config->deliveryreport = "no"; 132 Config->deliveryreport = "no";
135 } 133 }
136 if (log) WriteSMSDLog("deliveryreport = %s", Config->deliveryreport); 134 if (log) WriteSMSDLog("deliveryreport = %s", Config->deliveryreport);
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
164 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "include_numbers", false); 183 Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "include_numbers", false);
165 Config->ExcludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "exclude_numbers", false); 184 Config->ExcludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "exclude_numbers", false);
166 if (Config->IncludeNumbers != NULL) { 185 if (Config->IncludeNumbers != NULL) {
167 if (log) WriteSMSDLog("Include numbers available"); 186 if (log) WriteSMSDLog("Include numbers available");
168 } 187 }
169 if (Config->ExcludeNumbers != NULL) { 188 if (Config->ExcludeNumbers != NULL) {
170 if (Config->IncludeNumbers == NULL) { 189 if (Config->IncludeNumbers == NULL) {
171 if (log) WriteSMSDLog("Exclude numbers available"); 190 if (log) WriteSMSDLog("Exclude numbers available");
172 } else { 191 } else {
173 if (log) WriteSMSDLog("Exclude numbers available, but IGNORED"); 192 if (log) WriteSMSDLog("Exclude numbers available, but IGNORED");
174 } 193 }
175 } 194 }
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}
180 201
181bool SMSD_CheckSecurity(GSM_SMSDConfig *Config) 202bool SMSD_CheckSecurity(GSM_SMSDConfig *Config)
182{ 203{
183 GSM_SecurityCode SecurityCode; 204 GSM_SecurityCode SecurityCode;
184 GSM_Error error; 205 GSM_Error error;
185 206
186 /* Need PIN ? */ 207 /* Need PIN ? */
187 error=Phone->GetSecurityStatus(&s,&SecurityCode.Type); 208 error=Phone->GetSecurityStatus(&s,&SecurityCode.Type);
188 /* Unknown error */ 209 /* Unknown error */
189 if (error != ERR_NOTSUPPORTED && error != ERR_NONE) { 210 if (error != ERR_NOTSUPPORTED && error != ERR_NONE) {
190 WriteSMSDLog("Error getting security status (%i)", error); 211 WriteSMSDLog("Error getting security status (%i)", error);
191 return false; 212 return false;
192 } 213 }
193 /* No supported - do not check more */ 214 /* No supported - do not check more */
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 */
196 switch (SecurityCode.Type) { 218 switch (SecurityCode.Type) {
197 case SEC_Pin: 219 case SEC_Pin:
198 WriteSMSDLog("Trying to enter PIN"); 220 WriteSMSDLog("Trying to enter PIN");
199 strcpy(SecurityCode.Code,Config->PINCode); 221 strcpy(SecurityCode.Code,Config->PINCode);
200 error=Phone->EnterSecurityCode(&s,SecurityCode); 222 error=Phone->EnterSecurityCode(&s,SecurityCode);
201 if (error == ERR_SECURITYERROR) { 223 if (error == ERR_SECURITYERROR) {
202 GSM_Terminate_SMSD("ERROR: incorrect PIN", error, true, -1); 224 GSM_Terminate_SMSD("ERROR: incorrect PIN", error, true, -1);
203 } 225 }
204 if (error != ERR_NONE) { 226 if (error != ERR_NONE) {
205 WriteSMSDLog("Error entering PIN (%i)", error); 227 WriteSMSDLog("Error entering PIN (%i)", error);
206 return false; 228 return false;
@@ -317,191 +339,245 @@ bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
317 339
318 error = Service->FindOutboxSMS(&sms, Config, Config->SMSID); 340 error = Service->FindOutboxSMS(&sms, Config, Config->SMSID);
319 341
320 if (error == ERR_EMPTY || error == ERR_NOTSUPPORTED) { 342 if (error == ERR_EMPTY || error == ERR_NOTSUPPORTED) {
321 /* No outbox sms - wait few seconds and escape */ 343 /* No outbox sms - wait few seconds and escape */
322 for (j=0;j<Config->commtimeout && !gshutdown;j++) { 344 for (j=0;j<Config->commtimeout && !gshutdown;j++) {
323 GSM_GetCurrentDateTime (&Date); 345 GSM_GetCurrentDateTime (&Date);
324 i=Date.Second; 346 i=Date.Second;
325 while (i==Date.Second && !gshutdown) { 347 while (i==Date.Second && !gshutdown) {
326 my_sleep(10); 348 my_sleep(10);
327 GSM_GetCurrentDateTime(&Date); 349 GSM_GetCurrentDateTime(&Date);
328 } 350 }
351 Service->RefreshPhoneStatus(Config);
329 } 352 }
330 return true; 353 return true;
331 } 354 }
332 if (error != ERR_NONE) { 355 if (error != ERR_NONE) {
333 /* Unknown error - escape */ 356 /* Unknown error - escape */
334 WriteSMSDLog("Error in outbox on %s", Config->SMSID); 357 WriteSMSDLog("Error in outbox on %s", Config->SMSID);
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 }
338 Service->MoveSMS(&sms,Config, Config->SMSID, true,false); 361 Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
339 return false; 362 return false;
340 } 363 }
364
341 if (!gshutdown) { 365 if (!gshutdown) {
342 if (strcmp(Config->prevSMSID, Config->SMSID) == 0) { 366 if (strcmp(Config->prevSMSID, Config->SMSID) == 0) {
343 Config->retries++; 367 Config->retries++;
344 if (Config->retries > MAX_RETRIES) { 368 if (Config->retries > MAX_RETRIES) {
345 Config->retries = 0; 369 Config->retries = 0;
346 strcpy(Config->prevSMSID, ""); 370 strcpy(Config->prevSMSID, "");
347 WriteSMSDLog("Moved to errorbox: %s", Config->SMSID); 371 WriteSMSDLog("Moved to errorbox: %s", Config->SMSID);
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 }
351 Service->MoveSMS(&sms,Config, Config->SMSID, true,false); 375 Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
352 return false; 376 return false;
353 } 377 }
354 } else { 378 } else {
355 Config->retries = 0; 379 Config->retries = 0;
356 strcpy(Config->prevSMSID, Config->SMSID); 380 strcpy(Config->prevSMSID, Config->SMSID);
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));
363 return false; 411 return false;
364 } 412 }
365 j=0; 413 Service->RefreshPhoneStatus(Config);
414 j = 0;
415 TPMR = -1;
366 SendingSMSStatus = ERR_TIMEOUT; 416 SendingSMSStatus = ERR_TIMEOUT;
367 while (!gshutdown) { 417 while (!gshutdown) {
368 GSM_GetCurrentDateTime (&Date); 418 GSM_GetCurrentDateTime (&Date);
369 z=Date.Second; 419 z=Date.Second;
370 while (z==Date.Second) { 420 while (z==Date.Second) {
371 my_sleep(10); 421 my_sleep(10);
372 GSM_GetCurrentDateTime(&Date); 422 GSM_GetCurrentDateTime(&Date);
373 GSM_ReadDevice(&s,true); 423 GSM_ReadDevice(&s,true);
374 if (SendingSMSStatus != ERR_TIMEOUT) break; 424 if (SendingSMSStatus != ERR_TIMEOUT) break;
375 } 425 }
426 Service->RefreshSendStatus(Config, Config->SMSID);
427 Service->RefreshPhoneStatus(Config);
376 if (SendingSMSStatus != ERR_TIMEOUT) break; 428 if (SendingSMSStatus != ERR_TIMEOUT) break;
377 j++; 429 j++;
378 if (j>Config->sendtimeout) break; 430 if (j>Config->sendtimeout) break;
379 } 431 }
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));
382 return false; 435 return false;
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) {
386 return false; 439 return false;
387 } 440 }
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, "");
394 if (Service->MoveSMS(&sms,Config, Config->SMSID, false, true) != ERR_NONE) { 443 if (Service->MoveSMS(&sms,Config, Config->SMSID, false, true) != ERR_NONE) {
395 Service->MoveSMS(&sms,Config, Config->SMSID, true, false); 444 Service->MoveSMS(&sms,Config, Config->SMSID, true, false);
396 } 445 }
397 } 446 }
398 return true; 447 return true;
399} 448}
400 449
401void SMSDaemon(int argc, char *argv[]) 450void SMSDaemon(int argc, char *argv[])
402{ 451{
403 int errors = 255, initerrors=0; 452 int errors = 255, initerrors=0;
404 GSM_SMSDService *Service; 453 GSM_SMSDService *Service;
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;
408 457
409 if (!strcmp(argv[2],"FILES")) { 458 if (!strcmp(argv[2],"FILES")) {
410 Service = &SMSDFiles; 459 Service = &SMSDFiles;
411#ifdef HAVE_MYSQL_MYSQL_H 460#ifdef HAVE_MYSQL_MYSQL_H
412 } else if (!strcmp(argv[2],"MYSQL")) { 461 } else if (!strcmp(argv[2],"MYSQL")) {
413 Service = &SMSDMySQL; 462 Service = &SMSDMySQL;
414#endif 463#endif
415 } else { 464 } else {
416 fprintf(stderr,"Unknown service type (\"%s\")\n",argv[2]); 465 fprintf(stderr,"Unknown service type (\"%s\")\n",argv[2]);
417 exit(-1); 466 exit(-1);
418 } 467 }
419 468
420 SMSD_ReadConfig(argv[3], &Config, true); 469 SMSD_ReadConfig(argv[3], &Config, true, argv[2]);
421 470
422 error = Service->Init(&Config); 471 error = Service->Init(&Config);
423 if (error!=ERR_NONE) { 472 if (error!=ERR_NONE) {
424 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1); 473 GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
425 } 474 }
426 475
427 signal(SIGINT, interrupt); 476 signal(SIGINT, interrupt);
428 signal(SIGTERM, interrupt); 477 signal(SIGTERM, interrupt);
429 fprintf(stderr,"Press Ctrl+C to stop the program ...\n"); 478 fprintf(stderr,"Press Ctrl+C to stop the program ...\n");
430 479
431 time1 = time(NULL); 480 lastreceive = time(NULL);
481 lastreset = time(NULL);
432 SendingSMSStatus = ERR_UNKNOWN; 482 SendingSMSStatus = ERR_UNKNOWN;
433 483
434 while (!gshutdown) { 484 while (!gshutdown) {
435 /* There were errors in communication - try to recover */ 485 /* There were errors in communication - try to recover */
436 if (errors > 2) { 486 if (errors > 2) {
437 if (errors != 255) { 487 if (errors != 255) {
438 WriteSMSDLog("Terminating communication (%i,%i)", error, errors); 488 WriteSMSDLog("Terminating communication (%i,%i)", error, errors);
439 error=GSM_TerminateConnection(&s); 489 error=GSM_TerminateConnection(&s);
440 } 490 }
441 if (initerrors++ > 3) my_sleep(30000); 491 if (initerrors++ > 3) my_sleep(30000);
442 WriteSMSDLog("Starting communication"); 492 WriteSMSDLog("Starting communication");
443 error=GSM_InitConnection(&s,2); 493 error=GSM_InitConnection(&s,2);
444 switch (error) { 494 switch (error) {
445 case ERR_NONE: 495 case ERR_NONE:
446 s.User.SendSMSStatus = SMSSendingSMSStatus; 496 s.User.SendSMSStatus = SMSSendingSMSStatus;
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 */
450 // di = s.di; 520 // di = s.di;
451 break; 521 break;
452 case ERR_DEVICEOPENERROR: 522 case ERR_DEVICEOPENERROR:
453 GSM_Terminate_SMSD("Can't open device (%i)", error, true, -1); 523 GSM_Terminate_SMSD("Can't open device (%i)", error, true, -1);
454 default: 524 default:
455 WriteSMSDLog("Error at init connection (%i)", error); 525 WriteSMSDLog("Error at init connection (%i)", error);
456 errors = 250; 526 errors = 250;
457 } 527 }
458 continue; 528 continue;
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
463 if (!SMSD_CheckSecurity(&Config)) { 533 if (!SMSD_CheckSecurity(&Config)) {
464 errors++; 534 errors++;
465 initerrors++; 535 initerrors++;
466 continue; 536 continue;
467 } else errors=0; 537 } else errors=0;
468 538
469 initerrors = 0; 539 initerrors = 0;
470 540
471 if (!SMSD_CheckSMSStatus(&Config,Service)) { 541 if (!SMSD_CheckSMSStatus(&Config,Service)) { /* read all incoming SMS */
472 errors++; 542 errors++;
473 continue; 543 continue;
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 }
476 if (!SMSD_SendSMS(&Config,Service)) continue; 551 if (!SMSD_SendSMS(&Config,Service)) continue;
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);
479} 555}
480 556
481GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms) 557GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms)
482{ 558{
483 GSM_SMSDService *Service; 559 GSM_SMSDService *Service;
484 GSM_SMSDConfig Config; 560 GSM_SMSDConfig Config;
485 561
486 if (!strcmp(service,"FILES")) { 562 if (!strcmp(service,"FILES")) {
487 Service = &SMSDFiles; 563 Service = &SMSDFiles;
488#ifdef HAVE_MYSQL_MYSQL_H 564#ifdef HAVE_MYSQL_MYSQL_H
489 } else if (!strcmp(service,"MYSQL")) { 565 } else if (!strcmp(service,"MYSQL")) {
490 Service = &SMSDMySQL; 566 Service = &SMSDMySQL;
491#endif 567#endif
492 } else { 568 } else {
493 fprintf(stderr,"Unknown service type (\"%s\")\n",service); 569 fprintf(stderr,"Unknown service type (\"%s\")\n",service);
494 exit(-1); 570 exit(-1);
495 } 571 }
496 572
497 SMSD_ReadConfig(filename, &Config, false); 573 SMSD_ReadConfig(filename, &Config, false, service);
498 574
499 error = Service->Init(&Config); 575 error = Service->Init(&Config);
500 if (error!=ERR_NONE) return ERR_UNKNOWN; 576 if (error!=ERR_NONE) return ERR_UNKNOWN;
501 577
502 return Service->CreateOutboxSMS(sms,&Config); 578 return Service->CreateOutboxSMS(sms,&Config);
503} 579}
504 580
505/* How should editor hadle tabs in this file? Add editor commands here. 581/* How should editor hadle tabs in this file? Add editor commands here.
506 * vim: noexpandtab sw=8 ts=8 sts=8: 582 * vim: noexpandtab sw=8 ts=8 sts=8:
507 */ 583 */
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,61 +1,78 @@
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
6#ifdef WIN32 6#ifdef WIN32
7# include <mysql.h> 7# include <mysql.h>
8# include <mysqld_error.h> 8# include <mysqld_error.h>
9#else 9#else
10# include <mysql/mysql.h> 10# include <mysql/mysql.h>
11# include <mysql/mysqld_error.h> 11# include <mysql/mysqld_error.h>
12#endif 12#endif
13#endif 13#endif
14 14
15#include "../../common/service/sms/gsmsms.h" 15#include "../../common/service/sms/gsmsms.h"
16#include "../../common/service/sms/gsmmulti.h" 16#include "../../common/service/sms/gsmmulti.h"
17 17
18#define MAX_RETRIES 1 18#define MAX_RETRIES 1
19 19
20 void SMSDaemon (int argc, char *argv[]); 20 void SMSDaemon (int argc, char *argv[]);
21 GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms); 21 GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms);
22 22
23typedef struct { 23typedef struct {
24 /* general options */ 24 /* general options */
25 INI_Entry *IncludeNumbers, *ExcludeNumbers; 25 INI_Entry *IncludeNumbers, *ExcludeNumbers;
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
29 /* options for FILES */ 31 /* options for FILES */
30 unsigned char *inboxpath, *outboxpath, *sentsmspath; 32 unsigned char *inboxpath, *outboxpath, *sentsmspath;
31 unsigned char *errorsmspath, *inboxformat, *transmitformat; 33 unsigned char *errorsmspath, *inboxformat, *transmitformat;
32 34
33 /* options for MYSQL */ 35 /* options for MYSQL */
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
41 MYSQL DB; char DT[20]; 45 MYSQL DB; char DT[20];
42#endif 46#endif
43} GSM_SMSDConfig; 47} GSM_SMSDConfig;
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;
53 70
54#ifdef __GNUC__ 71#ifdef __GNUC__
55__attribute__((format(printf, 1, 2))) 72__attribute__((format(printf, 1, 2)))
56#endif 73#endif
57void WriteSMSDLog(char *format, ...); 74void WriteSMSDLog(char *format, ...);
58 75
59/* How should editor hadle tabs in this file? Add editor commands here. 76/* How should editor hadle tabs in this file? Add editor commands here.
60 * vim: noexpandtab sw=8 ts=8 sts=8: 77 * vim: noexpandtab sw=8 ts=8 sts=8:
61 */ 78 */
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index c67dc6a..16c5880 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -371,25 +371,25 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
371 371
372 return cSum; 372 return cSum;
373 373
374} 374}
375//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 375//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
376#include <stdlib.h> 376#include <stdlib.h>
377#define DEBUGMODE false 377#define DEBUGMODE false
378bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 378bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
379{ 379{
380 380
381 QString fileName; 381 QString fileName;
382#ifdef _WIN32_ 382#ifdef _WIN32_
383 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 383 fileName = locateLocal("tmp", "tempfile.vcs")
384#else 384#else
385 fileName = "/tmp/kdepimtemp.vcs"; 385 fileName = "/tmp/kdepimtemp.vcs";
386#endif 386#endif
387#ifdef DESKTOP_VERSION 387#ifdef DESKTOP_VERSION
388 QString command ="./kammu --backup " + fileName + " -yes" ; 388 QString command ="./kammu --backup " + fileName + " -yes" ;
389#else 389#else
390 QString command ="kammu --backup " + fileName + " -yes" ; 390 QString command ="kammu --backup " + fileName + " -yes" ;
391#endif 391#endif
392 int ret = system ( command.latin1() ); 392 int ret = system ( command.latin1() );
393 if ( ret != 0 ) { 393 if ( ret != 0 ) {
394 qDebug("Error::command returned %d", ret); 394 qDebug("Error::command returned %d", ret);
395 return false; 395 return false;
@@ -575,25 +575,25 @@ bool PhoneFormat::save( Calendar *calendar)
575 int w = status.sizeHint().width()+20 ; 575 int w = status.sizeHint().width()+20 ;
576 if ( w < 200 ) w = 230; 576 if ( w < 200 ) w = 230;
577 int h = status.sizeHint().height()+20 ; 577 int h = status.sizeHint().height()+20 ;
578 int dw = QApplication::desktop()->width(); 578 int dw = QApplication::desktop()->width();
579 int dh = QApplication::desktop()->height(); 579 int dh = QApplication::desktop()->height();
580 status.setCaption(i18n("Writing to phone...") ); 580 status.setCaption(i18n("Writing to phone...") );
581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
582 status.show(); 582 status.show();
583 status.raise(); 583 status.raise();
584 qApp->processEvents(); 584 qApp->processEvents();
585 QString message; 585 QString message;
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
589 QString fileName = "/tmp/kdepimtemp.vcs"; 589 QString fileName = "/tmp/kdepimtemp.vcs";
590#endif 590#endif
591 591
592 // 1 remove events which should be deleted 592 // 1 remove events which should be deleted
593 QPtrList<Event> er = calendar->rawEvents(); 593 QPtrList<Event> er = calendar->rawEvents();
594 Event* ev = er.first(); 594 Event* ev = er.first();
595 while ( ev ) { 595 while ( ev ) {
596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
597 calendar->deleteEvent( ev ); 597 calendar->deleteEvent( ev );
598 } else { 598 } else {
599 599