summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show 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.c36
-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.c68
-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.h23
-rw-r--r--gammu/emb/common/misc/coding/md5.c2
-rw-r--r--gammu/emb/common/misc/misc.c15
-rw-r--r--gammu/emb/common/misc/misc.h8
-rw-r--r--gammu/emb/common/phone/alcatel/alcatel.c14
-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.c12
-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.c166
-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.c221
-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.c120
-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.c626
-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.c572
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.c130
-rw-r--r--gammu/emb/gammu/smsd/smsdcore.h27
-rw-r--r--libkcal/phoneformat.cpp4
74 files changed, 2985 insertions, 768 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
@@ -118,57 +118,57 @@
* Please also note, that CB function was always TO CHECK in MyGnokii/Gnokii
* too.
*/
/* Enables cell broadcast */
/* #undef GSM_ENABLE_CELLBROADCAST */
/* If you want backup/restore stuff. Some people wanted it - they required
* smalled library made from Gammu and didn't require it. Please note,
* that backup/restore stuff can be easy separated from other things.
*/
#define GSM_ENABLE_BACKUP 1
/* Bu default commented: some parts of source are not ready or not tested
* at all (or aren't good tested). Uncomment, if want them
*/
//#define DEVELOP
/* By default disabled. It allows to making short beep after such things
* like changing logo in phone (like in Logo Manager)
*/
//#define GSM_ENABLE_BEEP
/* ---------------------- C language specific --------------------------- */
#ifndef WIN32
/* are the scandir functions available */
# define HAVE_DIRENT_H 1
# define HAVE_SCANDIR 1
# define HAVE_ALPHASORT 1
# define HAVE_PTHREAD 1
# define HAVE_SYS_IOCTL_H 1
-# define HAVE_MYSQL_MYSQL_H 1
+//LR # define HAVE_MYSQL_MYSQL_H 1
#endif
#define HAVE_ISWSPACE 1
#define HAVE_TOWLOWER 1
#ifndef WIN32
/* Will be used Bluez BT stack ? */
// LR bluetooth disabled
//# define GSM_ENABLE_BLUEZ 1
/* Will be used Affix BT stack ? */
/* # undef GSM_ENABLE_AFFIX */
#endif
/* Uncomment, if you want searching RF channel during each BT connection */
/* It can make connecting longer or connection less stable */
/* With MS VC and MS BT stack required irprops.lib from MS Platform SDK to compile */
#ifndef WIN32
// LR bluetooth disabled
//# define BLUETOOTH_RF_SEARCHING 1
#else
//# define BLUETOOTH_RF_SEARCHING 1
#endif
#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
@@ -127,61 +127,62 @@ service/sms/gsmems.c \
service/sms/gsmmulti.c \
service/gsmcal.c \
service/gsmdata.c \
service/gsmpbk.c \
service/gsmring.c \
service/gsmlogo.c \
service/gsmmisc.c \
service/gsmnet.c \
service/backup/gsmback.c \
service/backup/backldif.c \
service/backup/backlmb.c \
service/backup/backtext.c \
service/backup/backvcs.c \
service/backup/backvcf.c \
service/backup/backics.c \
device/bluetoth/affix.c \
device/bluetoth/bluez.c \
device/bluetoth/blue_w32.c \
device/bluetoth/bluetoth.c \
device/serial/ser_djg.c \
device/irda/irda.c \
device/devfunc.c \
protocol/at/at.c \
protocol/alcatel/alcabus.c \
protocol/nokia/mbus2.c \
protocol/nokia/fbus2.c \
protocol/nokia/phonet.c \
protocol/obex/obex.c \
protocol/symbian/mrouter.c \
phone/pfunc.c \
phone/at/atgen.c \
phone/at/siemens.c \
+phone/at/samsung.c \
phone/at/sonyeric.c \
phone/alcatel/alcatel.c \
phone/nokia/dct3/n6110.c \
phone/nokia/dct3/n7110.c \
phone/nokia/dct3/n9210.c \
phone/nokia/dct3/dct3func.c \
phone/nokia/dct4/n3320.c \
phone/nokia/dct4/n3650.c \
phone/nokia/dct4/n6510.c \
phone/nokia/dct4/dct4func.c \
phone/nokia/nauto.c \
phone/nokia/nfunc.c \
phone/nokia/nfuncold.c \
phone/obex/obexgen.c \
phone/symbian/mroutgen.c
DEFINES += DESKTOP_VERSION
TARGET = microgammu
CONFIG = warn_off release console
DESTDIR = ../../../bin
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
unix: {
SOURCES += device/serial/ser_unx.c
}
win32:{
SOURCES += device/serial/ser_w32.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
@@ -128,53 +128,54 @@ service/sms/gsmmulti.c \
service/gsmcal.c \
service/gsmdata.c \
service/gsmpbk.c \
service/gsmring.c \
service/gsmlogo.c \
service/gsmmisc.c \
service/gsmnet.c \
service/backup/gsmback.c \
service/backup/backldif.c \
service/backup/backlmb.c \
service/backup/backtext.c \
service/backup/backvcs.c \
service/backup/backvcf.c \
service/backup/backics.c \
device/bluetoth/affix.c \
device/bluetoth/bluez.c \
device/bluetoth/blue_w32.c \
device/bluetoth/bluetoth.c \
device/serial/ser_unx.c \
device/serial/ser_djg.c \
device/irda/irda.c \
device/devfunc.c \
protocol/at/at.c \
protocol/alcatel/alcabus.c \
protocol/nokia/mbus2.c \
protocol/nokia/fbus2.c \
protocol/nokia/phonet.c \
protocol/obex/obex.c \
protocol/symbian/mrouter.c \
phone/pfunc.c \
phone/at/atgen.c \
phone/at/siemens.c \
+phone/at/samsung.c \
phone/at/sonyeric.c \
phone/alcatel/alcatel.c \
phone/nokia/dct3/n6110.c \
phone/nokia/dct3/n7110.c \
phone/nokia/dct3/n9210.c \
phone/nokia/dct3/dct3func.c \
phone/nokia/dct4/n3320.c \
phone/nokia/dct4/n3650.c \
phone/nokia/dct4/n6510.c \
phone/nokia/dct4/dct4func.c \
phone/nokia/nauto.c \
phone/nokia/nfunc.c \
phone/nokia/nfuncold.c \
phone/obex/obexgen.c \
phone/symbian/mroutgen.c
TARGET = kammu
DESTDIR = $(QPEDIR)/lib
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
CONFIG = warn_off release console
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,33 +1,42 @@
-/* Based on work by Marcel Holtmann and other authors of Bluez */
+/* Based on some work from Bluez (www.bluez.org)
+ * (C) 2000-2001 Qualcomm Incorporated
+ * (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
+ * (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
+ * GNU GPL version 2
+ */
+/* based on some Marcel Holtmann work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_BLUETOOTHDEVICE
#ifdef GSM_ENABLE_BLUEZ
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include "../../gsmcomon.h"
#include "../devfunc.h"
#include "bluetoth.h"
GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device)
{
GSM_Device_BlueToothData *d = &s->Device.Data.BlueTooth;
struct sockaddr_rc laddr, raddr;
bdaddr_t bdaddr;
int fd;
smprintf(s, "Connecting to RF channel %i\n",port);
@@ -52,156 +61,156 @@ GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device)
raddr.rc_family = AF_BLUETOOTH;
raddr.rc_channel = port;
if (connect(fd, (struct sockaddr *)&raddr, sizeof(raddr)) < 0) {
dbgprintf("Can't connect\n");
close(fd);
return ERR_DEVICEOPENERROR;
}
d->hPhone = fd;
return ERR_NONE;
}
#ifdef BLUETOOTH_RF_SEARCHING
struct search_context {
char *svc;
uuid_t group;
int tree;
uint32_t handle;
};
static void print_service_desc(void *value, void *user)
{
sdp_data_t *p = (sdp_data_t *)value;
int i = 0, proto = 0, *channel = (int *)user;
for (; p; p = p->next, i++) {
switch (p->dtd) {
case SDP_UUID16:
case SDP_UUID32:
case SDP_UUID128:
- proto = 1;//sdp_uuid_to_proto(&p->val.uuid);
+ proto = sdp_uuid_to_proto(&p->val.uuid);
break;
case SDP_UINT8:
if (proto == RFCOMM_UUID) {
(*channel) = p->val.uint8;
return;
}
break;
}
}
}
void print_access_protos(value, user)
{
sdp_list_t *protDescSeq = (sdp_list_t *)value;
int *channel = (int *)user;
sdp_list_foreach(protDescSeq,print_service_desc,channel);
}
static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context)
{
sdp_session_t *sess;
- sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
- uint32_t range = 0x0000ffff;
- char str[20];
sdp_record_t *rec;
+ sdp_list_t *attrid, *search, *seq, *next, *proto = 0;
sdp_data_t *d;
bdaddr_t interface;
+ uint32_t range = 0x0000ffff;
struct search_context subcontext;
+ char str[20];
int channel,channel2;
bacpy(&interface,BDADDR_ANY);
ba2str(bdaddr, str);
smprintf(s,"%s\n", str);
sess = sdp_connect(&interface, bdaddr, SDP_RETRY_IF_BUSY);
if (!sess) {
dbgprintf("Failed to connect to SDP server on %s: %s\n", str, strerror(errno));
return ERR_UNKNOWN;
}
attrid = sdp_list_append(0, &range);
search = sdp_list_append(0, &context->group);
if (sdp_service_search_attr_req(sess, search, SDP_ATTR_REQ_RANGE, attrid, &seq)) {
dbgprintf("Service Search failed: %s\n", strerror(errno));
sdp_close(sess);
return ERR_UNKNOWN;
}
sdp_list_free(attrid, 0);
sdp_list_free(search, 0);
channel2 = -1;
for (; seq; seq = next) {
rec = (sdp_record_t *) seq->data;
if (channel2 == -1) {
if (!context->tree) {
d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY);
- if (false) {
+ if (sdp_get_access_protos(rec,&proto) == 0) {
channel = -1;
sdp_list_foreach(proto,print_access_protos,&channel);
- //sdp_list_free(proto,(sdp_free_func_t)sdp_data_free);
+ sdp_list_free(proto,(sdp_free_func_t)sdp_data_free);
}
smprintf(s,"Channel %i",channel);
if (d) smprintf(s," - \"%s\"",d->val.str);
smprintf(s,"\n");
if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) {
channel2 = channel;
}
}
if (sdp_get_group_id(rec,&subcontext.group) != -1) {
memcpy(&subcontext, context, sizeof(struct search_context));
if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext);
}
}
next = seq->next;
free(seq);
- //sdp_record_free(rec);
+ sdp_record_free(rec);
}
sdp_close(sess);
if (channel2 != -1) return bluetooth_connect(s, channel2, str);
- return ERR_UNKNOWN;
+ return ERR_NOTSUPPORTED;
}
GSM_Error bluetooth_findchannel(GSM_StateMachine *s)
{
inquiry_info ii[20];
uint8_t count = 0;
int i;
struct search_context context;
GSM_Error error = ERR_NOTSUPPORTED;
memset(&context, '\0', sizeof(struct search_context));
- //sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP);
+ sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP);
if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) {
dbgprintf("Searching for devices\n");
if (sdp_general_inquiry(ii, 20, 8, &count) < 0) {
return ERR_UNKNOWN;
}
} else {
count = 1;
str2ba(s->CurrentConfig->Device,&ii[0].bdaddr);
}
for (i=0;i<count;i++) {
error = bluetooth_checkdevice(s,&ii[i].bdaddr,&context);
if (error == ERR_NONE) return error;
}
return error;
}
#endif
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,32 +1,40 @@
+/* Some source from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
+/* Some source from Minicom (http://alioth.debian.org/projects/minicom)
+ * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg
+ * GNU GPL version 2
+ */
#include <string.h>
#ifdef WIN32
# include <io.h>
#else
# include <errno.h>
# include <signal.h>
#endif
#include "../gsmstate.h"
#ifdef GSM_ENABLE_BLUETOOTHDEVICE
#ifdef BLUETOOTH_RF_SEARCHING
GSM_Error bluetooth_checkservicename(GSM_StateMachine *s, char *name)
{
if (s->ConnectionType == GCT_BLUEPHONET && strstr(name,"Nokia PC Suite")!=NULL) return ERR_NONE;
if (s->ConnectionType == GCT_BLUEOBEX && strstr(name,"OBEX") !=NULL) return ERR_NONE;
if (s->ConnectionType == GCT_BLUEAT && strstr(name,"COM 1") !=NULL) return ERR_NONE;
return ERR_UNKNOWN;
}
#endif
#endif
#if defined (GSM_ENABLE_BLUETOOTHDEVICE) || defined (GSM_ENABLE_IRDADEVICE)
int socket_read(GSM_StateMachine *s, void *buf, size_t nbytes, int hPhone)
{
fd_set readfds;
#ifdef WIN32
struct timeval timer;
@@ -76,65 +84,65 @@ GSM_Error socket_close(GSM_StateMachine *s, int hPhone)
closesocket(hPhone); /*FIXME: error checking */
#else
close(hPhone); /*FIXME: error checking */
#endif
return ERR_NONE;
}
#endif
#ifdef ENABLE_LGPL
GSM_Error lock_device(const char* port, char **lock_device)
{
*lock_device = 0;
return ERR_NONE;
}
bool unlock_device(char **lock_file)
{
return true;
}
#else
#define max_buf_len 128
#define lock_path "/var/lock/LCK.."
/* Lock the device. Allocated string with a lock name is returned
* in lock_device
*/
GSM_Error lock_device(const char* port, char **lock_device)
{
-#ifndef WIN32
+#if !defined(WIN32) && !defined(DJGPP)
char *lock_file = NULL;
char buffer[max_buf_len];
const char *aux;
int fd, len;
GSM_Error error = ERR_NONE;
dbgprintf("Locking device\n");
aux = strrchr(port, '/');
/* Remove leading '/' */
if (aux) {
aux++;
} else {
/* No / in port */
aux = port;
}
len = strlen(aux) + strlen(lock_path);
memset(buffer, 0, sizeof(buffer));
lock_file = calloc(len + 1, 1);
if (!lock_file) {
dbgprintf("Out of memory error while locking device\n");
return ERR_MOREMEMORY;
}
/* I think we don't need to use strncpy, as we should have enough
* buffer due to strlen results
*/
strcpy(lock_file, lock_path);
strcat(lock_file, aux);
/* Check for the stale lockfile.
* The code taken from minicom by Miquel van Smoorenburg */
@@ -189,65 +197,65 @@ GSM_Error lock_device(const char* port, char **lock_device)
dbgprintf("Device seems to be locked by unknown process\n");
error = ERR_DEVICEOPENERROR;
} else if (errno == EACCES) {
dbgprintf("Please check permission on lock directory\n");
error = ERR_PERMISSION;
} else if (errno == ENOENT) {
dbgprintf("Cannot create lockfile %s. Please check for existence of path\n", lock_file);
error = ERR_UNKNOWN;
} else {
dbgprintf("Unknown error with creating lockfile %s\n", lock_file);
error = ERR_UNKNOWN;
}
goto failed;
}
sprintf(buffer, "%10ld gammu\n", (long)getpid());
write(fd, buffer, strlen(buffer));
close(fd);
*lock_device = lock_file;
return ERR_NONE;
failed:
free(lock_file);
*lock_device = 0;
return error;
#else
*lock_device = 0;
return ERR_NONE;
#endif
}
/* Removes lock and frees memory */
bool unlock_device(char **lock_file)
{
-#ifndef WIN32
+#if !defined(WIN32) && !defined(DJGPP)
int err;
if (!lock_file) {
dbgprintf("Cannot unlock device\n");
return false;
}
err = unlink(*lock_file);
free(*lock_file);
*lock_file = NULL;
return (err + 1);
#else
return true;
#endif
}
#endif
int FindSerialSpeed(char *buffer)
{
switch (atoi(buffer)) {
case 50 : return 50;
case 75 : return 75;
case 110 : return 110;
case 134 : return 134;
case 150 : return 150;
case 200 : return 200;
case 300 : return 300;
case 600 : return 600;
case 1200 : return 1200;
case 1800 : return 1800;
case 2400 : return 2400;
case 4800 : return 4800;
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,35 +1,39 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Ralf Thelen and MyGnokii */
-/* based on some work from Gnokii and MSDN */
+/* based on some work from Ralf Thelen and MyGnokii (www.mwiacek.com) */
+/* based on some work from MSDN */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
/* You have to include wsock32.lib library to MS VC project to compile it */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_IRDADEVICE
#ifndef DJGPP
#ifndef WIN32
# include <stdlib.h>
# include <unistd.h>
# include <stdio.h>
# include <fcntl.h>
# include <errno.h>
# include <string.h>
# include <sys/time.h>
# include <sys/poll.h>
# include <sys/socket.h>
# include <sys/ioctl.h>
#else
# include <windows.h>
# include <io.h>
#endif
#include "../../gsmcomon.h"
#include "../devfunc.h"
#include "irda.h"
static bool irda_discover_device(GSM_StateMachine *state)
{
GSM_Device_IrdaData *d = &state->Device.Data.Irda;
struct irda_device_list *list;
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,33 +1,33 @@
-/* part of irda.h available in Linux kernel source */
+/* part of irda.h available in Linux kernel source (www.kernel.org) */
/*********************************************************************
*
* Filename: irda.h
* Version:
* Description:
* Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Mon Mar 8 14:06:12 1999
* Modified at: Sat Dec 25 16:06:42 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
*
* Copyright (c) 1999 Dag Brattli, All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge.
*
********************************************************************/
#ifndef __irda_unx_h
#define __irda_unx_h
#include <sys/types.h>
#include <sys/socket.h>
#define SOL_IRLMP 266 /* Same as SOL_IRDA for now */
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
@@ -1,74 +1,74 @@
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_SERIALDEVICE
#ifdef DJGPP
#include "../../gsmcomon.h"
#include "ser_djg.h"
static GSM_Error serial_close(GSM_StateMachine *s)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
static GSM_Error serial_open (GSM_StateMachine *s)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
- return ERR_NONE;
+ return ERR_NOTIMPLEMENTED;
}
static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
return 0;
}
static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
return 0;
}
GSM_Device_Functions SerialDevice = {
serial_open,
serial_close,
serial_setparity,
serial_setdtrrts,
serial_setspeed,
serial_read,
serial_write
};
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,67 +1,91 @@
/* (c) 2002-2004 by Marcin Wiacek */
/* locking device and settings all speeds by Michal Cihar */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_SERIALDEVICE
#ifndef WIN32
#ifndef DJGPP
#include <sys/file.h>
#include <sys/time.h>
#include <string.h>
#include <termios.h>
#include <errno.h>
#include "../../gsmcomon.h"
#include "ser_unx.h"
+#ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+#endif
+
+#ifdef __NetBSD__
+# define FNONBLOCK O_NONBLOCK
+
+# define B57600 0010001
+# define B115200 0010002
+# define B230400 0010003
+# define B460800 0010004
+# define B500000 0010005
+# define B576000 0010006
+# define B921600 0010007
+# define B1000000 0010010
+# define B1152000 0010011
+# define B1500000 0010012
+# define B2000000 0010013
+# define B2500000 0010014
+# define B3000000 0010015
+# define B3500000 0010016
+# define B4000000 0010017
+#endif
+
static GSM_Error serial_close(GSM_StateMachine *s)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
/* Restores old settings */
tcsetattr(d->hPhone, TCSANOW, &d->old_settings);
/* Closes device */
close(d->hPhone);
return ERR_NONE;
}
-#ifndef O_NONBLOCK
-# define O_NONBLOCK 0
-#endif
-
static GSM_Error serial_open (GSM_StateMachine *s)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
struct termios t;
int i;
/* O_NONBLOCK MUST is required to avoid waiting for DCD */
d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (d->hPhone < 0) {
i = errno;
GSM_OSErrorInfo(s,"open in serial_open");
if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory
if (i == 13) return ERR_DEVICENOPERMISSION; //permission denied
return ERR_DEVICEOPENERROR;
}
#ifdef TIOCEXCL
/* open() calls from other applications shall fail now */
ioctl(d->hPhone, TIOCEXCL, (char *) 0);
#endif
if (tcgetattr(d->hPhone, &d->old_settings) == -1) {
close(d->hPhone);
GSM_OSErrorInfo(s,"tcgetattr in serial_open");
return ERR_DEVICEREADERROR;
}
if (tcflush(d->hPhone, TCIOFLUSH) == -1) {
serial_close(s);
GSM_OSErrorInfo(s,"tcflush in serial_open");
return ERR_DEVICEOPENERROR;
}
@@ -173,79 +197,83 @@ static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts)
return ERR_NONE;
}
static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
struct termios t;
int speed2 = B19200;
if (tcgetattr(d->hPhone, &t)) {
GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed");
return ERR_DEVICEREADERROR;
}
smprintf(s, "Setting speed to %d\n", speed);
switch (speed) {
case 50: speed2 = B50; break;
case 75: speed2 = B75; break;
case 110: speed2 = B110; break;
case 134: speed2 = B134; break;
case 150: speed2 = B150; break;
case 200: speed2 = B200; break;
case 300: speed2 = B300; break;
case 600: speed2 = B600; break;
case 1200: speed2 = B1200; break;
case 1800: speed2 = B1800; break;
case 2400: speed2 = B2400; break;
case 4800: speed2 = B4800; break;
case 9600: speed2 = B9600; break;
case 19200: speed2 = B19200; break;
case 38400: speed2 = B38400; break;
+#ifdef B57600
case 57600: speed2 = B57600; break;
case 115200: speed2 = B115200; break;
case 230400: speed2 = B230400; break;
case 460800: speed2 = B460800; break;
+#ifdef B500000
case 500000: speed2 = B500000; break;
case 576000: speed2 = B576000; break;
case 921600: speed2 = B921600; break;
case 1000000: speed2 = B1000000; break;
case 1152000: speed2 = B1152000; break;
case 1500000: speed2 = B1500000; break;
case 2000000: speed2 = B2000000; break;
case 2500000: speed2 = B2500000; break;
case 3000000: speed2 = B3000000; break;
case 3500000: speed2 = B3500000; break;
case 4000000: speed2 = B4000000; break;
+#endif
+#endif
}
/* This should work on all systems because it is done according to POSIX */
cfsetispeed(&t, speed2);
cfsetospeed(&t, speed2);
if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) {
serial_close(s);
GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed");
return ERR_DEVICECHANGESPEEDERROR;
}
return ERR_NONE;
}
static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
struct timeval timeout2;
fd_set readfds;
int actual = 0;
FD_ZERO(&readfds);
FD_SET(d->hPhone, &readfds);
timeout2.tv_sec = 0;
timeout2.tv_usec = 1;
if (select(d->hPhone+1, &readfds, NULL, NULL, &timeout2)) {
actual = read(d->hPhone, buf, nbytes);
if (actual == -1) GSM_OSErrorInfo(s,"serial_read");
}
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,34 +1,38 @@
/* (c) 2002-2004 by Marcin Wiacek */
-/* based on some work from Gnokii, MSDN and others */
+/* based on some work from MSDN and others */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_SERIALDEVICE
#ifdef WIN32
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <memory.h>
#include "../../gsmcomon.h"
#include "ser_w32.h"
static GSM_Error serial_close(GSM_StateMachine *s)
{
GSM_Device_SerialData *d = &s->Device.Data.Serial;
/* Disables all monitored events for device */
SetCommMask(d->hPhone, 0);
/* Discards all characters from input/output buffer and terminates
* pending read/write operations
*/
PurgeComm(d->hPhone, PURGE_TXABORT | PURGE_RXABORT |
PURGE_TXCLEAR | PURGE_RXCLEAR);
/* Clears the DTR (data-terminal-ready) signal */
EscapeCommFunction(d->hPhone, CLRDTR);
/* Restores old settings */
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
@@ -92,105 +92,106 @@ unsigned char *GetMsg (INI_Section *cfg, unsigned char *default_string)
if (num < (int)strlen(buff) - 1) {
if (buff[num] == '\\' && buff[num+1] == 'n') {
def_str[strlen(def_str)] = 0x0a;
num+=2;
} else {
def_str[strlen(def_str)] = buff[num++];
}
} else {
def_str[strlen(def_str)] = buff[num++];
}
}
retval = def_str;
} else {
retval = default_string;
}
return retval;
}
}
e = e->Next;
}
return default_string;
}
typedef struct {
GSM_Error ErrorNum;
unsigned char *ErrorText;
} PrintErrorEntry;
static PrintErrorEntry PrintErrorEntries[] = {
{ERR_NONE, "No error."},
{ERR_DEVICEOPENERROR, "Error opening device. Unknown/busy or no permissions."},
{ERR_DEVICELOCKED, "Error opening device. Device locked."},
- {ERR_DEVICENOTEXIST, "Error opening device. Not exist."},
+ {ERR_DEVICENOTEXIST, "Error opening device. Doesn't exist."},
{ERR_DEVICEBUSY, "Error opening device. Already opened by other application."},
{ERR_DEVICENOPERMISSION, "Error opening device. No permissions."},
{ERR_DEVICENODRIVER, "Error opening device. No required driver in operating system."},
{ERR_DEVICENOTWORK, "Error opening device. Some hardware not connected/wrong configured."},
{ERR_DEVICEDTRRTSERROR, "Error setting device DTR or RTS."},
{ERR_DEVICECHANGESPEEDERROR, "Error setting device speed. Maybe speed not supported."},
{ERR_DEVICEWRITEERROR, "Error writing device."},
- {ERR_DEVICEREADERROR, "Error during reading device"},
- {ERR_DEVICEPARITYERROR, "Can't set parity on device"},
+ {ERR_DEVICEREADERROR, "Error during reading device."},
+ {ERR_DEVICEPARITYERROR, "Can't set parity on device."},
{ERR_TIMEOUT, "No response in specified timeout. Probably phone not connected."},
/* Some missed */
{ERR_UNKNOWNRESPONSE, "Unknown response from phone. See readme.txt, how to report it."},
/* Some missed */
{ERR_UNKNOWNCONNECTIONTYPESTRING,"Unknown connection type string. Check config file."},
{ERR_UNKNOWNMODELSTRING, "Unknown model type string. Check config file."},
{ERR_SOURCENOTAVAILABLE, "Some required functions not compiled for your OS. Please contact."},
{ERR_NOTSUPPORTED, "Function not supported by phone."},
{ERR_EMPTY, "Entry is empty"},
{ERR_SECURITYERROR, "Security error. Maybe no PIN ?"},
{ERR_INVALIDLOCATION, "Invalid location. Maybe too high ?"},
{ERR_NOTIMPLEMENTED, "Function not implemented. Help required."},
{ERR_FULL, "Memory full."},
{ERR_UNKNOWN, "Unknown error."},
/* Some missed */
{ERR_CANTOPENFILE, "Can't open specified file. Read only ?"},
{ERR_MOREMEMORY, "More memory required..."},
{ERR_PERMISSION, "Permission to file/device required..."},
- {ERR_EMPTYSMSC, "Empty SMSC number. Set in phone or use -smscnumber"},
+ {ERR_EMPTYSMSC, "Empty SMSC number. Set in phone or use -smscnumber."},
{ERR_INSIDEPHONEMENU, "You're inside phone menu (during editing ?). Leave it and try again."},
{ERR_WORKINPROGRESS, "Function is during writing. If want help, please contact with authors."},
- {ERR_PHONEOFF, "Phone is disabled and connected to charger"},
- {ERR_FILENOTSUPPORTED, "File format not supported by Gammu"},
+ {ERR_PHONEOFF, "Phone is disabled and connected to charger."},
+ {ERR_FILENOTSUPPORTED, "File format not supported by Gammu."},
{ERR_BUG, "Nobody is perfect, some bug appeared in protocol implementation. Please contact authors."},
- {ERR_CANCELED, "Transfer was canceled by phone (you pressed cancel on phone?)."},
+ {ERR_CANCELED, "Transfer was canceled by phone (you pressed cancel on phone?)"},
/* Some missed */
{ERR_OTHERCONNECTIONREQUIRED, "Current connection type doesn't support called function."},
- /* Some missed */
+ {ERR_WRONGCRC, "CRC error."},
{ERR_INVALIDDATETIME, "Invalid date or time specified."},
- {ERR_MEMORY, "Phone memory error, maybe it is read only"},
- {ERR_INVALIDDATA, "Invalid data"},
+ {ERR_MEMORY, "Phone memory error, maybe it is read only."},
+ {ERR_INVALIDDATA, "Invalid data."},
+ {ERR_FILEALREADYEXIST, "File with specified name already exist."},
{0, ""}
};
unsigned char *print_error(GSM_Error e, FILE *df, INI_Section *cfg)
{
unsigned char *def = NULL;
int i = 0;
while (PrintErrorEntries[i].ErrorNum != 0) {
if (PrintErrorEntries[i].ErrorNum == e) {
def = PrintErrorEntries[i].ErrorText;
break;
}
i++;
}
if (def == NULL) def = "Unknown error.";
if (df!=NULL && di.dl!=0) fprintf(df,"[ERROR %i: %s]\n",e,def);
return GetMsg(cfg,def);
}
const char *GetGammuLocalePath(void)
{
#ifdef LOCALE_PATH
static const char Buffer[] = LOCALE_PATH;
return Buffer;
#else
return NULL;
#endif
}
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
@@ -37,56 +37,57 @@ typedef enum {
ERR_DEVICEREADERROR, /* Error during reading device */
ERR_DEVICEPARITYERROR, /* Can't set parity on device */
ERR_TIMEOUT, /* Command timed out */
ERR_FRAMENOTREQUESTED, /* Frame handled, but not requested in this moment */
ERR_UNKNOWNRESPONSE, /* Response not handled by gammu */
ERR_UNKNOWNFRAME, /* Frame not handled by gammu */
ERR_UNKNOWNCONNECTIONTYPESTRING,/* Unknown connection type given by user */
ERR_UNKNOWNMODELSTRING, /* Unknown model given by user */
/*20*/ ERR_SOURCENOTAVAILABLE, /* Some functions not compiled in your OS */
ERR_NOTSUPPORTED, /* Not supported by phone */
ERR_EMPTY, /* Empty phonebook entry, ... */
ERR_SECURITYERROR, /* Not allowed */
ERR_INVALIDLOCATION, /* Too high or too low location... */
ERR_NOTIMPLEMENTED, /* Function not implemented */
ERR_FULL, /* Memory is full */
ERR_UNKNOWN,
ERR_CANTOPENFILE, /* Error during opening file */
ERR_MOREMEMORY, /* More memory required */
/*30*/ ERR_PERMISSION, /* No permission */
ERR_EMPTYSMSC, /* SMSC number is empty */
ERR_INSIDEPHONEMENU, /* Inside phone menu - can't make something */
ERR_NOTCONNECTED, /* Phone NOT connected - can't make something */
ERR_WORKINPROGRESS, /* Work in progress */
ERR_PHONEOFF, /* Phone is disabled and connected to charger */
ERR_FILENOTSUPPORTED, /* File format not supported by Gammu */
ERR_BUG, /* Found bug in implementation or phone */
ERR_CANCELED, /* Action was canceled by user */
ERR_NEEDANOTHERANSWER, /* Inside Gammu: phone module need to send another answer frame */
/*40*/ ERR_OTHERCONNECTIONREQUIRED,
ERR_WRONGCRC,
ERR_INVALIDDATETIME, /* Invalid date/time */
ERR_MEMORY, /* Phone memory error, maybe it is read only */
- ERR_INVALIDDATA /* Invalid data */
+ ERR_INVALIDDATA, /* Invalid data */
+ ERR_FILEALREADYEXIST /* File with specified name already exist */
} GSM_Error;
extern GSM_Error NoneFunction (void);
extern GSM_Error NotImplementedFunction (void);
extern GSM_Error NotSupportedFunction (void);
#define NONEFUNCTION (void *) NoneFunction
#define NOTIMPLEMENTED (void *) NotImplementedFunction
#define NOTSUPPORTED (void *) NotSupportedFunction
unsigned char *GetMsg (INI_Section *cfg, unsigned char *default_string);
unsigned char *print_error (GSM_Error e, FILE *df, INI_Section *cfg);
GSM_Error GSM_SetDebugFile(char *info, Debug_Info *privdi);
const char *GetGammuLocalePath(void);
const char *GetGammuVersion(void);
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -157,140 +157,140 @@ GSM_Error GSM_RegisterAllPhoneModules(GSM_StateMachine *s)
}
#endif
#ifdef GSM_ENABLE_ATGEN
/* With ATgen and auto model we can work with unknown models too */
if (s->ConnectionType==GCT_AT || s->ConnectionType==GCT_BLUEAT || s->ConnectionType==GCT_IRDAAT) {
smprintf(s,"[Module - \"%s\"]\n",ATGENPhone.models);
s->Phone.Functions = &ATGENPhone;
return ERR_NONE;
}
#endif
if (model->model[0] == 0) return ERR_UNKNOWNMODELSTRING;
}
s->Phone.Functions=NULL;
#ifdef GSM_ENABLE_ATGEN
/* AT module can have the same models ID to "normal" Nokia modules */
if (s->ConnectionType==GCT_AT || s->ConnectionType==GCT_BLUEAT || s->ConnectionType==GCT_IRDAAT) {
GSM_RegisterModule(s,&ATGENPhone);
if (s->Phone.Functions!=NULL) return ERR_NONE;
}
#endif
#ifdef GSM_ENABLE_OBEXGEN
GSM_RegisterModule(s,&OBEXGENPhone);
#endif
#ifdef GSM_ENABLE_MROUTERGEN
GSM_RegisterModule(s,&MROUTERGENPhone);
#endif
#ifdef GSM_ENABLE_NOKIA3320
GSM_RegisterModule(s,&N3320Phone);
#endif
#ifdef GSM_ENABLE_NOKIA3650
GSM_RegisterModule(s,&N3650Phone);
#endif
+#ifdef GSM_ENABLE_NOKIA650
+ GSM_RegisterModule(s,&N650Phone);
+#endif
#ifdef GSM_ENABLE_NOKIA6110
GSM_RegisterModule(s,&N6110Phone);
#endif
#ifdef GSM_ENABLE_NOKIA6510
GSM_RegisterModule(s,&N6510Phone);
#endif
#ifdef GSM_ENABLE_NOKIA7110
GSM_RegisterModule(s,&N7110Phone);
#endif
#ifdef GSM_ENABLE_NOKIA9210
GSM_RegisterModule(s,&N9210Phone);
#endif
#ifdef GSM_ENABLE_ALCATEL
GSM_RegisterModule(s,&ALCATELPhone);
#endif
if (s->Phone.Functions==NULL) return ERR_UNKNOWNMODELSTRING;
return ERR_NONE;
}
GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum)
{
GSM_Error error;
GSM_DateTime time;
int i;
- char Buffer[80];
for (i=0;i<s->ConfigNum;i++) {
s->CurrentConfig = &s->Config[i];
s->Speed = 0;
s->ReplyNum = ReplyNum;
s->Phone.Data.ModelInfo = GetModelData("unknown",NULL,NULL);
s->Phone.Data.Manufacturer[0] = 0;
s->Phone.Data.Model[0] = 0;
s->Phone.Data.Version[0] = 0;
s->Phone.Data.VerDate[0] = 0;
s->Phone.Data.VerNum = 0;
s->Phone.Data.StartInfoCounter = 0;
s->Phone.Data.SentMsg = NULL;
s->Phone.Data.HardwareCache[0] = 0;
s->Phone.Data.ProductCodeCache[0] = 0;
s->Phone.Data.EnableIncomingCall = false;
s->Phone.Data.EnableIncomingSMS = false;
s->Phone.Data.EnableIncomingCB = false;
s->Phone.Data.EnableIncomingUSSD = false;
s->User.UserReplyFunctions = NULL;
s->User.IncomingCall = NULL;
s->User.IncomingSMS = NULL;
s->User.IncomingCB = NULL;
s->User.IncomingUSSD = NULL;
s->User.SendSMSStatus = NULL;
s->LockFile = NULL;
s->opened = false;
s->Phone.Functions = NULL;
s->di = di;
s->di.use_global = s->CurrentConfig->UseGlobalDebugFile;
GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, &s->di);
error=GSM_SetDebugFile(s->CurrentConfig->DebugFile, &s->di);
if (error != ERR_NONE) return error;
if (s->di.dl == DL_TEXTALL || s->di.dl == DL_TEXT || s->di.dl == DL_TEXTERROR ||
s->di.dl == DL_TEXTALLDATE || s->di.dl == DL_TEXTDATE || s->di.dl == DL_TEXTERRORDATE) {
- smprintf(s,"[Gammu - version %s built %s %s]\n",VERSION,__TIME__,__DATE__);
- smprintf(s,"[Connection - \"%s\"]\n",s->CurrentConfig->Connection);
+ smprintf(s,"[Gammu - %s built %s %s",VERSION,__TIME__,__DATE__);
+ if (strlen(GetCompiler()) != 0) {
+ smprintf(s," in %s",GetCompiler());
+ }
+ smprintf(s,"]\n[Connection - \"%s\"]\n",s->CurrentConfig->Connection);
smprintf(s,"[Model type - \"%s\"]\n",s->CurrentConfig->Model);
smprintf(s,"[Device - \"%s\"]\n",s->CurrentConfig->Device);
-
- Buffer[0] = 0;
- if (strlen(GetOS()) != 0) sprintf(Buffer,"%s",GetOS());
- if (strlen(GetCompiler()) != 0) {
- if (Buffer[0] != 0) strcat(Buffer+strlen(Buffer),", ");
- strcat(Buffer+strlen(Buffer),GetCompiler());
+ if (strlen(GetOS()) != 0) {
+ smprintf(s,"[Run on - %s]\n",GetOS());
}
- if (Buffer[0] != 0) smprintf(s,"[OS/compiler - %s]\n",Buffer);
}
if (s->di.dl==DL_BINARY) {
smprintf(s,"%c",((unsigned char)strlen(VERSION)));
smprintf(s,"%s",VERSION);
}
error=GSM_RegisterAllConnections(s, s->CurrentConfig->Connection);
if (error!=ERR_NONE) return error;
/* Model auto */
if (s->CurrentConfig->Model[0]==0) {
if (mystrncasecmp(s->CurrentConfig->LockDevice,"yes",0)) {
error = lock_device(s->CurrentConfig->Device, &(s->LockFile));
if (error != ERR_NONE) return error;
}
/* Irda devices can set now model to some specific and
* we don't have to make auto detection later */
error=s->Device.Functions->OpenDevice(s);
if (i != s->ConfigNum - 1) {
if (error == ERR_DEVICEOPENERROR) continue;
if (error == ERR_DEVICELOCKED) continue;
if (error == ERR_DEVICENOTEXIST) continue;
if (error == ERR_DEVICEBUSY) continue;
if (error == ERR_DEVICENOPERMISSION) continue;
if (error == ERR_DEVICENODRIVER) continue;
if (error == ERR_DEVICENOTWORK) continue;
}
if (error!=ERR_NONE) {
if (s->LockFile!=NULL) unlock_device(&(s->LockFile));
return error;
}
@@ -525,82 +525,93 @@ GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer,
if (Phone->StartInfoCounter == 0) s->Phone.Functions->ShowStartInfo(s,false);
}
}
Phone->RequestID = request;
Phone->DispatchError = ERR_TIMEOUT;
for (reply=0;reply<s->ReplyNum;reply++) {
if (reply!=0) {
if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl == DL_TEXTERROR ||
s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE || s->di.dl == DL_TEXTERRORDATE)
{
smprintf(s, "[Retrying %i type 0x%02X]\n", reply, type);
}
}
error = s->Protocol.Functions->WriteMessage(s, buffer, length, type);
if (error!=ERR_NONE) return error;
error = GSM_WaitForOnce(s, buffer, length, type, time);
if (error != ERR_TIMEOUT) return error;
}
return Phone->DispatchError;
}
static GSM_Error CheckReplyFunctions(GSM_StateMachine *s, GSM_Reply_Function *Reply, int *reply)
{
GSM_Phone_Data *Data = &s->Phone.Data;
GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg;
bool execute;
bool available = false;
int i = 0;
+// int j;
while (Reply[i].requestID!=ID_None) {
execute=false;
/* Binary frames like in Nokia */
if (strlen(Reply[i].msgtype) < 2) {
if (Reply[i].msgtype[0]==msg->Type) {
if (Reply[i].subtypechar!=0) {
if (Reply[i].subtypechar<=msg->Length) {
if (msg->Buffer[Reply[i].subtypechar]==Reply[i].subtype)
execute=true;
}
} else execute=true;
}
} else {
+// printf("msg length %i %i\n",strlen(Reply[i].msgtype),msg->Length);
+ if ((int)strlen(Reply[i].msgtype)<msg->Length) {
+// printf("Comparing \"%s\" and \"",Reply[i].msgtype);
+// for (j=0;j<strlen(Reply[i].msgtype);j++) {
+// if (msg->Buffer[j]!=13 && msg->Buffer[j]!=10) {
+// printf("%c",msg->Buffer[j]);
+// }
+// }
+// printf("\"\n");
if (strncmp(Reply[i].msgtype,msg->Buffer,strlen(Reply[i].msgtype))==0) {
execute=true;
}
}
+ }
if (execute) {
*reply=i;
if (Reply[i].requestID == ID_IncomingFrame ||
Reply[i].requestID == Data->RequestID ||
Data->RequestID == ID_EachFrame) {
return ERR_NONE;
}
available=true;
}
i++;
}
if (available) {
return ERR_FRAMENOTREQUESTED;
} else {
return ERR_UNKNOWNFRAME;
}
}
GSM_Error GSM_DispatchMessage(GSM_StateMachine *s)
{
GSM_Error error = ERR_UNKNOWNFRAME;
GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg;
GSM_Phone_Data *Phone = &s->Phone.Data;
bool disp = false;
GSM_Reply_Function *Reply;
int reply, i;
if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
smprintf(s, "RECEIVED frame ");
@@ -816,223 +827,244 @@ bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num)
cfg->LockDevice = INI_GetValue(cfg_info, section, "use_locking", false);
if (!cfg->LockDevice) {
free(cfg->LockDevice);
cfg->LockDevice = strdup(DefaultLockDevice);
} else {
cfg->DefaultLockDevice = false;
}
Temp = INI_GetValue(cfg_info, section, "model", false);
if (!Temp) {
strcpy(cfg->Model,DefaultModel);
} else {
cfg->DefaultModel = false;
strcpy(cfg->Model,Temp);
}
Temp = INI_GetValue(cfg_info, section, "logformat", false);
if (!Temp) {
strcpy(cfg->DebugLevel,DefaultDebugLevel);
} else {
cfg->DefaultDebugLevel = false;
strcpy(cfg->DebugLevel,Temp);
}
cfg->StartInfo = INI_GetValue(cfg_info, section, "startinfo", false);
if (!cfg->StartInfo) {
free(cfg->StartInfo);
cfg->StartInfo = strdup(DefaultStartInfo);
} else {
cfg->DefaultStartInfo = false;
}
return true;
}
static OnePhoneModel allmodels[] = {
+#ifdef GSM_ENABLE_NOKIA650
+ {"0650" ,"THF-12","", {0}},
+#endif
#ifdef GSM_ENABLE_NOKIA6510
{"1100", "RH-18" ,"", {0}},
{"1100a","RH-38" ,"", {0}},
{"1100b","RH-36" ,"", {0}},
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"2100" ,"NAM-2" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess
#endif
#ifdef GSM_ENABLE_NOKIA6510
- {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},
- {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},
+ {"3100" ,"RH-19" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
+ {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme
{"3108", "RH-6", "Nokia 3108", {0}}, //does it have irda ?
- {"3200", "RH-30" ,"Nokia 3200", {F_PBKTONEGAL,0}},
- {"3200a","RH-31" ,"Nokia 3200", {F_PBKTONEGAL,0}},
+ {"3200", "RH-30" ,"Nokia 3200", {F_PBKTONEGAL,0}},//fixme
+ {"3200a","RH-31" ,"Nokia 3200", {F_PBKTONEGAL,0}},//fixme
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"3210" ,"NSE-8" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
{"3210" ,"NSE-9" ,"", {F_NOWAP,F_NOCALLER,F_NOCALENDAR,F_NOPBKUNICODE,F_POWER_BATT,F_PROFILES51,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
#endif
#ifdef GSM_ENABLE_NOKIA6510
- {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},
- {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},
+ {"3300" ,"NEM-1" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
+ {"3300" ,"NEM-2" ,"Nokia 3300", {F_PBKTONEGAL,0}},//fixme
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"3310" ,"NHM-5" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},
#endif
#ifdef GSM_ENABLE_NOKIA3320
{"3320" ,"NPC-1" ,"Nokia 3320", {F_CAL62,F_DAYMONTH,0}},//fixme
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"3330" ,"NHM-6" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
{"3390" ,"NPB-1" ,"", {F_NOWAP,F_NOCALLER,F_RING_SM,F_CAL33,F_PROFILES33,F_NOPICTUREUNI,F_NOCALLINFO,F_NODTMF,0}},
{"3410" ,"NHM-2" ,"", {F_RING_SM,F_CAL33,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},
#endif
#ifdef GSM_ENABLE_NOKIA6510
{"3510" ,"NHM-8" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}},
{"3510i","RH-9" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}},
{"3530" ,"RH-9" ,"", {F_CAL35,F_PBK35,F_NOGPRSPOINT,F_VOICETAGS,0}},
{"3589i","RH-44" ,"", {F_VOICETAGS,0}},
{"3590" ,"NPM-8" ,"", {0}},//irda?
{"3595" ,"NPM-10" ,"", {0}},//irda?
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"3610" ,"NAM-1" ,"", {F_NOCALLER,F_RING_SM,F_CAL33,F_POWER_BATT,F_PROFILES33,F_NOCALLINFO,F_NODTMF,0}},//quess
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA3650)
{"3650" ,"NHL-8" ,"Nokia 3650", {0}},
{"NGAGE","NEM-4" ,"", {F_RADIO,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
{"5100" ,"NPM-6" ,"Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
{"5100" ,"NPM-6U","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
{"5100" ,"NPM-6X","Nokia 5100", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
+ {"5140" ,"NPL-4" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
+ {"5140" ,"NPL-5" ,"Nokia 5140", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKUSER,F_WAPMMSPROXY,0}},
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"5110" ,"NSE-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
{"5110i","NSE-2" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
{"5130" ,"NSK-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
{"5190" ,"NSB-1" ,"", {F_NOWAP,F_NOCALLER,F_NORING,F_NOPICTURE,F_NOSTARTUP,F_NOCALENDAR,F_NOPBKUNICODE,F_PROFILES51,F_MAGICBYTES,F_DISPSTATUS,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
{"5210" ,"NSM-5" ,"Nokia 5210", {F_CAL52,F_NOSTARTANI,F_NOPICTUREUNI,F_NODTMF,0}},
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"5510" ,"NPM-5" ,"", {F_NOCALLER,F_PROFILES33,F_NOPICTUREUNI,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
{"6100" ,"NPL-2" ,"Nokia 6100", {F_PBKTONEGAL,F_TODO66,0}},
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"6110" ,"NSE-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
{"6130" ,"NSK-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
{"6150" ,"NSM-1" ,"", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,F_NOPICTUREUNI,0}},
{"6190" ,"NSB-3" ,"", {F_NOWAP,F_NOPICTURE,F_NOSTARTANI,F_NOPBKUNICODE,F_MAGICBYTES,F_DISPSTATUS,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
{"6200" ,"NPL-3" ,"Nokia 6200", {F_PBKTONEGAL,0}},
- {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,0}},
+ {"6220" ,"RH-20" ,"Nokia 6220", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110)
{"6210" ,"NPE-3" ,"Nokia 6210", {F_VOICETAGS,F_CAL62,0}},
{"6250" ,"NHM-3" ,"Nokia 6250", {F_VOICETAGS,F_CAL62,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
- {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}},
+ {"6230" ,"RH-12" ,"Nokia 6230", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,F_WAPMMSPROXY,F_NOTES,0}},
{"6310" ,"NPE-4" ,"Nokia 6310", {F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
{"6310i","NPL-1" ,"Nokia 6310i",{F_TODO63,F_CAL65,F_NOMIDI,F_BLUETOOTH,F_NOMMS,F_VOICETAGS,0}},
{"6385" ,"NHP-2AX","Nokia 6385",{F_TODO63,F_CAL65,F_NOMIDI,F_NOMMS,F_VOICETAGS,0}},
{"6510" ,"NPM-9" ,"Nokia 6510", {F_TODO63,F_CAL65,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
{"6610" ,"NHL-4U","Nokia 6610", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
+ {"6610i","RM-37" ,"Nokia 6610i",{F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
{"6800" ,"NSB-9" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
{"6800" ,"NHL-6" ,"Nokia 6800", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},
+ {"6810" ,"RM-2" ,"Nokia 6810", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess
+ {"6820" ,"NHL-9" ,"Nokia 6820", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,0}},//quess
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA7110)
{"7110" ,"NSE-5" ,"Nokia 7110", {F_CAL62,0}},
{"7190" ,"NSB-5" ,"Nokia 7190", {F_CAL62,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
+ {"7200" ,"RH-23" ,"Nokia 7200", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_PBKUSER,0}},//quess
{"7210" ,"NHL-4" ,"Nokia 7210", {F_PBKTONEGAL,F_TODO66,F_RADIO,0}},
{"7250" ,"NHL-4J","Nokia 7250", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}},
{"7250i","NHL-4JX","Nokia 7250i",{F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKIMG,0}},
{"7600", "NMM-3", "Nokia 7600", {F_TODO66,0}},
#endif
#if defined(GSM_ENABLE_ATGEN)
{"7650" ,"NHL-2" ,"Nokia 7650", {0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
{"8210" ,"NSM-3" ,"Nokia 8210", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}},
{"8250" ,"NSM-3D","Nokia 8250", {F_NOWAP,F_NOSTARTANI,F_CAL82,F_NOPICTUREUNI,0}},
{"8290" ,"NSB-7" ,"Nokia 8290", {F_NOWAP,F_NOSTARTANI,F_NOPBKUNICODE,F_NOPICTUREUNI,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
{"8310" ,"NHM-7" ,"Nokia 8310", {F_CAL62,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
{"8390" ,"NSB-8" ,"Nokia 8390", {F_CAL62,F_NOMIDI,F_RADIO,F_NOFILESYSTEM,F_NOMMS,F_VOICETAGS,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6110)
{"8850" ,"NSM-2" ,"Nokia 8850", {0}},
{"8855" ,"NSM-4" ,"Nokia 8855", {0}},
{"8890" ,"NSB-6" ,"Nokia 8890", {0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_NOKIA6510)
{"8910" ,"NHM-4" ,"Nokia 8910", {F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}},
{"8910i","NHM-4" ,"Nokia 8910i",{F_CAL62,F_NOMIDI,F_NOFILESYSTEM,F_NOMMS,0}},
#endif
#ifdef GSM_ENABLE_NOKIA9210
{"9210" ,"RAE-3" ,"", {0}},
{"9210i","RAE-5" ,"", {0}},
#endif
#ifdef GSM_ENABLE_ATGEN
{"at" , "at", "", {0}},
+ /* Siemens */
{"M20" , "M20", "", {F_M20SMS,F_SLOWWRITE,0}},
{"MC35" , "MC35", "", {0}},
+ {"TC35" , "TC35", "", {0}},
{"S25", "S25", "SIEMENS S25", {0}},
{"C35i" , "C35i", "", {0}},
{"S35i" , "S35i", "", {0}},
{"M35i" , "M35i", "", {0}},
{"S40" , "Siemens S40", "", {0}},
{"C45" , "C45", "", {0}},
{"S45" , "S45", "", {0}},
{"ME45" , "ME45", "", {0}},
{"SL45" , "SL45", "", {0}},
{"SL45i" , "SL45i", "", {0}},
{"M50" , "M50", "", {0}},
{"S45" , "6618" , "", {0}},
{"ME45" , "3618" , "", {0}},
{"S55" , "S55" , "", {0}},
+ /* Samsung */
+ {"S100" , "SGH-S100" , "", {0}},
+ {"S200" , "SGH-S200" , "", {0}},
+ {"S300" , "SGH-S300" , "", {0}},
+ {"S500" , "SGH-S500" , "", {0}},
+ {"V200" , "SGH-V200" , "", {0}},
+ {"T100" , "SGH-T100" , "", {0}},
+ {"E700" , "SGH-E700" , "", {0}},
+ /* Ericsson/Sony Ericsson */
{"T28s", "1101101-BVT28s","", {0}},
{"R320s" , "1101201-BV R320s","", {0}},
{"R380s", "7100101-BVR380s" ,"", {0}},
{"R520m", "1130101-BVR520m" ,"", {0}},
{"T39m", "1130102-BVT39m" ,"", {0}},
{"T65", "1101901-BVT65" , "", {0}},
{"T68", "1130201-BVT68" , "", {0}},
{"T68i", "1130202-BVT68" , "", {0}},
{"R600", "102001-BVR600" , "", {0}},
{"T200", "1130501-BVT200" ,"", {0}},
{"T300", "1130601-BVT300" ,"T300", {0}},
{"T310", "1130602-BVT310" ,"", {0}},
{"P800", "7130501-BVP800" ,"", {0}},
+ /* Other */
{"iPAQ" , "iPAQ" , "" , {0}},
{"A2D" , "A2D" , "" , {0}},
{"9210" , "RAE-3", "Nokia Communicator GSM900/1800",{0}},
{"myV-65", "myV-65 GPRS", "", {F_SMSME900,0}},
#endif
#if defined(GSM_ENABLE_ATGEN) || defined(GSM_ENABLE_ALCATEL)
{"BE5", "ONE TOUCH 500","", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}},
{"BH4", "ONE TOUCH 535","ALCATEL OT535", {F_ALCATEL,F_SMSONLYSENT,0}},
{"BF5", "ONE TOUCH 715","ALCATEL OT715", {F_ALCATEL,F_SMSONLYSENT,F_BROKENCPBS,0}},
#endif
{"unknown", "" ,"", {0}}
};
OnePhoneModel *GetModelData(char *model, char *number, char *irdamodel)
{
int i = 0;
while (strcmp(allmodels[i].number,"") != 0) {
if (model !=NULL) {
if (strcmp (model, allmodels[i].model) == 0) {
return (&allmodels[i]);
}
}
if (number !=NULL) {
if (strcmp (number, allmodels[i].number) == 0) {
return (&allmodels[i]);
}
}
if (irdamodel !=NULL) {
if (strcmp (irdamodel, allmodels[i].irdamodel) == 0) {
return (&allmodels[i]);
}
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,48 +1,56 @@
/* (c) 2002-2004 by Marcin Wiacek & Michal Cihar */
#ifndef __gsm_state_h
#define __gsm_state_h
#include <time.h>
#include "config.h"
#include "misc/cfg.h"
+typedef struct _GSM_StateMachine GSM_StateMachine;
+typedef struct _GSM_User GSM_User;
+typedef struct _OnePhoneModel OnePhoneModel;
+typedef struct _GSM_Reply_Function GSM_Reply_Function;
+
#ifdef GSM_ENABLE_NOKIA3320
# include "phone/nokia/dct4/n3320.h"
#endif
#ifdef GSM_ENABLE_NOKIA3650
# include "phone/nokia/dct4/n3650.h"
#endif
+#ifdef GSM_ENABLE_NOKIA650
+# include "phone/nokia/dct3/n0650.h"
+#endif
#ifdef GSM_ENABLE_NOKIA6110
# include "phone/nokia/dct3/n6110.h"
#endif
#ifdef GSM_ENABLE_NOKIA6510
# include "phone/nokia/dct4/n6510.h"
#endif
#ifdef GSM_ENABLE_NOKIA7110
# include "phone/nokia/dct3/n7110.h"
#endif
#ifdef GSM_ENABLE_NOKIA9210
# include "phone/nokia/dct3/n9210.h"
#endif
#ifdef GSM_ENABLE_ATGEN
# include "phone/at/atgen.h"
#endif
#ifdef GSM_ENABLE_ALCATEL
# include "phone/alcatel/alcatel.h"
#endif
#ifdef GSM_ENABLE_OBEXGEN
# include "phone/obex/obexgen.h"
#endif
#ifdef GSM_ENABLE_MROUTERGEN
# include "phone/symbian/mroutgen.h"
#endif
#ifndef GSM_USED_MBUS2
# undef GSM_ENABLE_MBUS2
#endif
#ifndef GSM_USED_FBUS2
# undef GSM_ENABLE_FBUS2
#endif
#ifndef GSM_USED_FBUS2DLR3
@@ -65,65 +73,65 @@
#endif
#ifndef GSM_USED_AT
# undef GSM_ENABLE_AT
#endif
#ifndef GSM_USED_IRDAOBEX
# undef GSM_ENABLE_IRDAOBEX
#endif
#ifndef GSM_USED_BLUEOBEX
# undef GSM_ENABLE_BLUEOBEX
#endif
#ifndef GSM_USED_ALCABUS
# undef GSM_ENABLE_ALCABUS
#endif
#ifndef GSM_USED_IRDAPHONET
# undef GSM_ENABLE_IRDAPHONET
#endif
#ifndef GSM_USED_BLUEFBUS2
# undef GSM_ENABLE_BLUEFBUS2
#endif
#ifndef GSM_USED_BLUEPHONET
# undef GSM_ENABLE_BLUEPHONET
#endif
#ifndef GSM_USED_BLUEAT
# undef GSM_ENABLE_BLUEAT
#endif
#ifndef GSM_USED_IRDAAT
# undef GSM_ENABLE_IRDAAT
#endif
#ifndef GSM_USED_MROUTERBLUE
# undef GSM_ENABLE_MROUTERBLUE
#endif
-#if defined(GSM_ENABLE_NOKIA3320) || defined(GSM_ENABLE_NOKIA6110) || defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
+#if defined(GSM_ENABLE_NOKIA3320) || defined(GSM_ENABLE_NOKIA650) || defined(GSM_ENABLE_NOKIA6110) || defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
# define GSM_ENABLE_NOKIA_DCT3
#endif
#if defined(GSM_ENABLE_NOKIA3650) || defined(GSM_ENABLE_NOKIA6510)
# define GSM_ENABLE_NOKIA_DCT4
#endif
#include "protocol/protocol.h"
#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)
# include "protocol/nokia/fbus2.h"
#endif
#ifdef GSM_ENABLE_MBUS2
# include "protocol/nokia/mbus2.h"
#endif
#if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET)
# include "protocol/nokia/phonet.h"
#endif
#if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT)
# include "protocol/at/at.h"
#endif
#ifdef GSM_ENABLE_ALCABUS
# include "protocol/alcatel/alcabus.h"
#endif
#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX)
# include "protocol/obex/obex.h"
#endif
#if defined(GSM_ENABLE_MROUTERBLUE)
# include "protocol/symbian/mrouter.h"
#endif
#define GSM_ENABLE_SERIALDEVICE
#ifndef GSM_USED_SERIALDEVICE
# undef GSM_ENABLE_SERIALDEVICE
@@ -170,67 +178,64 @@
# undef GSM_ENABLE_PHONETBLUE
# undef GSM_ENABLE_FBUS2BLUE
# undef GSM_ENABLE_MROUTERBLUE
# endif
#endif
#ifdef GSM_ENABLE_SERIALDEVICE
# include "device/serial/ser_w32.h"
# include "device/serial/ser_unx.h"
# include "device/serial/ser_djg.h"
#endif
#ifdef GSM_ENABLE_IRDADEVICE
# include "device/irda/irda.h"
#endif
#ifdef GSM_ENABLE_BLUETOOTHDEVICE
# include "device/bluetoth/bluetoth.h"
#endif
#include "service/gsmpbk.h"
#include "service/gsmnet.h"
#include "service/gsmring.h"
#include "service/gsmcal.h"
#include "service/gsmdata.h"
#include "service/gsmlogo.h"
#include "service/gsmmisc.h"
#include "service/gsmprof.h"
#include "service/gsmcall.h"
#include "service/sms/gsmsms.h"
#include "service/sms/gsmems.h"
#include "service/sms/gsmmulti.h"
#include "service/backup/gsmback.h"
-typedef struct _GSM_StateMachine GSM_StateMachine;
-typedef struct _GSM_User GSM_User;
-typedef struct _OnePhoneModel OnePhoneModel;
/* ------------------------- Device layer ---------------------------------- */
/**
* Device functions, each device has to provide these.
*/
typedef struct {
/**
* Opens device.
*/
GSM_Error (*OpenDevice) (GSM_StateMachine *s);
/**
* Closes device.
*/
GSM_Error (*CloseDevice) (GSM_StateMachine *s);
/**
* Sets parity for device.
*/
GSM_Error (*DeviceSetParity) (GSM_StateMachine *s, bool parity);
/**
* Sets dtr (data to read) and rts (ready to send) flags.
*/
GSM_Error (*DeviceSetDtrRts) (GSM_StateMachine *s, bool dtr, bool rts);
/**
* Sets device speed.
*/
GSM_Error (*DeviceSetSpeed) (GSM_StateMachine *s, int speed);
/**
* Attempts to read nbytes from device.
*/
int (*ReadDevice) (GSM_StateMachine *s, void *buf, size_t nbytes);
/**
@@ -342,64 +347,66 @@ typedef struct {
#endif
#if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX)
GSM_Protocol_OBEXData OBEX;
#endif
#if defined(GSM_ENABLE_MROUTERBLUE)
GSM_Protocol_MROUTERData MROUTER;
#endif
} Data;
GSM_Protocol_Functions *Functions;
} GSM_Protocol;
/* -------------------------- Phone layer ---------------------------------- */
/**
* Phone requests identificators, these are used for internally identifying
* which operation is being performed.
*/
typedef enum {
ID_None=1,
ID_GetModel,
ID_GetFirmware,
ID_EnableSecurity,
ID_GetIMEI,
ID_GetDateTime,
ID_GetAlarm,
ID_GetMemory,
ID_GetMemoryStatus,
ID_GetSMSC,
ID_GetSMSMessage,
ID_EnableEcho,
ID_EnableErrorInfo,
ID_SetOBEX,
+ ID_SetUSSD,
+ ID_GetNote,
ID_GetSignalQuality,
ID_GetBatteryCharge,
ID_GetSMSFolders,
ID_GetSMSFolderStatus,
ID_GetSMSStatus,
ID_AddSMSFolder,
ID_GetNetworkInfo,
ID_GetRingtone,
ID_DialVoice,
ID_GetCalendarNotesInfo,
ID_GetCalendarNote,
ID_GetSecurityCode,
ID_GetWAPBookmark,
ID_GetBitmap,
ID_SaveSMSMessage,
ID_CancelCall,
ID_SetDateTime,
ID_SetAlarm,
ID_DisableConnectFunc,
ID_EnableConnectFunc,
ID_AnswerCall,
ID_SetBitmap,
ID_SetRingtone,
ID_DeleteSMSMessage,
ID_DeleteCalendarNote,
ID_SetPath,
ID_SetSMSC,
ID_SetProfile,
ID_SetMemory,
ID_DeleteMemory,
ID_SetCalendarNote,
ID_SetIncomingSMS,
@@ -409,64 +416,65 @@ typedef enum {
ID_GetConnectSet,
ID_SetWAPBookmark,
ID_GetLocale,
ID_SetLocale,
ID_GetCalendarSettings,
ID_SetCalendarSettings,
ID_GetGPRSPoint,
ID_SetGPRSPoint,
ID_EnableGPRSPoint,
ID_DeleteWAPBookmark,
ID_Netmonitor,
ID_HoldCall,
ID_UnholdCall,
ID_ConferenceCall,
ID_SplitCall,
ID_TransferCall,
ID_SwitchCall,
ID_GetManufactureMonth,
ID_GetProductCode,
ID_GetOriginalIMEI,
ID_GetHardware,
ID_GetPPM,
ID_GetSMSMode,
ID_GetSMSMemories,
ID_GetManufacturer,
ID_SetMemoryType,
ID_SetMemoryCharset,
ID_GetMMSSettings,
ID_SetSMSParameters,
ID_GetFMStation,
ID_SetFMStation,
ID_GetLanguage,
+ ID_SetFastSMSSending,
ID_Reset,
ID_GetToDo,
ID_PressKey,
ID_DeleteAllToDo,
ID_SetLight,
ID_Divert,
ID_SetToDo,
ID_PlayTone,
ID_GetChatSettings,
ID_GetSyncMLSettings,
ID_GetSyncMLName,
ID_GetSecurityStatus,
ID_EnterSecurityCode,
ID_GetProfile,
ID_GetRingtonesInfo,
ID_MakeAuthentication,
ID_GetSpeedDial,
ID_ResetPhoneSettings,
ID_SendDTMF,
ID_GetDisplayStatus,
ID_SetAutoNetworkLogin,
ID_SetConnectSet,
ID_SetMMSSettings,
ID_GetSIMIMSI,
ID_GetFileInfo,
ID_FileSystemStatus,
ID_GetFile,
ID_AddFile,
ID_AddFolder,
ID_DeleteFile,
#ifdef GSM_ENABLE_ALCATEL
/* AT mode */
@@ -640,64 +648,65 @@ typedef struct {
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_CalendarEntry *Cal;
/**
* Used internally by phone drivers.
*/
unsigned char *SecurityCode;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_WAPBookmark *WAPBookmark;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_MultiWAPSettings *WAPSettings;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_Bitmap *Bitmap;
/**
* Used internally by phone drivers.
*/
unsigned char *Netmonitor;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_MultiCallDivert *Divert;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_ToDoEntry *ToDo;
+ GSM_NoteEntry *Note;
/**
* Used internally by phone drivers.
*/
bool PressKey;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_SecurityCodeType *SecurityStatus;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_Profile *Profile;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_AllRingtonesInfo *RingtonesInfo;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_DisplayFeatures *DisplayFeatures;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_FMStation *FMStation;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_Locale *Locale;
/**
* Pointer to structure used internally by phone drivers.
*/
GSM_CalendarSettings *CalendarSettings;
@@ -741,123 +750,126 @@ typedef struct {
*/
bool EnableIncomingUSSD;
/**
* Last message received from phone.
*/
GSM_Protocol_Message *RequestMsg;
/**
* Last message sent by Gammu.
*/
GSM_Protocol_Message *SentMsg;
/**
* What operation is being performed now, see @ref GSM_Phone_RequestID
* for possible values.
*/
GSM_Phone_RequestID RequestID;
/**
* Error returned by function in phone module.
*/
GSM_Error DispatchError;
/**
* Structure with private phone modules data.
*/
struct {
int fake;
#ifdef GSM_ENABLE_NOKIA3320
GSM_Phone_N3320Data N3320;
#endif
#ifdef GSM_ENABLE_NOKIA3650
GSM_Phone_N3650Data N3650;
#endif
+#ifdef GSM_ENABLE_NOKIA650
+ GSM_Phone_N650Data N650;
+#endif
#ifdef GSM_ENABLE_NOKIA6110
GSM_Phone_N6110Data N6110;
#endif
#ifdef GSM_ENABLE_NOKIA6510
GSM_Phone_N6510Data N6510;
#endif
#ifdef GSM_ENABLE_NOKIA7110
GSM_Phone_N7110Data N7110;
#endif
#ifdef GSM_ENABLE_ATGEN
GSM_Phone_ATGENData ATGEN;
#endif
#ifdef GSM_ENABLE_ALCATEL
GSM_Phone_ALCATELData ALCATEL;
#endif
#ifdef GSM_ENABLE_OBEXGEN
GSM_Phone_OBEXGENData OBEXGEN;
#endif
#ifdef GSM_ENABLE_MROUTERGEN
GSM_Phone_MROUTERGENData MROUTERGEN;
#endif
} Priv;
} GSM_Phone_Data;
/**
* Structure for defining reply functions.
*
* Function is called when requestID matches current operation or is
* ID_IncomingFrame and msgtype matches start message and (if msgtype is just
* one character) subtypechar is zero or subtypechar-th character of message
* matches subtype.
*
* Should be used in array with last element containing ID_None as requestID.
*/
-typedef struct {
+struct _GSM_Reply_Function {
/**
* Pointer to function that should be executed.
*/
GSM_Error (*Function) (GSM_Protocol_Message msg, GSM_StateMachine *s);
/**
* Message type, if it is longer than 1 character, it disables subtype
* checking.
*/
unsigned char *msgtype;
/**
* Which character of message should be checked as subtype. Zero to
* disable subtype checking.
*/
int subtypechar;
/**
* Subtype to be checked.
*/
unsigned char subtype;
/**
* Phone request when this can be called, use ID_IncomingFrame when
* you want to use this in any state.
*/
GSM_Phone_RequestID requestID;
-} GSM_Reply_Function;
+};
/**
* Structure defining phone functions.
*/
typedef struct {
/**
* Names of supported models separated by |. Must contain at least one
* name.
*/
char *models;
/**
* Array of reply functions for the phone, see
* @ref GSM_Reply_Function for details about it.
*/
GSM_Reply_Function *ReplyFunctions;
/**
* Initializes phone.
*/
GSM_Error (*Initialise) (GSM_StateMachine *s);
/**
* Terminates phone communication.
*/
GSM_Error (*Terminate) (GSM_StateMachine *s);
/**
* Dispatches messages from phone, at the end it should call
* @ref GSM_DispatchMessage.
*/
GSM_Error (*DispatchMessage) (GSM_StateMachine *s);
/**
* Enables showing information on phone display.
*/
GSM_Error (*ShowStartInfo) (GSM_StateMachine *s, bool enable);
@@ -1030,64 +1042,65 @@ typedef struct {
* both SIM and phone).
*/
GSM_Error (*GetSMSStatus) (GSM_StateMachine *s, GSM_SMSMemoryStatus *status);
/**
* Reads SMS message.
*/
GSM_Error (*GetSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms);
/**
* Reads next (or first if start set) SMS message. This might be
* faster for some phones than using @ref GetSMS for each message.
*/
GSM_Error (*GetNextSMS) (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start);
/**
* Sets SMS.
*/
GSM_Error (*SetSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
/**
* Adds SMS to specified folder.
*/
GSM_Error (*AddSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
/**
* Deletes SMS.
*/
GSM_Error (*DeleteSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
/**
* Sends SMS.
*/
GSM_Error (*SendSMS) (GSM_StateMachine *s, GSM_SMSMessage *sms);
/**
* Sends SMS already saved in phone.
*/
GSM_Error (*SendSavedSMS) (GSM_StateMachine *s, int Folder, int Location);
+ GSM_Error (*SetFastSMSSending) (GSM_StateMachine *s, bool enable);
/**
* Enable/disable notification on incoming SMS.
*/
GSM_Error (*SetIncomingSMS) (GSM_StateMachine *s, bool enable);
/**
* Gets network information from phone.
*/
GSM_Error (*SetIncomingCB) (GSM_StateMachine *s, bool enable);
/**
* Returns SMS folders information.
*/
GSM_Error (*GetSMSFolders) (GSM_StateMachine *s, GSM_SMSFolders *folders);
/**
* Creates SMS folder.
*/
GSM_Error (*AddSMSFolder) (GSM_StateMachine *s, unsigned char *name);
/**
* Deletes SMS folder.
*/
GSM_Error (*DeleteSMSFolder) (GSM_StateMachine *s, int ID);
/**
* Dials number and starts voice call.
*/
GSM_Error (*DialVoice) (GSM_StateMachine *s, char *Number, GSM_CallShowNumber ShowNumber);
/**
* Accept current incoming call.
*/
GSM_Error (*AnswerCall) (GSM_StateMachine *s, int ID, bool all);
/**
* Deny current incoming call.
*/
GSM_Error (*CancelCall) (GSM_StateMachine *s, int ID, bool all);
@@ -1250,129 +1263,132 @@ typedef struct {
/**
* Retrieves calendar entry. This is useful for continuous reading of all
* calendar entries.
*/
GSM_Error (*GetNextCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
/**
* Sets calendar entry
*/
GSM_Error (*SetCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note);
/**
* Adds calendar entry.
*/
GSM_Error (*AddCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note);
/**
* Deletes calendar entry.
*/
GSM_Error (*DeleteCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note);
/**
* Deletes all calendar entries.
*/
GSM_Error (*DeleteAllCalendar) (GSM_StateMachine *s);
/**
* Reads calendar settings.
*/
GSM_Error (*GetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings);
/**
* Sets calendar settings.
*/
GSM_Error (*SetCalendarSettings)(GSM_StateMachine *s, GSM_CalendarSettings *settings);
/**
* Gets note.
*/
- GSM_Error (*GetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh);
+ GSM_Error (*GetNextNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh);
/**
* Reads profile.
*/
GSM_Error (*GetProfile) (GSM_StateMachine *s, GSM_Profile *Profile);
/**
* Updates profile.
*/
GSM_Error (*SetProfile) (GSM_StateMachine *s, GSM_Profile *Profile);
/**
* Reads FM station.
*/
GSM_Error (*GetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation);
/**
* Sets FM station.
*/
GSM_Error (*SetFMStation) (GSM_StateMachine *s, GSM_FMStation *FMStation);
/**
* Clears defined FM stations.
*/
GSM_Error (*ClearFMStations) (GSM_StateMachine *s);
/**
* Gets next filename from filesystem.
*/
GSM_Error (*GetNextFileFolder) (GSM_StateMachine *s, GSM_File *File, bool start);
/**
* Gets file part from filesystem.
*/
GSM_Error (*GetFilePart) (GSM_StateMachine *s, GSM_File *File);
/**
* Adds file part to filesystem.
*/
GSM_Error (*AddFilePart) (GSM_StateMachine *s, GSM_File *File, int *Pos);
/**
* Acquires filesystem status.
*/
GSM_Error (*GetFileSystemStatus)(GSM_StateMachine *s, GSM_FileSystemStatus *Status);
/**
* Deletes file from filessytem.
*/
GSM_Error (*DeleteFile) (GSM_StateMachine *s, unsigned char *ID);
/**
* Adds folder to filesystem.
*/
GSM_Error (*AddFolder) (GSM_StateMachine *s, GSM_File *File);
/**
* Gets GPRS access point.
*/
GSM_Error (*GetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point);
/**
* Sets GPRS access point.
*/
GSM_Error (*SetGPRSAccessPoint) (GSM_StateMachine *s, GSM_GPRSAccessPoint *point);
} GSM_Phone_Functions;
extern GSM_Phone_Functions NAUTOPhone;
#ifdef GSM_ENABLE_NOKIA3320
extern GSM_Phone_Functions N3320Phone;
#endif
#ifdef GSM_ENABLE_NOKIA3650
extern GSM_Phone_Functions N3650Phone;
#endif
#ifdef GSM_ENABLE_NOKIA6110
extern GSM_Phone_Functions N6110Phone;
#endif
+#ifdef GSM_ENABLE_NOKIA650
+ extern GSM_Phone_Functions N650Phone;
+#endif
#ifdef GSM_ENABLE_NOKIA6510
extern GSM_Phone_Functions N6510Phone;
#endif
#ifdef GSM_ENABLE_NOKIA7110
extern GSM_Phone_Functions N7110Phone;
#endif
#ifdef GSM_ENABLE_NOKIA9210
extern GSM_Phone_Functions N9210Phone;
#endif
#ifdef GSM_ENABLE_ATGEN
extern GSM_Phone_Functions ATGENPhone;
#endif
#ifdef GSM_ENABLE_ALCATEL
extern GSM_Phone_Functions ALCATELPhone;
#endif
#ifdef GSM_ENABLE_OBEXGEN
extern GSM_Phone_Functions OBEXGENPhone;
#endif
#ifdef GSM_ENABLE_MROUTERGEN
extern GSM_Phone_Functions MROUTERGENPhone;
#endif
typedef struct {
GSM_Phone_Data Data;
GSM_Phone_Functions *Functions;
} GSM_Phone;
/* --------------------------- User layer ---------------------------------- */
struct _GSM_User {
GSM_Reply_Function *UserReplyFunctions;
@@ -1494,64 +1510,65 @@ typedef enum {
F_POWER_BATT, /* Network and battery level get from netmonitor */
F_PROFILES33, /* Phone profiles in 3310 style */
F_PROFILES51, /* Phone profiles in 5110 style */
F_MAGICBYTES, /* Phone can make authentication with magic bytes */
F_NODTMF, /* Phone can't send DTMF */
F_DISPSTATUS, /* Phone return display status */
F_NOCALLINFO,
/* n3320.c */
F_DAYMONTH, /* Day and month reversed in pbk, when compare to GSM models */
/* n6510.c */
F_PBK35, /* Phonebook in 3510 style with ringtones ID */
F_PBKIMG, /* Phonebook in 7250 style with picture ID */
F_PBKTONEGAL, /* Phonebook with selecting ringtones from gallery */
F_PBKSMSLIST, /* Phonebook with SMS list */
F_PBKUSER, /* Phonebook with user ID */
F_RADIO, /* Phone with FM radio */
F_TODO63, /* ToDo in 6310 style - 0x55 msg type */
F_TODO66, /* ToDo in 6610 style - like calendar, with date and other */
F_NOMIDI, /* No ringtones in MIDI */
F_BLUETOOTH, /* Bluetooth support */
F_NOFILESYSTEM, /* No images, ringtones, java saved in special filesystem */
F_NOMMS, /* No MMS sets in phone */
F_NOGPRSPOINT, /* GPRS point are not useable */
F_CAL35, /* Calendar,3510 style - Reminder,Call,Birthday */
F_CAL65, /* Calendar,6510 style - CBMM, method 3 */
F_WAPMMSPROXY, /* WAP & MMS settings contains first & second proxy */
/* n6510.c && n7110.c */
F_VOICETAGS, /* Voice tags available */
F_CAL62, /* Calendar,6210 style - Call,Birthday,Memo,Meeting */
+ F_NOTES,
/* AT modules */
F_SMSONLYSENT, /* Phone supports only sent/unsent messages */
F_BROKENCPBS, /* CPBS on some memories can hang phone */
F_M20SMS, /* Siemens M20 like SMS handling */
F_SLOWWRITE, /* Use slower writing which some phone need */
F_SMSME900, /* SMS in ME start from location 900 - case of Sagem */
F_ALCATEL /* Phone supports Alcatel protocol */
} Feature;
/* For models table */
struct _OnePhoneModel {
char *model;
char *number;
char *irdamodel;
Feature features[12];
};
bool IsPhoneFeatureAvailable (OnePhoneModel *model, Feature feature);
OnePhoneModel *GetModelData (char *model, char *number, char *irdamodel);
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
int smprintf(GSM_StateMachine *s, const char *format, ...);
void GSM_OSErrorInfo(GSM_StateMachine *s, char *description);
#ifdef GSM_ENABLE_BACKUP
void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info);
#endif
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,50 +1,203 @@
/* (c) 2002-2004 by Marcin Wiacek, Michal Cihar and others */
-/* based on some work from MyGnokii and Gnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
+/* based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <locale.h>
#ifndef __OpenBSD__
# include <wctype.h>
#endif
#ifdef WIN32
# include "windows.h"
#endif
#include "../misc.h"
#include "coding.h"
+/* function changes #10 #13 chars to \n \r */
+char *EncodeUnicodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0;
+ static unsigned char Buf[20000];
+
+ while (buffer[Pos*2]!=0x00 || buffer[Pos*2+1]!=0x00) {
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 10) {
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = 'n';
+ Pos2++;
+ } else if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 13) {
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = 'r';
+ Pos2++;
+ } else if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ Buf[Pos2*2] = 0x00;
+ Buf[Pos2*2+1] = '\\';
+ Pos2++;
+ } else {
+ Buf[Pos2*2] = buffer[Pos*2];
+ Buf[Pos2*2+1] = buffer[Pos*2+1];
+ Pos2++;
+ }
+ Pos++;
+ }
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 0;
+ return Buf;
+}
+
+/* function changes #10 #13 chars to \n \r */
+char *EncodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0;
+ static unsigned char Buf[10000];
+
+ while (buffer[Pos]!=0x00) {
+ switch (buffer[Pos]) {
+ case 10:
+ Buf[Pos2++] = '\\';
+ Buf[Pos2++] = 'n';
+ break;
+ case 13:
+ Buf[Pos2++] = '\\';
+ Buf[Pos2++] = 'r';
+ break;
+ case '\\':
+ Buf[Pos2++] = '\\';
+ Buf[Pos2++] = '\\';
+ break;
+ default:
+ Buf[Pos2++] = buffer[Pos];
+ }
+ Pos++;
+ }
+ Buf[Pos2] = 0;
+ return Buf;
+}
+
+char *DecodeUnicodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0, level=0;
+ static unsigned char Buf[10000];
+
+ while (buffer[Pos*2]!=0x00 || buffer[Pos*2+1]!=0x00) {
+ Buf[Pos2*2] = buffer[Pos*2];
+ Buf[Pos2*2+1] = buffer[Pos*2+1];
+ switch (level) {
+ case 0:
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
+ level = 1;
+ } else {
+ Pos2++;
+ }
+ break;
+ case 1:
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 'n') {
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 10;
+ }
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == 'r') {
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 13;
+ }
+ if (buffer[Pos*2] == 0x00 && buffer[Pos*2+1] == '\\') {
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = '\\';
+ }
+ Pos2++;
+ level = 0;
+ }
+ Pos++;
+ }
+ Buf[Pos2*2] = 0;
+ Buf[Pos2*2+1] = 0;
+ return Buf;
+}
+
+char *DecodeSpecialChars(unsigned char *buffer)
+{
+ int Pos=0, Pos2=0, level=0;
+ static unsigned char Buf[10000];
+
+ while (buffer[Pos]!=0x00) {
+ Buf[Pos2] = buffer[Pos];
+ switch (level) {
+ case 0:
+ if (buffer[Pos] == '\\') {
+ level = 1;
+ } else {
+ Pos2++;
+ }
+ break;
+ case 1:
+ if (buffer[Pos] == 'n') Buf[Pos2] = 10;
+ if (buffer[Pos] == 'r') Buf[Pos2] = 13;
+ if (buffer[Pos] == '\\') Buf[Pos2] = '\\';
+ Pos2++;
+ level = 0;
+ }
+ Pos++;
+ }
+ Buf[Pos2] = 0;
+ return Buf;
+}
+
+char *mystrcasestr(unsigned const char *a, unsigned const char *b)
+{
+ unsigned char A[2000], B[200];
+ int i;
+
+ memset(A,0,sizeof(A));
+ memset(B,0,sizeof(B));
+ for (i=0;i<(int)strlen(a);i++) A[i] = tolower(a[i]);
+ for (i=0;i<(int)strlen(b);i++) B[i] = tolower(b[i]);
+
+ return strstr(A,B);
+}
+
unsigned int UnicodeLength(const unsigned char *str)
{
unsigned int len = 0;
if (str == NULL) return 0;
while(str[len*2] != 0 || str[len*2+1] != 0) len++;
return len;
}
/* Convert Unicode char saved in src to dest */
unsigned int EncodeWithUnicodeAlphabet(const unsigned char *src, wchar_t *dest)
{
char retval;
switch (retval = mbtowc(dest, src, MB_CUR_MAX)) {
case -1 :
case 0 : return 1;
default : return retval;
}
}
/* Convert Unicode char saved in src to dest */
unsigned int DecodeWithUnicodeAlphabet(wchar_t src, unsigned char *dest)
{
int retval;
switch (retval = wctomb(dest, src)) {
case -1:
*dest = '?';
return 1;
@@ -557,133 +710,133 @@ int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *ou
*OUTPUT = Byte >> (7 - Bits);
/* If we don't write at 0th bit of the octet, we should write
a second part of the previous octet */
if (Bits != 7)
*(OUTPUT-1) |= (Byte & ((1 << (7-Bits)) - 1)) << (Bits+1);
Bits--;
if (Bits == -1) Bits = 7; else OUTPUT++;
INPUT++;
}
return (OUTPUT - output);
#else
return 0;
#endif
}
void GSM_UnpackSemiOctetNumber(unsigned char *retval, unsigned char *Number, bool semioctet)
{
unsigned char Buffer[50] = "";
int length = Number[0];
if (semioctet) {
/* Convert number of semioctets to number of chars */
if (length % 2) length++;
length=length / 2 + 1;
}
/*without leading byte with format of number*/
length--;
- switch (Number[1]) {
- case NUMBER_ALPHANUMERIC:
+ switch ((Number[1] & 112)) {
+ case (NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN & 112):
if (length > 6) length++;
dbgprintf("Alphanumeric number, length %i\n",length);
GSM_UnpackEightBitsToSeven(0, length, length, Number+2, Buffer);
Buffer[length]=0;
break;
- case NUMBER_INTERNATIONAL:
+ case (NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN & 112):
dbgprintf("International number\n");
Buffer[0]='+';
DecodeBCD(Buffer+1,Number+2, length);
break;
default:
dbgprintf("Default number %02x\n",Number[1]);
DecodeBCD (Buffer, Number+2, length);
break;
}
EncodeUnicode(retval,Buffer,strlen(Buffer));
}
/**
* Packing some phone numbers (SMSC, SMS destination and others)
*
* See GSM 03.40 9.1.1:
* 1 byte - length of number given in semioctets or bytes (when given in
* bytes, includes one byte for byte with number format).
* Returned by function (set semioctet to true, if want result
* in semioctets).
* 1 byte - format of number (see GSM_NumberType in coding.h). Returned
* in unsigned char *Output.
* n bytes - 2n or 2n-1 semioctets with number. Returned in unsigned char
* *Output.
*
* 1 semioctet = 4 bits = half of byte
*/
int GSM_PackSemiOctetNumber(unsigned char *Number, unsigned char *Output, bool semioctet)
{
unsigned char format, buffer[50];
int length, i;
length=UnicodeLength(Number);
memcpy(buffer,DecodeUnicodeString(Number),length+1);
/* Checking for format number */
- format = NUMBER_UNKNOWN;
+ format = NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN;
for (i=0;i<length;i++) {
/* first byte is '+'. Number can be international */
if (i==0 && buffer[i]=='+') {
- format=NUMBER_INTERNATIONAL;
+ format=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN;
} else {
/*char is not number. It must be alphanumeric*/
- if (!isdigit(buffer[i])) format=NUMBER_ALPHANUMERIC;
+ if (!isdigit(buffer[i])) format=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN;
}
}
/**
* First byte is used for saving type of number. See GSM 03.40
* section 9.1.2.5
*/
Output[0]=format;
/* After number type we will have number. GSM 03.40 section 9.1.2 */
switch (format) {
- case NUMBER_ALPHANUMERIC:
+ case NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN:
length=GSM_PackSevenBitsToEight(0, buffer, Output+1, strlen(buffer))*2;
if (strlen(buffer)==7) length--;
break;
- case NUMBER_INTERNATIONAL:
+ case NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN:
length--;
EncodeBCD (Output+1, buffer+1, length, true);
break;
default:
EncodeBCD (Output+1, buffer, length, true);
break;
}
if (semioctet) return length;
/* Convert number of semioctets to number of chars */
if (length % 2) length++;
return length / 2 + 1;
}
void CopyUnicodeString(unsigned char *Dest, unsigned char *Source)
{
int j = 0;
while (Source[j]!=0x00 || Source[j+1]!=0x00) {
Dest[j] = Source[j];
Dest[j+1] = Source[j+1];
j=j+2;
}
Dest[j] = 0;
Dest[j+1] = 0;
}
/* Changes minor/major order in Unicode string */
void ReverseUnicodeString(unsigned char *String)
{
int j = 0;
@@ -890,85 +1043,85 @@ void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *sr
case 0x00:
switch (src[2*i+1]) {
case 0x01:
dest[current++] = 0x00;
dest[current++] = '~';
break;
case '~':
dest[current++] = 0x00;
dest[current++] = '~';
dest[current++] = 0x00;
dest[current++] = '~';
break;
default:
dest[current++] = src[i*2];
dest[current++] = src[i*2+1];
}
break;
default:
dest[current++] = src[i*2];
dest[current++] = src[i*2+1];
}
}
dest[current++] = 0x00;
dest[current++] = 0x00;
}
bool mystrncasecmp(unsigned const char *a, unsigned const char *b, int num)
{
int i;
if (a == NULL || b == NULL) return false;
- num--;
+ if (num == 0) num = -1;
for (i = 0; i != num; i++) {
if (a[i] == 0x00 && b[i] == 0x00) return true;
if (a[i] == 0x00 || b[i] == 0x00) return false;
if (tolower(a[i]) != tolower(b[i])) return false;
}
return true;
}
/* Compares two Unicode strings without regarding to case.
* Return true, when they're equal
*/
bool mywstrncasecmp(unsigned const char *a, unsigned const char *b, int num)
{
int i;
wchar_t wc,wc2;
if (a == NULL || b == NULL) return false;
- num--;
+ if (num == 0) num = -1;
for (i = 0; i != num; i++) {
if ((a[i*2] == 0x00 && a[i*2+1] == 0x00) && (b[i*2] == 0x00 && b[i*2+1] == 0x00)) return true;
if ((a[i*2] == 0x00 && a[i*2+1] == 0x00) || (b[i*2] == 0x00 && b[i*2+1] == 0x00)) return false;
wc = a[i*2+1] | (a[i*2] << 8);
wc2 = b[i*2+1] | (b[i*2] << 8);
if (mytowlower(wc) != mytowlower(wc2)) return false;
}
return true;
}
/* wcscmp in Mandrake 9.0 is wrong */
bool mywstrncmp(unsigned const char *a, unsigned const char *b, int num)
{
int i=0;
while (1) {
if (a[i*2] != b[i*2] || a[i*2+1] != b[i*2+1]) return false;
if (a[i*2] == 0x00 && a[i*2+1] == 0x00) return true;
i++;
if (num == i) return true;
}
}
/* FreeBSD boxes 4.7-STABLE does't have it, although it's ANSI standard */
bool myiswspace(unsigned const char *src)
{
#ifndef HAVE_ISWSPACE
int o;
unsigned char dest[10];
#endif
wchar_t wc;
@@ -986,65 +1139,65 @@ bool myiswspace(unsigned const char *src)
return iswspace(wc);
#endif
}
/* FreeBSD boxes 4.7-STABLE does't have it, although it's ANSI standard */
int mytowlower(wchar_t c)
{
#ifndef HAVE_TOWLOWER
unsigned char dest[10];
DecodeWithUnicodeAlphabet(c, dest);
return tolower(dest[0]);
#else
return towlower(c);
#endif
}
/*
* Following code is based on wcsstr from the GNU C Library, original
* comment follows:
*/
/*
* The original strstr() file contains the following comment:
*
* My personal strstr() implementation that beats most other algorithms.
* Until someone tells me otherwise, I assume that this is the
* fastest implementation of strstr() in C.
* I deliberately chose not to comment it. You should have at least
* as much fun trying to understand it, as I had to write it :-).
*
* Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
-unsigned char *mystrstr (const unsigned char *haystack, const unsigned char *needle)
+unsigned char *mywstrstr (const unsigned char *haystack, const unsigned char *needle)
{
/* One crazy define to convert unicode used in Gammu to standard wchar_t */
#define tolowerwchar(x) (mytowlower((wchar_t)( (((&(x))[0] & 0xff) << 8) | (((&(x))[1] & 0xff)) )))
register wchar_t b, c;
if ((b = tolowerwchar(*needle)) != L'\0') {
haystack -= 2; /* possible ANSI violation */
do {
haystack += 2;
if ((c = tolowerwchar(*haystack)) == L'\0')
goto ret0;
} while (c != b);
needle += 2;
if ((c = tolowerwchar(*needle)) == L'\0')
goto foundneedle;
needle += 2;
goto jin;
for (;;) {
register wchar_t a;
register const unsigned char *rhaystack, *rneedle;
do {
haystack += 2;
if ((a = tolowerwchar(*haystack)) == L'\0')
goto ret0;
if (a == b)
break;
haystack += 2;
if ((a = tolowerwchar(*haystack)) == L'\0')
goto ret0;
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,133 +1,148 @@
/* (c) 2002-2004 by Marcin Wiacek and others */
#ifndef __coding_h
#define __coding_h
+#if defined(_MSC_VER) && defined(__cplusplus)
+ extern "C" {
+#endif
+
#include <stdlib.h>
#include "../misc.h"
#ifdef __OpenBSD__
typedef int wint_t;
#endif
/* ---------------------------- Unicode ------------------------------------ */
bool mywstrncasecmp (unsigned const char *a, unsigned const char *b, int num);
-unsigned char *mystrstr (unsigned const char *haystack, unsigned const char *needle);
+unsigned char *mywstrstr (unsigned const char *haystack, unsigned const char *needle);
bool mywstrncmp (unsigned const char *a, unsigned const char *b, int num);
bool myiswspace (unsigned const char *src);
int mytowlower (wchar_t c);
unsigned int EncodeWithUnicodeAlphabet (const unsigned char *value, wchar_t *dest);
unsigned int DecodeWithUnicodeAlphabet (wchar_t value, unsigned char *dest);
unsigned int UnicodeLength (const unsigned char *str);
unsigned char *DecodeUnicodeString (const unsigned char *src);
unsigned char *DecodeUnicodeConsole (const unsigned char *src);
void DecodeUnicode (const unsigned char *src, unsigned char *dest);
void EncodeUnicode (unsigned char *dest, const unsigned char *src, int len);
void CopyUnicodeString (unsigned char *Dest, unsigned char *Source);
void ReverseUnicodeString (unsigned char *String);
void ReadUnicodeFile (unsigned char *Dest, unsigned char *Source);
void DecodeUnicodeSpecialNOKIAChars (unsigned char *dest, const unsigned char *src, int len);
void EncodeUnicodeSpecialNOKIAChars (unsigned char *dest, const unsigned char *src, int len);
+char *EncodeUnicodeSpecialChars (unsigned char *buffer);
+char *DecodeUnicodeSpecialChars (unsigned char *buffer);
+
/* ------------------------------- BCD ------------------------------------- */
unsigned char EncodeWithBCDAlphabet (int value);
int DecodeWithBCDAlphabet (unsigned char value);
void DecodeBCD (unsigned char *dest, const unsigned char *src, int len);
void EncodeBCD (unsigned char *dest, const unsigned char *src, int len, bool fill);
/* ------------------------------ UTF7 ------------------------------------- */
void DecodeUTF7 (unsigned char *dest, const unsigned char *src, int len);
/* ------------------------------ UTF8 ------------------------------------- */
wchar_t DecodeWithUTF8Alphabet (unsigned char mychar3, unsigned char mychar4);
bool EncodeWithUTF8Alphabet (unsigned char mychar1, unsigned char mychar2, unsigned char *ret1, unsigned char *ret2);
bool EncodeUTF8QuotedPrintable (unsigned char *dest, const unsigned char *src);
void DecodeUTF8QuotedPrintable (unsigned char *dest, const unsigned char *src, int len);
bool EncodeUTF8 (unsigned char *dest, const unsigned char *src);
void DecodeUTF8 (unsigned char *dest, const unsigned char *src, int len);
/* ------------------------------- BASE64 ---------------------------------- */
void EncodeBASE64 (const unsigned char *Input, unsigned char *Output, int Length);
int DecodeBASE64 (const unsigned char *Input, unsigned char *Output, int Length);
/* ----------------------------- HexBin ------------------------------------ */
void DecodeHexBin (unsigned char *dest, const unsigned char *src, int len);
void EncodeHexBin (unsigned char *dest, const unsigned char *src, int len);
/* ----------------------------- HexUnicode -------------------------------- */
void DecodeHexUnicode (unsigned char *dest, const unsigned char *src, int len);
void EncodeHexUnicode (unsigned char *dest, const unsigned char *src, int len);
/* ---------------------- DefaultAlphabet for SMS -------------------------- */
void EncodeDefault (unsigned char *dest, const unsigned char *src, int *len, bool UseExtensions, unsigned char *ExtraAlphabet);
void DecodeDefault (unsigned char *dest, const unsigned char *src, int len, bool UseExtensions, unsigned char *ExtraAlphabet);
void FindDefaultAlphabetLen (const unsigned char *src, int *srclen, int *smslen, int maxlen);
int GSM_PackSevenBitsToEight (int offset, unsigned char *input, unsigned char *output, int length);
int GSM_UnpackEightBitsToSeven (int offset, int in_length, int out_length,
unsigned char *input, unsigned char *output);
/* ----------------- Phone numbers according to GSM specs ------------------ */
/**
* Enum to handle types of phones numbers like
* specified in GSM 03.40 section 9.1.2.5
*/
typedef enum {
/**
* Unknown number type
*/
- NUMBER_UNKNOWN = 0x81,
+ NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN = 0x81,
/**
* International number (full number with code of country)
*/
- NUMBER_INTERNATIONAL = 0x91,
+ NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN = 0x91,
/**
* Alphanumeric number (with chars too)
*/
- NUMBER_ALPHANUMERIC = 0xD0
+ NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN = 0xD0
/* specification give also other values */
} GSM_NumberType;
void GSM_UnpackSemiOctetNumber (unsigned char *retval, unsigned char *Number, bool semioctet);
int GSM_PackSemiOctetNumber (unsigned char *Number, unsigned char *Output, bool semioctet);
/* ---------------------------- Bits --------------------------------------- */
void BufferAlign (unsigned char *Destination, int *CurrentBit);
void BufferAlignNumber(int *CurrentBit);
void AddBuffer (unsigned char *Destination, int *CurrentBit, unsigned char *Source, int BitsToProcess);
void AddBufferByte(unsigned char *Destination, int *CurrentBit, unsigned char Source, int BitsToProcess);
void GetBuffer (unsigned char *Source, int *CurrentBit, unsigned char *Destination, int BitsToProcess);
void GetBufferInt (unsigned char *Source, int *CurrentBit, int *integer, int BitsToProcess);
void GetBufferI (unsigned char *Source, int *CurrentBit, int *result, int BitsToProcess);
int GetBit (unsigned char *Buffer, int BitNum);
int SetBit (unsigned char *Buffer, int BitNum);
int ClearBit (unsigned char *Buffer, int BitNum);
/* ---------------------------- Other -------------------------------------- */
void StringToDouble (char *text, double *d);
bool mystrncasecmp (unsigned const char *a, unsigned const char *b, int num);
+char *mystrcasestr (unsigned const char *a, unsigned const char *b);
void MyGetLine(unsigned char *Buffer, int *Pos, unsigned char *OutBuffer, int MaxLen);
+char *EncodeSpecialChars(unsigned char *buffer);
+char *DecodeSpecialChars(unsigned char *buffer);
+
+#if defined(_MSC_VER) && defined(__cplusplus)
+ }
+#endif
+
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,33 +1,33 @@
-/* Taken from ReHash (see http://www.reichlsoft.de.vu/) and released
+/* Taken from ReHash (www.reichlsoft.de.vu) and released
* under GPL/LGPL with permission from ReHash author
* Dominik Reichl <dominik.reichl@t-online.de>, Germany
*/
/*
**********************************************************************
** MD5.cpp **
** **
** - Style modified by Tony Ray, January 2001 **
** Added support for randomizing initialization constants **
** - Style modified by Dominik Reichl, April 2003 **
** Optimized code **
** **
** MD5.c **
** RSA Data Security, Inc. MD5 Message Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
**********************************************************************
*/
/*
**********************************************************************
** MD5.h -- Header file for implementation of MD5 **
** RSA Data Security, Inc. MD5 Message Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
** Revised (for MD5): RLR 4/27/91 **
** -- G modified to have y&~z instead of y&z **
** -- FF, GG, HH modified to add in last register done **
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
** -- distinct additive constant for each step **
** -- round 4 added, working mod 7 **
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
@@ -1,45 +1,48 @@
/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
/* Checking used compiler (c) 2002 by Michal Cihar */
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdarg.h>
#include <stdio.h>
#include <locale.h>
#include <sys/timeb.h>
#ifdef WIN32
# include "windows.h"
#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+# include <sys/utsname.h>
+#endif
#include "../gsmstate.h"
#include "misc.h"
/* Based on article in Polish PC-Kurier 8/1998 page 104
* Archive on http://www.pckurier.pl
*/
char *DayOfWeek (int year, int month, int day)
{
int p,q,r,w;
static char DayOfWeekChar[10];
p=(14-month) / 12;
q=month+12*p-2;
r=year-p;
w=(day+(31*q) / 12 + r + r / 4 - r / 100 + r / 400) % 7;
strcpy(DayOfWeekChar,"");
switch (w) {
case 0: strcpy(DayOfWeekChar,"Sun"); break;
case 1: strcpy(DayOfWeekChar,"Mon"); break;
case 2: strcpy(DayOfWeekChar,"Tue"); break;
case 3: strcpy(DayOfWeekChar,"Wed"); break;
case 4: strcpy(DayOfWeekChar,"Thu"); break;
case 5: strcpy(DayOfWeekChar,"Fri"); break;
case 6: strcpy(DayOfWeekChar,"Sat"); break;
}
return DayOfWeekChar;
}
void Fill_GSM_DateTime(GSM_DateTime *Date, time_t timet)
{
struct tm *now;
@@ -202,68 +205,70 @@ char *OSDate (GSM_DateTime dt)
timeptr.tm_sec = dt.Second;
timeptr.tm_wday = w;
#ifdef _BSD_SOURCE
timeptr.tm_zone = NULL;
#endif
#ifdef WIN32
strftime(retval2, 200, "%#x", &timeptr);
#else
strftime(retval2, 200, "%x", &timeptr);
#endif
/* If don't have weekday name, include it */
strftime(retval, 200, "%A", &timeptr);
if (strstr(retval2,retval)==NULL) {
/* Check also for short name */
strftime(retval, 200, "%a", &timeptr);
if (strstr(retval2,retval)==NULL) {
strcat(retval2," (");
strcat(retval2,retval);
strcat(retval2,")");
}
}
#ifdef WIN32
setlocale(LC_ALL, ".ACP");
#endif
return retval2;
}
bool CheckDate(GSM_DateTime *date)
{
- /* FIXME: This could also check if day is correct for selected month */
+ const unsigned int days[]={31,29,31,30,31,30,31,31,30,31,30,31};
+
+ /* FIXME: This could also check for leap years */
return date->Year != 0 &&
date->Month >= 1 && date->Month <= 12 &&
- date->Day >= 1 && date->Day <= 31;
+ date->Day >= 1 && date->Day <= days[date->Month];
}
bool CheckTime(GSM_DateTime *date)
{
return date->Hour <= 23 && date->Hour >= 0 &&
date->Minute <= 59 && date->Minute >= 0 &&
date->Second <= 59 && date->Second >= 0;
}
int GetLine(FILE *File, char *Line, int count)
{
int num;
if (fgets(Line, count, File) != NULL) {
num = strlen(Line) - 1;
while(1) {
if (Line[num] != '\n' && Line[num] != '\r') break;
if (num == 0) break;
Line[num--] = 0;
}
return strlen(Line);
}
return -1;
}
void SplitLines(unsigned char *message, int messagesize, GSM_Lines *lines, unsigned char *whitespaces, int spaceslen, bool eot)
{
int i,number=0,j;
bool whitespace=true, nowwhite;
for (i=0;i<MAX_LINES*2;i++) lines->numbers[i]=0;
@@ -422,64 +427,67 @@ void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int mes
memset(buffer,0x20,sizeof(buffer));
buffer[len*5-1]=0;
for (i = 0; i < messagesize; i++) {
sprintf(buffer+j*4,"%02X",message[i]);
buffer[j*4+2] = 0x20;
if (isprint(message[i]) && message[i]!=0x09) {
if (j != len-1) buffer[j*4+2] = message[i];
buffer[(len-1)*4+j+3] = message[i];
} else {
buffer[(len-1)*4+j+3] = '.';
}
if (j != len-1 && i != messagesize-1) buffer[j*4+3] = '|';
if (j == len-1) {
smfprintf(df, dl, "%s\n", buffer);
memset(buffer,0x20,sizeof(buffer));
buffer[len*5-1]=0;
j = 0;
} else {
j++;
}
}
if (j != 0) smfprintf(df, dl, "%s\n", buffer);
}
char *GetOS(void)
{
#ifdef WIN32
OSVERSIONINFOEX Ver;
bool Extended = true;
#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+ struct utsname Ver;
+#endif
static char Buffer[100] = {0x00};
#ifdef WIN32
memset(&Ver,sizeof(OSVERSIONINFOEX),0);
Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (!GetVersionEx((OSVERSIONINFO *)&Ver)) {
Extended = false;
Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx((OSVERSIONINFO *)&Ver)) {
//#ifdef _MSC_VER
// Ver.dwMajorVersion = _winmajor;
// Ver.dwMinorVersion = _winminor;
// Ver.dwBuildNumber = _osver;
//#else
sprintf(Buffer, "Windows");
return Buffer;
//#endif
}
}
/* ----------------- 9x family ------------------ */
/* no info about Win95 SP1, Win95 OSR2.1, Win95 OSR2.5.... */
if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 950) {
sprintf(Buffer,"Win 95");
} else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 1111) {
sprintf(Buffer,"Win 95 OSR2.x");
/* no info about Win98 SP1.... */
} else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 10 && Ver.dwBuildNumber == 1998) {
sprintf(Buffer,"Win 98");
@@ -491,65 +499,66 @@ char *GetOS(void)
/* ---------------- NT family ------------------- */
} else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 1381) {
sprintf(Buffer,"Win NT 4.0");
} else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 2195) {
sprintf(Buffer,"Win 2000");
} else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 1 && Ver.dwBuildNumber == 2600) {
sprintf(Buffer,"Win XP");
#if _MSC_VER > 1200 //6.0 has it undeclared
if (Extended) {
if (Ver.wSuiteMask & VER_SUITE_PERSONAL) {
sprintf(Buffer+strlen(Buffer)," Home");
} else {
sprintf(Buffer+strlen(Buffer)," Pro");
}
}
#endif
} else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 2) {
sprintf(Buffer,"Win 2003");
} else {
sprintf(Buffer, "Windows %i.%i.%i",Ver.dwMajorVersion,Ver.dwMinorVersion,Ver.dwBuildNumber);
}
if (Extended && Ver.wServicePackMajor != 0) {
sprintf(Buffer+strlen(Buffer)," SP%i",Ver.wServicePackMajor);
}
#elif defined(linux) || defined(__linux) || defined(__linux__)
- sprintf(Buffer, "Linux");
+ uname(&Ver);
+ sprintf(Buffer, "Linux, kernel %s",Ver.release);
#elif defined(__FreeBSD__)
sprintf(Buffer, "FreeBSD");
#elif defined(__NetBSD__)
sprintf(Buffer, "NetBSD");
#elif defined(__OpenBSD__)
sprintf(Buffer, "OpenBSD");
#elif defined(__GNU__)
sprintf(Buffer, "GNU/Hurd");
#elif defined(sun) || defined(__sun) || defined(__sun__)
# ifdef __SVR4
sprintf(Buffer, "Sun Solaris");
# else
sprintf(Buffer, "SunOS");
# endif
#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
sprintf(Buffer, "HP-UX");
#elif defined(ultrix) || defined(__ultrix) || defined(__ultrix__)
sprintf(Buffer, "DEC Ultrix");
#elif defined(sgi) || defined(__sgi)
sprintf(Buffer, "SGI Irix");
#elif defined(__osf__)
sprintf(Buffer, "OSF Unix");
#elif defined(bsdi) || defined(__bsdi__)
sprintf(Buffer, "BSDI Unix");
#elif defined(_AIX)
sprintf(Buffer, "AIX Unix");
#elif defined(_UNIXWARE)
sprintf(Buffer, "SCO Unixware");
#elif defined(DGUX)
sprintf(Buffer, "DG Unix");
#elif defined(__QNX__)
sprintf(Buffer, "QNX");
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,37 +1,41 @@
/* (c) 2002-2004 by Marcin Wiacek */
#ifndef __misc_h
#define __misc_h
+#if defined(_MSC_VER) && defined(__cplusplus)
+ extern "C" {
+#endif
+
#include <stdio.h>
#include <time.h>
#ifdef WIN32
# include <windows.h>
#endif
#include "../config.h"
#ifndef __cplusplus
#ifndef false
# define false 0
#endif
#ifndef true
# define true !0
#endif
#ifndef bool
# define bool char
#endif
#endif /* __cplusplus */
#ifdef WIN32
# define my_sleep(x) ((x)<1000 ? Sleep(1) : Sleep((x)/1000))
#else
# define my_sleep(x) usleep(x)
#endif
#undef MAX
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#undef MIN
#define MIN(a,b) ((a)<(b) ? (a) : (b))
/* ------------------------------------------------------------------------- */
@@ -101,37 +105,41 @@ typedef struct {
* The difference between local time and GMT in hours
*/
int Timezone;
unsigned int Second;
unsigned int Minute;
unsigned int Hour;
unsigned int Day;
/**
* January = 1, February = 2, etc.
*/
unsigned int Month;
/**
* Complete year number. Not 03, but 2003
*/
unsigned int Year;
} GSM_DateTime;
void GSM_GetCurrentDateTime (GSM_DateTime *Date);
char *OSDateTime (GSM_DateTime dt, bool TimeZone);
char *OSDate (GSM_DateTime dt);
char *DayOfWeek (int year, int month, int day);
time_t Fill_Time_T (GSM_DateTime DT, int TZ);
void GetTimeDifference (unsigned long diff, GSM_DateTime *DT, bool Plus, int multi);
void Fill_GSM_DateTime (GSM_DateTime *Date, time_t timet);
bool CheckDate (GSM_DateTime *date);
bool CheckTime (GSM_DateTime *date);
char *GetCompiler(void);
char *GetOS(void);
+#if defined(_MSC_VER) && defined(__cplusplus)
+ }
+#endif
+
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -72,64 +72,65 @@ extern GSM_Error ATGEN_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry);
extern GSM_Error ATGEN_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry);
extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *Status);
extern GSM_Error ATGEN_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc);
extern GSM_Error ATGEN_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc);
extern GSM_Error ATGEN_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders);
extern GSM_Error ATGEN_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status);
extern GSM_Error ATGEN_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms);
extern GSM_Error ATGEN_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start);
extern GSM_Error ATGEN_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location);
extern GSM_Error ATGEN_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms);
extern GSM_Error ATGEN_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms);
extern GSM_Error ATGEN_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms);
extern GSM_Error ATGEN_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat);
extern GSM_Error ATGEN_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig);
extern GSM_Error ATGEN_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber);
extern GSM_Error ATGEN_AnswerCall (GSM_StateMachine *s, int ID, bool all);
extern GSM_Error ATGEN_CancelCall (GSM_StateMachine *s, int ID, bool all);
extern GSM_Error ATGEN_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time);
extern GSM_Error ATGEN_EnterSecurityCode (GSM_StateMachine *s, GSM_SecurityCode Code);
extern GSM_Error ATGEN_GetSecurityStatus (GSM_StateMachine *s, GSM_SecurityCodeType *Status);
extern GSM_Error ATGEN_ResetPhoneSettings (GSM_StateMachine *s, GSM_ResetSettingsType Type);
extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence);
extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI);
extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s);
extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo);
extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard);
extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press);
extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features);
extern GSM_Error ATGEN_SetAutoNetworkLogin (GSM_StateMachine *s);
extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type);
extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
+extern GSM_Error ATGEN_SetFastSMSSending (GSM_StateMachine *s, bool enable);
extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable);
extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable);
/**
* Alcatel uses some 8-bit characters in contacts, calendar etc.. This table
* attempts to decode it, it is probably not complete, here are just chars
* that I found...
*/
unsigned char GSM_AlcatelAlphabet[] =
{
/* in phone unicode description */
0x80, 0x00,0x20, /* empty */
0x81, 0x00,0x20, /* empty */
0x82, 0x00,0x20, /* empty */
0x83, 0x00,0x20, /* empty */
0x84, 0x00,0xe7, /* c cedilla */
0x85, 0x20,0x26, /* ... */
0x86, 0x03,0xc0, /* pi */
0x87, 0x01,0x3e, /* l caron */
0x88, 0x00,0xc0, /* A grave */
0x89, 0x00,0xc1, /* A acute */
0x8a, 0x00,0xc2, /* A circumflex */
0x8b, 0x00,0xc3, /* A tilde */
0x8c, 0x00,0xc8, /* E grave */
0x8d, 0x00,0xca, /* E circumflex */
0x8e, 0x00,0xcb, /* E diaresis */
0x8f, 0x00,0xcc, /* I grave */
0x90, 0x00,0xcd, /* I acute */
0x91, 0x00,0xd0, /* ETH */
0x92, 0x00,0xd2, /* O grave */
0x93, 0x00,0xd3, /* O acute */
@@ -515,64 +516,66 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary
error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2);
if (error != ERR_NONE) return error;
Priv->BinaryState = StateSession;
Priv->BinaryType = type;
/* Do we want to edit something of same type? */
if ((state == StateEdit) && (type == Priv->BinaryType)) {
Priv->BinaryState = StateEdit;
Priv->BinaryItem = item;
return ERR_NONE;
}
}
return ERR_NONE;
}
static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s)
{
GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
GSM_Error error;
if (Priv->Mode == ModeAT) return ERR_NONE;
error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0);
if (error != ERR_NONE) return error;
error = s->Protocol.Functions->Terminate(s);
if (error != ERR_NONE) return error;
dbgprintf ("Changing protocol to AT\n");
s->Protocol.Functions = &ATProtocol;
s->Phone.Functions->ReplyFunctions = ATGENReplyFunctions;
Priv->Mode = ModeAT;
+ s->Phone.Data.Priv.ATGEN.PBKCharset = 0;
+ s->Phone.Data.Priv.ATGEN.PBKMemory = 0;
my_sleep(100);
/* In case we don't send AT command short after closing binary mode,
* phone takes VERY long to react next time. The error code in
* intetionally ignored.
*/
GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame);
return ERR_NONE;
}
static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s)
{
GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL;
GSM_Error error;
Priv->Mode = ModeAT;
Priv->CalendarItems = NULL;
Priv->ContactsItems = NULL;
Priv->ToDoItems = NULL;
Priv->CalendarItemsCount = 0;
Priv->ToDoItemsCount = 0;
Priv->ContactsItemsCount = 0;
Priv->CurrentFields[0] = 0;
Priv->CurrentFieldsCount = 0;
Priv->CurrentFieldsItem = 0;
Priv->CurrentFieldsType = 0;
Priv->ProtocolVersion = V_1_0;
Priv->CurrentFieldsItem = -1;
@@ -3793,64 +3796,72 @@ static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine
return ERR_NONE;
case 0x82: /* Transfer canceled */
return ERR_CANCELED;
default:
smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]);
return ERR_NONE;
}
}
static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24);
smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord);
return ERR_NONE;
}
static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable)
{
GSM_Error error;
if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
return ATGEN_SetIncomingCB(s, enable);
}
static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable)
{
GSM_Error error;
if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
return ATGEN_SetIncomingSMS(s, enable);
}
+static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable)
+{
+ GSM_Error error;
+
+ if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error;
+ return ATGEN_SetFastSMSSending(s, enable);
+}
+
static GSM_Reply_Function ALCATELReplyFunctions[] = {
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit },
{ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 },
{ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1 },
{ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1 },
{ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1 },
{ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 },
{ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1 },
{ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 },
{ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField },
{ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField },
{NULL, "\x00",0x00,0x00, ID_None }
};
@@ -3884,108 +3895,109 @@ GSM_Phone_Functions ALCATELPhone = {
ALCATEL_PressKey,
ALCATEL_Reset,
ALCATEL_ResetPhoneSettings,
ALCATEL_EnterSecurityCode,
ALCATEL_GetSecurityStatus,
ALCATEL_GetDisplayStatus,
ALCATEL_SetAutoNetworkLogin,
ALCATEL_GetBatteryCharge,
ALCATEL_GetSignalStrength,
ALCATEL_GetNetworkInfo,
ALCATEL_GetCategory,
ALCATEL_AddCategory,
ALCATEL_GetCategoryStatus,
ALCATEL_GetMemoryStatus,
ALCATEL_GetMemory,
ALCATEL_GetNextMemory,
ALCATEL_SetMemory,
ALCATEL_AddMemory,
ALCATEL_DeleteMemory,
ALCATEL_DeleteAllMemory,
NOTSUPPORTED, /* GetSpeedDial */
NOTSUPPORTED, /* SetSpeedDial */
ALCATEL_GetSMSC,
ALCATEL_SetSMSC,
ALCATEL_GetSMSStatus,
ALCATEL_GetSMS,
ALCATEL_GetNextSMS,
NOTSUPPORTED, /* SetSMS */
ALCATEL_AddSMS,
ALCATEL_DeleteSMS,
ALCATEL_SendSMS,
ALCATEL_SendSavedSMS,
+ ALCATEL_SetFastSMSSending,
ALCATEL_SetIncomingSMS,
ALCATEL_SetIncomingCB,
ALCATEL_GetSMSFolders,
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
ALCATEL_DialVoice,
ALCATEL_AnswerCall,
ALCATEL_CancelCall,
NOTSUPPORTED, /* HoldCall */
NOTSUPPORTED, /* UnholdCall */
NOTSUPPORTED, /* ConferenceCall */
NOTSUPPORTED, /* SplitCall */
NOTSUPPORTED, /* TransferCall */
NOTSUPPORTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NONEFUNCTION, /* SetIncomingCall */
NOTSUPPORTED, /* SetIncomingUSSD */
ALCATEL_SendDTMF,
NOTSUPPORTED, /* GetRingtone */
NOTSUPPORTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
NOTSUPPORTED, /* GetBitmap */
NOTSUPPORTED, /* SetBitmap */
ALCATEL_GetToDoStatus,
ALCATEL_GetToDo,
ALCATEL_GetNextToDo,
ALCATEL_SetToDo,
ALCATEL_AddToDo,
ALCATEL_DeleteToDo,
ALCATEL_DeleteAllToDo,
ALCATEL_GetCalendarStatus,
ALCATEL_GetCalendar,
ALCATEL_GetNextCalendar,
ALCATEL_SetCalendar,
ALCATEL_AddCalendar,
ALCATEL_DeleteCalendar,
ALCATEL_DeleteAllCalendar,
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFilePart */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -1,77 +1,57 @@
/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_ATGEN
#include <string.h>
#include <time.h>
#include <ctype.h>
#include "../../gsmcomon.h"
#include "../../misc/coding/coding.h"
#include "../../service/sms/gsmsms.h"
#include "../pfunc.h"
+
#include "atgen.h"
+#include "samsung.h"
+#include "siemens.h"
+#include "sonyeric.h"
+
#ifdef GSM_ENABLE_ALCATEL
-extern GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message msg, GSM_StateMachine *s);
+GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message, GSM_StateMachine *);
#endif
-extern GSM_Error ATGEN_CMS35ReplyGetBitmap (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplySetBitmap (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplyGetRingtone (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplySetRingtone (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplyGetNextCal (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplySetCalendar (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_CMS35ReplyDeleteCalendar (GSM_Protocol_Message msg, GSM_StateMachine *s);
-extern GSM_Error ATGEN_SL45ReplyGetMemory (GSM_Protocol_Message msg, GSM_StateMachine *s);
-
-extern GSM_Error ATGEN_GetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone);
-extern GSM_Error ATGEN_SetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength);
-extern GSM_Error ATGEN_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
-extern GSM_Error ATGEN_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
-extern GSM_Error SIEMENS_GetNextCalendar (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
-extern GSM_Error SIEMENS_AddCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-extern GSM_Error SIEMENS_DelCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-
-extern GSM_Error SONYERIC_GetNextCalendar (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
-extern GSM_Error SONYERIC_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start);
-extern GSM_Error SONYERIC_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status);
-extern GSM_Error SONYERIC_AddCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-extern GSM_Error SONYERIC_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
-extern GSM_Error SONYERIC_DeleteAllToDo (GSM_StateMachine *s);
-extern GSM_Error SONYERIC_DelCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note);
-extern GSM_Error SONYERIC_GetCalendarStatus (GSM_StateMachine *s, GSM_CalendarStatus *Status);
typedef struct {
int Number;
char Text[60];
} ATErrorCode;
static ATErrorCode CMSErrorCodes[] = {
/*
* Error codes not specified here were either undefined or reserved in my
* copy of specifications, if you have newer one, please fill in the gaps.
*/
/* 0...127 from GSM 04.11 Annex E-2 */
{1, "Unassigned (unallocated) number"},
{8, "Operator determined barring"},
{10, "Call barred"},
{21, "Short message transfer rejected"},
{27, "Destination out of service"},
{28, "Unidentified subscriber"},
{29, "Facility rejected"},
{30, "Unknown subscriber"},
{38, "Network out of order"},
{41, "Temporary failure"},
{42, "Congestion"},
{47, "Resources unavailable, unspecified"},
{50, "Requested facility not subscribed"},
{69, "Requested facility not implemented"},
{81, "Invalid short message transfer reference value"},
{95, "Invalid message, unspecified"},
{96, "Invalid mandatory information"},
{97, "Message type non-existent or not implemented"},
{98, "Message not compatible with short message protocol state"},
{99, "Information element non-existent or not implemented"},
@@ -146,64 +126,66 @@ static ATErrorCode CMEErrorCodes[] = {
{14, "SIM busy"},
{15, "SIM wrong"},
{16, "incorrect password"},
{17, "SIM PIN2 required"},
{18, "SIM PUK2 required"},
{20, "memory full"},
{21, "invalid index"},
{22, "not found"},
{23, "memory failure"},
{24, "text string too long"},
{25, "invalid characters in text string"},
{26, "dial string too long"},
{27, "invalid characters in dial string"},
{30, "no network service"},
{31, "network timeout"},
{100, "unknown"},
};
GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->ErrorCode == 0) {
smprintf(s, "CME Error occured, but it's type not detected\n");
} else if (Priv->ErrorText == NULL) {
smprintf(s, "CME Error %i, no description available\n", Priv->ErrorCode);
} else {
smprintf(s, "CME Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText);
}
/* For error codes descriptions see table a bit above */
switch (Priv->ErrorCode) {
+ case -1:
+ return ERR_EMPTY;
case 3:
return ERR_PERMISSION;
case 4:
return ERR_NOTSUPPORTED;
case 5:
case 11:
case 12:
case 16:
case 17:
case 18:
return ERR_SECURITYERROR;
case 20:
return ERR_FULL;
case 21:
return ERR_INVALIDLOCATION;
case 22:
return ERR_EMPTY;
case 23:
return ERR_MEMORY;
case 24:
case 25:
case 26:
case 27:
return ERR_INVALIDDATA;
default:
return ERR_UNKNOWN;
}
}
GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
@@ -227,206 +209,264 @@ GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s)
case 317:
case 318:
return ERR_SECURITYERROR;
case 322:
return ERR_FULL;
case 321:
return ERR_INVALIDLOCATION;
default:
return ERR_UNKNOWN;
}
}
/* FIXME: Function doesn't respect quoting of parameters and thus +FOO:
* "ab","cd,ef" will consider as three arguments: "ab" >> "cd >> ef"
*/
int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output)
{
int position=0;
while (*input!=',' && *input!=0x0d && *input!=0x00) {
*output=*input;
input ++;
output ++;
position++;
}
*output=0;
position++;
return position;
}
void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input)
{
- dt->Year=2000+(*input-'0')*10; input++;
+ /* Samsung phones report year as %d instead of %02d */
+ if (input[2] == '/') {
+ dt->Year=(*input-'0')*10;
+ input++;
+ } else {
+ dt->Year=0;
+ }
+
dt->Year=dt->Year+(*input-'0'); input++;
+ dt->Year+=2000;
input++;
dt->Month=(*input-'0')*10; input++;
dt->Month=dt->Month+(*input-'0'); input++;
input++;
dt->Day=(*input-'0')*10; input++;
dt->Day=dt->Day+(*input-'0'); input++;
input++;
dt->Hour=(*input-'0')*10; input++;
dt->Hour=dt->Hour+(*input-'0'); input++;
input++;
dt->Minute=(*input-'0')*10; input++;
dt->Minute=dt->Minute+(*input-'0');input++;
input++;
dt->Second=(*input-'0')*10; input++;
dt->Second=dt->Second+(*input-'0');input++;
if (input!=NULL) {
input++;
dt->Timezone=(*input-'0')*10; input++;
dt->Timezone=dt->Timezone+(*input-'0');input++;
input=input-2;
if (*input=='-') dt->Timezone=-dt->Timezone;
}
}
GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg;
int i = 0, j, k;
char *err, *line;
ATErrorCode *ErrorCodes = NULL;
SplitLines(msg->Buffer, msg->Length, &Priv->Lines, "\x0D\x0A", 2, true);
/* Find number of lines */
while (Priv->Lines.numbers[i*2+1] != 0) {
/* FIXME: handle special chars correctly */
smprintf(s, "%i \"%s\"\n",i+1,GetLineString(msg->Buffer,Priv->Lines,i+1));
i++;
}
Priv->ReplyState = AT_Reply_Unknown;
Priv->ErrorText = NULL;
Priv->ErrorCode = 0;
line = GetLineString(msg->Buffer,Priv->Lines,i);
if (!strcmp(line,"OK")) Priv->ReplyState = AT_Reply_OK;
if (!strcmp(line,"> ")) Priv->ReplyState = AT_Reply_SMSEdit;
if (!strcmp(line,"CONNECT")) Priv->ReplyState = AT_Reply_Connect;
if (!strcmp(line,"ERROR" )) Priv->ReplyState = AT_Reply_Error;
if (!strncmp(line,"+CME ERROR:",11)) {
Priv->ReplyState = AT_Reply_CMEError;
ErrorCodes = CMEErrorCodes;
}
if (!strncmp(line,"+CMS ERROR:",11)) {
Priv->ReplyState = AT_Reply_CMSError;
ErrorCodes = CMSErrorCodes;
}
+
+ /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */
+ if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) {
+ err = line + 11;
+ Priv->ErrorCode = atoi(err);
+
+ if (Priv->ErrorCode == -1) {
+ Priv->ErrorText = "[Samsung] Empty location";
+ return GSM_DispatchMessage(s);
+ }
+ }
+
if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) {
j = 0;
/* One char behind +CM[SE] ERROR */
err = line + 12;
while (err[j] && !isalnum(err[j])) j++;
if (isdigit(err[j])) {
Priv->ErrorCode = atoi(&(err[j]));
k = 0;
while (ErrorCodes[k].Number != -1) {
if (ErrorCodes[k].Number == Priv->ErrorCode) {
Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
break;
}
k++;
}
} else if (isalpha(err[j])) {
k = 0;
while (ErrorCodes[k].Number != -1) {
if (!strncmp(err + j, ErrorCodes[k].Text, strlen(ErrorCodes[k].Text))) {
Priv->ErrorCode = ErrorCodes[k].Number;
Priv->ErrorText = (char *)&(ErrorCodes[k].Text);
break;
}
k++;
}
}
}
return GSM_DispatchMessage(s);
}
GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
case AT_Reply_OK:
case AT_Reply_Connect:
return ERR_NONE;
case AT_Reply_Error:
return ERR_UNKNOWN;
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
case AT_Reply_CMEError:
return ATGEN_HandleCMEError(s);
default:
break;
}
return ERR_UNKNOWNRESPONSE;
}
+GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned char buffer[2000],buffer2[4000];
+ int i = 10;
+
+ /* Ugly hack */
+ while (msg.Buffer[i]!=13) i++;
+ i = i - 6;
+ memcpy(buffer,msg.Buffer+10,i-11);
+ buffer[i-11] = 0x00;
+
+ smprintf(s, "USSD reply: \"%s\"\n",buffer);
+
+ if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
+ EncodeUnicode(buffer2,buffer,strlen(buffer));
+ s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
+ }
+
+ return ERR_NONE;
+}
+
+GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
+{
+ GSM_Error error;
+
+ if (enable) {
+ smprintf(s, "Enabling incoming USSD\n");
+ error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD);
+ } else {
+ smprintf(s, "Disabling incoming USSD\n");
+ error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD);
+ }
+ if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable;
+ return error;
+}
+
GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Phone_Data *Data = &s->Phone.Data;
if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED;
if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) {
CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2);
/* Sometimes phone adds this before manufacturer (Sagem) */
if (strncmp("+CGMM: ", Data->Model, 7) == 0) {
memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1);
}
Data->ModelInfo = GetModelData(NULL,Data->Model,NULL);
if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model);
if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL);
if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number);
if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia;
else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens;
else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens;
+ else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens;
else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP;
if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20");
else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35");
+ else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35");
else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ");
} else {
smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2)));
}
return ERR_NONE;
}
GSM_Error ATGEN_GetModel(GSM_StateMachine *s)
{
GSM_Error error;
if (s->Phone.Data.Model[0] != 0) return ERR_NONE;
smprintf(s, "Getting model\n");
error=GSM_WaitFor (s, "AT+CGMM\r", 8, 0x00, 3, ID_GetModel);
if (error==ERR_NONE) {
if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL ||
s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) {
smprintf(s, "[Connected model - \"%s\"]\n",s->Phone.Data.Model);
}
}
return error;
}
GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
switch (Priv->ReplyState) {
case AT_Reply_OK:
smprintf(s, "Manufacturer info received\n");
@@ -452,64 +492,69 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine
}
}
if (strstr(msg.Buffer,"Nokia")) {
smprintf(s, "Nokia\n");
strcpy(s->Phone.Data.Manufacturer,"Nokia");
Priv->Manufacturer = AT_Nokia;
}
if (strstr(msg.Buffer,"SIEMENS")) {
smprintf(s, "Siemens\n");
strcpy(s->Phone.Data.Manufacturer,"Siemens");
Priv->Manufacturer = AT_Siemens;
}
if (strstr(msg.Buffer,"ERICSSON")) {
smprintf(s, "Ericsson\n");
strcpy(s->Phone.Data.Manufacturer,"Ericsson");
Priv->Manufacturer = AT_Ericsson;
}
if (strstr(msg.Buffer,"iPAQ")) {
smprintf(s, "iPAQ\n");
strcpy(s->Phone.Data.Manufacturer,"HP");
Priv->Manufacturer = AT_HP;
}
if (strstr(msg.Buffer,"ALCATEL")) {
smprintf(s, "Alcatel\n");
strcpy(s->Phone.Data.Manufacturer,"Alcatel");
Priv->Manufacturer = AT_Alcatel;
}
if (strstr(msg.Buffer,"SAGEM")) {
smprintf(s, "Sagem\n");
strcpy(s->Phone.Data.Manufacturer,"Sagem");
Priv->Manufacturer = AT_Sagem;
}
+ if (strstr(msg.Buffer,"Samsung")) {
+ smprintf(s, "Samsung\n");
+ strcpy(s->Phone.Data.Manufacturer,"Samsung");
+ Priv->Manufacturer = AT_Samsung;
+ }
return ERR_NONE;
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
default:
break;
}
return ERR_UNKNOWNRESPONSE;
}
GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s)
{
if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE;
return GSM_WaitFor (s, "AT+CGMI\r", 8, 0x00, 4, ID_GetManufacturer);
}
GSM_Error ATGEN_ReplyGetFirmwareCGMR(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned int i = 0;
strcpy(s->Phone.Data.Version,"unknown");
s->Phone.Data.VerNum = 0;
if (Priv->ReplyState == AT_Reply_OK) {
CopyLineString(s->Phone.Data.Version, msg.Buffer, Priv->Lines, 2);
/* Sometimes phone adds this before manufacturer (Sagem) */
if (strncmp("+CGMR: ", s->Phone.Data.Version, 7) == 0) {
memmove(s->Phone.Data.Version, s->Phone.Data.Version + 7, strlen(s->Phone.Data.Version + 7) + 1);
}
}
if (Priv->Manufacturer == AT_Ericsson) {
while (1) {
@@ -645,74 +690,84 @@ GSM_Error ATGEN_Initialise(GSM_StateMachine *s)
}
return error;
}
GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
{
unsigned char req[50];
if (smsc->Location!=1) return ERR_NOTSUPPORTED;
sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number));
smprintf(s, "Setting SMSC\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC);
}
GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
case AT_Reply_OK:
/* Reply here is:
* (memories for reading)[, (memories for writing)[, (memories for storing received messages)]]
* each memory is in quotes,
* Example: ("SM"), ("SM"), ("SM")
*
* We need to get from this supported memories. For this case
* we assume, that just appearence of memory makes it
* available for everything. Then we need to find out whether
* phone supports writing to memory. This is done by searching
* for "), (", which will appear between lists.
*/
- s->Phone.Data.Priv.ATGEN.CanSaveSMS = (strstr(msg.Buffer, "), (") != NULL);
+ s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
+ if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
+ s->Phone.Data.Priv.ATGEN.CanSaveSMS = true;
+ }
+
if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE;
else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE;
+
if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE;
else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE;
- smprintf(s, "Available SMS memories received, ME = %d, SM = %d\n", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
+
+ smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
+ if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true");
+ smprintf(s, "\n");
return ERR_NONE;
case AT_Reply_Error:
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
default:
return ERR_UNKNOWNRESPONSE;
}
}
GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s)
{
smprintf(s, "Getting available SMS memories\n");
return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories);
}
GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
char req[] = "AT+CPMS=\"XX\",\"XX\"\r";
int reqlen = 18;
GSM_Error error;
if ((SIM && Priv->SIMSMSMemory == 0) || (!SIM && Priv->PhoneSMSMemory == 0)) {
/* We silently ignore error here, because when this fails, we can try to setmemory anyway */
ATGEN_GetSMSMemories(s);
}
/* If phone can not save SMS, don't try to set memory for saving */
if (!Priv->CanSaveSMS) {
req[12] = '\r';
reqlen = 13;
}
if (SIM) {
if (Priv->SMSMemory == MEM_SM) return ERR_NONE;
if (Priv->SIMSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED;
@@ -829,156 +884,157 @@ void ATGEN_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned cha
folderid,location,sms->Folder,sms->Location);
}
GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_SMSMessage *sms = &s->Phone.Data.GetSMSMessage->SMS[0];
int current = 0, current2, i;
unsigned char buffer[300],smsframe[800];
unsigned char firstbyte, TPDCS, TPUDL, TPStatus;
GSM_Error error;
switch (Priv->ReplyState) {
case AT_Reply_OK:
if (Priv->Lines.numbers[4] == 0x00) return ERR_EMPTY;
s->Phone.Data.GetSMSMessage->Number = 1;
s->Phone.Data.GetSMSMessage->SMS[0].Name[0] = 0;
s->Phone.Data.GetSMSMessage->SMS[0].Name[1] = 0;
switch (Priv->SMSMode) {
case SMS_AT_PDU:
CopyLineString(buffer, msg.Buffer, Priv->Lines, 2);
switch (buffer[7]) {
case '0': sms->State = SMS_UnRead; break;
case '1': sms->State = SMS_Read; break;
case '2': sms->State = SMS_UnSent; break;
default : sms->State = SMS_Sent; break;//case '3'
}
DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3)));
/* Siemens MC35 (only ?) */
if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY;
/* Siemens M20 */
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
- if (buffer[1]!=NUMBER_UNKNOWN && buffer[1]!=NUMBER_INTERNATIONAL &&
- buffer[1]!=NUMBER_ALPHANUMERIC) {
+ /* we check for the most often visible */
+ if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN &&
+ buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
/* Seems to be Delivery Report */
smprintf(s, "SMS type - status report (M20 style)\n");
sms->PDU = SMS_Status_Report;
sms->Folder = 1; /*INBOX SIM*/
sms->InboxFolder = true;
smsframe[12]=buffer[current++];
smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++];
current2=((buffer[current])+1)/2+1;
for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
smsframe[0] = 0;
for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
return ERR_NONE;
}
}
/* We use locations from SMS layouts like in ../phone2.c(h) */
for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++];
smsframe[12]=buffer[current++];
/* See GSM 03.40 section 9.2.3.1 */
switch (smsframe[12] & 0x03) {
case 0x00:
smprintf(s, "SMS type - deliver\n");
sms->PDU = SMS_Deliver;
if (Priv->SMSMemory == MEM_SM) {
sms->Folder = 1; /*INBOX SIM*/
} else {
sms->Folder = 3; /*INBOX ME*/
}
sms->InboxFolder = true;
current2=((buffer[current])+1)/2+1;
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
- if (buffer[current+1]==NUMBER_ALPHANUMERIC) {
+ if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
smprintf(s, "Trying to read alphanumeric number\n");
for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
current+=6;
for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++];
} else {
for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
}
} else {
for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
}
smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++];
smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++];
for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++];
smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++];
for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++];
GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSDeliver);
return ERR_NONE;
case 0x01:
smprintf(s, "SMS type - submit\n");
sms->PDU = SMS_Submit;
if (Priv->SMSMemory == MEM_SM) {
sms->Folder = 2; /*OUTBOX SIM*/
smprintf(s, "Outbox SIM\n");
} else {
sms->Folder = 4; /*OUTBOX ME*/
}
sms->InboxFolder = false;
smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++];
current2=((buffer[current])+1)/2+1;
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
- if (buffer[current+1]==NUMBER_ALPHANUMERIC) {
+ if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
smprintf(s, "Trying to read alphanumeric number\n");
for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
current+=6;
for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++];
} else {
for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
}
} else {
for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
}
smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++];
smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++];
/* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */
if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now
smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++];
for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++];
GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit);
return ERR_NONE;
case 0x02:
smprintf(s, "SMS type - status report\n");
sms->PDU = SMS_Status_Report;
sms->Folder = 1; /*INBOX SIM*/
sms->InboxFolder = true;
- smprintf(s, "TPMR is %02x\n",buffer[current]);
+ smprintf(s, "TPMR is %d\n",buffer[current]);
smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++];
current2=((buffer[current])+1)/2+1;
for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++];
for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++];
for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++];
smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current];
GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport);
return ERR_NONE;
}
break;
case SMS_AT_TXT:
current = 0;
while (msg.Buffer[current]!='"') current++;
current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
if (!strcmp(buffer,"\"0\"") || !strcmp(buffer,"\"REC UNREAD\"")) {
smprintf(s, "SMS type - deliver\n");
sms->State = SMS_UnRead;
sms->PDU = SMS_Deliver;
if (Priv->SMSMemory == MEM_SM) {
sms->Folder = 1; /*INBOX SIM*/
} else {
sms->Folder = 3; /*INBOX ME*/
}
sms->InboxFolder = true;
} else if (!strcmp(buffer,"\"1\"") || !strcmp(buffer,"\"REC READ\"")) {
smprintf(s, "SMS type - deliver\n");
sms->State = SMS_Read;
sms->PDU = SMS_Deliver;
if (Priv->SMSMemory == MEM_SM) {
sms->Folder = 1; /*INBOX SIM*/
} else {
sms->Folder = 3; /*INBOX ME*/
@@ -1611,75 +1667,75 @@ GSM_Error ATGEN_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00);
if (error!=ERR_NONE) return error;
error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4);
if (error != ERR_TIMEOUT) return error;
} else {
smprintf(s, "Escaping SMS mode\n");
error2 = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00);
if (error2 != ERR_NONE) return error2;
return error;
}
}
return Phone->DispatchError;
}
GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
char *start;
if (s->Protocol.Data.AT.EditMode) {
if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_SMSEdit) {
return ERR_UNKNOWN;
}
s->Protocol.Data.AT.EditMode = false;
return ERR_NONE;
}
switch (Priv->ReplyState) {
case AT_Reply_OK:
smprintf(s, "SMS sent OK\n");
if (s->User.SendSMSStatus!=NULL) {
- start = strstr(msg.Buffer, "+CMGW: ");
+ start = strstr(msg.Buffer, "+CMGS: ");
if (start != NULL) {
s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7));
} else {
- s->User.SendSMSStatus(s->CurrentConfig->Device,0,0);
+ s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1);
}
}
return ERR_NONE;
case AT_Reply_CMSError:
smprintf(s, "Error %i\n",Priv->ErrorCode);
- if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,0);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,-1);
return ATGEN_HandleCMSError(s);
case AT_Reply_Error:
return ERR_UNKNOWN;
default:
return ERR_UNKNOWNRESPONSE;
}
}
GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
GSM_Error error,error2;
int current, current2, Replies;
unsigned char buffer[1000], hexreq[1000];
GSM_Phone_Data *Phone = &s->Phone.Data;
if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit;
error = ATGEN_MakeSMSFrame(s, sms, hexreq, &current, &current2);
if (error != ERR_NONE) return error;
switch (Phone->Priv.ATGEN.SMSMode) {
case SMS_AT_PDU:
sprintf(buffer, "AT+CMGS=%i\r",current);
break;
case SMS_AT_TXT:
sprintf(buffer, "AT+CMGS=\"%s\"\r",DecodeUnicodeString(sms->Number));
}
s->Protocol.Data.AT.EditMode = true;
Replies = s->ReplyNum;
s->ReplyNum = 1;
smprintf(s,"Waiting for modem prompt\n");
@@ -1758,64 +1814,77 @@ GSM_Error ATGEN_ReplyGetDateTime_Alarm(GSM_Protocol_Message msg, GSM_StateMachin
GSM_Error ATGEN_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
{
s->Phone.Data.DateTime=date_time;
smprintf(s, "Getting date & time\n");
return GSM_WaitFor (s, "AT+CCLK?\r", 9, 0x00, 4, ID_GetDateTime);
}
GSM_Error ATGEN_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
{
char req[128];
sprintf(req, "AT+CCLK=\"%02i/%02i/%02i,%02i:%02i:%02i+00\"\r",
date_time->Year-2000,date_time->Month,date_time->Day,
date_time->Hour,date_time->Minute,date_time->Second);
smprintf(s, "Setting date & time\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetDateTime);
}
GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
{
if (alarm->Location != 1) return ERR_NOTSUPPORTED;
alarm->Repeating = true;
alarm->Text[0] = 0; alarm->Text[1] = 0;
s->Phone.Data.Alarm = alarm;
smprintf(s, "Getting alarm\n");
return GSM_WaitFor (s, "AT+CALA?\r", 9, 0x00, 4, ID_GetAlarm);
}
+/* R320 only takes HH:MM. Do other phones understand full date? */
+GSM_Error ATGEN_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
+{
+ char req[20];
+
+ if (alarm->Location != 1) return ERR_INVALIDLOCATION;
+
+ sprintf(req, "AT+CALA=\"%02i:%02i\"\r",alarm->DateTime.Hour,alarm->DateTime.Minute);
+
+ smprintf(s, "Setting Alarm\n");
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetAlarm);
+}
+
GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_SMSC *SMSC = s->Phone.Data.SMSC;
int current;
int len;
unsigned char buffer[100];
switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
case AT_Reply_OK:
smprintf(s, "SMSC info received\n");
current = 0;
while (msg.Buffer[current]!='"') current++;
/* SMSC number */
/* FIXME: support for all formats */
current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer);
/*
* Some phones return this as unicode encoded when they are
* switched to UCS2 mode, so we try to solve this correctly.
*/
len = strlen(buffer + 1) - 1;
buffer[len + 1] = 0;
if ((len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) {
/* This is probably unicode encoded number */
DecodeHexUnicode(SMSC->Number,buffer + 1,len);
} else {
EncodeUnicode(SMSC->Number,buffer + 1,len);
}
smprintf(s, "Number: \"%s\"\n",DecodeUnicodeString(SMSC->Number));
/* Format of SMSC number */
@@ -2173,64 +2242,66 @@ GSM_Error ATGEN_ReplyGetCPBRMemoryStatus(GSM_Protocol_Message msg, GSM_StateMach
cur -= Priv->FirstMemoryEntry - 1;
if (cur == Priv->NextMemoryEntry || Priv->NextMemoryEntry == 0)
Priv->NextMemoryEntry = cur + 1;
}
}
line++;
}
return ERR_NONE;
case AT_Reply_Error:
return ERR_UNKNOWN;
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
default:
return ERR_UNKNOWNRESPONSE;
}
}
GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM_AT_NeededMemoryInfo NeededInfo)
{
GSM_Error error;
char req[20];
int start;
int end;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
smprintf(s, "Getting memory information\n");
Priv->MemorySize = 0;
Priv->TextLength = 0;
Priv->NumberLength = 0;
error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus);
+ if (Priv->Manufacturer == AT_Samsung)
+ error = GSM_WaitFor (s, "", 0, 0x00, 4, ID_GetMemoryStatus);
if (error != ERR_NONE) return error;
if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE;
smprintf(s, "Getting memory status by reading values\n");
s->Phone.Data.MemoryStatus = Status;
Status->MemoryUsed = 0;
Status->MemoryFree = 0;
start = Priv->FirstMemoryEntry;
Priv->NextMemoryEntry = 0;
while (1) {
end = start + 20;
if (end > Priv->MemorySize) end = Priv->MemorySize;
sprintf(req, "AT+CPBR=%i,%i\r", start, end);
error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemoryStatus);
if (error != ERR_NONE) return error;
if (NeededInfo == AT_NextEmpty && Priv->NextMemoryEntry != 0 && Priv->NextMemoryEntry != end + 1) return ERR_NONE;
if (end == Priv->MemorySize) {
Status->MemoryFree = Priv->MemorySize - Status->MemoryUsed;
return ERR_NONE;
}
start = end + 1;
}
}
GSM_Error ATGEN_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
{
GSM_Error error;
error = ATGEN_SetPBKMemory(s, Status->MemoryType);
if (error != ERR_NONE) return error;
@@ -2239,64 +2310,70 @@ GSM_Error ATGEN_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
/* in some phones doesn't work or doesn't return memory status inside */
/* Some workaround for buggy mobile, that hangs after "AT+CPBS?" for other
* memory than SM.
*/
if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_BROKENCPBS) || (Status->MemoryType == MEM_SM)) {
smprintf(s, "Getting memory status\n");
error=GSM_WaitFor (s, "AT+CPBS?\r", 9, 0x00, 4, ID_GetMemoryStatus);
if (error == ERR_NONE) return ERR_NONE;
}
return ATGEN_GetMemoryInfo(s, Status, AT_Status);
}
GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Error error;
/* Have we already selected something? */
if (Priv->PBKCharset!=0) {
/* If we want unicode charset and we have it already or setting of it
* failed, we have nothing to do. */
if (PreferUnicode && (Priv->PBKCharset==AT_PBK_UCS2 || Priv->UCS2CharsetFailed)) return ERR_NONE;
/* If we don't need unicode charset and we have some (or have unicode
* charset when other failed), we have nothing to do. */
if (!PreferUnicode && (Priv->PBKCharset!=AT_PBK_UCS2 || Priv->NonUCS2CharsetFailed)) return ERR_NONE;
}
error=ATGEN_GetManufacturer(s);
if (error != ERR_NONE) return error;
+ /* Samsung (and Sagem?) phones use only PCCP437? */
+ if (Priv->Manufacturer == AT_Samsung) {
+ Priv->PBKCharset = AT_PBK_PCCP437;
+ return ERR_NONE;
+ }
+
if (PreferUnicode && !Priv->UCS2CharsetFailed) {
smprintf(s, "Setting charset to UCS2\n");
error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset);
if (error == ERR_NONE) {
Priv->PBKCharset = AT_PBK_UCS2;
return ERR_NONE;
} else {
Priv->UCS2CharsetFailed = true;
}
}
smprintf(s, "Setting charset to HEX\n");
error=GSM_WaitFor (s, "AT+CSCS=\"HEX\"\r", 14, 0x00, 3, ID_SetMemoryCharset);
/* Falcom replies OK for HEX mode and send everything
* in normal format */
if (error == ERR_NONE && Priv->Manufacturer != AT_Falcom) {
Priv->PBKCharset = AT_PBK_HEX;
return ERR_NONE;
}
smprintf(s, "Setting charset to GSM\n");
error=GSM_WaitFor (s, "AT+CSCS=\"GSM\"\r", 14, 0x00, 3, ID_SetMemoryCharset);
if (error == ERR_NONE) {
Priv->PBKCharset = AT_PBK_GSM;
return ERR_NONE;
}
if (!Priv->UCS2CharsetFailed) {
Priv->NonUCS2CharsetFailed = true;
smprintf(s, "Setting charset to UCS2\n");
error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset);
if (error == ERR_NONE) {
@@ -2356,65 +2433,95 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
/* Number format */
pos += ATGEN_ExtractOneParameter(pos, buffer);
smprintf(s, "Number format: %s\n",buffer);
/* International number */
if (!strcmp(buffer,"145")) {
sprintf(buffer+1,"%s",DecodeUnicodeString(Memory->Entries[0].Text));
if (strlen(buffer+1)!=0 && buffer[1] != '+') {
/* Sony Ericsson issue */
/* International number is without + */
buffer[0] = '+';
EncodeUnicode(Memory->Entries[0].Text,buffer,strlen(buffer));
}
}
/* Name */
pos += ATGEN_ExtractOneParameter(pos, buffer);
smprintf(s, "Name text: %s\n",buffer);
Memory->EntriesNum++;
Memory->Entries[1].EntryType=PBK_Text_Name;
switch (Priv->PBKCharset) {
case AT_PBK_HEX:
DecodeHexBin(buffer2,buffer+1,strlen(buffer)-2);
DecodeDefault(Memory->Entries[1].Text,buffer2,strlen(buffer2),false,NULL);
break;
case AT_PBK_GSM:
DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
break;
case AT_PBK_UCS2:
DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1);
break;
+ case AT_PBK_PCCP437:
+ /* FIXME: correctly decode PCCP437 */
+ DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
+ break;
+ }
+
+ /* Samsung number type */
+ if (Priv->Manufacturer == AT_Samsung) {
+ int type;
+
+ pos += ATGEN_ExtractOneParameter(pos, buffer);
+ smprintf(s, "Number type: %s\n",buffer);
+ type = strtoul(buffer, NULL, 0);
+ switch (type) {
+ case 0:
+ Memory->Entries[0].EntryType = PBK_Number_Mobile;
+ break;
+ case 1:
+ Memory->Entries[0].EntryType = PBK_Number_Work;
+ break;
+ case 2:
+ Memory->Entries[0].EntryType = PBK_Number_Home;
+ break;
+ case 3:
+ Memory->Entries[0].EntryType = PBK_Text_Email;
+ break;
+ default:
+ Memory->Entries[0].EntryType = PBK_Number_General;
+ }
}
+
return ERR_NONE;
case AT_Reply_CMEError:
return ATGEN_HandleCMEError(s);
case AT_Reply_Error:
smprintf(s, "Error - too high location ?\n");
return ERR_INVALIDLOCATION;
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
default:
break;
}
return ERR_UNKNOWNRESPONSE;
}
GSM_Error ATGEN_PrivGetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, int endlocation)
{
GSM_Error error;
unsigned char req[20];
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (entry->Location==0x00) return ERR_INVALIDLOCATION;
if (entry->MemoryType == MEM_ME) {
if (Priv->PBKSBNR == 0) {
sprintf(req, "AT^SBNR=?\r");
smprintf(s, "Checking availablity of SBNR\n");
error=GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory);
switch (error) {
case ERR_NONE:
Priv->PBKSBNR = AT_SBNR_AVAILABLE;
break;
case ERR_UNKNOWN:
@@ -2533,64 +2640,66 @@ GSM_Error ATGEN_ReplyDialVoice(GSM_Protocol_Message msg, GSM_StateMachine *s)
return ATGEN_HandleCMSError(s);
default:
break;
}
return ERR_UNKNOWNRESPONSE;
}
GSM_Error ATGEN_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
{
char req[39] = "ATDT";
if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
if (strlen(number) > 32) return (ERR_UNKNOWN);
strcat(req, number);
strcat(req, ";\r");
smprintf(s, "Making voice call\n");
return GSM_WaitFor (s, req, 4+2+strlen(number), 0x00, 5, ID_DialVoice);
}
GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
case AT_Reply_OK:
smprintf(s, "Security code was OK\n");
return ERR_NONE;
case AT_Reply_Error:
smprintf(s, "Incorrect security code\n");
return ERR_SECURITYERROR;
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
default:
break;
}
return ERR_UNKNOWNRESPONSE;
}
GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
{
unsigned char req[50];
switch (Code.Type) {
case SEC_Pin :
sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code);
break;
case SEC_Pin2 :
if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Siemens) {
sprintf(req, "AT+CPIN2=\"%s\"\r", Code.Code);
} else {
sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code);
}
break;
default : return ERR_NOTIMPLEMENTED;
}
smprintf(s, "Entering security code\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 6, ID_EnterSecurityCode);
}
GSM_Error ATGEN_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_SecurityCodeType *Status = s->Phone.Data.SecurityStatus;
@@ -2895,64 +3004,70 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
/* Get maximal text length */
if (Priv->TextLength == 0) {
ATGEN_GetMemoryInfo(s, NULL, AT_Sizes);
}
/* I char stored in GSM alphabet takes 7 bits, one
* unicode 16, if storing in unicode would truncate
* text, do not use it, otherwise we will use it */
if ((Priv->TextLength != 0) && ((Priv->TextLength * 7 / 16) <= len)) {
PreferUnicode = false;
} else {
PreferUnicode = true;
}
}
error = ATGEN_SetPBKCharset(s, PreferUnicode);
if (error != ERR_NONE) return error;
switch (Priv->PBKCharset) {
case AT_PBK_HEX:
EncodeHexBin(name, DecodeUnicodeString(entry->Entries[Name].Text), UnicodeLength(entry->Entries[Name].Text));
len = strlen(name);
break;
case AT_PBK_GSM:
smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
len = UnicodeLength(entry->Entries[Name].Text);
EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
break;
case AT_PBK_UCS2:
EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text));
len = strlen(name);
break;
+ case AT_PBK_PCCP437:
+ /* FIXME: correctly decode PCCP437 */
+ smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
+ len = UnicodeLength(entry->Entries[Name].Text);
+ EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
+ break;
}
} else {
smprintf(s, "WARNING: No usable name found!\n");
len = 0;
}
if (Number != -1) {
GSM_PackSemiOctetNumber(entry->Entries[Number].Text, number, false);
NumberType = number[0];
sprintf(number,"%s",DecodeUnicodeString(entry->Entries[Number].Text));
} else {
smprintf(s, "WARNING: No usable number found!\n");
number[0] = 0;
}
if (Priv->FirstMemoryEntry == 0) {
error = ATGEN_GetMemoryInfo(s, NULL, AT_First);
if (error != ERR_NONE) return error;
}
/* We can't use here:
* sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"%s\"\r",
* entry->Location, number, NumberType, name);
* because name can contain 0 when using GSM alphabet.
*/
sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"", entry->Location + Priv->FirstMemoryEntry - 1, number, NumberType);
reqlen = strlen(req);
if (reqlen + len > REQUEST_SIZE - 2) {
smprintf(s, "WARNING: Text truncated to fit in buffer!\n");
len = REQUEST_SIZE - 2 - reqlen;
}
memcpy(req + reqlen, name, len);
@@ -3223,64 +3338,101 @@ static GSM_Error ATGEN_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *N
if (Priv->Manufacturer==AT_Siemens ) return SIEMENS_GetNextCalendar(s,Note,start);
if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_GetNextCalendar(s,Note,start);
return ERR_NOTSUPPORTED;
}
GSM_Error ATGEN_Terminate(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
free(Priv->file.Buffer);
return ERR_NONE;
}
GSM_Error ATGEN_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer==AT_Siemens) return SIEMENS_AddCalendarNote(s, Note);
if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_AddCalendarNote(s, Note);
return ERR_NOTSUPPORTED;
}
GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer==AT_Siemens) return SIEMENS_DelCalendarNote(s, Note);
if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_DelCalendarNote(s, Note);
return ERR_NOTSUPPORTED;
}
+
+GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetBitmap(s, Bitmap);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetBitmap(s, Bitmap);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetBitmap(s, Bitmap);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetBitmap(s, Bitmap);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetRingtone(s, Ringtone, PhoneRingtone);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetRingtone(s, Ringtone, PhoneRingtone);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+
+ if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetRingtone(s, Ringtone, maxlength);
+ if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetRingtone(s, Ringtone, maxlength);
+ return ERR_NOTSUPPORTED;
+}
+
GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
{
GSM_Error error;
unsigned char Frame[] = "AT+CKPD=\"?\"\r";
if (Press) {
switch (Key) {
case GSM_KEY_1 : Frame[9] = '1'; break;
case GSM_KEY_2 : Frame[9] = '2'; break;
case GSM_KEY_3 : Frame[9] = '3'; break;
case GSM_KEY_4 : Frame[9] = '4'; break;
case GSM_KEY_5 : Frame[9] = '5'; break;
case GSM_KEY_6 : Frame[9] = '6'; break;
case GSM_KEY_7 : Frame[9] = '7'; break;
case GSM_KEY_8 : Frame[9] = '8'; break;
case GSM_KEY_9 : Frame[9] = '9'; break;
case GSM_KEY_0 : Frame[9] = '0'; break;
case GSM_KEY_HASH : Frame[9] = '#'; break;
case GSM_KEY_ASTERISK : Frame[9] = '*'; break;
case GSM_KEY_POWER : return ERR_NOTSUPPORTED;
case GSM_KEY_GREEN : Frame[9] = 'S'; break;
case GSM_KEY_RED : Frame[9] = 'E'; break;
case GSM_KEY_INCREASEVOLUME : Frame[9] = 'U'; break;
case GSM_KEY_DECREASEVOLUME : Frame[9] = 'D'; break;
case GSM_KEY_UP : Frame[9] = '^'; break;
case GSM_KEY_DOWN : Frame[9] = 'V'; break;
case GSM_KEY_MENU : Frame[9] = 'F'; break;
case GSM_KEY_NAMES : Frame[9] = 'C'; break;
default : return ERR_NOTSUPPORTED;
}
smprintf(s, "Pressing key\n");
error = GSM_WaitFor (s, Frame, 12, 0x00, 4, ID_PressKey);
@@ -3317,64 +3469,75 @@ GSM_Error ATGEN_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s)
// if (Buffer[i] == 13) i = i - 1; else break;
// }
DecodeDefault(CB.Text, Buffer2, msg.Buffer[6], false, NULL);
smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text));
}
if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) {
s->User.IncomingCB(s->CurrentConfig->Device,CB);
}
return ERR_NONE;
}
#endif
GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
{
#ifdef GSM_ENABLE_CELLBROADCAST
if (s->Phone.Data.EnableIncomingCB!=enable) {
s->Phone.Data.EnableIncomingCB = enable;
if (enable) {
smprintf(s, "Enabling incoming CB\n");
return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB);
} else {
smprintf(s, "Disabling incoming CB\n");
return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB);
}
}
return ERR_NONE;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
+GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable)
+{
+ if (enable) {
+ smprintf(s, "Enabling fast SMS sending\n");
+ return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending);
+ } else {
+ smprintf(s, "Disabling fast SMS sending\n");
+ return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending);
+ }
+}
+
GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "Incoming SMS\n");
return ERR_NONE;
}
GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
GSM_SMSMessage sms;
int current = 0, current2, i=0;
unsigned char buffer[300],smsframe[800];
smprintf(s, "Incoming SMS received (Deliver)\n");
if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
sms.State = SMS_UnRead;
sms.InboxFolder = true;
sms.PDU = SMS_Deliver;
/* T310 with larger SMS goes crazy and mix this incoming
* frame with normal answers. PDU is always last frame
* We find its' number and parse it */
while (Data->Priv.ATGEN.Lines.numbers[i*2+1] != 0) {
/* FIXME: handle special chars correctly */
i++;
}
DecodeHexBin (buffer,
GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i),
strlen(GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i)));
/* We use locations from SMS layouts like in ../phone2.c(h) */
for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++];
@@ -3395,275 +3558,305 @@ GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s
}
/* I don't have phone able to do it and can't fill it */
GSM_Error ATGEN_IncomingSMSReport(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "Incoming SMS received (Report)\n");
return ERR_NONE;
}
GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
{
/* Nokia returns OK, but doesn't return anything */
if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Nokia) return ERR_NOTSUPPORTED;
if (s->Phone.Data.EnableIncomingSMS!=enable) {
s->Phone.Data.EnableIncomingSMS = enable;
if (enable) {
smprintf(s, "Enabling incoming SMS\n");
/* Delivery reports */
GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS);
/* SMS deliver */
return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS);
} else {
smprintf(s, "Disabling incoming SMS\n");
return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS);
}
}
return ERR_NONE;
}
+GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{
+ if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale);
+ return ERR_NOTSUPPORTED;
+}
+
+GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{
+ if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale);
+ return ERR_NOTSUPPORTED;
+}
+
GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho },
{ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo },
{ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey },
{ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI },
{ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX },
+{ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale },
+{ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale },
+{ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale },
+{ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale },
+
#ifdef GSM_ENABLE_CELLBROADCAST
{ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB },
#endif
{ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge },
{ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel },
{ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer },
{ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware },
{ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware },
{ATGEN_ReplyGetIMEI, "AT+CGSN" ,0x00,0x00,ID_GetIMEI },
{ATGEN_ReplySendSMS, "AT+CMGS" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplySendSMS, "AT+CMSS" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingSMS },
{ATGEN_GenericReply, "AT+CMGF" ,0x00,0x00,ID_GetSMSMode },
{ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode },
{ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage },
{ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType },
{ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus },
{ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories },
{ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage },
{ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters },
{ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC },
{ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC },
{ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage },
{ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters },
{ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters },
+{ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending },
{ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime },
{ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime },
+{ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm },
{ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm },
{ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo },
{ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo },
{ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo },
{ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin},
{ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo },
{ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality },
{ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType },
{ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType },
{ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus },
+// /* Samsung phones reply +CPBR: after OK --claudio*/
{ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus },
+{ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus },
{ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus },
{ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset },
{ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory },
{ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory },
-{ATGEN_SL45ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
+{SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
{ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory },
-{ATGEN_CMS35ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
-{ATGEN_CMS35ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
+{SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
+{SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
-{ATGEN_CMS35ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
-{ATGEN_CMS35ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
+{SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
+{SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
-{ATGEN_CMS35ReplyGetNextCal, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
-{ATGEN_CMS35ReplySetCalendar, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
-{ATGEN_CMS35ReplyDeleteCalendar,"AT^SBNW=\"vcs\"" ,0x00,0x00,ID_DeleteCalendarNote },
+{SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
+{SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
+{SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_DeleteCalendarNote },
{ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode },
{ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode },
{ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus },
{ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF },
{ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall },
{ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice },
{ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall },
+{ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
+{ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset },
{ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset },
{ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings },
+{SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap },
+{SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap },
+
+{SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone },
+{SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone },
+
#ifdef GSM_ENABLE_ALCATEL
/* Why do I give Alcatel specific things here? It's simple, Alcatel needs
* some AT commands to start it's binary mode, so this needs to be in AT
* related stuff.
*
* XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel
* specific and it's part of ETSI specifications
*/
{ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl },
{ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol },
{ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect },
#endif
{NULL, "\x00" ,0x00,0x00,ID_None }
};
GSM_Phone_Functions ATGENPhone = {
- "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",
+ "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",
ATGENReplyFunctions,
ATGEN_Initialise,
ATGEN_Terminate,
ATGEN_DispatchMessage,
NOTSUPPORTED, /* ShowStartInfo */
ATGEN_GetManufacturer,
ATGEN_GetModel,
ATGEN_GetFirmware,
ATGEN_GetIMEI,
NOTSUPPORTED, /* GetOriginalIMEI */
NOTSUPPORTED, /* GetManufactureMonth */
NOTSUPPORTED, /* GetProductCode */
NOTSUPPORTED, /* GetHardware */
NOTSUPPORTED, /* GetPPM */
ATGEN_GetSIMIMSI,
ATGEN_GetDateTime,
ATGEN_SetDateTime,
ATGEN_GetAlarm,
- NOTIMPLEMENTED, /* SetAlarm */
- NOTSUPPORTED, /* GetLocale */
- NOTSUPPORTED, /* SetLocale */
+ ATGEN_SetAlarm,
+ ATGEN_GetLocale,
+ ATGEN_SetLocale,
ATGEN_PressKey,
ATGEN_Reset,
ATGEN_ResetPhoneSettings,
ATGEN_EnterSecurityCode,
ATGEN_GetSecurityStatus,
ATGEN_GetDisplayStatus,
ATGEN_SetAutoNetworkLogin,
ATGEN_GetBatteryCharge,
ATGEN_GetSignalQuality,
ATGEN_GetNetworkInfo,
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
ATGEN_GetMemoryStatus,
ATGEN_GetMemory,
ATGEN_GetNextMemory,
ATGEN_SetMemory,
ATGEN_AddMemory,
ATGEN_DeleteMemory,
ATGEN_DeleteAllMemory,
NOTSUPPORTED, /* GetSpeedDial */
NOTSUPPORTED, /* SetSpeedDial */
ATGEN_GetSMSC,
ATGEN_SetSMSC,
ATGEN_GetSMSStatus,
ATGEN_GetSMS,
ATGEN_GetNextSMS,
NOTSUPPORTED, /* SetSMS */
ATGEN_AddSMS,
ATGEN_DeleteSMS,
ATGEN_SendSMS,
ATGEN_SendSavedSMS,
+ ATGEN_SetFastSMSSending,
ATGEN_SetIncomingSMS,
ATGEN_SetIncomingCB,
ATGEN_GetSMSFolders,
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
ATGEN_DialVoice,
ATGEN_AnswerCall,
ATGEN_CancelCall,
NOTSUPPORTED, /* HoldCall */
NOTSUPPORTED, /* UnholdCall */
NOTSUPPORTED, /* ConferenceCall */
NOTSUPPORTED, /* SplitCall */
NOTSUPPORTED, /* TransferCall */
NOTSUPPORTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NONEFUNCTION, /* SetIncomingCall */
- NOTSUPPORTED, /* SetIncomingUSSD */
+ ATGEN_SetIncomingUSSD,
ATGEN_SendDTMF,
ATGEN_GetRingtone,
ATGEN_SetRingtone,
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
ATGEN_GetBitmap, /* GetBitmap */
ATGEN_SetBitmap, /* SetBitmap */
SONYERIC_GetToDoStatus,
NOTSUPPORTED, /* GetToDo */
SONYERIC_GetNextToDo,
NOTSUPPORTED, /* SetToDo */
SONYERIC_AddToDo,
NOTSUPPORTED, /* DeleteToDo */
SONYERIC_DeleteAllToDo,
SONYERIC_GetCalendarStatus,
NOTIMPLEMENTED, /* GetCalendar */
ATGEN_GetNextCalendar,
NOTIMPLEMENTED, /* SetCalendar */
ATGEN_AddCalendarNote,
ATGEN_DelCalendarNote,
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFile */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -13,98 +13,104 @@
#ifndef GSM_USED_BLUEAT
# define GSM_USED_BLUEAT
#endif
#ifndef GSM_USED_IRDAAT
# define GSM_USED_IRDAAT
#endif
#define MAX_VCALENDAR_LOCATION 50
typedef enum {
SMS_AT_PDU = 1,
SMS_AT_TXT
} GSM_AT_SMS_Modes;
typedef enum {
AT_Reply_OK = 1,
AT_Reply_Connect,
AT_Reply_Error,
AT_Reply_Unknown,
AT_Reply_CMSError,
AT_Reply_CMEError,
AT_Reply_SMSEdit
} GSM_AT_Reply_State;
typedef enum {
AT_Nokia = 1,
AT_Alcatel,
AT_Siemens,
AT_HP,
AT_Falcom,
AT_Ericsson,
AT_Sagem,
+ AT_Samsung,
AT_Unknown
} GSM_AT_Manufacturer;
typedef enum {
AT_PBK_HEX = 1,
AT_PBK_GSM,
- AT_PBK_UCS2
+ AT_PBK_UCS2,
+ AT_PBK_PCCP437
} GSM_AT_PBK_Charset;
typedef enum {
AT_AVAILABLE = 1,
AT_NOTAVAILABLE
} GSM_AT_SMSMemory;
typedef enum {
AT_SBNR_AVAILABLE = 1,
AT_SBNR_NOTAVAILABLE
} GSM_AT_SBNR;
typedef enum {
AT_Status,
AT_NextEmpty,
AT_Total,
AT_First,
AT_Sizes
} GSM_AT_NeededMemoryInfo;
#define AT_PBK_MAX_MEMORIES 200
typedef struct {
GSM_AT_Manufacturer Manufacturer; /* Who is manufacturer */
GSM_Lines Lines; /* Allow to simply get each line in response */
GSM_AT_Reply_State ReplyState; /* What response type - error, OK, etc. */
int ErrorCode; /* Error codes from responses */
char *ErrorText; /* Error description */
GSM_MemoryType PBKMemory; /* Last read PBK memory */
char PBKMemories[AT_PBK_MAX_MEMORIES + 1]; /* Supported by phone PBK memories */
int NextMemoryEntry; /* Next empty memory entry */
int FirstMemoryEntry; /* First memory entry to be read */
GSM_AT_PBK_Charset PBKCharset; /* Last read PBK charset */
bool UCS2CharsetFailed; /* Whether setting of UCS2 charset has already failed */
bool NonUCS2CharsetFailed; /* Whether setting of non-UCS2 charset has already failed */
GSM_AT_SBNR PBKSBNR;
int NumberLength;
int TextLength;
int MemorySize;
GSM_SMSMemoryStatus LastSMSStatus;
int LastSMSRead;
int FirstCalendarPos;
bool CanSaveSMS;
GSM_AT_SMSMemory PhoneSMSMemory; /* Is phone SMS memory available ? */
GSM_AT_SMSMemory SIMSMSMemory; /* Is SIM SMS memory available ? */
GSM_MemoryType SMSMemory; /* Last read SMS memory */
GSM_AT_SMS_Modes SMSMode; /* PDU or TEXT mode for SMS ? */
bool OBEX;
GSM_File file;
} GSM_Phone_ATGENData;
+GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *);
+GSM_Error ATGEN_HandleCMEError (GSM_StateMachine *);
+GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *);
+
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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 @@
+/* Samsung-specific functions
+ * Copyright (C) 2004 Claudio Matsuoka <cmatsuoka@gmail.com>
+ * Tested with S300 only!
+ */
+
+#include "../../gsmstate.h"
+
+#ifdef GSM_ENABLE_ATGEN
+
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+
+#include "../../misc/coding/coding.h"
+#include "../../gsmcomon.h"
+#include "../../service/sms/gsmsms.h"
+#include "../pfunc.h"
+
+#include "atgen.h"
+#include "samsung.h"
+
+/* Binary frame size */
+#define BLKSZ 1024
+
+struct ModelRes {
+ char *model;
+ int width;
+ int height;
+};
+
+static struct ModelRes modres[] = {
+ { "S100", 128, 128 },
+ { "S200", 128, 113 },
+ { "S300", 128, 97 },
+ { "S500", 128, 128 },
+ { "T100", 128, 128 },
+ { "E700", 128, 128 },
+ { NULL, 0, 0 }
+};
+
+/*
+ * CRC functions from the Granch SBNI12 Linux driver by
+ * Denis I. Timofeev <timofeev@granch.ru>
+ */
+static unsigned int crc32tab[] = {
+ 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
+ 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
+ 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605,
+ 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C,
+ 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53,
+ 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A,
+ 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661,
+ 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278,
+ 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF,
+ 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6,
+ 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD,
+ 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4,
+ 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B,
+ 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82,
+ 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9,
+ 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0,
+ 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7,
+ 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE,
+ 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795,
+ 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C,
+ 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3,
+ 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA,
+ 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1,
+ 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8,
+ 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F,
+ 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76,
+ 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D,
+ 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344,
+ 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B,
+ 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12,
+ 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739,
+ 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320,
+ 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17,
+ 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E,
+ 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525,
+ 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C,
+ 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73,
+ 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A,
+ 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541,
+ 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158,
+ 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF,
+ 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6,
+ 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED,
+ 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4,
+ 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB,
+ 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2,
+ 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589,
+ 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190,
+ 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87,
+ 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E,
+ 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5,
+ 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC,
+ 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3,
+ 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA,
+ 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1,
+ 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8,
+ 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F,
+ 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856,
+ 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D,
+ 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064,
+ 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B,
+ 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832,
+ 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419,
+ 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000
+};
+
+static unsigned int GetCRC(char *data, int size)
+{
+ unsigned int crc = 0;
+
+ while (size--)
+ crc = crc32tab[(crc ^ *data++) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF);
+
+ return crc;
+}
+
+/*
+ * Frame transfer
+ */
+
+static GSM_Error WaitFor(GSM_StateMachine *s, char *t, int ttl)
+{
+ char readbuf[100];
+ int n;
+ unsigned int sec;
+ GSM_DateTime Date;
+
+ GSM_GetCurrentDateTime (&Date);
+ sec = Date.Second;
+
+ n = s->Device.Functions->ReadDevice(s, readbuf, 80);
+ readbuf[n] = 0;
+ while (strstr(readbuf, t) == NULL && (sec + ttl) >= Date.Second) {
+ my_sleep(5000);
+ n = s->Device.Functions->ReadDevice(s, readbuf, 80);
+ readbuf[n] = 0;
+ GSM_GetCurrentDateTime (&Date);
+ }
+
+ return (sec + ttl) >= Date.Second ? ERR_NONE : ERR_TIMEOUT;
+}
+
+static GSM_Error SetSamsungFrame(GSM_StateMachine *s, unsigned char *buff, int size, GSM_Phone_RequestID id)
+{
+ GSM_Phone_Data *Phone = &s->Phone.Data;
+ GSM_Error error;
+ int i, count;
+
+ count = size / BLKSZ;
+
+ for (i = 0; i < count; i++) {
+ error = WaitFor(s, ">", 4);
+ if (error!=ERR_NONE) return error;
+
+ error = s->Protocol.Functions->WriteMessage(s,
+ buff + i * BLKSZ, BLKSZ, 0x00);
+ if (error!=ERR_NONE) return error;
+ }
+
+ error = WaitFor(s, ">", 4);
+ if (error!=ERR_NONE) return error;
+ error = s->Protocol.Functions->WriteMessage(s,
+ buff + i * BLKSZ, size%BLKSZ, 0x00);
+ if (error!=ERR_NONE) return error;
+
+ error = GSM_WaitFor(s, "", 0, 0x00, 4, id);
+ if (error!=ERR_NONE) return error;
+
+ return Phone->DispatchError;
+}
+
+/* Answer format for binary data transfer
+ *
+ * SDNDCRC = 0xa : RECEIVECRC = 0xcbf53a1c : BINSIZE = 5
+ * CRCERR
+ */
+static GSM_Error ReplySetSamsungFrame(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ unsigned long txcrc, rxcrc;
+ int binsize;
+ char *pos;
+
+ /* Parse SDNDCRC */
+ pos = strchr(msg.Buffer, '=');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ txcrc = strtoul(pos, NULL, 0);
+ smprintf(s, "Sent CRC : 0x%lx\n", txcrc);
+
+ /* Parse RECEIVECRC */
+ pos = strchr(pos, '=');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ rxcrc = strtoul(pos, NULL, 0);
+ smprintf(s, "Reveived CRC : 0x%lx\n", rxcrc);
+
+ /* Parse BINSIZE */
+ pos = strchr(pos, '=');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ binsize = strtoul(pos, NULL, 0);
+ smprintf(s, "Binary size : %d\n", binsize);
+
+ return txcrc == rxcrc ? ERR_NONE : ERR_WRONGCRC;
+}
+
+/*
+ * Bitmaps
+ */
+
+GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ unsigned char buffer[32];
+ char *pos;
+ int location, count;
+
+ switch (Priv->ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Bitmap info received\n");
+ /* Parse +IMGR:location,name,0,0,0,0 */
+
+ /* Parse location */
+ pos = strchr(msg.Buffer, ':');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ location = atoi(pos);
+ smprintf(s, "Location : %d\n", location);
+
+ /* Parse name */
+ pos = strchr(pos, '"');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ for (count = 0; count < 31; count++) {
+ if (pos[count] == '"')
+ break;
+ buffer[count] = pos[count];
+ }
+ buffer[count] = 0;
+ smprintf(s, "Name : %s\n", buffer);
+ s->Phone.Data.Bitmap->Name = malloc((strlen(buffer) + 1) * 2);
+ if (s->Phone.Data.Bitmap->Name == NULL)
+ return ERR_MOREMEMORY;
+ EncodeUnicode(s->Phone.Data.Bitmap->Name, buffer, strlen(buffer));
+
+ s->Phone.Data.Bitmap->Location = location;
+
+ return ERR_NONE;
+ case AT_Reply_Error:
+ return ERR_UNKNOWN;
+ case AT_Reply_CMSError:
+ return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Bitmap sent\n");
+ return ReplySetSamsungFrame(msg, s);
+}
+
+GSM_Error SAMSUNG_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char req[100];
+
+ s->Phone.Data.Bitmap=Bitmap;
+ smprintf(s, "Getting bitmap\n");
+ sprintf(req, "AT+IMGR=%d\r", Bitmap->Location-1);
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
+}
+
+GSM_Error SAMSUNG_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+{
+ unsigned char req[100];
+ unsigned long crc;
+ GSM_Error error;
+ char name[50], *dot, *model;
+ GSM_Phone_Data *Data = &s->Phone.Data;
+ int i;
+
+ s->Phone.Data.Bitmap = Bitmap;
+ smprintf(s, "Setting bitmap\n");
+
+ if (Bitmap->Type != GSM_PictureBinary) {
+ smprintf(s, "Invalid picture type\n");
+ return ERR_INVALIDDATA;
+ }
+
+ if (Bitmap->BinaryPic.Type != PICTURE_GIF) {
+ smprintf(s, "Invalid binary picture type\n");
+ return ERR_INVALIDDATA;
+ }
+
+ /* Check if picture size matches phone model */
+ model = GetModelData(NULL,Data->Model,NULL)->model;
+ smprintf(s, "Checking picture size for %s\n", model);
+ for (i = 0; modres[i].model; i++) {
+ if (!strcmp(model, modres[i].model)) {
+ if (Bitmap->BitmapWidth != modres[i].width ||
+ Bitmap->BitmapHeight != modres[i].height) {
+ smprintf(s, "Model %s must use %d x %d picture size\n",
+ modres[i].model, modres[i].width,
+ modres[i].height);
+ return ERR_INVALIDDATA;
+ }
+ break;
+ }
+ }
+ if (modres[i].model == NULL) {
+ smprintf(s, "Model \"%s\" is not supported.\n", Data->Model);
+ return ERR_NOTSUPPORTED;
+ }
+
+ crc = GetCRC(Bitmap->BinaryPic.Buffer, Bitmap->BinaryPic.Length);
+
+ /* Remove extension from file name */
+ strncpy(name, DecodeUnicodeString(Bitmap->Name), 50);
+ if ((dot = strrchr(name, '.')) != NULL)
+ *dot = 0;
+
+ sprintf(req, "AT+IMGW=0,\"%s\",2,0,0,0,0,100,%d,%u\r", name,
+ Bitmap->BinaryPic.Length, (unsigned int)crc);
+
+ error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
+ if (error!=ERR_NONE) return error;
+
+ return SetSamsungFrame(s, Bitmap->BinaryPic.Buffer,
+ Bitmap->BinaryPic.Length, ID_SetBitmap);
+}
+
+/*
+ * Ringtones
+ */
+
+GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ unsigned char buffer[32];
+ char *pos;
+ int location, length, count;
+
+ switch (Priv->ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Ringtone info received\n");
+ /* Parse +MELR:location,name,size */
+
+ /* Parse location */
+ pos = strchr(msg.Buffer, ':');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ location = atoi(pos);
+ smprintf(s, "Location : %d\n", location);
+
+ /* Parse name */
+ pos = strchr(pos, '"');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ /* Ringtone.Name size is 20 chars */
+ for (count = 0; count < 19; count++) {
+ if (pos[count] == '"')
+ break;
+ buffer[count] = pos[count];
+ }
+ buffer[count] = 0;
+ smprintf(s, "Name : %s\n", buffer);
+ EncodeUnicode(s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
+
+ /* Parse ringtone length */
+ pos = strchr(pos, ',');
+ if (!pos) return ERR_UNKNOWN;
+ pos++;
+ length = atoi(pos);
+ smprintf(s, "Length : %d\n", length);
+
+ /* S300 ringtones are always MMF */
+ s->Phone.Data.Ringtone->Format = RING_MMF;
+ s->Phone.Data.Ringtone->Location = location;
+ s->Phone.Data.Ringtone->BinaryTone.Length = length;
+
+ return ERR_NONE;
+ case AT_Reply_Error:
+ return ERR_UNKNOWN;
+ case AT_Reply_CMSError:
+ return ATGEN_HandleCMSError(s);
+ case AT_Reply_CMEError:
+ return ATGEN_HandleCMEError(s);
+ default:
+ return ERR_UNKNOWNRESPONSE;
+ }
+}
+
+GSM_Error SAMSUNG_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+{
+ unsigned char req[100];
+
+ s->Phone.Data.Ringtone = Ringtone;
+ smprintf(s, "Getting ringtone\n");
+ sprintf(req, "AT+MELR=%d\r", Ringtone->Location-1);
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
+}
+
+GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Ringtone sent\n");
+ return ReplySetSamsungFrame(msg, s);
+}
+
+GSM_Error SAMSUNG_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+{
+ unsigned char req[100];
+ unsigned long crc;
+ GSM_Error error;
+ char name[50], *dot;
+
+ s->Phone.Data.Ringtone = Ringtone;
+ smprintf(s, "Setting ringtone\n");
+
+ if (Ringtone->Format != RING_MMF) {
+ smprintf(s, "Not MMF ringtone\n");
+ return ERR_INVALIDDATA;
+ }
+
+ /* Remove extension from file name */
+ strncpy(name, DecodeUnicodeString(Ringtone->Name), 50);
+ if ((dot = strrchr(name, '.')) != NULL) *dot = 0;
+
+ crc = GetCRC(Ringtone->BinaryTone.Buffer, Ringtone->BinaryTone.Length);
+ sprintf(req, "AT+MELW=0,\"%s\",4,%d,%u\r", name,
+ Ringtone->BinaryTone.Length, (unsigned int)crc);
+
+ error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00);
+ if (error!=ERR_NONE) return error;
+
+ return SetSamsungFrame(s, Ringtone->BinaryTone.Buffer,
+ Ringtone->BinaryTone.Length, ID_SetRingtone);
+}
+
+#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 @@
+#ifndef samsung_h
+#define samsung_h
+
+#include "../../gsmstate.h"
+
+GSM_Error SAMSUNG_ReplyGetRingtone (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_ReplySetRingtone (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_ReplyGetBitmap (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_ReplySetBitmap (GSM_Protocol_Message, GSM_StateMachine *);
+GSM_Error SAMSUNG_GetRingtone (GSM_StateMachine *, GSM_Ringtone *, bool);
+GSM_Error SAMSUNG_SetRingtone (GSM_StateMachine *, GSM_Ringtone *, int *);
+GSM_Error SAMSUNG_GetBitmap (GSM_StateMachine *, GSM_Bitmap *);
+GSM_Error SAMSUNG_SetBitmap (GSM_StateMachine *, GSM_Bitmap *);
+GSM_Error SAMSUNG_GetCallLogs (GSM_StateMachine *, GSM_MemoryEntry *, int);
+
+#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
@@ -1,318 +1,314 @@
/* (c) 2002-2003 by Walek */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_ATGEN
#include <string.h>
#include <time.h>
#include <ctype.h>
#include "../../misc/coding/coding.h"
#include "../../gsmcomon.h"
#include "../../service/sms/gsmsms.h"
#include "../pfunc.h"
-extern GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s);
+#include "atgen.h"
+#include "siemens.h"
-GSM_Error ATGEN_CMS35ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
-{
- if (s->Protocol.Data.AT.EditMode) {
- s->Protocol.Data.AT.EditMode = false;
- return ERR_NONE;
- }
- dbgprintf ("Written %s",function);
- if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
- dbgprintf (" - OK\n");
- return ERR_NONE;
- } else {
- dbgprintf (" - error\n");
- return ERR_UNKNOWN;
- }
-}
-GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ,
+static GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ,
unsigned char *buffer, int *len)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
int i=2, pos=0, length=0;
unsigned char buf[512];
if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY;
if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN;
while (1) {
if (Priv->Lines.numbers[i*2+1]==0) break;
if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) &&
(strstr(GetLineString(msg.Buffer,Priv->Lines,i),templ))){
length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1));
DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length);
length = length/2;
memcpy (buffer+pos,buf,length);
pos+=length;
}
i++;
}
*len = pos;
return ERR_NONE;
}
-GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ,
+static GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ,
int Location, GSM_Phone_RequestID RequestID, int len)
{
GSM_Phone_Data *Phone = &s->Phone.Data;
GSM_Error error;
unsigned char req[20],req1[512],hexreq[2096];
int MaxFrame,CurrentFrame,size,sz,pos=0;
EncodeHexBin(hexreq,buff,len);
size = len * 2;
MaxFrame = size / 352;
if (size % 352) MaxFrame++;
for (CurrentFrame=0;CurrentFrame<MaxFrame;CurrentFrame++) {
pos=CurrentFrame*352;
if (pos+352 < size) sz = 352; else sz = size - pos;
sprintf(req, "AT^SBNW=\"%s\",%i,%i,%i\r",templ,Location,CurrentFrame+1,MaxFrame);
s->Protocol.Data.AT.EditMode = true;
error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, RequestID);
s->Phone.Data.DispatchError=ERR_TIMEOUT;
s->Phone.Data.RequestID=RequestID;
if (error!=ERR_NONE) return error;
memcpy (req1,hexreq+pos,sz);
error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00);
if (error!=ERR_NONE) return error;
error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00);
if (error!=ERR_NONE) return error;
error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4);
if (error == ERR_TIMEOUT) return error;
}
return Phone->DispatchError;
}
-GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
unsigned char buffer[4096];
int length;
GSM_Error error;
error = GetSiemensFrame(msg,s,"bmp",buffer,&length);
if (error!=ERR_NONE) return error;
dbgprintf ("Operator logo received lenght=%i\n",length);
error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap);
if (error==ERR_NONE) return error;
else return ERR_UNKNOWN;
}
-GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function)
{
- return ATGEN_CMS35ReplySetFunction (msg, s, "Operator Logo");
+ if (s->Protocol.Data.AT.EditMode) {
+ s->Protocol.Data.AT.EditMode = false;
+ return ERR_NONE;
+ }
+ dbgprintf ("Written %s",function);
+ if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){
+ dbgprintf (" - OK\n");
+ return ERR_NONE;
+ } else {
+ dbgprintf (" - error\n");
+ return ERR_UNKNOWN;
+ }
}
-GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+GSM_Error SIEMENS_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ return SIEMENS_ReplySetFunction (msg, s, "Operator Logo");
+}
+
+GSM_Error SIEMENS_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
{
unsigned char req[32];
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
if (Bitmap->Location-1 < 0) Bitmap->Location++;
s->Phone.Data.Bitmap=Bitmap;
sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1);
smprintf(s, "Getting Bitmap\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap);
}
-GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
+GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
{
unsigned char buffer[4096];
int length;
GSM_Error error;
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED;
error = Bitmap2BMP (buffer,NULL,Bitmap);
if (error!=ERR_NONE) return error;
length = 0x100 * buffer[3] + buffer[2];
buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff;
if (Bitmap->Location-1 < 0) Bitmap->Location++;
s->Phone.Data.Bitmap=Bitmap;
return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1,
ID_SetBitmap,length);
}
-GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
unsigned char buffer[32];
int length;
GSM_Error error;
error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length);
if (error!=ERR_NONE) return error;
dbgprintf ("Midi ringtone received\n");
s->Phone.Data.Ringtone->Format = RING_MIDI;
s->Phone.Data.Ringtone->NokiaBinary.Length = length;
sprintf(buffer,"Individual");
EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer));
return ERR_NONE;
}
-GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
+GSM_Error SIEMENS_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
{
unsigned char req[32];
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
-
s->Phone.Data.Ringtone=Ringtone;
sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1);
smprintf(s, "Getting RingTone\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone);
}
-GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
- return ATGEN_CMS35ReplySetFunction (msg, s, "Ringtone");
+ return SIEMENS_ReplySetFunction (msg, s, "Ringtone");
}
-GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
+GSM_Error SIEMENS_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
{
GSM_Phone_Data *Phone = &s->Phone.Data;
- if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
-
if (Ringtone->Location==255) Ringtone->Location=1;
if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION;
s->Phone.Data.Ringtone = Ringtone;
Phone->Ringtone = Ringtone;
return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1,
ID_SetRingtone,Ringtone->NokiaBinary.Length);
}
-GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
GSM_CalendarEntry *Calendar = Data->Cal;
GSM_ToDoEntry ToDo;
GSM_Error error;
unsigned char buffer[354];
int len, pos=0;
if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN;
error = GetSiemensFrame(msg,s,"vcs",buffer,&len);
if (error!=ERR_NONE) return error;
error=GSM_DecodeVCALENDAR_VTODO(buffer,&pos,Calendar,&ToDo,Siemens_VCalendar,0);
return error;
}
GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Error error;
unsigned char req[32];
int Location;
if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
if (start) Note->Location=Priv->FirstCalendarPos;
s->Phone.Data.Cal = Note;
Note->EntriesNum = 0;
smprintf(s, "Getting VCALENDAR\n");
Location = Note->Location;
while (1){
Location++;
sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location);
error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote);
if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION;
Note->Location = Location;
Priv->FirstCalendarPos = Location;
if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY;
if (error==ERR_NONE) return error;
}
return error;
}
-GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyAddCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
- return ATGEN_CMS35ReplySetFunction (msg, s, "Calendar Note");
+ return SIEMENS_ReplySetFunction (msg, s, "Calendar Note");
}
-GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyDelCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN;
if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) {
smprintf(s, "Calendar note deleted\n");
return ERR_NONE;
} else {
smprintf(s, "Can't delete calendar note\n");
return ERR_UNKNOWN;
}
}
GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
unsigned char req[32];
if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
s->Phone.Data.Cal = Note;
sprintf(req, "AT^SBNW=\"vcs\",%i,0\r",Note->Location);
smprintf(s, "Deleting calendar note\n");
return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_DeleteCalendarNote);
}
GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Error error;
unsigned char req[500];
int size=0;
if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED;
// if (Note->Location==0x00) return ERR_INVALIDLOCATION;
s->Phone.Data.Cal = Note;
error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar);
return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size);
}
/* (c) by Timo Teras */
-GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
+GSM_Error SIEMENS_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
#ifndef ENABLE_LGPL
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_MemoryEntry *Memory = s->Phone.Data.Memory;
unsigned char buffer[500],buffer2[500];
switch (Priv->ReplyState) {
case AT_Reply_OK:
smprintf(s, "Phonebook entry received\n");
CopyLineString(buffer, msg.Buffer, Priv->Lines, 3);
DecodeHexBin(buffer2,buffer,strlen(buffer));
Memory->EntriesNum = 0;
DecodeVCARD21Text(buffer2, Memory);
if (Memory->EntriesNum == 0) return ERR_EMPTY;
return ERR_NONE;
case AT_Reply_Error:
smprintf(s, "Error - too high location ?\n");
return ERR_INVALIDLOCATION;
case AT_Reply_CMSError:
return ATGEN_HandleCMSError(s);
default:
break;
}
return ERR_UNKNOWNRESPONSE;
#else
return ERR_NOTIMPLEMENTED;
#endif
}
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
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
@@ -1,56 +1,54 @@
/* (c) 2003 by Marcin Wiacek */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_ATGEN
#include <string.h>
#include <time.h>
#include <ctype.h>
#include "../../gsmcomon.h"
#include "../../misc/coding/coding.h"
-extern GSM_Reply_Function ATGENReplyFunctions[];
-extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
+#include "atgen.h"
+#include "sonyeric.h"
#ifdef GSM_ENABLE_OBEXGEN
-extern GSM_Reply_Function OBEXGENReplyFunctions[];
-extern GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File);
-extern GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos);
-extern GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s);
+#include "../obex/obexgen.h"
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+extern GSM_Reply_Function OBEXGENReplyFunctions[];
+extern GSM_Reply_Function ATGENReplyFunctions[];
static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_Error error;
if (Priv->OBEX) return ERR_NONE;
dbgprintf ("Changing to OBEX\n");
error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX);
if (error != ERR_NONE) return error;
error = s->Protocol.Functions->Terminate(s);
if (error != ERR_NONE) return error;
s->Protocol.Functions = &OBEXProtocol;
error = s->Protocol.Functions->Initialise(s);
if (error != ERR_NONE) {
s->Protocol.Functions = &ATProtocol;
return error;
}
strcpy(s->CurrentConfig->Model,"seobex");
s->Phone.Data.Priv.OBEXGEN.Service = 0;
s->Phone.Functions->DispatchMessage = GSM_DispatchMessage;
s->Phone.Functions->ReplyFunctions = OBEXGENReplyFunctions;
Priv->OBEX = true;
return ERR_NONE;
}
static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s)
{
@@ -97,315 +95,426 @@ static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned
if (error != ERR_EMPTY) return error;
return SONYERIC_SetATMode(s);
}
static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length)
{
GSM_Error error;
GSM_File File;
int Pos = 0;
error = SONYERIC_SetOBEXMode(s);
if (error != ERR_NONE) return error;
strcpy(File.ID_FullName,FileName);
EncodeUnicode(File.Name,FileName,strlen(FileName));
File.Used = Length;
File.Buffer = malloc(Length);
memcpy(File.Buffer,Buffer,Length);
error = ERR_NONE;
while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos);
free(File.Buffer);
if (error != ERR_EMPTY) return error;
return SONYERIC_SetATMode(s);
}
#endif
GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
GSM_ToDoEntry ToDo;
int Pos, num, Loc;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (start) {
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Note->Location = 1;
} else {
Note->Location++;
}
smprintf(s, "Getting calendar note %i\n",Note->Location);
Loc = Note->Location;
Pos = 0;
num = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (Note->EntriesNum != 0) {
num++;
if (num == Loc) return ERR_NONE;
}
}
return ERR_EMPTY;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
GSM_CalendarEntry Calendar;
int Pos, num, Loc;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
if (start) {
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
ToDo->Location = 1;
} else {
ToDo->Location++;
}
smprintf(s,"Getting ToDo %i\n",ToDo->Location);
Loc = ToDo->Location;
Pos = 0;
num = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (ToDo->EntriesNum != 0) {
num++;
if (num == Loc) return ERR_NONE;
}
}
return ERR_EMPTY;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
GSM_ToDoEntry ToDo;
GSM_CalendarEntry Calendar;
int Pos;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s,"Getting ToDo status\n");
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
status->Used = 0;
Pos = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (ToDo.EntriesNum != 0) status->Used++;
}
return ERR_NONE;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
unsigned char req[5000];
int size=0;
smprintf(s,"Adding calendar note\n");
GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar);
return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned char req[5000];
int size=0;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s,"Adding ToDo\n");
GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo);
return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
int Pos,Level = 0,Used;
unsigned char *Buf;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned char Line[2000];
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s,"Deleting all ToDo\n");
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Pos = 0;
Buf = NULL;
Used = 0;
while (1) {
MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
if (strlen(Line) == 0) break;
dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
switch (Level) {
case 0:
if (strstr(Line,"BEGIN:VTODO")) {
Level = 2;
break;
}
Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
strcpy(Buf+Used,Line);
Used=Used+strlen(Line)+3;
Buf[Used-3] = 13;
Buf[Used-2] = 10;
Buf[Used-1] = 0x00;
break;
case 2: /* ToDo note */
if (strstr(Line,"END:VTODO")) {
Level = 0;
}
break;
}
}
error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
// if (Buf != NULL) free(Buf);
return error;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
int Pos,Level = 0,Loc=0,Used;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
unsigned char Line[2000];
unsigned char *Buf;
smprintf(s, "Deleting calendar note %i\n",Note->Location);
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Pos = 0;
Buf = NULL;
Used = 0;
while (1) {
MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
if (strlen(Line) == 0) break;
dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
switch (Level) {
case 0:
if (strstr(Line,"BEGIN:VEVENT")) {
Loc++;
if (Loc == Note->Location) {
Level = 1;
break;
}
}
Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3);
strcpy(Buf+Used,Line);
Used=Used+strlen(Line)+3;
Buf[Used-3] = 13;
Buf[Used-2] = 10;
Buf[Used-1] = 0x00;
break;
case 1: /* Calendar note */
if (strstr(Line,"END:VEVENT")) {
Level = 0;
}
break;
}
}
DumpMessage(s->di.df, s->di.dl, Buf, Used);
error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
if (Buf != NULL) free(Buf);
return error;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
{
-#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
+#ifdef GSM_ENABLE_OBEXGEN
GSM_Error error;
GSM_ToDoEntry ToDo;
GSM_CalendarEntry Calendar;
int Pos;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
smprintf(s, "Getting calendar status\n");
error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
if (error != ERR_NONE) return error;
Status->Used = 0;
Pos = 0;
while (1) {
error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
if (error == ERR_EMPTY) break;
if (error != ERR_NONE) return error;
if (Calendar.EntriesNum != 0) Status->Used++;
}
return ERR_NONE;
#else
return ERR_SOURCENOTAVAILABLE;
#endif
}
-#endif
+GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{ /* Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar
+ License: Whatever the current maintainer of gammulib chooses, as long as there
+ is an easy way to obtain the source under GPL, otherwise the author's parts
+ of this function are GPL 2.0.
+ */
+ GSM_Locale *locale = s->Phone.Data.Locale;
+ char format;
+
+ switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Date settings received\n");
+ format=atoi(msg.Buffer);
+ switch (format) {
+ case 0: locale->DateFormat = GSM_Date_OFF;
+ locale->DateSeparator = 0;
+ break;
+ case 1: locale->DateFormat = GSM_Date_DDMMMYY;
+ locale->DateSeparator = '-';
+ break;
+ case 2: locale->DateFormat = GSM_Date_DDMMYY;
+ locale->DateSeparator = '-';
+ break;
+ case 3: locale->DateFormat = GSM_Date_MMDDYY;
+ locale->DateSeparator = '/';
+ break;
+ case 4: locale->DateFormat = GSM_Date_DDMMYY;
+ locale->DateSeparator = '/';
+ break;
+ case 5: locale->DateFormat = GSM_Date_DDMMYY;
+ locale->DateSeparator = '.';
+ break;
+ case 6: locale->DateFormat = GSM_Date_YYMMDD;
+ locale->DateSeparator = 0;
+ break;
+ case 7: locale->DateFormat = GSM_Date_YYMMDD;
+ locale->DateSeparator = '-';
+ break;
+ default:return ERR_UNKNOWNRESPONSE;
+ }
+ default:
+ return ERR_NOTSUPPORTED;
+ }
+}
+
+GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{ /* Author: Peter Ondraska
+ License: Whatever the current maintainer of gammulib chooses, as long as there
+ is an easy way to obtain the source under GPL, otherwise the author's parts
+ of this function are GPL 2.0.
+ */
+ char format;
+
+ switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
+ case AT_Reply_OK:
+ smprintf(s, "Time settings received\n");
+ format=atoi(msg.Buffer);
+ switch (format) {
+ case 1:
+ case 2: s->Phone.Data.Locale->AMPMTime=(format==2);
+ return ERR_NONE;
+ default:return ERR_UNKNOWNRESPONSE;
+ }
+ default: return ERR_NOTSUPPORTED;
+ }
+}
+
+GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{
+ GSM_Error error;
+
+ s->Phone.Data.Locale = locale;
+
+ smprintf(s, "Getting date format\n");
+ error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale);
+ if (error!=ERR_NONE) return error;
+
+ smprintf(s, "Getting time format\n");
+ return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale);
+}
+
+
+GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
+{ /* Author: Peter Ondraska
+ License: Whatever the current maintainer of gammulib chooses, as long as there
+ is an easy way to obtain the source under GPL, otherwise the author's parts
+ of this function are GPL 2.0.
+ */
+ /* this is not yet supported by gammu.c */
+ int format=0;
+ char req[12];
+
+ if (locale->DateFormat==GSM_Date_OFF) { format=0; } else
+ if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else
+ if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else
+ if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else
+ if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else
+ if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else
+ if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else
+ if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; }
+ else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */
+
+ sprintf(req,"AT+ESDF=%i\r",format);
+ smprintf(s, "Setting date format\n");
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
+
+ if (locale->AMPMTime) { format=2; } else { format=1; }
+ sprintf(req,"AT+ESTF=%i\r",format);
+ smprintf(s, "Setting time format\n");
+ return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale);
+}
+
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,35 +1,38 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail, Pavel Janik, others and Gnokii */
/* resetting DCT4 phones settings (c) by Walek */
+/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include <string.h> /* memcpy only */
#include <stdio.h>
#include <ctype.h>
#include "../../../gsmstate.h"
#include "../../../misc/coding/coding.h"
#include "../../../service/sms/gsmsms.h"
#include "../../pfunc.h"
#include "../nfunc.h"
#include "dct3func.h"
#ifdef GSM_ENABLE_NOKIA_DCT3
GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
{
GSM_Error error;
/* We have to enable WAP frames in phone */
error=DCT3DCT4_EnableWAPFunctions(s);
if (error!=ERR_NONE) return error;
return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
}
GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
{
GSM_Error error;
/* We have to enable WAP frames in phone */
error=DCT3DCT4_EnableWAPFunctions(s);
if (error!=ERR_NONE) return error;
@@ -365,64 +368,65 @@ GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msg
unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03,
0x02, /* Unknown. Not for enabling/disabling */
0x00, /* Hour */
0x00, /* Minute */
0x00}; /* Unknown. Not seconds */
if (alarm->Location != 1) return ERR_NOTSUPPORTED;
req[8] = alarm->DateTime.Hour;
req[9] = alarm->DateTime.Minute;
smprintf(s, "Setting alarm\n");
return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm);
}
GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int i;
GSM_Phone_Data *Data = &s->Phone.Data;
switch (msg.Buffer[3]) {
case 0x34:
smprintf(s, "SMSC received\n");
Data->SMSC->Format = SMS_FORMAT_Text;
switch (msg.Buffer[6]) {
case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager; break;
case 0x32: Data->SMSC->Format = SMS_FORMAT_Email; break;
}
Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat;
Data->SMSC->Validity.Relative = msg.Buffer[8];
+ if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
i=33;
while (msg.Buffer[i]!=0) {i++;}
i=i-33;
if (i>GSM_MAX_SMSC_NAME_LENGTH) {
smprintf(s, "Too long name\n");
return ERR_UNKNOWNRESPONSE;
}
EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i);
smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true);
smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false);
smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
return ERR_NONE;
case 0x35:
smprintf(s, "Getting SMSC failed\n");
return ERR_INVALIDLOCATION;
}
return ERR_UNKNOWNRESPONSE;
}
GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
{
unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64,
0x00}; /* Location */
if (smsc->Location==0x00) return ERR_INVALIDLOCATION;
@@ -430,66 +434,66 @@ GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
s->Phone.Data.SMSC=smsc;
smprintf(s, "Getting SMSC\n");
return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC);
}
GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int count;
GSM_Phone_Data *Data = &s->Phone.Data;
#ifdef DEBUG
GSM_NetworkInfo NetInfo;
char name[100];
smprintf(s, "Network info received\n");
smprintf(s, " Status : ");
switch (msg.Buffer[8]) {
case 0x01: smprintf(s, "home network"); break;
case 0x02: smprintf(s, "roaming network"); break;
case 0x03: smprintf(s, "requesting network"); break;
case 0x04: smprintf(s, "not registered in the network"); break;
default : smprintf(s, "unknown");
}
smprintf(s, "\n");
smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic");
if (msg.Buffer[8]<0x03) {
sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]);
smprintf(s, "CID : %s\n", NetInfo.CID);
sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]);
smprintf(s, "LAC : %s\n", NetInfo.LAC);
- smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode);
+ smprintf(s, "Network code : %s\n", NetInfo.NetworkCode);
smprintf(s, "Network name for Gammu : %s ",
DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode)));
smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode)));
if (msg.Length>18) {
if (msg.Buffer[18]==0x00) {
/* In 6210 name is in "normal" Unicode */
memcpy(name,msg.Buffer+18,msg.Buffer[17]*2);
name[msg.Buffer[17]*2] =0x00;
name[msg.Buffer[17]*2+1]=0x00;
smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
} else {
/* In 9210 first 0x00 is cut from Unicode string */
name[0] = 0;
memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2);
name[msg.Buffer[17]*2+1]=0x00;
name[msg.Buffer[17]*2+2]=0x00;
smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name));
}
}
}
#endif
if (Data->RequestID==ID_GetNetworkInfo) {
Data->NetworkInfo->NetworkName[0] = 0x00;
Data->NetworkInfo->NetworkName[1] = 0x00;
Data->NetworkInfo->State = 0;
switch (msg.Buffer[8]) {
case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break;
case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork; break;
case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork; break;
case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break;
}
@@ -1179,69 +1183,69 @@ GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *setting
pos = 4;
memset(SetReq2 + pos, 0, 200 - pos);
SetReq2[pos++] = phone3;
SetReq2[pos++] = 0x02;
SetReq2[pos++] = 0x02; /* USSD */
if (loc3 != -1) {
if (!settings->Settings[loc3].IsIP) SetReq2[pos] = 0x01;
}
pos++;
if (loc3 != -1) {
/* Service number or IP address */
pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false);
/* Code number */
pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false);
} else pos+=2;
memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
pos += 8;
smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n");
error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet);
if (error != ERR_NONE) return error;
}
error = DCT3DCT4_SetActiveConnectSet(s, settings);
if (error != ERR_NONE) return error;
return DCT3DCT4_DisableConnectionFunctions(s);
}
GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (msg.Buffer[3]) {
case 0x02:
smprintf(s, "SMS sent OK\n");
- if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[5]);
return ERR_NONE;
case 0x03:
smprintf(s, "Error %i\n",msg.Buffer[6]);
- if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0);
+ if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],-1);
return ERR_NONE;
}
return ERR_UNKNOWNRESPONSE;
}
GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
int length;
GSM_Error error;
unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00};
error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true);
if (error != ERR_NONE) return error;
smprintf(s, "Sending sms\n");
return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02);
}
GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (msg.Buffer[3]) {
case 0x00:
smprintf(s, "Netmonitor correctly set\n");
break;
default:
smprintf(s, "Menu %i\n",msg.Buffer[3]);
smprintf(s, "%s\n",msg.Buffer+4);
strcpy(s->Phone.Data.Netmonitor,msg.Buffer+4);
break;
}
return ERR_NONE;
}
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.h b/gammu/emb/common/phone/nokia/dct3/dct3func.h
index 66b67ec..18b2026 100644
--- a/gammu/emb/common/phone/nokia/dct3/dct3func.h
+++ b/gammu/emb/common/phone/nokia/dct3/dct3func.h
@@ -1,37 +1,39 @@
/* (c) 2002-2003 by Marcin Wiacek */
#ifndef phone_nokia_dct3_h
#define phone_nokia_dct3_h
+#include "../ncommon.h"
+
GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyEnableSecurity (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyDialCommand (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetWAPBookmark (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetNetworkInfo (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySendSMSMessage (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyGetWAPSettings (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplySetWAPSettings (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyNetmonitor (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyDeleteSMSMessage (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error N71_92_ReplyGetSignalQuality (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error N71_92_ReplyGetBatteryCharge (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error N71_92_ReplyPhoneSetting (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error N61_91_ReplySetOpLogo (GSM_Protocol_Message msg, GSM_StateMachine *s);
#ifdef GSM_ENABLE_CELLBROADCAST
GSM_Error DCT3_ReplySetIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s);
GSM_Error DCT3_ReplyIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s);
#endif
GSM_Error DCT3_DeleteWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
GSM_Error DCT3_GetWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark);
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,36 +1,38 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail and Gnokii */
-/* Authentication function (c) 1999 or earlier by Pavel Janik */
/* 5210 calendar IDs by Frederick Ros */
+/* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../../gsmstate.h"
#ifdef GSM_ENABLE_NOKIA6110
#include <string.h>
#include "../../../../cfg/config.h"
#include "../../../misc/coding/coding.h"
#include "../../../service/sms/gsmsms.h"
#include "../../../gsmcomon.h"
#include "../../pfunc.h"
#include "../nfunc.h"
#include "n6110.h"
#include "dct3func.h"
static unsigned char N6110_MEMORY_TYPES[] = {
MEM_ME, 0x02,
MEM_SM, 0x03,
MEM_ON, 0x05,
MEM_DC, 0x07,
MEM_RC, 0x08,
MEM_MC, 0x09,
MEM_VM, 0x0b,
0x00, 0x00
};
static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
N6110_Language lang = N6110_Auto;
if (msg.Buffer[3] == 0x15) return ERR_NONE;
@@ -98,64 +100,65 @@ static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const
GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
bool found;
for (o_len = 0; i_len < len; o_len++) {
found = false;
if (Priv->PhoneLanguage != N6110_Auto) {
i = 0;
while(1) {
if (N6110_Lang_Table[i].Lang == 0) break;
if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage &&
N6110_Lang_Table[i].Phone == src[i_len]) {
dest[o_len*2] = N6110_Lang_Table[i].Unicode1;
dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2;
i_len++;
found = true;
break;
}
i++;
}
}
if (!found) {
i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc);
dest[o_len*2] = (wc >> 8) & 0xff;
dest[(o_len*2)+1] = wc & 0xff;
}
}
dest[o_len*2] = 0;
dest[(o_len*2)+1] = 0;
}
#ifndef ENABLE_LGPL
+/* Pavel Janik */
/* This function provides Nokia authentication protocol.
* Nokia authentication protocol is used in the communication between Nokia
* mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
* commercially sold by Nokia Corp.
* The authentication scheme is based on the token send by the phone to the
* software. The software does it's magic (see the function
* N6110_GetNokiaAuthentication) and returns the result back to the phone.
* If the result is correct the phone responds with the message "Accessory
* connected!" displayed on the LCD. Otherwise it will display "Accessory not
* supported" and some functions will not be available for use (?).
* The specification of the protocol is not publicly available, no comment.
*/
static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)
{
int i, j, CRC=0;
unsigned char Temp[16]; /* This is our temporary working area. */
/* Here we put FAC (Final Assembly Code) and serial number into our area. */
Temp[0] = Imei[6]; Temp[1] = Imei[7];
Temp[2] = Imei[8]; Temp[3] = Imei[9];
Temp[4] = Imei[10]; Temp[5] = Imei[11];
Temp[6] = Imei[12]; Temp[7] = Imei[13];
/* And now the TAC (Type Approval Code). */
Temp[8] = Imei[2]; Temp[9] = Imei[3];
Temp[10] = Imei[4]; Temp[11] = Imei[5];
/* And now we pack magic bytes from the phone. */
Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1];
Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3];
for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1;
@@ -795,64 +798,65 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone,
/* We copy UDH now */
memcpy(req+2,UDHHeader.Text,UDHHeader.Length);
*maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+2+UDHHeader.Length, &size);
error = s->Protocol.Functions->WriteMessage(s, req, 2+UDHHeader.Length+size, 0x12);
if (error!=ERR_NONE) return error;
my_sleep(1000);
/* We have to make something (not important, what) now */
/* no answer from phone*/
return DCT3_GetNetworkInfo(s,&NetInfo);
} else {
return ERR_NOTSUPPORTED;
}
}
*maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+7, &size);
req[4] = Ringtone->Location - 1;
smprintf(s, "Setting ringtone\n");
return GSM_WaitFor (s, req, 7 + size, 0x05, 4, ID_SetRingtone);
case RING_NOKIABINARY:
error=DCT3_EnableSecurity (s, 0x01);
if (error!=ERR_NONE) return error;
memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name));
current += UnicodeLength(Ringtone->Name);
reqBin[current++] = 0x00;
reqBin[current++] = 0x00;
reqBin[current++] = 0x00;/*xxx*/
memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
current=current+Ringtone->NokiaBinary.Length;
reqBin[3]=Ringtone->Location-1;
if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10;
smprintf(s, "Setting binary ringtone\n");
return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone);
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
}
return ERR_NOTSUPPORTED;
}
static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int count=5;
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Operator logo received\n");
NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode);
count = count + 3;
smprintf(s, "Network code : %s\n", Data->Bitmap->NetworkCode);
smprintf(s, "Network name for Gammu : %s ",
DecodeUnicodeString(GSM_GetNetworkName(Data->Bitmap->NetworkCode)));
smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(Data->Bitmap->NetworkCode)));
count = count + 3; /* We ignore size */
Data->Bitmap->BitmapWidth = msg.Buffer[count++];
Data->Bitmap->BitmapHeight = msg.Buffer[count++];
count++;
PHONE_DecodeBitmap(GSM_NokiaOperatorLogo,msg.Buffer+count,Data->Bitmap);
return ERR_NONE;
}
static GSM_Error N6110_ReplyGetStartup(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int i, count = 5;
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Startup logo & notes received\n");
@@ -1495,101 +1499,103 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
while (msg.Buffer[i]!=0) {
i++;
if (i>msg.Length) return ERR_EMPTY;
}
EncodeUnicode(Data->Ringtone->Name,msg.Buffer+8,i-8);
smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
/* Looking for start && end */
end=0;start=0;i=0;
while (true) {
if (start!=0) {
if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
end=i+2; break;
}
if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
end=i+2; break;
}
} else {
if (msg.Buffer[i]==0x02 && msg.Buffer[i+1]==0xfc && msg.Buffer[i+2]==0x09) {
start = i;
}
}
i++;
if (i==msg.Length-3) return ERR_EMPTY;
}
/* Copying frame */
memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start);
Data->Ringtone->NokiaBinary.Length=end-start;
#ifdef DEBUG
if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length);
#endif
return ERR_NONE;
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
}
smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format);
break;
default:
smprintf(s, "Invalid location. Too high ?\n");
return ERR_INVALIDLOCATION;
}
return ERR_UNKNOWNRESPONSE;
}
static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
{
GSM_Error error;
unsigned char req[] = {0x00, 0x01, 0x9e,
0x00}; /* location */
if (PhoneRingtone) return ERR_NOTSUPPORTED;
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NORING)) return ERR_NOTSUPPORTED;
if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
if (Ringtone->Format == 0x00) {
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) {
Ringtone->Format = RING_NOTETONE;
} else {
Ringtone->Format = RING_NOKIABINARY;
}
}
switch (Ringtone->Format) {
case RING_NOTETONE:
if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
break;
case RING_NOKIABINARY:
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED;
break;
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
}
error=DCT3_EnableSecurity (s, 0x01);
if (error!=ERR_NONE) return error;
req[3]=Ringtone->Location-1;
s->Phone.Data.Ringtone=Ringtone;
smprintf(s, "Getting (binary) ringtone\n");
return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone);
}
static GSM_Error N6110_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
*s->Phone.Data.SecurityStatus = msg.Buffer[4];
#ifdef DEBUG
smprintf(s, "Security code status\n");
switch(msg.Buffer[4]) {
case SEC_SecurityCode: smprintf(s, "waiting for Security Code.\n"); break;
case SEC_Pin : smprintf(s, "waiting for PIN.\n"); break;
case SEC_Pin2 : smprintf(s, "waiting for PIN2.\n"); break;
case SEC_Puk : smprintf(s, "waiting for PUK.\n"); break;
case SEC_Puk2 : smprintf(s, "waiting for PUK2.\n"); break;
case SEC_None : smprintf(s, "nothing to enter.\n"); break;
default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
return ERR_UNKNOWNRESPONSE;
}
#endif
return ERR_NONE;
}
@@ -2414,66 +2420,66 @@ static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntr
unsigned char req[] = {N6110_FRAME_HEADER, 0x66,
0x00}; /* Location */
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED;
if (start) {
Priv->LastCalendarPos = 1;
} else {
Priv->LastCalendarPos++;
}
Note->Location = Priv->LastCalendarPos;
req[4] = Priv->LastCalendarPos;
s->Phone.Data.Cal=Note;
smprintf(s, "Getting calendar note\n");
error=GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNote);
GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(Note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
/* 2090 year is set for example in 3310 */
if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) {
error=N6110_GetDateTime(s, &date_time);
if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year;
}
return error;
}
GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
unsigned char buffer[2000],buffer2[4000];
int tmp;
- tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, msg.Buffer+8, buffer);
- msg.Buffer[tmp] = 0;
+ tmp=GSM_UnpackEightBitsToSeven(0, msg.Buffer[7], 82, msg.Buffer+8, buffer);
+ buffer[tmp] = 0;
smprintf(s, "USSD reply: \"%s\"\n",buffer);
if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
EncodeUnicode(buffer2,buffer,strlen(buffer));
s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
}
return ERR_NONE;
}
GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
{
GSM_Error error;
unsigned char req1[] = {N6110_FRAME_HEADER, 0x42, 0x05, 0x01,
0x07, 0xa2, 0x88, 0x81, 0x21, 0x15, 0x63, 0xa8,
0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15,
0x63, 0x80};
if (!all) {
smprintf(s, "Answering call part 1\n");
error = GSM_WaitFor (s, req1, 24, 0x01, 5, ID_AnswerCall);
if (error != ERR_NONE) return error;
return DCT3DCT4_AnswerCall(s,ID);
}
return DCT3_AnswerAllCalls(s);
}
static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
{
unsigned int pos = 4;
@@ -2778,107 +2784,108 @@ GSM_Phone_Functions N6110Phone = {
DCT3_PressKey,
DCT3_Reset,
N61_71_ResetPhoneSettings,
N6110_EnterSecurityCode,
N6110_GetSecurityStatus,
N6110_GetDisplayStatus,
NOTIMPLEMENTED, /* SetAutoNetworkLogin */
N6110_GetBatteryCharge,
N6110_GetSignalQuality,
DCT3_GetNetworkInfo,
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
N6110_GetMemoryStatus,
N6110_GetMemory,
NOTIMPLEMENTED, /* GetNextMemory */
N6110_SetMemory,
NOTIMPLEMENTED, /* AddMemory */
N6110_DeleteMemory,
NOTIMPLEMENTED, /* DeleteAllMemory */
N6110_GetSpeedDial,
NOTIMPLEMENTED, /* SetSpeedDial */
DCT3_GetSMSC,
DCT3_SetSMSC,
DCT3_GetSMSStatus,
N6110_GetSMSMessage,
N6110_GetNextSMSMessage,
N6110_SetSMS,
N6110_AddSMS,
N6110_DeleteSMSMessage,
DCT3_SendSMSMessage,
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOKIA_SetIncomingSMS,
DCT3_SetIncomingCB,
PHONE_GetSMSFolders,
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
N6110_DialVoice,
N6110_AnswerCall,
DCT3_CancelCall,
N6110_HoldCall,
N6110_UnholdCall,
N6110_ConferenceCall,
N6110_SplitCall,
N6110_TransferCall,
N6110_SwitchCall,
DCT3DCT4_GetCallDivert,
DCT3DCT4_SetCallDivert,
DCT3DCT4_CancelAllDiverts,
NOKIA_SetIncomingCall,
NOKIA_SetIncomingUSSD,
DCT3DCT4_SendDTMF,
N6110_GetRingtone,
N6110_SetRingtone,
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
DCT3_PlayTone,
DCT3_GetWAPBookmark,
DCT3_SetWAPBookmark,
DCT3_DeleteWAPBookmark,
DCT3_GetWAPSettings,
DCT3_SetWAPSettings,
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
N6110_GetBitmap,
N6110_SetBitmap,
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
NOTIMPLEMENTED, /* GetCalendarStatus */
NOTIMPLEMENTED, /* GetCalendar */
N6110_GetNextCalendarNote,
NOTIMPLEMENTED, /* SetCalendar */
N6110_AddCalendarNote,
N6110_DeleteCalendarNote,
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
N6110_GetProfile,
N6110_SetProfile,
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFile */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,34 +1,37 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail and Gnokii */
+/* based on some Markus Plail work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../../gsmstate.h"
#ifdef GSM_ENABLE_NOKIA7110
#include <string.h>
#include <time.h>
#include "../../../misc/coding/coding.h"
#include "../../../gsmcomon.h"
#include "../../../service/gsmlogo.h"
#include "../../pfunc.h"
#include "../nfunc.h"
#include "../nfuncold.h"
#include "n7110.h"
#include "dct3func.h"
static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
{
return DCT3_GetAlarm(s, alarm, 0x19);
}
static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
{
return DCT3_SetAlarm(s, alarm, 0x19);
}
static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Phonebook entry received\n");
@@ -497,64 +500,65 @@ static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
}
i++;
if (i==msg.Length) return ERR_EMPTY;
}
/* Copying frame */
memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37);
Data->Ringtone->NokiaBinary.Length=i-37;
return ERR_NONE;
case 0x24:
smprintf(s, "Invalid location. Too high ?\n");
return ERR_INVALIDLOCATION;
}
return ERR_UNKNOWNRESPONSE;
}
static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
{
unsigned char req[] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00};
if (PhoneRingtone) return ERR_NOTSUPPORTED;
if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
switch (Ringtone->Format) {
case RING_NOTETONE:
/* In the future get binary and convert */
return ERR_NOTSUPPORTED;
case RING_NOKIABINARY:
req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
s->Phone.Data.Ringtone=Ringtone;
smprintf(s, "Getting binary ringtone\n");
return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone);
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
}
return ERR_NOTSUPPORTED;
}
static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int i;
GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
smprintf(s, "Received info for Picture Images\n");
smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]);
smprintf(s, "Locations :");
Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
for (i=0;i<Priv->LastPictureImageFolder.Number;i++) {
Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2];
smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]);
}
smprintf(s, "\n");
return ERR_NONE;
}
static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location)
{
GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
GSM_SMSFolders folders;
GSM_Error error;
int i, j = 0, count = 0;
unsigned char req[] = {N6110_FRAME_HEADER, 0x96,
0x00, /* Folder ID */
0x0f, 0x07};
@@ -1618,107 +1622,108 @@ GSM_Phone_Functions N7110Phone = {
DCT3_PressKey,
DCT3_Reset,
N61_71_ResetPhoneSettings,
NOTSUPPORTED, /* EnterSecurityCode */
NOTSUPPORTED, /* GetSecurityStatus */
NOTSUPPORTED, /* GetDisplayStatus */
NOTIMPLEMENTED, /* SetAutoNetworkLogin */
N71_92_GetBatteryCharge,
N71_92_GetSignalQuality,
DCT3_GetNetworkInfo,
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
N7110_GetMemoryStatus,
N7110_GetMemory,
NOTIMPLEMENTED, /* GetNextMemory */
N7110_SetMemory,
NOTIMPLEMENTED, /* AddMemory */
N7110_DeleteMemory,
NOTIMPLEMENTED, /* DeleteAllMemory */
N7110_GetSpeedDial,
NOTIMPLEMENTED, /* SetSpeedDial */
DCT3_GetSMSC,
DCT3_SetSMSC,
N7110_GetSMSStatus,
N7110_GetSMSMessage,
N7110_GetNextSMSMessage,
N7110_SetSMS,
N7110_AddSMS,
N7110_DeleteSMS,
DCT3_SendSMSMessage,
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
N7110_SetIncomingSMS,
DCT3_SetIncomingCB,
N7110_GetSMSFolders,
NOTIMPLEMENTED, /* AddSMSFolder */
NOTIMPLEMENTED, /* DeleteSMSFolder */
DCT3_DialVoice,
N7110_AnswerCall,
DCT3_CancelCall,
NOTIMPLEMENTED, /* HoldCall */
NOTIMPLEMENTED, /* UnholdCall */
NOTIMPLEMENTED, /* ConferenceCall */
NOTIMPLEMENTED, /* SplitCall */
NOTIMPLEMENTED, /* TransferCall */
NOTIMPLEMENTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
N7110_SetCallDivert,
N7110_CancelAllDiverts,
N7110_SetIncomingCall,
N7110_SetIncomingUSSD,
DCT3DCT4_SendDTMF,
N7110_GetRingtone,
N7110_SetRingtone,
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
DCT3_PlayTone,
DCT3_GetWAPBookmark,
DCT3_SetWAPBookmark,
DCT3_DeleteWAPBookmark,
DCT3_GetWAPSettings,
DCT3_SetWAPSettings,
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
N7110_GetBitmap,
N7110_SetBitmap,
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
N7110_GetCalendarStatus,
NOTIMPLEMENTED, /* GetCalendar */
N7110_GetNextCalendar,
NOTIMPLEMENTED, /* SetCalendar */
N7110_AddCalendar,
N71_65_DelCalendar,
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
N7110_GetProfile,
N7110_SetProfile,
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFile */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -290,107 +290,108 @@ GSM_Phone_Functions N9210Phone = {
NOTIMPLEMENTED, /* PressKey */
NOTIMPLEMENTED, /* Reset */
NOTIMPLEMENTED, /* ResetPhoneSettings */
NOTSUPPORTED, /* EnterSecurityCode */
NOTSUPPORTED, /* GetSecurityStatus */
NOTSUPPORTED, /* GetDisplayStatus */
NOTIMPLEMENTED, /* SetAutoNetworkLogin */
N71_92_GetBatteryCharge,
N71_92_GetSignalQuality,
DCT3_GetNetworkInfo,
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
NOTIMPLEMENTED, /* GetMemoryStatus */
NOTIMPLEMENTED, /* GetMemory */
NOTIMPLEMENTED, /* GetNextMemory */
NOTIMPLEMENTED, /* SetMemory */
NOTIMPLEMENTED, /* AddMemory */
NOTIMPLEMENTED, /* DeleteMemory */
NOTIMPLEMENTED, /* DeleteAllMemory */
NOTIMPLEMENTED, /* GetSpeedDial */
NOTIMPLEMENTED, /* SetSpeedDial */
DCT3_GetSMSC,
DCT3_SetSMSC, /* FIXME: test it */
NOTIMPLEMENTED, /* GetSMSStatus */
NOTIMPLEMENTED, /* GetSMS */
NOTIMPLEMENTED, /* GetNextSMS */
NOTIMPLEMENTED, /* SetSMS */
NOTIMPLEMENTED, /* AddSMS */
NOTIMPLEMENTED, /* DeleteSMS */
DCT3_SendSMSMessage,
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
N9210_SetIncomingSMS,
DCT3_SetIncomingCB,
NOTIMPLEMENTED, /* GetSMSFolders */
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
DCT3_DialVoice,
N9210_AnswerCall,
DCT3_CancelCall,
NOTSUPPORTED, /* HoldCall */
NOTSUPPORTED, /* UnholdCall */
NOTSUPPORTED, /* ConferenceCall */
NOTSUPPORTED, /* SplitCall */
NOTSUPPORTED, /* TransferCall */
NOTSUPPORTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NOTSUPPORTED, /* SetIncomingCall */
NOTIMPLEMENTED, /* SetIncomingUSSD */
NOTSUPPORTED, /* SendDTMF */
NOTIMPLEMENTED, /* GetRingtone */
NOTIMPLEMENTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTIMPLEMENTED, /* GetWAPBookmark */
NOTIMPLEMENTED, /* SetWAPBookmark */
NOTIMPLEMENTED, /* DeleteWAPBookmark */
NOTIMPLEMENTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
N9210_GetBitmap,
N9210_SetBitmap,
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
NOTSUPPORTED, /* GetCalendarStatus */
NOTSUPPORTED, /* GetCalendar */
NOTSUPPORTED, /* GetNextCalendar */
NOTSUPPORTED, /* SetCalendar */
NOTSUPPORTED, /* AddCalendar */
NOTSUPPORTED, /* DeleteCalendar */
NOTSUPPORTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTIMPLEMENTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFile */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -165,107 +165,108 @@ GSM_Phone_Functions N3320Phone = {
NOTSUPPORTED, /* PressKey */
NOTSUPPORTED, /* Reset */
NOTSUPPORTED, /* ResetPhoneSettings */
NOTSUPPORTED, /* EnterSecurityCode */
NOTSUPPORTED, /* GetSecurityStatus */
NOTSUPPORTED, /* GetDisplayStatus */
NOTSUPPORTED, /* SetAutoNetworkLogin */
NOTSUPPORTED, /* GetBatteryCharge */
NOTSUPPORTED, /* GetSignalQuality */
NOTSUPPORTED, /* GetNetworkInfo */
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
N3320_GetMemoryStatus,
N3320_GetMemory,
NOTSUPPORTED, /* GetNextMemory */
NOTSUPPORTED, /* SetMemory */
NOTSUPPORTED, /* AddMemory */
NOTSUPPORTED, /* DeleteMemory */
NOTIMPLEMENTED, /* DeleteAllMemory */
NOTSUPPORTED, /* GetSpeedDial */
NOTSUPPORTED, /* SetSpeedDial */
NOTSUPPORTED, /* GetSMSC */
NOTSUPPORTED, /* SetSMSC */
NOTSUPPORTED, /* GetSMSStatus */
NOTSUPPORTED, /* GetSMS */
NOTSUPPORTED, /* GetNextSMS */
NOTSUPPORTED, /* SetSMS */
NOTSUPPORTED, /* AddSMS */
NOTSUPPORTED, /* DeleteSMS */
NOTSUPPORTED, /* SendSMS */
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
NOTSUPPORTED, /* SetIncomingCB */
NOTSUPPORTED, /* GetSMSFolders */
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
NOTIMPLEMENTED, /* DialVoice */
NOTIMPLEMENTED, /* AnswerCall */
NOTIMPLEMENTED, /* CancelCall */
NOTIMPLEMENTED, /* HoldCall */
NOTIMPLEMENTED, /* UnholdCall */
NOTIMPLEMENTED, /* ConferenceCall */
NOTIMPLEMENTED, /* SplitCall */
NOTIMPLEMENTED, /* TransferCall */
NOTIMPLEMENTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NOTIMPLEMENTED, /* SetIncomingCall */
NOTIMPLEMENTED, /* SetIncomingUSSD */
NOTSUPPORTED, /* SendDTMF */
NOTSUPPORTED, /* GetRingtone */
NOTSUPPORTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTIMPLEMENTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
NOTSUPPORTED, /* GetBitmap */
NOTSUPPORTED, /* SetBitmap */
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
N3320_GetCalendarStatus,
NOTIMPLEMENTED, /* GetCalendar */
N3320_GetNextCalendar,
NOTIMPLEMENTED, /* SetCalendar */
NOTSUPPORTED, /* AddCalendar */
NOTSUPPORTED, /* DeleteCalendar */
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTIMPLEMENTED, /* AddFilePart */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTIMPLEMENTED, /* DeleteFile */
NOTIMPLEMENTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -286,107 +286,108 @@ GSM_Phone_Functions N3650Phone = {
NOTSUPPORTED, /* PressKey */
DCT4_Reset,
NOTSUPPORTED, /* ResetPhoneSettings */
NOTSUPPORTED, /* EnterSecurityCode */
NOTSUPPORTED, /* GetSecurityStatus */
NOTSUPPORTED, /* GetDisplayStatus */
NOTSUPPORTED, /* SetAutoNetworkLogin */
NOTSUPPORTED, /* GetBatteryCharge */
NOTSUPPORTED, /* GetSignalQuality */
NOTSUPPORTED, /* GetNetworkInfo */
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
NOTSUPPORTED, /* GetMemoryStatus */
NOTSUPPORTED, /* GetMemory */
NOTSUPPORTED, /* GetNextMemory */
NOTSUPPORTED, /* SetMemory */
NOTSUPPORTED, /* AddMemory */
NOTSUPPORTED, /* DeleteMemory */
NOTIMPLEMENTED, /* DeleteAllMemory */
NOTSUPPORTED, /* GetSpeedDial */
NOTSUPPORTED, /* SetSpeedDial */
NOTSUPPORTED, /* GetSMSC */
NOTSUPPORTED, /* SetSMSC */
NOTSUPPORTED, /* GetSMSStatus */
NOTSUPPORTED, /* GetSMS */
NOTSUPPORTED, /* GetNextSMS */
NOTSUPPORTED, /* SetSMS */
NOTSUPPORTED, /* AddSMS */
NOTSUPPORTED, /* DeleteSMS */
NOTSUPPORTED, /* SendSMS */
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
NOTSUPPORTED, /* SetIncomingCB */
NOTSUPPORTED, /* GetSMSFolders */
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
NOTIMPLEMENTED, /* DialVoice */
NOTIMPLEMENTED, /* AnswerCall */
NOTIMPLEMENTED, /* CancelCall */
NOTIMPLEMENTED, /* HoldCall */
NOTIMPLEMENTED, /* UnholdCall */
NOTIMPLEMENTED, /* ConferenceCall */
NOTIMPLEMENTED, /* SplitCall */
NOTIMPLEMENTED, /* TransferCall */
NOTIMPLEMENTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NOTIMPLEMENTED, /* SetIncomingCall */
NOTIMPLEMENTED, /* SetIncomingUSSD */
NOTSUPPORTED, /* SendDTMF */
NOTSUPPORTED, /* GetRingtone */
NOTSUPPORTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTIMPLEMENTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
NOTSUPPORTED, /* GetBitmap */
NOTSUPPORTED, /* SetBitmap */
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
NOTIMPLEMENTED, /* GetCalendarStatus */
NOTIMPLEMENTED, /* GetCalendar */
NOTSUPPORTED, /* GetNextCalendar */
NOTIMPLEMENTED, /* SetCalendar */
NOTSUPPORTED, /* AddCalendar */
NOTSUPPORTED, /* DeleteCalendar */
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
N3650_GetNextFileFolder,
N3650_GetFilePart,
NOTIMPLEMENTED, /* AddFilePart */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTIMPLEMENTED, /* DeleteFile */
NOTIMPLEMENTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,34 +1,37 @@
/* (c) 2002-2004 by Marcin Wiacek */
-/* based on some work from Markus Plail, Pawel Kot and Gnokii */
+/* based on some Markus Plail, Pawel Kot work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
/* function for making CRC for filesystem (c) 2003 by Michael Schroeder */
#include "../../../gsmstate.h"
#ifdef GSM_ENABLE_NOKIA6510
#include <string.h>
#include <time.h>
#include "../../../misc/coding/coding.h"
#include "../../../gsmcomon.h"
#include "../../../service/gsmlogo.h"
#include "../nfunc.h"
#include "../nfuncold.h"
#include "../../pfunc.h"
#include "dct4func.h"
#include "n6510.h"
static GSM_Error N6510_Initialise (GSM_StateMachine *s)
{
s->Phone.Data.Priv.N6510.CalendarIconsNum = 0;
/* Enables various things like incoming SMS, call info, etc. */
return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17\x39", 7);
}
static GSM_Error N6510_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "Phonebook entry received\n");
switch (msg.Buffer[6]) {
case 0x0f:
return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
@@ -90,64 +93,66 @@ static GSM_Error N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *St
s->Phone.Data.MemoryStatus=Status;
smprintf(s, "Getting memory status\n");
return GSM_WaitFor (s, req, 10, 0x03, 4, ID_GetMemoryStatus);
}
static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int i, current, j;
GSM_Phone_Data *Data = &s->Phone.Data;
switch (msg.Buffer[4]) {
case 0x00:
smprintf(s, "SMSC received\n");
break;
case 0x02:
smprintf(s, "SMSC empty\n");
return ERR_INVALIDLOCATION;
default:
smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]);
return ERR_UNKNOWNRESPONSE;
}
memset(Data->SMSC,0,sizeof(GSM_SMSC));
Data->SMSC->Location = msg.Buffer[8];
Data->SMSC->Format = SMS_FORMAT_Text;
switch (msg.Buffer[10]) {
case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break;
case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break;
case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager; break;
case 0x32: Data->SMSC->Format = SMS_FORMAT_Email; break;
}
Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat;
Data->SMSC->Validity.Relative = msg.Buffer[12];
+ if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time;
+
current = 14;
for (i=0;i<msg.Buffer[13];i++) {
switch (msg.Buffer[current]) {
case 0x81:
j=current+4;
while (msg.Buffer[j]!=0) {j++;}
j=j-33;
if (j>GSM_MAX_SMSC_NAME_LENGTH) {
smprintf(s, "Too long name\n");
return ERR_UNKNOWNRESPONSE;
}
CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4);
smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name));
break;
case 0x82:
switch (msg.Buffer[current+2]) {
case 0x01:
GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+current+4,true);
smprintf(s, " Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber));
break;
case 0x02:
GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+current+4,false);
smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number));
break;
default:
smprintf(s, "Unknown SMSC number: %02x\n",msg.Buffer[current+2]);
return ERR_UNKNOWNRESPONSE;
}
break;
default:
smprintf(s, "Unknown SMSC block: %02x\n",msg.Buffer[current]);
return ERR_UNKNOWNRESPONSE;
@@ -956,69 +961,69 @@ static GSM_Error N6510_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *
return GSM_WaitFor (s, req, 9, 0x0a, 4, ID_GetSignalQuality);
}
static GSM_Error N6510_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Battery level received: %i\n",msg.Buffer[9]*100/7);
Data->BatteryCharge->BatteryPercent = ((int)(msg.Buffer[9]*100/7));
Data->BatteryCharge->ChargeState = 0;
return ERR_NONE;
}
static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat)
{
unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x02, 0x00};
s->Phone.Data.BatteryCharge = bat;
smprintf(s, "Getting battery level\n");
return GSM_WaitFor (s, req, 6, 0x17, 4, ID_GetBatteryCharge);
}
static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true);
}
static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Operator logo received\n");
+ if (msg.Length == 18) return ERR_EMPTY;
NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode);
smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode);
Data->Bitmap->BitmapWidth = msg.Buffer[20];
Data->Bitmap->BitmapHeight = msg.Buffer[21];
- if (msg.Length == 18) return ERR_EMPTY;
PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap);
return ERR_NONE;
}
GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "Phonebook entry deleted\n");
return ERR_NONE;
}
GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
{
unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x55, 0x01,
0x04, 0x55, 0x00, 0x10, 0xFF, 0x02,
0x00, 0x01, /* location */
0x00, 0x00, 0x00, 0x00,
0x05, /* memory type */
0x55, 0x55, 0x55};
req[12] = entry->Location / 256;
req[13] = entry->Location % 256;
req[18] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
if (req[18]==0xff) return ERR_NOTSUPPORTED;
smprintf(s, "Deleting phonebook entry\n");
return GSM_WaitFor (s, req, 22, 0x03, 4, ID_SetMemory);
}
static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
{
int count = 22, blocks;
@@ -1736,65 +1741,66 @@ static GSM_Error N6510_ReplyGetSyncMLName(GSM_Protocol_Message msg, GSM_StateMac
{
GSM_SyncMLSettings *Sett = s->Phone.Data.SyncMLSettings;
smprintf(s, "SyncML names received OK\n");
CopyUnicodeString(Sett->Name,msg.Buffer+18);
return ERR_NONE;
}
static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings *settings)
{
GSM_Error error;
// unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x05,
// 0x00, 0x00, 0x00, 0x31, 0x00,
// 0x06, 0x00, 0x00, 0x00, 0xDE, 0x00, 0x00};
// unsigned char GetActive[] = {N6110_FRAME_HEADER, 0x05,
// 0x00, 0x00, 0x00, 0x31, 0x00,
// 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
unsigned char req[] = {N6110_FRAME_HEADER, 0x05,
0x00, 0x00, 0x00, 0x31, 0x00,
0x01, //location
0x00, 0x00, 0x02, 0x46, 0x00, 0x00};
settings->Connection.Location = settings->Location;
error = N6510_GetConnectionSettings(s, &settings->Connection, N6510_SYNCML_SETTINGS);
if (error != ERR_NONE) return error;
settings->Active = settings->Connection.Active;
settings->Name[0] = 0;
settings->Name[1] = 0;
-// s->Phone.Data.SyncMLSettings = settings;
+ s->Phone.Data.SyncMLSettings = settings;
+
// smprintf(s, "Getting SyncML settings name\n");
// error = GSM_WaitFor (s, NameReq, 16, 0x43, 4, ID_GetSyncMLName);
// if (error != ERR_NONE) return error;
req[9] = settings->Location - 1;
smprintf(s, "Getting additional SyncML settings\n");
return GSM_WaitFor (s, req, 16, 0x43, 4, ID_GetSyncMLSettings);
}
static GSM_Error N6510_ReplyGetChatSettings(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_ChatSettings *Sett = s->Phone.Data.ChatSettings;
int i;
Sett->Name[0] = 0;
Sett->Name[1] = 0;
Sett->HomePage[0] = 0;
Sett->HomePage[1] = 0;
Sett->User[0] = 0;
Sett->User[1] = 0;
Sett->Password[0] = 0;
Sett->Password[1] = 0;
switch(msg.Buffer[3]) {
case 0x3B:
smprintf(s, "Chat settings received OK\n");
memcpy(Sett->Name,msg.Buffer+20,msg.Buffer[12]*2);
Sett->Name[msg.Buffer[12]*2] = 0;
Sett->Name[msg.Buffer[12]*2+1] = 0;
memcpy(Sett->HomePage,msg.Buffer+20+msg.Buffer[12]*2,msg.Buffer[15]*2);
Sett->HomePage[msg.Buffer[15]*2] = 0;
Sett->HomePage[msg.Buffer[15]*2+1] = 0;
@@ -2254,65 +2260,65 @@ static GSM_Error N6510_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_State
}
return ERR_UNKNOWNRESPONSE;
}
static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
unsigned char folderid;
int location;
unsigned char req[] = {N6110_FRAME_HEADER, 0x04,
0x01, /* 0x01=SM, 0x02=ME */
0x00, /* FolderID */
0x00, 0x02, /* Location */
0x0F, 0x55};
N6510_GetSMSLocation(s, sms, &folderid, &location);
switch (folderid) {
case 0x01: req[5] = 0x02; break; /* INBOX SIM */
case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */
default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders */
}
req[6]=location / 256;
req[7]=location;
smprintf(s, "Deleting sms\n");
return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage);
}
static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (msg.Buffer[8]) {
case 0x00:
- smprintf(s, "SMS sent OK, TPMR for sent sms is %02x\n",msg.Buffer[10]);
+ smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]);
if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]);
return ERR_NONE;
default:
smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]);
if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]);
return ERR_NONE;
}
}
static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
{
int length = 11;
GSM_Error error;
GSM_SMSMessageLayout Layout;
unsigned char req [300] = {
N6110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x55, 0x55};
if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit;
memset(req+9,0x00,sizeof(req) - 9);
error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length);
if (error != ERR_NONE) return error;
smprintf(s, "Sending sms\n");
return s->Protocol.Functions->WriteMessage(s, req, length + 9, 0x02);
}
static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_Phone_Data *Data = &s->Phone.Data;
smprintf(s, "Security Code status received: ");
switch (msg.Buffer[4]) {
@@ -2741,64 +2747,65 @@ static GSM_Error N6510_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi
}
}
/* Copying frame */
memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+tmp,i-tmp);
Data->Ringtone->NokiaBinary.Length=i-tmp;
return ERR_NONE;
}
static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
{
GSM_AllRingtonesInfo Info;
GSM_Error error;
unsigned char req2[6] = {N7110_FRAME_HEADER, 0x12,
0x00, 0xe7}; /* Location */
if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
switch (Ringtone->Format) {
case RING_NOTETONE:
/* In the future get binary and convert */
return ERR_NOTSUPPORTED;
case RING_NOKIABINARY:
s->Phone.Data.Ringtone = Ringtone;
Info.Number = 0;
error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone);
if (error != ERR_NONE) return error;
if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION;
req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256;
req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256;
smprintf(s, "Getting binary ringtone\n");
return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone);
case RING_MIDI:
+ case RING_MMF:
return ERR_NOTSUPPORTED;
}
return ERR_NOTSUPPORTED;
}
static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start)
{
GSM_Error error;
unsigned char reqStart[] = {
0x00,0x06,0x01,0x00,0x07,0x00 };
unsigned char reqPlay[] = {
0x00,0x06,0x01,0x14,0x05,0x04,
0x00,0x00,0x00,0x03,0x03,0x08,
0x00,0x00,0x00,0x01,0x00,0x00,
0x03,0x08,0x01,0x00,
0x07,0xd0, /*Frequency */
0x00,0x00,0x03,0x08,0x02,0x00,0x00,
0x05, /*Volume */
0x00,0x00};
unsigned char reqOff[] = {
0x00,0x06,0x01,0x14,0x05,0x05,
0x00,0x00,0x00,0x01,0x03,0x08,
0x05,0x00,0x00,0x08,0x00,0x00};
// unsigned char reqOff2[] = {
// 0x00,0x06,0x01,0x14,0x05,0x04,
// 0x00,0x00,0x00,0x01,0x03,0x08,
// 0x00,0x00,0x00,0x00,0x00,0x00};
if (start) {
smprintf(s, "Enabling sound - part 1\n");
error=GSM_WaitFor (s, reqStart, 6, 0x0b, 4, ID_PlayTone);
if (error!=ERR_NONE) return error;
@@ -2957,64 +2964,67 @@ static GSM_Error N6510_ReplyGetProfile(GSM_Protocol_Message msg, GSM_StateMachin
CopyUnicodeString(Data->Profile->Name,blockstart + 7);
smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name));
Data->Profile->DefaultName = false;
break;
default:
NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false);
}
blockstart = blockstart + blockstart[0];
}
return ERR_NONE;
case 0x06:
Data->Profile->Active = false;
if (Data->Profile->Location == msg.Buffer[5]) Data->Profile->Active = true;
return ERR_NONE;
}
return ERR_UNKNOWNRESPONSE;
}
static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
{
unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01};
unsigned char reqActive[] = {N6110_FRAME_HEADER, 0x05};
int i, length = 7;
GSM_Error error;
/* For now !!! */
if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) {
if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED;
}
if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) {
return ERR_NOTSUPPORTED;
}
+ if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) {
+ return ERR_NOTSUPPORTED;
+ }
if (Profile->Location>5) return ERR_INVALIDLOCATION;
for (i = 0; i < 0x0a; i++) {
req[length++] = 0x04;
req[length++] = Profile->Location;
req[length++] = i;
req[length++] = 0x01;
}
req[length++] = 0x04;
req[length++] = Profile->Location;
req[length++] = 0x0c;
req[length++] = 0x01;
req[length++] = 0x04;
Profile->CarKitProfile = false;
Profile->HeadSetProfile = false;
Profile->FeaturesNumber = 0;
s->Phone.Data.Profile=Profile;
smprintf(s, "Getting profile\n");
error = GSM_WaitFor (s, req, length, 0x39, 4, ID_GetProfile);
if (error != ERR_NONE) return error;
smprintf(s, "Checking, which profile is active\n");
return GSM_WaitFor (s, reqActive, 4, 0x39, 4, ID_GetProfile);
}
static GSM_Error N6510_ReplySetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s)
@@ -3086,162 +3096,192 @@ static GSM_Error N6510_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
req[length + 3] = req[length + 7] = Value;
blocks++;
length += 9;
}
}
smprintf(s, "Setting profile\n");
return GSM_WaitFor (s, req, length, 0x39, 4, ID_SetProfile);
}
static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_SMSMessage sms;
#ifdef DEBUG
smprintf(s, "SMS message received\n");
N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
#endif
if (s->Phone.Data.EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
sms.State = SMS_UnRead;
sms.InboxFolder = true;
N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10);
s->User.IncomingSMS(s->CurrentConfig->Device,sms);
}
return ERR_NONE;
}
static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
{
+ unsigned int pos2 = 15;
unsigned int pos = 4;
+ unsigned char req2[100] = {N6110_FRAME_HEADER,0x01,
+ 0x00,0x02,0x07,0x04,
+ 0x01, // 1 - voice, 2 - data
+ 0x00,0x03,
+ 0x18, // length of rest + 1
+ 0x00,0x00,0x00};
unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
0x0c}; /* Number length */
+ GSM_Error error;
+
+ /* USSD not supported */
+ if (number[0] == '*') return ERR_NOTSUPPORTED;
+ if (number[0] == '#') return ERR_NOTSUPPORTED;
req[pos++] = strlen(number);
EncodeUnicode(req+pos,number,strlen(number));
pos += strlen(number)*2;
req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
req[pos++] = 0x01;
req[pos++] = 0x05;
req[pos++] = 0x00;
req[pos++] = 0x02;
req[pos++] = 0x00;
req[pos++] = 0x00;
switch (ShowNumber) {
case GSM_CALL_HideNumber:
req[pos++] = 0x02;
break;
case GSM_CALL_ShowNumber:
req[pos++] = 0x03;
break;
case GSM_CALL_DefaultNumberPresence:
req[pos++] = 0x01;
break;
}
+ smprintf(s, "Making voice call\n");
+ error = GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
+ if (error != ERR_NOTSUPPORTED) return error;
+
+ if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED;
+
+ req2[11] = strlen(number)*2+6;
+ req2[pos2++] = strlen(number);
+ EncodeUnicode(req2+pos2,number,strlen(number));
+ pos2 += strlen(number)*2;
smprintf(s, "Making voice call\n");
- return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
+ error = GSM_WaitFor (s, req2, pos2, 0x01, 4, ID_DialVoice);
+ if (error == ERR_NOTSUPPORTED) return ERR_NONE;
+ return error;
}
/* method 3 */
static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last)
{
int i=0,j=0;
while (Last->Location[j] != 0x00) j++;
if (j >= GSM_MAXCALENDARTODONOTES) {
smprintf(s, "Increase GSM_MAXCALENDARTODONOTES\n");
return ERR_UNKNOWN;
}
if (j == 0) {
Last->Number=msg.Buffer[8]*256+msg.Buffer[9];
smprintf(s, "Number of Entries: %i\n",Last->Number);
}
smprintf(s, "Locations: ");
while (14+(i*4) <= msg.Length) {
Last->Location[j++]=msg.Buffer[12+i*4]*256+msg.Buffer[13+i*4];
smprintf(s, "%i ",Last->Location[j-1]);
i++;
}
smprintf(s, "\nNumber of Entries in frame: %i\n",i);
Last->Location[j] = 0;
smprintf(s, "\n");
if (i == 1 && msg.Buffer[12+0*4]*256+msg.Buffer[13+0*4] == 0) return ERR_EMPTY;
if (i == 0) return ERR_EMPTY;
return ERR_NONE;
}
/* method 3 */
-static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, bool Calendar)
+static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, char Type)
{
- GSM_Error error;
+ GSM_Error error = ERR_UNKNOWN;
int i;
unsigned char req[] = {N6110_FRAME_HEADER, 0x9E, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, /* First location */
- 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style */
+ 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style, 2 = Notes */
Last->Location[0] = 0x00;
Last->Number = 0;
- if (Calendar) {
+ req[10] = Type;
+ if (Type == 0) {
smprintf(s, "Getting locations for calendar method 3\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
- } else {
- req[10] = 0x01;
+ } else if (Type == 1) {
smprintf(s, "Getting locations for ToDo method 2\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
+ } else if (Type == 2) {
+ smprintf(s, "Getting locations for Notes\n");
+ error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
}
if (error != ERR_NONE && error != ERR_EMPTY) return error;
while (1) {
i=0;
while (Last->Location[i] != 0x00) i++;
smprintf(s, "i = %i %i\n",i,Last->Number);
if (i == Last->Number) break;
if (i != Last->Number && error == ERR_EMPTY) {
smprintf(s, "Phone doesn't support some notes with this method. Workaround\n");
Last->Number = i;
break;
}
req[8] = Last->Location[i-1] / 256;
req[9] = Last->Location[i-1] % 256;
- if (Calendar) {
+ if (Type == 0) {
smprintf(s, "Getting locations for calendar method 3\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo);
- } else {
+ } else if (Type == 1) {
smprintf(s, "Getting locations for todo method 2\n");
error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo);
+ } else if (Type == 2) {
+ smprintf(s, "Getting locations for Notes\n");
+ error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote);
}
if (error != ERR_NONE && error != ERR_EMPTY) return error;
}
return ERR_NONE;
}
/* method 3 */
GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_CalendarEntry *entry = s->Phone.Data.Cal;
GSM_DateTime Date;
unsigned long diff;
int i;
bool found = false;
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
smprintf(s, "Calendar note received method 3\n");
smprintf(s,"Note type %02i: ",msg.Buffer[27]);
switch(msg.Buffer[27]) {
case 0x00: smprintf(s,"Reminder\n"); entry->Type = GSM_CAL_REMINDER; break;
case 0x01: smprintf(s,"Meeting\n"); entry->Type = GSM_CAL_MEETING; break;
case 0x02: smprintf(s,"Call\n"); entry->Type = GSM_CAL_CALL; break;
case 0x04: smprintf(s,"Birthday\n"); entry->Type = GSM_CAL_BIRTHDAY; break;
case 0x08: smprintf(s,"Memo\n"); entry->Type = GSM_CAL_MEMO; break;
default : smprintf(s,"unknown\n");
}
smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n",
msg.Buffer[28]*256+msg.Buffer[29],
msg.Buffer[30],msg.Buffer[31],msg.Buffer[32],
msg.Buffer[33]);
@@ -3321,109 +3361,115 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s)
if (msg.Buffer[42] == 0xff && msg.Buffer[43] == 0xff) {
entry->Entries[0].Date.Year = 0;
} else {
entry->Entries[0].Date.Year = msg.Buffer[42]*256+msg.Buffer[43];
}
}
memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+54, msg.Buffer[51]*2);
entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2] = 0;
entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2+1] = 0;
entry->Entries[entry->EntriesNum].EntryType = CAL_TEXT;
entry->EntriesNum++;
smprintf(s, "Note text: \"%s\"\n",DecodeUnicodeString(entry->Entries[entry->EntriesNum-1].Text));
if (entry->Type == GSM_CAL_CALL) {
memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2);
entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0;
entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0;
entry->Entries[entry->EntriesNum].EntryType = CAL_PHONE;
entry->EntriesNum++;
}
if (entry->Type == GSM_CAL_MEETING) {
memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2);
entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0;
entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0;
entry->Entries[entry->EntriesNum].EntryType = CAL_LOCATION;
entry->EntriesNum++;
}
return ERR_NONE;
}
+static GSM_Error N6510_PrivGetGenericCalendar3(GSM_StateMachine *s, int Location, GSM_Phone_RequestID ID)
+{
+ unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
+ 0x00,0x99, /* Location */
+ 0xff,0xff,0xff,0xff};
+
+ req[8] = Location / 256;
+ req[9] = Location % 256;
+
+ return GSM_WaitFor (s, req, 14, 0x13, 4, ID);
+}
+
static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear)
{
GSM_Error error;
GSM_DateTime date_time;
- unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
- 0x00,0x99, /* Location */
- 0xff,0xff,0xff,0xff,0x01};
if (start) {
/* We have to get current year. It's NOT written in frame for
* Birthday
*/
error=s->Phone.Functions->GetDateTime(s,&date_time);
switch (error) {
case ERR_EMPTY:
case ERR_NOTIMPLEMENTED:
GSM_GetCurrentDateTime(&date_time);
break;
case ERR_NONE:
break;
default:
return error;
}
*LastCalendarYear = date_time.Year;
}
Note->EntriesNum = 0;
Note->Entries[0].Date.Year = *LastCalendarYear;
- req[8] = Note->Location / 256;
- req[9] = Note->Location % 256;
-
s->Phone.Data.Cal=Note;
smprintf(s, "Getting calendar note method 3\n");
- return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetCalendarNote);
+ return N6510_PrivGetGenericCalendar3(s, Note->Location, ID_GetCalendarNote);
}
/* method 3 */
GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos)
{
GSM_Error error;
bool start2;
if (start) {
- error=N6510_GetCalendarInfo3(s,LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s,LastCalendar,0);
if (error!=ERR_NONE) return error;
if (LastCalendar->Number == 0) return ERR_EMPTY;
*LastCalendarPos = 0;
} else {
(*LastCalendarPos)++;
}
error = ERR_EMPTY;
start2 = start;
while (error == ERR_EMPTY) {
if (*LastCalendarPos >= LastCalendar->Number) return ERR_EMPTY;
Note->Location = LastCalendar->Location[*LastCalendarPos];
error=N6510_PrivGetCalendar3(s, Note, start2, LastCalendarYear);
if (error == ERR_EMPTY) (*LastCalendarPos)++;
start2 = false;
}
return error;
}
static GSM_Error N6510_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (msg.Buffer[3]) {
case 0x3B:
/* Old method 1 for accessing calendar */
return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar);
case 0x9F:
smprintf(s, "Info with calendar notes locations received method 3\n");
return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar);
}
@@ -3448,82 +3494,82 @@ static GSM_Error N6510_GetCalendarNotePos3(GSM_StateMachine *s)
}
static GSM_Error N6510_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
switch (msg.Buffer[3]) {
case 0x32:
/* Old method 1 for accessing calendar */
return N71_65_ReplyGetCalendarNotePos1(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos);
case 0x96:
return N6510_ReplyGetCalendarNotePos3(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos);
}
return ERR_UNKNOWNRESPONSE;
}
static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntry *Entry, unsigned char *ID)
{
int i,j,LastCalendarYear;
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
GSM_CalendarEntry Note;
GSM_NOKIACalToDoLocations LastCalendar1,LastCalendar2;
GSM_Error error;
bool found;
for(i=0;i<Priv->CalendarIconsNum;i++) {
if (Priv->CalendarIconsTypes[i] == Entry->Type) {
*ID = Priv->CalendarIcons[i];
return ERR_NONE;
}
}
smprintf(s, "Starting finding note ID\n");
- error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
if (error != ERR_NONE) return error;
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35) ||
IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) ||
IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
error=N71_65_AddCalendar2(s,Entry);
} else {
if (Entry->Type == GSM_CAL_MEETING) {
error=N71_65_AddCalendar1(s, Entry, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
} else {
error=N71_65_AddCalendar2(s,Entry);
}
}
if (error != ERR_NONE) return error;
- error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0);
memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations));
if (error != ERR_NONE) return error;
smprintf(s,"Number of entries: %i %i\n",LastCalendar1.Number,LastCalendar2.Number);
for(i=0;i<LastCalendar2.Number;i++) {
found = true;
for(j=0;j<LastCalendar1.Number;j++) {
if (LastCalendar1.Location[j] == LastCalendar2.Location[i]) {
found = false;
break;
}
}
if (found) {
Note.Location = LastCalendar2.Location[i];
error=N6510_PrivGetCalendar3(s, &Note, true, &LastCalendarYear);
if (error != ERR_NONE) return error;
error=N71_65_DelCalendar(s, &Note);
if (error != ERR_NONE) return error;
smprintf(s, "Ending finding note ID\n");
for(j=0;j<Priv->CalendarIconsNum;j++) {
if (Priv->CalendarIconsTypes[j] == Entry->Type) {
*ID = Priv->CalendarIcons[j];
return ERR_NONE;
}
}
return ERR_UNKNOWN;
}
}
@@ -3708,65 +3754,65 @@ static GSM_Error N6510_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *
/* Method 2. In known phones texts of notes cut to 50 chars. Some features missed */
// return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
} else {
/* Method 3. All DCT4 features supported. Not supported by 8910 */
return N6510_GetNextCalendar3(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos);
}
}
static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
{
GSM_Error error;
#ifdef GSM_FORCE_DCT4_CALENDAR_6210
/* Method 1 */
error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
if (error!=ERR_NONE) return error;
Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
return ERR_NONE;
#endif
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
/* Method 1 */
error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar);
if (error!=ERR_NONE) return error;
Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
return ERR_NONE;
/* Method 2 */
// return ERR_NOTSUPPORTED;
} else {
/* Method 3 */
- error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,true);
+ error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0);
if (error!=ERR_NONE) return error;
Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
return ERR_NONE;
}
}
static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
{
#ifdef GSM_FORCE_DCT4_CALENDAR_6210
return N71_65_AddCalendar2(s,Note);
#endif
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) {
return N71_65_AddCalendar2(s,Note);
// return N71_65_AddCalendar1(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
} else {
/* Method 3. All DCT4 features supported. Not supported by 8910 */
return N6510_AddCalendar3(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos);
}
}
static GSM_Error N6510_ReplyLogIntoNetwork(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "Probably phone says: I log into network\n");
return ERR_NONE;
}
void N6510_EncodeFMFrequency(double freq, unsigned char *buff)
{
double freq0;
unsigned char buffer[20];
unsigned int i,freq2;
@@ -3943,64 +3989,100 @@ GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool ena
0x00, 0x00, 0x00, 0x01,
0x05, 0x04, 0x02, 0x00};
req[4] = light;
if (!enable) req[5] = 0x02;
smprintf(s, "Setting light\n");
return GSM_WaitFor (s, req, 14, 0x3A, 4, ID_SetLight);
}
static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable)
{
GSM_Error error;
if (enable) {
error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,true);
if (error != ERR_NONE) return error;
error=N6510_SetLight(s,N6510_LIGHT_TORCH,true);
if (error != ERR_NONE) return error;
return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true);
} else {
error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false);
if (error != ERR_NONE) return error;
error=N6510_SetLight(s,N6510_LIGHT_TORCH,false);
if (error != ERR_NONE) return error;
return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false);
}
}
+static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote);
+}
+
+static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s)
+{
+ smprintf(s, "Note received\n");
+ memcpy(s->Phone.Data.Note->Text,msg.Buffer+54,(msg.Buffer[50]*256+msg.Buffer[51])*2);
+ s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2] = 0;
+ s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0;
+ return ERR_NONE;
+}
+
+GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start)
+{
+ GSM_Error error;
+ GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote;
+
+ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED;
+
+ if (start) {
+ error=N6510_GetCalendarInfo3(s,LastNote,2);
+ if (error!=ERR_NONE) return error;
+ Note->Location = 1;
+ } else {
+ Note->Location++;
+ }
+
+ if (Note->Location > LastNote->Number) return ERR_EMPTY;
+
+ s->Phone.Data.Note = Note;
+ smprintf(s, "Getting note\n");
+ return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote);
+}
+
static int N6510_FindFileCheckSum(unsigned char *ptr, int len)
{
int acc, i, accx;
accx = 0;
acc = 0xffff;
while (len--) {
accx = (accx & 0xffff00ff) | (acc & 0xff00);
acc = (acc & 0xffff00ff) | *ptr++ << 8;
for (i = 0; i < 8; i++) {
acc <<= 1;
if (acc & 0x10000) acc ^= 0x1021;
if (accx & 0x80000000) acc ^= 0x1021;
accx <<= 1;
}
}
dbgprintf("Checksum from Gammu is %04X\n",(acc & 0xffff));
return (acc & 0xffff);
}
static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_File *File = s->Phone.Data.FileInfo;
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
int i;
switch (msg.Buffer[3]) {
case 0x15:
smprintf(s,"File or folder details received\n");
CopyUnicodeString(File->Name,msg.Buffer+10);
if (!strncmp(DecodeUnicodeString(File->Name),"GMSTemp",7)) return ERR_EMPTY;
if (File->Name[0] == 0x00 && File->Name[1] == 0x00) return ERR_UNKNOWN;
@@ -4026,65 +4108,65 @@ static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_Stat
File->ModifiedEmpty = false;
NOKIA_DecodeDateTime(s, msg.Buffer+i-22, &File->Modified);
if (File->Modified.Year == 0x00) File->ModifiedEmpty = true;
dbgprintf("%02x %02x %02x %02x\n",msg.Buffer[i-22],msg.Buffer[i-21],msg.Buffer[i-20],msg.Buffer[i-19]);
Priv->FileToken = msg.Buffer[i-10]*256+msg.Buffer[i-9];
Priv->ParentID = msg.Buffer[i]*256+msg.Buffer[i+1];
smprintf(s,"ParentID is %i\n",Priv->ParentID);
File->Type = GSM_File_Other;
if (msg.Length > 240){
i = 227;
if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x01)
File->Type = GSM_File_Image_JPG;
else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x02)
File->Type = GSM_File_Image_BMP;
else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x07)
File->Type = GSM_File_Image_BMP;
else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x03)
File->Type = GSM_File_Image_PNG;
else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05)
File->Type = GSM_File_Image_GIF;
else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09)
File->Type = GSM_File_Image_WBMP;
else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01)
File->Type = GSM_File_Sound_AMR;
else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02)
File->Type = GSM_File_Sound_MIDI;
else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05)
File->Type = GSM_File_Video_3GP;
else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01)
File->Type = GSM_File_Java_JAR;
-#if DEVELOP
+#ifdef DEVELOP
else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01)
File->Type = GSM_File_MMS;
#endif
}
return ERR_NONE;
case 0x2F:
smprintf(s,"File or folder used bytes received\n");
File->Used = msg.Buffer[6]*256*256*256+
msg.Buffer[7]*256*256+
msg.Buffer[8]*256+
msg.Buffer[9];
return ERR_NONE;
case 0x33:
if (s->Phone.Data.RequestID == ID_GetFileInfo) {
i = Priv->FilesLocationsUsed-1;
while (1) {
if (i==Priv->FilesLocationsCurrent-1) break;
dbgprintf("Copying %i to %i, max %i, current %i\n",
i,i+msg.Buffer[9],
Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent);
Priv->FilesLocations[i+msg.Buffer[9]] = Priv->FilesLocations[i];
Priv->FilesLevels[i+msg.Buffer[9]] = Priv->FilesLevels[i];
i--;
}
Priv->FilesLocationsUsed += msg.Buffer[9];
for (i=0;i<msg.Buffer[9];i++) {
Priv->FilesLocations[Priv->FilesLocationsCurrent+i] = msg.Buffer[13+i*4-1]*256 + msg.Buffer[13+i*4];
Priv->FilesLevels[Priv->FilesLocationsCurrent+i] = File->Level+1;
dbgprintf("%i ",Priv->FilesLocations[Priv->FilesLocationsCurrent+i]);
}
dbgprintf("\n");
}
@@ -4369,65 +4451,65 @@ static GSM_Error N6510_ReplyAddFileHeader(GSM_Protocol_Message msg, GSM_StateMac
static GSM_Error N6510_ReplyAddFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
return ERR_NONE;
}
static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos)
{
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
GSM_File File2;
GSM_Error error;
int j;
unsigned char Header[400] = {
N7110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x01,
0x00, 0x0C, /* parent folder ID */
0x00, 0x00, 0x00, 0xE8};
unsigned char Add[15000] = {
N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01,
0x00, 0x04, /* file ID */
0x00, 0x00,
0x01, 0x28}; /* length */
unsigned char end[30] = {
N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01,
0x00, 0x04, /* file ID */
0x00, 0x00, 0x00, 0x00};
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED;
s->Phone.Data.File = File;
if (*Pos == 0) {
error = N6510_SearchForFileName(s,File);
- if (error == ERR_NONE) return ERR_INVALIDLOCATION;
+ if (error == ERR_NONE) return ERR_FILEALREADYEXIST;
if (error != ERR_EMPTY) return error;
Header[8] = atoi(File->ID_FullName) / 256;
Header[9] = atoi(File->ID_FullName) % 256;
memset(Header+14, 0x00, 300);
CopyUnicodeString(Header+14,File->Name);
Header[222] = File->Used / (256*256*256);
Header[223] = File->Used / (256*256);
Header[224] = File->Used / 256;
Header[225] = File->Used % 256;
switch(File->Type) {
case GSM_File_Image_JPG : Header[231]=0x02; Header[233]=0x01; break;
case GSM_File_Image_BMP : Header[231]=0x02; Header[233]=0x02; break;
case GSM_File_Image_PNG : Header[231]=0x02; Header[233]=0x03; break;
case GSM_File_Image_GIF : Header[231]=0x02; Header[233]=0x05; break;
case GSM_File_Image_WBMP : Header[231]=0x02; Header[233]=0x09; break;
case GSM_File_Sound_AMR : Header[231]=0x04; Header[233]=0x01; break;
case GSM_File_Sound_MIDI : Header[231]=0x04; Header[233]=0x05; break; //Header[238]=0x01;
case GSM_File_Sound_NRT : Header[231]=0x04; Header[233]=0x06; break;
case GSM_File_Video_3GP : Header[231]=0x08; Header[233]=0x05; break;
case GSM_File_Java_JAR : Header[231]=0x10; Header[233]=0x01; break;
#ifdef DEVELOP
case GSM_File_MMS:
Header[214]=0x07;
Header[215]=0xd3;
Header[216]=0x06;
Header[217]=0x01;
Header[218]=0x12;
Header[219]=0x13;
Header[220]=0x29;
Header[233]=0x01;
break;
@@ -4785,65 +4867,65 @@ static GSM_Error N6510_ReplyGetToDoStatus1(GSM_Protocol_Message msg, GSM_StateMa
smprintf(s, "Locations: ");
for (i=0;i<Last->Number;i++) {
Last->Location[i]=msg.Buffer[12+(i*4)]*256+msg.Buffer[(i*4)+13];
smprintf(s, "%i ",Last->Location[i]);
}
smprintf(s, "\n");
return ERR_NONE;
}
/* ToDo support - 6310 style */
static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *status)
{
GSM_Error error;
GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
unsigned char reqLoc[] = {
N6110_FRAME_HEADER,
0x15, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00};
smprintf(s, "Getting ToDo locations\n");
error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo);
if (error != ERR_NONE) return error;
status->Used = LastToDo->Number;
return ERR_NONE;
}
static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status)
{
GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
GSM_Error error;
- error = N6510_GetCalendarInfo3(s,LastToDo,false);
+ error = N6510_GetCalendarInfo3(s,LastToDo,1);
if (error!=ERR_NONE) return error;
status->Used = LastToDo->Number;
return ERR_NONE;
}
static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
{
status->Used = 0;
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
return N6510_GetToDoStatus1(s, status);
} else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
return N6510_GetToDoStatus2(s, status);
} else {
return ERR_NOTSUPPORTED;
}
}
/* ToDo support - 6310 style */
static GSM_Error N6510_ReplyGetToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
GSM_ToDoEntry *Last = s->Phone.Data.ToDo;
smprintf(s, "TODO received method 1\n");
switch (msg.Buffer[4]) {
case 1 : Last->Priority = GSM_Priority_High; break;
case 2 : Last->Priority = GSM_Priority_Medium; break;
case 3 : Last->Priority = GSM_Priority_Low; break;
default : return ERR_UNKNOWN;
}
@@ -4915,164 +4997,155 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine
msg.Buffer[34]*256+msg.Buffer[35],
msg.Buffer[36],msg.Buffer[37],msg.Buffer[38],
msg.Buffer[39]);
Date.Year = msg.Buffer[34]*256+msg.Buffer[35];
Date.Month = msg.Buffer[36];
Date.Day = msg.Buffer[37];
Date.Hour = msg.Buffer[38];
Date.Minute = msg.Buffer[39];
Date.Second = 0;
Last->Entries[1].EntryType = TODO_END_DATETIME;
memcpy(&Last->Entries[1].Date,&Date,sizeof(GSM_DateTime));
smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n",
msg.Buffer[28]*256+msg.Buffer[29],
msg.Buffer[30],msg.Buffer[31],msg.Buffer[32],
msg.Buffer[33]);
Date.Year = msg.Buffer[28]*256+msg.Buffer[29];
Date.Month = msg.Buffer[30];
Date.Day = msg.Buffer[31];
Date.Hour = msg.Buffer[32];
Date.Minute = msg.Buffer[33];
Date.Second = 0;
Last->EntriesNum = 2;
if (msg.Buffer[45] == 0x01) {
Last->Entries[2].Number = msg.Buffer[45];
Last->Entries[2].EntryType = TODO_COMPLETED;
Last->EntriesNum++;
smprintf(s,"Completed\n");
}
- if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff)
- {
+ if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) {
smprintf(s, "No alarm\n");
} else {
diff = ((unsigned int)msg.Buffer[14]) << 24;
diff += ((unsigned int)msg.Buffer[15]) << 16;
diff += ((unsigned int)msg.Buffer[16]) << 8;
diff += msg.Buffer[17];
memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime));
GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60);
smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n",
Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month,
Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour,
Last->Entries[Last->EntriesNum].Date.Minute,Last->Entries[Last->EntriesNum].Date.Second);
Last->Entries[Last->EntriesNum].EntryType = TODO_ALARM_DATETIME;
if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 &&
msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00)
{
Last->Entries[Last->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
smprintf(s, "Alarm type : Silent\n");
}
Last->EntriesNum++;
}
return ERR_NONE;
}
/* ToDo support - 6610 style */
static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
{
GSM_Error error;
GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
- /* The same to getting calendar method 3 */
- unsigned char req[] = {
- N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00,
- 0x00,0x99, /* Location */
- 0xff,0xff,0xff,0xff,0x01};
if (refresh) {
- error=N6510_GetCalendarInfo3(s,LastToDo,false);
+ error=N6510_GetCalendarInfo3(s,LastToDo,1);
if (error!=ERR_NONE) return error;
ToDo->Location = 1;
} else {
ToDo->Location++;
}
if (ToDo->Location > LastToDo->Number) return ERR_EMPTY;
- req[8] = LastToDo->Location[ToDo->Location-1] / 256;
- req[9] = LastToDo->Location[ToDo->Location-1] % 256;
-
s->Phone.Data.ToDo = ToDo;
smprintf(s, "Getting todo method 2\n");
- return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetToDo);
+ return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo);
}
static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh)
{
if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
return N6510_GetNextToDo1(s, ToDo, refresh);
} else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
return N6510_GetNextToDo2(s, ToDo, refresh);
} else {
return ERR_NOTSUPPORTED;
}
}
/* ToDo support - 6310 style */
static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "All TODO deleted\n");
return ERR_NONE;
}
/* ToDo support - 6310 style */
static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s)
{
unsigned char req[] = {N6110_FRAME_HEADER, 0x11};
if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) {
return ERR_NOTSUPPORTED;
}
smprintf(s, "Deleting all ToDo method 1\n");
return GSM_WaitFor (s, req, 4, 0x55, 4, ID_DeleteAllToDo);
}
static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
{
GSM_Error error;
GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo;
GSM_CalendarEntry Note;
if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) {
return ERR_NOTSUPPORTED;
}
- error=N6510_GetCalendarInfo3(s,LastToDo,false);
+ error=N6510_GetCalendarInfo3(s,LastToDo,1);
if (error!=ERR_NONE) return error;
smprintf(s, "Deleting ToDo method 2\n");
if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION;
Note.Location = LastToDo->Location[ToDo->Location-1];
return N71_65_DelCalendar(s,&Note);
}
/* ToDo support - 6310 style */
static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "TODO first location received method 1: %02x\n",msg.Buffer[9]);
s->Phone.Data.ToDo->Location = msg.Buffer[9];
return ERR_NONE;
}
/* ToDo support - 6310 style */
static GSM_Error N6510_ReplyAddToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
smprintf(s, "TODO set OK\n");
return ERR_NONE;
}
/* ToDo support - 6310 style */
static GSM_Error N6510_AddToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
{
int Text, Alarm, EndTime, Completed, ulen, Phone;
GSM_Error error;
unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x0F};
unsigned char reqSet[500] = {
@@ -5422,128 +5495,136 @@ GSM_Error N6510_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark
/* We have to enable WAP frames in phone */
error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
if (error!=ERR_NONE) return error;
return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark);
}
GSM_Error N6510_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
{
GSM_Error error;
/* We have to enable WAP frames in phone */
error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS);
if (error!=ERR_NONE) return error;
return DCT3DCT4_GetWAPBookmarkPart(s,bookmark);
}
static GSM_Reply_Function N6510ReplyFunctions[] = {
{N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
{N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
{N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice },
{N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
{N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
{N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
{N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
{N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
{N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame },
+ {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame },
{N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
{N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame },
{N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC },
{N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC },
{N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
{N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
{N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
{N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
{N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
{DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert },
{N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
{NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
{NoneReply, "\x06",0x03,0x09,ID_IncomingFrame },
{N6510_ReplyEnterSecurityCode, "\x08",0x03,0x08,ID_EnterSecurityCode },
{N6510_ReplyEnterSecurityCode, "\x08",0x03,0x09,ID_EnterSecurityCode },
{N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus },
{N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo },
{N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame },
{N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame },
{N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality },
{N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame },
{NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame },
{N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap },
{N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap },
{NoneReply, "\x0B",0x03,0x01,ID_PlayTone },
{NoneReply, "\x0B",0x03,0x15,ID_PlayTone },
{NoneReply, "\x0B",0x03,0x16,ID_PlayTone },
{N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },
{N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },
{N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },
{N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },
{N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
{N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
{N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
{N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
#ifdef DEBUG
{N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },
#endif
{N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
{N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/
{N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo },
{N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/
{N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo },
+ {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote },
{N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings },
{N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale },
{N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings },
{N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/
{N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo },
{N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/
{N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo },
+ {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote },
{N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage },
{N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap },
{N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage },
{N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage },
{N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage },
{N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus },
{N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus },
{N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage },
{N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder },
{N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders },
{N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage },
{N6510_ReplyGetSMSStatus, "\x14",0x03,0x1a,ID_GetSMSStatus },
{DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset },
{DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset },
{NoneReply, "\x15",0x03,0x68,ID_Reset },
{N6510_ReplyGetBatteryCharge, "\x17",0x03,0x0B,ID_GetBatteryCharge },
{N6510_ReplySetDateTime, "\x19",0x03,0x02,ID_SetDateTime },
{N6510_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime },
{N6510_ReplySetAlarm, "\x19",0x03,0x12,ID_SetAlarm },
{N6510_ReplyGetAlarm, "\x19",0x03,0x1A,ID_GetAlarm },
{N6510_ReplyGetAlarm, "\x19",0x03,0x20,ID_GetAlarm },
{DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI },
{NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware },
{N6510_ReplyGetPPM, "\x1B",0x03,0x08,ID_GetPPM },
{NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode },
/* 0x1C - vibra */
@@ -5622,161 +5703,162 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
{N6510_ReplyDeleteFile, "\x6D",0x03,0x19,ID_DeleteFile },
{N6510_ReplyDeleteFile, "\x6D",0x03,0x1F,ID_DeleteFile },
{N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x23,ID_FileSystemStatus },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFileInfo },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFile },
{N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x2F,ID_FileSystemStatus },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFileInfo },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFile },
{N6510_ReplyAddFilePart, "\x6D",0x03,0x41,ID_AddFile },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_AddFile },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFile },
{N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFileInfo },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_GetBitmap },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_SetBitmap },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_GetBitmap },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_SetBitmap },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_GetBitmap },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_SetBitmap },
{N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x25,ID_SetBitmap },
{DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
{DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
/* 0xD7 - Bluetooth */
{N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone },
{NULL, "\x00",0x00,0x00,ID_None }
};
GSM_Phone_Functions N6510Phone = {
- "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",
+ "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",
N6510ReplyFunctions,
N6510_Initialise,
NONEFUNCTION, /* Terminate */
GSM_DispatchMessage,
N6510_ShowStartInfo,
NOKIA_GetManufacturer,
DCT3DCT4_GetModel,
DCT3DCT4_GetFirmware,
DCT4_GetIMEI,
N6510_GetOriginalIMEI,
N6510_GetManufactureMonth,
DCT4_GetProductCode,
DCT4_GetHardware,
N6510_GetPPM,
NOTSUPPORTED, /* GetSIMIMSI */
N6510_GetDateTime,
N6510_SetDateTime,
N6510_GetAlarm,
N6510_SetAlarm,
N6510_GetLocale,
NOTSUPPORTED, /* SetLocale */
N6510_PressKey,
DCT4_Reset,
NOTIMPLEMENTED, /* ResetPhoneSettings */
N6510_EnterSecurityCode,
N6510_GetSecurityStatus,
NOTSUPPORTED, /* GetDisplayStatus */
NOTIMPLEMENTED, /* SetAutoNetworkLogin */
N6510_GetBatteryCharge,
N6510_GetSignalQuality,
N6510_GetNetworkInfo,
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTSUPPORTED, /* GetCategoryStatus */
N6510_GetMemoryStatus,
N6510_GetMemory,
NOTIMPLEMENTED, /* GetNextMemory */
N6510_SetMemory,
NOTIMPLEMENTED, /* AddMemory */
N6510_DeleteMemory,
NOTIMPLEMENTED, /* DeleteAllMemory */
N6510_GetSpeedDial,
NOTIMPLEMENTED, /* SetSpeedDial */
N6510_GetSMSC,
N6510_SetSMSC,
N6510_GetSMSStatus,
N6510_GetSMSMessage,
N6510_GetNextSMSMessage,
N6510_SetSMS,
N6510_AddSMS,
N6510_DeleteSMSMessage,
N6510_SendSMSMessage,
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOKIA_SetIncomingSMS,
NOTIMPLEMENTED, /* SetIncomingCB */
N6510_GetSMSFolders,
N6510_AddSMSFolder,
NOTIMPLEMENTED, /* DeleteSMSFolder */
N6510_DialVoice,
N6510_AnswerCall,
N6510_CancelCall,
NOTIMPLEMENTED, /* HoldCall */
NOTIMPLEMENTED, /* UnholdCall */
NOTIMPLEMENTED, /* ConferenceCall */
NOTIMPLEMENTED, /* SplitCall */
NOTIMPLEMENTED, /* TransferCall */
NOTIMPLEMENTED, /* SwitchCall */
DCT3DCT4_GetCallDivert,
DCT3DCT4_SetCallDivert,
DCT3DCT4_CancelAllDiverts,
NOKIA_SetIncomingCall,
NOKIA_SetIncomingUSSD,
DCT3DCT4_SendDTMF,
N6510_GetRingtone,
N6510_SetRingtone,
N6510_GetRingtonesInfo,
N6510_DeleteUserRingtones,
N6510_PlayTone,
N6510_GetWAPBookmark,
N6510_SetWAPBookmark,
N6510_DeleteWAPBookmark,
N6510_GetWAPSettings,
N6510_SetWAPSettings,
N6510_GetMMSSettings,
N6510_SetMMSSettings,
N6510_GetSyncMLSettings,
NOTSUPPORTED, /* SetSyncMLSettings */
N6510_GetChatSettings,
NOTSUPPORTED, /* SetChatSettings */
N6510_GetBitmap,
N6510_SetBitmap,
N6510_GetToDoStatus,
NOTIMPLEMENTED, /* GetToDo */
N6510_GetNextToDo,
NOTIMPLEMENTED, /* SetToDo */
N6510_AddToDo,
N6510_DeleteToDo2,
N6510_DeleteAllToDo1,
N6510_GetCalendarStatus,
NOTIMPLEMENTED, /* GetCalendar */
N6510_GetNextCalendar,
NOTIMPLEMENTED, /* SetCalendar */
N6510_AddCalendar,
N71_65_DelCalendar,
NOTIMPLEMENTED, /* DeleteAllCalendar */
N6510_GetCalendarSettings,
NOTSUPPORTED, /* SetCalendarSettings */
- NOTIMPLEMENTED, /* GetNote */
+ N6510_GetNextNote,
N6510_GetProfile,
N6510_SetProfile,
N6510_GetFMStation,
N6510_SetFMStation,
N6510_ClearFMStations,
N6510_GetNextFileFolder,
N6510_GetFilePart,
N6510_AddFilePart,
N6510_GetFileSystemStatus,
N6510_DeleteFile,
N6510_AddFolder,
N6510_GetGPRSAccessPoint,
N6510_SetGPRSAccessPoint
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -5,64 +5,66 @@
#include "../ncommon.h"
#include "../../../service/sms/gsmsms.h"
typedef enum {
N6510_MMS_SETTINGS = 0x01,
N6510_CHAT_SETTINGS,
N6510_WAP_SETTINGS,
N6510_SYNCML_SETTINGS
} N6510_Connection_Settings;
typedef enum {
N6510_LIGHT_DISPLAY = 0x01,
N6510_LIGHT_KEYPAD = 0x03,
N6510_LIGHT_TORCH = 0x10
} N6510_PHONE_LIGHTS;
typedef struct {
int LastCalendarYear;
int LastCalendarPos;
GSM_NOKIACalToDoLocations LastCalendar;
int FirstCalendarPos;
unsigned char CalendarIcons[10];
GSM_CalendarNoteType CalendarIconsTypes[10];
int CalendarIconsNum;
GSM_NOKIASMSFolder LastSMSFolder;
GSM_SMSFolders LastSMSFolders;
GSM_NOKIACalToDoLocations LastToDo;
+ GSM_NOKIACalToDoLocations LastNote;
+
unsigned char RingtoneID; /* When set with preview */
int FilesLocations[1000];
int FilesLevels[1000];
int FilesLocationsUsed;
int FilesLocationsCurrent;
int FileToken;
int ParentID;
int FileCheckSum;
unsigned char FMStatus[4000];
int FMStatusLength;
unsigned char GPRSPoints[4000];
int GPRSPointsLength;
int BearerNumber;
unsigned char PhoneMode;
} GSM_Phone_N6510Data;
void N6510_EncodeFMFrequency(double freq, unsigned char *buff);
void N6510_DecodeFMFrequency(double *freq, unsigned char *buff);
#ifndef GSM_USED_MBUS2
# define GSM_USED_MBUS2
#endif
#ifndef GSM_USED_FBUS2
# define GSM_USED_FBUS2
#endif
#ifndef GSM_USED_FBUS2DLR3
# define GSM_USED_FBUS2DLR3
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
@@ -92,53 +92,53 @@ GSM_Phone_Functions NAUTOPhone = {
NOTSUPPORTED, /* SetIncomingUSSD */
NOTSUPPORTED, /* SendDTMF */
NOTSUPPORTED, /* GetRingtone */
NOTSUPPORTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetBitmap */
NOTSUPPORTED, /* SetBitmap */
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
NOTSUPPORTED, /* GetCalendarStatus */
NOTSUPPORTED, /* GetCalendar */
NOTSUPPORTED, /* GetNextCalendar */
NOTSUPPORTED, /* SetCalendar */
NOTSUPPORTED, /* AddCalendar */
NOTSUPPORTED, /* DeleteCalendar */
NOTSUPPORTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFilePart */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -1364,93 +1364,107 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
break;
case 0x05:
smprintf(s, "Incoming call\n");
smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
tmp = 6;
NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false);
smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer));
/* FIXME: read name from frame */
call.Status = GSM_CALL_IncomingCall;
tmp = 6;
NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false);
break;
case 0x07:
smprintf(s, "Call answer initiated\n");
break;
case 0x09:
smprintf(s, "Call released\n");
call.Status = GSM_CALL_CallLocalEnd;
break;
case 0x0a:
smprintf(s, "Call is being released\n");
break;
case 0x0b:
smprintf(s, "Meaning not known\n");
call.CallIDAvailable = false;
break;
case 0x0c:
smprintf(s, "Audio status\n");
if (msg.Buffer[4] == 0x01) smprintf(s, "Audio enabled\n");
else smprintf(s, "Audio disabled\n");
call.CallIDAvailable = false;
break;
+ case 0x0f:
+ case 0x10:
+ smprintf(s, "Meaning not known\n");
+ call.CallIDAvailable = false;
+ break;
case 0x23:
smprintf(s, "Call held\n");
call.Status = GSM_CALL_CallHeld;
break;
case 0x25:
smprintf(s, "Call resumed\n");
call.Status = GSM_CALL_CallResumed;
break;
case 0x27:
smprintf(s, "Call switched\n");
call.Status = GSM_CALL_CallSwitched;
break;
case 0x53:
smprintf(s, "Outgoing call\n");
smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii
tmp = 6;
NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false);
smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer));
/* FIXME: read name from frame */
call.Status = GSM_CALL_OutgoingCall;
tmp = 6;
NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false);
break;
+ case 0xA6:
+ case 0xD2:
+ case 0xD3:
+ smprintf(s, "Meaning not known\n");
+ call.CallIDAvailable = false;
+ break;
}
if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]);
if (s->Phone.Data.EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) {
if (call.CallIDAvailable) call.CallID = msg.Buffer[4];
s->User.IncomingCall(s->CurrentConfig->Device, call);
}
+ if (s->Phone.Data.RequestID == ID_DialVoice) {
+ if (msg.Buffer[3] == 0x10) return ERR_NOTSUPPORTED;
+ }
if (s->Phone.Data.RequestID == ID_CancelCall) {
if (msg.Buffer[3] == 0x09) {
if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
/* when we canceled call and see frame about other
* call releasing, we don't give ERR_NONE for "our"
* call release command
*/
return ERR_NEEDANOTHERANSWER;
}
}
if (s->Phone.Data.RequestID == ID_AnswerCall) {
if (msg.Buffer[3] == 0x07) {
if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE;
return ERR_NEEDANOTHERANSWER;
}
}
return ERR_NONE;
}
void N71_65_GetCalendarRecurrance(GSM_StateMachine *s, unsigned char *buffer, GSM_CalendarEntry *entry)
{
int Recurrance;
Recurrance = buffer[0]*256 + buffer[1];
/* 8760 hours = 1 year */
if (Recurrance == 0xffff) Recurrance=8760;
if (Recurrance != 0) {
smprintf(s, "Recurrance : %i hours\n",Recurrance);
entry->Entries[entry->EntriesNum].EntryType = CAL_RECURRANCE;
entry->Entries[entry->EntriesNum].Number = Recurrance;
entry->EntriesNum++;
}
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
@@ -745,107 +745,108 @@ GSM_Phone_Functions OBEXGENPhone = {
NOTIMPLEMENTED, /* PressKey */
NOTIMPLEMENTED, /* Reset */
NOTIMPLEMENTED, /* ResetPhoneSettings */
NOTIMPLEMENTED, /* EnterSecurityCode */
NOTIMPLEMENTED, /* GetSecurityStatus */
NOTIMPLEMENTED, /* GetDisplayStatus */
NOTIMPLEMENTED, /* SetAutoNetworkLogin */
NOTIMPLEMENTED, /* GetBatteryCharge */
NOTIMPLEMENTED, /* GetSignalQuality */
NOTIMPLEMENTED, /* GetNetworkInfo */
NOTIMPLEMENTED, /* GetCategory */
NOTSUPPORTED, /* AddCategory */
NOTIMPLEMENTED, /* GetCategoryStatus */
NOTIMPLEMENTED, /* GetMemoryStatus */
NOTIMPLEMENTED, /* GetMemory */
NOTIMPLEMENTED, /* GetNextMemory */
NOTIMPLEMENTED, /* SetMemory */
NOTIMPLEMENTED, /* AddMemory */
NOTIMPLEMENTED, /* DeleteMemory */
NOTIMPLEMENTED, /* DeleteAllMemory */
NOTIMPLEMENTED, /* GetSpeedDial */
NOTIMPLEMENTED, /* SetSpeedDial */
NOTIMPLEMENTED, /* GetSMSC */
NOTIMPLEMENTED, /* SetSMSC */
NOTIMPLEMENTED, /* GetSMSStatus */
NOTIMPLEMENTED, /* GetSMS */
NOTIMPLEMENTED, /* GetNextSMS */
NOTIMPLEMENTED, /* SetSMS */
NOTIMPLEMENTED, /* AddSMS */
NOTIMPLEMENTED, /* DeleteSMS */
NOTIMPLEMENTED, /* SendSMSMessage */
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTIMPLEMENTED, /* SetIncomingSMS */
NOTIMPLEMENTED, /* SetIncomingCB */
NOTIMPLEMENTED, /* GetSMSFolders */
NOTIMPLEMENTED, /* AddSMSFolder */
NOTIMPLEMENTED, /* DeleteSMSFolder */
NOTIMPLEMENTED, /* DialVoice */
NOTIMPLEMENTED, /* AnswerCall */
NOTIMPLEMENTED, /* CancelCall */
NOTIMPLEMENTED, /* HoldCall */
NOTIMPLEMENTED, /* UnholdCall */
NOTIMPLEMENTED, /* ConferenceCall */
NOTIMPLEMENTED, /* SplitCall */
NOTIMPLEMENTED, /* TransferCall */
NOTIMPLEMENTED, /* SwitchCall */
NOTIMPLEMENTED, /* GetCallDivert */
NOTIMPLEMENTED, /* SetCallDivert */
NOTIMPLEMENTED, /* CancelAllDiverts */
NOTIMPLEMENTED, /* SetIncomingCall */
NOTIMPLEMENTED, /* SetIncomingUSSD */
NOTIMPLEMENTED, /* SendDTMF */
NOTIMPLEMENTED, /* GetRingtone */
NOTIMPLEMENTED, /* SetRingtone */
NOTIMPLEMENTED, /* GetRingtonesInfo */
NOTIMPLEMENTED, /* DeleteUserRingtones */
NOTIMPLEMENTED, /* PlayTone */
NOTIMPLEMENTED, /* GetWAPBookmark */
NOTIMPLEMENTED, /* SetWAPBookmark */
NOTIMPLEMENTED, /* DeleteWAPBookmark */
NOTIMPLEMENTED, /* GetWAPSettings */
NOTIMPLEMENTED, /* SetWAPSettings */
NOTIMPLEMENTED, /* GetMMSSettings */
NOTIMPLEMENTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
NOTIMPLEMENTED, /* GetBitmap */
NOTIMPLEMENTED, /* SetBitmap */
NOTIMPLEMENTED, /* GetToDoStatus */
NOTIMPLEMENTED, /* GetToDo */
NOTIMPLEMENTED, /* GetNextToDo */
NOTIMPLEMENTED, /* SetToDo */
NOTIMPLEMENTED, /* AddToDo */
NOTIMPLEMENTED, /* DeleteToDo */
NOTIMPLEMENTED, /* DeleteAllToDo */
NOTIMPLEMENTED, /* GetCalendarStatus */
NOTIMPLEMENTED, /* GetCalendar */
NOTIMPLEMENTED, /* GetNextCalendar */
NOTIMPLEMENTED, /* SetCalendar */
NOTIMPLEMENTED, /* AddCalendar */
NOTIMPLEMENTED, /* DeleteCalendar */
NOTIMPLEMENTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTIMPLEMENTED, /* GetProfile */
NOTIMPLEMENTED, /* SetProfile */
NOTIMPLEMENTED, /* GetFMStation */
NOTIMPLEMENTED, /* SetFMStation */
NOTIMPLEMENTED, /* ClearFMStations */
OBEXGEN_GetNextFileFolder,
OBEXGEN_GetFilePart,
OBEXGEN_AddFilePart,
NOTIMPLEMENTED, /* GetFileSystemStatus */
OBEXGEN_DeleteFile,
OBEXGEN_AddFolder,
NOTIMPLEMENTED, /* GetGPRSAccessPoint */
NOTIMPLEMENTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -2,37 +2,41 @@
#ifndef obexgen_h
#define obexgen_h
#include "../../gsmcomon.h"
#include "../../gsmstate.h"
#include "../../service/gsmmisc.h"
#include "../../service/sms/gsmsms.h"
#ifndef GSM_USED_IRDAOBEX
# define GSM_USED_IRDAOBEX
#endif
#ifndef GSM_USED_BLUEOBEX
# define GSM_USED_BLUEOBEX
#endif
typedef enum {
OBEX_None = 1,
OBEX_BrowsingFolders
} OBEX_Service;
typedef struct {
int FileLev;
int FilesLocationsUsed;
int FilesLocationsCurrent;
GSM_File Files[500];
bool FileLastPart;
int FrameSize;
OBEX_Service Service;
} GSM_Phone_OBEXGENData;
+GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File);
+GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos);
+GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s);
+
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -114,107 +114,108 @@ GSM_Phone_Functions MROUTERGENPhone = {
NOTSUPPORTED, /* SetLocale */
NOTSUPPORTED, /* PressKey */
NOTSUPPORTED, /* Reset */
NOTSUPPORTED, /* ResetPhoneSettings */
NOTSUPPORTED, /* EnterSecurityCode */
NOTSUPPORTED, /* GetSecurityStatus */
NOTSUPPORTED, /* GetDisplayStatus */
NOTSUPPORTED, /* SetAutoNetworkLogin */
NOTSUPPORTED, /* GetBatteryCharge */
NOTSUPPORTED, /* GetSignalQuality */
NOTSUPPORTED, /* GetNetworkInfo */
NOTSUPPORTED, /* GetCategory */
NOTSUPPORTED, /* GetCategoryStatus */
NOTSUPPORTED, /* GetMemoryStatus */
NOTSUPPORTED, /* GetMemory */
NOTSUPPORTED, /* GetNextMemory */
NOTSUPPORTED, /* SetMemory */
NOTSUPPORTED, /* AddMemory */
NOTSUPPORTED, /* DeleteMemory */
NOTIMPLEMENTED, /* DeleteAllMemory */
NOTSUPPORTED, /* GetSpeedDial */
NOTSUPPORTED, /* SetSpeedDial */
NOTSUPPORTED, /* GetSMSC */
NOTSUPPORTED, /* SetSMSC */
NOTSUPPORTED, /* GetSMSStatus */
NOTSUPPORTED, /* GetSMS */
NOTSUPPORTED, /* GetNextSMS */
NOTSUPPORTED, /* SetSMS */
NOTSUPPORTED, /* AddSMS */
NOTSUPPORTED, /* DeleteSMS */
NOTSUPPORTED, /* SendSMSMessage */
NOTSUPPORTED, /* SendSavedSMS */
+ NOTSUPPORTED, /* SetFastSMSSending */
NOTSUPPORTED, /* SetIncomingSMS */
NOTSUPPORTED, /* SetIncomingCB */
NOTSUPPORTED, /* GetSMSFolders */
NOTSUPPORTED, /* AddSMSFolder */
NOTSUPPORTED, /* DeleteSMSFolder */
NOTSUPPORTED, /* DialVoice */
NOTSUPPORTED, /* AnswerCall */
NOTSUPPORTED, /* CancelCall */
NOTSUPPORTED, /* HoldCall */
NOTSUPPORTED, /* UnholdCall */
NOTSUPPORTED, /* ConferenceCall */
NOTSUPPORTED, /* SplitCall */
NOTSUPPORTED, /* TransferCall */
NOTSUPPORTED, /* SwitchCall */
NOTSUPPORTED, /* GetCallDivert */
NOTSUPPORTED, /* SetCallDivert */
NOTSUPPORTED, /* CancelAllDiverts */
NOTSUPPORTED, /* SetIncomingCall */
NOTSUPPORTED, /* SetIncomingUSSD */
NOTSUPPORTED, /* SendDTMF */
NOTSUPPORTED, /* GetRingtone */
NOTSUPPORTED, /* SetRingtone */
NOTSUPPORTED, /* GetRingtonesInfo */
NOTSUPPORTED, /* DeleteUserRingtones */
NOTSUPPORTED, /* PlayTone */
NOTSUPPORTED, /* GetWAPBookmark */
NOTSUPPORTED, /* SetWAPBookmark */
NOTSUPPORTED, /* DeleteWAPBookmark */
NOTSUPPORTED, /* GetWAPSettings */
NOTSUPPORTED, /* SetWAPSettings */
NOTSUPPORTED, /* GetMMSSettings */
NOTSUPPORTED, /* SetMMSSettings */
NOTSUPPORTED, /* GetSyncMLSettings */
NOTSUPPORTED, /* SetSyncMLSettings */
NOTSUPPORTED, /* GetChatSettings */
NOTSUPPORTED, /* SetChatSettings */
NOTSUPPORTED, /* GetBitmap */
NOTSUPPORTED, /* SetBitmap */
NOTSUPPORTED, /* GetToDoStatus */
NOTSUPPORTED, /* GetToDo */
NOTSUPPORTED, /* GetNextToDo */
NOTSUPPORTED, /* SetToDo */
NOTSUPPORTED, /* AddToDo */
NOTSUPPORTED, /* DeleteToDo */
NOTSUPPORTED, /* DeleteAllToDo */
NOTSUPPORTED, /* GetCalendarStatus */
NOTSUPPORTED, /* GetCalendar */
NOTSUPPORTED, /* GetNextCalendar */
NOTSUPPORTED, /* SetCalendar */
NOTSUPPORTED, /* AddCalendar */
NOTSUPPORTED, /* DeleteCalendar */
NOTSUPPORTED, /* DeleteAllCalendar */
NOTSUPPORTED, /* GetCalendarSettings */
NOTSUPPORTED, /* SetCalendarSettings */
- NOTSUPPORTED, /* GetNote */
+ NOTSUPPORTED, /* GetNextNote */
NOTSUPPORTED, /* GetProfile */
NOTSUPPORTED, /* SetProfile */
NOTSUPPORTED, /* GetFMStation */
NOTSUPPORTED, /* SetFMStation */
NOTSUPPORTED, /* ClearFMStations */
NOTSUPPORTED, /* GetNextFileFolder */
NOTSUPPORTED, /* GetFilePart */
NOTSUPPORTED, /* AddFilePart */
NOTSUPPORTED, /* GetFileSystemStatus */
NOTSUPPORTED, /* DeleteFile */
NOTSUPPORTED, /* AddFolder */
NOTSUPPORTED, /* GetGPRSAccessPoint */
NOTSUPPORTED /* SetGPRSAccessPoint */
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -37,72 +37,76 @@ static GSM_Error AT_WriteMessage (GSM_StateMachine *s, unsigned char *buffer,
return ERR_NONE;
}
typedef struct {
char *text;
int lines;
} SpecialAnswersStruct;
static GSM_Error AT_StateMachine(GSM_StateMachine *s, unsigned char rx_char)
{
GSM_Protocol_Message Msg2;
GSM_Protocol_ATData *d = &s->Protocol.Data.AT;
int i;
/* These are lines with end of "normal" answers */
static char *StartStrings[] = {
"OK" , "ERROR" ,
"+CME ERROR:" , "+CMS ERROR:" ,
"+CPIN: " , /*A2D issue*/
NULL};
/* Some info from phone can be inside "normal" answers
* It starts with strings written here
*/
static SpecialAnswersStruct SpecialAnswers[] = {
{"_OSIGQ:" ,1}, {"_OBS:" ,1},
{"^SCN:" ,1}, {"+CGREG:" ,1},
{"+CBM:" ,1}, {"+CMT:" ,2},
{"+CMTI:" ,1}, {"+CDS:" ,2},
- {"+CREG:" ,1},
+ {"+CREG:" ,1}, {"+CUSD" ,1},
{"RING" ,1}, {"NO CARRIER" ,1},
{"NO ANSWER" ,1}, {"+COLP" ,1},
{"+CLIP" ,1},
+ {"SDNDCRC =" ,1}, /* Samsung binary transfer end */
+
{NULL ,1}};
+//printf("%c",rx_char);
+
/* Ignore leading CR, LF and ESC */
if (d->Msg.Length == 0) {
if (rx_char == 10 || rx_char == 13 || rx_char == 27) return ERR_NONE;
d->LineStart = d->Msg.Length;
}
if (d->Msg.BufferUsed < d->Msg.Length + 2) {
d->Msg.BufferUsed = d->Msg.Length + 2;
d->Msg.Buffer = (unsigned char *)realloc(d->Msg.Buffer,d->Msg.BufferUsed);
}
d->Msg.Buffer[d->Msg.Length++] = rx_char;
d->Msg.Buffer[d->Msg.Length ] = 0;
switch (rx_char) {
case 0:
break;
case 10:
case 13:
if (!d->wascrlf) d->LineEnd = d->Msg.Length-1;
d->wascrlf = true;
if (d->Msg.Length > 0 && rx_char == 10 && d->Msg.Buffer[d->Msg.Length-2]==13) {
i = 0;
while (StartStrings[i] != NULL) {
if (strncmp(StartStrings[i],d->Msg.Buffer+d->LineStart,strlen(StartStrings[i])) == 0) {
s->Phone.Data.RequestMsg = &d->Msg;
s->Phone.Data.DispatchError = s->Phone.Functions->DispatchMessage(s);
d->Msg.Length = 0;
break;
}
i++;
}
if (d->Msg.Length == 0) break;
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,34 +1,38 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii and MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../gsmstate.h"
#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)
#include <stdio.h>
#include <string.h>
#include "../../gsmcomon.h"
#include "fbus2.h"
static GSM_Error FBUS2_WriteFrame(GSM_StateMachine *s,
unsigned char *MsgBuffer,
int MsgLength,
unsigned char MsgType)
{
unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 10];
unsigned char checksum=0;
int i, len, sent;
buffer2[0] = FBUS2_FRAME_ID;
if (s->ConnectionType==GCT_FBUS2IRDA) buffer2[0] = FBUS2_IRDA_FRAME_ID;
buffer2[1] = FBUS2_DEVICE_PHONE; //destination
buffer2[2] = FBUS2_DEVICE_PC; //source
buffer2[3] = MsgType;
buffer2[4] = MsgLength / 256;
buffer2[5] = MsgLength % 256;
memcpy(buffer2 + 6, MsgBuffer, MsgLength);
len = MsgLength + 6;
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,34 +1,38 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii and MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#ifndef fbus2_h
#define fbus2_h
#include "../protocol.h"
#define FBUS2_FRAME_ID 0x1e
#define FBUS2_IRDA_FRAME_ID 0x1c
#define FBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */
#define FBUS2_DEVICE_PC 0x0c /* Our PC */
#define FBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */
#define FBUS2_MAX_TRANSMIT_LENGTH 120
typedef struct {
int MsgSequenceNumber;
int MsgRXState;
int FramesToGo;
GSM_Protocol_Message MultiMsg;
GSM_Protocol_Message Msg;
} GSM_Protocol_FBUS2Data;
#ifndef GSM_USED_SERIALDEVICE
# define GSM_USED_SERIALDEVICE
#endif
#if defined(GSM_ENABLE_BLUEFBUS2)
# ifndef GSM_USED_BLUETOOTHDEVICE
# define GSM_USED_BLUETOOTHDEVICE
# endif
#endif
#endif
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,34 +1,34 @@
/* (c) 2001-2003 by Marcin Wiacek */
-/* based on some work from MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
#include "../../gsmstate.h"
#ifdef GSM_ENABLE_MBUS2
#include <stdio.h>
#include <string.h>
#include "../../gsmcomon.h"
#include "mbus2.h"
static GSM_Error MBUS2_WriteMessage (GSM_StateMachine *s,
unsigned char *MsgBuffer,
int MsgLength,
unsigned char MsgType)
{
unsigned char *buffer2, checksum = 0;
GSM_Protocol_MBUS2Data *d = &s->Protocol.Data.MBUS2;
int i, sent, len;
GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType);
buffer2 = (unsigned char *)malloc(MsgLength + 8);
buffer2[0] = MBUS2_FRAME_ID;
buffer2[1] = MBUS2_DEVICE_PHONE; // destination
buffer2[2] = MBUS2_DEVICE_PC; // source
buffer2[3] = MsgType;
buffer2[4] = MsgLength / 256;
buffer2[5] = MsgLength % 256;
memcpy(buffer2 + 6, MsgBuffer, MsgLength);
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,28 +1,28 @@
/* (c) 2001-2003 by Marcin Wiacek */
-/* based on some work from MyGnokii */
+/* based on some work from MyGnokii (www.mwiacek.com) */
#ifndef mbus2_h
#define mbus2_h
#include "../protocol.h"
#define MBUS2_FRAME_ID 0x1f
#define MBUS2_DEVICE_PHONE 0x00 /* Nokia mobile phone */
#define MBUS2_DEVICE_PC 0x10 /* Our PC (MBUS) */
#define MBUS2_ACK_BYTE 0x7f /* Acknowledge of the received frame */
typedef struct {
int MsgSequenceNumber;
int MsgRXState;
GSM_Protocol_Message Msg;
} GSM_Protocol_MBUS2Data;
#ifndef GSM_USED_SERIALDEVICE
# define GSM_USED_SERIALDEVICE
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,34 +1,37 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include "../../gsmstate.h"
#if defined(GSM_ENABLE_IRDA) || defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_BLUEPHONET)
#include <stdio.h>
#include <string.h>
#include "../../gsmcomon.h"
#include "phonet.h"
static GSM_Error PHONET_WriteMessage (GSM_StateMachine *s,
unsigned char *MsgBuffer,
int MsgLength,
unsigned char MsgType)
{
unsigned char *buffer2;
int sent;
GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType);
buffer2 = (unsigned char *)malloc(MsgLength + 6);
buffer2[0] = PHONET_FRAME_ID,
buffer2[1] = PHONET_DEVICE_PHONE; //destination
buffer2[2] = PHONET_DEVICE_PC; //source
if (s->ConnectionType==GCT_PHONETBLUE || s->ConnectionType==GCT_BLUEPHONET) {
buffer2[0] = PHONET_BLUE_FRAME_ID;
buffer2[1] = PHONET_DEVICE_PHONE; //destination
buffer2[2] = PHONET_BLUE_DEVICE_PC; //source
}
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,34 +1,37 @@
/* (c) 2002-2003 by Marcin Wiacek */
-/* based on some work from Gnokii */
+/* Based on some work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#ifndef PHONET_h
#define PHONET_h
#include "../protocol.h"
#define PHONET_FRAME_ID 0x14
#define PHONET_BLUE_FRAME_ID 0x19
#define PHONET_DEVICE_PHONE 0x00 /* Nokia mobile phone */
#define PHONET_DEVICE_PC 0x0c /* Our PC */
#define PHONET_BLUE_DEVICE_PC 0x10 /* Our PC */
typedef struct {
int MsgRXState;
GSM_Protocol_Message Msg;
} GSM_Protocol_PHONETData;
#if defined(GSM_ENABLE_IRDAPHONET)
# ifndef GSM_USED_IRDADEVICE
# define GSM_USED_IRDADEVICE
# endif
#endif
#if defined(GSM_ENABLE_BLUEPHONET)
# ifndef GSM_USED_BLUETOOTHDEVICE
# define GSM_USED_BLUETOOTHDEVICE
# endif
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
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
@@ -1,69 +1,73 @@
/* (c) 2002-2004 by Marcin Wiacek */
#ifndef __gsm_backgen_h
#define __gsm_backgen_h
#include "../../config.h"
#include "../../misc/misc.h"
#include "../gsmpbk.h"
#include "../gsmcal.h"
#include "../gsmlogo.h"
#include "../gsmring.h"
#include "../gsmdata.h"
#include "../gsmprof.h"
#include "../gsmmisc.h"
#include "../sms/gsmsms.h"
#define GSM_BACKUP_MAX_PHONEPHONEBOOK 501
#define GSM_BACKUP_MAX_SIMPHONEBOOK 251
#define GSM_BACKUP_MAX_CALLER 6
#define GSM_BACKUP_MAX_SMSC 10
#define GSM_BACKUP_MAX_WAPBOOKMARK 40
#define GSM_BACKUP_MAX_WAPSETTINGS 30
#define GSM_BACKUP_MAX_MMSSETTINGS 30
+#define GSM_BACKUP_MAX_SYNCMLSETTINGS 10
+#define GSM_BACKUP_MAX_CHATSETTINGS 10
#define GSM_BACKUP_MAX_RINGTONES 30
#define GSM_BACKUP_MAX_PROFILES 10
#define GSM_BACKUP_MAX_FMSTATIONS 20
#define GSM_BACKUP_MAX_GPRSPOINT 10
#define GSM_BACKUP_MAX_NOTE 10 /* FIXME */
typedef struct {
char IMEI [MAX_IMEI_LENGTH];
char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH];
char Creator [80];
GSM_DateTime DateTime;
bool DateTimeAvailable;
char MD5Original [100];
char MD5Calculated [100];
GSM_MemoryEntry *PhonePhonebook [GSM_BACKUP_MAX_PHONEPHONEBOOK + 1];
GSM_MemoryEntry *SIMPhonebook [GSM_BACKUP_MAX_SIMPHONEBOOK + 1];
GSM_CalendarEntry *Calendar [GSM_MAXCALENDARTODONOTES + 1];
GSM_Bitmap *CallerLogos [GSM_BACKUP_MAX_CALLER + 1];
GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1];
GSM_WAPBookmark *WAPBookmark [GSM_BACKUP_MAX_WAPBOOKMARK + 1];
GSM_MultiWAPSettings *WAPSettings [GSM_BACKUP_MAX_WAPSETTINGS + 1];
GSM_MultiWAPSettings *MMSSettings [GSM_BACKUP_MAX_MMSSETTINGS + 1];
+ GSM_SyncMLSettings *SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
+ GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
GSM_Ringtone *Ringtone [GSM_BACKUP_MAX_RINGTONES + 1];
GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1];
GSM_Profile *Profiles [GSM_BACKUP_MAX_PROFILES + 1];
GSM_FMStation *FMStation [GSM_BACKUP_MAX_FMSTATIONS +1];
GSM_GPRSAccessPoint *GPRSPoint [GSM_BACKUP_MAX_GPRSPOINT + 1];
GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1];
GSM_Bitmap *StartupLogo;
GSM_Bitmap *OperatorLogo;
} GSM_Backup;
#define GSM_BACKUP_MAX_SMS 500
typedef struct {
GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS];
} GSM_SMS_Backup;
extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -122,111 +122,112 @@ static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *my
unsigned char buffer2[300];
char *readvalue;
int i;
i=0;
myvalue[0] = 0;
while (true) {
sprintf(buffer2,"%s%02i",myname,i);
readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode);
if (readvalue!=NULL) {
myvalue[strlen(myvalue)+strlen(readvalue)]=0;
memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue));
} else break;
i++;
}
}
static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode)
{
unsigned char buffer[10000], buffer2[10000];
if (myname[0] == 0x00) {
if (UseUnicode) {
EncodeUnicode(buffer,myvalue,strlen(myvalue));
fwrite(buffer,1,strlen(myvalue)*2,file);
} else fprintf(file,"%s",myvalue);
} else {
if (UseUnicode) {
sprintf(buffer,"%s = \"",myname);
EncodeUnicode(buffer2,buffer,strlen(buffer));
fwrite(buffer2,1,strlen(buffer)*2,file);
- fwrite(myvalue,1,UnicodeLength(myvalue)*2,file);
+ fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
sprintf(buffer,"\"%c%c",13,10);
EncodeUnicode(buffer2,buffer,strlen(buffer));
fwrite(buffer2,1,strlen(buffer)*2,file);
} else {
- sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10);
+ sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
fprintf(file,"%s",buffer);
EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2);
fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10);
}
}
}
static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode)
{
unsigned char paramname[10000],*readvalue;
if (UseUnicode) {
EncodeUnicode(paramname,myname,strlen(myname));
readvalue = INI_GetValue(file_info, section, paramname, UseUnicode);
if (readvalue!=NULL) {
- CopyUnicodeString(myvalue,readvalue+2);
- myvalue[UnicodeLength(readvalue)*2-4]=0;
- myvalue[UnicodeLength(readvalue)*2-3]=0;
+ CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
+ myvalue[UnicodeLength(myvalue)*2-2]=0;
+ myvalue[UnicodeLength(myvalue)*2-1]=0;
+
dbgprintf("%s\n",DecodeUnicodeString(readvalue));
} else {
myvalue[0]=0;
myvalue[1]=0;
return false;
}
} else {
strcpy(paramname,myname);
strcat(paramname,"Unicode");
readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
if (readvalue!=NULL) {
dbgprintf("%s %i\n",readvalue,strlen(readvalue));
DecodeHexBin (myvalue, readvalue, strlen(readvalue));
myvalue[strlen(readvalue)/2]=0;
myvalue[strlen(readvalue)/2+1]=0;
dbgprintf("%s\n",DecodeUnicodeString(myvalue));
} else {
strcpy(paramname,myname);
readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
if (readvalue!=NULL) {
- EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2);
+ EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
} else {
myvalue[0]=0;
myvalue[1]=0;
return false;
}
}
}
return true;
}
static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode)
{
unsigned char buffer[100];
int Length = 3;
sprintf(buffer, " = ");
SaveVCALDateTime(buffer, &Length, dt, NULL);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode)
{
unsigned char buffer[100];
sprintf(buffer, " = %04d%02d%02d%c%c", dt->Year, dt->Month, dt->Day,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
/* ---------------------- backup files ------------------------------------- */
static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
{
@@ -389,64 +390,75 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
}
if (text) {
sprintf(buffer,"Entry%02iText",j);
SaveBackupText(file,buffer,Pbk->Entries[j].Text, UseUnicode);
}
switch (Pbk->Entries[j].EntryType) {
case PBK_Number_General:
case PBK_Number_Mobile:
case PBK_Number_Work:
case PBK_Number_Fax:
case PBK_Number_Home:
case PBK_Number_Other:
case PBK_Number_Pager:
if (Pbk->Entries[j].VoiceTag!=0) {
sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
i = 0;
while (Pbk->Entries[j].SMSList[i]!=0) {
sprintf(buffer,"Entry%02iSMSList%02i = %i%c%c",j,i,Pbk->Entries[j].SMSList[i],13,10);
SaveBackupText(file, "", buffer, UseUnicode);
i++;
}
break;
default:
break;
}
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
+static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
+{
+ char buffer[1000];
+
+ sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveBackupText(file, "Text", Note->Text, UseUnicode);
+ sprintf(buffer, "%c%c",13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+}
+
static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
{
int i;
char buffer[1000];
sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBackupText(file, "", "Type = ", UseUnicode);
switch (Note->Type) {
case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break;
case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break;
case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break;
case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break;
case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break;
case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break;
case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break;
case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break;
case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break;
case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break;
case GSM_CAL_T_FOOT : sprintf(buffer,"Training/Football%c%c", 13,10); break;
case GSM_CAL_T_GOLF : sprintf(buffer,"Training/Golf%c%c", 13,10); break;
case GSM_CAL_T_GYM : sprintf(buffer,"Training/Gym%c%c", 13,10); break;
case GSM_CAL_T_HORS : sprintf(buffer,"Training/HorseRaces%c%c", 13,10); break;
case GSM_CAL_T_HOCK : sprintf(buffer,"Training/Hockey%c%c", 13,10); break;
case GSM_CAL_T_RACE : sprintf(buffer,"Training/Races%c%c", 13,10); break;
case GSM_CAL_T_RUGB : sprintf(buffer,"Training/Rugby%c%c", 13,10); break;
case GSM_CAL_T_SAIL : sprintf(buffer,"Training/Sailing%c%c", 13,10); break;
@@ -628,64 +640,106 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
case WAPSETTINGS_SPEED_AUTO : sprintf(buffer,"CallSpeed%02i = auto%c%c" ,i,13,10); break;
}
switch (settings->Settings[i].Speed) {
case WAPSETTINGS_SPEED_9600 :
case WAPSETTINGS_SPEED_14400:
case WAPSETTINGS_SPEED_AUTO :
SaveBackupText(file, "", buffer, UseUnicode);
default:
break;
}
sprintf(buffer,"User%02i",i);
SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode);
sprintf(buffer,"Password%02i",i);
SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode);
break;
case WAPSETTINGS_BEARER_USSD:
sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"ServiceCode%02i",i);
SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode);
if (settings->Settings[i].IsIP) {
sprintf(buffer,"IP%02i",i);
} else {
sprintf(buffer,"Number%02i",i);
}
SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode);
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
}
+static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"HomePage");
+ SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
+static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ sprintf(buffer,"PhonebookDB");
+ SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
+ sprintf(buffer,"CalendarDB");
+ SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
+ sprintf(buffer,"Server");
+ SaveBackupText(file, buffer, settings->Server, UseUnicode);
+ if (settings->SyncPhonebook) {
+ sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ if (settings->SyncCalendar) {
+ sprintf(buffer,"SyncCalendar = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncCalendar = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
{
unsigned char buffer[10000],buffer2[10000];
int x,y;
sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
for (y=0;y<bitmap->BitmapHeight;y++) {
for (x=0;x<bitmap->BitmapWidth;x++) {
buffer[x] = ' ';
if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#';
}
buffer[bitmap->BitmapWidth] = 0;
sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10);
SaveBackupText(file, "", buffer2, UseUnicode);
}
}
static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
{
unsigned char buffer[1000];
sprintf(buffer,"Location = %03i%c%c",bitmap->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
if (!bitmap->DefaultName) SaveBackupText(file, "Name", bitmap->Text, UseUnicode);
if (!bitmap->DefaultRingtone) {
if (bitmap->FileSystemRingtone) {
sprintf(buffer,"FileRingtone = %02x%c%c",bitmap->RingtoneID,13,10);
} else {
sprintf(buffer,"Ringtone = %02x%c%c",bitmap->RingtoneID,13,10);
@@ -736,80 +790,81 @@ static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode)
sprintf(buffer,"Location = %03i%c%c",SMSC->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBackupText(file, "Name", SMSC->Name, UseUnicode);
SaveBackupText(file, "Number", SMSC->Number, UseUnicode);
SaveBackupText(file, "DefaultNumber", SMSC->DefaultNumber, UseUnicode);
SaveBackupText(file, "", "Format = ", UseUnicode);
switch (SMSC->Format) {
case SMS_FORMAT_Text : sprintf(buffer,"Text"); break;
case SMS_FORMAT_Fax : sprintf(buffer,"Fax"); break;
case SMS_FORMAT_Email : sprintf(buffer,"Email"); break;
case SMS_FORMAT_Pager : sprintf(buffer,"Pager"); break;
}
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"%c%cValidity = ",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
switch (SMSC->Validity.Relative) {
case SMS_VALID_1_Hour : sprintf(buffer, "1hour" ); break;
case SMS_VALID_6_Hours : sprintf(buffer, "6hours" ); break;
case SMS_VALID_1_Day : sprintf(buffer, "24hours" ); break;
case SMS_VALID_3_Days : sprintf(buffer, "72hours" ); break;
case SMS_VALID_1_Week : sprintf(buffer, "1week" ); break;
case SMS_VALID_Max_Time :
default : sprintf(buffer,"MaximumTime" ); break;
}
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"%c%c%c%c",13,10,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode)
{
unsigned char buffer[45000];
- int i,j;
sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBackupText(file, "Name", ringtone->Name, UseUnicode);
switch (ringtone->Format) {
case RING_NOKIABINARY:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode);
break;
case RING_MIDI:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode);
break;
+ case RING_MMF:
+ EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
+ SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
+ break;
case RING_NOTETONE:
break;
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
{
unsigned char buffer[1000];
sprintf(buffer,"[Operator]%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBitmapEntry(file, bitmap, UseUnicode);
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode)
{
unsigned char buffer[1000];
int j;
sprintf(buffer,"Location = %i%c%c",ToDo->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
switch (ToDo->Priority) {
case GSM_Priority_High:
sprintf(buffer,"Priority = High%c%c",13,10);
break;
case GSM_Priority_Medium:
@@ -1046,99 +1101,120 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
}
if (backup->DateTimeAvailable) {
SaveBackupText(file, "", "DateTime", UseUnicode);
SaveVCalDateTime(file, &backup->DateTime, UseUnicode);
}
sprintf(buffer,"Format = 1.03%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
i=0;
while (backup->PhonePhonebook[i]!=NULL) {
sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode);
i++;
}
i=0;
while (backup->SIMPhonebook[i]!=NULL) {
sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode);
i++;
}
i=0;
while (backup->Calendar[i]!=NULL) {
sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveCalendarEntry(file, backup->Calendar[i], UseUnicode);
i++;
}
i=0;
+ while (backup->Note[i]!=NULL) {
+ sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveNoteEntry(file, backup->Note[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->CallerLogos[i]!=NULL) {
sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode);
i++;
}
i=0;
while (backup->SMSC[i]!=NULL) {
sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveSMSCEntry(file, backup->SMSC[i], UseUnicode);
i++;
}
i=0;
while (backup->WAPBookmark[i]!=NULL) {
sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode);
i++;
}
i=0;
while (backup->WAPSettings[i]!=NULL) {
sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode);
i++;
}
i=0;
while (backup->MMSSettings[i]!=NULL) {
sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode);
i++;
}
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode);
i++;
}
i=0;
while (backup->ToDo[i]!=NULL) {
sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveToDoEntry(file, backup->ToDo[i], UseUnicode);
i++;
}
i=0;
while (backup->Profiles[i]!=NULL) {
sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveProfileEntry(file, backup->Profiles[i], UseUnicode);
i++;
}
i=0;
while (backup->FMStation[i]!=NULL) {
sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveFMStationEntry(file, backup->FMStation[i], UseUnicode);
i++;
}
i=0;
while (backup->GPRSPoint[i]!=NULL) {
sprintf(buffer,"[GPRSPoint%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveGPRSPointEntry(file, backup->GPRSPoint[i], UseUnicode);
@@ -2627,65 +2703,190 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
backup->GPRSPoint[num]->Location = num + 1;
ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode);
num++;
}
}
num = 0;
for (h = file_info; h != NULL; h = h->Next) {
found = false;
if (UseUnicode) {
EncodeUnicode(buffer,"Note",4);
if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
} else {
if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
}
if (found) {
readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode);
if (readvalue==NULL) break;
if (num < GSM_BACKUP_MAX_NOTE) {
backup->Note[num] = malloc(sizeof(GSM_NoteEntry));
if (backup->Note[num] == NULL) return ERR_MOREMEMORY;
backup->Note[num + 1] = NULL;
} else {
dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n");
return ERR_MOREMEMORY;
}
ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode);
num++;
}
}
if (backup->MD5Original[0]!=0) {
FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated);
}
-
+ for (h = file_info; h != NULL; h = h->Next) {
+ found = false;
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Backup",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Checksum",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Profile",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"PhonePBK",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SIMPBK",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Calendar",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Caller",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SMSC",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPBookmark",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Bookmark",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPSettings",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Settings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"MMSSettings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Ringtone",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"TODO",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Startup",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Operator",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"FMStation",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"GPRSPoint",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Note",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
+ }
+ if (!found) return ERR_NOTIMPLEMENTED;
+ }
return ERR_NONE;
}
/* ---------------------- backup files for SMS ----------------------------- */
static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS)
{
unsigned char buffer[10000], *readvalue;
GSM_SetDefaultSMSData(SMS);
SMS->PDU = SMS_Submit;
SMS->SMSC.Location = 0;
sprintf(buffer,"SMSC");
ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false);
sprintf(buffer,"ReplySMSC");
SMS->ReplyViaSameSMSC = false;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) {
if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true;
}
sprintf(buffer,"Class");
SMS->Class = -1;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) SMS->Class = atoi(readvalue);
sprintf(buffer,"Sent");
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) {
ReadVCALDateTime(readvalue, &SMS->DateTime);
SMS->PDU = SMS_Deliver;
}
sprintf(buffer,"RejectDuplicates");
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
@@ -44,237 +44,255 @@ void GSM_FreeBackup(GSM_Backup *backup)
}
i=0;
while (backup->CallerLogos[i]!=NULL) {
free(backup->CallerLogos[i]);
backup->CallerLogos[i] = NULL;
i++;
}
i=0;
while (backup->SMSC[i]!=NULL) {
free(backup->SMSC[i]);
backup->SMSC[i] = NULL;
i++;
}
i=0;
while (backup->WAPBookmark[i]!=NULL) {
free(backup->WAPBookmark[i]);
backup->WAPBookmark[i] = NULL;
i++;
}
i=0;
while (backup->WAPSettings[i]!=NULL) {
free(backup->WAPSettings[i]);
backup->WAPSettings[i] = NULL;
i++;
}
i=0;
while (backup->MMSSettings[i]!=NULL) {
free(backup->MMSSettings[i]);
backup->MMSSettings[i] = NULL;
i++;
}
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ free(backup->SyncMLSettings[i]);
+ backup->SyncMLSettings[i] = NULL;
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ free(backup->ChatSettings[i]);
+ backup->ChatSettings[i] = NULL;
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
free(backup->Ringtone[i]);
backup->Ringtone[i] = NULL;
i++;
}
i=0;
while (backup->ToDo[i]!=NULL) {
free(backup->ToDo[i]);
backup->ToDo[i] = NULL;
i++;
}
i=0;
while (backup->Profiles[i]!=NULL) {
free(backup->Profiles[i]);
backup->Profiles[i] = NULL;
i++;
}
i=0;
while (backup->FMStation[i]!=NULL) {
free(backup->FMStation[i]);
backup->FMStation[i] = NULL;
i++;
}
if (backup->StartupLogo!=NULL) {
free(backup->StartupLogo);
backup->StartupLogo = NULL;
}
if (backup->OperatorLogo!=NULL) {
free(backup->OperatorLogo);
backup->OperatorLogo = NULL;
}
i=0;
while (backup->GPRSPoint[i]!=NULL) {
free(backup->GPRSPoint[i]);
backup->GPRSPoint[i] = NULL;
i++;
}
i=0;
while (backup->Note[i]!=NULL) {
free(backup->Note[i]);
backup->Note[i] = NULL;
i++;
}
}
GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode)
{
- if (strstr(FileName,".lmb")) {
+ if (mystrcasestr(FileName,".lmb")) {
return SaveLMB(FileName,backup);
- } else if (strstr(FileName,".vcs")) {
+ } else if (mystrcasestr(FileName,".vcs")) {
return SaveVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return SaveVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return SaveLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return SaveICS(FileName,backup);
} else {
return SaveBackup(FileName,backup, UseUnicode);
}
}
GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
{
FILE *file;
unsigned char buffer[300];
file = fopen(FileName, "rb");
if (file == NULL) return ERR_CANTOPENFILE;
fread(buffer, 1, 9, file); /* Read the header of the file. */
fclose(file);
GSM_ClearBackup(backup);
/* Attempt to identify filetype */
- if (strstr(FileName,".vcs")) {
+ if (mystrcasestr(FileName,".vcs")) {
return LoadVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return LoadVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return LoadLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return LoadICS(FileName,backup);
} else if (memcmp(buffer, "LMB ",4)==0) {
return LoadLMB(FileName,backup);
} else if (buffer[0] == 0xFE && buffer[1] == 0xFF) {
return LoadBackup(FileName,backup,true);
} else if (buffer[0] == 0xFF && buffer[1] == 0xFE) {
return LoadBackup(FileName,backup,true);
} else {
return LoadBackup(FileName,backup,false);
}
}
void GSM_ClearBackup(GSM_Backup *backup)
{
backup->PhonePhonebook [0] = NULL;
backup->SIMPhonebook [0] = NULL;
backup->Calendar [0] = NULL;
backup->CallerLogos [0] = NULL;
backup->SMSC [0] = NULL;
backup->WAPBookmark [0] = NULL;
backup->WAPSettings [0] = NULL;
backup->MMSSettings [0] = NULL;
+ backup->SyncMLSettings [0] = NULL;
+ backup->ChatSettings [0] = NULL;
backup->Ringtone [0] = NULL;
backup->Profiles [0] = NULL;
backup->ToDo [0] = NULL;
backup->GPRSPoint [0] = NULL;
backup->FMStation [0] = NULL;
backup->Note [0] = NULL;
backup->StartupLogo = NULL;
backup->OperatorLogo = NULL;
backup->Creator [0] = 0;
backup->IMEI [0] = 0;
backup->Model [0] = 0;
backup->DateTimeAvailable = false;
backup->MD5Original [0] = 0;
backup->MD5Calculated [0] = 0;
}
void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
{
info->UseUnicode = false;
info->IMEI = false;
info->Model = false;
info->DateTime = false;
info->PhonePhonebook = false;
info->SIMPhonebook = false;
info->ToDo = false;
info->Calendar = false;
info->CallerLogos = false;
info->SMSC = false;
info->WAPBookmark = false;
info->WAPSettings = false;
info->MMSSettings = false;
+ info->SyncMLSettings = false;
+ info->ChatSettings = false;
info->Ringtone = false;
info->StartupLogo = false;
info->OperatorLogo = false;
info->Profiles = false;
info->FMStation = false;
info->GPRSPoint = false;
info->Note = false;
if (strstr(FileName,".lmb")) {
info->PhonePhonebook = true;
info->SIMPhonebook = true;
info->CallerLogos = true;
info->StartupLogo = true;
} else if (strstr(FileName,".vcs")) {
info->ToDo = true;
info->Calendar = true;
} else if (strstr(FileName,".vcf")) {
info->PhonePhonebook = true;
} else if (strstr(FileName,".ics")) {
info->ToDo = true;
info->Calendar = true;
} else if (strstr(FileName,".ldif")) {
info->PhonePhonebook = true;
} else {
info->UseUnicode = true;
info->IMEI = true;
info->Model = true;
info->DateTime = true;
info->PhonePhonebook = true;
info->SIMPhonebook = true;
info->ToDo = true;
info->Calendar = true;
info->CallerLogos = true;
info->SMSC = true;
info->WAPBookmark = true;
info->WAPSettings = true;
info->MMSSettings = true;
+ info->SyncMLSettings = true;
+ info->ChatSettings = true;
info->Ringtone = true;
info->StartupLogo = true;
info->OperatorLogo = true;
info->Profiles = true;
info->FMStation = true;
info->GPRSPoint = true;
info->Note = true;
}
}
void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup)
{
GSM_GetBackupFormatFeatures(FileName, info);
if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false;
if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false;
if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false;
if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false;
if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false;
if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false;
if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false;
if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false;
if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false;
if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false;
/* .... */
}
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -1,48 +1,50 @@
/* (c) 2003-2004 by Marcin Wiacek */
#ifndef __gsm_back_h
#define __gsm_back_h
#include "backgen.h"
#ifdef GSM_ENABLE_BACKUP
GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode);
GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup);
void GSM_ClearBackup (GSM_Backup *backup);
void GSM_FreeBackup (GSM_Backup *backup);
typedef struct {
bool UseUnicode;
bool IMEI;
bool Model;
bool DateTime;
bool ToDo;
bool PhonePhonebook;
bool SIMPhonebook;
bool Calendar;
bool CallerLogos;
bool SMSC;
bool WAPBookmark;
bool Profiles;
bool WAPSettings;
bool MMSSettings;
+ bool SyncMLSettings;
+ bool ChatSettings;
bool Ringtone;
bool StartupLogo;
bool OperatorLogo;
bool FMStation;
bool GPRSPoint;
bool Note;
} GSM_Backup_Info;
void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info);
void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup);
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -376,65 +376,65 @@ typedef struct {
* Number of entries.
*/
int EntriesNum;
/**
* Values of current entry.
*/
GSM_SubToDoEntry Entries[GSM_TODO_ENTRIES];
} GSM_ToDoEntry;
void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone);
typedef enum {
Nokia_VToDo = 1,
SonyEricsson_VToDo
} GSM_VToDoVersion;
GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version);
/**
* Status of to do entries.
*/
typedef struct {
/**
* Number of used positions.
*/
int Used;
} GSM_ToDoStatus;
/* --------------------------- note ---------------------------------------- */
typedef struct {
int Location;
- char Text[100];
+ char Text[3000*2];
} GSM_NoteEntry;
GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note);
/* --------------------------- alarm --------------------------------------- */
/**
* Alarm values.
*/
typedef struct {
/**
* Location where it is stored.
*/
int Location;
/**
* Date and time of alarm.
*/
GSM_DateTime DateTime;
/**
* Whether it repeats each day.
*/
bool Repeating;
/**
* Text that is shown on display.
*/
char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2];
} GSM_Alarm;
/* --------------------------- calendar & todo ----------------------------- */
GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer);
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
@@ -217,111 +217,189 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W
AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x60);
}
}
Buffer[(*Length)++] = 0x01; //END PARMeter
/* URL */
Buffer[(*Length)++] = 0x86; //CHARACTERISTIC-LIST with attributes
if (MMS) {
Buffer[(*Length)++] = 0x7C; //TYPE = MMSURL
} else {
Buffer[(*Length)++] = 0x07; //TYPE = URL
}
Buffer[(*Length)++] = 0x11; //VALUE
Buffer[(*Length)++] = 0x03; //Inline string
sprintf(buffer,"%s",DecodeUnicodeString(settings->HomePage));
for (i=0;i<(int)strlen(buffer);i++) {
Buffer[(*Length)++] = buffer[i];//Text
}
Buffer[(*Length)++] = 0x00; //END Inline string
Buffer[(*Length)++] = 0x01; //END PARMeter
/* ISP_NAME (name) */
Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
Buffer[(*Length)++] = 0x08; //TYPE=NAME
Buffer[(*Length)++] = 0x01; //END PARMeter
/* Settings name */
AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title));
Buffer[(*Length)++] = 0x01; //END PARMeter
Buffer[(*Length)++] = 0x01; //END PARMeter
}
/* http://forum.nokia.com: OTA Settings 7.0 */
+/* first it used default/ISO coding */
+/* Joergen Thomsen changed to UTF8 */
void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark)
{
unsigned char buffer[100];
- bool UnicodeCoding = false;
- EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
- if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
+// bool UnicodeCoding = false;
+// EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
+// if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
Buffer[(*Length)++] = 0x01; //Push ID
Buffer[(*Length)++] = 0x06; //PDU Type (push)
Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers)
strcpy(Buffer+(*Length),"\x1F\x2B");
(*Length)=(*Length)+2; //Value length
strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks");
(*Length)=(*Length)+40; //MIME-Type
Buffer[(*Length)++] = 0x00; //end inline string
strcpy(Buffer+(*Length),"\x81\xEA");
(*Length)=(*Length)+2; //charset UTF-8 short int.
+ /* removed by Joergen Thomsen */
/* Block from sniffs. UNKNOWN */
- if (!UnicodeCoding) {
- Buffer[(*Length)++] = 0x00;
- Buffer[(*Length)++] = 0x01;
- } else {
- strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
- (*Length)=(*Length)+4;
- }
- Buffer[(*Length)++] = 0x00;
+// if (!UnicodeCoding) {
+// Buffer[(*Length)++] = 0x00;
+// Buffer[(*Length)++] = 0x01;
+// } else {
+// strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
+// (*Length)=(*Length)+4;
+// }
+// Buffer[(*Length)++] = 0x00;
+
+ /* added by Joergen Thomsen */
+ Buffer[(*Length)++] = 0x01; // Version WBXML 1.1
+ Buffer[(*Length)++] = 0x01; // Unknown public identifier
+ Buffer[(*Length)++] = 0x6A; // charset UTF-8
+ Buffer[(*Length)++] = 0x00; // string table length
Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content
/* URL */
Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK
Buffer[(*Length)++] = 0x01; //END PARMeter
- if (!UnicodeCoding) {
- /* TITLE */
- AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
- /* URL */
- AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
- } else {
+
+ /* removed by Joergen Thomsen */
+// if (!UnicodeCoding) {
+// /* TITLE */
+// AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
+// /* URL */
+// AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
+// } else {
+// /* TITLE */
+// AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
+// /* URL */
+// AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
+// }
+
+ /* added by Joergen Thomsen */
/* TITLE */
- AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
+ EncodeUTF8(buffer, bookmark->Title);
+ AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer));
/* URL */
- AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
+ EncodeUTF8(buffer, bookmark->Address);
+ AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer));
+
+ Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC)
+ Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC-LIST)
}
- Buffer[(*Length)++] = 0x01; //END PARMeter
- Buffer[(*Length)++] = 0x01; //END PARMeter
+
+void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL)
+{
+ int i;
+
+ Buffer[(*Length)++] = 0x01; //Push ID
+ Buffer[(*Length)++] = 0x06; //PDU Type (push)
+ Buffer[(*Length)++] = 28; //Headers length (content type + headers)
+ strcpy(Buffer+(*Length),"\x1F\x23");
+ (*Length)=(*Length)+2; //Value length
+ strcpy(Buffer+(*Length),"application/vnd.wap.sic");
+ (*Length)=(*Length)+23; //MIME-Type
+ Buffer[(*Length)++] = 0x00; //end inline string
+ strcpy(Buffer+(*Length),"\x81\xEA");
+ (*Length)=(*Length)+2; //charset UTF-8 short int.
+
+ Buffer[(*Length)++] = 0x02; // WBXML 1.2
+ Buffer[(*Length)++] = 0x05; // SI 1.0 Public Identifier
+ Buffer[(*Length)++] = 0x6A; // charset UTF-8
+ Buffer[(*Length)++] = 0x00; // string table length
+ Buffer[(*Length)++] = 0x45; // SI with content
+ Buffer[(*Length)++] = 0xC6; // indication with content and attributes
+ Buffer[(*Length)++] = 0x0B; // address
+ Buffer[(*Length)++] = 0x03; // Inline string
+ for (i=0;i<(int)strlen(URL);i++) {
+ Buffer[(*Length)++] = URL[i];//Text
+ }
+ Buffer[(*Length)++] = 0x00; // END Inline string
+
+#ifdef XXX
+ Buffer[(*Length)++] = 0x0A; // created...
+ Buffer[(*Length)++] = 0xC3; // OPAQUE
+ Buffer[(*Length)++] = 0x07; // length
+ Buffer[(*Length)++] = 0x19; // year
+ Buffer[(*Length)++] = 0x80; // year
+ Buffer[(*Length)++] = 0x21; // month
+ Buffer[(*Length)++] = 0x12; // ..
+ Buffer[(*Length)++] = 0x00; // ..
+ Buffer[(*Length)++] = 0x00; // ..
+ Buffer[(*Length)++] = 0x00; // ..
+ Buffer[(*Length)++] = 0x10; // expires
+ Buffer[(*Length)++] = 0xC3; // OPAQUE
+ Buffer[(*Length)++] = 0x04; // length
+ Buffer[(*Length)++] = 0x20; // year
+ Buffer[(*Length)++] = 0x10; // year
+ Buffer[(*Length)++] = 0x06; // month
+ Buffer[(*Length)++] = 0x25; // day
+#endif
+
+ Buffer[(*Length)++] = 0x01; // END (indication)
+ Buffer[(*Length)++] = 0x03; // Inline string
+ for (i=0;i<(int)strlen(Text);i++) {
+ Buffer[(*Length)++] = Text[i]; //Text
+ }
+ Buffer[(*Length)++] = 0x00; // END Inline string
+ Buffer[(*Length)++] = 0x01; // END (indication)
+ Buffer[(*Length)++] = 0x01; // END (SI)
}
void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length)
{
int i;
strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F");
(*Length)=(*Length)+4;
/* Unique MMS ID ? */
strcpy(Buffer+(*Length),"123456789");
(*Length)=(*Length)+9;
Buffer[(*Length)++] = 0x00;
strcpy(Buffer+(*Length),"\x8D\x90\x89");
(*Length)=(*Length)+3;
strcpy(Buffer+(*Length),"\x01\x81\x86\x81\x96");
(*Length)=(*Length)+5;
if (UnicodeLength(Info->Subject) != 0) {
sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Subject));
(*Length)=(*Length)+UnicodeLength(Info->Subject);
Buffer[(*Length)++] = 0x00;
}
for (i=0;i<Info->EntriesNum;i++) {
switch(Info->Entries[i].ID) {
case MMS_Text:
strcpy(Buffer+(*Length),"\x84\xA3\x01\x04\x04\x03\x83\x81\xEA");
(*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
@@ -59,64 +59,66 @@ typedef struct {
bool ReadOnly;
char Proxy [(100+1)*2];
int ProxyPort;
char Proxy2 [(100+1)*2];
int Proxy2Port;
WAPSettings_Bearer ActiveBearer;
} GSM_MultiWAPSettings;
void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_WAPSettings *settings, bool MMS);
/* -------------------------------- WAP Bookmark --------------------------- */
typedef struct {
char Address [(255+1)*2];
char Title [(50+1)*2];
int Location;
} GSM_WAPBookmark;
void NOKIA_EncodeWAPBookmarkSMSText (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark);
GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark);
/* ------------------------------ MMS Indicator ---------------------------- */
typedef struct {
unsigned char Address[500];
unsigned char Title[200];
unsigned char Sender[200];
} GSM_MMSIndicator;
void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator);
+void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL);
+
/* ------------------------------ MMS file --------------------------------- */
#define MAX_MULTI_MMS 20
typedef enum {
MMS_Text = 1,
MMS_Bitmap_JPG
} EncodeMultiPartMMSID;
typedef struct {
EncodeMultiPartMMSID ID;
GSM_File File;
unsigned char *Buffer;
} EncodeMultiPartMMSEntry;
typedef struct {
/* Input values */
EncodeMultiPartMMSEntry Entries[MAX_MULTI_MMS];
int EntriesNum;
unsigned char Source[200];
unsigned char Destination[200];
unsigned char Subject[200];
} GSM_EncodeMultiPartMMSInfo;
void GSM_EncodeMMSFile (GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length);
void GSM_ClearMultiPartMMSInfo (GSM_EncodeMultiPartMMSInfo *Info);
/* ------------------------------------------------------------------------ */
typedef struct {
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,36 +1,37 @@
/* (c) 2001-2004 by Marcin Wiacek */
#include <string.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include "../misc/misc.h"
#include "../misc/coding/coding.h"
#include "gsmlogo.h"
#include "gsmnet.h"
void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height)
{
*width = 0;
*height = 0;
switch (Type) {
case GSM_EMSSmallPicture : *width=8; *height=8; break;
case GSM_EMSMediumPicture : *width=16; *height=16; break;
case GSM_EMSBigPicture : *width=32; *height=32; break;
case GSM_NokiaOperatorLogo :
case GSM_NokiaCallerLogo : *width=72; *height=14; break;
case GSM_NokiaPictureImage : *width=72; *height=28; break;
case GSM_Nokia7110OperatorLogo :
case GSM_Nokia6510OperatorLogo : *width=78; *height=21; break;
case GSM_NokiaStartupLogo : *width=84; *height=48; break;
case GSM_Nokia6210StartupLogo : *width=96; *height=60; break;
case GSM_Nokia7110StartupLogo : *width=96; *height=65; break;
case GSM_EMSVariablePicture : break;
case GSM_AlcatelBMMIPicture : break;
}
}
int PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, int Width, int Height)
{
int width, height, x;
PHONE_GetBitmapWidthHeight(Type, &width, &height);
@@ -132,64 +133,65 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B
if (Type != GSM_Nokia6510OperatorLogo && Type != GSM_Nokia7110OperatorLogo && Type != GSM_EMSVariablePicture) {
Bitmap->BitmapHeight = height;
Bitmap->BitmapWidth = width;
}
switch (Type) {
case GSM_NokiaOperatorLogo :
case GSM_Nokia7110OperatorLogo :
case GSM_Nokia6510OperatorLogo : Bitmap->Type=GSM_OperatorLogo; break;
case GSM_NokiaCallerLogo : Bitmap->Type=GSM_CallerGroupLogo; break;
case GSM_AlcatelBMMIPicture :
case GSM_NokiaStartupLogo :
case GSM_Nokia7110StartupLogo :
case GSM_Nokia6210StartupLogo : Bitmap->Type=GSM_StartupLogo; break;
case GSM_NokiaPictureImage :
case GSM_EMSVariablePicture :
case GSM_EMSSmallPicture :
case GSM_EMSMediumPicture :
case GSM_EMSBigPicture : Bitmap->Type=GSM_PictureImage; break;
}
Bitmap->Location = 0;
Bitmap->Text[0] = 0;
Bitmap->Text[1] = 0;
Bitmap->BitmapEnabled = false;
Bitmap->DefaultName = false;
Bitmap->DefaultBitmap = false;
Bitmap->DefaultRingtone = false;
Bitmap->RingtoneID = 0;
Bitmap->NetworkCode[0] = 0;
Bitmap->Sender[0] = 0;
Bitmap->Sender[1] = 0;
Bitmap->ID = 0;
+ Bitmap->Name = NULL;
GSM_ClearBitmap(Bitmap);
for (x=0;x<Bitmap->BitmapWidth;x++) {
for (y=0;y<Bitmap->BitmapHeight;y++) {
if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) {
GSM_SetPointBitmap(Bitmap,x,y);
}
}
}
}
void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height)
{
memset(buffer,0,PHONE_GetBitmapSize(Type,width,height));
}
void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
{
int width, height, x, y;
GSM_Bitmap dest;
PHONE_GetBitmapWidthHeight(Type, &width, &height);
if (width == 0 && height == 0) {
width = Bitmap->BitmapWidth;
height = Bitmap->BitmapHeight;
}
GSM_ResizeBitmap(&dest, Bitmap, width, height);
PHONE_ClearBitmap(Type, buffer, width, height);
for (x=0;x<width;x++) {
for (y=0;y<height;y++) {
if (GSM_IsPointBitmap(&dest,x,y)) PHONE_SetPointBitmap(Type, buffer, x, y, width, height);
@@ -597,75 +599,75 @@ static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap)
fwrite(header,1,sizeof(header),file);
PHONE_EncodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]);
fwrite(buffer,1,PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0),file);
return ERR_NONE;
}
static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap)
{
unsigned char buffer[4];
buffer[0] = 0x00;
buffer[1] = 0x00;
buffer[2] = bitmap->Bitmap[0].BitmapWidth;
buffer[3] = bitmap->Bitmap[0].BitmapHeight;
fwrite(buffer,1,4,file);
PrivSaveNLMWBMP(file, &bitmap->Bitmap[0]);
return ERR_NONE;
}
GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
{
FILE *file;
GSM_Error error=ERR_NONE;
file = fopen(FileName, "wb");
if (file == NULL) return ERR_CANTOPENFILE;
/* Attempt to identify filetype */
- if (strstr(FileName,".nlm")) {
+ if (mystrcasestr(FileName,".nlm")) {
error=savenlm(file,bitmap);
- } else if (strstr(FileName,".ngg")) {
+ } else if (mystrcasestr(FileName,".ngg")) {
error=savengg(file,bitmap);
- } else if (strstr(FileName,".nol")) {
+ } else if (mystrcasestr(FileName,".nol")) {
error=savenol(file,bitmap);
- } else if (strstr(FileName,".xpm")) {
+ } else if (mystrcasestr(FileName,".xpm")) {
error=savexpm(file,bitmap);
- } else if (strstr(FileName,".nsl")) {
+ } else if (mystrcasestr(FileName,".nsl")) {
error=savensl(file,bitmap);
- } else if (strstr(FileName,".wbmp")) {
+ } else if (mystrcasestr(FileName,".wbmp")) {
error=savewbmp(file,bitmap);
} else {
error=savebmp(file,bitmap);
}
fclose(file);
return error;
}
GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap)
{
bool first_white,isfile=false;
unsigned char buff[34];
int w,h,pos,y,x,i,buffpos=0;
#ifdef DEBUG
int sizeimage=0;
#endif
if (bitmap->Type == GSM_None) bitmap->Type = GSM_StartupLogo;
if (file!=NULL) isfile=true;
if (isfile) {
fread(buff, 1, 34, file);
} else {
memcpy(buff,buffer,34);
}
/* height and width of image in the file */
h=buff[22]+256*buff[21];
w=buff[18]+256*buff[17];
dbgprintf("Image Size in BMP file: %dx%d\n",w,h);
GSM_GetMaxBitmapWidthHeight(bitmap->Type, &bitmap->BitmapWidth, &bitmap->BitmapHeight);
@@ -926,78 +928,111 @@ static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap)
#endif
if (!strncmp(block, "NSLD", 4)) {
bitmap->Bitmap[0].BitmapHeight = 48;
bitmap->Bitmap[0].BitmapWidth = 84;
OldType = bitmap->Bitmap[0].Type;
PHONE_DecodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]);
if (OldType != GSM_None) bitmap->Bitmap[0].Type = OldType;
dbgprintf("Startup logo (size %i)\n",block_size);
}
}
}
}
bitmap->Number = 1;
return(ERR_NONE);
}
static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
{
unsigned char buffer[10000];
fread(buffer,1,4,file);
bitmap->Bitmap[0].BitmapWidth = buffer[2];
bitmap->Bitmap[0].BitmapHeight = buffer[3];
bitmap->Number = 1;
fread(buffer,1,10000,file);
PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]);
GSM_ReverseBitmap(&bitmap->Bitmap[0]);
return ERR_NONE;
}
+static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
+{
+ GSM_Bitmap *bmap = &bitmap->Bitmap[0];
+ char *buffer;
+ struct stat st;
+ int length;
+
+ dbgprintf("loading gif file\n");
+ fstat(fileno(file), &st);
+ bmap->BinaryPic.Length = length = st.st_size;
+ bmap->BinaryPic.Buffer = buffer = malloc(length);
+ if (bmap->BinaryPic.Buffer == NULL)
+ return ERR_MOREMEMORY;
+
+ fread(buffer, 1, length, file);
+ dbgprintf("Length %i name \"%s\"\n", length,
+ DecodeUnicodeString(bmap->Name));
+
+ bmap->Type = GSM_PictureBinary;
+ bmap->BinaryPic.Type = PICTURE_GIF;
+ bmap->BitmapWidth = 256 * buffer[7] + buffer[6];
+ bmap->BitmapHeight = 256 * buffer[9] + buffer[8];
+ bitmap->Number = 1;
+
+ return ERR_NONE;
+}
+
GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
{
FILE *file;
unsigned char buffer[300];
file = fopen(FileName, "rb");
if (file == NULL) return ERR_CANTOPENFILE;
+ bitmap->Bitmap[0].Name = malloc((strlen(FileName) + 1) * 2);
+ if (bitmap->Bitmap[0].Name == NULL) return ERR_MOREMEMORY;
+ EncodeUnicode(bitmap->Bitmap[0].Name, FileName, strlen(FileName));
+
fread(buffer, 1, 9, file); /* Read the header of the file. */
rewind(file);
bitmap->Bitmap[0].DefaultBitmap = false;
/* Attempt to identify filetype */
if (memcmp(buffer, "BM",2)==0) {
return loadbmp(file,bitmap);
} else if (buffer[0] == 0x00 && buffer[1] == 0x00) {
return loadwbmp(file,bitmap);
} else if (memcmp(buffer, "NLM",3)==0) {
return loadnlm(file,bitmap);
} else if (memcmp(buffer, "NOL",3)==0) {
return loadnolngg(file,bitmap,true);
} else if (memcmp(buffer, "NGG",3)==0) {
return loadnolngg(file,bitmap,false);
} else if (memcmp(buffer, "FORM",4)==0) {
return loadnsl(file,bitmap);
+ } else if (memcmp(buffer, "GIF",3)==0) {
+ return loadgif(file,bitmap);
}
return ERR_UNKNOWN;
}
void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length)
{
int Width, Height;
Buffer[(*Length)++] = 0x00;
PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
Buffer[(*Length)++] = Width;
Buffer[(*Length)++] = Height;
Buffer[(*Length)++] = 0x01;
PHONE_EncodeBitmap(Type, Buffer + (*Length), Bitmap);
(*Length) = (*Length) + PHONE_GetBitmapSize(Type,0,0);
}
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,80 +1,98 @@
/* (c) 2002-2004 by Marcin Wiacek */
#ifndef __gsm_bitmaps_h
#define __gsm_bitmaps_h
#include "../gsmcomon.h"
+typedef enum {
+ PICTURE_BMP = 1,
+ PICTURE_GIF,
+ PICTURE_JPG,
+ PICTURE_ICN,
+ PICTURE_PNG
+} GSM_BinaryPicture_Types;
+
+typedef struct {
+ GSM_BinaryPicture_Types Type;
+ unsigned char *Buffer;
+ int Length;
+} GSM_BinaryPicture;
+
/**
* Enum to handle all possible bitmaps, which are not saved in various filesystems.
*/
typedef enum {
GSM_None = 1,
/**
* ID of static file in filesystem displayed during startup
*/
GSM_ColourStartupLogo_ID,
/**
* Static mono bitmap/ID of animated mono bitmap displayed during startup
*/
GSM_StartupLogo,
/**
* ID of static file in filesystem displayed instead of operator name
*/
GSM_ColourOperatorLogo_ID,
/**
* Mono bitmap displayed instead of operator name
*/
GSM_OperatorLogo,
/**
* ID of static file in filesystem displayed as wallpaper
*/
GSM_ColourWallPaper_ID,
/**
* Mono bitmap assigned to caller group
*/
GSM_CallerGroupLogo,
/**
* Text displayed during startup, which can't be removed from phone menu
*/
GSM_DealerNote_Text,
/**
* Text displayed during startup
*/
GSM_WelcomeNote_Text,
/**
* Image defined in Smart Messaging specification
*/
- GSM_PictureImage
+ GSM_PictureImage,
+ /**
+ * Binary picture (BMP, GIF, etc.)
+ */
+ GSM_PictureBinary
} GSM_Bitmap_Types;
#define GSM_BITMAP_SIZE (65+7)/8*96
#define GSM_BITMAP_TEXT_LENGTH 128
/**
* Structure for all possible bitmaps, which are not saved in various filesystems
*/
typedef struct {
/**
* For all: bitmap type
*/
GSM_Bitmap_Types Type;
/**
* For caller group logos: number of group
* For startup logos: number of animated bitmap
*/
unsigned char Location;
/**
* For dealer/welcome note text: text
* For caller group logo: name of group
* For picture images: text assigned to it
*/
unsigned char Text[2 * (GSM_BITMAP_TEXT_LENGTH + 1)];
/**
* For caller group logo: true, when logo is enabled in group
*/
bool BitmapEnabled;
/**
* For caller group logo: true, when group has default name
*/
bool DefaultName;
@@ -86,64 +104,72 @@ typedef struct {
* For caller group logo: true, when group has default ringtone
*/
bool DefaultRingtone;
/**
* For caller group logo: ringtone ID. Phone model specific
*/
unsigned char RingtoneID;
bool FileSystemRingtone;
/**
* For mono bitmaps: body of bitmap
*/
unsigned char BitmapPoints[GSM_BITMAP_SIZE];
/**
* For mono bitmaps: height specified in pixels
*/
unsigned char BitmapHeight;
/**
* For mono bitmaps: width specified in pixels
*/
unsigned char BitmapWidth;
/**
* For operator logos: Network operator code
*/
char NetworkCode[7];
/**
* For picture images: number of sender
*/
unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)];
/**
* For colour bitmaps: ID
*/
unsigned char ID;
+ /**
+ * For binary pictures (GIF, BMP, etc.): frame and length
+ */
+ GSM_BinaryPicture BinaryPic;
+ /**
+ * Bitmap name
+ */
+ char *Name;
} GSM_Bitmap;
#define MAX_MULTI_BITMAP 6
/**
* Structure to handle more than one bitmap
*/
typedef struct {
/**
* Number of bitmaps
*/
unsigned char Number;
/**
* All bitmaps
*/
GSM_Bitmap Bitmap[MAX_MULTI_BITMAP];
} GSM_MultiBitmap;
typedef enum {
GSM_NokiaStartupLogo = 1, /*size 84*48*/
GSM_NokiaOperatorLogo, /*size 72*14*/
GSM_Nokia7110OperatorLogo, /*size 78*21*/
GSM_Nokia6510OperatorLogo, /*size 78*21*/
GSM_NokiaCallerLogo, /*size 72*14*/
GSM_NokiaPictureImage, /*size 72*28*/
GSM_Nokia7110StartupLogo, /*size 96*65*/
GSM_Nokia6210StartupLogo, /*size 96*60*/
GSM_AlcatelBMMIPicture,
GSM_EMSSmallPicture, /*size 8* 8*/
GSM_EMSMediumPicture, /*size 16*16*/
GSM_EMSBigPicture, /*size 32*32*/
GSM_EMSVariablePicture
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
@@ -263,54 +263,59 @@ typedef struct {
/* File attributes */
bool Protected;
bool ReadOnly;
bool Hidden;
bool System;
} GSM_File;
GSM_Error GSM_ReadFile(char *FileName, GSM_File *File);
GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size);
void GSM_IdentifyFileFormat(GSM_File *File);
typedef struct {
int Free;
int Used;
} GSM_FileSystemStatus;
/* ----------------------------- GPRS access points ----------------------- */
typedef struct {
int Location;
unsigned char Name[300];
unsigned char URL[500];
bool Active;
} GSM_GPRSAccessPoint;
/* ------------------------------------------------------------------------ */
typedef enum {
GSM_Date_DDMMYYYY = 1,
GSM_Date_MMDDYYYY,
- GSM_Date_YYYYMMDD
+ GSM_Date_YYYYMMDD,
+ GSM_Date_DDMMMYY,
+ GSM_Date_MMDDYY,
+ GSM_Date_DDMMYY,
+ GSM_Date_YYMMDD,
+ GSM_Date_OFF
} GSM_DateFormat;
typedef struct {
unsigned char DateSeparator;
GSM_DateFormat DateFormat;
bool AMPMTime;
} GSM_Locale;
/* ------------------------------------------------------------------------ */
void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt);
void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start);
void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start);
bool ReadVCALText(char *Buffer, char *Start, char *Value);
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,41 +1,44 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* Based on some work from Ralf Thelen (7110 ringtones),
- * Gnokii (RTTL and SM) and others
+/* Based on some work from Ralf Thelen (7110 ringtones) and others */
+/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
*/
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include <sys/stat.h>
#ifdef WIN32
# include <windows.h>
#endif
#include "../gsmcomon.h"
#include "../misc/coding/coding.h"
#include "../gsmstate.h"
#include "gsmring.h"
#include "sms/gsmsms.h"
int GSM_RingNoteGetFrequency(GSM_RingNote Note)
{
double freq=0;
/* Values according to the software from http://iki.fi/too/sw/xring/
* generated with:
* perl -e 'print int(4400 * (2 **($_/12)) + .5)/10, "\n" for(3..14)'
*/
switch (Note.Note) {
case Note_C : freq = 523.3; break;
case Note_Cis: freq = 554.4; break;
case Note_D : freq = 587.3; break;
case Note_Dis: freq = 622.3; break;
case Note_E : freq = 659.3; break;
case Note_F : freq = 698.5; break;
case Note_Fis: freq = 740; break;
case Note_G : freq = 784; break;
case Note_Gis: freq = 830.6; break;
case Note_A : freq = 880; break;
case Note_Ais: freq = 932.3; break;
case Note_H : freq = 987.8; break;
case Note_Pause: break;
@@ -127,64 +130,70 @@ GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone)
DATA_Header[5] = ((unsigned char)wavfilesize / 256);
DATA_Header[6] = ((unsigned char)wavfilesize / (256*256));
DATA_Header[7] = ((unsigned char)wavfilesize / (256*256*256));
fseek( file, 0, SEEK_SET);
fwrite(&WAV_Header, 1, sizeof(WAV_Header), file);
fwrite(&FMT_Header, 1, sizeof(FMT_Header), file);
fwrite(&DATA_Header, 1, sizeof(DATA_Header), file);
return ERR_NONE;
}
static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone)
{
char nullchar=0x00;
fwrite(&nullchar,1,1,file);
fwrite(&nullchar,1,1,file);
fprintf(file,"\x0C\x01\x2C");
fprintf(file,"%s",DecodeUnicodeString(ringtone->Name));
fwrite(&nullchar,1,1,file);
fwrite(&nullchar,1,1,file);
fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
return ERR_NONE;
}
static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
{
fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
return ERR_NONE;
}
+static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
+{
+ fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
+ return ERR_NONE;
+}
+
GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
{
GSM_RingNoteScale DefNoteScale;
GSM_RingNoteDuration DefNoteDuration;
GSM_RingNoteStyle DefNoteStyle=0;
int DefNoteTempo=0;
bool started = false, firstcomma = true;
GSM_RingNote *Note;
unsigned char buffer[15];
int i,j,k=0;
/* Saves ringtone name */
fprintf(file,"%s:",DecodeUnicodeString(ringtone->Name));
/* Find the most frequently used duration */
for (i=0;i<6;i++) buffer[i]=0;
for (i=0;i<ringtone->NoteTone.NrCommands;i++) {
if (ringtone->NoteTone.Commands[i].Type == RING_Note) {
Note = &ringtone->NoteTone.Commands[i].Note;
/* some durations need 2 bytes in file, some 1 */
if (Note->Duration >= Duration_Full && Note->Duration <= Duration_1_8) {
buffer[Note->Duration/32]++;
}
if (Note->Duration >= Duration_1_16 && Note->Duration <= Duration_1_32) {
buffer[Note->Duration/32]+=2;
}
}
}
/* Now find the most frequently used */
@@ -456,64 +465,67 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
{
FILE *file;
file = fopen(FileName, "wb");
if (file == NULL) return ERR_CANTOPENFILE;
switch (ringtone->Format) {
case RING_NOTETONE:
if (strstr(FileName,".ott")) {
saveott(file,ringtone);
#ifndef ENABLE_LGPL
} else if (strstr(FileName,".mid")) {
savemid(file,ringtone);
#endif
} else if (strstr(FileName,".rng")) {
saveott(file,ringtone);
} else if (strstr(FileName,".imy")) {
saveimelody(file,ringtone);
} else if (strstr(FileName,".ime")) {
saveimelody(file,ringtone);
} else if (strstr(FileName,".wav")) {
savewav(file,ringtone);
} else {
saverttl(file, ringtone);
}
break;
case RING_NOKIABINARY:
savebin(file, ringtone);
break;
case RING_MIDI:
savepuremidi(file, ringtone);
break;
+ case RING_MMF:
+ savemmf(file, ringtone);
+ break;
}
fclose(file);
return ERR_NONE;
}
static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone)
{
GSM_RingNoteScale DefNoteScale = Scale_880;
GSM_RingNoteDuration DefNoteDuration = Duration_1_4;
GSM_RingNoteStyle DefNoteStyle = NaturalStyle;
int DefNoteTempo = 63, i=0;
unsigned char buffer[2000],Name[100];
GSM_RingNote *Note;
fread(buffer, 2000, 1, file);
ringtone->NoteTone.NrCommands = 0;
/* -------------- name ---------------- */
while (buffer[i] != ':') {
if (buffer[i] == 0x00) return ERR_NONE;
i++;
}
if (i == 0) {
/* This is for RTTL ringtones without name. */
EncodeUnicode(ringtone->Name,"Gammu",5);
} else {
memcpy(Name,buffer,i);
Name[i] = 0x00;
@@ -740,137 +752,166 @@ static GSM_Error loadcommunicator(FILE *file, GSM_Ringtone *ringtone)
static GSM_Error loadbin(FILE *file, GSM_Ringtone *ringtone)
{
int i;
unsigned char buffer[2000];
dbgprintf("loading binary\n");
ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file);
i=5;
while (buffer[i]!=0x00) i++;
EncodeUnicode(ringtone->Name,buffer+5,i-5);
while (buffer[i]!=0x02 && buffer[i+1]!=0xFC && buffer[i+2]!=0x09) {
i++;
}
ringtone->NokiaBinary.Length=ringtone->NokiaBinary.Length-i;
memcpy(ringtone->NokiaBinary.Frame,buffer+i,ringtone->NokiaBinary.Length);
dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
return ERR_NONE;
}
static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
{
unsigned char buffer[30000];
dbgprintf("loading midi\n");
EncodeUnicode(ringtone->Name,"MIDI",4);
ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file);
memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length);
dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
return ERR_NONE;
}
+static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
+{
+ struct stat st;
+ char *buffer;
+ int length;
+
+ dbgprintf("loading smaf file\n");
+ fstat(fileno(file), &st);
+ ringtone->BinaryTone.Length = length = st.st_size;
+ ringtone->BinaryTone.Buffer = buffer = malloc(length);
+ if (buffer == NULL)
+ return ERR_MOREMEMORY;
+ fread(buffer, 1, length, file);
+
+ dbgprintf("Length %i name \"%s\"\n", length,
+ DecodeUnicodeString(ringtone->Name));
+
+ return ERR_NONE;
+}
+
static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
{
unsigned char buffer[2000];
ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file);
if (buffer[18]==0x00 && buffer[21]!=0x02) {
/* DCT3, Unicode subformat, 62xx & 7110 */
CopyUnicodeString(ringtone->Name,buffer+18);
ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2);
memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length);
} else {
/* DCT3, normal subformat, 32xx/33xx/51xx/5210/5510/61xx/8xxx */
EncodeUnicode(ringtone->Name,buffer+17,buffer[16]);
ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (19+UnicodeLength(ringtone->Name));
memcpy(ringtone->NokiaBinary.Frame,buffer+19+UnicodeLength(ringtone->Name),ringtone->NokiaBinary.Length);
}
dbgprintf("Name \"%s\"\n",DecodeUnicodeString(ringtone->Name));
return ERR_NONE;
}
GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
{
FILE *file;
unsigned char buffer[300];
GSM_Error error = ERR_UNKNOWN;
dbgprintf("Loading ringtone %s\n",FileName);
file = fopen(FileName, "rb");
if (file == NULL) return ERR_CANTOPENFILE;
/* Read the header of the file. */
fread(buffer, 1, 4, file);
if (ringtone->Format == 0x00) {
ringtone->Format = RING_NOTETONE;
if (buffer[0]==0x00 && buffer[1]==0x00 &&
buffer[2]==0x0C && buffer[3]==0x01) {
ringtone->Format = RING_NOKIABINARY;
}
if (buffer[0]==0x00 && buffer[1]==0x00 &&
buffer[2]==0x00) {
ringtone->Format = RING_NOKIABINARY;
}
if (buffer[0]==0x4D && buffer[1]==0x54 &&
buffer[2]==0x68 && buffer[3]==0x64) {
ringtone->Format = RING_MIDI;
}
+ if (buffer[0]==0x4D && buffer[1]==0x4D &&
+ buffer[2]==0x4D && buffer[3]==0x44) {
+ ringtone->Format = RING_MMF;
+ }
}
rewind(file);
switch (ringtone->Format) {
case RING_NOTETONE:
if (buffer[0]==0x02 && buffer[1]==0x4A) {
error=loadott(file,ringtone);
} else if (buffer[0]==0xC7 && buffer[1]==0x45) {
error=loadcommunicator(file,ringtone);
} else {
error=loadrttl(file,ringtone);
}
ringtone->NoteTone.AllNotesScale=false;
break;
case RING_NOKIABINARY:
if (buffer[0]==0x00 && buffer[1]==0x00 &&
buffer[2]==0x0C && buffer[3]==0x01) {
error=loadbin(file,ringtone);
}
if (buffer[0]==0x00 && buffer[1]==0x00 &&
buffer[2]==0x00) {
error=loadre(file,ringtone);
}
break;
case RING_MIDI:
EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
error = loadpuremidi(file,ringtone);
+ break;
+ case RING_MMF:
+ EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
+ error = loadmmf(file,ringtone);
+ break;
}
fclose(file);
return(error);
}
/* -------------------------- required with Nokia & RTTL ------------------- */
/* Beats per Minute like written in Smart Messaging */
static int SM_BeatsPerMinute[] = {
25, 28, 31, 35, 40, 45, 50, 56, 63, 70,
80, 90, 100, 112, 125, 140, 160, 180, 200, 225,
250, 285, 320, 355, 400, 450, 500, 565, 635, 715,
800, 900
};
int GSM_RTTLGetTempo(int Beats)
{
int i=0;
while (Beats > SM_BeatsPerMinute[i] && SM_BeatsPerMinute[i] != 900) i++;
return i<<3;
}
/* This function packs the ringtone from the structure "ringtone" to
"package", where maxlength means length of package.
Function returns number of packed notes and change maxlength to
number of used chars in "package" */
unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength)
{
unsigned char CommandLength = 0x02;
unsigned char Loop = 0x15; /* Infinite */
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
@@ -91,79 +91,81 @@ typedef enum {
typedef struct {
GSM_RingNoteDuration Duration;
GSM_RingNoteDurationSpec DurationSpec;
GSM_RingNoteNote Note;
GSM_RingNoteStyle Style;
GSM_RingNoteScale Scale;
int Tempo;
} GSM_RingNote;
typedef enum {
RING_Note = 1,
RING_EnableVibra,
RING_DisableVibra,
RING_EnableLight,
RING_DisableLight,
RING_EnableLED,
RING_DisableLED,
RING_Repeat
} GSM_RingCommandType;
typedef struct {
GSM_RingCommandType Type;
GSM_RingNote Note;
unsigned char Value;
} GSM_RingCommand;
typedef struct {
int NrCommands;
GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
bool AllNotesScale;
} GSM_NoteRingtone;
+/* FIXME: should use BinaryTone instead? */
/* Structure to hold Nokia binary ringtones. */
typedef struct {
- unsigned char Frame[30000];
+ unsigned char Frame[50000];
int Length;
} GSM_NokiaBinaryRingtone;
typedef struct {
- unsigned char *Frame;
+ unsigned char *Buffer;
int Length;
} GSM_BinaryTone;
typedef enum {
RING_NOTETONE = 1,
RING_NOKIABINARY,
- RING_MIDI
+ RING_MIDI,
+ RING_MMF
} GSM_RingtoneFormat;
/**
* Structure for saving various ringtones formats
*/
typedef struct {
/**
* Ringtone saved in one of three formats
*/
GSM_NokiaBinaryRingtone NokiaBinary;
GSM_BinaryTone BinaryTone;
GSM_NoteRingtone NoteTone;
/**
* Ringtone format
*/
GSM_RingtoneFormat Format;
/**
* Ringtone name
*/
char Name[20*2];
/**
* Ringtone location
*/
int Location;
} GSM_Ringtone;
typedef struct {
int Group; //Nokia specific
int ID;
char Name[30*2];
} GSM_RingtoneInfo;
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
@@ -458,64 +458,69 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info,
return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_PICTURE);
case SMS_AlcatelMonoAnimationLong:
/* Number of sequence words */
Buffer[0] = (Info->Entries[0].Bitmap->Number+1) % 256;
Buffer[1] = (Info->Entries[0].Bitmap->Number+1) / 256;
/* Picture display time 1 second (1 = 100ms) */
Buffer[2] = 10 % 256;
Buffer[3] = 10 / 256 + 0xF0;
Length = 4;
j = 0;
/* Offsets to bitmaps */
for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) % 256;
Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) / 256;
j += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight)+2;
}
/* Bitmaps */
for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth;
Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight;
PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]);
Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight);
}
return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION);
case SMS_MMSIndicatorLong:
Class = 1;
UDH = UDH_MMSIndicatorLong;
GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator);
break;
+ case SMS_WAPIndicatorLong:
+ Class = 1;
+ UDH = UDH_MMSIndicatorLong;
+ GSM_EncodeWAPIndicatorSMSText(Buffer,&Length,Info->Entries[0].MMSIndicator->Title,Info->Entries[0].MMSIndicator->Address);
+ break;
case SMS_NokiaRingtoneLong:
case SMS_NokiaRingtone:
UDH = UDH_NokiaRingtone;
Class = 1;
/* 7 = length of UDH_NokiaRingtone UDH header */
Length = GSM_MAX_8BIT_SMS_LENGTH-7;
Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length);
if (Info->Entries[0].ID == SMS_NokiaRingtone) break;
if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) {
UDH = UDH_NokiaRingtoneLong;
Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3;
Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length);
}
break;
case SMS_NokiaOperatorLogoLong:
if (Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth > 72 || Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight > 14) {
UDH = UDH_NokiaOperatorLogoLong;
Class = 1;
NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode);
Length = Length + 3;
NOKIA_CopyBitmap(GSM_Nokia7110OperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length);
break;
}
case SMS_NokiaOperatorLogo:
UDH = UDH_NokiaOperatorLogo;
Class = 1;
NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode);
Length = Length + 3;
NOKIA_CopyBitmap(GSM_NokiaOperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length);
break;
case SMS_NokiaCallerLogo:
UDH = UDH_NokiaCallerLogo;
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,37 +1,41 @@
/* (c) 2002-2004 by Marcin Wiacek */
#ifndef __gsm_multi_h
#define __gsm_multi_h
+#if defined(_MSC_VER) && defined(__cplusplus)
+ extern "C" {
+#endif
+
#include "../../gsmcomon.h"
#include "../gsmlogo.h"
#include "../gsmcal.h"
#include "../gsmpbk.h"
#include "../gsmdata.h"
#include "../gsmring.h"
#include "gsmsms.h"
/* ---------------------- multi SMS --------------------------------------- */
/* Identifiers for Smart Messaging 3.0 multipart SMS */
#define SM30_ISOTEXT 0 /* ISO 8859-1 text */
#define SM30_UNICODETEXT 1
#define SM30_OTA 2
#define SM30_RINGTONE 3
#define SM30_PROFILENAME 4
/* ... */
#define SM30_SCREENSAVER 6
/* Identifiers for Alcatel Terminal Data Download */
#define ALCATELTDD_PICTURE 4
#define ALCATELTDD_ANIMATION 5
#define ALCATELTDD_SMSTEMPLATE 6
void GSM_SMSCounter(int MessageLength,
unsigned char *MessageBuffer,
GSM_UDH UDHType,
GSM_Coding_Type Coding,
int *SMSNum,
int *CharsLeft);
@@ -143,82 +147,83 @@ typedef enum {
*/
SMS_NokiaVCARD21Long,
/**
* Nokia VCALENDAR 1.0 - can be in few sms
*/
SMS_NokiaVCALENDAR10Long,
SMS_NokiaVTODOLong,
SMS_VCARD10Long,
SMS_VCARD21Long,
SMS_DisableVoice,
SMS_DisableFax,
SMS_DisableEmail,
SMS_EnableVoice,
SMS_EnableFax,
SMS_EnableEmail,
SMS_VoidSMS,
/**
* IMelody 1.0
*/
SMS_EMSSound10,
/**
* IMelody 1.2
*/
SMS_EMSSound12,
/**
* IMelody without header - SonyEricsson extension
*/
SMS_EMSSonyEricssonSound,
/**
* IMelody 1.0 with UPI.
*/
SMS_EMSSound10Long,
- /***
+ /**
* IMelody 1.2 with UPI.
*/
SMS_EMSSound12Long,
/**
* IMelody without header with UPI.
*/
SMS_EMSSonyEricssonSoundLong,
SMS_EMSPredefinedSound,
SMS_EMSPredefinedAnimation,
SMS_EMSAnimation,
/**
* Fixed bitmap of size 16x16 or 32x32.
*/
SMS_EMSFixedBitmap,
SMS_EMSVariableBitmap,
SMS_EMSVariableBitmapLong,
SMS_MMSIndicatorLong,
+ SMS_WAPIndicatorLong,
/**
* Variable bitmap with black and white colors
*/
SMS_AlcatelMonoBitmapLong,
/**
* Variable animation with black and white colors
*/
SMS_AlcatelMonoAnimationLong,
SMS_AlcatelSMSTemplateName
} EncodeMultiPartSMSID;
typedef struct {
EncodeMultiPartSMSID ID;
int Number;
GSM_Ringtone *Ringtone;
GSM_MultiBitmap *Bitmap;
GSM_WAPBookmark *Bookmark;
GSM_WAPSettings *Settings;
GSM_MMSIndicator *MMSIndicator;
GSM_MemoryEntry *Phonebook;
GSM_CalendarEntry *Calendar;
GSM_ToDoEntry *ToDo;
bool Protected;
unsigned char *Buffer;
bool Left;
bool Right;
bool Center;
bool Large;
bool Small;
bool Bold;
@@ -235,37 +240,41 @@ typedef struct {
int EntriesNum;
bool UnicodeCoding;
int Class;
unsigned char ReplaceMessage;
bool Unknown;
} GSM_MultiPartSMSInfo;
/**
* Encodes multi part SMS from "readable" format.
*/
GSM_Error GSM_EncodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS);
/**
* Decodes multi part SMS to "readable" format.
*/
bool GSM_DecodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, bool ems);
/**
* Clears @ref GSM_MultiPartSMSInfo to default values.
*/
void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
/**
* Frees any allocated structures inside @ref GSM_MultiPartSMSInfo.
*/
void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
/**
* Links SMS messages according to IDs.
*/
GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems);
+#if defined(_MSC_VER) && defined(__cplusplus)
+ }
+#endif
+
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,34 +1,37 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Pawel Kot, others and Gnokii */
+/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#include <ctype.h>
#include <string.h>
#include <time.h>
#include "../../gsmcomon.h"
#include "../../misc/coding/coding.h"
#include "../gsmcal.h"
#include "../gsmpbk.h"
#include "../gsmlogo.h"
#include "../gsmring.h"
#include "../gsmdata.h"
#include "../gsmnet.h"
#include "gsmsms.h"
/* User data headers */
static GSM_UDHHeader UDHHeaders[] = {
/* See GSM 03.40 section 9.2.3.24.1
* 1 byte 0x00
* 1 byte 0x03
* 1 byte 0x01: unique ID for message series
* 1 byte 0x00: how many SMS in sequence
* 1 byte 0x00: number of current SMS in sequence */
{ UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3},
/* See GSM 03.40 section 9.2.3.24.2 for voice, fax and email messages */
{ UDH_DisableVoice, 0x04, "\x01\x02\x00\x00",-1,-1,-1,-1},
{ UDH_DisableFax, 0x04, "\x01\x02\x01\x00",-1,-1,-1,-1},
{ UDH_DisableEmail, 0x04, "\x01\x02\x02\x00",-1,-1,-1,-1},
{ UDH_EnableVoice, 0x04, "\x01\x02\x00\x01",-1,-1,-1,-1},
{ UDH_EnableFax, 0x04, "\x01\x02\x01\x01",-1,-1,-1,-1},
{ UDH_EnableEmail, 0x04, "\x01\x02\x02\x01",-1,-1,-1,-1},
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,34 +1,37 @@
/* (c) 2001-2004 by Marcin Wiacek */
-/* based on some work from Pawel Kot, others and Gnokii */
+/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
+ * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
+ * GNU GPL version 2 or later
+ */
#ifndef __gsm_sms_h
#define __gsm_sms_h
#include "../../gsmcomon.h"
#include "../gsmlogo.h"
#include "../gsmcal.h"
#include "../gsmpbk.h"
#include "../gsmdata.h"
#include "../gsmring.h"
/* --------------------- Some general definitions ------------------------- */
#define GSM_MAX_UDH_LENGTH 140
#define GSM_MAX_SMS_LENGTH 160
#define GSM_MAX_8BIT_SMS_LENGTH 140
/* -------------------- Cell Broadcast ------------------------------------ */
/**
* Structure for Cell Broadcast messages.
*/
typedef struct {
/**
* Message text.
*/
char Text[300];
/**
* Channel number.
*/
int Channel;
} GSM_CBMessage;
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
@@ -581,68 +581,72 @@ void DCT3SetPhoneMenus(int argc, char *argv[])
j=128;
z++;
} else j=j/2;
}
// reqSet[3]=0xe7;
// reqSet[4]=0x25;
// reqSet[5]=0x00;
// reqSet[6]=0xe0;
error=GSM_WaitFor (&s, reqSet, 7, 0x40, 4, ID_User4);
Print_Error(error);
printf("Enabling netmonitor\n");
error=DCT3_Netmonitor(&s, 243, value);
Print_Error(error);
}
static GSM_Error DCT3_Reply61GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
printf("Security Code is \"%s\"\n",msg.Buffer+5);
return ERR_NONE;
}
static GSM_Error DCT3_Reply7191GetSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
printf("Security Code is \"%s\"\n",msg.Buffer+6);
return ERR_NONE;
}
void DCT3GetSecurityCode(int argc, char *argv[])
{
+#ifdef GSM_ENABLE_NOKIA6110
unsigned char req6110[] = {0x00, 0x01, 0x6e,
0x01}; /* Code type */
+#endif
+#if defined(GSM_ENABLE_NOKIA7110) || defined(GSM_ENABLE_NOKIA9210)
unsigned char req71_91[] = {N7110_FRAME_HEADER, 0xee,
0x1c}; /* Setting */
+#endif
if (CheckDCT3Only()!=ERR_NONE) return;
error=DCT3_EnableSecurity (&s, 0x01);
Print_Error(error);
s.User.UserReplyFunctions=UserReplyFunctions3;
#ifdef GSM_ENABLE_NOKIA6110
if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
error=GSM_WaitFor (&s, req6110, 4, 0x40, 4, ID_User6);
}
#endif
#ifdef GSM_ENABLE_NOKIA7110
if (strstr(N7110Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6);
}
#endif
#ifdef GSM_ENABLE_NOKIA9210
if (strstr(N9210Phone.models, s.Phone.Data.ModelInfo->model) != NULL) {
error=GSM_WaitFor (&s, req71_91, 5, 0x7a, 4, ID_User6);
}
#endif
Print_Error(error);
}
#ifdef GSM_ENABLE_NOKIA6110
static GSM_Error DCT3_ReplyGetOperatorName(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
unsigned char buffer[10];
@@ -738,64 +742,66 @@ void DCT3DisplayOutput(int argc, char *argv[])
{
unsigned char req[] = {N6110_FRAME_HEADER, 0x53,
0x01}; //1 = enable, 2 = disable
GSM_Init(true);
if (strstr(N6110Phone.models, s.Phone.Data.ModelInfo->model) == NULL) Print_Error(ERR_NOTSUPPORTED);
CheckDCT3();
s.User.UserReplyFunctions=UserReplyFunctions3;
error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7);
Print_Error(error);
signal(SIGINT, interrupt);
printf("Press Ctrl+C to break...\n");
printf("Entering monitor mode...\n\n");
while (!gshutdown) {
GSM_ReadDevice(&s,true);
my_sleep(10);
}
req[4] = 0x02;
error=GSM_WaitFor (&s, req, 5, 0x0d, 4, ID_User7);
Print_Error(error);
GSM_Terminate();
}
#endif
static GSM_Reply_Function UserReplyFunctions3[] = {
+#ifdef GSM_ENABLE_NOKIA6110
{DCT3_ReplyDisplayOutput, "\x0D",0x03,0x50,ID_IncomingFrame },
{DCT3_ReplyDisplayOutput, "\x0D",0x03,0x54,ID_User7 },
+#endif
{DCT3_ReplyEnableSecurity2, "\x40",0x02,0x64,ID_EnableSecurity },
{DCT3_ReplyResetTest36, "\x40",0x02,0x65,ID_User2 },
{DCT3_ReplyGetADC, "\x40",0x02,0x68,ID_User3 },
{DCT3_ReplyGetPPS, "\x40",0x02,0x6A,ID_User4 },
{DCT3_ReplySetPPS, "\x40",0x02,0x6B,ID_User4 },
{DCT3_Reply61GetSecurityCode, "\x40",0x02,0x6E,ID_User6 },
{DCT3_ReplySimlockInfo, "\x40",0x02,0x8A,ID_User3 },
#ifdef GSM_ENABLE_NOKIA6110
{DCT3_ReplySetOperatorName, "\x40",0x02,0x8B,ID_User7 },
{DCT3_ReplyGetOperatorName, "\x40",0x02,0x8C,ID_User5 },
#endif
{DCT3_ReplyGetADC, "\x40",0x02,0x91,ID_User3 },
{NoneReply, "\x40",0x02,0xA3,ID_User3 },
{DCT3_ReplyGetT9, "\x40",0x02,0xAE,ID_User3 },
{DCT3_ReplyGetMSID, "\x40",0x02,0xb5,ID_User8 },
{DCT3_ReplyGetDSPROM, "\x40",0x02,0xC8,ID_User10 },
{DCT3_ReplyGetMCUchkSum, "\x40",0x02,0xC8,ID_User9 },
{DCT3_ReplyPhoneTests, "\x40",0x02,0xCF,ID_User1 },
{DCT3_Reply7191GetSecurityCode, "\x7a",0x04,0x1C,ID_User6 },
{NULL, "\x00",0x00,0x00,ID_None }
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -6,65 +6,66 @@
#include <string.h>
#include "dct4.h"
#include "../../gammu.h"
#include "../../../common/phone/pfunc.h"
#include "../../../common/phone/nokia/nfunc.h"
#include "../../../common/phone/nokia/dct4/dct4func.h"
#include "../../../common/misc/coding/coding.h"
extern GSM_Reply_Function UserReplyFunctions4[];
/* ------- some usefull functions ----------------------------------------- */
GSM_Error CheckDCT4Only()
{
bool found = false;
/* Checking if phone is DCT4 */
#ifdef GSM_ENABLE_NOKIA3650
if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
#endif
#ifdef GSM_ENABLE_NOKIA6510
if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
#endif
#ifdef GSM_ENABLE_NOKIA3320
if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true;
#endif
if (!found) return ERR_NOTSUPPORTED;
if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 &&
s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE &&
- s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET) {
+ s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET &&
+ s.ConnectionType!=GCT_FBUS2DKU5) {
return ERR_OTHERCONNECTIONREQUIRED;
}
return ERR_NONE;
}
static void CheckDCT4()
{
GSM_Error error;
error = CheckDCT4Only();
switch (error) {
case ERR_NOTSUPPORTED:
Print_Error(ERR_NOTSUPPORTED);
break;
case ERR_OTHERCONNECTIONREQUIRED:
printf("Can't do it with current phone protocol\n");
GSM_TerminateConnection(&s);
exit(-1);
default:
break;
}
}
static bool answer_yes2(char *text)
{
int len;
char ans[99];
while (1) {
printf("%s (yes/no) ? ",text);
len=GetLine(stdin, ans, 99);
if (len==-1) exit(-1);
@@ -856,100 +857,103 @@ void DCT4GetT9(int argc, char *argv[])
0x02, 0xBC}; /* How many bytes to read */
if (CheckDCT4Only()!=ERR_NONE) return;
T9File = fopen("T9", "w");
if (T9File == NULL) return;
s.User.UserReplyFunctions=UserReplyFunctions4;
i = 0;
while (1) {
req[12] = i / 256;
req[13] = i % 256;
if (i != 0) {
if (T9Dictionary - i < req[16]*256+req[17]) {
req[16] = (T9Dictionary - i) / 256;
req[17] = (T9Dictionary - i) % 256;
}
if (T9Dictionary - i == 0) break;
}
error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3);
Print_Error(error);
if (i==0) {
T9Dictionary = T9FullSize;
dbgprintf("T9 dictionary size is %i\n",T9Dictionary);
}
i+=T9Size;
}
fclose(T9File);
}
+#ifdef GSM_ENABLE_NOKIA6510
+
extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable);
void DCT4SetLight(int argc, char *argv[])
{
int i;
N6510_PHONE_LIGHTS type;
bool enable;
if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY;
} else if (mystrncasecmp(argv[2],"keypad",0)) { type = N6510_LIGHT_KEYPAD;
} else if (mystrncasecmp(argv[2],"torch",0)) { type = N6510_LIGHT_TORCH;
} else {
printf("What lights should I enable (\"%s\") ?\n",argv[2]);
exit(-1);
}
if (mystrncasecmp(argv[3],"on",0)) { enable = true;
} else if (mystrncasecmp(argv[3],"off",0)) { enable = false;
} else {
printf("What should I do (\"%s\") ?\n",argv[3]);
exit(-1);
}
for (i=0;i<s.ConfigNum;i++) {
s.Config[i].StartInfo = "false";
}
GSM_Init(true);
CheckDCT4();
error=N6510_SetLight(&s, type, enable);
Print_Error(error);
GSM_Terminate();
}
+#endif
void DCT4DisplayTest(int argc, char *argv[])
{
unsigned char ans[200];
unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00};
unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04,
0x09, /* test number */
0x00};
if (CheckDCT4Only()!=ERR_NONE) return;
s.User.UserReplyFunctions=UserReplyFunctions4;
DCT4_SetPhoneMode(&s, DCT4_MODE_TEST);
s.Protocol.Functions->WriteMessage(&s, req0, 6, 0x40);
req[8] = atoi(argv[2]);
s.Protocol.Functions->WriteMessage(&s, req, 10, 0x40);
printf("Press any key to continue...\n");
GetLine(stdin, ans, 99);
DCT4_SetPhoneMode(&s, DCT4_MODE_NORMAL);
}
int ADC;
static GSM_Error DCT4_ReplyGetADC(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
if (msg.Buffer[6] == 0xff && msg.Buffer[7] == 0xff) return ERR_NONE;
switch (msg.Buffer[3]) {
@@ -992,64 +996,66 @@ static struct DCT4ADCInfo DCT4ADC[] = {
{"", "", 1}
};
void DCT4GetADC(int argc, char *argv[])
{
int i = 0;
unsigned char GetRaw[] = {N6110_FRAME_HEADER, 0x0F,
0x00, /* Test number */
0x01};
unsigned char GetUnit[] = {N6110_FRAME_HEADER, 0x11,
0x00, /* Test number */
0x01};
if (CheckDCT4Only()!=ERR_NONE) return;
s.User.UserReplyFunctions=UserReplyFunctions4;
while (1) {
printf(" %30s ",DCT4ADC[i].name);
GetRaw[4] = i;
error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3);
Print_Error(error);
GetUnit[4] = i;
ADC = DCT4ADC[i].x;
error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3);
Print_Error(error);
printf("%s\n",DCT4ADC[i].unit);
i++;
if (DCT4ADC[i].name[0] == 0x00) break;
}
}
+#ifdef GSM_ENABLE_NOKIA6510
+
static double RadioFreq;
static unsigned char RadioName[100];
static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
int length;
unsigned char name[100];
switch (msg.Buffer[3]) {
case 0x09:
N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16);
length = msg.Buffer[8];
memcpy(name,msg.Buffer+18,length*2);
name[length*2] = 0x00;
name[length*2+1] = 0x00;
CopyUnicodeString(RadioName,name);
smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(RadioName));
return ERR_NONE;
case 0x15:
case 0x16:
smprintf(s,"Response for enabling radio/headset status received\n");
if (msg.Buffer[5] == 0) {
smprintf(s,"Connected\n");
return ERR_NONE;
}
smprintf(s,"Probably not connected\n");
return ERR_PERMISSION;
}
return ERR_UNKNOWNRESPONSE;
}
@@ -1145,64 +1151,65 @@ void DCT4TuneRadio(int argc, char *argv[])
i = 0;
continue;
}
i++;
}
for (i=0;i<num;i++) {
fprintf(stderr,"%02i.",i+1);
if (FMStation[i].Frequency < 100) fprintf(stderr," ");
fprintf(stderr,"%.1f MHz - \"%s\" \n",
FMStation[i].Frequency,
DecodeUnicodeString(FMStation[i].StationName));
}
if (answer_yes2("Do you want to save found stations")) {
fprintf(stderr,"Deleting old FM stations: ");
error=Phone->ClearFMStations(&s);
Print_Error(error);
fprintf(stderr,"Done\n");
for (i=0;i<num;i++) {
FMStation[i].Location = i+1;
error=Phone->SetFMStation(&s,&FMStation[i]);
Print_Error(error);
fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num);
}
fprintf(stderr,"\n");
}
error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3);
Print_Error(error);
GSM_Terminate();
}
+#endif
void DCT4PlaySavedRingtone(int argc, char *argv[])
{
unsigned char req[] = {N6110_FRAME_HEADER,
0x01,
0x00,0x64, //id
0x01, //group
0x01,0x00,0x00,
0x0A, //volume
0x00,0x00,0x00,0x00,0x00,0x00,0x00};
GSM_AllRingtonesInfo Info;
GSM_Init(true);
CheckDCT4();
s.User.UserReplyFunctions=UserReplyFunctions4;
error=Phone->GetRingtonesInfo(&s,&Info);
Print_Error(error);
if (atoi(argv[2]) > Info.Number-1) {
GSM_Terminate();
return;
}
req[4] = Info.Ringtone[atoi(argv[2])].ID / 256;
req[5] = Info.Ringtone[atoi(argv[2])].ID % 256;
req[6] = Info.Ringtone[atoi(argv[2])].Group;
error=GSM_WaitFor (&s, req, 18, 0x1F, 4, ID_User3);
Print_Error(error);
@@ -1284,58 +1291,60 @@ void DCT4GetScreenDump(int argc, char *argv[])
static GSM_Reply_Function UserReplyFunctions4[] = {
#ifdef DEBUG
{DCT4_ReplyResetSecurityCode, "\x08",0x03,0x05,ID_User2 },
{DCT4_ReplyResetSecurityCode, "\x08",0x03,0x06,ID_User2 },
#endif
{DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_User3 },
{DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_IncomingFrame},
{DCT4_ReplyGetADC, "\x17",0x03,0x10,ID_User3 },
{DCT4_ReplyGetADC, "\x17",0x03,0x12,ID_User3 },
{DCT4_ReplySetPPS, "\x1b",0x03,0x05,ID_User1 },
{NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_User6 },
{DCT4_ReplyVibra, "\x1C",0x03,0x0D,ID_User3 },
{DCT4_ReplyVibra, "\x1C",0x03,0x0F,ID_User3 },
{NoneReply, "\x1F",0x03,0x02,ID_User3 },
{DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1 },
{DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3 },
{DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4 },
{DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4 },
{DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1 },
{DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3 },
{DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3 },
{DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1 },
{DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2 },
+#ifdef GSM_ENABLE_NOKIA6510
{DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3 },
{DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3 },
{DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation},
{DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3 },
+#endif
{DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4 },
{DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6 },
{DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6 },
{DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3 },
{DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3 },
{DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3 },
{DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3 },
{DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3 },
{DCT4_ReplyGetBTInfo, "\xD7",0x03,0x0A,ID_User6 },
{NULL, "\x00",0x00,0x00,ID_None }
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,55 +1,58 @@
/* (c) 2002-2004 by Marcin Wiacek */
#include "../../../common/gsmstate.h"
void DCT4SetPhoneMenus (int argc, char *argv[]);
void DCT4SelfTests (int argc, char *argv[]);
void DCT4SetVibraLevel (int argc, char *argv[]);
void DCT4GetSecurityCode (int argc, char *argv[]);
-#ifdef DEBUG
-void DCT4ResetSecurityCode (int argc, char *argv[]);
-#endif
void DCT4GetVoiceRecord (int argc, char *argv[]);
void DCT4Info (int argc, char *argv[]);
void DCT4GetT9 (int argc, char *argv[]);
-void DCT4SetLight (int argc, char *argv[]);
void DCT4DisplayTest (int argc, char *argv[]);
void DCT4GetADC (int argc, char *argv[]);
void DCT4VibraTest (int argc, char *argv[]);
-void DCT4TuneRadio (int argc, char *argv[]);
void DCT4PlaySavedRingtone (int argc, char *argv[]);
void DCT4MakeCameraShoot (int argc, char *argv[]);
void DCT4GetScreenDump (int argc, char *argv[]);
+#ifdef DEBUG
+ void DCT4ResetSecurityCode (int argc, char *argv[]);
+#endif
+#ifdef GSM_ENABLE_NOKIA6510
+ void DCT4SetLight (int argc, char *argv[]);
+ void DCT4TuneRadio (int argc, char *argv[]);
+#endif
+
/* ------------------- features matrix ------------------------------------- */
typedef enum {
DCT4_ALWAYS_ONLINE = 1,
DCT4_GPRS_PCCH,
DCT4_GEA1,
DCT4_EOTD,
DCT4_WAP_PUSH,
DCT4_USE_PREF_SIM_NET,
DCT4_JAVA_TCK,
DCT4_ALS,
DCT4_A52,
DCT4_CSP,
DCT4_EONS,
DCT4_3GINDICATOR,
DCT4_DISPLAY_PHONE_NAME,
DCT4_DISPLAY_WAP_PROFILE,
DCT4_GAMES_WAP_DOWNLOAD,
DCT4_GAMES_SCORE_SEND,
DCT4_GAMES_URL_CHECK,
DCT4_BLUETOOTH_MENU,
DCT4_WAP_BOOKMARKS_MENU,
DCT4_WAP_BOOKMARKS_MENU2,
DCT4_WAP_GOTO_MENU,
DCT4_WAP_SETTINGS_MENU,
DCT4_SERVICES_GAMES_APP_GALLERY,
DCT4_JAVA_GAMES_MENU,
DCT4_SAT_CONFIRM_MENU,
DCT4_INSTANT_MESS_MENU,
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,103 +1,90 @@
/* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */
/* FM stuff by Walek */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <locale.h>
#include <signal.h>
#include <ctype.h>
#include <wchar.h>
-#undef HAVE_MYSQL_MYSQL_H
#ifdef WIN32
# include <windows.h>
# include <process.h>
# ifdef _MSC_VER
# include <sys/utime.h>
# else
# include <utime.h>
# endif
#else
# include <utime.h>
#endif
#include "../common/gammu.h"
#include "gammu.h"
#include "smsd/smsdcore.h"
#ifdef DEBUG
# include "sniff.h"
#endif
#ifdef GSM_ENABLE_NOKIA_DCT3
# include "depend/nokia/dct3.h"
# include "depend/nokia/dct3trac/wmx.h"
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
# include "depend/nokia/dct4.h"
#endif
#ifdef GSM_ENABLE_ATGEN
# include "depend/siemens/dsiemens.h"
#endif
#ifdef HAVE_PTHREAD
# include <pthread.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
-//static GSM_StateMachine s;
-//static GSM_Phone_Functions *Phone;
+GSM_StateMachine s;
+GSM_Phone_Functions *Phone;
static INI_Section *cfg = NULL;
-//static GSM_Error error = ERR_NONE;
+GSM_Error error = ERR_NONE;
static int i;
-//static bool gshutdown = false;
-typedef struct {
- unsigned char Connection[50];
-} OneConnectionInfo;
-
-typedef struct {
- unsigned char Device[50];
- OneConnectionInfo Connections[6];
- //GSM_StateMachine s;
-} OneDeviceInfo;
+volatile bool gshutdown = false;
-static int num;
-static OneDeviceInfo SearchDevices[100];
-static bool SearchOutput;
void interrupt(int sign)
{
signal(sign, SIG_IGN);
gshutdown = true;
}
#ifdef __GNUC__
__attribute__((format(printf, 1, 2)))
#endif
int printmsg(char *format, ...)
{
va_list argp;
int result;
va_start(argp, format);
result = vfprintf(stdout,GetMsg(s.msg,format),argp);
va_end(argp);
return result;
}
#ifdef __GNUC__
__attribute__((format(printf, 1, 2)))
#endif
int printmsgerr(char *format, ...)
{
va_list argp;
int result;
va_start(argp, format);
result = vfprintf(stderr,GetMsg(s.msg,format), argp);
va_end(argp);
return result;
@@ -214,64 +201,65 @@ static bool answer_yes(char *text)
if (mystrncasecmp(ans, "no" ,0)) return false;
}
}
#ifdef GSM_ENABLE_BEEP
void GSM_PhoneBeep(void)
{
error = PHONE_Beep(&s);
if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) Print_Error(error);
}
#endif
static GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
{
int i;
bool first=true;
GSM_Error error;
signal(SIGINT, interrupt);
printmsg("Press Ctrl+C to break...\n");
for (i=0;i<ringtone.NoteTone.NrCommands;i++) {
if (gshutdown) break;
if (ringtone.NoteTone.Commands[i].Type != RING_NOTETONE) continue;
error=PHONE_RTTLPlayOneNote(&s,ringtone.NoteTone.Commands[i].Note,first);
if (error!=ERR_NONE) return error;
first = false;
}
/* Disables buzzer */
return s.Phone.Functions->PlayTone(&s,255*255,0,false);
}
+
static void PlayRingtone(int argc, char *argv[])
{
GSM_Ringtone ringtone,ringtone2;
ringtone.Format = 0;
error=GSM_ReadRingtoneFile(argv[2],&ringtone);
Print_Error(error);
error=GSM_RingtoneConvert(&ringtone2,&ringtone,RING_NOTETONE);
Print_Error(error);
GSM_Init(true);
error=GSM_PlayRingtone(ringtone2);
Print_Error(error);
GSM_Terminate();
}
static void Identify(int argc, char *argv[])
{
unsigned char buffer[100];
GSM_Init(true);
error=Phone->GetManufacturer(&s);
Print_Error(error);
printmsg("Manufacturer : %s\n", s.Phone.Data.Manufacturer);
error=Phone->GetModel(&s);
Print_Error(error);
printmsg("Model : %s (%s)\n",
s.Phone.Data.ModelInfo->model,
@@ -312,98 +300,98 @@ static void Identify(int argc, char *argv[])
if (error == ERR_NONE) printmsg("Manufactured : %s\n",buffer);
}
error=Phone->GetProductCode(&s, buffer);
if (error != ERR_NOTSUPPORTED) {
if (error != ERR_NOTIMPLEMENTED) Print_Error(error);
if (error == ERR_NONE) printmsg("Product code : %s\n",buffer);
}
error=Phone->GetSIMIMSI(&s, buffer);
switch (error) {
case ERR_SECURITYERROR:
case ERR_NOTSUPPORTED:
case ERR_NOTIMPLEMENTED:
break;
case ERR_NONE:
printmsg("SIM IMSI : %s\n",buffer);
break;
default:
Print_Error(error);
}
#ifdef GSM_ENABLE_NOKIA_DCT3
DCT3Info(argc, argv);
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
DCT4Info(argc, argv);
#endif
GSM_Terminate();
}
-//#if 0
static void GetDateTime(int argc, char *argv[])
{
GSM_DateTime date_time;
GSM_Locale locale;
GSM_Init(true);
error=Phone->GetDateTime(&s, &date_time);
switch (error) {
case ERR_EMPTY:
printmsg("Date and time not set in phone\n");
break;
case ERR_NONE:
printmsg("Phone time is %s\n",OSDateTime(date_time,false));
break;
default:
Print_Error(error);
}
error=Phone->GetLocale(&s, &locale);
switch (error) {
case ERR_NOTSUPPORTED:
case ERR_NOTIMPLEMENTED:
break;
default:
Print_Error(error);
printmsg("Time format is ");
if (locale.AMPMTime) printmsg("12 hours\n"); else printmsg("24 hours\n");
printmsg("Date format is ");
switch (locale.DateFormat) {
case GSM_Date_DDMMYYYY:printmsg("DD MM YYYY");break;
case GSM_Date_MMDDYYYY:printmsg("MM DD YYYY");break;
case GSM_Date_YYYYMMDD:printmsg("YYYY MM DD");
+ default :break;
}
printmsg(", date separator is %c\n",locale.DateSeparator);
}
GSM_Terminate();
}
static void SetDateTime(int argc, char *argv[])
{
GSM_DateTime date_time;
GSM_GetCurrentDateTime(&date_time);
GSM_Init(true);
error=Phone->SetDateTime(&s, &date_time);
Print_Error(error);
GSM_Terminate();
}
static void GetAlarm(int argc, char *argv[])
{
GSM_Alarm alarm;
GSM_Init(true);
alarm.Location = 1;
error=Phone->GetAlarm(&s, &alarm);
switch (error) {
case ERR_EMPTY:
printmsg("Alarm not set in phone\n");
@@ -558,152 +546,169 @@ static void GetAllMemory(int argc, char *argv[])
Entry.MemoryType = 0;
if (mystrncasecmp(argv[2],"DC",0)) Entry.MemoryType=MEM_DC;
if (mystrncasecmp(argv[2],"ON",0)) Entry.MemoryType=MEM_ON;
if (mystrncasecmp(argv[2],"RC",0)) Entry.MemoryType=MEM_RC;
if (mystrncasecmp(argv[2],"MC",0)) Entry.MemoryType=MEM_MC;
if (mystrncasecmp(argv[2],"ME",0)) Entry.MemoryType=MEM_ME;
if (mystrncasecmp(argv[2],"SM",0)) Entry.MemoryType=MEM_SM;
if (mystrncasecmp(argv[2],"VM",0)) Entry.MemoryType=MEM_VM;
if (mystrncasecmp(argv[2],"FD",0)) Entry.MemoryType=MEM_FD;
if (Entry.MemoryType==0) {
printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
exit (-1);
}
GSM_Init(true);
while (!gshutdown) {
error = Phone->GetNextMemory(&s, &Entry, start);
if (error == ERR_EMPTY) break;
Print_Error(error);
printmsg("Memory %s, Location %i\n",argv[2],Entry.Location);
PrintMemoryEntry(&Entry);
start = false;
}
GSM_Terminate();
}
static void GetMemory(int argc, char *argv[])
{
- int j, start, stop;
+ int j, start, stop, emptynum = 0, fillednum = 0;
GSM_MemoryEntry entry;
+ bool empty = true;
entry.MemoryType=0;
if (mystrncasecmp(argv[2],"DC",0)) entry.MemoryType=MEM_DC;
if (mystrncasecmp(argv[2],"ON",0)) entry.MemoryType=MEM_ON;
if (mystrncasecmp(argv[2],"RC",0)) entry.MemoryType=MEM_RC;
if (mystrncasecmp(argv[2],"MC",0)) entry.MemoryType=MEM_MC;
if (mystrncasecmp(argv[2],"ME",0)) entry.MemoryType=MEM_ME;
if (mystrncasecmp(argv[2],"SM",0)) entry.MemoryType=MEM_SM;
if (mystrncasecmp(argv[2],"VM",0)) entry.MemoryType=MEM_VM;
if (mystrncasecmp(argv[2],"FD",0)) entry.MemoryType=MEM_FD;
if (entry.MemoryType==0) {
printmsg("ERROR: unknown memory type (\"%s\")\n",argv[2]);
exit (-1);
}
GetStartStop(&start, &stop, 3, argc, argv);
+ if (argc > 5 && strcmp(argv[5],"")) {
+ if (mystrncasecmp(argv[5],"-nonempty",0)) {
+ empty = false;
+ } else {
+ printmsg("ERROR: unknown parameter \"%s\"\n",argv[5]);
+ exit (-1);
+ }
+ }
+
GSM_Init(true);
if (!strcmp(s.Phone.Data.ModelInfo->model,"3310")) {
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");
}
for (j=start;j<=stop;j++) {
- printmsg("Memory %s, Location %i\n",argv[2],j);
+ if (empty) printmsg("Memory %s, Location %i\n",argv[2],j);
entry.Location=j;
error=Phone->GetMemory(&s, &entry);
if (error != ERR_EMPTY) Print_Error(error);
if (error == ERR_EMPTY) {
+ emptynum++;
+ if (empty) {
printmsg("Entry is empty\n");
printf("\n");
+ }
} else {
+ fillednum++;
+ if (!empty) printmsg("Memory %s, Location %i\n",argv[2],j);
PrintMemoryEntry(&entry);
}
}
+ printmsg("%i entries empty, %i entries filled\n",emptynum,fillednum);
+
GSM_Terminate();
}
#define MemoryLocationToString(x) ( \
x == MEM_ON ? "ON" : \
x == MEM_RC ? "RC" : \
x == MEM_MC ? "MC" : \
x == MEM_ME ? "ME" : \
x == MEM_SM ? "SM" : \
x == MEM_VM ? "VM" : \
x == MEM_FD ? "FD" : "XX")
static void SearchOneEntry(GSM_MemoryEntry *Entry, unsigned char *Text)
{
int i;
for (i=0;i<Entry->EntriesNum;i++) {
switch (Entry->Entries[i].EntryType) {
case PBK_Number_General :
case PBK_Number_Mobile :
case PBK_Number_Work :
case PBK_Number_Fax :
case PBK_Number_Home :
case PBK_Number_Pager :
case PBK_Number_Other :
case PBK_Text_Note :
case PBK_Text_Postal :
case PBK_Text_Email :
case PBK_Text_Email2 :
case PBK_Text_URL :
case PBK_Text_Name :
case PBK_Text_LastName :
case PBK_Text_FirstName :
case PBK_Text_Company :
case PBK_Text_JobTitle :
case PBK_Text_StreetAddress :
case PBK_Text_City :
case PBK_Text_State :
case PBK_Text_Zip :
case PBK_Text_Country :
case PBK_Text_Custom1 :
case PBK_Text_Custom2 :
case PBK_Text_Custom3 :
case PBK_Text_Custom4 :
case PBK_Caller_Group :
- if (mystrstr(Entry->Entries[i].Text, Text) != NULL) {
+ if (mywstrstr(Entry->Entries[i].Text, Text) != NULL) {
fprintf(stderr,"\n");
printmsg("Memory %s, Location %i\n",MemoryLocationToString(Entry->MemoryType),Entry->Location);
PrintMemoryEntry(Entry);
return;
}
break;
default:
break;
}
}
}
static void SearchOneMemory(GSM_MemoryType MemoryType, char *Title, unsigned char *Text)
{
GSM_MemoryEntry Entry;
GSM_MemoryStatus Status;
int i = 0, l = 1;
bool start = true;
Status.MemoryType = MemoryType;
Entry.MemoryType = MemoryType;
if (Phone->GetMemoryStatus(&s, &Status) == ERR_NONE) {
fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1));
if (Phone->GetNextMemory != NOTSUPPORTED && Phone->GetNextMemory != NOTIMPLEMENTED) {
while (i < Status.MemoryUsed) {
if (gshutdown) return;
i++;
fprintf(stderr,"\r%s: %i%%", Title, (i+1)*100/(Status.MemoryUsed+1));
error = Phone->GetNextMemory(&s, &Entry, start);
if (error == ERR_EMPTY) break;
Print_Error(error);
@@ -795,219 +800,229 @@ static void ListMemoryCategory(int argc, char *argv[])
printmsgerr("Press Ctrl+C to break...\n");
Length = strlen(argv[2]);
for (j = 0; j < Length; j++) {
if (!isdigit(argv[2][j])) {
Number = false;
break;
}
}
if (Number) {
j = atoi(argv[2]);
if (j > 0) {
ListMemoryCategoryEntries(j);
}
} else {
if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
Length = GSM_MAX_CATEGORY_NAME_LENGTH;
}
EncodeUnicode(Text, argv[2], Length);
Category.Type = Category_Phonebook;
Status.Type = Category_Phonebook;
if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
for (count=0,j=1;count<Status.Used;j++) {
Category.Location=j;
error=Phone->GetCategory(&s, &Category);
if (error != ERR_EMPTY) {
count++;
- if (mystrstr(Category.Name, Text) != NULL) {
+ if (mywstrstr(Category.Name, Text) != NULL) {
ListMemoryCategoryEntries(j);
}
}
}
}
}
GSM_Terminate();
}
static void displaysinglesmsinfo(GSM_SMSMessage sms, bool displaytext, bool displayudh)
{
switch (sms.PDU) {
case SMS_Status_Report:
printmsg("SMS status report\n");
printmsg("Status : ");
switch (sms.State) {
case SMS_Sent : printmsg("Sent"); break;
case SMS_Read : printmsg("Read"); break;
case SMS_UnRead : printmsg("UnRead"); break;
case SMS_UnSent : printmsg("UnSent"); break;
}
printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
- printmsg("Reference number: 0x%02X\n",sms.MessageReference);
+ printmsg("Reference number: %d\n",sms.MessageReference);
printmsg("Sent : %s\n",OSDateTime(sms.DateTime,true));
printmsg("SMSC number : \"%s\"\n",DecodeUnicodeConsole(sms.SMSC.Number));
printmsg("SMSC response : %s\n",OSDateTime(sms.SMSCTime,true));
printmsg("Delivery status : %s\n",DecodeUnicodeConsole(sms.Text));
printmsg("Details : ");
if (sms.DeliveryStatus & 0x40) {
if (sms.DeliveryStatus & 0x20) {
printmsg("Temporary error, ");
} else {
printmsg("Permanent error, ");
}
} else if (sms.DeliveryStatus & 0x20) {
printmsg("Temporary error, ");
}
switch (sms.DeliveryStatus) {
case 0x00: printmsg("SM received by the SME"); break;
case 0x01: printmsg("SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
case 0x02: printmsg("SM replaced by the SC"); break;
case 0x20: printmsg("Congestion"); break;
case 0x21: printmsg("SME busy"); break;
case 0x22: printmsg("No response from SME"); break;
case 0x23: printmsg("Service rejected"); break;
case 0x24: printmsg("Quality of service not aviable"); break;
case 0x25: printmsg("Error in SME"); break;
case 0x40: printmsg("Remote procedure error"); break;
case 0x41: printmsg("Incompatibile destination"); break;
case 0x42: printmsg("Connection rejected by SME"); break;
case 0x43: printmsg("Not obtainable"); break;
case 0x44: printmsg("Quality of service not available"); break;
case 0x45: printmsg("No internetworking available"); break;
case 0x46: printmsg("SM Validity Period Expired"); break;
case 0x47: printmsg("SM deleted by originating SME"); break;
case 0x48: printmsg("SM Deleted by SC Administration"); break;
case 0x49: printmsg("SM does not exist"); break;
case 0x60: printmsg("Congestion"); break;
case 0x61: printmsg("SME busy"); break;
case 0x62: printmsg("No response from SME"); break;
case 0x63: printmsg("Service rejected"); break;
case 0x64: printmsg("Quality of service not available"); break;
case 0x65: printmsg("Error in SME"); break;
default : printmsg("Reserved/Specific to SC: %x",sms.DeliveryStatus); break;
}
printf("\n");
break;
case SMS_Deliver:
printmsg("SMS message\n");
+ if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
+ printmsg("Saved : %s\n",OSDateTime(sms.DateTime,true));
+ } else {
printmsg("SMSC number : \"%s\"",DecodeUnicodeConsole(sms.SMSC.Number));
if (sms.ReplyViaSameSMSC) printmsg(" (set for reply)");
printmsg("\nSent : %s\n",OSDateTime(sms.DateTime,true));
+ }
/* No break. The only difference for SMS_Deliver and SMS_Submit is,
* that SMS_Deliver contains additional data. We wrote them and then go
* for data shared with SMS_Submit
*/
case SMS_Submit:
if (sms.ReplaceMessage != 0) printmsg("SMS replacing ID : %i\n",sms.ReplaceMessage);
/* If we went here from "case SMS_Deliver", we don't write "SMS Message" */
if (sms.PDU==SMS_Submit) {
printmsg("SMS message\n");
- printmsg("Reference number : 0x%02X\n",sms.MessageReference);
+ if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
+ } else {
+ printmsg("Reference number : %d\n",sms.MessageReference);
+ }
}
if (sms.Name[0] != 0x00 || sms.Name[1] != 0x00) {
printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(sms.Name));
}
if (sms.Class != -1) {
printmsg("Class : %i\n",sms.Class);
}
printmsg("Coding : ");
switch (sms.Coding) {
case SMS_Coding_Unicode : printmsg("Unicode\n"); break;
case SMS_Coding_Default : printmsg("Default GSM alphabet\n"); break;
case SMS_Coding_8bit : printmsg("8 bit\n"); break;
}
+ if (sms.State==SMS_UnSent && sms.Memory==MEM_ME) {
+ } else {
+ printmsg("Remote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
+ }
printmsg("Status : ");
switch (sms.State) {
- case SMS_Sent : printmsg("Sent"); break;
- case SMS_Read : printmsg("Read"); break;
- case SMS_UnRead : printmsg("UnRead"); break;
- case SMS_UnSent : printmsg("UnSent"); break;
+ case SMS_Sent : printmsg("Sent\n"); break;
+ case SMS_Read : printmsg("Read\n"); break;
+ case SMS_UnRead : printmsg("UnRead\n"); break;
+ case SMS_UnSent : printmsg("UnSent\n"); break;
}
- printmsg("\nRemote number : \"%s\"\n",DecodeUnicodeConsole(sms.Number));
if (sms.UDH.Type != UDH_NoUDH) {
printmsg("User Data Header : ");
switch (sms.UDH.Type) {
case UDH_ConcatenatedMessages : printmsg("Concatenated (linked) message"); break;
case UDH_ConcatenatedMessages16bit : printmsg("Concatenated (linked) message"); break;
case UDH_DisableVoice : printmsg("Disables voice indicator"); break;
case UDH_EnableVoice : printmsg("Enables voice indicator"); break;
case UDH_DisableFax : printmsg("Disables fax indicator"); break;
case UDH_EnableFax : printmsg("Enables fax indicator"); break;
case UDH_DisableEmail : printmsg("Disables email indicator"); break;
case UDH_EnableEmail : printmsg("Enables email indicator"); break;
case UDH_VoidSMS : printmsg("Void SMS"); break;
case UDH_NokiaWAP : printmsg("Nokia WAP bookmark"); break;
case UDH_NokiaOperatorLogoLong : printmsg("Nokia operator logo"); break;
case UDH_NokiaWAPLong : printmsg("Nokia WAP bookmark or WAP/MMS settings"); break;
case UDH_NokiaRingtone : printmsg("Nokia ringtone"); break;
case UDH_NokiaRingtoneLong : printmsg("Nokia ringtone"); break;
case UDH_NokiaOperatorLogo : printmsg("Nokia GSM operator logo"); break;
case UDH_NokiaCallerLogo : printmsg("Nokia caller logo"); break;
case UDH_NokiaProfileLong : printmsg("Nokia profile"); break;
case UDH_NokiaCalendarLong : printmsg("Nokia calendar note"); break;
case UDH_NokiaPhonebookLong : printmsg("Nokia phonebook entry"); break;
case UDH_UserUDH : printmsg("User UDH"); break;
case UDH_MMSIndicatorLong : printmsg("MMS indicator"); break;
case UDH_NoUDH: break;
}
if (sms.UDH.Type != UDH_NoUDH) {
if (sms.UDH.ID8bit != -1) printmsg(", ID (8 bit) %i",sms.UDH.ID8bit);
if (sms.UDH.ID16bit != -1) printmsg(", ID (16 bit) %i",sms.UDH.ID16bit);
if (sms.UDH.PartNumber != -1 && sms.UDH.AllParts != -1) {
if (displayudh) {
printmsg(", part %i of %i",sms.UDH.PartNumber,sms.UDH.AllParts);
} else {
printmsg(", %i parts",sms.UDH.AllParts);
}
}
}
printf("\n");
}
if (displaytext) {
printf("\n");
if (sms.Coding!=SMS_Coding_8bit) {
printmsg("%s\n",DecodeUnicodeConsole(sms.Text));
} else {
printmsg("8 bit SMS, cannot be displayed here\n");
}
}
break;
}
}
-//#if 0
+
static void displaymultismsinfo (GSM_MultiSMSMessage sms, bool eachsms, bool ems)
{
GSM_MultiPartSMSInfo SMSInfo;
bool RetVal,udhinfo=true;
int j;
/* GSM_DecodeMultiPartSMS returns if decoded SMS contenst correctly */
RetVal = GSM_DecodeMultiPartSMS(&SMSInfo,&sms,ems);
if (eachsms) {
if (sms.SMS[0].UDH.Type != UDH_NoUDH && sms.SMS[0].UDH.AllParts == sms.Number) udhinfo = false;
if (RetVal && !udhinfo) {
displaysinglesmsinfo(sms.SMS[0],false,false);
printf("\n");
} else {
for (j=0;j<sms.Number;j++) {
displaysinglesmsinfo(sms.SMS[j],!RetVal,udhinfo);
printf("\n");
}
}
} else {
for (j=0;j<sms.Number;j++) {
displaysinglesmsinfo(sms.SMS[j],!RetVal,true);
printf("\n");
}
}
if (!RetVal) {
GSM_FreeMultiPartSMSInfo(&SMSInfo);
return;
}
if (SMSInfo.Unknown) printmsg("Some details were ignored (unknown or not implemented in decoding functions)\n\n");
@@ -1256,125 +1271,141 @@ static void Monitor(int argc, char *argv[])
printf("\n");
}
}
if (gshutdown) break;
if (Phone->GetNetworkInfo(&s,&NetInfo)==ERR_NONE) {
printmsg("Network state : ");
switch (NetInfo.State) {
case GSM_HomeNetwork : printmsg("home network\n"); break;
case GSM_RoamingNetwork : printmsg("roaming network\n"); break;
case GSM_RequestingNetwork : printmsg("requesting network\n"); break;
case GSM_NoNetwork : printmsg("not logged into network\n"); break;
case GSM_RegistrationDenied : printmsg("registration to network denied\n"); break;
case GSM_NetworkStatusUnknown : printmsg("unknown\n"); break;
default : printmsg("unknown\n");
}
if (NetInfo.State == GSM_HomeNetwork || NetInfo.State == GSM_RoamingNetwork) {
printmsg("Network : %s (%s", NetInfo.NetworkCode,DecodeUnicodeConsole(GSM_GetNetworkName(NetInfo.NetworkCode)));
printmsg(", %s)", DecodeUnicodeConsole(GSM_GetCountryName(NetInfo.NetworkCode)));
printmsg(", LAC %s, CID %s\n", NetInfo.LAC,NetInfo.CID);
if (NetInfo.NetworkName[0] != 0x00 || NetInfo.NetworkName[1] != 0x00) {
printmsg("Name in phone : \"%s\"\n",DecodeUnicodeConsole(NetInfo.NetworkName));
}
}
}
printf("\n");
}
printmsg("Leaving monitor mode...\n");
GSM_Terminate();
}
+static void IncomingUSSD2(char *Device, char *Buffer)
+{
+ printmsg("Service reply: \"%s\"\n",DecodeUnicodeConsole(Buffer));
+
+ gshutdown = true;
+}
+
static void GetUSSD(int argc, char *argv[])
{
GSM_Init(true);
signal(SIGINT, interrupt);
printmsgerr("Press Ctrl+C to break...\n");
- s.User.IncomingUSSD = IncomingUSSD;
+ s.User.IncomingUSSD = IncomingUSSD2;
error=Phone->SetIncomingUSSD(&s,true);
Print_Error(error);
error=Phone->DialVoice(&s, argv[2], GSM_CALL_DefaultNumberPresence);
Print_Error(error);
while (!gshutdown) GSM_ReadDevice(&s,true);
GSM_Terminate();
}
static void GetSMSC(int argc, char *argv[])
{
GSM_SMSC smsc;
int start, stop;
GetStartStop(&start, &stop, 2, argc, argv);
GSM_Init(true);
for (i=start;i<=stop;i++) {
smsc.Location=i;
error=Phone->GetSMSC(&s, &smsc);
Print_Error(error);
if (!strcmp(DecodeUnicodeConsole(smsc.Name),"")) {
printmsg("%i. Set %i\n",smsc.Location, smsc.Location);
} else {
printmsg("%i. \"%s\"\n",smsc.Location, DecodeUnicodeConsole(smsc.Name));
}
printmsg("Number : \"%s\"\n",DecodeUnicodeConsole(smsc.Number));
printmsg("Default number : \"%s\"\n",DecodeUnicodeConsole(smsc.DefaultNumber));
printmsg("Format : ");
switch (smsc.Format) {
case SMS_FORMAT_Text : printmsg("Text"); break;
case SMS_FORMAT_Fax : printmsg("Fax"); break;
case SMS_FORMAT_Email : printmsg("Email"); break;
case SMS_FORMAT_Pager : printmsg("Pager"); break;
}
printf("\n");
printmsg("Validity : ");
switch (smsc.Validity.Relative) {
case SMS_VALID_1_Hour : printmsg("1 hour"); break;
case SMS_VALID_6_Hours : printmsg("6 hours"); break;
case SMS_VALID_1_Day : printmsg("24 hours"); break;
case SMS_VALID_3_Days : printmsg("72 hours"); break;
case SMS_VALID_1_Week : printmsg("1 week"); break;
case SMS_VALID_Max_Time : printmsg("Maximum time"); break;
- default : printmsg("Unknown");
+ default :
+ if (smsc.Validity.Relative >= 0 && smsc.Validity.Relative <= 143) {
+ printmsg("%i minutes",(smsc.Validity.Relative+1)*5);
+ } else if (smsc.Validity.Relative >= 144 && smsc.Validity.Relative <= 167) {
+ printmsg("%i minutes",12*60 + (smsc.Validity.Relative-143)*30);
+ } else if (smsc.Validity.Relative >= 168 && smsc.Validity.Relative <= 196) {
+ printmsg("%i days",smsc.Validity.Relative-166);
+ } else if (smsc.Validity.Relative >= 197 && smsc.Validity.Relative <= 255) {
+ printmsg("%i weeks",smsc.Validity.Relative-192);
+ }
}
printf("\n");
}
GSM_Terminate();
}
static void GetSMS(int argc, char *argv[])
{
GSM_MultiSMSMessage sms;
GSM_SMSFolders folders;
int start, stop;
int j;
GetStartStop(&start, &stop, 3, argc, argv);
GSM_Init(true);
error=Phone->GetSMSFolders(&s, &folders);
Print_Error(error);
for (j = start; j <= stop; j++) {
sms.SMS[0].Folder = atoi(argv[2]);
sms.SMS[0].Location = j;
error=Phone->GetSMS(&s, &sms);
switch (error) {
case ERR_EMPTY:
printmsg("Location %i\n",sms.SMS[0].Location);
printmsg("Empty\n");
break;
default:
Print_Error(error);
@@ -1399,85 +1430,83 @@ static void DeleteSMS(int argc, char *argv[])
GSM_SMSMessage sms;
int start, stop;
sms.Folder=atoi(argv[2]);
GetStartStop(&start, &stop, 3, argc, argv);
GSM_Init(true);
for (i=start;i<=stop;i++) {
sms.Folder = 0;
sms.Location = i;
error=Phone->DeleteSMS(&s, &sms);
Print_Error(error);
}
#ifdef GSM_ENABLE_BEEP
GSM_PhoneBeep();
#endif
GSM_Terminate();
}
static void GetAllSMS(int argc, char *argv[])
{
GSM_MultiSMSMessage sms;
GSM_SMSFolders folders;
bool start = true;
GSM_Init(true);
error=Phone->GetSMSFolders(&s, &folders);
Print_Error(error);
- fprintf(stderr,"Reading: ");
while (error == ERR_NONE) {
sms.SMS[0].Folder=0x00;
error=Phone->GetNextSMS(&s, &sms, start);
switch (error) {
case ERR_EMPTY:
break;
default:
Print_Error(error);
printmsg("Location %i, folder \"%s\"",sms.SMS[0].Location,DecodeUnicodeConsole(folders.Folder[sms.SMS[0].Folder-1].Name));
switch(sms.SMS[0].Memory) {
case MEM_SM: printmsg(", SIM memory"); break;
case MEM_ME: printmsg(", phone memory"); break;
case MEM_MT: printmsg(", phone or SIM memory"); break;
default : break;
}
if (sms.SMS[0].InboxFolder) printmsg(", Inbox folder");
printf("\n");
displaymultismsinfo(sms,false,false);
}
- fprintf(stderr,"*");
start=false;
}
fprintf(stderr,"\n");
#ifdef GSM_ENABLE_BEEP
GSM_PhoneBeep();
#endif
GSM_Terminate();
}
static void GetEachSMS(int argc, char *argv[])
{
GSM_MultiSMSMessage *GetSMS[PHONE_MAXSMSINFOLDER],*SortedSMS[PHONE_MAXSMSINFOLDER],sms;
int GetSMSNumber = 0,i,j;
GSM_SMSFolders folders;
bool start = true, ems = true;
GetSMS[0] = NULL;
GSM_Init(true);
error=Phone->GetSMSFolders(&s, &folders);
Print_Error(error);
fprintf(stderr,"Reading: ");
while (error == ERR_NONE) {
sms.SMS[0].Folder=0x00;
error=Phone->GetNextSMS(&s, &sms, start);
switch (error) {
case ERR_EMPTY:
break;
default:
@@ -1550,65 +1579,66 @@ static void GetSMSFolders(int argc, char *argv[])
switch(folders.Folder[i].Memory) {
case MEM_SM: printmsg(", SIM memory"); break;
case MEM_ME: printmsg(", phone memory"); break;
case MEM_MT: printmsg(", phone or SIM memory"); break;
default : break;
}
if (folders.Folder[i].InboxFolder) printmsg(", Inbox folder");
printf("\n");
}
GSM_Terminate();
}
static void GetRingtone(int argc, char *argv[])
{
GSM_Ringtone ringtone;
bool PhoneRingtone = false;
if (mystrncasecmp(argv[1],"--getphoneringtone",0)) PhoneRingtone = true;
GetStartStop(&ringtone.Location, NULL, 2, argc, argv);
GSM_Init(true);
ringtone.Format=0;
error=Phone->GetRingtone(&s,&ringtone,PhoneRingtone);
Print_Error(error);
switch (ringtone.Format) {
case RING_NOTETONE : printmsg("Smart Messaging"); break;
case RING_NOKIABINARY : printmsg("Nokia binary"); break;
- case RING_MIDI : printmsg("Midi format"); break;
+ case RING_MIDI : printmsg("MIDI"); break;
+ case RING_MMF : printmsg("SMAF (MMF)"); break;
}
printmsg(" format, ringtone \"%s\"\n",DecodeUnicodeConsole(ringtone.Name));
if (argc==4) {
error=GSM_SaveRingtoneFile(argv[3], &ringtone);
Print_Error(error);
}
GSM_Terminate();
}
static void GetRingtonesList(int argc, char *argv[])
{
GSM_AllRingtonesInfo Info;
int i;
GSM_Init(true);
error=Phone->GetRingtonesInfo(&s,&Info);
Print_Error(error);
GSM_Terminate();
for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name));
}
static void DialVoice(int argc, char *argv[])
{
GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence;
if (argc > 3) {
if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber;
@@ -2013,66 +2043,66 @@ static void DeleteCalendar(int argc, char *argv[])
GSM_CalendarEntry Note;
int start,stop;
GetStartStop(&start, &stop, 2, argc, argv);
GSM_Init(true);
for (i=start;i<=stop;i++) {
Note.Location=i;
error = Phone->DeleteCalendar(&s, &Note);
if (error == ERR_EMPTY) continue;
Print_Error(error);
PrintCalendar(&Note);
}
GSM_Terminate();
}
static void GetAllCalendar(int argc, char *argv[])
{
GSM_CalendarEntry Note;
bool refresh = true;
signal(SIGINT, interrupt);
printmsgerr("Press Ctrl+C to break...\n");
GSM_Init(true);
while (!gshutdown) {
error=Phone->GetNextCalendar(&s,&Note,refresh);
if (error == ERR_EMPTY) break;
- PrintCalendar(&Note);
Print_Error(error);
+ PrintCalendar(&Note);
refresh=false;
}
GSM_Terminate();
}
static void GetCalendarSettings(int argc, char *argv[])
{
GSM_CalendarSettings settings;
GSM_Init(true);
error=Phone->GetCalendarSettings(&s,&settings);
Print_Error(error);
if (settings.AutoDelete == 0) {
printmsg("Auto deleting disabled");
} else {
printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete);
}
printmsg("\nWeek start on ");
switch(settings.StartDay) {
case 1: printmsg("Monday"); break;
case 6: printmsg("Saturday"); break;
case 7: printmsg("Sunday"); break;
}
printf("\n");
GSM_Terminate();
}
static void GetWAPBookmark(int argc, char *argv[])
@@ -2213,64 +2243,66 @@ static void GetBitmap(int argc, char *argv[])
printmsg("Ringtone : ");
if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) {
printmsg("\"%s\" (ID %i)\n",
DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)),
MultiBitmap.Bitmap[0].RingtoneID);
} else {
printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID);
}
}
if (MultiBitmap.Bitmap[0].BitmapEnabled) {
printmsg("Bitmap : enabled\n");
} else {
printmsg("Bitmap : disabled\n");
}
if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
break;
case GSM_StartupLogo:
GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
break;
case GSM_OperatorLogo:
if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) {
GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap);
} else {
printmsg("No operator logo in phone\n");
}
break;
case GSM_PictureImage:
GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]);
printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender));
+ if (MultiBitmap.Bitmap[0].Name)
+ printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name));
if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap);
break;
case GSM_WelcomeNote_Text:
printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
break;
case GSM_DealerNote_Text:
printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text));
break;
default:
break;
}
Print_Error(error);
GSM_Terminate();
}
static void SetBitmap(int argc, char *argv[])
{
GSM_Bitmap Bitmap, NewBitmap;
GSM_MultiBitmap MultiBitmap;
GSM_NetworkInfo NetInfo;
bool init = true;
if (mystrncasecmp(argv[2],"STARTUP",0)) {
if (argc<4) {
printmsg("More arguments required\n");
exit(-1);
}
MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
MultiBitmap.Bitmap[0].Location=1;
if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2;
if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3;
@@ -2476,171 +2508,188 @@ static void DisplaySMSFrame(GSM_SMSMessage *SMS)
for(i=0;i<SMS->UDH.Length;i++) {
req[i]=buffer[PHONE_SMSSubmit.Text+i];
}
EncodeHexBin(hexudh, req, SMS->UDH.Length);
printf("msg:%s nb:%i udh:%s\n",
hexmsg,
(buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8,
hexudh);
#else
for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) {
req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i];
}
req[current++]=buffer[PHONE_SMSSubmit.firstbyte];
req[current++]=buffer[PHONE_SMSSubmit.TPMR];
for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) {
req[current++]=buffer[PHONE_SMSSubmit.Number+i];
}
req[current++]=buffer[PHONE_SMSSubmit.TPPID];
req[current++]=buffer[PHONE_SMSSubmit.TPDCS];
req[current++]=buffer[PHONE_SMSSubmit.TPVP];
req[current++]=buffer[PHONE_SMSSubmit.TPUDL];
for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i];
EncodeHexBin(hexreq, req, current);
printmsg("%s\n\n",hexreq);
#endif
}
#define SEND_SAVE_SMS_BUFFER_SIZE 10000
static GSM_Error SMSStatus;
-//#if 0
+
static void SendSMSStatus (char *Device, int status, int MessageReference)
{
dbgprintf("Sent SMS on device: \"%s\"\n",Device);
if (status==0) {
printmsg("..OK");
SMSStatus = ERR_NONE;
} else {
printmsg("..error %i",status);
SMSStatus = ERR_UNKNOWN;
}
- printmsg(", message reference=%02x\n",MessageReference);
+ printmsg(", message reference=%d\n",MessageReference);
}
static void SendSaveDisplaySMS(int argc, char *argv[])
{
#ifdef GSM_ENABLE_BACKUP
GSM_Backup Backup;
#endif
int i,j,z,FramesNum = 0;
int Protected = 0;
GSM_SMSFolders folders;
GSM_MultiSMSMessage sms;
GSM_Ringtone ringtone[MAX_MULTI_SMS];
GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2;
GSM_MultiPartSMSInfo SMSInfo;
GSM_NetworkInfo NetInfo;
GSM_MMSIndicator MMSInfo;
FILE *ReplaceFile,*f;
char ReplaceBuffer2 [200],ReplaceBuffer[200];
char InputBuffer [SEND_SAVE_SMS_BUFFER_SIZE/2+1];
char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE];
char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2];
char Name [(GSM_MAX_NUMBER_LENGTH+1)*2];
char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2];
int startarg = 0;
int chars_read = 0;
int nextlong = 0;
bool ReplyViaSameSMSC = false;
int SMSCSet = 1;
int MaxSMS = -1;
bool EMS16Bit = false;
bool SendSaved = false;
/* Parameters required only during saving */
int Folder = 1; /*Inbox by default */
GSM_SMS_State State = SMS_Sent;
/* Required only during sending */
GSM_SMSValidity Validity;
GSM_SMSC PhoneSMSC;
bool DeliveryReport = false;
ReplaceBuffer[0] = 0;
ReplaceBuffer[1] = 0;
GSM_ClearMultiPartSMSInfo(&SMSInfo);
SMSInfo.ReplaceMessage = 0;
SMSInfo.EntriesNum = 1;
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender,"Gammu",5);
Name[0] = 0;
Name[1] = 0;
startarg = 0;
} else {
EncodeUnicode(Sender,argv[3],strlen(argv[3]));
startarg = 1;
Validity.Format = 0;
}
- if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) startarg=startarg+2;
+ if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) {
+ startarg=startarg+2;
+ EncodeUnicode(SMSC,"1234",4);
+ SMSCSet = 0;
+ }
if (mystrncasecmp(argv[2],"TEXT",0)) {
chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin);
if (chars_read == 0) printmsg("Warning: 0 chars read !\n");
InputBuffer[chars_read] = 0x00;
InputBuffer[chars_read+1] = 0x00;
EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer));
SMSInfo.Entries[0].Buffer = Buffer[0];
SMSInfo.Entries[0].ID = SMS_Text;
SMSInfo.UnicodeCoding = false;
startarg += 3;
} else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) {
SMSInfo.UnicodeCoding = false;
SMSInfo.EntriesNum = 1;
Buffer[0][0] = 0x00;
Buffer[0][1] = 0x00;
SMSInfo.Entries[0].Buffer = Buffer[0];
SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName;
startarg += 3;
} else if (mystrncasecmp(argv[2],"EMS",0)) {
SMSInfo.UnicodeCoding = false;
SMSInfo.EntriesNum = 0;
startarg += 3;
} else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) {
if (argc<6+startarg) {
- printmsg("Where is ringtone filename ?\n");
+ printmsg("Where are parameters ?\n");
exit(-1);
}
SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong;
SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender,"MMS Info",8);
}
strcpy(MMSInfo.Address, argv[3+startarg]);
strcpy(MMSInfo.Title, argv[4+startarg]);
strcpy(MMSInfo.Sender, argv[5+startarg]);
startarg += 6;
+ } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) {
+ if (argc<5+startarg) {
+ printmsg("Where are parameters ?\n");
+ exit(-1);
+ }
+ SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong;
+ SMSInfo.Entries[0].MMSIndicator = &MMSInfo;
+ if (mystrncasecmp(argv[1],"--savesms",0)) {
+ EncodeUnicode(Sender,"WAP Info",8);
+ }
+ strcpy(MMSInfo.Address, argv[3+startarg]);
+ strcpy(MMSInfo.Title, argv[4+startarg]);
+ startarg += 5;
} else if (mystrncasecmp(argv[2],"RINGTONE",0)) {
if (argc<4+startarg) {
printmsg("Where is ringtone filename ?\n");
exit(-1);
}
ringtone[0].Format=RING_NOTETONE;
error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]);
Print_Error(error);
SMSInfo.Entries[0].ID = SMS_NokiaRingtone;
SMSInfo.Entries[0].Ringtone = &ringtone[0];
if (mystrncasecmp(argv[1],"--savesms",0)) {
CopyUnicodeString(Sender, ringtone[0].Name);
EncodeUnicode(Name,"Ringtone ",9);
CopyUnicodeString(Name+9*2, ringtone[0].Name);
}
startarg += 4;
} else if (mystrncasecmp(argv[2],"OPERATOR",0)) {
if (argc<4+startarg) {
printmsg("Where is logo filename ?\n");
exit(-1);
}
bitmap[0].Bitmap[0].Type=GSM_OperatorLogo;
error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
Print_Error(error);
strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00");
SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo;
SMSInfo.Entries[0].Bitmap = &bitmap[0];
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "OpLogo",6);
EncodeUnicode(Name,"OpLogo ",7);
}
startarg += 4;
@@ -2681,211 +2730,211 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
}
SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong;
SMSInfo.Entries[0].Bitmap = &bitmap[0];
bitmap[0].Bitmap[0].Text[0] = 0;
bitmap[0].Bitmap[0].Text[1] = 0;
startarg += 4 + atoi(argv[3+startarg]);
} else if (mystrncasecmp(argv[2],"PICTURE",0)) {
if (argc<4+startarg) {
printmsg("Where is logo filename ?\n");
exit(-1);
}
bitmap[0].Bitmap[0].Type=GSM_PictureImage;
error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]);
printmsg("File \"%s\"\n",argv[3+startarg]);
Print_Error(error);
SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong;
SMSInfo.Entries[0].Bitmap = &bitmap[0];
SMSInfo.UnicodeCoding = false;
bitmap[0].Bitmap[0].Text[0] = 0;
bitmap[0].Bitmap[0].Text[1] = 0;
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "Picture",7);
EncodeUnicode(Name,"Picture Image",13);
}
startarg += 4;
#ifdef GSM_ENABLE_BACKUP
} else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
if (argc<5+startarg) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.WAPBookmark[i]!=NULL) {
if (i == atoi(argv[4+startarg])-1) break;
i++;
}
if (i != atoi(argv[4+startarg])-1) {
printmsg("Bookmark not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i];
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "Bookmark",8);
EncodeUnicode(Name,"WAP Bookmark",12);
}
startarg += 5;
} else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) {
if (argc<6+startarg) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.WAPSettings[i]!=NULL) {
if (i == atoi(argv[4+startarg])-1) break;
i++;
}
if (i != atoi(argv[4+startarg])-1) {
printmsg("WAP settings not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].Settings = NULL;
for (j=0;j<Backup.WAPSettings[i]->Number;j++) {
switch (Backup.WAPSettings[i]->Settings[j].Bearer) {
case WAPSETTINGS_BEARER_GPRS:
if (mystrncasecmp(argv[5+startarg],"GPRS",0)) {
SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
break;
}
case WAPSETTINGS_BEARER_DATA:
if (mystrncasecmp(argv[5+startarg],"DATA",0)) {
SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j];
break;
}
default:
break;
}
}
if (SMSInfo.Entries[0].Settings == NULL) {
printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n");
exit(-1);
}
SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong;
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "Settings",8);
EncodeUnicode(Name,"WAP Settings",12);
}
startarg += 6;
} else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) {
if (argc<5+startarg) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.MMSSettings[i]!=NULL) {
if (i == atoi(argv[4+startarg])-1) break;
i++;
}
if (i != atoi(argv[4+startarg])-1) {
printmsg("MMS settings not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].Settings = NULL;
for (j=0;j<Backup.MMSSettings[i]->Number;j++) {
switch (Backup.MMSSettings[i]->Settings[j].Bearer) {
case WAPSETTINGS_BEARER_GPRS:
SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j];
break;
default:
break;
}
}
if (SMSInfo.Entries[0].Settings == NULL) {
printmsg("Sorry. No GPRS bearer found in MMS settings\n");
exit(-1);
}
SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong;
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "Settings",8);
EncodeUnicode(Name,"MMS Settings",12);
}
startarg += 5;
} else if (mystrncasecmp(argv[2],"CALENDAR",0)) {
if (argc<5+startarg) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.Calendar[i]!=NULL) {
if (i == atoi(argv[4+startarg])-1) break;
i++;
}
if (i != atoi(argv[4+startarg])-1) {
printmsg("Calendar note not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long;
SMSInfo.Entries[0].Calendar = Backup.Calendar[i];
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "Calendar",8);
}
startarg += 5;
} else if (mystrncasecmp(argv[2],"TODO",0)) {
if (argc<5+startarg) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.ToDo[i]!=NULL) {
if (i == atoi(argv[4+startarg])-1) break;
i++;
}
if (i != atoi(argv[4+startarg])-1) {
printmsg("ToDo note not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong;
SMSInfo.Entries[0].ToDo = Backup.ToDo[i];
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "ToDo",8);
}
startarg += 5;
} else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
if (argc<6+startarg) {
printmsg("Where is backup filename and location and memory type ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[3+startarg],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
if (mystrncasecmp(argv[4+startarg],"SM",0)) {
while (Backup.SIMPhonebook[i]!=NULL) {
if (i == atoi(argv[5+startarg])-1) break;
i++;
}
if (i != atoi(argv[5+startarg])-1) {
printmsg("Phonebook entry not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i];
} else if (mystrncasecmp(argv[4+startarg],"ME",0)) {
while (Backup.PhonePhonebook[i]!=NULL) {
if (i == atoi(argv[5+startarg])-1) break;
i++;
}
if (i != atoi(argv[5+startarg])-1) {
printmsg("Phonebook entry not found in file\n");
exit(-1);
}
SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i];
} else {
printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]);
exit(-1);
}
if (mystrncasecmp(argv[2],"VCARD10",0)) {
SMSInfo.Entries[0].ID = SMS_VCARD10Long;
} else {
SMSInfo.Entries[0].ID = SMS_VCARD21Long;
}
if (mystrncasecmp(argv[1],"--savesms",0)) {
EncodeUnicode(Sender, "VCARD",5);
@@ -3780,193 +3829,196 @@ static void SendSaveDisplaySMS(int argc, char *argv[])
error=Phone->SendSMS(&s, &sms.SMS[i]);
Print_Error(error);
printmsg("....waiting for network answer");
while (!gshutdown) {
GSM_ReadDevice(&s,true);
if (SMSStatus == ERR_UNKNOWN) {
GSM_Terminate();
exit(-1);
}
if (SMSStatus == ERR_NONE) break;
}
}
}
GSM_Terminate();
}
#ifdef GSM_ENABLE_BACKUP
static void SaveFile(int argc, char *argv[])
{
GSM_Backup Backup;
int i,j;
FILE *file;
unsigned char Buffer[10000];
GSM_MemoryEntry *pbk;
if (mystrncasecmp(argv[2],"CALENDAR",0)) {
if (argc<5) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.Calendar[i]!=NULL) {
if (i == atoi(argv[5])-1) break;
i++;
}
if (i != atoi(argv[5])-1) {
printmsg("Calendar note not found in file\n");
exit(-1);
}
j = 0;
GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar);
} else if (mystrncasecmp(argv[2],"BOOKMARK",0)) {
if (argc<5) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.WAPBookmark[i]!=NULL) {
if (i == atoi(argv[5])-1) break;
i++;
}
if (i != atoi(argv[5])-1) {
printmsg("WAP bookmark not found in file\n");
exit(-1);
}
j = 0;
GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]);
} else if (mystrncasecmp(argv[2],"NOTE",0)) {
if (argc<5) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.Note[i]!=NULL) {
if (i == atoi(argv[5])-1) break;
i++;
}
if (i != atoi(argv[5])-1) {
printmsg("Note not found in file\n");
exit(-1);
}
j = 0;
GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]);
} else if (mystrncasecmp(argv[2],"TODO",0)) {
if (argc<5) {
printmsg("Where is backup filename and location ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
while (Backup.ToDo[i]!=NULL) {
if (i == atoi(argv[5])-1) break;
i++;
}
if (i != atoi(argv[5])-1) {
printmsg("ToDo note not found in file\n");
exit(-1);
}
j = 0;
GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo);
} else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) {
if (argc<6) {
printmsg("Where is backup filename and location and memory type ?\n");
exit(-1);
}
error=GSM_ReadBackupFile(argv[4],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
i = 0;
if (mystrncasecmp(argv[5],"SM",0)) {
while (Backup.SIMPhonebook[i]!=NULL) {
if (i == atoi(argv[6])-1) break;
i++;
}
if (i != atoi(argv[6])-1) {
printmsg("Phonebook entry not found in file\n");
exit(-1);
}
pbk = Backup.SIMPhonebook[i];
} else if (mystrncasecmp(argv[5],"ME",0)) {
while (Backup.PhonePhonebook[i]!=NULL) {
if (i == atoi(argv[6])-1) break;
i++;
}
if (i != atoi(argv[6])-1) {
printmsg("Phonebook entry not found in file\n");
exit(-1);
}
pbk = Backup.PhonePhonebook[i];
} else {
printmsg("Unknown memory type: \"%s\"\n",argv[5]);
exit(-1);
}
j = 0;
if (mystrncasecmp(argv[2],"VCARD10",0)) {
GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10);
} else {
GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21);
}
} else {
printmsg("What format of file (\"%s\") ?\n",argv[2]);
exit(-1);
}
file = fopen(argv[3],"wb");
fwrite(Buffer,1,j,file);
fclose(file);
}
static void Backup(int argc, char *argv[])
{
int i, used;
GSM_MemoryStatus MemStatus;
GSM_ToDoEntry ToDo;
GSM_ToDoStatus ToDoStatus;
GSM_MemoryEntry Pbk;
- GSM_CalendarEntry Note;
+ GSM_CalendarEntry Calendar;
GSM_Bitmap Bitmap;
GSM_WAPBookmark Bookmark;
GSM_Profile Profile;
GSM_MultiWAPSettings Settings;
+ GSM_SyncMLSettings SyncML;
+ GSM_ChatSettings Chat;
GSM_Ringtone Ringtone;
GSM_SMSC SMSC;
GSM_Backup Backup;
+ GSM_NoteEntry Note;
GSM_Backup_Info Info;
GSM_FMStation FMStation;
GSM_GPRSAccessPoint GPRSPoint;
bool DoBackup;
if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true;
GSM_ClearBackup(&Backup);
GSM_GetBackupFormatFeatures(argv[2],&Info);
sprintf(Backup.Creator,"Gammu %s",VERSION);
if (strlen(GetOS()) != 0) {
strcat(Backup.Creator+strlen(Backup.Creator),", ");
strcat(Backup.Creator+strlen(Backup.Creator),GetOS());
}
if (strlen(GetCompiler()) != 0) {
strcat(Backup.Creator+strlen(Backup.Creator),", ");
strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler());
}
signal(SIGINT, interrupt);
printmsgerr("Press Ctrl+C to break...\n");
GSM_Init(true);
if (Info.UseUnicode) {
Info.UseUnicode=answer_yes("Use Unicode subformat of backup file");
}
if (Info.DateTime) {
GSM_GetCurrentDateTime (&Backup.DateTime);
Backup.DateTimeAvailable=true;
}
@@ -4045,126 +4097,158 @@ static void Backup(int argc, char *argv[])
Pbk.MemoryType = MEM_SM;
i = 1;
used = 0;
while (used != MemStatus.MemoryUsed) {
Pbk.Location = i;
error=Phone->GetMemory(&s, &Pbk);
if (error != ERR_EMPTY) {
Print_Error(error);
if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) {
Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.SIMPhonebook[used + 1] = NULL;
} else {
printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK");
GSM_Terminate();
exit(-1);
}
*Backup.SIMPhonebook[used]=Pbk;
used++;
}
printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed);
i++;
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoBackup = false;
if (Info.Calendar) {
printmsg("Checking calendar\n");
- error=Phone->GetNextCalendar(&s,&Note,true);
+ error=Phone->GetNextCalendar(&s,&Calendar,true);
if (error==ERR_NONE) {
if (answer_yes(" Backup calendar notes")) DoBackup = true;
}
}
if (DoBackup) {
used = 0;
printmsgerr(" Reading : ");
while (error == ERR_NONE) {
if (used < GSM_MAXCALENDARTODONOTES) {
Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry));
if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.Calendar[used+1] = NULL;
} else {
printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
GSM_Terminate();
exit(-1);
}
- *Backup.Calendar[used]=Note;
+ *Backup.Calendar[used]=Calendar;
used ++;
- error=Phone->GetNextCalendar(&s,&Note,false);
+ error=Phone->GetNextCalendar(&s,&Calendar,false);
printmsgerr("*");
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoBackup = false;
if (Info.ToDo) {
printmsg("Checking ToDo\n");
error=Phone->GetToDoStatus(&s,&ToDoStatus);
if (error == ERR_NONE && ToDoStatus.Used != 0) {
if (answer_yes(" Backup ToDo")) DoBackup = true;
}
}
if (DoBackup) {
used = 0;
error=Phone->GetNextToDo(&s,&ToDo,true);
while (error == ERR_NONE) {
if (used < GSM_MAXCALENDARTODONOTES) {
Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry));
if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.ToDo[used+1] = NULL;
} else {
printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES");
GSM_Terminate();
exit(-1);
}
*Backup.ToDo[used]=ToDo;
used ++;
error=Phone->GetNextToDo(&s,&ToDo,false);
printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used);
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoBackup = false;
+ if (Info.Note) {
+ printmsg("Checking notes\n");
+ error=Phone->GetNextNote(&s,&Note,true);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup notes")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_NOTE) {
+ Backup.Note[used] = malloc(sizeof(GSM_NoteEntry));
+ if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.Note[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.Note[used]=Note;
+ used ++;
+ error=Phone->GetNextNote(&s,&Note,false);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
if (Info.CallerLogos) {
printmsg("Checking caller logos\n");
Bitmap.Type = GSM_CallerGroupLogo;
Bitmap.Location = 1;
error=Phone->GetBitmap(&s,&Bitmap);
if (error == ERR_NONE) {
if (answer_yes(" Backup caller groups and logos")) DoBackup = true;
}
}
if (DoBackup) {
printmsgerr(" Reading : ");
error = ERR_NONE;
used = 0;
while (error == ERR_NONE) {
if (used < GSM_BACKUP_MAX_CALLER) {
Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap));
if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.CallerLogos[used+1] = NULL;
} else {
printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER");
GSM_Terminate();
exit(-1);
}
*Backup.CallerLogos[used] = Bitmap;
used ++;
Bitmap.Location = used + 1;
error=Phone->GetBitmap(&s,&Bitmap);
printmsgerr("*");
if (gshutdown) {
GSM_Terminate();
exit(0);
}
@@ -4205,157 +4289,225 @@ static void Backup(int argc, char *argv[])
error = Phone->GetBitmap(&s,&Bitmap);
if (error == ERR_NONE) {
if (answer_yes(" Backup startup logo/text")) DoBackup = true;
}
}
if (DoBackup) {
Backup.StartupLogo = malloc(sizeof(GSM_Bitmap));
if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY);
*Backup.StartupLogo = Bitmap;
if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) {
Bitmap.Type = GSM_StartupLogo;
error = Phone->GetBitmap(&s,&Bitmap);
if (error == ERR_NONE) *Backup.StartupLogo = Bitmap;
}
}
DoBackup = false;
if (Info.OperatorLogo) {
printmsg("Checking operator logo\n");
Bitmap.Type = GSM_OperatorLogo;
error=Phone->GetBitmap(&s,&Bitmap);
if (error == ERR_NONE) {
if (strcmp(Bitmap.NetworkCode,"000 00")!=0) {
if (answer_yes(" Backup operator logo")) DoBackup = true;
}
}
}
if (DoBackup) {
Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap));
if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY);
*Backup.OperatorLogo = Bitmap;
}
DoBackup = false;
+ if (Info.WAPBookmark) {
+ printmsg("Checking WAP bookmarks\n");
+ Bookmark.Location = 1;
+ error=Phone->GetWAPBookmark(&s,&Bookmark);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
+ Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
+ if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.WAPBookmark[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.WAPBookmark[used]=Bookmark;
+ used ++;
+ Bookmark.Location = used+1;
+ error=Phone->GetWAPBookmark(&s,&Bookmark);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
+ if (Info.WAPSettings) {
+ printmsg("Checking WAP settings\n");
+ Settings.Location = 1;
+ error=Phone->GetWAPSettings(&s,&Settings);
+ if (error==ERR_NONE) {
+ if (answer_yes(" Backup WAP settings")) DoBackup = true;
+ }
+ }
+ if (DoBackup) {
+ used = 0;
+ printmsgerr(" Reading : ");
+ while (error == ERR_NONE) {
+ if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
+ Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
+ if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.WAPSettings[used+1] = NULL;
+ } else {
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
+ GSM_Terminate();
+ exit(-1);
+ }
+ *Backup.WAPSettings[used]=Settings;
+ used ++;
+ Settings.Location = used+1;
+ error=Phone->GetWAPSettings(&s,&Settings);
+ printmsgerr("*");
+ if (gshutdown) {
+ GSM_Terminate();
+ exit(0);
+ }
+ }
+ printmsgerr("\n");
+ }
+ DoBackup = false;
if (Info.MMSSettings) {
printmsg("Checking MMS settings\n");
Settings.Location = 1;
error=Phone->GetMMSSettings(&s,&Settings);
if (error==ERR_NONE) {
if (answer_yes(" Backup MMS settings")) DoBackup = true;
}
}
if (DoBackup) {
used = 0;
printmsgerr(" Reading : ");
while (error == ERR_NONE) {
if (used < GSM_BACKUP_MAX_MMSSETTINGS) {
Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.MMSSettings[used+1] = NULL;
} else {
printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS");
GSM_Terminate();
exit(-1);
}
*Backup.MMSSettings[used]=Settings;
used ++;
Settings.Location = used+1;
error=Phone->GetMMSSettings(&s,&Settings);
printmsgerr("*");
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoBackup = false;
- if (Info.WAPBookmark) {
- printmsg("Checking WAP bookmarks\n");
- Bookmark.Location = 1;
- error=Phone->GetWAPBookmark(&s,&Bookmark);
+ if (Info.ChatSettings) {
+ printmsg("Checking Chat settings\n");
+ Chat.Location = 1;
+ error=Phone->GetChatSettings(&s,&Chat);
if (error==ERR_NONE) {
- if (answer_yes(" Backup WAP bookmarks")) DoBackup = true;
+ if (answer_yes(" Backup Chat settings")) DoBackup = true;
}
}
if (DoBackup) {
used = 0;
printmsgerr(" Reading : ");
while (error == ERR_NONE) {
- if (used < GSM_BACKUP_MAX_WAPBOOKMARK) {
- Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark));
- if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY);
- Backup.WAPBookmark[used+1] = NULL;
+ if (used < GSM_BACKUP_MAX_CHATSETTINGS) {
+ Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings));
+ if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.ChatSettings[used+1] = NULL;
} else {
- printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK");
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS");
GSM_Terminate();
exit(-1);
}
- *Backup.WAPBookmark[used]=Bookmark;
+ *Backup.ChatSettings[used]=Chat;
used ++;
- Bookmark.Location = used+1;
- error=Phone->GetWAPBookmark(&s,&Bookmark);
+ Chat.Location = used+1;
+ error=Phone->GetChatSettings(&s,&Chat);
printmsgerr("*");
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoBackup = false;
- if (Info.WAPSettings) {
- printmsg("Checking WAP settings\n");
- Settings.Location = 1;
- error=Phone->GetWAPSettings(&s,&Settings);
+ if (Info.SyncMLSettings) {
+ printmsg("Checking SyncML settings\n");
+ SyncML.Location = 1;
+ error=Phone->GetSyncMLSettings(&s,&SyncML);
if (error==ERR_NONE) {
- if (answer_yes(" Backup WAP settings")) DoBackup = true;
+ if (answer_yes(" Backup SyncML settings")) DoBackup = true;
}
}
if (DoBackup) {
used = 0;
printmsgerr(" Reading : ");
while (error == ERR_NONE) {
- if (used < GSM_BACKUP_MAX_WAPSETTINGS) {
- Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings));
- if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
- Backup.WAPSettings[used+1] = NULL;
+ if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) {
+ Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings));
+ if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY);
+ Backup.SyncMLSettings[used+1] = NULL;
} else {
- printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS");
+ printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS");
GSM_Terminate();
exit(-1);
}
- *Backup.WAPSettings[used]=Settings;
+ *Backup.SyncMLSettings[used]=SyncML;
used ++;
- Settings.Location = used+1;
- error=Phone->GetWAPSettings(&s,&Settings);
+ SyncML.Location = used+1;
+ error=Phone->GetSyncMLSettings(&s,&SyncML);
printmsgerr("*");
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoBackup = false;
if (Info.Ringtone) {
printmsg("Checking user ringtones\n");
Ringtone.Location = 1;
Ringtone.Format = 0;
error=Phone->GetRingtone(&s,&Ringtone,false);
if (error==ERR_EMPTY || error == ERR_NONE) {
if (answer_yes(" Backup user ringtones")) DoBackup = true;
}
}
if (DoBackup) {
used = 0;
i = 1;
printmsgerr(" Reading : ");
while (error == ERR_NONE || error == ERR_EMPTY) {
if (error == ERR_NONE) {
if (used < GSM_BACKUP_MAX_RINGTONES) {
Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone));
if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.Ringtone[used+1] = NULL;
} else {
printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES");
GSM_Terminate();
exit(-1);
@@ -4473,72 +4625,77 @@ static void Backup(int argc, char *argv[])
printmsgerr("*");
}
printmsgerr("\n");
}
GSM_Terminate();
GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode);
GSM_FreeBackup(&Backup);
}
static void Restore(int argc, char *argv[])
{
GSM_Backup Backup;
GSM_FMStation FMStation;
GSM_DateTime date_time;
GSM_CalendarEntry Calendar;
GSM_Bitmap Bitmap;
GSM_Ringtone Ringtone;
GSM_MemoryEntry Pbk;
GSM_MemoryStatus MemStatus;
GSM_ToDoEntry ToDo;
GSM_ToDoStatus ToDoStatus;
GSM_Profile Profile;
GSM_MultiWAPSettings Settings;
GSM_GPRSAccessPoint GPRSPoint;
GSM_WAPBookmark Bookmark;
int i, used, max = 0;
bool Past = true;
bool Found, DoRestore;
error=GSM_ReadBackupFile(argv[2],&Backup);
+ if (error!=ERR_NOTIMPLEMENTED) {
Print_Error(error);
+ } else {
+ 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");
+ }
signal(SIGINT, interrupt);
printmsgerr("Press Ctrl+C to break...\n");
if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
+ if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator);
if (Backup.MD5Calculated[0]!=0) {
dbgprintf("\"%s\"\n",Backup.MD5Original);
dbgprintf("\"%s\"\n",Backup.MD5Calculated);
if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) {
if (!answer_yes("Checksum in backup file do not match. Continue")) return;
}
}
GSM_Init(true);
DoRestore = false;
if (Backup.PhonePhonebook[0] != NULL) {
MemStatus.MemoryType = MEM_ME;
error=Phone->GetMemoryStatus(&s, &MemStatus);
if (error==ERR_NONE) {
max = 0;
while (Backup.PhonePhonebook[max]!=NULL) max++;
printmsgerr("%i entries in backup file\n",max);
if (answer_yes("Restore phone phonebook")) DoRestore = true;
}
}
if (DoRestore) {
used = 0;
for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
Pbk.MemoryType = MEM_ME;
Pbk.Location = i + 1;
Pbk.EntriesNum = 0;
if (used<max) {
if (Backup.PhonePhonebook[used]->Location == Pbk.Location) {
Pbk = *Backup.PhonePhonebook[used];
used++;
@@ -4589,140 +4746,134 @@ static void Restore(int argc, char *argv[])
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoRestore = false;
if (Backup.CallerLogos[0] != NULL) {
Bitmap.Type = GSM_CallerGroupLogo;
Bitmap.Location = 1;
error=Phone->GetBitmap(&s,&Bitmap);
if (error == ERR_NONE) {
if (answer_yes("Restore caller groups and logos")) DoRestore = true;
}
}
if (DoRestore) {
max = 0;
while (Backup.CallerLogos[max]!=NULL) max++;
for (i=0;i<max;i++) {
error=Phone->SetBitmap(&s,Backup.CallerLogos[i]);
Print_Error(error);
printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
- 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 ) {
+ 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)")) {
GSM_GetCurrentDateTime(&date_time);
error=Phone->SetDateTime(&s, &date_time);
Print_Error(error);
}
}
DoRestore = false;
if (Backup.Calendar[0] != NULL) {
- DoRestore = true;
/* N6110 doesn't support getting calendar status */
error = Phone->GetNextCalendar(&s,&Calendar,true);
if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) {
max = 0;
while (Backup.Calendar[max] != NULL) max++;
printmsgerr("%i entries in backup file\n",max);
+ // LR
+ //if (answer_yes("Restore calendar notes")) {
+ //Past = answer_yes("Restore notes from the past");
DoRestore = true;
- /*
- if (answer_yes("Restore calendar notes")) {
- Past = answer_yes("Restore notes from the past");
- DoRestore = true;
- }
- */
+ //}
}
}
if (DoRestore) {
printmsgerr("Deleting old notes: ");
error = Phone->DeleteAllCalendar(&s);
if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
while (1) {
error = Phone->GetNextCalendar(&s,&Calendar,true);
if (error != ERR_NONE) break;
error = Phone->DeleteCalendar(&s,&Calendar);
Print_Error(error);
printmsgerr("*");
}
printmsgerr("\n");
} else {
printmsgerr("Done\n");
Print_Error(error);
}
for (i=0;i<max;i++) {
if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue;
Calendar = *Backup.Calendar[i];
error=Phone->AddCalendar(&s,&Calendar);
Print_Error(error);
printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
DoRestore = false;
if (Backup.ToDo[0] != NULL) {
error = Phone->GetToDoStatus(&s,&ToDoStatus);
if (error == ERR_NONE) {
- error == ERR_NOTSUPPORTED;
- DoRestore = true;
max = 0;
while (Backup.ToDo[max]!=NULL) max++;
printmsgerr("%i entries in backup file\n",max);
- /*if (answer_yes("Restore ToDo")) */DoRestore = true;
+ //LR if (answer_yes("Restore ToDo"))
+ DoRestore = true;
}
}
if (DoRestore) {
- if ( max > 0 ) {
ToDo = *Backup.ToDo[0];
error = Phone->SetToDo(&s,&ToDo);
}
- }
if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) {
printmsgerr("Deleting old ToDo: ");
error=Phone->DeleteAllToDo(&s);
if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
while (1) {
error = Phone->GetNextToDo(&s,&ToDo,true);
if (error != ERR_NONE) break;
error = Phone->DeleteToDo(&s,&ToDo);
Print_Error(error);
printmsgerr("*");
}
printmsgerr("\n");
} else {
printmsgerr("Done\n");
Print_Error(error);
}
for (i=0;i<max;i++) {
ToDo = *Backup.ToDo[i];
ToDo.Location = 0;
error=Phone->AddToDo(&s,&ToDo);
Print_Error(error);
printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
} else if (DoRestore) {
/* At first delete entries, that were deleted */
used = 0;
@@ -4962,65 +5113,65 @@ static void Restore(int argc, char *argv[])
}
if (DoRestore) {
max = 0;
while (Backup.GPRSPoint[max]!=NULL) max++;
for (i=0;i<max;i++) {
error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]);
Print_Error(error);
printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
}
GSM_Terminate();
}
static void AddNew(int argc, char *argv[])
{
GSM_Backup Backup;
GSM_DateTime date_time;
GSM_MemoryEntry Pbk;
GSM_MemoryStatus MemStatus;
GSM_ToDoEntry ToDo;
GSM_ToDoStatus ToDoStatus;
GSM_CalendarEntry Calendar;
GSM_WAPBookmark Bookmark;
int i, max, j;
error=GSM_ReadBackupFile(argv[2],&Backup);
- Print_Error(error);
+ if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
signal(SIGINT, interrupt);
printmsgerr("Press Ctrl+C to break...\n");
if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
GSM_Init(true);
if (Backup.PhonePhonebook[0] != NULL) {
MemStatus.MemoryType = MEM_ME;
error=Phone->GetMemoryStatus(&s, &MemStatus);
if (error==ERR_NONE) {
max = 0;
while (Backup.PhonePhonebook[max]!=NULL) max++;
printmsgerr("%i entries in backup file\n",max);
if (MemStatus.MemoryFree < max) {
printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree);
} else if (answer_yes("Add phone phonebook entries")) {
for (i=0;i<max;i++) {
Pbk = *Backup.PhonePhonebook[i];
Pbk.MemoryType = MEM_ME;
error=Phone->AddMemory(&s, &Pbk);
Print_Error(error);
printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
if (gshutdown) {
GSM_Terminate();
exit(0);
}
}
printmsgerr("\n");
@@ -5589,66 +5740,65 @@ static void AddSMS(int argc, char *argv[])
if (answer_yes("Restore sms")) {
error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
Print_Error(error);
}
smsnum++;
}
GSM_Terminate();
}
static void RestoreSMS(int argc, char *argv[])
{
GSM_MultiSMSMessage SMS;
GSM_SMS_Backup Backup;
GSM_SMSFolders folders;
int smsnum = 0;
char buffer[200];
error=GSM_ReadSMSBackupFile(argv[2], &Backup);
Print_Error(error);
GSM_Init(true);
error=Phone->GetSMSFolders(&s, &folders);
Print_Error(error);
while (Backup.SMS[smsnum] != NULL) {
SMS.Number = 1;
memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage));
displaymultismsinfo(SMS,false,false);
sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name));
if (answer_yes(buffer)) {
- Backup.SMS[smsnum]->Location = 0;
- error=Phone->SetSMS(&s, Backup.SMS[smsnum]);
+ error=Phone->AddSMS(&s, Backup.SMS[smsnum]);
Print_Error(error);
}
smsnum++;
}
GSM_Terminate();
}
#endif
static void CopyBitmap(int argc, char *argv[])
{
GSM_MultiBitmap Bitmap;
int i;
Bitmap.Bitmap[0].Type = GSM_None;
error=GSM_ReadBitmapFile(argv[2],&Bitmap);
Print_Error(error);
if (argc==3) {
for (i=0;i<Bitmap.Number;i++) {
switch (Bitmap.Bitmap[i].Type) {
case GSM_StartupLogo : printmsg("Startup logo"); break;
case GSM_OperatorLogo: printmsg("Operator logo"); break;
case GSM_PictureImage: printmsg("Picture Image"); break;
case GSM_CallerGroupLogo : printmsg("Caller group logo"); break;
default : break;
}
printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight);
GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]);
}
} else {
@@ -5784,65 +5934,65 @@ static void NokiaComposer(int argc, char *argv[])
}
}
}
Duration = 0;
switch (Note->Duration) {
case Duration_Full : Duration = 128; break;
case Duration_1_2 : Duration = 64; break;
case Duration_1_4 : Duration = 32; break;
case Duration_1_8 : Duration = 16; break;
case Duration_1_16 : Duration = 8; break;
case Duration_1_32 : Duration = 4; break;
default : dbgprintf("error\n");break;
}
if (Duration > DefNoteDuration) {
while (DefNoteDuration != Duration) {
printmsg("9");
DefNoteDuration = DefNoteDuration * 2;
}
}
if (Duration < DefNoteDuration) {
while (DefNoteDuration != Duration) {
printmsg("8");
DefNoteDuration = DefNoteDuration / 2;
}
}
printmsg(" ");
}
}
}
printf("\n");
}
-//#if 0
+
static void CopyRingtone(int argc, char *argv[])
{
GSM_Ringtone ringtone, ringtone2;
GSM_RingtoneFormat Format;
ringtone.Format = 0;
error=GSM_ReadRingtoneFile(argv[2],&ringtone);
Print_Error(error);
Format = ringtone.Format;
if (argc == 5) {
if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE;
} else if (mystrncasecmp(argv[4],"BINARY",0)) { Format = RING_NOKIABINARY;
} else {
printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]);
exit(-1);
}
}
error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format);
Print_Error(error);
error=GSM_SaveRingtoneFile(argv[3],&ringtone2);
Print_Error(error);
}
static void PressKeySequence(int argc, char *argv[])
{
int i,Length;
GSM_KeyCode KeyCode[500];
error = MakeKeySequence(argv[2], KeyCode, &Length);
@@ -6069,142 +6219,135 @@ static void ListToDoCategory(int argc, char *argv[])
printmsgerr("Press Ctrl+C to break...\n");
Length = strlen(argv[2]);
for (j = 0; j < Length; j++) {
if (!isdigit(argv[2][j])) {
Number = false;
break;
}
}
if (Number) {
j = atoi(argv[2]);
if (j > 0) {
ListToDoCategoryEntries(j);
}
} else {
if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH);
Length = GSM_MAX_CATEGORY_NAME_LENGTH;
}
EncodeUnicode(Text, argv[2], Length);
Category.Type = Category_ToDo;
Status.Type = Category_ToDo;
if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) {
for (count=0,j=1;count<Status.Used;j++) {
Category.Location=j;
error=Phone->GetCategory(&s, &Category);
if (error != ERR_EMPTY) {
count++;
- if (mystrstr(Category.Name, Text) != NULL) {
+ if (mywstrstr(Category.Name, Text) != NULL) {
ListToDoCategoryEntries(j);
}
}
}
}
}
GSM_Terminate();
}
static void GetToDo(int argc, char *argv[])
{
GSM_ToDoEntry ToDo;
int i;
int start,stop;
GetStartStop(&start, &stop, 2, argc, argv);
GSM_Init(true);
for (i=start;i<=stop;i++) {
ToDo.Location=i;
error = Phone->GetToDo(&s,&ToDo);
if (error == ERR_EMPTY) continue;
Print_Error(error);
PrintToDo(&ToDo);
}
GSM_Terminate();
}
static void GetAllToDo(int argc, char *argv[])
{
GSM_ToDoEntry ToDo;
bool start = true;
signal(SIGINT, interrupt);
printmsgerr("Press Ctrl+C to break...\n");
GSM_Init(true);
while (!gshutdown) {
error = Phone->GetNextToDo(&s, &ToDo, start);
if (error == ERR_EMPTY) break;
Print_Error(error);
PrintToDo(&ToDo);
start = false;
}
GSM_Terminate();
}
-static void GetNote(int argc, char *argv[])
+static void GetAllNotes(int argc, char *argv[])
{
GSM_NoteEntry Note;
- int start,stop;
- bool refresh=true;
+ bool start = true;
- GetStartStop(&start, &stop, 2, argc, argv);
+ signal(SIGINT, interrupt);
+ printmsgerr("Press Ctrl+C to break...\n");
GSM_Init(true);
- for (i=start;i<=stop;i++) {
- Note.Location=i;
- printmsg("Location : %i\n",i);
- error=Phone->GetNote(&s,&Note,refresh);
- if (error != ERR_EMPTY) Print_Error(error);
-
- if (error == ERR_EMPTY) {
- printmsg("Entry is empty\n\n");
- } else {
+ while (!gshutdown) {
+ error = Phone->GetNextNote(&s, &Note, start);
+ if (error == ERR_EMPTY) break;
+ Print_Error(error);
printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text));
printf("\n");
- refresh=false;
- }
+ start = false;
}
-
GSM_Terminate();
}
static void GetSecurityStatus(int argc, char *argv[])
{
GSM_Init(true);
PrintSecurityStatus();
GSM_Terminate();
}
static void EnterSecurityCode(int argc, char *argv[])
{
GSM_SecurityCode Code;
if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin;
} else if (mystrncasecmp(argv[2],"PUK",0)) { Code.Type = SEC_Puk;
} else if (mystrncasecmp(argv[2],"PIN2",0)) { Code.Type = SEC_Pin2;
} else if (mystrncasecmp(argv[2],"PUK2",0)) { Code.Type = SEC_Puk2;
} else {
printmsg("What security code (\"%s\") ?\n",argv[2]);
exit(-1);
}
strcpy(Code.Code,argv[3]);
GSM_Init(true);
error=Phone->EnterSecurityCode(&s,Code);
Print_Error(error);
@@ -6542,79 +6685,104 @@ static void SetAutoNetworkLogin(int argc, char *argv[])
#ifdef DEBUG
static void MakeConvertTable(int argc, char *argv[])
{
unsigned char InputBuffer[10000], Buffer[10000];
FILE *file;
int size,i,j=0;
file = fopen(argv[2], "rb");
if (file == NULL) Print_Error(ERR_CANTOPENFILE);
size=fread(InputBuffer, 1, 10000-1, file);
fclose(file);
InputBuffer[size] = 0;
InputBuffer[size+1] = 0;
ReadUnicodeFile(Buffer,InputBuffer);
for(i=0;i<((int)UnicodeLength(Buffer));i++) {
j++;
if (j==100) {
printf("\"\\\n\"");
j=0;
}
printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]);
}
printf("\\x00\\x00");
}
#endif
static void ListNetworks(int argc, char *argv[])
{
extern unsigned char *GSM_Networks[];
+ extern unsigned char *GSM_Countries[];
int i=0;
+ char country[4]="";
- printmsg("Network Name\n\n");
+ if (argc>2) {
+ while (GSM_Countries[i*2]!=NULL) {
+ if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) {
+ strcpy(country,GSM_Countries[i*2]);
+ printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]);
+ break;
+ }
+ i++;
+ }
+ if (!*country) {
+ printmsg("Unknown country name.");
+ exit(-1);
+ }
+ }
+ printmsg("Network Name\n");
+ i=0;
while (GSM_Networks[i*2]!=NULL) {
+ if (argc>2) {
+ if (!strncmp(GSM_Networks[i*2],country,strlen(country))) {
printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
+ }
+ } else {
+ printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]);
+ }
i++;
}
}
static void Version(int argc, char *argv[])
{
// unsigned char buff[10];
// int len;
- printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
+ printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__);
+ if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler());
+ printmsg("]\n\n");
#ifdef DEBUG
printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage));
printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC));
printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State));
printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader));
printf("bool - %i\n",sizeof(bool));
printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime));
printf("int - %i\n",sizeof(int));
printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo));
#endif
// len=DecodeBASE64("AXw", buff, 3);
// DumpMessage(stdout, buff, len);
}
static void GetFMStation(int argc, char *argv[])
{
GSM_FMStation Station;
int start,stop;
GetStartStop(&start, &stop, 2, argc, argv);
GSM_Init(true);
for (i=start;i<=stop;i++) {
Station.Location=i;
error=Phone->GetFMStation(&s,&Station);
switch (error) {
case ERR_EMPTY:
printmsg("Entry number %i is empty\n",i);
break;
@@ -6673,93 +6841,87 @@ static void GetFileSystem(int argc, char *argv[])
printf("R");
} else {
printf(" ");
}
if (Files.Hidden) {
printf("H");
} else {
printf(" ");
}
if (Files.System) {
printf("S");
} else {
printf(" ");
}
if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) {
if (!Files.Folder) {
if (mystrncasecmp(argv[2],"-flatall",0)) {
if (!Files.ModifiedEmpty) {
printf(" %30s",OSDateTime(Files.Modified,false));
} else printf(" %30c",0x20);
printf(" %9i",Files.Used);
printf(" ");
} else printf("|-- ");
} else printf("Folder ");
} else {
if (Files.Level != 1) {
for (j=0;j<Files.Level-2;j++) printf(" | ");
printf(" |-- ");
}
if (Files.Folder) printf("Folder ");
}
printf("\"%s\"",DecodeUnicodeConsole(Files.Name));
- printf("\n");
-
- Start = false;
} else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) {
/* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS]
* format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */
if (!Files.Folder) {
printf("%s;File;",Files.ID_FullName);
printf("\"%s\";",FolderName);
printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
if (!Files.ModifiedEmpty) {
printf("\"%s\";",OSDateTime(Files.Modified,false));
} else printf("\"%c\";",0x20);
printf("%i;",Files.Used);
} else {
printf("%s;Folder;",Files.ID_FullName);
printf("\"%s\";",DecodeUnicodeConsole(Files.Name));
strcpy(FolderName,DecodeUnicodeConsole(Files.Name));
}
if (Files.Protected) printf("P");
if (Files.ReadOnly) printf("R");
if (Files.Hidden) printf("H");
if (Files.System) printf("S");
-
- printf("\n");
-
- Start = false;
}
+ Start = false;
}
error = Phone->GetFileSystemStatus(&s,&Status);
if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) {
Print_Error(error);
printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used);
}
GSM_Terminate();
}
static void GetOneFile(GSM_File *File, bool newtime, int i)
{
FILE *file;
bool start;
unsigned char buffer[5000];
struct utimbuf filedate;
if (File->Buffer != NULL) {
free(File->Buffer);
File->Buffer = NULL;
}
File->Used = 0;
start = true;
error = ERR_NONE;
while (error == ERR_NONE) {
error = Phone->GetFilePart(&s,File);
if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) {
if (start) {
printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name));
start = false;
@@ -7009,68 +7171,72 @@ static void AddFolder(int argc, char *argv[])
GSM_Init(true);
error = Phone->AddFolder(&s,&File);
Print_Error(error);
GSM_Terminate();
}
struct NokiaFolderInfo {
char *model;
char *parameter;
char *folder;
char *level;
};
static struct NokiaFolderInfo Folder[] = {
/* Language indepedent in DCT4 */
{"", "MMSUnreadInbox", "INBOX", "3"},
{"", "MMSReadInbox", "INBOX", "3"},
{"", "MMSOutbox", "OUTBOX", "3"},
{"", "MMSSent", "SENT", "3"},
{"", "MMSDrafts", "DRAFTS", "3"},
{"", "Application", "applications", "3"},
{"", "Game", "games", "3"},
/* Language depedent in DCT4 */
{"", "Gallery", "Pictures", "2"}, /* 3510 */
{"", "Gallery", "Graphics", "3"}, /* 3510i */
{"", "Gallery", "Images", "3"}, /* 6610 */
{"3510", "Gallery", "", "8"},
{"3510i","Gallery", "", "3"},
{"5100", "Gallery", "", "3"},
{"6220", "Gallery", "", "5"},
+ {"6610", "Gallery", "", "2"},
+ {"7210", "Gallery", "", "2"},
{"", "Tones", "Tones", "3"},
{"3510i","Tones", "", "4"},
{"5100", "Tones", "", "4"},
{"6220", "Tones", "", "6"},
+ {"6610", "Tones", "", "4"},
+ {"7210", "Tones", "", "4"},
/* Language indepedent in OBEX */
{"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX" },
{"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX" },
{"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX" },
{"obex", "MMSSent", "", "predefMessages\\predefSENT" },
{"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS" },
// {"obex", "Application, "", "predefjava\\predefapplications"},
// {"obex", "Game", "", "predefjava\\predefgames" },
{"obex", "Gallery", "", "predefgallery\\predefgraphics" },
{"obex", "Tones", "", "predefgallery\\predeftones" },
/* End of list */
{"", "", "", ""}
};
static void NokiaAddFile(int argc, char *argv[])
{
GSM_File File, Files;
FILE *file;
GSM_DateTime DT,DT2;
time_t t_time1,t_time2;
unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400];
bool Start = true, Found = false, wasclr;
bool ModEmpty = false;
int i = 0, Pos, Size, Size2, nextlong;
while (Folder[i].level[0] != 0) {
if (mystrncasecmp(argv[2],Folder[i].parameter,0)) {
Found = true;
break;
}
i++;
@@ -7529,414 +7695,423 @@ static void CallDivert(int argc, char *argv[])
case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break;
case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage"); break;
case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break;
default : printmsg("unknown %i",cd.Request.DivertType); break;
}
printmsg("\n Calls type : ");
switch (cd.Request.CallType) {
case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
case GSM_DIVERT_DataCalls : printmsg("data"); break;
case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break;
default : printmsg("unknown %i",cd.Request.CallType); break;
}
printmsg("\nResponse:");
for (i=0;i<cd.Response.EntriesNum;i++) {
printmsg("\n Calls type : ");
switch (cd.Response.Entries[i].CallType) {
case GSM_DIVERT_VoiceCalls: printmsg("voice"); break;
case GSM_DIVERT_FaxCalls : printmsg("fax"); break;
case GSM_DIVERT_DataCalls : printmsg("data"); break;
default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break;
}
printf("\n");
printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout);
printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number));
}
printf("\n");
GSM_Terminate();
}
-
-//#if 0
static void CancelAllDiverts(int argc, char *argv[])
{
GSM_Init(true);
error = Phone->CancelAllDiverts(&s);
Print_Error(error);
GSM_Terminate();
}
+typedef struct {
+ unsigned char Connection[50];
+} OneConnectionInfo;
+
+typedef struct {
+ unsigned char Device[50];
+ OneConnectionInfo Connections[4];
+} OneDeviceInfo;
+int num;
+bool SearchOutput;
void SearchPhoneThread(OneDeviceInfo *Info)
{
+ //LR
+#if 0
int j;
GSM_Error error;
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
- fprintf(stderr,"*********************************** \n");
-#if 0
+ GSM_StateMachine ss;
+
j = 0;
while(strlen(Info->Connections[j].Connection) != 0) {
- memcpy(&Info->s.di,&s.di,sizeof(Debug_Info));
- Info->s.msg = s.msg;
- Info->s.ConfigNum = 1;
- Info->s.opened = false;
- Info->s.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
- Info->s.Config[0].Localize = s.Config[0].Localize;
- Info->s.Config[0].Device = Info->Device;
- Info->s.Config[0].Connection = Info->Connections[j].Connection;
- Info->s.Config[0].SyncTime = "no";
- Info->s.Config[0].DebugFile = s.Config[0].DebugFile;
- Info->s.Config[0].Model[0] = 0;
- strcpy(Info->s.Config[0].DebugLevel,s.Config[0].DebugLevel);
- Info->s.Config[0].LockDevice = "no";
- Info->s.Config[0].StartInfo = "no";
-
- error = GSM_InitConnection(&Info->s,1);
+ memcpy(&ss.di,&s.di,sizeof(Debug_Info));
+ ss.msg = s.msg;
+ ss.ConfigNum = 1;
+ ss.opened = false;
+ ss.Config[0].UseGlobalDebugFile = s.Config[0].UseGlobalDebugFile;
+ ss.Config[0].Localize = s.Config[0].Localize;
+ ss.Config[0].Device = Info->Device;
+ ss.Config[0].Connection = Info->Connections[j].Connection;
+ ss.Config[0].SyncTime = "no";
+ ss.Config[0].DebugFile = s.Config[0].DebugFile;
+ ss.Config[0].Model[0] = 0;
+ strcpy(ss.Config[0].DebugLevel,s.Config[0].DebugLevel);
+ ss.Config[0].LockDevice = "no";
+ ss.Config[0].StartInfo = "no";
+
+ error = GSM_InitConnection(&ss,1);
if (SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
if (error == ERR_NONE) {
- error=Info->s.Phone.Functions->GetManufacturer(&Info->s);
+ error=ss.Phone.Functions->GetManufacturer(&ss);
if (error == ERR_NONE) {
- error=Info->s.Phone.Functions->GetModel(&Info->s);
+ error=ss.Phone.Functions->GetModel(&ss);
if (error == ERR_NONE) {
if (!SearchOutput) printf("Connection \"%s\" on device \"%s\"\n",Info->Connections[j].Connection,Info->Device);
printmsg(" Manufacturer : %s\n",
- Info->s.Phone.Data.Manufacturer);
+ ss.Phone.Data.Manufacturer);
printmsg(" Model : %s (%s)\n",
- Info->s.Phone.Data.ModelInfo->model,
- Info->s.Phone.Data.Model);
+ ss.Phone.Data.ModelInfo->model,
+ ss.Phone.Data.Model);
} else {
- if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
}
} else {
- if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
}
} else {
- if (SearchOutput) printf(" %s\n",print_error(error,Info->s.di.df,Info->s.msg));
+ if (SearchOutput) printf(" %s\n",print_error(error,ss.di.df,ss.msg));
}
if (error != ERR_DEVICEOPENERROR) {
- GSM_TerminateConnection(&Info->s);
+ GSM_TerminateConnection(&ss);
dbgprintf("Closing done\n");
}
- if (error == ERR_DEVICEOPENERROR || error == ERR_NONE) break;
+ if (error == ERR_DEVICEOPENERROR) break;
j++;
}
num--;
#endif
}
-//#undef HAVE_PTHREAD
-//#if 0
#if defined(WIN32) || defined(HAVE_PTHREAD)
#ifdef HAVE_PTHREAD
pthread_t Thread[100];
#endif
+OneDeviceInfo SearchDevices[60];
+
void MakeSearchThread(int i)
{
num++;
#ifdef HAVE_PTHREAD
if (pthread_create(&Thread[i],NULL,(void *)SearchPhoneThread,&SearchDevices[i])!=0) {
dbgprintf("Error creating thread\n");
}
#else
if (CreateThread((LPSECURITY_ATTRIBUTES)NULL,0,
(LPTHREAD_START_ROUTINE)SearchPhoneThread,&SearchDevices[i],
0,NULL)==NULL) {
dbgprintf("Error creating thread\n");
}
#endif
}
static void SearchPhone(int argc, char *argv[])
{
int i,dev = 0, dev2 = 0;
SearchOutput = false;
if (argc == 3 && mystrncasecmp(argv[2], "-debug",0)) SearchOutput = true;
num = 0;
#ifdef WIN32
# ifdef GSM_ENABLE_IRDADEVICE
sprintf(SearchDevices[dev].Device,"");
sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
- SearchDevices[dev].Connections[1].Connection[0] = 0;
+ sprintf(SearchDevices[dev].Connections[1].Connection,"irdaat");
+ SearchDevices[dev].Connections[2].Connection[0] = 0;
dev++;
# endif
# ifdef GSM_ENABLE_SERIALDEVICE
dev2 = dev;
- for(i=0;i<10;i++) {
+ for(i=0;i<20;i++) {
sprintf(SearchDevices[dev2].Device,"com%i:",i+1);
sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
SearchDevices[dev2].Connections[4].Connection[0] = 0;
dev2++;
}
# endif
#endif
#ifdef __linux__
# ifdef GSM_ENABLE_IRDADEVICE
for(i=0;i<6;i++) {
sprintf(SearchDevices[dev].Device,"/dev/ircomm%i",i);
sprintf(SearchDevices[dev].Connections[0].Connection,"irdaphonet");
sprintf(SearchDevices[dev].Connections[1].Connection,"at19200");
SearchDevices[dev].Connections[2].Connection[0] = 0;
dev++;
}
# endif
# ifdef GSM_ENABLE_SERIALDEVICE
dev2 = dev;
for(i=0;i<10;i++) {
sprintf(SearchDevices[dev2].Device,"/dev/ttyS%i",i);
sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
SearchDevices[dev2].Connections[4].Connection[0] = 0;
dev2++;
}
for(i=0;i<8;i++) {
sprintf(SearchDevices[dev2].Device,"/dev/ttyD00%i",i);
sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
SearchDevices[dev2].Connections[4].Connection[0] = 0;
dev2++;
}
for(i=0;i<4;i++) {
sprintf(SearchDevices[dev2].Device,"/dev/usb/tts/%i",i);
sprintf(SearchDevices[dev2].Connections[0].Connection,"fbusdlr3");
sprintf(SearchDevices[dev2].Connections[1].Connection,"fbus");
sprintf(SearchDevices[dev2].Connections[2].Connection,"at19200");
sprintf(SearchDevices[dev2].Connections[3].Connection,"mbus");
SearchDevices[dev2].Connections[4].Connection[0] = 0;
dev2++;
}
# endif
#endif
for(i=0;i<dev;i++) MakeSearchThread(i);
while (num != 0) my_sleep(5);
for(i=dev;i<dev2;i++) MakeSearchThread(i);
while (num != 0) my_sleep(5);
}
#endif /*Support for threads */
-// #if 0
+
static void NokiaGetADC(int argc, char *argv[])
{
GSM_Init(true);
#ifdef GSM_ENABLE_NOKIA_DCT3
DCT3GetADC(argc,argv);
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
DCT4GetADC(argc, argv);
#endif
GSM_Terminate();
}
static void NokiaDisplayTest(int argc, char *argv[])
{
GSM_Init(true);
#ifdef GSM_ENABLE_NOKIA_DCT3
DCT3DisplayTest(argc,argv);
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
DCT4DisplayTest(argc, argv);
#endif
GSM_Terminate();
}
static void NokiaGetT9(int argc, char *argv[])
{
GSM_Init(true);
#ifdef GSM_ENABLE_NOKIA_DCT3
DCT3GetT9(argc,argv);
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
DCT4GetT9(argc, argv);
#endif
GSM_Terminate();
}
static void NokiaVibraTest(int argc, char *argv[])
{
GSM_Init(true);
#ifdef GSM_ENABLE_NOKIA_DCT3
DCT3VibraTest(argc,argv);
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
DCT4VibraTest(argc, argv);
#endif
GSM_Terminate();
}
static GSM_Parameters Parameters[] = {
{"--identify", 0, 0, Identify, {H_Info,0}, ""},
{"--version", 0, 0, Version, {H_Other,0}, ""},
{"--getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
{"--monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0}, "[times]"},
{"--setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
- {"--listnetworks", 0, 0, ListNetworks, {H_Network,0}, ""},
+ {"--listnetworks", 0, 1, ListNetworks, {H_Network,0}, "[country]"},
{"--getgprspoint", 1, 2, GetGPRSPoint, {H_Nokia,H_Network,0}, "start [stop]"},
{"--addfolder", 2, 2, AddFolder, {H_Filesystem,0}, "parentfolderID name"},
{"--getfilesystem", 0, 1, GetFileSystem, {H_Filesystem,0}, "[-flatall|-flat]"},
{"--getfilesystemstatus", 0, 0, GetFileSystemStatus, {H_Filesystem,0}, ""},
{"--getfiles", 1,40, GetFiles, {H_Filesystem,0}, "ID1, ID2, ..."},
{"--getfilefolder", 1,40, GetFileFolder, {H_Filesystem,0}, "ID1, ID2, ..."},
{"--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]"},
{"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "MMSUnreadInbox|MMSReadInbox|MMSOutbox|MMSDrafts|MMSSent file sender title"},
{"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "Application|Game file [-readonly]"},
{"--nokiaaddfile", 2, 5, NokiaAddFile, {H_Filesystem,H_Nokia,0}, "Gallery|Tones file [-name name][-protected][-readonly][-system][-hidden][-newtime]"},
{"--deletefiles", 1,20, DeleteFiles, {H_Filesystem,0}, "fileID"},
{"--playringtone", 1, 1, PlayRingtone, {H_Ringtone,0}, "file"},
{"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, ""},
{"--getdatetime", 0, 0, GetDateTime, {H_DateTime,0}, ""},
{"--setdatetime", 0, 0, SetDateTime, {H_DateTime,0}, ""},
{"--getalarm", 0, 0, GetAlarm, {H_DateTime,0}, ""},
{"--setalarm", 2, 2, SetAlarm, {H_DateTime,0}, "hour minute"},
{"--resetphonesettings", 1, 1, ResetPhoneSettings, {H_Settings,0}, "PHONE|DEV|UIF|ALL|FACTORY"},
- {"--getmemory", 2, 3, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop]"},
- {"--getallmemory", 1, 1, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
+ {"--getmemory", 2, 4, GetMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD start [stop [-nonempty]]"},
+ {"--getallmemory", 1, 2, GetAllMemory, {H_Memory,0}, "DC|MC|RC|ON|VM|SM|ME|FD"},
{"--searchmemory", 1, 1, SearchMemory, {H_Memory,0}, "text"},
{"--listmemorycategory", 1, 1, ListMemoryCategory, {H_Memory, H_Category,0}, "text|number"},
{"--getfmstation", 1, 2, GetFMStation, {H_FM,0}, "start [stop]"},
{"--getsmsc", 1, 2, GetSMSC, {H_SMS,0}, "start [stop]"},
{"--getsms", 2, 3, GetSMS, {H_SMS,0}, "folder start [stop]"},
{"--deletesms", 2, 3, DeleteSMS, {H_SMS,0}, "folder start [stop]"},
{"--deleteallsms", 1, 1, DeleteAllSMS, {H_SMS,0}, "folder"},
{"--getsmsfolders", 0, 0, GetSMSFolders, {H_SMS,0}, ""},
{"--getallsms", 0, 0, GetAllSMS, {H_SMS,0}, ""},
{"--geteachsms", 0, 0, GetEachSMS, {H_SMS,0}, ""},
#define SMS_TEXT_OPTIONS "[-inputunicode][-16bit][-flash][-len len][-autolen len][-unicode][-enablevoice][-disablevoice][-enablefax][-disablefax][-enableemail][-disableemail][-voidsms][-replacemessages ID][-replacefile file]"
#define SMS_PICTURE_OPTIONS "[-text text][-unicode][-alcatelbmmi]"
#define SMS_PROFILE_OPTIONS "[-name name][-bitmap bitmap][-ringtone ringtone]"
#define SMS_EMS_OPTIONS "[-unicode][-16bit][-format lcrasbiut][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-fixedbitmap file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...][-protected number]"
#define SMS_SMSTEMPLATE_OPTIONS "[-unicode][-text text][-unicodefiletext file][-defsound ID][-defanimation ID][-tone10 file][-tone10long file][-tone12 file][-tone12long file][-toneSE file][-toneSElong file][-variablebitmap file][-variablebitmaplong file][-animation frames file1 ...]"
#define SMS_ANIMATION_OPTIONS ""
#define SMS_OPERATOR_OPTIONS "[-netcode netcode][-biglogo]"
#define SMS_SAVE_OPTIONS "[-folder id][-unread][-read][-unsent][-sent][-sender number]"
#define SMS_SEND_OPTIONS "[-report][-validity HOUR|6HOURS|DAY|3DAYS|WEEK|MAX][-save [-folder number]]"
#define SMS_COMMON_OPTIONS "[-smscset number][-smscnumber number][-reply][-maxsms num]"
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE file " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION frames file1 file2... " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR URL Title Sender " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
+ {"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR URL Title " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
#ifdef GSM_ENABLE_BACKUP
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS file location DATA|GPRS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO file location " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 file SM|ME location [-nokia]" SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS},
#endif
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_PROFILE_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
{"--savesms", 1,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE " SMS_SAVE_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "TEXT destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_TEXT_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Ringtone,0}, "RINGTONE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "OPERATOR destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_OPERATOR_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "CALLER destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "PICTURE destination file " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_PICTURE_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Logo,0}, "ANIMATION destination frames file1 file2... " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_ANIMATION_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSINDICATOR destination URL Title Sender " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
+ {"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPINDICATOR destination URL Title " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
#ifdef GSM_ENABLE_BACKUP
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "BOOKMARK destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_WAP,0}, "WAPSETTINGS destination file location DATA|GPRS " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_MMS,0}, "MMSSETTINGS destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Calendar,0}, "CALENDAR destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_ToDo,0}, "TODO destination file location " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Memory,0}, "VCARD10|VCARD21 destination file SM|ME location [-nokia]" SMS_SEND_OPTIONS SMS_COMMON_OPTIONS},
#endif
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Settings,0}, "PROFILE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS ""SMS_PROFILE_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "EMS destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_EMS_OPTIONS},
{"--sendsms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "SMSTEMPLATE destination " SMS_SEND_OPTIONS SMS_COMMON_OPTIONS SMS_SMSTEMPLATE_OPTIONS},
{"--displaysms", 2,30, SendSaveDisplaySMS, {H_SMS,0}, "... (options like in sendsms)"},
{"--addsmsfolder", 1, 1, AddSMSFolder, {H_SMS,0}, "name"},
#ifdef HAVE_MYSQL_MYSQL_H
{"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "MYSQL configfile"},
#endif
{"--smsd", 2, 2, SMSDaemon, {H_SMS,H_Other,0}, "FILES configfile"},
{"--sendsmsdsms", 2,30, SendSaveDisplaySMS, {H_SMS,H_Other,0}, "TEXT|WAPSETTINGS|... destination FILES|MYSQL configfile ... (options like in sendsms)"},
{"--getringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
{"--getphoneringtone", 1, 2, GetRingtone, {H_Ringtone,0}, "location [file]"},
{"--getringtoneslist", 0, 0, GetRingtonesList, {H_Ringtone,0}, ""},
{"--setringtone", 1, 6, SetRingtone, {H_Ringtone,0}, "file [-location location][-scale][-name name]"},
{"--nokiacomposer", 1, 1, NokiaComposer, {H_Ringtone,H_Nokia,0}, "file"},
{"--copyringtone", 2, 3, CopyRingtone, {H_Ringtone,0}, "source destination [RTTL|BINARY]"},
{"--getussd", 1, 1, GetUSSD, {H_Call,0}, "code"},
{"--dialvoice", 1, 2, DialVoice, {H_Call,0}, "number [show|hide]"},
{"--getspeeddial", 1, 2, GetSpeedDial, {H_Call,H_Memory,0}, "start [stop]"},
{"--cancelcall", 0, 1, CancelCall, {H_Call,0}, "[ID]"},
{"--answercall", 0, 1, AnswerCall, {H_Call,0}, "[ID]"},
{"--unholdcall", 1, 1, UnholdCall, {H_Call,0}, "ID"},
{"--holdcall", 1, 1, HoldCall, {H_Call,0}, "ID"},
{"--conferencecall", 1, 1, ConferenceCall, {H_Call,0}, "ID"},
{"--splitcall", 1, 1, SplitCall, {H_Call,0}, "ID"},
{"--switchcall", 0, 1, SwitchCall, {H_Call,0}, "[ID]"},
{"--transfercall", 0, 1, TransferCall, {H_Call,0}, "[ID]"},
{"--divert", 3, 5, CallDivert, {H_Call,0}, "get|set all|busy|noans|outofreach all|voice|fax|data [number timeout]"},
{"--canceldiverts", 0, 0, CancelAllDiverts, {H_Call,0}, ""},
{"--senddtmf", 1, 1, SendDTMF, {H_Call,0}, "sequence"},
{"--getcalendarsettings", 0, 0, GetCalendarSettings, {H_Calendar,H_Settings,0}, ""},
{"--getalltodo", 0, 0, GetAllToDo, {H_ToDo,0}, ""},
{"--listtodocategory", 1, 1, ListToDoCategory, {H_ToDo, H_Category,0}, "text|number"},
{"--gettodo", 1, 2, GetToDo, {H_ToDo,0}, "start [stop]"},
{"--deletetodo", 1, 2, DeleteToDo, {H_ToDo,0}, "start [stop]"},
- {"--getnote", 1, 2, GetNote, {H_Note,0}, "start [stop]"},
+ {"--getallnotes", 0, 0, GetAllNotes, {H_Note,0}, ""},
{"--deletecalendar", 1, 2, DeleteCalendar, {H_Calendar,0}, "start [stop]"},
{"--getallcalendar", 0, 0, GetAllCalendar, {H_Calendar,0}, ""},
{"--getcalendar", 1, 2, GetCalendar, {H_Calendar,0}, "start [stop]"},
{"--getcategory", 2, 3, GetCategory, {H_Category,H_ToDo,H_Memory,0}, "TODO|PHONEBOOK start [stop]"},
{"--getallcategory", 1, 1, GetAllCategories, {H_Category,H_ToDo,H_Memory,0}, "TODO|PHONEBOOK"},
{"--reset", 1, 1, Reset, {H_Other,0}, "SOFT|HARD"},
{"--getprofile", 1, 2, GetProfile, {H_Settings,0}, "start [stop]"},
{"--getsecuritystatus", 0, 0, GetSecurityStatus, {H_Info,0}, ""},
{"--entersecuritycode", 2, 2, EnterSecurityCode, {H_Other,0}, "PIN|PUK|PIN2|PUK2 code"},
{"--deletewapbookmark", 1, 2, DeleteWAPBookmark, {H_WAP,0}, "start [stop]"},
{"--getwapbookmark", 1, 2, GetWAPBookmark, {H_WAP,0}, "start [stop]"},
{"--getwapsettings", 1, 2, GetWAPMMSSettings, {H_WAP,0}, "start [stop]"},
{"--getmmssettings", 1, 2, GetWAPMMSSettings, {H_MMS,0}, "start [stop]"},
{"--getsyncmlsettings", 1, 2, GetSyncMLSettings, {H_WAP,0}, "start [stop]"},
{"--getchatsettings", 1, 2, GetChatSettings, {H_WAP,0}, "start [stop]"},
{"--savemmsfile", 3, 15,SaveMMSFile, {H_MMS,0}, "file [-subject text][-text text]"},
{"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "STARTUP [file]"},
{"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "CALLER location [file]"},
{"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "OPERATOR [file]"},
{"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "PICTURE location [file]"},
{"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "TEXT"},
{"--getbitmap", 1, 3, GetBitmap, {H_Logo,0}, "DEALER"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "STARTUP file|1|2|3"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOURSTARTUP [fileID]"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "WALLPAPER fileID"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "CALLER location [file]"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "OPERATOR [file [netcode]]"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "COLOUROPERATOR [fileID [netcode]]"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "PICTURE file location [text]"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "TEXT text"},
{"--setbitmap", 1, 4, SetBitmap, {H_Logo,0}, "DEALER text"},
{"--copybitmap", 1, 3, CopyBitmap, {H_Logo,0}, "inputfile [outputfile [OPERATOR|PICTURE|STARTUP|CALLER]]"},
@@ -7947,66 +8122,68 @@ static GSM_Parameters Parameters[] = {
#ifdef GSM_ENABLE_BACKUP
{"--savefile", 4, 5, SaveFile, {H_Backup,H_Calendar,0}, "CALENDAR target.vcs file location"},
{"--savefile", 4, 5, SaveFile, {H_Backup,H_ToDo,0}, "TODO target.vcs file location"},
{"--savefile", 4, 5, SaveFile, {H_Backup,H_Memory,0}, "VCARD10|VCARD21 target.vcf file SM|ME location"},
{"--savefile", 4, 5, SaveFile, {H_Backup,H_WAP,0}, "BOOKMARK target.url file location"},
{"--backup", 1, 2, Backup, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file [-yes]"},
{"--backupsms", 1, 1, BackupSMS, {H_Backup,H_SMS,0}, "file"},
{"--restore", 1, 1, Restore, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
{"--addnew", 1, 1, AddNew, {H_Backup,H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, "file"},
{"--restoresms", 1, 1, RestoreSMS, {H_Backup,H_SMS,0}, "file"},
{"--addsms", 2, 2, AddSMS, {H_Backup,H_SMS,0}, "folder file"},
#endif
{"--clearall", 0, 0, ClearAll, {H_Memory,H_Calendar,H_ToDo,H_Category,H_Ringtone,H_WAP,H_FM,0}, ""},
{"--networkinfo", 0, 0, NetworkInfo, {H_Network,0}, ""},
#ifdef GSM_ENABLE_AT
{"--siemenssatnetmon", 0, 0, ATSIEMENSSATNetmon, {H_Siemens,H_Network,0}, ""},
{"--siemensnetmonact", 1, 1, ATSIEMENSActivateNetmon, {H_Siemens,H_Network,0}, "netmon_type (1-full, 2-simple)"},
{"--siemensnetmonitor", 1, 1, ATSIEMENSNetmonitor, {H_Siemens,H_Network,0}, "test"},
#endif
#ifdef GSM_ENABLE_NOKIA6110
{"--nokiagetoperatorname", 0, 0, DCT3GetOperatorName, {H_Nokia,H_Network,0}, ""},
{"--nokiasetoperatorname", 0, 2, DCT3SetOperatorName, {H_Nokia,H_Network,0}, "[networkcode name]"},
{"--nokiadisplayoutput", 0, 0, DCT3DisplayOutput, {H_Nokia,0}, ""},
#endif
#ifdef GSM_ENABLE_NOKIA_DCT3
{"--nokianetmonitor", 1, 1, DCT3netmonitor, {H_Nokia,H_Network,0}, "test"},
{"--nokianetmonitor36", 0, 0, DCT3ResetTest36, {H_Nokia,0}, ""},
{"--nokiadebug", 1, 2, DCT3SetDebug, {H_Nokia,H_Network,0}, "filename [[v11-22][,v33-44]...]"},
#endif
#ifdef GSM_ENABLE_NOKIA_DCT4
{"--nokiasetvibralevel", 1, 1, DCT4SetVibraLevel, {H_Nokia,H_Other,0}, "level"},
{"--nokiagetvoicerecord", 1, 1, DCT4GetVoiceRecord, {H_Nokia,H_Other,0}, "location"},
+#ifdef GSM_ENABLE_NOKIA6510
{"--nokiasetlights", 2, 2, DCT4SetLight, {H_Nokia,H_Tests,0}, "keypad|display|torch on|off"},
{"--nokiatuneradio", 0, 0, DCT4TuneRadio, {H_Nokia,H_FM,0}, ""},
+#endif
{"--nokiamakecamerashoot", 0, 0, DCT4MakeCameraShoot, {H_Nokia,H_Other,0}, ""},
{"--nokiagetscreendump", 0, 0, DCT4GetScreenDump, {H_Nokia,H_Other,0}, ""},
#endif
#if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4)
{"--nokiavibratest", 0, 0, NokiaVibraTest, {H_Nokia,H_Tests,0}, ""},
{"--nokiagett9", 0, 0, NokiaGetT9, {H_Nokia,H_SMS,0}, ""},
{"--nokiadisplaytest", 1, 1, NokiaDisplayTest, {H_Nokia,H_Tests,0}, "number"},
{"--nokiagetadc", 0, 0, NokiaGetADC, {H_Nokia,H_Tests,0}, ""},
{"--nokiasecuritycode", 0, 0, NokiaSecurityCode, {H_Nokia,H_Info,0}, ""},
{"--nokiaselftests", 0, 0, NokiaSelfTests, {H_Nokia,H_Tests,0}, ""},
{"--nokiasetphonemenus", 0, 0, NokiaSetPhoneMenus, {H_Nokia,H_Other,0}, ""},
#endif
#ifdef DEBUG
{"--decodesniff", 2, 3, decodesniff, {H_Decode,0}, "MBUS2|IRDA file [phonemodel]"},
{"--decodebinarydump", 1, 2, decodebinarydump, {H_Decode,0}, "file [phonemodel]"},
{"--makeconverttable", 1, 1, MakeConvertTable, {H_Decode,0}, "file"},
#endif
{"", 0, 0, NULL }
};
static HelpCategoryDescriptions HelpDescriptions[] = {
{H_Call, "call", "Calls",},
{H_SMS, "sms", "SMS and EMS"},
{H_Memory, "memory", "Memory (phonebooks and calls)"},
{H_Filesystem, "filesystem", "Filesystem"},
{H_Logo, "logo", "Logo and pictures"},
{H_Ringtone, "ringtone", "Ringtones"},
{H_Calendar, "calendar", "Calendar notes"},
{H_ToDo, "todo", "To do lists"},
{H_Note, "note", "Notes"},
{H_DateTime, "datetime", "Date, time and alarms"},
{H_Category, "category", "Categories"},
@@ -8017,69 +8194,69 @@ static HelpCategoryDescriptions HelpDescriptions[] = {
{H_Nokia, "nokia", "Nokia specific"},
#endif
#ifdef GSM_ENABLE_AT
{H_Siemens, "siemens", "Siemens specific"},
#endif
{H_Network, "network", "Network"},
{H_WAP, "wap", "WAP settings and bookmarks"},
{H_MMS, "mms", "MMS and MMS settings"},
{H_Tests, "tests", "Phone tests"},
{H_FM, "fm", "FM radio"},
{H_Info, "info", "Phone information"},
{H_Settings, "settings", "Phone settings"},
#ifdef DEBUG
{H_Decode, "decode", "Dumps decoding"},
#endif
{H_Other, "other", "Functions that don't fit elsewhere"},
{0, NULL, NULL}
};
void HelpHeader(void)
{
printmsg("[Gammu version %s built %s %s]\n\n",VERSION,__TIME__,__DATE__);
}
static void HelpGeneral(void)
{
int i=0;
HelpHeader();
printmsg("Usage: gammu [confign] [nothing|text|textall|binary|errors] [options]\n\n");
- printmsg("First parameter optionally specifies which config section to use (by default are probed all).\n");
- printmsg("Second parameter optionally controls debug level, next specify actions.\n\n");
+ printmsg("First parameter optionally specifies which config section to use (all are probed by default).\n");
+ printmsg("Second parameter optionally controls debug level, next one specifies actions.\n\n");
/* We might want to put here some most used commands */
- printmsg("For more details call help on specific topic (gammu --help topic), topics are:\n\n");
+ printmsg("For more details, call help on specific topic (gammu --help topic). Topics are:\n\n");
while (HelpDescriptions[i].category != 0) {
printf("%11s - %s\n", HelpDescriptions[i].option, HelpDescriptions[i].description);
i++;
}
printf("\n");
}
static void HelpSplit(int cols, int len, unsigned char *buff)
{
int l, len2, pos, split;
bool in_opt,first=true;
char *remain, spaces[50], buffer[500];
if (cols == 0) {
printf(" %s\n", buff);
} else {
printf(" ");
spaces[0] = 0;
len2 = strlen(buff);
if (len + len2 < cols) {
printf("%s\n", buff);
} else {
for(l = 0; l < len; l++) strcat(spaces, " ");
remain = buff;
while (strlen(remain) > 0) {
split = 0;
pos = 0;
in_opt = false;
if (!first) printf(spaces);
@@ -8105,65 +8282,65 @@ static void HelpSplit(int cols, int len, unsigned char *buff)
buffer[split] = 0;
printf("%s\n", buffer);
remain += split;
if (remain[0] == ' ') remain++;
}
}
}
}
}
static void Help(int argc, char *argv[])
{
int i = 0, j = 0, k, cols;
bool disp;
#ifdef TIOCGWINSZ
struct winsize w;
#endif
#if defined(WIN32) || defined(DJGPP)
#else
char *columns;
#endif
/* Just --help */
if (argc == 2) {
HelpGeneral();
return;
}
if (!strcmp(argv[2],"all")) {
HelpHeader();
} else {
while (HelpDescriptions[i].category != 0) {
- if (strcmp(argv[2], HelpDescriptions[i].option) == 0) break;
+ if (mystrncasecmp(argv[2], HelpDescriptions[i].option,strlen(argv[2]))) break;
i++;
}
if (HelpDescriptions[i].category == 0) {
HelpGeneral();
printmsg("Unknown help topic specified!\n");
return;
}
HelpHeader();
printmsg("Gammu parameters, topic: %s\n\n", HelpDescriptions[i].description);
}
#if defined(WIN32) || defined(DJGPP)
cols = 80;
#else
cols = 0;
/* If stdout is a tty, we will wrap to columns it has */
if (isatty(1)) {
#ifdef TIOCGWINSZ
if (ioctl(2, TIOCGWINSZ, &w) == 0) {
if (w.ws_col > 0) cols = w.ws_col;
}
#endif
if (cols == 0) {
columns = getenv("COLUMNS");
if (columns != NULL) {
cols = atoi(columns);
if (cols <= 0) cols = 0;
}
}
if (cols == 0) {
/* Fallback */
@@ -8177,256 +8354,181 @@ static void Help(int argc, char *argv[])
disp = false;
if (!strcmp(argv[2],"all")) {
if (j==0) disp = true;
if (j!=0) {
if (strcmp(Parameters[j].help,Parameters[j-1].help)) {
disp = true;
} else {
if (strcmp(Parameters[j].parameter,Parameters[j-1].parameter)) {
disp = true;
}
}
}
} else {
while (Parameters[j].help_cat[k] != 0) {
if (Parameters[j].help_cat[k] == HelpDescriptions[i].category) {
disp = true;
break;
}
k++;
}
}
if (disp) {
printf("%s", Parameters[j].parameter);
if (Parameters[j].help[0] == 0) {
printf("\n");
} else {
HelpSplit(cols - 1, strlen(Parameters[j].parameter) + 1, Parameters[j].help);
}
}
j++;
}
}
-#if 0
-#endif // 0
+
int main(int argc, char *argv[])
{
-
- //fprintf(stderr,"HIIIIIIIIIIIII \n");
- //#if 0
- static int z ,start,i;
- static int only_config ;
-#if !defined(WIN32) && defined(LOCALE_PATH)
- static char *locale, locale_file[201];
+ int z = 0,start=0,i;
+ int only_config = -1;
+#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
+ char *locale, locale_file[201];
#endif
- static char *cp;
- static bool count_failed;
- z = 0;
- start=0;only_config = -1;count_failed = false;
+ char *cp;
+ bool count_failed = false;
+
s.opened = false;
s.msg = NULL;
s.ConfigNum = 0;
setlocale(LC_ALL, "");
#ifdef DEBUG
di.dl = DL_TEXTALL;
di.df = stdout;
#endif
- //#if 0
+
/* Any parameters? */
if (argc == 1) {
HelpGeneral();
printmsg("Too few parameters!\n");
exit(1);
}
/* Help? */
if (strncmp(argv[1 + start], "--help", 6) == 0) {
Help(argc - start, argv + start);
exit(1);
}
/* Is first parameter numeric? If so treat it as config that should be loaded. */
- //if (isdigit(argv[1][0])) {
- //only_config = atoi(argv[1]);
- //if (only_config >= 0) start++; else only_config = -1;
- //}
- only_config = 0;;
-#if 0
- GSM_ReadConfig(NULL, &s.Config[0], 0);
- s.ConfigNum = 1;
- GSM_Config *con = &s.Config[0];
-
- char* tempC;
- tempC = argv[argc-1]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using model %s \n",tempC);
- strcpy(con->Model,tempC );
- }
- tempC = argv[argc-2]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using device %s \n",tempC);
- con->Device = strdup(tempC);
- con->DefaultDevice = false;
- }
- tempC = argv[argc-3]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using connection %s \n",tempC);
- con->Connection = strdup(tempC);
- con->DefaultConnection = false;
- }
- argc = argc-3;
- //#if 0
- if ( ! mConnection.isEmpty() ) {
- cfg->Connection = strdup(mConnection.latin1());
- cfg->DefaultConnection = false;
- qDebug("Connection set %s ", cfg->Connection );
-
+ if (isdigit(argv[1][0])) {
+ only_config = atoi(argv[1]);
+ if (only_config >= 0) start++; else only_config = -1;
}
- if ( ! mDevice.isEmpty() ) {
- cfg->Device = strdup(mDevice.latin1());
- cfg->DefaultDevice = false;
- qDebug("Device set %s ", cfg->Device);
-
- }
- if ( ! mModel.isEmpty() ) {
- strcpy(cfg->Model,mModel.latin1() );
- cfg->DefaultModel = false;
- qDebug("Model set %s ",cfg->Model );
- }
-
-#endif
-
cfg=GSM_FindGammuRC();
+ if (cfg == NULL) printmsg("Warning: No configuration file found!\n");
+
for (i = 0; i <= MAX_CONFIG_NUM; i++) {
if (cfg!=NULL) {
cp = INI_GetValue(cfg, "gammu", "gammucoding", false);
if (cp) di.coding = cp;
s.Config[i].Localize = INI_GetValue(cfg, "gammu", "gammuloc", false);
if (s.Config[i].Localize) {
s.msg=INI_ReadFile(s.Config[i].Localize, true);
} else {
-#if !defined(WIN32) && defined(LOCALE_PATH)
+#if !defined(WIN32) && !defined(DJGPP) && defined(LOCALE_PATH)
locale = setlocale(LC_MESSAGES, NULL);
if (locale != NULL) {
snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
LOCALE_PATH,
tolower(locale[0]),
tolower(locale[1]));
s.msg = INI_ReadFile(locale_file, true);
}
#endif
}
}
/* Wanted user specific configuration? */
-
if (only_config != -1) {
/* Here we get only in first for loop */
if (!GSM_ReadConfig(cfg, &s.Config[0], only_config)) break;
} else {
if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
}
s.ConfigNum++;
/* We want to use only one file descriptor for global and state machine debug output */
s.Config[i].UseGlobalDebugFile = true;
/* It makes no sense to open several debug logs... */
if (i != 0) {
strcpy(s.Config[i].DebugLevel, s.Config[0].DebugLevel);
free(s.Config[i].DebugFile);
s.Config[i].DebugFile = strdup(s.Config[0].DebugFile);
} else {
/* Just for first config */
/* When user gave debug level on command line */
if (argc > 1 + start && GSM_SetDebugLevel(argv[1 + start], &di)) {
/* Debug level from command line will be used with phone too */
strcpy(s.Config[i].DebugLevel,argv[1 + start]);
start++;
} else {
/* Try to set debug level from config file */
GSM_SetDebugLevel(s.Config[i].DebugLevel, &di);
}
/* If user gave debug file in gammurc, we will use it */
error=GSM_SetDebugFile(s.Config[i].DebugFile, &di);
Print_Error(error);
}
/* We wanted to read just user specified configuration. */
if (only_config != -1) {break;}
}
-#if 0
- GSM_Config *con = &s.Config[0];
-
- char* tempC;
- tempC = argv[argc-1]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using model %s \n",tempC);
- strcpy(con->Model,tempC );
- }
- tempC = argv[argc-2]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using device %s \n",tempC);
- con->Device = strdup(tempC);
- con->DefaultDevice = false;
- }
- tempC = argv[argc-3]+2;
- if ( *tempC != 0 ) {
- fprintf(stderr,"Using connection %s \n",tempC);
- con->Connection = strdup(tempC);
- con->DefaultConnection = false;
- }
-#endif
-
/* Do we have enough parameters? */
if (argc == 1 + start) {
HelpGeneral();
printmsg("Too few parameters!\n");
exit(-2);
}
/* Check used version vs. compiled */
if (!mystrncasecmp(GetGammuVersion(),VERSION,0)) {
printmsg("ERROR: version of installed libGammu.so (%s) is different to version of Gammu (%s)\n",
GetGammuVersion(),VERSION);
exit(-1);
}
/* Check parameters */
while (Parameters[z].Function != NULL) {
if (mystrncasecmp(Parameters[z].parameter,argv[1+start], 0)) {
if (argc-2-start >= Parameters[z].min_arg && argc-2-start <= Parameters[z].max_arg) {
- fprintf(stderr,"Executing \n");
Parameters[z].Function(argc - start, argv + start);
break;
} else {
count_failed = true;
}
}
z++;
}
/* Tell user when we did nothing */
if (Parameters[z].Function == NULL) {
HelpGeneral();
if (count_failed) {
printmsg("Bad parameter count!\n");
} else {
printmsg("Bad option!\n");
}
}
/* Close debug output if opened */
if (di.df!=stdout) fclose(di.df);
- //#endif // 0
- fprintf(stderr,"kammu: Success. End. \n");
+
exit(0);
}
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -28,47 +28,47 @@ typedef enum {
#endif
H_Network,
H_WAP,
H_MMS,
H_FM,
H_Info,
H_Settings,
#ifdef DEBUG
H_Decode,
#endif
H_Other
} HelpCategory;
typedef struct {
HelpCategory category;
char *option;
char *description;
} HelpCategoryDescriptions;
typedef struct {
char *parameter;
int min_arg;
int max_arg;
void (*Function) (int argc, char *argv[]);
HelpCategory help_cat[10];
char *help;
} GSM_Parameters;
void Print_Error (GSM_Error error);
void GSM_Init (bool checkerror);
void GSM_Terminate (void);
-static GSM_StateMachine s;
-static GSM_Phone_Functions *Phone;
-static GSM_Error error;
+extern GSM_StateMachine s;
+extern GSM_Phone_Functions *Phone;
+extern GSM_Error error;
-static bool gshutdown;
+extern volatile bool gshutdown;
void interrupt(int sign);
#ifdef GSM_ENABLE_BEEP
void GSM_PhoneBeep (void);
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,33 +1,33 @@
-/* (c) 2002-2003 by Joergen Thomsen */
+/* (c) 2002-2004 by Joergen Thomsen */
#include "../../cfg/config.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <time.h>
#ifdef WIN32
# include <io.h>
#endif
#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR && defined HAVE_ALPHASORT
# include <dirent.h>
#endif
#include "../../common/misc/coding/coding.h"
#include "../../common/service/backup/gsmback.h"
#include "smsdcore.h"
/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */
static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config)
{
GSM_Error error = ERR_NONE;
int i,j;
unsigned char FileName[100], FullName[400], ext[4], buffer[64],buffer2[400];
bool done;
FILE *file;
#ifdef GSM_ENABLE_BACKUP
GSM_SMS_Backup backup;
#endif
j = 0;
done = false;
@@ -77,237 +77,284 @@ static GSM_Error SMSDFiles_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig
case SMS_Coding_Unicode:
case SMS_Coding_Default:
DecodeUnicode(sms.SMS[i].Text,buffer2);
if (mystrncasecmp(Config->inboxformat, "unicode", 0)) {
buffer[0] = 0xFE;
buffer[1] = 0xFF;
fwrite(buffer,1,2,file);
fwrite(sms.SMS[i].Text,1,strlen(buffer2)*2,file);
} else {
fwrite(buffer2,1,strlen(buffer2),file);
}
break;
case SMS_Coding_8bit:
fwrite(sms.SMS[i].Text,1,sms.SMS[i].Length,file);
}
fclose(file);
} else error = ERR_CANTOPENFILE;
}
if (error == ERR_NONE) {
WriteSMSDLog("%s %s", (sms.SMS[i].PDU == SMS_Status_Report?"Delivery report":"Received"), FileName);
} else {
WriteSMSDLog("Cannot save %s (%i)", FileName, errno);
return ERR_CANTOPENFILE;
}
}
}
return ERR_NONE;
}
/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
* There is also set ID for SMS
+ * File extension convention:
+ * OUTxxxxx.txt : normal text SMS
+ * Options appended to the extension applying to this SMS only:
+ * d: delivery report requested
+ * f: flash SMS
+ * b: WAP bookmark as name,URL
+ * e.g. OUTG20040620_193810_123_+4512345678_xpq.txtdf
+ * is a flash text SMS requesting delivery reports
*/
static GSM_Error SMSDFiles_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
{
GSM_Error error = ERR_NOTSUPPORTED;
GSM_MultiPartSMSInfo SMSInfo;
+ GSM_WAPBookmark Bookmark;
unsigned char FileName[100],FullName[400];
unsigned char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
unsigned char Buffer2[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2];
FILE *File;
int i, len, phlen;
- char *pos1, *pos2;
+ char *pos1, *pos2, *options;
#if defined HAVE_DIRENT_H && defined HAVE_SCANDIR & defined HAVE_ALPHASORT
struct dirent **namelist = NULL;
int l, m ,n;
strcpy(FullName, Config->outboxpath);
FullName[strlen(Config->outboxpath)-1] = '\0';
n = scandir(FullName, &namelist, 0, alphasort);
m = 0;
- while ((m < n) && ((*(namelist[m]->d_name) == '.') ||
- !mystrncasecmp(namelist[m]->d_name,"out", 3) ||
+ while ((m < n) && ((*(namelist[m]->d_name) == '.') || // directory and UNIX hidden file
+ !mystrncasecmp(namelist[m]->d_name,"out", 3) || // must start with 'out'
((strlen(namelist[m]->d_name) >= 4) &&
- !mystrncasecmp(&namelist[m]->d_name[strlen(namelist[m]->d_name)-4],".txt",4)
+ !mystrncasecmp(strrchr(namelist[m]->d_name, '.'),".txt",4)
)
)
) m++;
if (m < n) strcpy(FileName,namelist[m]->d_name);
for (l=0; l < n; l++) free(namelist[l]);
free(namelist);
namelist = NULL;
if (m >= n) return ERR_EMPTY;
error = ERR_NONE;
#else
#ifdef WIN32
struct _finddata_t c_file;
long hFile;
strcpy(FullName, Config->outboxpath);
- strcat(FullName, "OUT*.txt");
+ strcat(FullName, "OUT*.txt*");
if((hFile = _findfirst( FullName, &c_file )) == -1L ) {
return ERR_EMPTY;
} else {
strcpy(FileName,c_file.name);
}
_findclose( hFile );
error = ERR_NONE;
#endif
#endif
if (error != ERR_NONE) return error;
-
+ options = strrchr(FileName, '.') + 4;
strcpy(FullName, Config->outboxpath);
strcat(FullName, FileName);
File = fopen(FullName, "rb");
len = fread(Buffer, 1, sizeof(Buffer)-2, File);
fclose(File);
- if (len<2) return ERR_EMPTY;
- if ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) &&
- (Buffer[0] != 0xFE || Buffer[1] != 0xFF)) {
+ if ((len < 2) ||
+ (len >= 2 && ((Buffer[0] != 0xFF || Buffer[1] != 0xFE) &&
+ (Buffer[0] != 0xFE || Buffer[1] != 0xFF)))) {
if (len > GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS) len = GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS;
EncodeUnicode(Buffer2, Buffer, len);
len = len*2;
memmove(Buffer, Buffer2, len);
}
Buffer[len] = 0;
Buffer[len+1] = 0;
ReadUnicodeFile(Buffer2,Buffer);
+ GSM_ClearMultiPartSMSInfo(&SMSInfo);
+ sms->Number = 0;
+
SMSInfo.ReplaceMessage = 0;
SMSInfo.Entries[0].Buffer = Buffer2;
SMSInfo.Class = -1;
SMSInfo.EntriesNum = 1;
+ Config->currdeliveryreport = -1;
+ if (strchr(options, 'd')) Config->currdeliveryreport = 1;
+ if (strchr(options, 'f')) SMSInfo.Class = 0; /* flash SMS */
+
if (mystrncasecmp(Config->transmitformat, "unicode", 0)) {
SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
SMSInfo.UnicodeCoding = true;
} else if (mystrncasecmp(Config->transmitformat, "7bit", 0)) {
SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong;
SMSInfo.UnicodeCoding = false;
} else {
/* auto */
SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong;
}
+
+ if (strchr(options, 'b')) { // WAP bookmark as title,URL
+ SMSInfo.Entries[0].Buffer = NULL;
+ SMSInfo.Entries[0].Bookmark = &Bookmark;
+ SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong;
+ SMSInfo.Entries[0].Bookmark->Location = 0;
+ pos2 = mywstrstr(Buffer2, "\0,");
+ if (pos2 == NULL) {
+ pos2 = Buffer2;
+ } else {
+ *pos2 = '\0'; pos2++; *pos2 = '\0'; pos2++; // replace comma by zero
+ }
+
+ len = UnicodeLength(Buffer2);
+ if (len > 50) len = 50;
+ memmove(&SMSInfo.Entries[0].Bookmark->Title, Buffer2, len * 2);
+ pos1 = &SMSInfo.Entries[0].Bookmark->Title[0] + len * 2;
+ *pos1 = '\0'; pos1++; *pos1 = '\0';
+
+ len = UnicodeLength(pos2);
+ if (len > 255) len = 255;
+ memmove(&SMSInfo.Entries[0].Bookmark->Address, pos2, len * 2);
+ pos1 = &SMSInfo.Entries[0].Bookmark->Address[0] + len * 2;
+ *pos1 = '\0'; pos1++; *pos1 = '\0';
+ }
+
GSM_EncodeMultiPartSMS(&SMSInfo,sms);
pos1 = FileName;
strcpy(ID,FileName);
for (i = 1; i <= 3 && pos1 != NULL ; i++) pos1 = strchr(++pos1, '_');
if (pos1 != NULL) {
/* OUT<priority><date>_<time>_<serialno>_<phone number>_<anything>.txt */
pos2 = strchr(++pos1, '_');
if (pos2 != NULL) {
phlen = strlen(pos1) - strlen(pos2);
} else {
/* something wrong */
return ERR_UNKNOWN;
}
} else if (i == 2) {
/* OUTxxxxxxx.txt or OUTxxxxxxx */
pos1 = &FileName[3];
pos2 = strchr(pos1, '.');
if (pos2 == NULL) {
phlen = strlen(pos1);
} else {
phlen = strlen(pos1) - strlen(pos2);
}
} else if (i == 4) {
/* OUT<priority>_<phone number>_<serialno>.txt */
pos1 = strchr(FileName, '_');
pos2 = strchr(++pos1, '_');
phlen = strlen(pos1) - strlen(pos2);
} else {
/* something wrong */
return ERR_UNKNOWN;
}
for (len=0;len<sms->Number;len++) {
EncodeUnicode(sms->SMS[len].Number, pos1, phlen);
}
#ifdef DEBUG
if (sms->Number != 0) {
DecodeUnicode(sms->SMS[0].Number,Buffer);
- dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i\n",
+ dbgprintf("Found %i sms to \"%s\" with text \"%s\" cod %i lgt %i udh: t %i l %i dlr: %i fls: %i",
sms->Number,
Buffer,
DecodeUnicodeString(sms->SMS[0].Text),
sms->SMS[0].Coding,
sms->SMS[0].Length,
sms->SMS[0].UDH.Type,
- sms->SMS[0].UDH.Length);
- } else dbgprintf("error\n");
+ sms->SMS[0].UDH.Length,
+ Config->currdeliveryreport,
+ SMSInfo.Class);
+ } else dbgprintf("error: SMS-count = 0");
#endif
return ERR_NONE;
}
/* After sending SMS is moved to Sent Items or Error Items. */
static GSM_Error SMSDFiles_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
{
FILE *oFile,*iFile;
int ilen = 0, olen = 0;
char Buffer[(GSM_MAX_SMS_LENGTH*MAX_MULTI_SMS+1)*2],ifilename[400],ofilename[400];
char *sourcepath, *destpath;
sourcepath = Config->outboxpath;
if (sent) {
destpath = Config->sentsmspath;
} else {
destpath = Config->errorsmspath;
}
strcpy(ifilename, sourcepath);
strcat(ifilename, ID);
strcpy(ofilename, destpath);
strcat(ofilename, ID);
#ifdef WIN32
if (!mystrncasecmp(ifilename, ofilename, strlen(ofilename))) {
#else
if (strcmp(ifilename, ofilename) != 0) {
#endif
iFile = fopen(ifilename, "r");
ilen = fread(Buffer, 1, sizeof(Buffer), iFile);
fclose(iFile);
oFile = fopen(ofilename, "w");
olen = fwrite(Buffer, 1, ilen, oFile);
fclose(oFile);
}
if (ilen == olen) {
if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0)) {
WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
return ERR_UNKNOWN;
}
return ERR_NONE;
} else {
WriteSMSDLog("Error copying SMS %s -> %s", ifilename, ofilename);
if (alwaysDelete) {
if ((strcmp(ifilename, "/") == 0) || (remove(ifilename) != 0))
WriteSMSDLog("Could not delete %s (%i)", ifilename, errno);
}
return ERR_UNKNOWN;
}
}
-static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK)
+static GSM_Error SMSDFiles_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
{
- if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
+ 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));
return ERR_NONE;
}
GSM_SMSDService SMSDFiles = {
NONEFUNCTION, /* Init */
+ NONEFUNCTION, /* InitAfterConnect */
SMSDFiles_SaveInboxSMS,
SMSDFiles_FindOutboxSMS,
SMSDFiles_MoveSMS,
NOTSUPPORTED, /* CreateOutboxSMS */
- SMSDFiles_AddSentSMSInfo
+ SMSDFiles_AddSentSMSInfo,
+ NOTSUPPORTED, /* RefreshSendStatus */
+ NOTSUPPORTED /* RefreshPhoneStatus */
};
-/* How should editor hadle tabs in this file? Add editor commands here.
+/* How should editor handle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
diff --git a/gammu/emb/gammu/smsd/s_files.h b/gammu/emb/gammu/smsd/s_files.h
index 5cfa05f..ed07ef3 100644
--- a/gammu/emb/gammu/smsd/s_files.h
+++ b/gammu/emb/gammu/smsd/s_files.h
@@ -1,7 +1,7 @@
-/* (c) 2002-2003 by Joergen Thomsen */
+/* (c) 2002-2004 by Joergen Thomsen */
extern GSM_SMSDService SMSDFiles;
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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
@@ -1,414 +1,724 @@
/* (c) 2004 by Marcin Wiacek */
#include "../../cfg/config.h"
#ifdef HAVE_MYSQL_MYSQL_H
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <time.h>
#ifdef WIN32
# include <windows.h>
# pragma comment(lib, "libmysql.lib")
#endif
#include "../../common/misc/coding/coding.h"
#include "../../common/service/backup/gsmback.h"
+#include "../gammu.h"
#include "smsdcore.h"
/* Connects to database */
static GSM_Error SMSDMySQL_Init(GSM_SMSDConfig *Config)
{
+ unsigned char buf[400];
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+
mysql_init(&Config->DB);
if (!mysql_real_connect(&Config->DB,Config->PC,Config->user,Config->password,Config->database,0,NULL,0)) {
WriteSMSDLog("Error connecting to database: %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
+ sprintf(buf, "SELECT ID FROM `outbox` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT ID FROM `outbox_multipart` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for outbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT ID FROM `sentitems` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for sent sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for sent sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT ID FROM `inbox` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No table for inbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No table for inbox sms: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+ sprintf(buf, "SELECT Version FROM `gammu` WHERE 1");
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("No Gammu table: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("No Gammu table: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Row = mysql_fetch_row(Res))) {
+ mysql_free_result(Res);
+ WriteSMSDLog("No version info in Gammu table: %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (atoi(Row[0]) > 4) {
+ mysql_free_result(Res);
+ WriteSMSDLog("DataBase structures are from higher Gammu version");
+ WriteSMSDLog("Please update this client application");
+ return ERR_UNKNOWN;
+ }
+ if (atoi(Row[0]) < 4) {
+ mysql_free_result(Res);
+ WriteSMSDLog("DataBase structures are from older Gammu version");
+ WriteSMSDLog("Please update DataBase, if you want to use this client application");
+ return ERR_UNKNOWN;
+ }
+ mysql_free_result(Res);
+
+ return ERR_NONE;
+}
+
+static GSM_Error SMSDMySQL_InitAfterConnect(GSM_SMSDConfig *Config)
+{
+ unsigned char buf[400],buf2[200];
+
+ sprintf(buf,"DELETE FROM `phones` WHERE `IMEI` = '%s'",s.Phone.Data.IMEI);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buf);
+#endif
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("Error deleting from database (Init): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+
+ sprintf(buf2,"Gammu %s",VERSION);
+ if (strlen(GetOS()) != 0) {
+ strcat(buf2+strlen(buf2),", ");
+ strcat(buf2+strlen(buf2),GetOS());
+ }
+ if (strlen(GetCompiler()) != 0) {
+ strcat(buf2+strlen(buf2),", ");
+ strcat(buf2+strlen(buf2),GetCompiler());
+ }
+
+ 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);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buf);
+#endif
+ if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
+ WriteSMSDLog("Error deleting from database (Init): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+
return ERR_NONE;
}
/* Save SMS from phone (called Inbox sms - it's in phone Inbox) somewhere */
static GSM_Error SMSDMySQL_SaveInboxSMS(GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config)
{
- unsigned char buffer[10000],buffer2[200],buffer3[2];
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
+ unsigned char buffer[10000],buffer2[200],buffer3[50];
int i,j,z;
+ GSM_DateTime DT;
+ time_t t_time1,t_time2;
+ bool found;
+ long diff;
for (i=0;i<sms.Number;i++) {
- if ((sms.SMS[i].PDU == SMS_Status_Report) && mystrncasecmp(Config->deliveryreport, "log", 3)) {
- strcpy(buffer, DecodeUnicodeString(sms.SMS[i].Number));
- WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer);
+ if (sms.SMS[i].PDU == SMS_Status_Report) {
+ strcpy(buffer2, DecodeUnicodeString(sms.SMS[i].Number));
+ if (mystrncasecmp(Config->deliveryreport, "log", 3)) {
+ WriteSMSDLog("Delivery report: %s to %s", DecodeUnicodeString(sms.SMS[i].Text), buffer2);
+ }
+
+ sprintf(buffer, "SELECT ID,Status,SendingDateTime,DeliveryDateTime,SMSCNumber FROM `sentitems` WHERE \
+ DeliveryDateTime='00000000000000' AND \
+ SenderID='%s' AND TPMR='%i' AND DestinationNumber='%s'",
+ Config->PhoneID, sms.SMS[i].MessageReference, buffer2);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error reading from database (SaveInbox): %s %s\n", buffer, mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database (SaveInbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ found = false;
+ while ((Row = mysql_fetch_row(Res))) {
+ if (strcmp(Row[4],DecodeUnicodeString(sms.SMS[i].SMSC.Number))) {
+ if (Config->skipsmscnumber[0] == 0) continue;
+ if (strcmp(Config->skipsmscnumber,Row[4])) continue;
+ }
+ if (!strcmp(Row[1],"SendingOK") || !strcmp(Row[1],"DeliveryPending")) {
+ sprintf(buffer,"%c%c%c%c",Row[2][0],Row[2][1],Row[2][2],Row[2][3]);
+ DT.Year = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][4],Row[2][5]);
+ DT.Month = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][6],Row[2][7]);
+ DT.Day = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][8],Row[2][9]);
+ DT.Hour = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][10],Row[2][11]);
+ DT.Minute = atoi(buffer);
+ sprintf(buffer,"%c%c",Row[2][12],Row[2][13]);
+ DT.Second = atoi(buffer);
+ t_time1 = Fill_Time_T(DT,0);
+ t_time2 = Fill_Time_T(sms.SMS[i].DateTime,0);
+ diff = t_time2 - t_time1;
+ // fprintf(stderr,"diff is %i, %i-%i-%i-%i-%i and %i-%i-%i-%i-%i-%i\n",diff,
+ // DT.Year,DT.Month,DT.Day,DT.Hour,DT.Minute,DT.Second,
+ // 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);
+ if (diff > -10 && diff < 10) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (found) {
+ sprintf(buffer,"UPDATE `sentitems` SET `DeliveryDateTime`='%04i%02i%02i%02i%02i%02i', `Status`='",
+ sms.SMS[i].SMSCTime.Year,sms.SMS[i].SMSCTime.Month,sms.SMS[i].SMSCTime.Day,
+ sms.SMS[i].SMSCTime.Hour,sms.SMS[i].SMSCTime.Minute,sms.SMS[i].SMSCTime.Second);
+ sprintf(buffer3,"%s",DecodeUnicodeString(sms.SMS[i].Text));
+ if (!strcmp(buffer3,"Delivered")) {
+ sprintf(buffer+strlen(buffer),"DeliveryOK");
+ } else if (!strcmp(buffer3,"Failed")) {
+ sprintf(buffer+strlen(buffer),"DeliveryFailed");
+ } else if (!strcmp(buffer3,"Pending")) {
+ sprintf(buffer+strlen(buffer),"DeliveryPending");
+ } else if (!strcmp(buffer3,"Unknown")) {
+ sprintf(buffer+strlen(buffer),"DeliveryUnknown");
+ }
+ sprintf(buffer+strlen(buffer),"', `StatusError` = '%i'",sms.SMS[i].DeliveryStatus);
+ sprintf(buffer+strlen(buffer)," WHERE `ID` = '%s' AND `TPMR` = '%i'",Row[0],sms.SMS[i].MessageReference);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error writing to database (SaveInboxSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ }
+ mysql_free_result(Res);
continue;
}
if (sms.SMS[i].PDU != SMS_Deliver) continue;
buffer[0]=0;
- sprintf(buffer+strlen(buffer),"INSERT INTO `Inbox` \
- (`DateTime`,`Text`,`SenderNumber`,`Coding`,`SMSCNumber`,`UDH`, \
- `Class`,`TextDecoded`) VALUES ('%04d%02d%02d%02d%02d%02d','",
+ sprintf(buffer+strlen(buffer),"INSERT INTO `inbox` \
+ (`ReceivingDateTime`,`Text`,`SenderNumber`,`Coding`,`SMSCNumber`,`UDH`, \
+ `Class`,`TextDecoded`,`RecipientID`) VALUES ('%04d%02d%02d%02d%02d%02d','",
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);
switch (sms.SMS[i].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
EncodeHexUnicode(buffer+strlen(buffer),sms.SMS[i].Text,UnicodeLength(sms.SMS[i].Text));
break;
case SMS_Coding_8bit:
EncodeHexBin(buffer+strlen(buffer),sms.SMS[i].Text,sms.SMS[i].Length);
}
sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms.SMS[i].Number));
switch (sms.SMS[i].Coding) {
case SMS_Coding_Unicode:
sprintf(buffer+strlen(buffer),"Unicode");
break;
case SMS_Coding_Default:
sprintf(buffer+strlen(buffer),"Default");
break;
case SMS_Coding_8bit:
sprintf(buffer+strlen(buffer),"8bit");
break;
}
sprintf(buffer+strlen(buffer),"','%s'",DecodeUnicodeString(sms.SMS[i].SMSC.Number));
if (sms.SMS[i].UDH.Type == UDH_NoUDH) {
sprintf(buffer+strlen(buffer),",''");
} else {
sprintf(buffer+strlen(buffer),",'");
EncodeHexBin(buffer+strlen(buffer),sms.SMS[i].UDH.Text,sms.SMS[i].UDH.Length);
sprintf(buffer+strlen(buffer),"'");
}
sprintf(buffer+strlen(buffer),",'%i','",sms.SMS[i].Class);
switch (sms.SMS[i].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
sprintf(buffer2,"%s",DecodeUnicodeString(sms.SMS[i].Text));
for (j=0;j<(int)strlen(buffer2);j++) {
sprintf(buffer3,"'");
z = strlen(buffer);
if (buffer2[j]==buffer3[0]) {
buffer[z+2]=0;
buffer[z+1]=buffer2[j];
buffer[z] ='\\';
} else {
buffer[z+1]=0;
buffer[z] =buffer2[j];
}
}
break;
case SMS_Coding_8bit:
break;
}
- sprintf(buffer+strlen(buffer),"')");
+ sprintf(buffer+strlen(buffer),"','%s')",Config->PhoneID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error writing to database (SaveInbox): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
}
return ERR_NONE;
}
+static GSM_Error SMSDMySQL_RefreshSendStatus(GSM_SMSDConfig *Config, unsigned char *ID)
+{
+ unsigned char buffer[10000];
+
+ sprintf(buffer,"UPDATE `outbox` SET `SendingTimeOut`=(now() + INTERVAL 15 SECOND)+0 WHERE `ID` = '%s' AND `SendingTimeOut` < now()",ID);
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error writing to database (RefreshSendStatus): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_affected_rows(&Config->DB) == 0) return ERR_UNKNOWN;
+ return ERR_NONE;
+}
+
/* Find one multi SMS to sending and return it (or return ERR_EMPTY)
* There is also set ID for SMS
*/
static GSM_Error SMSDMySQL_FindOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID)
{
unsigned char buf[400];
MYSQL_RES *Res;
MYSQL_ROW Row;
int i;
+ bool found = false;
- sprintf(buf, "SELECT ID,DateTime FROM `Outbox` WHERE 1");
+ sprintf(buf, "SELECT ID,InsertIntoDB,SendingDateTime,SenderID FROM `outbox` WHERE SendingDateTime < NOW() AND SendingTimeOut < NOW()");
if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
if (!(Res = mysql_store_result(&Config->DB))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
- if (!(Row = mysql_fetch_row(Res))) {
+ while ((Row = mysql_fetch_row(Res))) {
+ sprintf(ID,"%s",Row[0]);
+ sprintf(Config->DT,"%s",Row[1]);
+ if (strlen(Row[3]) == 0 || !strcmp(Row[3],Config->PhoneID)) {
+ if (SMSDMySQL_RefreshSendStatus(Config, ID)==ERR_NONE) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found) {
mysql_free_result(Res);
return ERR_EMPTY;
}
- sprintf(ID,"%s",Row[0]);
- sprintf(Config->DT,"%s",Row[1]);
+ mysql_free_result(Res);
sms->Number = 0;
- for (i=1;i<10;i++) {
- GSM_SetDefaultSMSData(&sms->SMS[sms->Number]);
+ for (i=0;i<MAX_MULTI_SMS;i++) {
+ GSM_SetDefaultSMSData(&sms->SMS[i]);
+ sms->SMS[i].SMSC.Number[0] = 0;
+ sms->SMS[i].SMSC.Number[1] = 0;
+ }
+ for (i=1;i<MAX_MULTI_SMS+1;i++) {
if (i==1) {
- sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,MultiPart FROM `Outbox` WHERE ID='%s'",ID);
+ sprintf(buf, "SELECT Text,Coding,UDH,Class,TextDecoded,ID,DestinationNumber,MultiPart,RelativeValidity,DeliveryReport FROM `outbox` WHERE ID='%s'",ID);
} else {
- sprintf(buf, "SELECT Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,SequencePosition FROM `Outbox_MultiPart` WHERE ID='%s' AND SequencePosition='%i'",ID,i);
+ sprintf(buf, "SELECT Text,Coding,UDH,Class,TextDecoded,ID,SequencePosition FROM `outbox_multipart` WHERE ID='%s' AND SequencePosition='%i'",ID,i);
}
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buf);
+#endif
if (mysql_real_query(&Config->DB,buf,strlen(buf))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
if (!(Res = mysql_store_result(&Config->DB))) {
- WriteSMSDLog("Error reading from database: %s\n", mysql_error(&Config->DB));
+ WriteSMSDLog("Error reading from database (FindOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
if (!(Row = mysql_fetch_row(Res))) {
mysql_free_result(Res);
return ERR_NONE;
}
sms->SMS[sms->Number].Coding=SMS_Coding_Default;
- if (!strcmp(Row[2],"Unicode")) sms->SMS[sms->Number].Coding=SMS_Coding_Unicode;
- if (!strcmp(Row[2],"8bit")) sms->SMS[sms->Number].Coding=SMS_Coding_8bit;
+ if (!strcmp(Row[1],"Unicode")) sms->SMS[sms->Number].Coding=SMS_Coding_Unicode;
+ if (!strcmp(Row[1],"8bit")) sms->SMS[sms->Number].Coding=SMS_Coding_8bit;
if (strlen(Row[0])==0) {
- EncodeUnicode(sms->SMS[sms->Number].Text,Row[6],strlen(Row[6]));
+ EncodeUnicode(sms->SMS[sms->Number].Text,Row[4],strlen(Row[4]));
} else {
switch (sms->SMS[sms->Number].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
DecodeHexUnicode(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0]));
break;
case SMS_Coding_8bit:
DecodeHexBin(sms->SMS[sms->Number].Text,Row[0],strlen(Row[0]));
sms->SMS[sms->Number].Length=strlen(Row[0])/2;
}
}
- EncodeUnicode(sms->SMS[sms->Number].Number,Row[1],strlen(Row[1]));
+ if (i == 1) {
+ EncodeUnicode(sms->SMS[sms->Number].Number,Row[6],strlen(Row[6]));
+ } else {
+ CopyUnicodeString(sms->SMS[sms->Number].Number,sms->SMS[0].Number);
+ }
sms->SMS[sms->Number].UDH.Type = UDH_NoUDH;
- if (strlen(Row[3])!=0) {
+ if (strlen(Row[2])!=0) {
sms->SMS[sms->Number].UDH.Type = UDH_UserUDH;
- sms->SMS[sms->Number].UDH.Length = strlen(Row[3])/2;
- DecodeHexBin(sms->SMS[sms->Number].UDH.Text,Row[3],strlen(Row[3]));
+ sms->SMS[sms->Number].UDH.Length = strlen(Row[2])/2;
+ DecodeHexBin(sms->SMS[sms->Number].UDH.Text,Row[2],strlen(Row[2]));
}
- EncodeUnicode(sms->SMS[sms->Number].SMSC.Number,Row[4],strlen(Row[4]));
- sms->SMS[sms->Number].Class = atoi(Row[5]);
+ sms->SMS[sms->Number].Class = atoi(Row[3]);
sms->SMS[sms->Number].PDU = SMS_Submit;
- sms->SMS[sms->Number].SMSC.Location = 0;
sms->Number++;
- if (i == 1 && !strcmp(Row[8],"false")) break;
+ if (i==1) {
+ Config->relativevalidity = atoi(Row[8]);
+
+ Config->currdeliveryreport = -1;
+ if (!strcmp(Row[9],"yes")) {
+ Config->currdeliveryreport = 1;
+ } else if (!strcmp(Row[9],"no")) {
+ Config->currdeliveryreport = 0;
}
+
+ if (!strcmp(Row[7],"false")) break;
+
+ }
+ }
+ mysql_free_result(Res);
return ERR_NONE;
}
/* After sending SMS is moved to Sent Items or Error Items. */
static GSM_Error SMSDMySQL_MoveSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent)
{
- char *status;
- unsigned char buffer[10000],buffer2[200],buffer3[2];
- int i,j,z;
+ unsigned char buffer[10000];
+
+ sprintf(buffer,"DELETE FROM `outbox` WHERE `ID` = '%s'",ID);
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error deleting from database (MoveSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ sprintf(buffer,"DELETE FROM `outbox_multipart` WHERE `ID` = '%s'",ID);
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error deleting from database (MoveSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ return ERR_NONE;
+}
+
+/* Adds SMS to Outbox */
+static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config)
+{
+ unsigned char buffer[10000],buffer2[200],buffer3[2],buffer4[10000];
+ int i,j,z,ID;
+ MYSQL_RES *Res;
+ MYSQL_ROW Row;
- if (sent) status = "OK"; else status = "Error";
+ sprintf(buffer,"SELECT ID FROM outbox ORDER BY ID DESC LIMIT 1");
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
+ }
+ if ((Row = mysql_fetch_row(Res))) {
+ sprintf(buffer,"%s",Row[0]);
+ ID = atoi(buffer);
+ } else {
+ ID = 0;
+ }
+ mysql_free_result(Res);
for (i=0;i<sms->Number;i++) {
buffer[0]=0;
- sprintf(buffer+strlen(buffer),"UPDATE `SentItems` SET `Text`='");
+ if (i==0) {
+ sprintf(buffer+strlen(buffer),"INSERT INTO `outbox` (`DeliveryReport`,`MultiPart`,`InsertIntoDB");
+ } else {
+ sprintf(buffer+strlen(buffer),"INSERT INTO `outbox_multipart` (`SequencePosition");
+ }
+ sprintf(buffer+strlen(buffer),"`,`Text`,");
+ if (i==0) {
+ sprintf(buffer+strlen(buffer),"`DestinationNumber`,`RelativeValidity`,");
+ }
+ sprintf(buffer+strlen(buffer),"`Coding`,`UDH`, \
+ `Class`,`TextDecoded`,`ID`) VALUES ('");
+ if (i==0) {
+ if (sms->SMS[i].PDU == SMS_Status_Report) {
+ sprintf(buffer+strlen(buffer),"yes','");
+ } else {
+ sprintf(buffer+strlen(buffer),"default','");
+ }
+ if (sms->Number == 1) {
+ sprintf(buffer+strlen(buffer),"false");
+ } else {
+ sprintf(buffer+strlen(buffer),"true");
+ }
+ sprintf(buffer+strlen(buffer),"',NOW()");
+ } else {
+ sprintf(buffer+strlen(buffer),"%i'",i+1);
+ }
+ sprintf(buffer+strlen(buffer),",'");
switch (sms->SMS[i].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[i].Text,UnicodeLength(sms->SMS[i].Text));
break;
case SMS_Coding_8bit:
EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].Text,sms->SMS[i].Length);
}
-
- sprintf(buffer+strlen(buffer),"',`DestinationNumber`='%s',`Coding`='",DecodeUnicodeString(sms->SMS[i].Number));
-
+ sprintf(buffer+strlen(buffer),"',");
+ if (i==0) {
+ sprintf(buffer+strlen(buffer),"'%s',",DecodeUnicodeString(sms->SMS[i].Number));
+ if (sms->SMS[i].SMSC.Validity.Format == SMS_Validity_RelativeFormat) {
+ sprintf(buffer+strlen(buffer),"'%i',",sms->SMS[i].SMSC.Validity.Relative);
+ } else {
+ sprintf(buffer+strlen(buffer),"'-1',");
+ }
+ }
+ sprintf(buffer+strlen(buffer),"'");
switch (sms->SMS[i].Coding) {
case SMS_Coding_Unicode:
sprintf(buffer+strlen(buffer),"Unicode");
break;
case SMS_Coding_Default:
sprintf(buffer+strlen(buffer),"Default");
break;
case SMS_Coding_8bit:
sprintf(buffer+strlen(buffer),"8bit");
break;
}
-
- sprintf(buffer+strlen(buffer),"',`SMSCNumber`='%s',`UDH`='",DecodeUnicodeString(sms->SMS[i].SMSC.Number));
+ sprintf(buffer+strlen(buffer),"','");
if (sms->SMS[i].UDH.Type != UDH_NoUDH) {
EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length);
}
-
- sprintf(buffer+strlen(buffer),"',`Class`='%i',`TextDecoded`='",sms->SMS[i].Class);
+ sprintf(buffer+strlen(buffer),"','%i','",sms->SMS[i].Class);
switch (sms->SMS[i].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[i].Text));
for (j=0;j<(int)strlen(buffer2);j++) {
sprintf(buffer3,"'");
z = strlen(buffer);
if (buffer2[j]==buffer3[0]) {
buffer[z+2]=0;
buffer[z+1]=buffer2[j];
buffer[z] ='\\';
} else {
buffer[z+1]=0;
buffer[z] =buffer2[j];
}
}
break;
case SMS_Coding_8bit:
+
break;
}
- sprintf(buffer+strlen(buffer),"',`Status`='%s',`DateTime`='%s' ",status,Config->DT);
- sprintf(buffer+strlen(buffer),"WHERE `ID`='%s' AND `SequencePosition`='%i'",ID,i+1);
- if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ sprintf(buffer+strlen(buffer),"','");
+ if (i==0) {
+ while (true) {
+ ID++;
+ sprintf(buffer4,"SELECT ID FROM sentitems WHERE ID='%i'",ID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer4);
+#endif
+ if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
+ if (!(Res = mysql_store_result(&Config->DB))) {
+ WriteSMSDLog("Error reading from database (CreateOutbox): %s\n", mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
}
- sprintf(buffer,"DELETE FROM `Outbox` WHERE `ID` = '%s'",ID);
- if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ if (!(Row = mysql_fetch_row(Res))) {
+ buffer4[0] = 0;
+ strcpy(buffer4,buffer);
+ sprintf(buffer4+strlen(buffer4),"%i')",ID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer4);
+#endif
+ if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
+ if (mysql_errno(&Config->DB) == ER_DUP_ENTRY) {
+ WriteSMSDLog("Duplicated outgoing SMS ID\n");
+ continue;
+ }
+ WriteSMSDLog("Error writing to database (CreateOutbox): %d %s %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB),buffer4);
return ERR_UNKNOWN;
}
- sprintf(buffer,"DELETE FROM `Outbox_MultiPart` WHERE `ID` = '%s'",ID);
- if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ mysql_free_result(Res);
+ break;
+ }
+ mysql_free_result(Res);
+ }
+ } else {
+ strcpy(buffer4,buffer);
+ sprintf(buffer4+strlen(buffer4),"%i')",ID);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer4);
+#endif
+ if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
+ WriteSMSDLog("Error writing to database (CreateOutbox): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
+ }
+ }
return ERR_NONE;
}
-/* Adds SMS to Outbox */
-static GSM_Error SMSDMySQL_CreateOutboxSMS(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config)
+
+static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR)
{
- unsigned char buffer[10000],buffer2[200],buffer3[2],buffer4[10000];
- int i,j,z;
- GSM_DateTime time;
+ unsigned char buffer[10000],buffer2[200],buffer3[2],buff[50];
+ int j,z;
- for (i=0;i<sms->Number;i++) {
- buffer[0]=0;
- if (i==0) {
- sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox` (`MultiPart`,`DateTime");
- } else {
- sprintf(buffer+strlen(buffer),"INSERT INTO `Outbox_MultiPart` (`SequencePosition");
- }
- sprintf(buffer+strlen(buffer),"`,`Text`,`DestinationNumber`,`Coding`,`SMSCNumber`,`UDH`, \
- `Class`,`TextDecoded`,`ID`) VALUES ('");
- if (i==0) {
- if (sms->Number == 1) {
- sprintf(buffer+strlen(buffer),"false");
+ 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));
+
+ buff[0] = 0;
+ if (err == SMSD_SEND_OK) {
+ if (sms->SMS[Part-1].PDU == SMS_Status_Report) {
+ sprintf(buff,"SendingOK");
} else {
- sprintf(buffer+strlen(buffer),"true");
+ sprintf(buff,"SendingOKNoReport");
}
- sprintf(buffer+strlen(buffer),"',NOW()");
- } else {
- sprintf(buffer+strlen(buffer),"%i'",i+1);
}
- sprintf(buffer+strlen(buffer),",'");
+ if (err == SMSD_SEND_SENDING_ERROR) sprintf(buff,"SendingError");
+ if (err == SMSD_SEND_ERROR) sprintf(buff,"Error");
- switch (sms->SMS[i].Coding) {
+ buffer[0] = 0;
+ sprintf(buffer+strlen(buffer),"INSERT INTO `sentitems` \
+ (`ID`,`SequencePosition`,`Status`,`SendingDateTime`, `SMSCNumber`, `TPMR`, \
+ `SenderID`,`Text`,`DestinationNumber`,`Coding`,`UDH`,`Class`,`TextDecoded`,`InsertIntoDB`,`RelativeValidity`) VALUES (");
+ sprintf(buffer+strlen(buffer),"'%s','%i','%s',NOW(),'%s','%i','%s','",ID,Part,buff,DecodeUnicodeString(sms->SMS[Part-1].SMSC.Number),TPMR,Config->PhoneID);
+ switch (sms->SMS[Part-1].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
- EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[i].Text,UnicodeLength(sms->SMS[i].Text));
+ EncodeHexUnicode(buffer+strlen(buffer),sms->SMS[Part-1].Text,UnicodeLength(sms->SMS[Part-1].Text));
break;
case SMS_Coding_8bit:
- EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].Text,sms->SMS[i].Length);
+ EncodeHexBin(buffer+strlen(buffer),sms->SMS[Part-1].Text,sms->SMS[Part-1].Length);
}
- sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms->SMS[i].Number));
- switch (sms->SMS[i].Coding) {
+ sprintf(buffer+strlen(buffer),"','%s','",DecodeUnicodeString(sms->SMS[Part-1].Number));
+ switch (sms->SMS[Part-1].Coding) {
case SMS_Coding_Unicode:
sprintf(buffer+strlen(buffer),"Unicode");
break;
case SMS_Coding_Default:
sprintf(buffer+strlen(buffer),"Default");
break;
case SMS_Coding_8bit:
sprintf(buffer+strlen(buffer),"8bit");
break;
}
- sprintf(buffer+strlen(buffer),"','%s'",DecodeUnicodeString(sms->SMS[i].SMSC.Number));
- if (sms->SMS[i].UDH.Type == UDH_NoUDH) {
- sprintf(buffer+strlen(buffer),",''");
- } else {
- sprintf(buffer+strlen(buffer),",'");
- EncodeHexBin(buffer+strlen(buffer),sms->SMS[i].UDH.Text,sms->SMS[i].UDH.Length);
- sprintf(buffer+strlen(buffer),"'");
+ sprintf(buffer+strlen(buffer),"','");
+ if (sms->SMS[Part-1].UDH.Type != UDH_NoUDH) {
+ EncodeHexBin(buffer+strlen(buffer),sms->SMS[Part-1].UDH.Text,sms->SMS[Part-1].UDH.Length);
}
- sprintf(buffer+strlen(buffer),",'%i','",sms->SMS[i].Class);
- switch (sms->SMS[i].Coding) {
+ sprintf(buffer+strlen(buffer),"','%i','",sms->SMS[Part-1].Class);
+ switch (sms->SMS[Part-1].Coding) {
case SMS_Coding_Unicode:
case SMS_Coding_Default:
- sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[i].Text));
+ sprintf(buffer2,"%s",DecodeUnicodeString(sms->SMS[Part-1].Text));
for (j=0;j<(int)strlen(buffer2);j++) {
sprintf(buffer3,"'");
z = strlen(buffer);
if (buffer2[j]==buffer3[0]) {
buffer[z+2]=0;
buffer[z+1]=buffer2[j];
buffer[z] ='\\';
} else {
buffer[z+1]=0;
buffer[z] =buffer2[j];
}
}
break;
case SMS_Coding_8bit:
-
- break;
- }
- sprintf(buffer+strlen(buffer),"','");
- if (i==0) {
- while (true) {
- GSM_GetCurrentDateTime(&time);
- buffer4[0] = 0;
- strcpy(buffer4,buffer);
- sprintf(buffer4+strlen(buffer4),"%i')",
- time.Hour*1000000+
- time.Minute*10000+
- time.Second*100+time.Day);
- if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
- if (mysql_errno(&Config->DB) == ER_DUP_ENTRY) {
- WriteSMSDLog("Duplicated outgoing SMS ID\n");
- continue;
- }
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
- return ERR_UNKNOWN;
- }
break;
}
+ sprintf(buffer+strlen(buffer),"','%s','",Config->DT);
+ if (sms->SMS[Part-1].SMSC.Validity.Format == SMS_Validity_RelativeFormat) {
+ sprintf(buffer+strlen(buffer),"%i')",sms->SMS[Part-1].SMSC.Validity.Relative);
} else {
- strcpy(buffer4,buffer);
- sprintf(buffer4+strlen(buffer4),"%i')",
- time.Hour*1000000+
- time.Minute*10000+
- time.Second*100+time.Day);
- if (mysql_real_query(&Config->DB,buffer4,strlen(buffer4))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
- return ERR_UNKNOWN;
- }
+ sprintf(buffer+strlen(buffer),"-1')");
}
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
+ if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
+ WriteSMSDLog("Error writing to database (AddSent): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ return ERR_UNKNOWN;
}
return ERR_NONE;
}
-static GSM_Error SMSDMySQL_AddSentSMSInfo(GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK)
+static GSM_Error SMSDMySQL_RefreshPhoneStatus(GSM_SMSDConfig *Config)
{
- unsigned char buffer[10000];
-
- if (OK) WriteSMSDLog("Transmitted %s (%s: %i) to %s", Config->SMSID, (Part == sms->Number?"total":"part"),Part,DecodeUnicodeString(sms->SMS[0].Number));
+ unsigned char buffer[500];
- buffer[0] = 0;
- sprintf(buffer+strlen(buffer),"INSERT INTO `SentItems` \
- (`ID`,`SequencePosition`,`Status`,`SendingDateTime`) VALUES (");
- sprintf(buffer+strlen(buffer),"'%s','%i','Sending',NOW())",ID,Part);
+ sprintf(buffer,"UPDATE `phones` SET `TimeOut`= (NOW() + INTERVAL 10 SECOND)+0");
+ sprintf(buffer+strlen(buffer)," WHERE `IMEI` = '%s'",s.Phone.Data.IMEI);
+#ifdef DEBUG
+ fprintf(stdout,"%s\n",buffer);
+#endif
if (mysql_real_query(&Config->DB,buffer,strlen(buffer))) {
- WriteSMSDLog("Error writing to database: %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
+ WriteSMSDLog("Error writing to database (SaveInboxSMS): %d %s\n", mysql_errno(&Config->DB), mysql_error(&Config->DB));
return ERR_UNKNOWN;
}
return ERR_NONE;
}
GSM_SMSDService SMSDMySQL = {
SMSDMySQL_Init,
+ SMSDMySQL_InitAfterConnect,
SMSDMySQL_SaveInboxSMS,
SMSDMySQL_FindOutboxSMS,
SMSDMySQL_MoveSMS,
SMSDMySQL_CreateOutboxSMS,
- SMSDMySQL_AddSentSMSInfo
+ SMSDMySQL_AddSentSMSInfo,
+ SMSDMySQL_RefreshSendStatus,
+ SMSDMySQL_RefreshPhoneStatus
};
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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,226 +1,248 @@
-/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */
+/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
#include <string.h>
#include <signal.h>
#include <stdarg.h>
#include <time.h>
#include "../../common/misc/coding/coding.h"
#include "../gammu.h"
#include "smsdcore.h"
#include "s_files.h"
#ifdef HAVE_MYSQL_MYSQL_H
# include "s_mysql.h"
#endif
FILE *smsd_log_file = NULL;
+static int TPMR;
static GSM_Error SendingSMSStatus;
+
static void SMSSendingSMSStatus (char *Device, int status, int mr)
{
dbgprintf("Incoming SMS device: \"%s\" status=%d, reference=%d\n",Device, status, mr);
+ TPMR = mr;
if (status==0) {
SendingSMSStatus = ERR_NONE;
} else {
SendingSMSStatus = ERR_UNKNOWN;
}
}
void GSM_Terminate_SMSD(char *msg, int error, bool exitprogram, int rc)
{
int ret = ERR_NONE;
if (s.opened) {
WriteSMSDLog("Terminating communication");
ret=GSM_TerminateConnection(&s);
if (ret!=ERR_NONE) {
printf("%s\n",print_error(error,s.di.df,s.msg));
if (s.opened) GSM_TerminateConnection(&s);
}
}
if (error != 0) {
WriteSMSDLog(msg, error, print_error(error,s.di.df,s.msg));
fprintf(stderr, msg, error, print_error(error,s.di.df,s.msg));
fprintf(stderr, "\n");
}
if (exitprogram) {
if (smsd_log_file!=NULL) fclose(smsd_log_file);
exit(rc);
}
}
#ifdef __GNUC__
__attribute__((format(printf, 1, 2)))
#endif
void WriteSMSDLog(char *format, ...)
{
GSM_DateTime date_time;
char Buffer[2000];
va_list argp;
int result;
if (smsd_log_file != NULL) {
va_start(argp, format);
result = vsprintf(Buffer,GetMsg(s.msg,format),argp);
va_end(argp);
GSM_GetCurrentDateTime(&date_time);
fprintf(smsd_log_file,"%s %4d/%02d/%02d %02d:%02d:%02d : %s\n",
DayOfWeek(date_time.Year, date_time.Month, date_time.Day),
date_time.Year, date_time.Month, date_time.Day,
date_time.Hour, date_time.Minute, date_time.Second,Buffer);
fflush(smsd_log_file);
}
}
-void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log)
+void SMSD_ReadConfig(char *filename, GSM_SMSDConfig *Config, bool log, char *service)
{
INI_Section *smsdcfgfile = NULL;
GSM_Config smsdcfg;
unsigned char *str;
static unsigned char emptyPath[1] = "\0";
smsdcfgfile=INI_ReadFile(filename, false);
if (smsdcfgfile==NULL) {
fprintf(stderr,"Can't find file \"%s\"\n",filename);
exit(-1);
}
Config->logfilename=INI_GetValue(smsdcfgfile, "smsd", "logfile", false);
if (Config->logfilename != NULL) {
smsd_log_file=fopen(Config->logfilename,"ab");
if (smsd_log_file == NULL) {
fprintf(stderr,"Can't open file \"%s\"\n",Config->logfilename);
exit(-1);
}
fprintf(stderr,"Log filename is \"%s\"\n",Config->logfilename);
}
if (log) WriteSMSDLog("Start GAMMU smsd");
/* Include Numbers used, because we don't want create new variable */
Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "gammu", false);
if (Config->IncludeNumbers) {
GSM_ReadConfig(smsdcfgfile, &smsdcfg, 0);
memcpy(&s.Config,&smsdcfg,sizeof(GSM_Config));
+ error=GSM_SetDebugFile(s.Config[0].DebugFile, &di);
}
Config->PINCode=INI_GetValue(smsdcfgfile, "smsd", "PIN", false);
if (Config->PINCode == NULL) {
if (log) WriteSMSDLog("No PIN code in %s file",filename);
fprintf(stderr,"No PIN code in %s file\n",filename);
exit(-1);
}
if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode);
- Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
- if (Config->user == NULL) Config->user="root";
- Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
- if (Config->password == NULL) Config->password="";
- Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
- if (Config->PC == NULL) Config->PC="localhost";
- Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
- if (Config->database == NULL) Config->database="sms";
-
str = INI_GetValue(smsdcfgfile, "smsd", "commtimeout", false);
if (str) Config->commtimeout=atoi(str); else Config->commtimeout = 1;
str = INI_GetValue(smsdcfgfile, "smsd", "sendtimeout", false);
if (str) Config->sendtimeout=atoi(str); else Config->sendtimeout = 10;
str = INI_GetValue(smsdcfgfile, "smsd", "receivefrequency", false);
if (str) Config->receivefrequency=atoi(str); else Config->receivefrequency = 0;
- if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i", Config->commtimeout, Config->sendtimeout, Config->receivefrequency);
+ str = INI_GetValue(smsdcfgfile, "smsd", "resetfrequency", false);
+ if (str) Config->resetfrequency=atoi(str); else Config->resetfrequency = 0;
+ if (log) WriteSMSDLog("commtimeout=%i, sendtimeout=%i, receivefrequency=%i, resetfrequency=%i",
+ Config->commtimeout, Config->sendtimeout, Config->receivefrequency, Config->resetfrequency);
Config->deliveryreport = INI_GetValue(smsdcfgfile, "smsd", "deliveryreport", false);
if (Config->deliveryreport == NULL || (!mystrncasecmp(Config->deliveryreport, "log", 3) && !mystrncasecmp(Config->deliveryreport, "sms", 3))) {
Config->deliveryreport = "no";
}
if (log) WriteSMSDLog("deliveryreport = %s", Config->deliveryreport);
+ Config->PhoneID = INI_GetValue(smsdcfgfile, "smsd", "phoneid", false);
+ if (Config->PhoneID == NULL) Config->PhoneID = "";
+ if (log) WriteSMSDLog("phoneid = %s", Config->PhoneID);
+
+ if (!strcmp(service,"FILES")) {
Config->inboxpath=INI_GetValue(smsdcfgfile, "smsd", "inboxpath", false);
if (Config->inboxpath == NULL) Config->inboxpath = emptyPath;
Config->inboxformat=INI_GetValue(smsdcfgfile, "smsd", "inboxformat", false);
if (Config->inboxformat == NULL || (!mystrncasecmp(Config->inboxformat, "detail", 6) && !mystrncasecmp(Config->inboxformat, "unicode", 7))) {
Config->inboxformat = "standard";
}
if (log) WriteSMSDLog("Inbox is \"%s\" with format \"%s\"", Config->inboxpath, Config->inboxformat);
Config->outboxpath=INI_GetValue(smsdcfgfile, "smsd", "outboxpath", false);
if (Config->outboxpath == NULL) Config->outboxpath = emptyPath;
Config->transmitformat=INI_GetValue(smsdcfgfile, "smsd", "transmitformat", false);
if (Config->transmitformat == NULL || (!mystrncasecmp(Config->transmitformat, "auto", 4) && !mystrncasecmp(Config->transmitformat, "unicode", 7))) {
Config->transmitformat = "7bit";
}
if (log) WriteSMSDLog("Outbox is \"%s\" with transmission format \"%s\"", Config->outboxpath, Config->transmitformat);
Config->sentsmspath=INI_GetValue(smsdcfgfile, "smsd", "sentsmspath", false);
if (Config->sentsmspath == NULL) Config->sentsmspath = Config->outboxpath;
if (log) WriteSMSDLog("Sent SMS moved to \"%s\"",Config->sentsmspath);
Config->errorsmspath=INI_GetValue(smsdcfgfile, "smsd", "errorsmspath", false);
if (Config->errorsmspath == NULL) Config->errorsmspath = Config->sentsmspath;
if (log) WriteSMSDLog("SMS with errors moved to \"%s\"",Config->errorsmspath);
+ }
+
+#ifdef HAVE_MYSQL_MYSQL_H
+ if (!strcmp(service,"MYSQL")) {
+ Config->skipsmscnumber = INI_GetValue(smsdcfgfile, "smsd", "skipsmscnumber", false);
+ if (Config->skipsmscnumber == NULL) Config->skipsmscnumber="";
+ Config->user = INI_GetValue(smsdcfgfile, "smsd", "user", false);
+ if (Config->user == NULL) Config->user="root";
+ Config->password = INI_GetValue(smsdcfgfile, "smsd", "password", false);
+ if (Config->password == NULL) Config->password="";
+ Config->PC = INI_GetValue(smsdcfgfile, "smsd", "pc", false);
+ if (Config->PC == NULL) Config->PC="localhost";
+ Config->database = INI_GetValue(smsdcfgfile, "smsd", "database", false);
+ if (Config->database == NULL) Config->database="sms";
+ }
+#endif
Config->IncludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "include_numbers", false);
Config->ExcludeNumbers=INI_FindLastSectionEntry(smsdcfgfile, "exclude_numbers", false);
if (Config->IncludeNumbers != NULL) {
if (log) WriteSMSDLog("Include numbers available");
}
if (Config->ExcludeNumbers != NULL) {
if (Config->IncludeNumbers == NULL) {
if (log) WriteSMSDLog("Exclude numbers available");
} else {
if (log) WriteSMSDLog("Exclude numbers available, but IGNORED");
}
}
Config->retries = 0;
Config->prevSMSID[0] = 0;
+ Config->SMSC.Location = 0;
+ Config->relativevalidity = -1;
}
bool SMSD_CheckSecurity(GSM_SMSDConfig *Config)
{
GSM_SecurityCode SecurityCode;
GSM_Error error;
/* Need PIN ? */
error=Phone->GetSecurityStatus(&s,&SecurityCode.Type);
/* Unknown error */
if (error != ERR_NOTSUPPORTED && error != ERR_NONE) {
WriteSMSDLog("Error getting security status (%i)", error);
return false;
}
/* No supported - do not check more */
if (error == ERR_NOTSUPPORTED) return true;
+
/* If PIN, try to enter */
switch (SecurityCode.Type) {
case SEC_Pin:
WriteSMSDLog("Trying to enter PIN");
strcpy(SecurityCode.Code,Config->PINCode);
error=Phone->EnterSecurityCode(&s,SecurityCode);
if (error == ERR_SECURITYERROR) {
GSM_Terminate_SMSD("ERROR: incorrect PIN", error, true, -1);
}
if (error != ERR_NONE) {
WriteSMSDLog("Error entering PIN (%i)", error);
return false;
}
break;
case SEC_SecurityCode:
case SEC_Pin2:
case SEC_Puk:
case SEC_Puk2:
GSM_Terminate_SMSD("ERROR: phone requires not supported code type", 0, true, -1);
case SEC_None:
break;
}
return true;
}
bool SMSD_ReadDeleteSMS(GSM_SMSDConfig *Config, GSM_SMSDService *Service)
{
bool start,process;
GSM_MultiSMSMessage sms;
unsigned char buffer[100];
GSM_Error error=ERR_NONE;
INI_Entry *e;
@@ -297,211 +319,265 @@ bool SMSD_CheckSMSStatus(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
/* Do we have any SMS in phone ? */
error=Phone->GetSMSStatus(&s,&SMSStatus);
if (error != ERR_NONE) {
WriteSMSDLog("Error getting SMS status (%i)", error);
return false;
}
/* Yes. We have SMS in phone */
if (SMSStatus.SIMUsed+SMSStatus.PhoneUsed != 0) {
return SMSD_ReadDeleteSMS(Config,Service);
}
return true;
}
bool SMSD_SendSMS(GSM_SMSDConfig *Config,GSM_SMSDService *Service)
{
GSM_MultiSMSMessage sms;
GSM_DateTime Date;
GSM_Error error;
unsigned int i, j, z;
error = Service->FindOutboxSMS(&sms, Config, Config->SMSID);
if (error == ERR_EMPTY || error == ERR_NOTSUPPORTED) {
/* No outbox sms - wait few seconds and escape */
for (j=0;j<Config->commtimeout && !gshutdown;j++) {
GSM_GetCurrentDateTime (&Date);
i=Date.Second;
while (i==Date.Second && !gshutdown) {
my_sleep(10);
GSM_GetCurrentDateTime(&Date);
}
+ Service->RefreshPhoneStatus(Config);
}
return true;
}
if (error != ERR_NONE) {
/* Unknown error - escape */
WriteSMSDLog("Error in outbox on %s", Config->SMSID);
for (i=0;i<sms.Number;i++) {
- Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
}
Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
return false;
}
+
if (!gshutdown) {
if (strcmp(Config->prevSMSID, Config->SMSID) == 0) {
Config->retries++;
if (Config->retries > MAX_RETRIES) {
Config->retries = 0;
strcpy(Config->prevSMSID, "");
WriteSMSDLog("Moved to errorbox: %s", Config->SMSID);
for (i=0;i<sms.Number;i++) {
- Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_ERROR, -1);
}
Service->MoveSMS(&sms,Config, Config->SMSID, true,false);
return false;
}
} else {
Config->retries = 0;
strcpy(Config->prevSMSID, Config->SMSID);
}
for (i=0;i<sms.Number;i++) {
- if (strcmp(Config->deliveryreport, "no") != 0) sms.SMS[i].PDU = SMS_Status_Report;
+ if (sms.SMS[i].SMSC.Location == 1) {
+ if (Config->SMSC.Location == 0) {
+ Config->SMSC.Location = 1;
+ error = Phone->GetSMSC(&s,&Config->SMSC);
+ if (error!=ERR_NONE) {
+ WriteSMSDLog("Error getting SMSC from phone");
+ return false;
+ }
+
+ }
+ memcpy(&sms.SMS[i].SMSC,&Config->SMSC,sizeof(GSM_SMSC));
+ sms.SMS[i].SMSC.Location = 0;
+ if (Config->relativevalidity != -1) {
+ sms.SMS[i].SMSC.Validity.Format = SMS_Validity_RelativeFormat;
+ sms.SMS[i].SMSC.Validity.Relative = Config->relativevalidity;
+ }
+ }
+
+ if (Config->currdeliveryreport == 1) {
+ sms.SMS[i].PDU = SMS_Status_Report;
+ } else {
+ if ((strcmp(Config->deliveryreport, "no") != 0 && (Config->currdeliveryreport == -1))) sms.SMS[i].PDU = SMS_Status_Report;
+ }
+
error=Phone->SendSMS(&s, &sms.SMS[i]);
if (error!=ERR_NONE) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, -1);
WriteSMSDLog("Error sending SMS %s (%i): %s", Config->SMSID, error,print_error(error,s.di.df,s.msg));
return false;
}
+ Service->RefreshPhoneStatus(Config);
j=0;
+ TPMR = -1;
SendingSMSStatus = ERR_TIMEOUT;
while (!gshutdown) {
GSM_GetCurrentDateTime (&Date);
z=Date.Second;
while (z==Date.Second) {
my_sleep(10);
GSM_GetCurrentDateTime(&Date);
GSM_ReadDevice(&s,true);
if (SendingSMSStatus != ERR_TIMEOUT) break;
}
+ Service->RefreshSendStatus(Config, Config->SMSID);
+ Service->RefreshPhoneStatus(Config);
if (SendingSMSStatus != ERR_TIMEOUT) break;
j++;
if (j>Config->sendtimeout) break;
}
if (SendingSMSStatus != ERR_NONE) {
+ Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_SENDING_ERROR, TPMR);
WriteSMSDLog("Error getting send status of %s (%i): %s", Config->SMSID, SendingSMSStatus,print_error(SendingSMSStatus,s.di.df,s.msg));
return false;
}
- error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, true);
+ error = Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, SMSD_SEND_OK, TPMR);
if (error!=ERR_NONE) {
return false;
}
}
- while ((int)i<sms.Number-1) {
- Service->AddSentSMSInfo(&sms, Config, Config->SMSID, i+1, false);
- i++;
- }
strcpy(Config->prevSMSID, "");
if (Service->MoveSMS(&sms,Config, Config->SMSID, false, true) != ERR_NONE) {
Service->MoveSMS(&sms,Config, Config->SMSID, true, false);
}
}
return true;
}
void SMSDaemon(int argc, char *argv[])
{
int errors = 255, initerrors=0;
GSM_SMSDService *Service;
GSM_Error error;
- time_t time1;
+ time_t lastreceive, lastreset = 0;
GSM_SMSDConfig Config;
if (!strcmp(argv[2],"FILES")) {
Service = &SMSDFiles;
#ifdef HAVE_MYSQL_MYSQL_H
} else if (!strcmp(argv[2],"MYSQL")) {
Service = &SMSDMySQL;
#endif
} else {
fprintf(stderr,"Unknown service type (\"%s\")\n",argv[2]);
exit(-1);
}
- SMSD_ReadConfig(argv[3], &Config, true);
+ SMSD_ReadConfig(argv[3], &Config, true, argv[2]);
error = Service->Init(&Config);
if (error!=ERR_NONE) {
GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
}
signal(SIGINT, interrupt);
signal(SIGTERM, interrupt);
fprintf(stderr,"Press Ctrl+C to stop the program ...\n");
- time1 = time(NULL);
+ lastreceive = time(NULL);
+ lastreset = time(NULL);
SendingSMSStatus = ERR_UNKNOWN;
while (!gshutdown) {
/* There were errors in communication - try to recover */
if (errors > 2) {
if (errors != 255) {
WriteSMSDLog("Terminating communication (%i,%i)", error, errors);
error=GSM_TerminateConnection(&s);
}
if (initerrors++ > 3) my_sleep(30000);
WriteSMSDLog("Starting communication");
error=GSM_InitConnection(&s,2);
switch (error) {
case ERR_NONE:
s.User.SendSMSStatus = SMSSendingSMSStatus;
Phone = s.Phone.Functions;
+ if (errors == 255) {
errors = 0;
+ s.Phone.Data.IMEI[0] = 0;
+ if (!(Phone->GetIMEI(&s))) {
+ errors++;
+ } else {
+ error = Service->InitAfterConnect(&Config);
+ if (error!=ERR_NONE) {
+ GSM_Terminate_SMSD("Stop GAMMU smsd (%i)", error, true, -1);
+ }
+ Phone->SetFastSMSSending(&s,true);
+ }
+ } else {
+ errors = 0;
+ }
+ if (initerrors > 3 || initerrors < 0) {
+ error=Phone->Reset(&s, false); /* soft reset */
+ WriteSMSDLog("Reset return code: %s (%i) ", error == ERR_NONE? "OK":"ERROR", error);
+ lastreset = time(NULL);
+ my_sleep(5000);
+ }
/* Marcin Wiacek: FIXME. To check */
// di = s.di;
break;
case ERR_DEVICEOPENERROR:
GSM_Terminate_SMSD("Can't open device (%i)", error, true, -1);
default:
WriteSMSDLog("Error at init connection (%i)", error);
errors = 250;
}
continue;
}
- if ((difftime(time(NULL), time1) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
- time1 = time(NULL);
+ if ((difftime(time(NULL), lastreceive) >= Config.receivefrequency) || (SendingSMSStatus != ERR_NONE)) {
+ lastreceive = time(NULL);
if (!SMSD_CheckSecurity(&Config)) {
errors++;
initerrors++;
continue;
} else errors=0;
initerrors = 0;
- if (!SMSD_CheckSMSStatus(&Config,Service)) {
+ if (!SMSD_CheckSMSStatus(&Config,Service)) { /* read all incoming SMS */
errors++;
continue;
} else errors=0;
+
+ if (Config.resetfrequency > 0 && difftime(time(NULL), lastreset) >= Config.resetfrequency) { /* time for preventive reset */
+ errors = 254; initerrors = -2;
+ continue;
+ }
}
if (!SMSD_SendSMS(&Config,Service)) continue;
}
+ Phone->SetFastSMSSending(&s,false);
GSM_Terminate_SMSD("Stop GAMMU smsd", 0, false, 0);
}
GSM_Error SMSDaemonSendSMS(char *service, char *filename, GSM_MultiSMSMessage *sms)
{
GSM_SMSDService *Service;
GSM_SMSDConfig Config;
if (!strcmp(service,"FILES")) {
Service = &SMSDFiles;
#ifdef HAVE_MYSQL_MYSQL_H
} else if (!strcmp(service,"MYSQL")) {
Service = &SMSDMySQL;
#endif
} else {
fprintf(stderr,"Unknown service type (\"%s\")\n",service);
exit(-1);
}
- SMSD_ReadConfig(filename, &Config, false);
+ SMSD_ReadConfig(filename, &Config, false, service);
error = Service->Init(&Config);
if (error!=ERR_NONE) return ERR_UNKNOWN;
return Service->CreateOutboxSMS(sms,&Config);
}
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
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 @@
-/* (c) 2002-2003 by Marcin Wiacek and Joergen Thomsen */
+/* (c) 2002-2004 by Marcin Wiacek and Joergen Thomsen */
#include "../../cfg/config.h"
-#undef HAVE_MYSQL_MYSQL_H
+
#ifdef HAVE_MYSQL_MYSQL_H
#ifdef WIN32
# include <mysql.h>
# include <mysqld_error.h>
#else
# include <mysql/mysql.h>
# include <mysql/mysqld_error.h>
#endif
#endif
#include "../../common/service/sms/gsmsms.h"
#include "../../common/service/sms/gsmmulti.h"
#define MAX_RETRIES 1
void SMSDaemon (int argc, char *argv[]);
GSM_Error SMSDaemonSendSMS (char *service, char *filename, GSM_MultiSMSMessage *sms);
typedef struct {
/* general options */
INI_Entry *IncludeNumbers, *ExcludeNumbers;
unsigned int commtimeout, sendtimeout, receivefrequency;
+ unsigned int resetfrequency;
unsigned char *deliveryreport, *logfilename, *PINCode;
+ unsigned char *PhoneID;
/* options for FILES */
unsigned char *inboxpath, *outboxpath, *sentsmspath;
unsigned char *errorsmspath, *inboxformat, *transmitformat;
/* options for MYSQL */
unsigned char *database, *user, *password;
- unsigned char *PC;
+ unsigned char *PC, *skipsmscnumber;
/* private variables required for work */
- unsigned int retries;
+ int relativevalidity;
+ unsigned int retries, currdeliveryreport;
unsigned char SMSID[200], prevSMSID[200];
+ GSM_SMSC SMSC;
#ifdef HAVE_MYSQL_MYSQL_H
MYSQL DB; char DT[20];
#endif
} GSM_SMSDConfig;
+typedef enum {
+ SMSD_SEND_OK = 1,
+ SMSD_SEND_SENDING_ERROR,
+ SMSD_SEND_DELIVERY_PENDING,
+ SMSD_SEND_DELIVERY_FAILED,
+ SMSD_SEND_DELIVERY_OK,
+ SMSD_SEND_DELIVERY_UNKNOWN,
+ SMSD_SEND_ERROR
+} GSM_SMSDSendingError;
+
typedef struct {
GSM_Error (*Init) (GSM_SMSDConfig *Config);
+ GSM_Error (*InitAfterConnect) (GSM_SMSDConfig *Config);
GSM_Error (*SaveInboxSMS) (GSM_MultiSMSMessage sms, GSM_SMSDConfig *Config);
GSM_Error (*FindOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID);
GSM_Error (*MoveSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, bool alwaysDelete, bool sent);
GSM_Error (*CreateOutboxSMS) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config);
- GSM_Error (*AddSentSMSInfo) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, bool OK);
+ GSM_Error (*AddSentSMSInfo) (GSM_MultiSMSMessage *sms, GSM_SMSDConfig *Config, unsigned char *ID, int Part, GSM_SMSDSendingError err, int TPMR);
+ GSM_Error (*RefreshSendStatus) (GSM_SMSDConfig *Config, unsigned char *ID);
+ GSM_Error (*RefreshPhoneStatus) (GSM_SMSDConfig *Config);
} GSM_SMSDService;
#ifdef __GNUC__
__attribute__((format(printf, 1, 2)))
#endif
void WriteSMSDLog(char *format, ...);
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index c67dc6a..16c5880 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -351,65 +351,65 @@ ulong PhoneFormat::getCsum( const QStringList & attList)
int j,k,i;
int add;
for ( i = 0; i < max ; ++i ) {
QString s = attList[i];
if ( ! s.isEmpty() ){
j = s.length();
for ( k = 0; k < j; ++k ) {
int mul = k +1;
add = s[k].unicode ();
if ( k < 16 )
mul = mul * mul;
int ii = i+1;
add = add * mul *ii*ii*ii;
cSum += add;
}
}
}
//QString dump = attList.join(",");
//qDebug("csum: %d %s", cSum,dump.latin1());
return cSum;
}
//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
#include <stdlib.h>
#define DEBUGMODE false
bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
{
QString fileName;
#ifdef _WIN32_
- fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
+ fileName = locateLocal("tmp", "tempfile.vcs")
#else
fileName = "/tmp/kdepimtemp.vcs";
#endif
#ifdef DESKTOP_VERSION
QString command ="./kammu --backup " + fileName + " -yes" ;
#else
QString command ="kammu --backup " + fileName + " -yes" ;
#endif
int ret = system ( command.latin1() );
if ( ret != 0 ) {
qDebug("Error::command returned %d", ret);
return false;
}
VCalFormat vfload;
vfload.setLocalTime ( true );
qDebug("loading file ...");
if ( ! vfload.load( calendar, fileName ) )
return false;
QPtrList<Event> er = calendar->rawEvents();
Event* ev = er.first();
qDebug("reading events... ");
while ( ev ) {
QStringList cat = ev->categories();
if ( cat.contains( "MeetingDEF" )) {
ev->setCategories( QStringList() );
}
int id = ev->pilotId();
Event *event;
event = existingCal->event( mProfileName ,QString::number( id ) );
if ( event ) {
event = (Event*)event->clone();
@@ -555,65 +555,65 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
}
#include <qcstring.h>
void PhoneFormat::afterSave( Incidence* inc)
{
uint csum;
inc->removeID( mProfileName );
if ( inc->type() == "Event")
csum = PhoneFormat::getCsumEvent( (Event*) inc );
else
csum = PhoneFormat::getCsumTodo( (Todo*) inc );
inc->setCsum( mProfileName, QString::number( csum ));
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
}
bool PhoneFormat::save( Calendar *calendar)
{
QLabel status ( i18n(" Opening device ..."), 0 );
int w = status.sizeHint().width()+20 ;
if ( w < 200 ) w = 230;
int h = status.sizeHint().height()+20 ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
status.setCaption(i18n("Writing to phone...") );
status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
status.show();
status.raise();
qApp->processEvents();
QString message;
#ifdef _WIN32_
- QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
+ QString fileName = locateLocal("tmp", "tempfile.vcs")
#else
QString fileName = "/tmp/kdepimtemp.vcs";
#endif
// 1 remove events which should be deleted
QPtrList<Event> er = calendar->rawEvents();
Event* ev = er.first();
while ( ev ) {
if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteEvent( ev );
} else {
}
ev = er.next();
}
// 2 remove todos which should be deleted
QPtrList<Todo> tl = calendar->rawTodos();
Todo* to = tl.first();
while ( to ) {
if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
calendar->deleteTodo( to );
} else {
if ( to->isCompleted()) {
calendar->deleteTodo( to );
}
}
to = tl.next();
}
// 3 save file
VCalFormat vfsave;
vfsave.setLocalTime ( true );
if ( ! vfsave.save( calendar, fileName ) )