34 files changed, 1065 insertions, 116 deletions
diff --git a/gammu/emb/common/common.pro b/gammu/emb/common/common.pro index 797199b..af45382 100644 --- a/gammu/emb/common/common.pro +++ b/gammu/emb/common/common.pro @@ -1,188 +1,194 @@ ###################################################################### # Automatically generated by qmake (1.07a) Fri Jul 30 22:13:34 2004 ###################################################################### TEMPLATE = lib DEPENDPATH += device \ misc \ phone \ protocol \ service \ device/bluetoth \ device/irda \ device/serial \ misc/coding \ phone/alcatel \ phone/at \ phone/nokia \ phone/obex \ phone/symbian \ protocol/alcatel \ protocol/at \ protocol/nokia \ protocol/obex \ protocol/symbian \ service/backup \ service/sms \ phone/nokia/dct3 \ phone/nokia/dct4 INCLUDEPATH += . \ misc/coding \ misc \ device \ phone/nokia/dct4 \ phone/nokia/dct3 \ phone/at \ phone/alcatel \ phone/obex \ phone/symbian \ protocol \ protocol/nokia \ protocol/at \ protocol/alcatel \ protocol/obex \ protocol/symbian \ device/serial \ device/irda \ device/bluetoth \ service \ service/sms \ service/backup \ phone/nokia \ phone # Input HEADERS += config.h \ gammu.h \ gsmcomon.h \ gsmstate.h \ device/devfunc.h \ misc/cfg.h \ misc/misc.h \ phone/pfunc.h \ protocol/protocol.h \ service/gsmcal.h \ service/gsmcall.h \ service/gsmdata.h \ service/gsmlogo.h \ service/gsmmisc.h \ service/gsmnet.h \ service/gsmpbk.h \ service/gsmprof.h \ service/gsmring.h \ device/bluetoth/affix.h \ - device/bluetoth/blue_w32.h \ device/bluetoth/bluetoth.h \ device/bluetoth/bluez.h \ device/irda/irda.h \ - device/irda/irda_unx.h \ - device/irda/irda_w32.h \ device/serial/ser_djg.h \ - device/serial/ser_unx.h \ - device/serial/ser_w32.h \ misc/coding/coding.h \ misc/coding/md5.h \ phone/alcatel/alcatel.h \ phone/at/atgen.h \ phone/nokia/ncommon.h \ phone/nokia/nfunc.h \ phone/nokia/nfuncold.h \ phone/obex/obexgen.h \ phone/symbian/mroutgen.h \ protocol/alcatel/alcabus.h \ protocol/at/at.h \ protocol/nokia/fbus2.h \ protocol/nokia/mbus2.h \ protocol/nokia/phonet.h \ protocol/obex/obex.h \ protocol/symbian/mrouter.h \ service/backup/backgen.h \ service/backup/backics.h \ service/backup/backldif.h \ service/backup/backlmb.h \ service/backup/backtext.h \ service/backup/backvcf.h \ service/backup/backvcs.h \ service/backup/gsmback.h \ service/sms/gsmems.h \ service/sms/gsmmulti.h \ service/sms/gsmsms.h \ phone/nokia/dct3/dct3comm.h \ phone/nokia/dct3/dct3func.h \ phone/nokia/dct3/n6110.h \ phone/nokia/dct3/n7110.h \ + phone/nokia/dct3/n0650.h \ phone/nokia/dct3/n9210.h \ phone/nokia/dct4/dct4func.h \ phone/nokia/dct4/n3320.h \ phone/nokia/dct4/n3650.h \ phone/nokia/dct4/n6510.h SOURCES +=gsmcomon.c \ gsmstate.c \ misc/misc.c \ misc/cfg.c \ misc/coding/coding.c \ misc/coding/md5.c \ service/sms/gsmsms.c \ 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/n0650.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 +HEADERS += device/serial/ser_unx.h \ + device/irda/irda_unx.h + +SOURCES += device/serial/ser_unx.c \ + } win32:{ -SOURCES += device/serial/ser_w32.c + +HEADERS += device/serial/ser_w32.h \ + device/irda/irda_w32.h \ + device/bluetoth/blue_w32.h + +SOURCES += device/serial/ser_w32.c \ + device/bluetoth/blue_w32.c } diff --git a/gammu/emb/common/commonE.pro b/gammu/emb/common/commonE.pro index f5b559d..1512814 100644 --- a/gammu/emb/common/commonE.pro +++ b/gammu/emb/common/commonE.pro @@ -1,181 +1,187 @@ ###################################################################### # Automatically generated by qmake (1.07a) Fri Jul 30 22:13:34 2004 ###################################################################### TEMPLATE = lib DEPENDPATH += device \ misc \ phone \ protocol \ service \ device/bluetoth \ device/irda \ device/serial \ misc/coding \ phone/alcatel \ phone/at \ phone/nokia \ phone/obex \ phone/symbian \ protocol/alcatel \ protocol/at \ protocol/nokia \ protocol/obex \ protocol/symbian \ service/backup \ service/sms \ phone/nokia/dct3 \ phone/nokia/dct4 INCLUDEPATH += . \ misc/coding \ misc \ device \ phone/nokia/dct4 \ phone/nokia/dct3 \ phone/at \ phone/alcatel \ phone/obex \ phone/symbian \ protocol \ protocol/nokia \ protocol/at \ protocol/alcatel \ protocol/obex \ protocol/symbian \ device/serial \ device/irda \ device/bluetoth \ service \ service/sms \ service/backup \ phone/nokia \ phone # Input HEADERS += config.h \ gammu.h \ gsmcomon.h \ gsmstate.h \ device/devfunc.h \ misc/cfg.h \ misc/misc.h \ phone/pfunc.h \ protocol/protocol.h \ service/gsmcal.h \ service/gsmcall.h \ service/gsmdata.h \ service/gsmlogo.h \ service/gsmmisc.h \ service/gsmnet.h \ service/gsmpbk.h \ service/gsmprof.h \ service/gsmring.h \ device/bluetoth/affix.h \ - device/bluetoth/blue_w32.h \ device/bluetoth/bluetoth.h \ device/bluetoth/bluez.h \ device/irda/irda.h \ device/irda/irda_unx.h \ - device/irda/irda_w32.h \ device/serial/ser_djg.h \ device/serial/ser_unx.h \ - device/serial/ser_w32.h \ misc/coding/coding.h \ misc/coding/md5.h \ phone/alcatel/alcatel.h \ phone/at/atgen.h \ phone/nokia/ncommon.h \ phone/nokia/nfunc.h \ phone/nokia/nfuncold.h \ phone/obex/obexgen.h \ phone/symbian/mroutgen.h \ protocol/alcatel/alcabus.h \ protocol/at/at.h \ protocol/nokia/fbus2.h \ protocol/nokia/mbus2.h \ protocol/nokia/phonet.h \ protocol/obex/obex.h \ protocol/symbian/mrouter.h \ service/backup/backgen.h \ service/backup/backics.h \ service/backup/backldif.h \ service/backup/backlmb.h \ service/backup/backtext.h \ service/backup/backvcf.h \ service/backup/backvcs.h \ service/backup/gsmback.h \ service/sms/gsmems.h \ service/sms/gsmmulti.h \ service/sms/gsmsms.h \ phone/nokia/dct3/dct3comm.h \ phone/nokia/dct3/dct3func.h \ phone/nokia/dct3/n6110.h \ phone/nokia/dct3/n7110.h \ phone/nokia/dct3/n9210.h \ phone/nokia/dct4/dct4func.h \ phone/nokia/dct4/n3320.h \ + phone/nokia/dct3/n0650.h \ phone/nokia/dct4/n3650.h \ phone/nokia/dct4/n6510.h SOURCES +=gsmcomon.c \ gsmstate.c \ misc/misc.c \ misc/cfg.c \ misc/coding/coding.c \ misc/coding/md5.c \ service/sms/gsmsms.c \ 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_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/dct3/n0650.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 + + + + + # device/bluetoth/blue_w32.h \ + # device/irda/irda_w32.h \ + # device/serial/ser_w32.h \ + # device/bluetoth/blue_w32.c \
\ No newline at end of file diff --git a/gammu/emb/common/device/serial/ser_djg.c b/gammu/emb/common/device/serial/ser_djg.c index 2524187..609deb8 100644 --- a/gammu/emb/common/device/serial/ser_djg.c +++ b/gammu/emb/common/device/serial/ser_djg.c @@ -1,74 +1,443 @@ +/* Some sources from SVAsync (c) 1996, 1997, Samuel Vincent + * 7337 Carioca Ct, Rohnert Park, Ca 94928 + * "you may freely use it in your programs without paying me anything" + */ +/* Some sources from DZCOMM */ #include "../../gsmstate.h" #ifdef GSM_ENABLE_SERIALDEVICE #ifdef DJGPP #include "../../gsmcomon.h" +#include "../../misc/coding/coding.h" #include "ser_djg.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <dos.h> +#include <dpmi.h> +#include <pc.h> +#include <go32.h> +#include <sys/farptr.h> +#include <sys/movedata.h> +#include <conio.h> + +extern unsigned short __djgpp_ds_alias; +extern void SVAsyncProtISR(void); + +static unsigned char SVAsyncStatus=0; + +static void lock_interrupt_memory(void); +static void unlock_interrupt_memory(void); + +#define Ctrl8259_0 0x020 /* 8259 port */ +#define Ctrl8259_1 0x021 /* 8259 port (Masks) */ +#define BufSize 32768 /* Buffer Size */ + +static unsigned char VectorNum; /* Vector Number */ +static unsigned char EnableIRQ; /* Mask to enable 8259 IRQ */ +static unsigned char DisableIRQ; /* Mask to disable 8259 IRQ */ +static _go32_dpmi_seginfo ProtVector; /* Old Protmode Vector */ +static _go32_dpmi_seginfo info; /* New Protmode Vector */ + +/* Register Addresses for the UART */ +static unsigned short Port; /* Port Base Address */ +unsigned short THR; /* Transmitter Holding Register */ +unsigned short RDR; /* Reciever Data Register */ +unsigned short BRDL; /* Baud Rate Divisor, Low byte */ +unsigned short BRDH; /* Baud Rate Divisor, High Byte */ +unsigned short IER; /* Interupt Enable Register */ +unsigned short IIR; /* Interupt Identification Register */ +unsigned short FCR; /* FIFO Control Register */ +unsigned short LCR; /* Line Control Register */ +unsigned short MCR; /* Modem Control Register */ +unsigned short LSR; /* Line Status Register */ +unsigned short MSR; /* Modem Status Register */ +unsigned short SCR; /* SCR Register */ + +/* Data Buffer */ +unsigned volatile char RecBuffer[BufSize] = { 0 }; +unsigned volatile int RecHead, RecTail; + +/* This uninstalls the ISR and resets the serial port. */ +static void SVAsyncStop(void) +{ + if(!SVAsyncStatus) return; + SVAsyncStatus = 0; + + /***** Mask (disable) 8259 IRQ Interrupt */ + outportb(Ctrl8259_1, (inportb(Ctrl8259_1) | DisableIRQ)); + + /***** Disable 8250 interrupt */ + outportb(LCR, (inportb(LCR) & 0x7F)); + outportb(IER, 0); + + /***** Set bit 3 in MCR to 0 */ + outportb(MCR, (inportb(MCR) & 0xF7)); + + /***** Interrupts are disabled. Restore saved interrupt vector. */ + _go32_dpmi_set_protected_mode_interrupt_vector(VectorNum, &ProtVector); +} + +/* This will empty the receive buffer */ +static void SVAsyncClear(void) +{ + disable(); + RecHead = 0; + RecTail = 0; + enable(); +} + + +/* Sets communication parameters + * Baud = 150, 300, 600, 1200, 2400, 4800, 9600, 19200, 28800, 38400, 57600 + * Control = The value to place in the LCR + */ +void SVAsyncSet(unsigned int Baud, unsigned int Control) +{ + int divisor; + unsigned char divlow, divhigh; + + if (!Baud) return; + + divisor = 115200 / Baud; + + disable(); + + outportb(LCR, Control | 0x80); /* Set Port Toggle to BRDL/BRDH registers */ + divlow = divisor & 0x000000ff; + divhigh = (divisor >> 8) & 0x000000ff; + outportb(BRDL, divlow); /* Set Baud Rate */ + outportb(BRDH, divhigh); + + outportb(LCR, Control & 0x007F); /* Set LCR and Port Toggle */ + + enable(); +} + +/* Sets various handshaking lines */ +void SVAsyncHand(unsigned int Hand) +{ + outportb(MCR, Hand | 0x08); /* Keep interrupt enable ON */ +} + +static void lock_interrupt_memory(void) +{ + int errval; + __dpmi_meminfo info; + unsigned long address; + + __dpmi_get_segment_base_address(_my_ds(), &address); + + info.address = (int) address + (int) &RDR; + info.size = sizeof(RDR); + errval = __dpmi_lock_linear_region(&info); + if(errval == -1) printf("Error in locking memory\n!"); + + info.address = (int) address + (int) &LSR; + info.size = sizeof(LSR); + errval = __dpmi_lock_linear_region(&info); + if(errval == -1) printf("Error in locking memory\n!"); + + info.address = (int) address + (int) &RecHead; + info.size = sizeof(RecHead); + errval = __dpmi_lock_linear_region(&info); + if(errval == -1) printf("Error in locking memory\n!"); + + info.address = (int) address + (int) &RecBuffer; + info.size = sizeof(RecBuffer); + errval = __dpmi_lock_linear_region(&info); + if(errval == -1) printf("Error in locking memory\n!"); + + info.address = (int) address + (int) RecBuffer; + info.size = BufSize; + errval = __dpmi_lock_linear_region(&info); + if(errval == -1) printf("Error in locking memory\n!"); + + __dpmi_get_segment_base_address(_my_cs(), &address); + + info.address = (int) address + (int) SVAsyncProtISR; + info.size = 4096; /* 4096 bytes is probably overkill. */ + errval = __dpmi_lock_linear_region(&info); + if(errval == -1) printf("Error in locking memory\n!"); +} + +static void unlock_interrupt_memory(void) +{ + __dpmi_meminfo info; + unsigned long address; + + __dpmi_get_segment_base_address(_my_ds(), &address); + info.address = (int) address + (int) &RDR; + info.size = sizeof(RDR); + __dpmi_unlock_linear_region(&info); + info.address = (int) address + (int) &LSR; + info.size = sizeof(LSR); + __dpmi_unlock_linear_region(&info); + info.address = (int) address + (int) &RecHead; + info.size = sizeof(RecHead); + __dpmi_unlock_linear_region(&info); + info.address = (int) address + (int) &RecBuffer; + info.size = sizeof(RecBuffer); + __dpmi_unlock_linear_region(&info); + info.address = (int) address + (int) RecBuffer; + info.size = BufSize; + __dpmi_unlock_linear_region(&info); + + __dpmi_get_segment_base_address(_my_cs(), &address); + + info.address = (int) address + (int) SVAsyncProtISR; + info.size = 4096; /* probably overkill */ + __dpmi_unlock_linear_region(&info); +} + static GSM_Error serial_close(GSM_StateMachine *s) { - GSM_Device_SerialData *d = &s->Device.Data.Serial; + SVAsyncStop(); - return ERR_NOTIMPLEMENTED; + return ERR_NONE; } static GSM_Error serial_open (GSM_StateMachine *s) { - GSM_Device_SerialData *d = &s->Device.Data.Serial; - - return ERR_NOTIMPLEMENTED; + GSM_Device_SerialData *d = &s->Device.Data.Serial; + unsigned char temp; + int i; + + /**** Set various things according to com port number */ + if (mystrncasecmp(s->CurrentConfig->Device,"com1:",0)) { + Port = 0x03F8; + VectorNum = 0x0C; + EnableIRQ = 0xEF; + DisableIRQ = 0x10; + } else if (mystrncasecmp(s->CurrentConfig->Device,"com2:",0)) { + Port = 0x02F8; + VectorNum = 0x0B; + EnableIRQ = 0xF7; + DisableIRQ = 0x08; + } else if (mystrncasecmp(s->CurrentConfig->Device,"com3:",0)) { + Port = 0x03E8; + VectorNum = 0x0C; + EnableIRQ = 0xEF; + DisableIRQ = 0x10; + } else if (mystrncasecmp(s->CurrentConfig->Device,"com4:",0)) { + Port = 0x02E8; + VectorNum = 0x0B; + EnableIRQ = 0xF7; + DisableIRQ = 0x08; + } else return ERR_NOTSUPPORTED; + + /**** Compute Register locations */ + THR = Port; + RDR = Port; + BRDL = Port; + BRDH = 1 + Port; + IER = 1 + Port; + IIR = 2 + Port; + FCR = 2 + Port; + LCR = 3 + Port; + MCR = 4 + Port; + LSR = 5 + Port; + MSR = 6 + Port; + SCR = 7 + Port; + + /***** Initalize Buffer */ + SVAsyncClear(); + + lock_interrupt_memory(); + atexit(unlock_interrupt_memory); + /***** Set bit 3 in MCR to 0 */ + outportb(MCR, (inportb(MCR) & 0xF7)); + + /*** Save and reassign interrupt vectors */ + + _go32_dpmi_get_protected_mode_interrupt_vector(VectorNum, &ProtVector); + + info.pm_offset = (int) SVAsyncProtISR; + info.pm_selector = _my_cs(); + _go32_dpmi_set_protected_mode_interrupt_vector(VectorNum, &info); + + atexit(SVAsyncStop); + + /***** Enable 8259 interrupt (IRQ) line for this async adapter */ + outportb(Ctrl8259_1, (inportb(Ctrl8259_1) & EnableIRQ)); + + /***** Enable 8250 Interrupt-on-data-ready */ + outportb(LCR, (inportb(LCR) & 0x7F)); + + outportb(IER, 0); + if (inportb(IER)) { + SVAsyncStatus = 0; + return ERR_UNKNOWN; + } + outportb(IER, 0x01); + + /***** Clear 8250 Status and data registers */ + do { + temp=inportb(RDR); + temp=inportb(LSR); + temp=inportb(MSR); + temp=inportb(IIR); + } while(!(temp & 1)); + + /***** Set Bit 3 of MCR -- Enable interupts */ + outportb(MCR, (inportb(MCR) | 0x08)); + + SVAsyncStatus = 1; + /***** Clear Buffer Just in case */ + SVAsyncClear(); + + /* Code based on stuff from SVAsync lib. + * Clear UART Status and data registers + * setting up FIFO if possible + */ + outportb(SCR, 0x55); + if (inportb(SCR) == 0x55) { + /* On the off chance that SCR is actually hardwired to 0x55, + * do the same check with a different value. + */ + outportb(SCR, 0xAA); + if (inportb(SCR) == 0xAA) { + /* The chip is better than an 8250 - it has a scratch pad */ + outportb(SCR, i); /* Set SCR back to what it was before */ + inportb(SCR); /* Give slow motherboards a chance */ + + /* Is there a FIFO ? - go through twice for slow motherboards */ + outportb(FCR, 0x01); + i = inportb(FCR); + outportb(FCR, 0x01); + i = inportb(FCR); + + /* Some old stuff relies on this (no idea why) */ + outportb(FCR, 0x00); + inportb(FCR); /* Give slow motherboards a chance */ + + if ((i&0x80) == 0) { + smprintf(s,"UART 16450 or UART 8250 with scratch pad\n"); + } else if ((i&0x40) == 0) { + smprintf(s,"UART 16550 - broken FIFO\n"); + } else { + /* It's a 16450A series : try and start the FIFO. + * It appears that some chips need a two call protocol, but + * those that don't seem to work even if you do start it + * twice. The first call is simply to start it, the second + * starts it and sets an 8 byte FIFO trigger level. + */ + outportb(FCR, 0x01); + inportb(FCR); /* Give slow motherboards a chance */ + outportb(FCR, 0x87); + inportb(FCR); /* Give slow motherboards a chance */ + + /* Check that the FIFO initialised */ + if ((inportb(IIR) & 0xc0) != 0xc0) { + /* + * It didn't so we assume it isn't there but disable it to + * be on the safe side. + */ + outportb(IIR, 0xfe); + inportb(IIR); /* Give slow motherboards a chance */ + smprintf(s,"UART 16450A - FIFO disabled\n"); + } else { + smprintf(s,"UART 16450A - FIFO enabled\n"); + } + } + } else { + smprintf(s,"UART 8250\n"); + } + } + + d->Control = BITS_8 | STOP_1; + d->Parity = false; + d->Speed = 9600; + SVAsyncSet(d->Speed,d->Control | NO_PARITY); + + return ERR_NONE; } static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) { GSM_Device_SerialData *d = &s->Device.Data.Serial; - return ERR_NOTIMPLEMENTED; + d->Parity = parity; + + if (parity) { + SVAsyncSet(d->Speed, d->Control | ODD_PARITY); + } else { + SVAsyncSet(d->Speed, d->Control | NO_PARITY); + } + + return ERR_NONE; } static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) { - GSM_Device_SerialData *d = &s->Device.Data.Serial; + if (dtr && rts) { + SVAsyncHand(DTR | RTS); + } else if (dtr) { + SVAsyncHand(DTR); + } else if (rts) { + SVAsyncHand(RTS); + } else { + SVAsyncHand(0); + } - return ERR_NOTIMPLEMENTED; + return ERR_NONE; } static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) { GSM_Device_SerialData *d = &s->Device.Data.Serial; - return ERR_NOTIMPLEMENTED; + d->Speed = speed; + + if (d->Parity) { + SVAsyncSet(d->Speed, d->Control | ODD_PARITY); + } else { + SVAsyncSet(d->Speed, d->Control | NO_PARITY); + } + + return ERR_NONE; } -static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) +static int serial_read(GSM_StateMachine *s, char *buf, size_t nbytes) { - GSM_Device_SerialData *d = &s->Device.Data.Serial; + if(RecTail == RecHead) return 0; + + disable(); + buf[0] = RecBuffer[RecTail++]; + if(RecTail >= BufSize) RecTail = 0; + enable(); - return 0; + return 1; } -static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) +static int serial_write(GSM_StateMachine *s, char *buf, size_t nbytes) { - GSM_Device_SerialData *d = &s->Device.Data.Serial; + int i; + + for (i=0;i<nbytes;i++) { + while(~inportb(LSR) & 0x20); + outportb(THR, buf[i]); + } - return 0; + return i; } 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_djg.h b/gammu/emb/common/device/serial/ser_djg.h index b35b282..3bb2a5b 100644 --- a/gammu/emb/common/device/serial/ser_djg.h +++ b/gammu/emb/common/device/serial/ser_djg.h @@ -1,15 +1,50 @@ +/* Some sources from SVAsync (c) 1996, 1997, Samuel Vincent + * 7337 Carioca Ct, Rohnert Park, Ca 94928 + * "you may freely use it in your programs without paying me anything" + */ #ifdef DJGPP #ifndef djgppserial_h #define djgppserial_h typedef struct { - int hPhone; + int hPhone; + int Speed; + unsigned int Control; + bool Parity; } GSM_Device_SerialData; +/* Defines for Com Port Paramaters, the second paramater to SVAsyncSet() */ +#define BITS_8 0x03 +#define BITS_7 0x02 +#define STOP_1 0x00 +#define STOP_2 0x04 +#define EVEN_PARITY 0x18 +#define ODD_PARITY 0x08 +#define NO_PARITY 0x00 + +/* Defines for SVAsyncHand() */ +#define DTR 0x01 +#define RTS 0x02 +#define USER 0x04 +#define LOOPBACK 0x10 + +/* Defines for SVAsyncStat() */ +#define D_CTS 0x0100 +#define D_DSR 0x0200 +#define D_RI 0x0400 +#define D_DCD 0x0800 +#define CTS 0x1000 +#define DSR 0x2000 +#define RI 0x4000 +#define DCD 0x8000 +#define PARITY 0x0004 +#define THREMPTY 0x0020 +#define BREAKDET 0x1000 + #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 69c7515..18b5f6f 100644 --- a/gammu/emb/common/device/serial/ser_unx.c +++ b/gammu/emb/common/device/serial/ser_unx.c @@ -1,319 +1,328 @@ /* (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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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; } static GSM_Error serial_open (GSM_StateMachine *s) { GSM_Device_SerialData *d = &s->Device.Data.Serial; - struct termios t; - int i; + 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; } memcpy(&t, &d->old_settings, sizeof(struct termios)); /* Opening without parity */ t.c_iflag = IGNPAR; t.c_oflag = 0; /* disconnect line, 8 bits, enable receiver, * ignore modem lines,lower modem line after disconnect */ t.c_cflag = B0 | CS8 | CREAD | CLOCAL | HUPCL; /* enable hardware (RTS/CTS) flow control (NON POSIX) */ /* t.c_cflag |= CRTSCTS; */ t.c_lflag = 0; t.c_cc[VMIN] = 1; t.c_cc[VTIME] = 0; if (tcsetattr(d->hPhone, TCSANOW, &t) == -1) { serial_close(s); GSM_OSErrorInfo(s,"tcsetattr in serial_open"); return ERR_DEVICEOPENERROR; } /* Making file descriptor asynchronous. */ if (fcntl(d->hPhone, F_SETFL, FASYNC | FNONBLOCK) == -1) { serial_close(s); GSM_OSErrorInfo(s,"fcntl in serial_open"); return ERR_DEVICEOPENERROR; } return ERR_NONE; } static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) { GSM_Device_SerialData *d = &s->Device.Data.Serial; - struct termios t; + struct termios t; if (tcgetattr(d->hPhone, &t)) { GSM_OSErrorInfo(s,"tcgetattr in serial_setparity"); return ERR_DEVICEREADERROR; } if (parity) { t.c_cflag |= (PARENB | PARODD); t.c_iflag = 0; } else { t.c_iflag = IGNPAR; } if (tcsetattr(d->hPhone, TCSANOW, &t) == -1){ serial_close(s); GSM_OSErrorInfo(s,"tcsetattr in serial_setparity"); return ERR_DEVICEPARITYERROR; } return ERR_NONE; } static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) { GSM_Device_SerialData *d = &s->Device.Data.Serial; - struct termios t; - unsigned int flags; + struct termios t; + unsigned int flags; if (tcgetattr(d->hPhone, &t)) { GSM_OSErrorInfo(s,"tcgetattr in serial_setdtrrts"); return ERR_DEVICEREADERROR; } #ifdef CRTSCTS /* Disabling hardware flow control */ t.c_cflag &= ~CRTSCTS; #endif if (tcsetattr(d->hPhone, TCSANOW, &t) == -1) { serial_close(s); GSM_OSErrorInfo(s,"tcsetattr in serial_setdtrrts"); return ERR_DEVICEDTRRTSERROR; } flags = TIOCM_DTR; if (dtr) { ioctl(d->hPhone, TIOCMBIS, &flags); } else { ioctl(d->hPhone, TIOCMBIC, &flags); } flags = TIOCM_RTS; if (rts) { ioctl(d->hPhone, TIOCMBIS, &flags); } else { ioctl(d->hPhone, TIOCMBIC, &flags); } flags = 0; ioctl(d->hPhone, TIOCMGET, &flags); dbgprintf("Serial device:"); dbgprintf(" DTR is %s", flags&TIOCM_DTR?"up":"down"); dbgprintf(", RTS is %s", flags&TIOCM_RTS?"up":"down"); dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down"); dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down"); if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR; if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR; 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_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"); } return actual; } static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) { GSM_Device_SerialData *d = &s->Device.Data.Serial; - int ret; - size_t actual = 0; + int ret; + size_t actual = 0; do { ret = write(d->hPhone, (unsigned char *)buf, nbytes - actual); if (ret < 0 && errno == EAGAIN) continue; if (ret < 0) { if (actual != nbytes) GSM_OSErrorInfo(s,"serial_write"); return actual; } actual += ret; buf += ret; if (s->ConnectionType == GCT_FBUS2PL2303) my_sleep(1); } while (actual < nbytes); return actual; } GSM_Device_Functions SerialDevice = { serial_open, serial_close, serial_setparity, serial_setdtrrts, serial_setspeed, serial_read, serial_write }; #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/serial/ser_w32.c b/gammu/emb/common/device/serial/ser_w32.c index 7d88fc7..a7919fe 100644 --- a/gammu/emb/common/device/serial/ser_w32.c +++ b/gammu/emb/common/device/serial/ser_w32.c @@ -1,102 +1,111 @@ /* (c) 2002-2004 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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 */ if (SetCommState(d->hPhone, &d->old_settings)==0) { GSM_OSErrorInfo(s, "SetCommState in serial_close"); } /* Closes device */ if (CloseHandle(d->hPhone)==0) { GSM_OSErrorInfo(s, "CloseHandle in serial_close"); } return ERR_NONE; } static GSM_Error serial_open (GSM_StateMachine *s) { GSM_Device_SerialData *d = &s->Device.Data.Serial; DCB dcb; unsigned char DeviceName[80],DeviceName2[80]; int i; #ifdef GSM_ENABLE_FBUS2DKU5 HKEY hKey; DWORD DeviceNameLen, KeyNameLen; unsigned char KeyName[100]; #endif strcpy(DeviceName2,s->CurrentConfig->Device); #ifdef GSM_ENABLE_FBUS2DKU5 if (s->ConnectionType == GCT_FBUS2DKU5) { smprintf(s,"Reading DKU5 device\n"); DeviceName2[0] = 0; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { smprintf(s,"Error opening key\n"); return ERR_DEVICENOTWORK; } i = 0; while(1) { DeviceNameLen = 80; KeyNameLen = 100; if (RegEnumValue(hKey,i,KeyName,&KeyNameLen,NULL,NULL,DeviceName2,&DeviceNameLen) != ERROR_SUCCESS) { smprintf(s,"Error reading key value\n"); return ERR_DEVICENOTWORK; } // smprintf(s,"Key name is %s, value is %s\n",KeyName,DeviceName2); if (!strncmp(KeyName,"\\Device\\AtmelVirtualPort",24)) break; i++; } RegCloseKey(hKey); if (strlen(DeviceName2) == 0) return ERR_DEVICENOTWORK; smprintf(s,"DKU5 device is \"%s\"\n",DeviceName2); //nodriver } #endif if ((s->ConnectionType == GCT_FBUS2DKU5) || (!strncmp(DeviceName2,"com",3) && strlen(DeviceName2)>3)) { sprintf(DeviceName,"\\\\.\\COM%i",atoi(DeviceName2+3)); } else { strcpy(DeviceName,DeviceName2); } smprintf(s,"Device is %s\n",DeviceName); /* Allows for reading/writing, no device sharing */ d->hPhone = CreateFile(DeviceName, diff --git a/gammu/emb/common/gsmstate.c b/gammu/emb/common/gsmstate.c index 31e365d..c65dc01 100644 --- a/gammu/emb/common/gsmstate.c +++ b/gammu/emb/common/gsmstate.c @@ -461,193 +461,193 @@ GSM_Error GSM_TerminateConnection(GSM_StateMachine *s) error = s->Device.Functions->CloseDevice(s); if (error!=ERR_NONE) return error; s->Phone.Data.ModelInfo = 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; if (s->LockFile!=NULL) unlock_device(&(s->LockFile)); if (!s->di.use_global && s->di.dl!=0 && fileno(s->di.df) != 1 && fileno(s->di.df) != 2) fclose(s->di.df); s->opened = false; return ERR_NONE; } GSM_Error GSM_WaitForOnce(GSM_StateMachine *s, unsigned char *buffer, int length, unsigned char type, int time) { GSM_Phone_Data *Phone = &s->Phone.Data; GSM_Protocol_Message sentmsg; int i; i=0; do { if (length != 0) { sentmsg.Length = length; sentmsg.Type = type; sentmsg.Buffer = (unsigned char *)malloc(length); memcpy(sentmsg.Buffer,buffer,length); Phone->SentMsg = &sentmsg; } /* Some data received. Reset timer */ if (GSM_ReadDevice(s,true)!=0) i=0; if (length != 0) { free (sentmsg.Buffer); Phone->SentMsg = NULL; } /* Request completed */ if (Phone->RequestID==ID_None) return Phone->DispatchError; i++; } while (i<time); return ERR_TIMEOUT; } GSM_Error GSM_WaitFor (GSM_StateMachine *s, unsigned char *buffer, int length, unsigned char type, int time, GSM_Phone_RequestID request) { GSM_Phone_Data *Phone = &s->Phone.Data; GSM_Error error; int reply; if (mystrncasecmp(s->CurrentConfig->StartInfo,"yes",0)) { if (Phone->StartInfoCounter > 0) { Phone->StartInfoCounter--; 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; +// 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 "); smprintf(s, "type 0x%02X/length 0x%02X/%i", msg->Type, msg->Length, msg->Length); DumpMessage(s->di.use_global ? di.df : s->di.df, s->di.dl, msg->Buffer, msg->Length); if (msg->Length == 0) smprintf(s, "\n"); fflush(s->di.df); } if (s->di.dl==DL_BINARY) { smprintf(s,"%c",0x02); /* Receiving */ smprintf(s,"%c",msg->Type); smprintf(s,"%c",msg->Length/256); smprintf(s,"%c",msg->Length%256); for (i=0;i<msg->Length;i++) { smprintf(s,"%c",msg->Buffer[i]); } } Reply=s->User.UserReplyFunctions; if (Reply!=NULL) error=CheckReplyFunctions(s,Reply,&reply); if (error==ERR_UNKNOWNFRAME) { Reply=s->Phone.Functions->ReplyFunctions; error=CheckReplyFunctions(s,Reply,&reply); } if (error==ERR_NONE) { error=Reply[reply].Function(*msg, s); if (Reply[reply].requestID==Phone->RequestID) { if (error == ERR_NEEDANOTHERANSWER) { error = ERR_NONE; } else { Phone->RequestID=ID_None; } } } if (strcmp(s->Phone.Functions->models,"NAUTO")) { if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTERROR || @@ -777,278 +777,279 @@ bool GSM_ReadConfig(INI_Section *cfg_info, GSM_Config *cfg, int num) cfg->DefaultDebugFile = true; cfg->DefaultDebugLevel = true; cfg->DefaultLockDevice = true; cfg->DefaultStartInfo = true; cfg->UseGlobalDebugFile = DefaultUseGlobalDebugFile; if (cfg_info==NULL) return false; if (num == 0) { sprintf(section,"gammu"); } else { sprintf(section,"gammu%i",num); } for (h = cfg_info; h != NULL; h = h->Next) { if (mystrncasecmp(section, h->SectionName, strlen(section))) { found = true; break; } } if (!found) return false; cfg->Device = INI_GetValue(cfg_info, section, "port", false); if (!cfg->Device) { free(cfg->Device); cfg->Device = strdup(DefaultPort); } else { cfg->DefaultDevice = false; } cfg->Connection = INI_GetValue(cfg_info, section, "connection", false); if (!cfg->Connection) { free(cfg->Connection); cfg->Connection = strdup(DefaultConnection); } else { cfg->DefaultConnection = false; } cfg->SyncTime = INI_GetValue(cfg_info, section, "synchronizetime", false); if (!cfg->SyncTime) { free(cfg->SyncTime); cfg->SyncTime = strdup(DefaultSynchronizeTime); } else { cfg->DefaultSyncTime = false; } cfg->DebugFile = INI_GetValue(cfg_info, section, "logfile", false); if (!cfg->DebugFile) { free(cfg->DebugFile); cfg->DebugFile = strdup(DefaultDebugFile); } else { cfg->DefaultDebugFile = false; } 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}},//fixme {"3100b","RH-50" ,"", {F_PBKTONEGAL,F_PBKSMSLIST,0}},//fixme + {"3105" ,"RH-48" ,"Nokia 3105", {F_PBKTONEGAL,F_PBKSMSLIST,F_VOICETAGS,0}},//fixme {"3108", "RH-6", "Nokia 3108", {0}}, //does it have irda ? {"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}},//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,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,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 + {"6810" ,"RM-2" ,"Nokia 6810", {F_PBKTONEGAL,F_TODO66,F_RADIO,F_PBKSMSLIST,F_NOTES,0}},//quess + {"6820" ,"NHL-9" ,"Nokia 6820", {F_PBKTONEGAL,F_TODO66,F_PBKSMSLIST,F_NOTES,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; diff --git a/gammu/emb/common/gsmstate.h b/gammu/emb/common/gsmstate.h index 2b4806c..6861fbc 100644 --- a/gammu/emb/common/gsmstate.h +++ b/gammu/emb/common/gsmstate.h @@ -285,192 +285,193 @@ typedef struct { * Writes message to device. */ GSM_Error (*WriteMessage) (GSM_StateMachine *s, unsigned char *buffer, int length, unsigned char type); /** * This one is called when character is received from device. */ GSM_Error (*StateMachine) (GSM_StateMachine *s, unsigned char rx_char); /** * Protocol initialisation. */ GSM_Error (*Initialise) (GSM_StateMachine *s); /** * Protocol termination. */ GSM_Error (*Terminate) (GSM_StateMachine *s); } GSM_Protocol_Functions; #ifdef GSM_ENABLE_MBUS2 extern GSM_Protocol_Functions MBUS2Protocol; #endif #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) || defined(GSM_ENABLE_FBUS2PL2303) extern GSM_Protocol_Functions FBUS2Protocol; #endif #if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) extern GSM_Protocol_Functions PHONETProtocol; #endif #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) extern GSM_Protocol_Functions ATProtocol; #endif #ifdef GSM_ENABLE_ALCABUS extern GSM_Protocol_Functions ALCABUSProtocol; #endif #if defined(GSM_ENABLE_IRDAOBEX) || defined(GSM_ENABLE_BLUEOBEX) extern GSM_Protocol_Functions OBEXProtocol; #endif #if defined(GSM_ENABLE_MROUTERBLUE) extern GSM_Protocol_Functions MROUTERProtocol; #endif /** * Structure containing protocol specific data and pointer to protocol * functions - @ref GSM_Protocol_Functions. The data are in a structure, so * you may use more protocols at once and switch between them. */ typedef struct { struct { char fake; #ifdef GSM_ENABLE_MBUS2 GSM_Protocol_MBUS2Data MBUS2; #endif #if defined(GSM_ENABLE_FBUS2) || defined(GSM_ENABLE_FBUS2IRDA) || defined(GSM_ENABLE_FBUS2DLR3) || defined(GSM_ENABLE_FBUS2DKU5) || defined(GSM_ENABLE_FBUS2PL2303) || defined(GSM_ENABLE_FBUS2BLUE) || defined(GSM_ENABLE_BLUEFBUS2) GSM_Protocol_FBUS2Data FBUS2; #endif #if defined(GSM_ENABLE_PHONETBLUE) || defined(GSM_ENABLE_IRDAPHONET) || defined(GSM_ENABLE_BLUEPHONET) GSM_Protocol_PHONETData PHONET; #endif #if defined(GSM_ENABLE_AT) || defined(GSM_ENABLE_BLUEAT) || defined(GSM_ENABLE_IRDAAT) GSM_Protocol_ATData AT; #endif #ifdef GSM_ENABLE_ALCABUS GSM_Protocol_ALCABUSData ALCABUS; #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_SetNote, 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, ID_SetIncomingCB, ID_GetCalendarNotePos, ID_Initialise, 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, @@ -1197,195 +1198,220 @@ typedef struct { */ GSM_Error (*GetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); /** * Changes MMS settings. */ GSM_Error (*SetMMSSettings) (GSM_StateMachine *s, GSM_MultiWAPSettings *settings); /** * Acquires SyncML settings. */ GSM_Error (*GetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings); /** * Changes SyncML settings. */ GSM_Error (*SetSyncMLSettings) (GSM_StateMachine *s, GSM_SyncMLSettings *settings); /** * Acquires chat/presence settings. */ GSM_Error (*GetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings); /** * Changes chat/presence settings. */ GSM_Error (*SetChatSettings) (GSM_StateMachine *s, GSM_ChatSettings *settings); /** * Gets bitmap. */ GSM_Error (*GetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap); /** * Sets bitmap. */ GSM_Error (*SetBitmap) (GSM_StateMachine *s, GSM_Bitmap *Bitmap); /** * Gets status of ToDos (count of used entries). */ GSM_Error (*GetToDoStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status); /** * Reads ToDo from phone. */ GSM_Error (*GetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); /** * Reads ToDo from phone. */ GSM_Error (*GetNextToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start); /** * Sets ToDo in phone. */ GSM_Error (*SetToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); /** * Adds ToDo in phone. */ GSM_Error (*AddToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); /** * Deletes ToDo entry in phone. */ GSM_Error (*DeleteToDo) (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); /** * Deletes all todo entries in phone. */ GSM_Error (*DeleteAllToDo) (GSM_StateMachine *s); /** * Retrieves calendar status (number of used entries). */ GSM_Error (*GetCalendarStatus) (GSM_StateMachine *s, GSM_CalendarStatus *Status); /** * Retrieves calendar entry. */ GSM_Error (*GetCalendar) (GSM_StateMachine *s, GSM_CalendarEntry *Note); /** * 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. + * Retrieves notes status (number of used entries). */ - GSM_Error (*GetNextNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool refresh); + GSM_Error (*GetNotesStatus) (GSM_StateMachine *s, GSM_ToDoStatus *status); + /** + * Retrieves notes entry. + */ + GSM_Error (*GetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); + /** + * Retrieves note entry. This is useful for continuous reading of all + * notes entries. + */ + GSM_Error (*GetNextNote) (GSM_StateMachine *s, GSM_NoteEntry *Note, bool start); + /** + * Sets note entry + */ + GSM_Error (*SetNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); + /** + * Adds note entry. + */ + GSM_Error (*AddNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); + /** + * Deletes note entry. + */ + GSM_Error (*DeleteNote) (GSM_StateMachine *s, GSM_NoteEntry *Note); + /** + * Deletes all notes entries. + */ + GSM_Error (*DeleteAllNotes) (GSM_StateMachine *s); /** * 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 ---------------------------------- */ diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c index 3821f13..b75077f 100644 --- a/gammu/emb/common/phone/alcatel/alcatel.c +++ b/gammu/emb/common/phone/alcatel/alcatel.c @@ -3886,118 +3886,124 @@ GSM_Phone_Functions ALCATELPhone = { NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ ALCATEL_GetSIMIMSI, ALCATEL_GetDateTime, ALCATEL_SetDateTime, ALCATEL_GetAlarm, ALCATEL_SetAlarm, NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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 ba23eb2..a875f0a 100644 --- a/gammu/emb/common/phone/at/atgen.c +++ b/gammu/emb/common/phone/at/atgen.c @@ -603,193 +603,193 @@ GSM_Error ATGEN_GetFirmware(GSM_StateMachine *s) error=ATGEN_GetManufacturer(s); if (error != ERR_NONE) return error; // smprintf(s, "Getting firmware - method 1\n"); // error=GSM_WaitFor (s, "ATI\r", 4, 0x00, 3, ID_GetFirmware); // if (error != ERR_NONE) { smprintf(s, "Getting firmware - method 2\n"); error=GSM_WaitFor (s, "AT+CGMR\r", 8, 0x00, 3, ID_GetFirmware); // } 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, "[Firmware version - \"%s\"]\n",s->Phone.Data.Version); } } return error; } GSM_Error ATGEN_Initialise(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; char buff[2]; Priv->SMSMode = 0; Priv->Manufacturer = 0; Priv->PhoneSMSMemory = 0; Priv->CanSaveSMS = false; Priv->SIMSMSMemory = 0; Priv->SMSMemory = 0; Priv->PBKMemory = 0; Priv->PBKSBNR = 0; Priv->PBKCharset = 0; Priv->UCS2CharsetFailed = false; Priv->NonUCS2CharsetFailed = false; Priv->PBKMemories[0] = 0; Priv->FirstCalendarPos = 0; Priv->NextMemoryEntry = 0; Priv->FirstMemoryEntry = 0; Priv->file.Used = 0; Priv->file.Buffer = NULL; Priv->OBEX = false; Priv->MemorySize = 0; Priv->TextLength = 0; Priv->NumberLength = 0; Priv->ErrorText = NULL; if (s->ConnectionType != GCT_IRDAAT && s->ConnectionType != GCT_BLUEAT) { /* We try to escape AT+CMGS mode, at least Siemens M20 * then needs to get some rest */ smprintf(s, "Escaping SMS mode\n"); error = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00); if (error!=ERR_NONE) return error; /* Grab any possible garbage */ while (s->Device.Functions->ReadDevice(s, buff, 2) > 0) my_sleep(10); } /* When some phones (Alcatel BE5) is first time connected, it needs extra * time to react, sending just AT wakes up the phone and it then can react * to ATE1. We don't need to check whether this fails as it is just to * wake up the phone and does nothing. */ smprintf(s, "Sending simple AT command to wake up some devices\n"); GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame); smprintf(s, "Enabling echo\n"); error = GSM_WaitFor (s, "ATE1\r", 5, 0x00, 3, ID_EnableEcho); if (error != ERR_NONE) return error; smprintf(s, "Enabling CME errors\n"); /* Try numeric errors */ if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { /* Try textual errors */ if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n"); } } error = ATGEN_GetModel(s); if (error != ERR_NONE) return error; if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) { s->Protocol.Data.AT.FastWrite = true; } return error; } GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) { unsigned char req[50]; - if (smsc->Location!=1) return ERR_NOTSUPPORTED; + if (smsc->Location!=1) return ERR_INVALIDLOCATION; 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 = 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, 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; req[9] = 'S'; req[10] = 'M'; req[14] = 'S'; req[15] = 'M'; smprintf(s, "Setting SMS memory type to SM\n"); error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType); if (Priv->SIMSMSMemory == 0 && error == ERR_NONE) { Priv->SIMSMSMemory = AT_AVAILABLE; } if (error == ERR_NOTSUPPORTED) { smprintf(s, "Can't access SIM card?\n"); return ERR_SECURITYERROR; } if (error != ERR_NONE) return error; Priv->SMSMemory = MEM_SM; } else { if (Priv->SMSMemory == MEM_ME) return ERR_NONE; if (Priv->PhoneSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED; req[9] = 'M'; req[10] = 'E'; req[14] = 'M'; req[15] = 'E'; @@ -3746,117 +3746,123 @@ GSM_Phone_Functions ATGENPhone = { NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ ATGEN_GetSIMIMSI, ATGEN_GetDateTime, ATGEN_SetDateTime, ATGEN_GetAlarm, 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 */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c index 8eeb39b..363e043 100644 --- a/gammu/emb/common/phone/at/sonyeric.c +++ b/gammu/emb/common/phone/at/sonyeric.c @@ -1,471 +1,472 @@ /* (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" #include "atgen.h" #include "sonyeric.h" -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) #include "../obex/obexgen.h" +extern GSM_Protocol_Functions OBEXProtocol; 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) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; if (!Priv->OBEX) return ERR_NONE; dbgprintf ("Changing to AT\n"); error = OBEXGEN_Disconnect(s); if (error != ERR_NONE) return error; error = s->Protocol.Functions->Terminate(s); if (error != ERR_NONE) return error; s->Protocol.Functions = &ATProtocol; error = s->Protocol.Functions->Initialise(s); if (error != ERR_NONE) { s->Protocol.Functions = &OBEXProtocol; return error; } strcpy(s->CurrentConfig->Model,"at"); s->Phone.Functions->DispatchMessage = ATGEN_DispatchMessage; s->Phone.Functions->ReplyFunctions = ATGENReplyFunctions; Priv->OBEX = false; return ERR_NONE; } static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName) { GSM_Error error; strcpy(File->ID_FullName,FileName); File->Used = 0; if (File->Buffer != NULL) free(File->Buffer); File->Buffer = NULL; error = SONYERIC_SetOBEXMode(s); if (error != ERR_NONE) return error; error = ERR_NONE; while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File); 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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) { -#ifdef GSM_ENABLE_OBEXGEN +#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) 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 } 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) diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c index 17cd0a4..9810a35 100644 --- a/gammu/emb/common/phone/nokia/dct3/dct3func.c +++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c @@ -1,102 +1,111 @@ /* (c) 2001-2004 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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; return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); } GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; switch (msg.Buffer[2]) { case 0x46: smprintf(s, "Pressing key OK\n"); if (Data->PressKey) return ERR_NONE; break; case 0x47: smprintf(s, "Releasing key OK\n"); if (!Data->PressKey) return ERR_NONE; break; } return ERR_UNKNOWNRESPONSE; } GSM_Error DCT3_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) { unsigned char PressReq[] = {0x00, 0x01, 0x46, 0x00, 0x01, 0x0a}; /* Key code */ unsigned char ReleaseReq[] = {0x00, 0x01, 0x47, 0x00, 0x01, 0x0c}; if (Press) { PressReq[5] = Key; s->Phone.Data.PressKey = true; smprintf(s, "Pressing key\n"); return GSM_WaitFor (s, PressReq, 6, 0xd1, 4, ID_PressKey); } else { s->Phone.Data.PressKey = false; smprintf(s, "Releasing key\n"); return GSM_WaitFor (s, ReleaseReq, 6, 0xd1, 4, ID_PressKey); } } GSM_Error DCT3_ReplyPlayTone(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Tone played\n"); return ERR_NONE; } GSM_Error DCT3_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start) { GSM_Error error; unsigned char req[] = {0x00,0x01,0x8f, 0x00, /* Volume */ 0x00, /* HerzLo */ 0x00}; /* HerzHi */ if (start) { error=DCT3_EnableSecurity (s, 0x01); if (error!=ERR_NONE) return error; } /* For Herz==255*255 we have silent */ if (Herz!=255*255) { req[3]=Volume; req[5]=Herz%256; req[4]=Herz/256; } else { @@ -364,248 +373,248 @@ GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) } GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype) { 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; req[5]=smsc->Location; 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]); + 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]); + sprintf(NetInfo.LAC, "%02X%02X", msg.Buffer[12], msg.Buffer[13]); smprintf(s, "LAC : %s\n", NetInfo.LAC); 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; } if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { if (msg.Buffer[18]==0x00) { /* In 6210 name is in "normal" Unicode */ memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2); Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00; Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00; } else { /* In 9210 first 0x00 is cut from Unicode string */ Data->NetworkInfo->NetworkName[0] = 0; memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2); Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00; Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00; } NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode); - sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); - sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); + sprintf(Data->NetworkInfo->CID, "%02X%02X", msg.Buffer[10], msg.Buffer[11]); + sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg.Buffer[12], msg.Buffer[13]); } } /* 6210/6250/7110 */ if (Data->RequestID==ID_GetBitmap) { if (msg.Buffer[4]==0x02) { smprintf(s, "Operator logo available\n"); count = 7; /* skip network info */ count += msg.Buffer[count]; count ++; Data->Bitmap->BitmapWidth = msg.Buffer[count++]; Data->Bitmap->BitmapHeight = msg.Buffer[count++]; count+=4; PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo,msg.Buffer+count,Data->Bitmap); NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->Bitmap->NetworkCode); } else { Data->Bitmap->BitmapWidth = 78; Data->Bitmap->BitmapHeight = 21; GSM_ClearBitmap(Data->Bitmap); strcpy(Data->Bitmap->NetworkCode,"000 00"); } } return ERR_NONE; } GSM_Error DCT3_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) { unsigned char req[] = {N6110_FRAME_HEADER, 0x70}; s->Phone.Data.NetworkInfo=netinfo; smprintf(s, "Getting network info\n"); return GSM_WaitFor (s, req, 4, 0x0a, 4, ID_GetNetworkInfo); } GSM_Error DCT3_ReplyDialCommand(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Answer for call commands\n"); return ERR_NONE; } GSM_Error DCT3_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) { unsigned int i = 0; GSM_Error error; unsigned char req[100] = {0x00, 0x01, 0x7c, 0x01}; /* call command */ if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED; error=DCT3_EnableSecurity (s, 0x01); if (error!=ERR_NONE) return error; for (i=0; i < strlen(number); i++) req[4+i]=number[i]; req[4+i+1]=0; smprintf(s, "Making voice call\n"); return GSM_WaitFor (s, req, 4+strlen(number)+1, 0x40, 4, ID_DialVoice); } static GSM_Error DCT3_CancelAllCalls(GSM_StateMachine *s) { GSM_Error error; unsigned char req[] = {0x00, 0x01, 0x7c, 0x03}; /* call command */ error=DCT3_EnableSecurity (s, 0x01); if (error!=ERR_NONE) return error; smprintf(s, "Canceling calls\n"); return GSM_WaitFor (s, req, 4, 0x40, 4, ID_CancelCall); } GSM_Error DCT3_CancelCall(GSM_StateMachine *s, int ID, bool all) { if (!all) return DCT3DCT4_CancelCall(s,ID); return DCT3_CancelAllCalls(s); } GSM_Error DCT3_AnswerAllCalls(GSM_StateMachine *s) { GSM_Error error; unsigned char req[] = {0x00, 0x01, 0x7c, 0x02}; /* call command */ error=DCT3_EnableSecurity (s, 0x01); if (error!=ERR_NONE) return error; smprintf(s, "Answering calls\n"); return GSM_WaitFor (s, req, 4, 0x40, 4, ID_AnswerCall); } GSM_Error DCT3_Reset(GSM_StateMachine *s, bool hard) { GSM_Error error; if (hard) { diff --git a/gammu/emb/common/phone/nokia/dct3/n0650.c b/gammu/emb/common/phone/nokia/dct3/n0650.c new file mode 100644 index 0000000..3899a16 --- a/dev/null +++ b/gammu/emb/common/phone/nokia/dct3/n0650.c @@ -0,0 +1,150 @@ +/* (c) 2004 by Marcin Wiacek */ + +#include <string.h> +#include <time.h> + +#include "../../../gsmcomon.h" +#include "../../../gsmstate.h" +#include "../nfunc.h" + +#ifdef GSM_ENABLE_NOKIA650 + +static GSM_Reply_Function N650ReplyFunctions[] = { + {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetModel }, + {DCT3DCT4_ReplyGetModelFirmware,"\xD2",0x02,0x00,ID_GetFirmware }, + + {NULL, "\x00",0x00,0x00,ID_None } +}; + +GSM_Phone_Functions N650Phone = { + "0650", + N650ReplyFunctions, + NONEFUNCTION, /* Initialise */ + NONEFUNCTION, /* Terminate */ + GSM_DispatchMessage, + NOTSUPPORTED, /* ShowStartInfo */ + NOKIA_GetManufacturer, + DCT3DCT4_GetModel, + DCT3DCT4_GetFirmware, + NOTSUPPORTED, /* GetIMEI */ + NOTSUPPORTED, /* GetOriginalIMEI */ + NOTSUPPORTED, /* GetManufactureMonth */ + NOTSUPPORTED, /* GetProductCode */ + NOTSUPPORTED, /* GetHardware */ + NOTSUPPORTED, /* GetPPM */ + NOTSUPPORTED, /* GetSIMIMSI */ + NOTSUPPORTED, /* GetDateTime */ + NOTSUPPORTED, /* SetDateTime */ + NOTSUPPORTED, /* GetAlarm */ + NOTSUPPORTED, /* SetAlarm */ + NOTSUPPORTED, /* GetLocale */ + 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, /* 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, /* SendSMSMessage */ + NOTSUPPORTED, /* SendSavedSMS */ + 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, /* 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ + 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/dct3/n0650.h b/gammu/emb/common/phone/nokia/dct3/n0650.h new file mode 100644 index 0000000..be491eb --- a/dev/null +++ b/gammu/emb/common/phone/nokia/dct3/n0650.h @@ -0,0 +1,18 @@ +/* (c) 2004 by Marcin Wiacek */ + +#ifndef n650_h +#define n650_h + +typedef struct { + int fake; +} GSM_Phone_N650Data; + +#ifndef GSM_USED_MBUS2 +# define GSM_USED_MBUS2 +#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/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c index dac6c12..c3ddfb6 100644 --- a/gammu/emb/common/phone/nokia/dct3/n6110.c +++ b/gammu/emb/common/phone/nokia/dct3/n6110.c @@ -1,102 +1,111 @@ /* (c) 2001-2004 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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; smprintf(s, "Phone language is %02x\n",msg.Buffer[6]); switch (msg.Buffer[6]) { case 0x21: lang = N6110_Europe; break; //Polish } s->Phone.Data.Priv.N6110.PhoneLanguage = lang; return ERR_NONE; } static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s) { unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01, 0x00, /* Profile location */ 0x00}; /* Feature number */ s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto; feat_req[5] = 0; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) { feat_req[6] = 0x1E; } else { feat_req[6] = 0x21; } smprintf(s, "Getting profile feature\n"); return GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetLanguage); } struct N6110_Lang_Char { N6110_Language Lang; unsigned char Phone; unsigned char Unicode1; unsigned char Unicode2; }; static struct N6110_Lang_Char N6110_Lang_Table[] = { {N6110_Europe,0x13,0x01,0x04},//Latin capital letter a with ogonek {N6110_Europe,0x14,0x01,0x05},//Latin small letter a with ogonek {N6110_Europe,0x15,0x01,0x06},//Latin capital letter c with acute {N6110_Europe,0x17,0x01,0x07},//Latin small letter c with acute {N6110_Europe,0x1D,0x01,0x18},//Latin capital letter e with ogonek {N6110_Europe,0x1E,0x01,0x19},//Latin small letter e with ogonek {N6110_Europe,0x83,0x00,0xD3},//Latin capital letter o with acute {N6110_Europe,0x8E,0x01,0x41},//Latin capital letter l with stroke {N6110_Europe,0x90,0x01,0x42},//Latin small letter l with stroke {N6110_Europe,0x92,0x01,0x43},//Latin capital letter n with acute {N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute {N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute {N6110_Europe,0xB2,0x20,0xAC},//euro {N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute {N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute {N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute {N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute {N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above {N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above {0,0,0,0} }; static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len) { int i_len = 0, o_len, i; wchar_t wc; GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; bool found; @@ -2775,117 +2784,123 @@ GSM_Phone_Functions N6110Phone = { DCT3_GetHardware, DCT3_GetPPM, NOTSUPPORTED, /* GetSIMIMSI */ N6110_GetDateTime, N6110_SetDateTime, N6110_GetAlarm, N6110_SetAlarm, NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ 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, /* GetNextNote */ + NOTSUPPORTED, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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 b597f9b..a8e0545 100644 --- a/gammu/emb/common/phone/nokia/dct3/n7110.c +++ b/gammu/emb/common/phone/nokia/dct3/n7110.c @@ -1,101 +1,110 @@ /* (c) 2001-2004 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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"); switch (msg.Buffer[6]) { case 0x0f: return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); default: return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false); } return ERR_UNKNOWN; } static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) { unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 0x02, /* memory type */ 0x05, 0x00, 0x00, /* location */ 0x00, 0x00}; req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[9]==0xff) return ERR_NOTSUPPORTED; if (entry->Location==0x00) return ERR_INVALIDLOCATION; req[10] = entry->Location / 256; req[11] = entry->Location % 256; s->Phone.Data.Memory=entry; smprintf(s, "Getting phonebook entry\n"); return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory); } static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Memory status received\n"); /* Quess ;-)) */ if (msg.Buffer[10]==0x10) { Data->MemoryStatus->MemoryFree = msg.Buffer[14]*256 + msg.Buffer[15]; } else { Data->MemoryStatus->MemoryFree = msg.Buffer[18]; } smprintf(s, " Size : %i\n",Data->MemoryStatus->MemoryFree); Data->MemoryStatus->MemoryUsed = msg.Buffer[16]*256 + msg.Buffer[17]; smprintf(s, " Used : %i\n",Data->MemoryStatus->MemoryUsed); Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; smprintf(s, " Free : %i\n",Data->MemoryStatus->MemoryFree); return ERR_NONE; } static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) { unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 0x05}; /* Memory type */ req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); if (req[5]==0xff) return ERR_NOTSUPPORTED; s->Phone.Data.MemoryStatus=Status; smprintf(s, "Getting memory status\n"); return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus); } static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location) { @@ -1613,117 +1622,123 @@ GSM_Phone_Functions N7110Phone = { DCT3_GetHardware, DCT3_GetPPM, NOTSUPPORTED, /* GetSIMIMSI */ N71_92_GetDateTime, N71_92_SetDateTime, N7110_GetAlarm, N7110_SetAlarm, NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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 ff71ad3..f535c2a 100644 --- a/gammu/emb/common/phone/nokia/dct3/n9210.c +++ b/gammu/emb/common/phone/nokia/dct3/n9210.c @@ -281,117 +281,123 @@ GSM_Phone_Functions N9210Phone = { DCT3_GetHardware, DCT3_GetPPM, NOTSUPPORTED, /* GetSIMIMSI */ N71_92_GetDateTime, N71_92_SetDateTime, NOTIMPLEMENTED, /* GetAlarm */ NOTIMPLEMENTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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 9b1d6cd..9dd9ffb 100644 --- a/gammu/emb/common/phone/nokia/dct4/n3320.c +++ b/gammu/emb/common/phone/nokia/dct4/n3320.c @@ -156,117 +156,123 @@ GSM_Phone_Functions N3320Phone = { NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ N3320_GetDateTime, NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ 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, /* 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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 d4746a7..f1fa826 100644 --- a/gammu/emb/common/phone/nokia/dct4/n3650.c +++ b/gammu/emb/common/phone/nokia/dct4/n3650.c @@ -277,117 +277,123 @@ GSM_Phone_Functions N3650Phone = { DCT4_GetHardware, NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ NOTSUPPORTED, /* GetDateTime */ NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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 2208def..c481863 100644 --- a/gammu/emb/common/phone/nokia/dct4/n6510.c +++ b/gammu/emb/common/phone/nokia/dct4/n6510.c @@ -1,102 +1,111 @@ /* (c) 2002-2004 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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); default: return N71_65_DecodePhonebook(s, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,false); } return ERR_UNKNOWN; } static GSM_Error N6510_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) { unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 0xfe, 0x10, /* memory type */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* location */ 0x00, 0x00, 0x01}; req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[9]==0xff) return ERR_NOTSUPPORTED; if (entry->Location==0x00) return ERR_INVALIDLOCATION; req[14] = entry->Location / 256; req[15] = entry->Location % 256; s->Phone.Data.Memory=entry; smprintf(s, "Getting phonebook entry\n"); return GSM_WaitFor (s, req, 19, 0x03, 4, ID_GetMemory); } static GSM_Error N6510_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Memory status received\n"); /* Quess ;-)) */ if (msg.Buffer[14]==0x10) { Data->MemoryStatus->MemoryFree = msg.Buffer[18]*256 + msg.Buffer[19]; } else { Data->MemoryStatus->MemoryFree = msg.Buffer[17]; } smprintf(s, "Size : %i\n",Data->MemoryStatus->MemoryFree); Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21]; smprintf(s, "Used : %i\n",Data->MemoryStatus->MemoryUsed); Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; smprintf(s, "Free : %i\n",Data->MemoryStatus->MemoryFree); return ERR_NONE; } static GSM_Error N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) { unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 0x00, /* memory type */ 0x55, 0x55, 0x55, 0x00}; req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); if (req[5]==0xff) return ERR_NOTSUPPORTED; 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; @@ -193,219 +202,219 @@ static GSM_Error N6510_ReplySetSMSC(GSM_Protocol_Message msg, GSM_StateMachine * return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) { int count = 13,i; unsigned char req[256] = {N6110_FRAME_HEADER, 0x12, 0x55, 0x01, 0x0B, 0x34, 0x05, /* Location */ 0x00, 0x00, /* Format */ 0x00, 0xFF}; /* Validity */ req[8] = smsc->Location; switch (smsc->Format) { case SMS_FORMAT_Text: req[10] = 0x00; break; case SMS_FORMAT_Fax: req[10] = 0x22; break; case SMS_FORMAT_Pager: req[10] = 0x26; break; case SMS_FORMAT_Email: req[10] = 0x32; break; } req[12] = smsc->Validity.Relative; /* We have now blocks. Number of blocks = 3 */ req[count++] = 0x03; /* -------------- SMSC number ----------------- */ /* Block type: number */ req[count++] = 0x82; /* Offset to next block */ req[count++] = 0x1A; /* Type of number: SMSC number */ req[count++] = 0x02; req[count] = GSM_PackSemiOctetNumber(smsc->Number, req+count+2, false) + 1; if (req[count]>18) { smprintf(s, "Too long SMSC number in frame\n"); return ERR_UNKNOWN; } req[count+1] = req[count] - 1; count += 23; /* --------------- Default number ------------- */ /* Block type: number */ req[count++] = 0x82; /* Offset to next block */ req[count++] = 0x14; /* Type of number: default number */ req[count++] = 0x01; req[count] = GSM_PackSemiOctetNumber(smsc->DefaultNumber, req+count+2, true) + 1; if (req[count]*2>12) { smprintf(s, "Too long SMSC number in frame\n"); return ERR_UNKNOWN; } req[count+1] = req[count] - 1; count += 17; /* -------------- SMSC name ------------------- */ req[count++] = 0x81; req[count++] = UnicodeLength(smsc->Name)*2 + 2 + 4; req[count++] = UnicodeLength(smsc->Name)*2 + 2; req[count++] = 0x00; /* Can't make CopyUnicodeString(req+count,sms->Name) !!!! * with MSVC6 count is changed then */ i = count; CopyUnicodeString(req+i,smsc->Name); count += UnicodeLength(smsc->Name)*2 + 2; smprintf(s, "Setting SMSC\n"); return GSM_WaitFor (s, req, count, 0x02, 4, ID_SetSMSC); } static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { int current = msg.Buffer[7]+7, tmp; GSM_Phone_Data *Data = &s->Phone.Data; #ifdef DEBUG char name[100]; GSM_NetworkInfo NetInfo; smprintf(s, "Network status : "); switch (msg.Buffer[8]) { case 0x00 : smprintf(s, "home network\n"); break; case 0x01 : smprintf(s, "roaming network\n"); break; case 0x04 : smprintf(s, "not logged"); break; case 0x06 : smprintf(s, "SIM card rejected\n"); break; case 0x09 : smprintf(s, "not logged"); break; default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break; } if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) { NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),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))); - sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); + sprintf(NetInfo.LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]); smprintf(s, "LAC : %s\n", NetInfo.LAC); - sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); + sprintf(NetInfo.CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]); smprintf(s, "CID : %s\n", NetInfo.CID); tmp = 10; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,name,true); 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 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break; case 0x01: Data->NetworkInfo->State = GSM_RoamingNetwork; break; case 0x04: case 0x06: case 0x09: Data->NetworkInfo->State = GSM_NoNetwork; break; } if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { tmp = 10; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,true); - sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[current+1], msg.Buffer[current+2]); - sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[current+5], msg.Buffer[current+6]); + sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]); + sprintf(Data->NetworkInfo->CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]); NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode); } } return ERR_NONE; } static GSM_Error N6510_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) { unsigned char req[] = {N6110_FRAME_HEADER, 0x00, 0x00}; s->Phone.Data.NetworkInfo=netinfo; smprintf(s, "Getting network info\n"); return GSM_WaitFor (s, req, 5, 0x0a, 4, ID_GetNetworkInfo); } static GSM_Error N6510_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *req, GSM_SMSMessageLayout *Layout, int *length) { int start, count = 0, pos1, pos2, pos3, pos4, pos5; GSM_Error error; memset(Layout,255,sizeof(GSM_SMSMessageLayout)); start = *length; req[count++] = 0x01; if (sms->PDU != SMS_Deliver) { req[count++] = 0x02; } else { req[count++] = 0x00; } pos1 = count; count++; /* firstbyte set in SMS Layout */ Layout->firstbyte = count; count++; if (sms->PDU != SMS_Deliver) { Layout->TPMR = count; count++; Layout->TPPID = count; count++; /* TP.DCS set in SMS layout */ Layout->TPDCS = count; count++; req[count++] = 0x00; } else { Layout->TPPID = count; count++; /* TP.DCS set in SMS layout */ Layout->TPDCS = count; count++; Layout->DateTime = count; count += 7; req[count++] = 0x55; req[count++] = 0x55; req[count++] = 0x55; } /* We have now blocks. Number of blocks = 3 or 4 */ if (sms->PDU != SMS_Deliver) { req[count++] = 0x04; } else { req[count++] = 0x03; } /* -------------- Phone number ------------- */ /* Block type: number */ req[count++] = 0x82; /* Offset to next block */ req[count++] = 0x10; /* Type of number: default number */ req[count++] = 0x01; pos4 = count; count++; /* now coded Number in SMS Layout */ Layout->Number = count; count+= 12; /* -------------- SMSC number -------------- */ /* Block type: number */ req[count++] = 0x82; /* Offset to next block */ req[count++] = 0x10; /* Type of number: SMSC number */ req[count++] = 0x02; pos5 = count; count++; /* now coded SMSC number in SMS Layout */ Layout->SMSCNumber = count; count += 12; /* -------------- SMS validity ------------- */ if (sms->PDU != SMS_Deliver) { /* Block type: validity */ req[count++] = 0x08; req[count++] = 0x04; /* data length */ req[count++] = 0x01; Layout->TPVP = count; count++; } /* --------------- SMS text ---------------- */ /* Block type: SMS text */ req[count++] = 0x80; /* this the same as req[11] but starting from req[42] */ pos2 = count; count++; @@ -1034,333 +1043,327 @@ static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; if (entry->Location == 0) return ERR_NOTSUPPORTED; req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[11]==0xff) return ERR_NOTSUPPORTED; req[12] = entry->Location / 256; req[13] = entry->Location % 256; count = count + N71_65_EncodePhonebookFrame(s, req+22, *entry, &blocks, true, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS)); req[21] = blocks; smprintf(s, "Writing phonebook entry\n"); return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetMemory); } static GSM_Error N6510_ReplySetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Operator logo set OK\n"); return ERR_NONE; } static GSM_Error N6510_SetCallerLogo(GSM_StateMachine *s, GSM_Bitmap *bitmap) { char string[500]; int block=0, i, Width, Height; unsigned int count = 22; unsigned char req[500] = { N6110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, 0xfe, 0x10, /* memory type */ 0x00, 0x00, /* location */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; req[13] = bitmap->Location; /* Enabling/disabling logo */ string[0] = bitmap->BitmapEnabled?1:0; string[1] = 0; count += N71_65_PackPBKBlock(s, N7110_PBK_LOGOON, 2, block++, string, req + count); /* Ringtone */ if (!bitmap->DefaultRingtone) { if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PBKTONEGAL)) { } else { string[0] = 0x00; string[1] = 0x00; string[2] = bitmap->RingtoneID; count += N71_65_PackPBKBlock(s, N7110_PBK_RINGTONE_ID, 3, block++, string, req + count); count --; req[count-5] = 8; } } /* Number of group */ string[0] = bitmap->Location; string[1] = 0; count += N71_65_PackPBKBlock(s, N7110_PBK_GROUP, 2, block++, string, req + count); /* Name */ if (!bitmap->DefaultName) { i = UnicodeLength(bitmap->Text) * 2; string[0] = i + 2; memcpy(string + 1, bitmap->Text, i); string[i + 1] = 0; count += N71_65_PackPBKBlock(s, N7110_PBK_NAME, i + 2, block++, string, req + count); } /* Logo */ if (!bitmap->DefaultBitmap) { PHONE_GetBitmapWidthHeight(GSM_NokiaCallerLogo, &Width, &Height); string[0] = Width; string[1] = Height; string[2] = 0; string[3] = 0; string[4] = PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0); PHONE_EncodeBitmap(GSM_NokiaCallerLogo, string + 5, bitmap); count += N71_65_PackPBKBlock(s, N7110_PBK_GROUPLOGO, PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 5, block++, string, req + count); } req[21] = block; return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap); } static GSM_Error N6510_ReplySetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s) { // smprintf(s, "Picture Image written OK, folder %i, location %i\n",msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]); return ERR_NONE; } static GSM_Error N6510_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) { GSM_SMSMessage sms; GSM_Phone_Bitmap_Types Type; int Width, Height, i, count; -#ifdef DEVELOP unsigned char folderid; - int location; -#endif + int location; GSM_NetworkInfo NetInfo; GSM_Error error; unsigned char reqStartup[1000] = { N7110_FRAME_HEADER, 0x04, 0x0F, 0x00, 0x00, 0x00, 0x04, 0xC0, 0x02, 0x00, 0x41, 0xC0, 0x03, 0x00, 0x60, 0xC0, 0x04}; unsigned char reqColourWallPaper[200] = { N6110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0xD5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18}; /* Bitmap ID */ unsigned char reqColourStartup[200] = { N6110_FRAME_HEADER, 0x04, 0x25, 0x00, 0x01, 0x00, 0x18}; unsigned char reqOp[1000] = { N7110_FRAME_HEADER, 0x25, 0x01, 0x55, 0x00, 0x00, 0x55, 0x01, /* 0x01 - not set, 0x02 - set */ 0x0C, 0x08, 0x62, 0xF0, 0x10, /* Network code */ 0x03, 0x55, 0x55}; unsigned char reqColourOp[200] = { N6110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0xE7, 0x00, 0x00, 0x00, 0xF9, 0x00, 0x08, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, /* File ID */ 0x00, 0x00, 0x00, 0x00}; /* Network code */ unsigned char reqNote[200] = {N6110_FRAME_HEADER, 0x04, 0x01}; unsigned char reqPicture[2000] = { N6110_FRAME_HEADER, 0x00, 0x02, 0x05, /* SMS folder */ 0x00, 0x00, /* location */ 0x01, 0x01, 0xa0, 0x02, 0x01, 0x40, 0x00, 0x34, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x03, 0x82, 0x10, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x10, 0x02, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0xa1, 0x55, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x48, 0x1c, 0x00, 0xfc, 0x00}; switch (Bitmap->Type) { case GSM_ColourWallPaper_ID: reqColourWallPaper[21] = Bitmap->ID; smprintf(s, "Setting colour wall paper\n"); return GSM_WaitFor (s, reqColourWallPaper, 22, 0x43, 4, ID_SetBitmap); case GSM_StartupLogo: Type = GSM_Nokia7110StartupLogo; switch (Bitmap->Location) { case 1: PHONE_EncodeBitmap(Type, reqStartup + 22, Bitmap); break; case 2: memset(reqStartup+5,0x00,15); PHONE_ClearBitmap(Type, reqStartup + 22,0,0); break; default: return ERR_NOTSUPPORTED; } smprintf(s, "Setting startup logo\n"); return GSM_WaitFor (s, reqStartup, 22+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap); case GSM_DealerNote_Text: reqNote[4] = 0x10; CopyUnicodeString(reqNote + 5, Bitmap->Text); i = 6 + UnicodeLength(Bitmap->Text) * 2; reqNote[i++] = 0; reqNote[i] = 0; return GSM_WaitFor (s, reqNote, i, 0x7A, 4, ID_SetBitmap); case GSM_WelcomeNote_Text: CopyUnicodeString(reqNote + 5, Bitmap->Text); i = 6 + UnicodeLength(Bitmap->Text) * 2; reqNote[i++] = 0; reqNote[i] = 0; return GSM_WaitFor (s, reqNote, i, 0x7A, 4, ID_SetBitmap); case GSM_OperatorLogo: /* We want to set operator logo, not clear */ if (strcmp(Bitmap->NetworkCode,"000 00")) { memset(reqOp + 19, 0, 281); NOKIA_EncodeNetworkCode(reqOp+12, Bitmap->NetworkCode); Type = GSM_Nokia6510OperatorLogo; reqOp[9] = 0x02; /* Logo enabled */ reqOp[18] = 0x1a; /* FIXME */ reqOp[19] = PHONE_GetBitmapSize(Type,0,0) + 8 + 29 + 2; PHONE_GetBitmapWidthHeight(Type, &Width, &Height); reqOp[20] = Width; reqOp[21] = Height; reqOp[22] = 0x00; reqOp[23] = PHONE_GetBitmapSize(Type,0,0) + 29; reqOp[24] = 0x00; reqOp[25] = PHONE_GetBitmapSize(Type,0,0) + 29; PHONE_EncodeBitmap(Type, reqOp + 26, Bitmap); smprintf(s, "Setting operator logo\n"); return GSM_WaitFor (s, reqOp, reqOp[19]+reqOp[11]+10, 0x0A, 4, ID_SetBitmap); } else { error=N6510_GetNetworkInfo(s,&NetInfo); if (error != ERR_NONE) return error; NOKIA_EncodeNetworkCode(reqOp+12, NetInfo.NetworkCode); smprintf(s, "Clearing operator logo\n"); return GSM_WaitFor (s, reqOp, 18, 0x0A, 4, ID_SetBitmap); } case GSM_ColourOperatorLogo_ID: /* We want to set operator logo, not clear */ if (strcmp(Bitmap->NetworkCode,"000 00")) { EncodeBCD(reqColourOp+23, Bitmap->NetworkCode, 6, false); reqColourOp[21] = Bitmap->ID; } smprintf(s, "Setting colour operator logo\n"); return GSM_WaitFor (s, reqColourOp, 26, 0x43, 4, ID_SetBitmap); case GSM_ColourStartupLogo_ID: switch (Bitmap->Location) { case 0: reqColourStartup[6] = 0x00; reqColourStartup[8] = 0x00; smprintf(s, "Setting colour startup logo\n"); return GSM_WaitFor (s, reqColourStartup, 9, 0x7A, 4, ID_SetBitmap); case 1: reqColourStartup[8] = Bitmap->ID; smprintf(s, "Setting colour startup logo\n"); return GSM_WaitFor (s, reqColourStartup, 9, 0x7A, 4, ID_SetBitmap); default:return ERR_NOTSUPPORTED; } case GSM_CallerGroupLogo: return N6510_SetCallerLogo(s,Bitmap); case GSM_PictureImage: error = N6510_GetPictureImage(s, Bitmap, &sms.Location); if (error == ERR_NONE) { -#ifdef DEVELOP sms.Folder = 0; N6510_GetSMSLocation(s, &sms, &folderid, &location); switch (folderid) { case 0x01: reqPicture[5] = 0x02; break; /* INBOX SIM */ case 0x02: reqPicture[5] = 0x03; break; /* OUTBOX SIM */ default : reqPicture[5] = folderid - 1; reqPicture[4] = 0x02; break; /* ME folders */ } reqPicture[6]=location / 256; reqPicture[7]=location; -#else - return ERR_NOTSUPPORTED; -#endif } Type = GSM_NokiaPictureImage; count = 78; PHONE_EncodeBitmap(Type, reqPicture + count, Bitmap); count += PHONE_GetBitmapSize(Type,0,0); smprintf(s, "Setting Picture Image\n"); return GSM_WaitFor (s, reqPicture, count, 0x14, 4, ID_SetBitmap); default: break; } return ERR_NOTSUPPORTED; } static GSM_Error N6510_ReplyGetRingtoneID(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; smprintf(s, "Ringtone ID received\n"); Priv->RingtoneID = msg.Buffer[15]; return ERR_NONE; } static GSM_Error N6510_ReplySetBinRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Binary ringtone set\n"); return ERR_NONE; } static GSM_Error N6510_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) { GSM_Error error; GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; GSM_NetworkInfo NetInfo; int size=200, current; unsigned char GetIDReq[] = { N7110_FRAME_HEADER, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x06, 0xE1, 0x00, 0xFF, 0x06, 0xE1, 0x01, 0x42}; unsigned char SetPreviewReq[1000] = { 0xAE, /* Ringtone ID */ 0x01, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /*Length*/ unsigned char AddBinaryReq[33000] = { N7110_FRAME_HEADER, 0x0E, 0x7F, 0xFF, 0xFE}; if (Ringtone->Format == RING_NOTETONE && Ringtone->Location==255) { smprintf(s, "Getting ringtone ID\n"); error=GSM_WaitFor (s, GetIDReq, 14, 0xDB, 4, ID_SetRingtone); if (error != ERR_NONE) return error; *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, SetPreviewReq+11, &size); SetPreviewReq[0] = Priv->RingtoneID; SetPreviewReq[10] = size; smprintf(s, "Setting ringtone\n"); error = s->Protocol.Functions->WriteMessage(s, SetPreviewReq, size+11, 0x00); if (error!=ERR_NONE) return error; my_sleep(1000); /* We have to make something (not important, what) now */ /* no answer from phone*/ return s->Phone.Functions->GetNetworkInfo(s,&NetInfo); } if (Ringtone->Format == RING_NOKIABINARY) { AddBinaryReq[7] = UnicodeLength(Ringtone->Name); CopyUnicodeString(AddBinaryReq+8,Ringtone->Name); current = 8 + UnicodeLength(Ringtone->Name)*2; AddBinaryReq[current++] = Ringtone->NokiaBinary.Length/256 + 1; AddBinaryReq[current++] = Ringtone->NokiaBinary.Length%256 + 1; AddBinaryReq[current++] = 0x00; memcpy(AddBinaryReq+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); current += Ringtone->NokiaBinary.Length; smprintf(s, "Adding binary ringtone\n"); return GSM_WaitFor (s, AddBinaryReq, current, 0x1F, 4, ID_SetRingtone); } if (Ringtone->Format == RING_MIDI) { AddBinaryReq[7] = UnicodeLength(Ringtone->Name); CopyUnicodeString(AddBinaryReq+8,Ringtone->Name); current = 8 + UnicodeLength(Ringtone->Name)*2; AddBinaryReq[current++] = Ringtone->NokiaBinary.Length/256; AddBinaryReq[current++] = Ringtone->NokiaBinary.Length%256; memcpy(AddBinaryReq+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); current += Ringtone->NokiaBinary.Length; AddBinaryReq[current++] = 0x00; AddBinaryReq[current++] = 0x00; smprintf(s, "Adding binary or MIDI ringtone\n"); return GSM_WaitFor (s, AddBinaryReq, current, 0x1F, 4, ID_SetRingtone); } return ERR_NOTSUPPORTED; } static GSM_Error N6510_ReplyDeleteRingtones(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Ringtones deleted\n"); return ERR_NONE; } @@ -2326,192 +2329,195 @@ static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_Stat case 0x07 : case 0x02 : smprintf(s, "waiting for PIN.\n"); *Data->SecurityStatus = SEC_Pin; break; case 0x03 : smprintf(s, "waiting for PUK.\n"); *Data->SecurityStatus = SEC_Puk; break; case 0x05 : smprintf(s, "PIN ok, SIM ok\n"); *Data->SecurityStatus = SEC_None; break; case 0x06 : smprintf(s, "No input status\n"); *Data->SecurityStatus = SEC_None; break; case 0x16 : smprintf(s, "No SIM card\n"); *Data->SecurityStatus = SEC_None; break; case 0x1A : smprintf(s, "SIM card rejected!\n"); *Data->SecurityStatus = SEC_None; break; default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); return ERR_UNKNOWNRESPONSE; } return ERR_NONE; } static GSM_Error N6510_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) { unsigned char req[5] = {N6110_FRAME_HEADER, 0x11, 0x00}; s->Phone.Data.SecurityStatus=Status; smprintf(s, "Getting security code status\n"); return GSM_WaitFor (s, req, 5, 0x08, 2, ID_GetSecurityStatus); } static GSM_Error N6510_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x08: smprintf(s, "Security code OK\n"); return ERR_NONE; case 0x09: switch (msg.Buffer[4]) { case 0x06: smprintf(s, "Wrong PIN\n"); return ERR_SECURITYERROR; case 0x09: smprintf(s, "Wrong PUK\n"); return ERR_SECURITYERROR; default: smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); } } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) { int len = 0; unsigned char req[15] = {N6110_FRAME_HEADER, 0x07, 0x00}; /* Code type */ switch (Code.Type) { case SEC_Pin : req[4] = 0x02; break; case SEC_Puk : req[4] = 0x03; break;/* FIXME */ default : return ERR_NOTSUPPORTED; } len = strlen(Code.Code); memcpy(req+5,Code.Code,len); req[5+len]=0x00; smprintf(s, "Entering security code\n"); return GSM_WaitFor (s, req, 6+len, 0x08, 4, ID_EnterSecurityCode); } static GSM_Error N6510_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) { unsigned char folder; GSM_Phone_Data *Data = &s->Phone.Data; switch (msg.Buffer[3]) { case 0x01: switch (msg.Buffer[4]) { case 0x00: smprintf(s, "Done OK\n"); smprintf(s, "Folder info: %i %i\n",msg.Buffer[5],msg.Buffer[8]); switch (msg.Buffer[8]) { case 0x02 : if (msg.Buffer[5] == 0x02) { folder = 0x03; /* INBOX ME */ } else { folder = 0x01; /* INBOX SIM */ } break; case 0x03 : if (msg.Buffer[5] == 0x02) { folder = 0x04; /* OUTBOX ME */ } else { folder = 0x02; /* OUTBOX SIM */ } break; default : folder = msg.Buffer[8] + 1; } N6510_SetSMSLocation(s, Data->SaveSMSMessage,folder,msg.Buffer[6]*256+msg.Buffer[7]); smprintf(s, "Saved in folder %i at location %i\n",folder, msg.Buffer[6]*256+msg.Buffer[7]); Data->SaveSMSMessage->Folder = folder; return ERR_NONE; case 0x02: printf("Incorrect location\n"); return ERR_INVALIDLOCATION; + case 0x03: + printf("Memory full (for example no empty space in SIM)\n"); + return ERR_FULL; case 0x05: printf("Incorrect folder\n"); return ERR_INVALIDLOCATION; default: smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); return ERR_UNKNOWNRESPONSE; } case 0x17: smprintf(s, "SMS name changed\n"); return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) { int location, length = 11; unsigned char folderid, folder; GSM_SMSMessageLayout Layout; GSM_Error error; unsigned char req [300] = { N6110_FRAME_HEADER, 0x00, 0x01, /* 1 = SIM, 2 = ME */ 0x02, /* Folder */ 0x00, 0x01, /* Location */ 0x01}; /* SMS state */ unsigned char NameReq[200] = { N6110_FRAME_HEADER, 0x16, 0x01, /* 1 = SIM, 2 = ME */ 0x02, /* Folder */ 0x00, 0x01}; /* Location */ 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; switch (sms->PDU) { case SMS_Submit: /* Inbox */ if (folderid == 0x01 || folderid == 0x03) sms->PDU = SMS_Deliver; break; case SMS_Deliver: /* SIM Outbox */ if (folderid == 0x02) sms->PDU = SMS_Submit; break; default: return ERR_UNKNOWN; } if (sms->PDU == SMS_Deliver) { switch (sms->State) { case SMS_Sent : /* We use GSM_Read, because phone return error */ case SMS_Read : req[8] = 0x01; break; case SMS_UnSent : /* We use GSM_UnRead, because phone return error */ case SMS_UnRead : req[8] = 0x03; break; } } else { switch (sms->State) { case SMS_Sent : /* We use GSM_Sent, because phone change folder */ case SMS_Read : req[8] = 0x05; break; case SMS_UnSent : /* We use GSM_UnSent, because phone change folder */ case SMS_UnRead : req[8] = 0x07; break; } } memset(req+9,0x00,sizeof(req) - 9); error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length); if (error != ERR_NONE) return error; s->Phone.Data.SaveSMSMessage=sms; smprintf(s, "Saving sms\n"); error=GSM_WaitFor (s, req, length+9, 0x14, 4, ID_SaveSMSMessage); if (error == ERR_NONE && UnicodeLength(sms->Name)!=0) { folder = sms->Folder; sms->Folder = 0; N6510_GetSMSLocation(s, sms, &folderid, &location); switch (folderid) { case 0x01: NameReq[5] = 0x02; break; /* INBOX SIM */ case 0x02: NameReq[5] = 0x03; break; /* OUTBOX SIM */ default : NameReq[5] = folderid - 1; NameReq[4] = 0x02; break; /* ME folders */ } NameReq[6]=location / 256; NameReq[7]=location; length = 8; CopyUnicodeString(NameReq+length, sms->Name); length = length+UnicodeLength(sms->Name)*2; NameReq[length++] = 0; NameReq[length++] = 0; error=GSM_WaitFor (s, NameReq, length, 0x14, 4, ID_SaveSMSMessage); sms->Folder = folder; } return error; } @@ -2583,291 +2589,295 @@ static GSM_Error N6510_ReplyGetManufactureMonth(GSM_Protocol_Message msg, GSM_St { if (msg.Buffer[7] == 0x00) { smprintf(s, "No SIM card\n"); return ERR_SECURITYERROR; } else { sprintf(s->Phone.Data.PhoneString,"%02i/%04i",msg.Buffer[13],msg.Buffer[14]*256+msg.Buffer[15]); return ERR_NONE; } } static GSM_Error N6510_GetManufactureMonth(GSM_StateMachine *s, char *value) { unsigned char req[6] = {0x00, 0x05, 0x02, 0x01, 0x00, 0x02}; // unsigned char req[6] = {0x00, 0x03, 0x04, 0x0B, 0x01, 0x00}; s->Phone.Data.PhoneString=value; smprintf(s, "Getting manufacture month\n"); return GSM_WaitFor (s, req, 6, 0x42, 2, ID_GetManufactureMonth); // return GSM_WaitFor (s, req, 6, 0x1B, 2, ID_GetManufactureMonth); } static GSM_Error N6510_ReplyGetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; switch(msg.Buffer[3]) { case 0x1A: smprintf(s, " Alarm: %02d:%02d\n", msg.Buffer[14], msg.Buffer[15]); Data->Alarm->Repeating = true; Data->Alarm->Text[0] = 0; Data->Alarm->Text[1] = 0; Data->Alarm->DateTime.Hour = msg.Buffer[14]; Data->Alarm->DateTime.Minute = msg.Buffer[15]; Data->Alarm->DateTime.Second = 0; return ERR_NONE; case 0x20: smprintf(s, "Alarm state received\n"); if (msg.Buffer[37] == 0x01) { smprintf(s, " Not set in phone\n"); return ERR_EMPTY; } smprintf(s, "Enabled\n"); return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) { unsigned char StateReq[] = {N6110_FRAME_HEADER, 0x1f, 0x01, 0x00}; unsigned char GetReq [] = {N6110_FRAME_HEADER, 0x19, 0x00, 0x02}; GSM_Error error; if (alarm->Location != 1) return ERR_NOTSUPPORTED; s->Phone.Data.Alarm=alarm; smprintf(s, "Getting alarm state\n"); error = GSM_WaitFor (s, StateReq, 6, 0x19, 4, ID_GetAlarm); if (error != ERR_NONE) return error; smprintf(s, "Getting alarm\n"); return GSM_WaitFor (s, GetReq, 6, 0x19, 4, ID_GetAlarm); } static GSM_Error N6510_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Alarm set\n"); return ERR_NONE; } static GSM_Error N6510_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) { unsigned char req[] = {N6110_FRAME_HEADER, 0x11, 0x00, 0x01, 0x01, 0x0c, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Hours, Minutes */ 0x00, 0x00, 0x00 }; if (alarm->Location != 1) return ERR_NOTSUPPORTED; req[14] = alarm->DateTime.Hour; req[15] = alarm->DateTime.Minute; smprintf(s, "Setting alarm\n"); return GSM_WaitFor (s, req, 19, 0x19, 4, ID_SetAlarm); } static GSM_Error N6510_ReplyGetRingtonesInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { int tmp,i; GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Ringtones info received\n"); memset(Data->RingtonesInfo,0,sizeof(GSM_AllRingtonesInfo)); if (msg.Buffer[4] * 256 + msg.Buffer[5] == 0x00) return ERR_EMPTY; Data->RingtonesInfo->Number = msg.Buffer[4] * 256 + msg.Buffer[5]; + // allocate array of ringtones based on number + Data->RingtonesInfo->Ringtone = calloc(Data->RingtonesInfo->Number, sizeof(GSM_RingtoneInfo)); tmp = 6; for (i=0;i<Data->RingtonesInfo->Number;i++) { Data->RingtonesInfo->Ringtone[i].Group = msg.Buffer[tmp+4]; Data->RingtonesInfo->Ringtone[i].ID = msg.Buffer[tmp+2] * 256 + msg.Buffer[tmp+3]; memcpy(Data->RingtonesInfo->Ringtone[i].Name,msg.Buffer+tmp+8,(msg.Buffer[tmp+6]*256+msg.Buffer[tmp+7])*2); smprintf(s, "%5i (%5i). \"%s\"\n", Data->RingtonesInfo->Ringtone[i].ID, Data->RingtonesInfo->Ringtone[i].Group, DecodeUnicodeString(Data->RingtonesInfo->Ringtone[i].Name)); tmp = tmp + (msg.Buffer[tmp]*256+msg.Buffer[tmp+1]); } return ERR_NONE; } static GSM_Error N6510_PrivGetRingtonesInfo(GSM_StateMachine *s, GSM_AllRingtonesInfo *Info, bool AllRingtones) { GSM_Error error; unsigned char UserReq[8] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0x02}; // unsigned char All_Req[9] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0xFE, 0x00, 0x7D}; unsigned char All_Req[8] = {N7110_FRAME_HEADER, 0x07, 0x00, 0x00, 0x00, 0x00}; s->Phone.Data.RingtonesInfo=Info; smprintf(s, "Getting binary ringtones ID\n"); if (AllRingtones) { // error = GSM_WaitFor (s, All_Req, 9, 0x1f, 4, ID_GetRingtonesInfo); error = GSM_WaitFor (s, All_Req, 8, 0x1f, 4, ID_GetRingtonesInfo); if (error == ERR_EMPTY && Info->Number == 0) return ERR_NOTSUPPORTED; return error; } else { error = GSM_WaitFor (s, UserReq, 8, 0x1f, 4, ID_GetRingtonesInfo); if (error == ERR_EMPTY && Info->Number == 0) return ERR_NOTSUPPORTED; return error; } } static GSM_Error N6510_GetRingtonesInfo(GSM_StateMachine *s, GSM_AllRingtonesInfo *Info) { return N6510_PrivGetRingtonesInfo(s, Info, true); } static GSM_Error N6510_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) { int tmp,i; GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Ringtone received\n"); memcpy(Data->Ringtone->Name,msg.Buffer+8,msg.Buffer[7]*2); Data->Ringtone->Name[msg.Buffer[7]*2]=0; Data->Ringtone->Name[msg.Buffer[7]*2+1]=0; smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name)); if (msg.Buffer[msg.Buffer[7]*2+10] == 'M' && msg.Buffer[msg.Buffer[7]*2+11] == 'T' && msg.Buffer[msg.Buffer[7]*2+12] == 'h' && msg.Buffer[msg.Buffer[7]*2+13] == 'd') { smprintf(s,"MIDI\n"); tmp = msg.Buffer[7]*2+10; i = msg.Length - 2; /* ?????? */ Data->Ringtone->Format = RING_MIDI; } else { /* Looking for end */ i=8+msg.Buffer[7]*2+3; tmp = i; while (true) { if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { i=i+2; break; } i++; if (i==msg.Length) return ERR_EMPTY; } } /* 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_AllRingtonesInfo Info = {0, NULL}; 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); + error = GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone); + if (Info.Ringtone) free(Info.Ringtone); + return error; 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; smprintf(s, "Enabling sound - part 2 (disabling sound command)\n"); error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone); if (error!=ERR_NONE) return error; } /* For Herz==255*255 we have silent */ if (Herz!=255*255) { reqPlay[23] = Herz%256; reqPlay[22] = Herz/256; reqPlay[31] = Volume; smprintf(s, "Playing sound\n"); return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone); } else { reqPlay[23] = 0; reqPlay[22] = 0; reqPlay[31] = 0; smprintf(s, "Playing silent sound\n"); return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone); // smprintf(s, "Disabling sound - part 1\n"); // error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone); // if (error!=ERR_NONE) return error; // smprintf(s, "Disabling sound - part 2\n"); // return GSM_WaitFor (s, reqOff2, 18, 0x0b, 4, ID_PlayTone); } } static GSM_Error N6510_ReplyGetPPM(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; int pos = 6,len; smprintf(s, "Received phone info\n"); while(pos < msg.Length) { if (msg.Buffer[pos] == 0x55 && msg.Buffer[pos+1] == 0x55) { while(1) { if (msg.Buffer[pos] != 0x55) break; pos++; } } len = pos; while(1) { if (msg.Buffer[len] == 0x00 && msg.Buffer[len+1] == 0x00) break; len++; } while(1) { if (msg.Buffer[len] != 0x00) break; len++; } len = len-pos; smprintf(s, "Block with ID %02x",msg.Buffer[pos]); #ifdef DEBUG if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, msg.Buffer+pos, len); #endif switch (msg.Buffer[pos]) { case 0x49: smprintf(s, "hardware version\n"); break; case 0x58: pos += 3; while (msg.Buffer[pos] != 0x00) pos++; @@ -3961,192 +3971,283 @@ static GSM_Error N6510_SetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStati req[12] = location; /* Name */ len = UnicodeLength(FMStation->StationName); req[8] = len; req[7] = 0x0e + len * 2; memcpy (req+18,FMStation->StationName,len*2); /* Frequency */ N6510_EncodeFMFrequency(FMStation->Frequency, req+16); smprintf(s, "Setting FM Station %i\n",FMStation->Location); return GSM_WaitFor (s, req, 0x13+len*2, 0x3E, 2, ID_SetFMStation); } static GSM_Error N6510_ReplySetLight(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Light set\n"); return ERR_NONE; } GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable) { unsigned char req[14] = { N6110_FRAME_HEADER, 0x05, 0x01, /* 0x01 = Display, 0x03 = keypad */ 0x01, /* 0x01 = Enable, 0x02 = disable */ 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 GSM_Error N6510_DeleteNote(GSM_StateMachine *s, GSM_NoteEntry *Not) +{ + GSM_Error error; + GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote; + GSM_CalendarEntry Note; + + if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED; + + error=N6510_GetCalendarInfo3(s,LastNote,2); + if (error!=ERR_NONE) return error; + + smprintf(s, "Deleting Note\n"); + + if (Not->Location > LastNote->Number || Not->Location == 0) return ERR_INVALIDLOCATION; + + Note.Location = LastNote->Location[Not->Location-1]; + return N71_65_DelCalendar(s,&Note); +} + +static GSM_Error N6510_ReplyGetNoteFirstLoc(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + smprintf(s, "First Note location: %i\n",msg.Buffer[8]*256+msg.Buffer[9]); + s->Phone.Data.Note->Location = msg.Buffer[8]*256+msg.Buffer[9]; + return ERR_NONE; +} + +static GSM_Error N6510_ReplyAddNote(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + smprintf(s, "ToDo added\n"); + return ERR_NONE; +} + +static GSM_Error N6510_AddNote(GSM_StateMachine *s, GSM_NoteEntry *Not) +{ + GSM_Error error; + int count=54; + unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95, + 0x02}; /* 1 = todo, 2 = note */ + unsigned char req[5000] = { + N6110_FRAME_HEADER, 0x65, + 0x02, /* 0 = calendar, 1 = todo, 2 = note */ + 0x00, 0x00, 0x00, + 0x00, 0x00, /* location */ + 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, /* alarm */ + 0x80, 0x00, 0x00, + 0xA9, /* note icon */ + 0x00, 0x00, 0x00, 0x00, /* alarm type */ + 0x00, /* 0x02 or 0x00 */ + 0x80, /* note type */ + 0x07, 0xD2, 0x01, 0x01, 0x00, 0x00, /* start date/time */ + 0x07, 0xD2, 0x01, 0x11, 0x00, 0x00, /* end date/time */ + 0x00, 0x00, /* recurrance */ + 0xFF, 0xFF, /* birth year */ + 0x00, /* ToDo priority */ + 0x00, /* ToDo completed ? */ + 0x00, 0x00, 0x00, + 0x00, /* note text length */ + 0x00, /* phone length/meeting place */ + 0x00, 0x00, 0x00}; + + s->Phone.Data.Note = Not; + + smprintf(s, "Getting first free Note location\n"); + error = GSM_WaitFor (s, reqLoc, 5, 0x13, 4, ID_SetNote); + if (error!=ERR_NONE) return error; + req[8] = Not->Location/256; + req[9] = Not->Location%256; + + req[49] = UnicodeLength(Not->Text); + CopyUnicodeString(req+54,Not->Text); + count+= req[49]*2; + + req[count++] = 0x00; + + smprintf(s, "Adding Note\n"); + return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetNote); +} + +static GSM_Error N6510_GetNoteStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) +{ + GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote; + GSM_Error error; + + error = N6510_GetCalendarInfo3(s,LastNote,2); + if (error!=ERR_NONE) return error; + + status->Used = LastNote->Number; + return ERR_NONE; +} + 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; i = msg.Buffer[8]*256+msg.Buffer[9]; dbgprintf("%02x %02x %02x %02x %02x %02x %02x %02x %02x\n", msg.Buffer[i-5],msg.Buffer[i-4],msg.Buffer[i-3], msg.Buffer[i-2],msg.Buffer[i-1],msg.Buffer[i], msg.Buffer[i+1],msg.Buffer[i+2],msg.Buffer[i+3]); File->Folder = false; if (msg.Buffer[i-5] == 0x00) File->Folder = true; File->ReadOnly = false; File->Protected = false; File->System = false; File->Hidden = false; if (msg.Buffer[i+2] == 0x01) File->Protected = true; if (msg.Buffer[i+4] == 0x01) File->ReadOnly = true; if (msg.Buffer[i+5] == 0x01) File->Hidden = true; if (msg.Buffer[i+6] == 0x01) File->System = true;//fixme 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; #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; @@ -5096,205 +5197,206 @@ static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMa /* 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,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] = { N6110_FRAME_HEADER, 0x01, 0x03, /* Priority */ 0x00, /* Length of text */ 0x80,0x00,0x00, 0x18}; /* Location */ s->Phone.Data.ToDo = ToDo; smprintf(s, "Getting first ToDo location\n"); error = GSM_WaitFor (s, reqLoc, 4, 0x55, 4, ID_SetToDo); if (error != ERR_NONE) return error; reqSet[9] = ToDo->Location; switch (ToDo->Priority) { case GSM_Priority_Low : reqSet[4] = 3; break; case GSM_Priority_Medium: reqSet[4] = 2; break; case GSM_Priority_High : reqSet[4] = 1; break; } GSM_ToDoFindDefaultTextTimeAlarmCompleted(ToDo, &Text, &Alarm, &Completed, &EndTime, &Phone); if (Text == -1) return ERR_NOTSUPPORTED; /* XXX: shouldn't this be handled different way? */ ulen = UnicodeLength(ToDo->Entries[Text].Text); reqSet[5] = ulen+1; CopyUnicodeString(reqSet+10,ToDo->Entries[Text].Text); reqSet[10+ulen*2] = 0x00; reqSet[10+ulen*2+1] = 0x00; smprintf(s, "Adding ToDo method 1\n"); return GSM_WaitFor (s, reqSet, 12+ulen*2, 0x55, 4, ID_SetToDo); } static GSM_Error N6510_ReplyAddToDo2(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "ToDo added method 2\n"); return ERR_NONE; } static GSM_Error N6510_ReplyGetToDoFirstLoc2(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "First ToDo location method 2: %i\n",msg.Buffer[8]*256+msg.Buffer[9]); - s->Phone.Data.ToDo->Location = msg.Buffer[9]; + s->Phone.Data.ToDo->Location = msg.Buffer[8]*256+msg.Buffer[9]; return ERR_NONE; } static GSM_Error N6510_AddToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) { GSM_CalendarEntry Note; time_t t_time1,t_time2; long diff; GSM_Error error; GSM_DateTime DT; int Text, Alarm, EndTime, Completed, count=54, Phone; - unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95, 0x01}; + unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x95, + 0x01}; /* 1 = todo, 2 = note */ unsigned char req[5000] = { N6110_FRAME_HEADER, 0x65, 0x01, /* 0 = calendar, 1 = todo */ 0x00, 0x00, 0x00, 0x00, 0x00, /* location */ 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, /* alarm */ 0x80, 0x00, 0x00, 0x01, /* note icon */ 0xFF, 0xFF, 0xFF, 0xFF, /* alarm type */ 0x00, /* 0x02 or 0x00 */ 0x01, /* note type */ 0x07, 0xD0, 0x01, 0x12, 0x0C, 0x00, /* start date/time */ 0x07, 0xD0, 0x01, 0x12, 0x0C, 0x00, /* end date/time */ 0x00, 0x00, /* recurrance */ 0x00, 0x00, /* birth year */ 0x20, /* ToDo priority */ 0x00, /* ToDo completed ? */ 0x00, 0x00, 0x00, 0x00, /* note text length */ 0x00, /* phone length/meeting place */ 0x00, 0x00, 0x00}; s->Phone.Data.ToDo = ToDo; smprintf(s, "Getting first free ToDo location method 2\n"); error = GSM_WaitFor (s, reqLoc, 5, 0x13, 4, ID_SetToDo); if (error!=ERR_NONE) return error; req[8] = ToDo->Location/256; req[9] = ToDo->Location%256; Note.Type = GSM_CAL_MEETING; DT.Year = 2004; DT.Month = 1; DT.Day = 1; DT.Hour = 12; DT.Minute = 12; DT.Second = 0; memcpy(&Note.Entries[0].Date,&DT,sizeof(GSM_DateTime)); Note.Entries[0].EntryType = CAL_START_DATETIME; memcpy(&Note.Entries[1].Date,&DT,sizeof(GSM_DateTime)); Note.Entries[1].EntryType = CAL_END_DATETIME; EncodeUnicode(Note.Entries[2].Text,"ala",3); Note.Entries[2].EntryType = CAL_TEXT; Note.EntriesNum = 3; error=N6510_FindCalendarIconID3(s, &Note, &req[21]); if (error!=ERR_NONE) return error; switch (ToDo->Priority) { case GSM_Priority_Low : req[44] = 0x10; break; case GSM_Priority_Medium: req[44] = 0x20; break; case GSM_Priority_High : req[44] = 0x30; break; } GSM_ToDoFindDefaultTextTimeAlarmCompleted(ToDo, &Text, &Alarm, &Completed, &EndTime, &Phone); if (Completed != -1) req[45] = 0x01; if (EndTime == -1) { GSM_GetCurrentDateTime(&DT); } else { memcpy(&DT,&ToDo->Entries[EndTime].Date,sizeof(GSM_DateTime)); } /*Start time*/ req[28] = DT.Year / 256; req[29] = DT.Year % 256; req[30] = DT.Month; req[31] = DT.Day; req[32] = DT.Hour; req[33] = DT.Minute; /*End time*/ req[34] = DT.Year / 256; req[35] = DT.Year % 256; req[36] = DT.Month; req[37] = DT.Day; req[38] = DT.Hour; req[39] = DT.Minute; if (Alarm != -1) { if (ToDo->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { req[22] = 0x00; req[23] = 0x00; req[24] = 0x00; req[25] = 0x00; } t_time2 = Fill_Time_T(DT,8); t_time1 = Fill_Time_T(ToDo->Entries[Alarm].Date,8); diff = (t_time1-t_time2)/60; smprintf(s, " Difference : %li seconds or minutes\n", -diff); req[14] = (unsigned char)(-diff >> 24); req[15] = (unsigned char)(-diff >> 16); req[16] = (unsigned char)(-diff >> 8); req[17] = (unsigned char)(-diff); } if (Text != -1) { req[49] = UnicodeLength(ToDo->Entries[Text].Text); CopyUnicodeString(req+54,ToDo->Entries[Text].Text); count+= req[49]*2; } @@ -5492,373 +5594,381 @@ static GSM_Error N6510_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *book GSM_Error N6510_DeleteWAPBookmark(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_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_ReplyAddNote, "\x13",0x03,0x66,ID_SetNote }, {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_ReplyGetNoteFirstLoc, "\x13",0x03,0x96,ID_SetNote }, {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 */ {N6510_ReplyGetRingtonesInfo, "\x1f",0x03,0x08,ID_GetRingtonesInfo }, {N6510_ReplyDeleteRingtones, "\x1f",0x03,0x11,ID_SetRingtone }, {N6510_ReplyGetRingtone, "\x1f",0x03,0x13,ID_GetRingtone }, {N6510_ReplySetBinRingtone, "\x1f",0x03,0x0F,ID_SetRingtone }, /* 0x23 - voice records */ {N6510_ReplyGetProfile, "\x39",0x03,0x02,ID_GetProfile }, {N6510_ReplySetProfile, "\x39",0x03,0x04,ID_SetProfile }, {N6510_ReplyGetProfile, "\x39",0x03,0x06,ID_GetProfile }, {N6510_ReplySetLight, "\x3A",0x03,0x06,ID_SetLight }, {N6510_ReplyGetFMStation, "\x3E",0x03,0x06,ID_GetFMStation }, {N6510_ReplyGetFMStatus, "\x3E",0x03,0x0E,ID_GetFMStation }, {N6510_ReplySetFMStation, "\x3E",0x03,0x15,ID_SetFMStation }, {N6510_ReplyGetFMStation, "\x3E",0x03,0x16,ID_GetFMStation }, {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc }, {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc }, {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc }, {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc }, {N6510_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark }, {N6510_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark }, {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark }, {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark }, {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark }, {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark }, {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet }, {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet }, {N6510_ReplyGetConnectionSettings,"\x3f",0x03,0x16,ID_GetConnectSet }, {N6510_ReplyGetConnectionSettings,"\x3f",0x03,0x17,ID_GetConnectSet }, {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x19,ID_SetConnectSet }, {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x1A,ID_SetConnectSet }, {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x28,ID_SetConnectSet }, {N6510_ReplySetConnectionSettings,"\x3f",0x03,0x2B,ID_SetConnectSet }, {N6510_ReplyGetChatSettings, "\x3f",0x03,0x3B,ID_GetChatSettings }, {N6510_ReplyGetChatSettings, "\x3f",0x03,0x3C,ID_GetChatSettings }, {N6510_ReplyGetOriginalIMEI, "\x42",0x07,0x00,ID_GetOriginalIMEI }, {N6510_ReplyGetManufactureMonth, "\x42",0x07,0x00,ID_GetManufactureMonth }, {N6510_ReplyGetOriginalIMEI, "\x42",0x07,0x01,ID_GetOriginalIMEI }, {N6510_ReplyGetManufactureMonth, "\x42",0x07,0x02,ID_GetManufactureMonth }, {N6510_ReplySetOperatorLogo, "\x43",0x03,0x08,ID_SetBitmap }, {N6510_ReplyGetGPRSAccessPoint, "\x43",0x03,0x06,ID_GetGPRSPoint }, {N6510_ReplySetGPRSAccessPoint1, "\x43",0x03,0x06,ID_SetGPRSPoint }, #ifdef DEVELOP {N6510_ReplyEnableGPRSAccessPoint,"\x43",0x03,0x06,ID_EnableGPRSPoint }, #endif {N6510_ReplyGetSyncMLSettings, "\x43",0x03,0x06,ID_GetSyncMLSettings }, {N6510_ReplyGetSyncMLName, "\x43",0x03,0x06,ID_GetSyncMLName }, {NoneReply, "\x43",0x03,0x08,ID_SetGPRSPoint }, /* 0x4A - voice records */ /* 0x53 - simlock */ {N6510_ReplyAddToDo1, "\x55",0x03,0x02,ID_SetToDo }, {N6510_ReplyGetToDo1, "\x55",0x03,0x04,ID_GetToDo }, {N6510_ReplyGetToDoFirstLoc1, "\x55",0x03,0x10,ID_SetToDo }, {N6510_ReplyDeleteAllToDo1, "\x55",0x03,0x12,ID_DeleteAllToDo }, {N6510_ReplyGetToDoStatus1, "\x55",0x03,0x16,ID_GetToDo }, {N6510_ReplyAddFileHeader, "\x6D",0x03,0x03,ID_AddFile }, {N6510_ReplyAddFolder, "\x6D",0x03,0x05,ID_AddFolder }, {N6510_ReplyGetFilePart, "\x6D",0x03,0x0F,ID_GetFile }, {N6510_ReplyAddFileHeader, "\x6D",0x03,0x13,ID_AddFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFileInfo }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_AddFile }, {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|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i", + "1100|1100a|1100b|3100|3100b|3105|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i", 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 */ + N6510_GetNoteStatus, + NOTIMPLEMENTED, /* GetNote */ N6510_GetNextNote, + NOTIMPLEMENTED, /* SetNote */ + N6510_AddNote, + N6510_DeleteNote, + NOTSUPPORTED, /* DeleteAllNotes */ 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/nauto.c b/gammu/emb/common/phone/nokia/nauto.c index 3bb53ec..3c7f2cd 100644 --- a/gammu/emb/common/phone/nokia/nauto.c +++ b/gammu/emb/common/phone/nokia/nauto.c @@ -28,117 +28,123 @@ GSM_Phone_Functions NAUTOPhone = { DCT3DCT4_GetFirmware, NOTSUPPORTED, /* GetIMEI */ NOTSUPPORTED, /* GetOriginalIMEI */ NOTSUPPORTED, /* GetManufactureMonth */ NOTSUPPORTED, /* GetProductCode */ NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ NOTSUPPORTED, /* GetDateTime */ NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ 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, /* 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, /* SendSMSMessage */ NOTSUPPORTED, /* SendSavedSMS */ 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, /* 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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/obex/obexgen.c b/gammu/emb/common/phone/obex/obexgen.c index 3106369..b91afac 100644 --- a/gammu/emb/common/phone/obex/obexgen.c +++ b/gammu/emb/common/phone/obex/obexgen.c @@ -736,117 +736,123 @@ GSM_Phone_Functions OBEXGENPhone = { NOTIMPLEMENTED, /* GetHardware */ NOTIMPLEMENTED, /* GetPPM */ NOTIMPLEMENTED, /* GetSIMIMSI */ NOTIMPLEMENTED, /* GetDateTime */ NOTIMPLEMENTED, /* SetDateTime */ NOTIMPLEMENTED, /* GetAlarm */ NOTIMPLEMENTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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/pfunc.c b/gammu/emb/common/phone/pfunc.c index a03a81d..fe890fc 100644 --- a/gammu/emb/common/phone/pfunc.c +++ b/gammu/emb/common/phone/pfunc.c @@ -1,138 +1,139 @@ /* (c) 2002-2003 by Marcin Wiacek */ #include <string.h> #include <ctype.h> #include "../gsmstate.h" #include "../service/sms/gsmsms.h" #include "../misc/coding/coding.h" /* These SMS layouts are used exactly as written in Nokia DCT3 phones. * In AT module(s) we have to use some layouts to convert AT frame to format * understod by SMS module. To share source the same layouts are used */ GSM_SMSMessageLayout PHONE_SMSDeliver = { 35 /* SMS Text */, 16 /* Phone number */, 0 /* SMSC Number */, 14 /* TPDCS */, 28 /* SendingDateTime */, 255 /* SMSCDateTime */, 255 /* TPStatus */, 15 /* TPUDL */, 255 /* TPVP */, 12 /* firstbyte */, 255 /* TPMR */, 13 /* TPPID */}; GSM_SMSMessageLayout PHONE_SMSSubmit = { 36 /* SMS Text */, 17 /* Phone number */, 0 /* SMSC Number */, 15 /* TPDCS */, 255 /* SendingDateTime */, 255 /* SMSCDateTime */, 255 /* TPStatus */, 16 /* TPUDL */, 29 /* TPVP */, 12 /* firstbyte */, 13 /* TPMR */, 14 /* TPPID */}; GSM_SMSMessageLayout PHONE_SMSStatusReport = { 255 /* SMS Text */, 15 /* Phone number */, 0 /* SMSC Number */, 255 /* TPDCS */, 27 /* SendingDateTime */, 34 /* SMSCDateTime */, 14 /* TPStatus */, 255 /* TPUDL */, 255 /* TPVP */, 12 /* firstbyte */, 13 /* TPMR */, 255 /* TPPID?? */}; GSM_Error PHONE_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders) { folders->Number=2; EncodeUnicode(folders->Folder[0].Name,GetMsg(s->msg,"Inbox"),strlen(GetMsg(s->msg,"Inbox"))); EncodeUnicode(folders->Folder[1].Name,GetMsg(s->msg,"Outbox"),strlen(GetMsg(s->msg,"Outbox"))); folders->Folder[0].InboxFolder = true; folders->Folder[1].InboxFolder = false; folders->Folder[0].Memory = MEM_SM; folders->Folder[1].Memory = MEM_SM; return ERR_NONE; } void GSM_CreateFirmwareNumber(GSM_StateMachine *s) { StringToDouble(s->Phone.Data.Version, &s->Phone.Data.VerNum); dbgprintf("Number version is \"%f\"\n", s->Phone.Data.VerNum); } GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, bool clear) { GSM_Error error; if (SMS->SMSC.Location!=0) { error = s->Phone.Functions->GetSMSC(s, &SMS->SMSC); if (error != ERR_NONE) return error; SMS->SMSC.Location = 0; } if (SMS->PDU == SMS_Deliver) { if (SMS->SMSC.Number[0] == 0x00 && SMS->SMSC.Number[1] == 0x00) { + smprintf(s,"No SMSC in SMS Deliver\n"); return ERR_EMPTYSMSC; } } return GSM_EncodeSMSFrame(SMS, buffer, Layout, length, clear); } GSM_Error PHONE_Terminate(GSM_StateMachine *s) { GSM_Error error; if (s->Phone.Data.EnableIncomingCB==true) { error=s->Phone.Functions->SetIncomingCB(s,false); if (error!=ERR_NONE) return error; } if (s->Phone.Data.EnableIncomingSMS==true) { error=s->Phone.Functions->SetIncomingSMS(s,false); if (error!=ERR_NONE) return error; } return ERR_NONE; } GSM_Error PHONE_RTTLPlayOneNote(GSM_StateMachine *s, GSM_RingNote note, bool first) { int duration, Hz; GSM_Error error; Hz=GSM_RingNoteGetFrequency(note); error=s->Phone.Functions->PlayTone(s,Hz,5,first); if (error!=ERR_NONE) return error; duration = GSM_RingNoteGetFullDuration(note); /* Is it correct ? Experimental values here */ switch (note.Style) { case StaccatoStyle: my_sleep (7500); error=s->Phone.Functions->PlayTone(s,0,0,false); if (error != ERR_NONE) return error; my_sleep ((1400000/note.Tempo*duration)-(7500)); break; case ContinuousStyle: my_sleep (1400000/note.Tempo*duration); break; case NaturalStyle: my_sleep (1400000/note.Tempo*duration-50); error=s->Phone.Functions->PlayTone(s,0,0,false); if (error != ERR_NONE) return error; my_sleep (50); break; } return ERR_NONE; } GSM_Error PHONE_Beep(GSM_StateMachine *s) { GSM_Error error; error=s->Phone.Functions->PlayTone(s, 4000, 5,true); if (error!=ERR_NONE) return error; my_sleep(500); return s->Phone.Functions->PlayTone(s,255*255,0,false); } GSM_Error NoneReply(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s,"None answer\n"); return ERR_NONE; } /* 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 a7382cf..63d26cf 100644 --- a/gammu/emb/common/phone/symbian/mroutgen.c +++ b/gammu/emb/common/phone/symbian/mroutgen.c @@ -105,117 +105,123 @@ GSM_Phone_Functions MROUTERGENPhone = { NOTSUPPORTED, /* GetProductCode */ NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ NOTSUPPORTED, /* GetDateTime */ NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ 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, /* GetNoteStatus */ + NOTSUPPORTED, /* GetNote */ NOTSUPPORTED, /* GetNextNote */ + NOTSUPPORTED, /* SetNote */ + NOTSUPPORTED, /* AddNote */ + NOTSUPPORTED, /* DeleteNote */ + NOTSUPPORTED, /* DeleteAllNotes */ 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/nokia/fbus2.c b/gammu/emb/common/protocol/nokia/fbus2.c index 2b41f8b..967eaa4 100644 --- a/gammu/emb/common/protocol/nokia/fbus2.c +++ b/gammu/emb/common/protocol/nokia/fbus2.c @@ -1,243 +1,253 @@ /* (c) 2002-2003 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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; /* Odd messages require additional 0x00 byte */ if (MsgLength % 2) buffer2[len++] = 0x00; checksum = 0; for (i = 0; i < len; i+=2) checksum ^= buffer2[i]; buffer2[len++] = checksum; checksum = 0; for (i = 1; i < len; i+=2) checksum ^= buffer2[i]; buffer2[len++] = checksum; /* Sending to phone */ sent=s->Device.Functions->WriteDevice(s,buffer2,len); if (sent!=len) return ERR_DEVICEWRITEERROR; return ERR_NONE; } static GSM_Error FBUS2_WriteMessage (GSM_StateMachine *s, unsigned char *MsgBuffer, int MsgLength, unsigned char MsgType) { int i, nom, togo, thislength; /* number of messages, ... */ unsigned char buffer2[FBUS2_MAX_TRANSMIT_LENGTH + 2], seqnum; GSM_Protocol_FBUS2Data *d = &s->Protocol.Data.FBUS2; GSM_Error error; GSM_DumpMessageLevel3(s, MsgBuffer, MsgLength, MsgType); nom = (MsgLength + FBUS2_MAX_TRANSMIT_LENGTH - 1) / FBUS2_MAX_TRANSMIT_LENGTH; togo = MsgLength; for (i = 0; i < nom; i++) { seqnum = d->MsgSequenceNumber; if (i==0) seqnum = seqnum + 0x40; d->MsgSequenceNumber = (d->MsgSequenceNumber + 1) & 0x07; thislength = togo; if (togo > FBUS2_MAX_TRANSMIT_LENGTH) thislength = FBUS2_MAX_TRANSMIT_LENGTH; memcpy(buffer2, MsgBuffer + (MsgLength - togo), thislength); buffer2[thislength] = nom - i; buffer2[thislength + 1] = seqnum; togo = togo - thislength; GSM_DumpMessageLevel2(s, buffer2, thislength, MsgType); error=FBUS2_WriteFrame(s, buffer2, thislength + 2, MsgType); if (error!=ERR_NONE) return error; } return ERR_NONE; } static GSM_Error FBUS2_SendAck(GSM_StateMachine *s, unsigned char MsgType, unsigned char MsgSequence) { unsigned char buffer2[2]; buffer2[0] = MsgType; buffer2[1] = MsgSequence; if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { smprintf(s,"[Sending Ack of type %02x, seq %x]\n",buffer2[0],buffer2[1]); } /* Sending to phone */ return FBUS2_WriteFrame(s, buffer2, 2, FBUS2_ACK_BYTE); } static GSM_Error FBUS2_StateMachine(GSM_StateMachine *s, unsigned char rx_char) { GSM_Protocol_FBUS2Data *d = &s->Protocol.Data.FBUS2; unsigned char frm_num, seq_num; bool correct = false; /* XOR the byte with the earlier checksum */ d->Msg.CheckSum[d->Msg.Count & 1] ^= rx_char; if (d->MsgRXState == RX_GetMessage) { d->Msg.Buffer[d->Msg.Count] = rx_char; d->Msg.Count++; /* This is not last byte in frame */ if (d->Msg.Count != d->Msg.Length+(d->Msg.Length%2)+2) return ERR_NONE; /* Checksum is incorrect */ if (d->Msg.CheckSum[0] != d->Msg.CheckSum[1]) { 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,"[ERROR: checksum]\n"); } free(d->Msg.Buffer); d->Msg.Length = 0; d->Msg.Buffer = NULL; d->MsgRXState = RX_Sync; return ERR_NONE; } seq_num = d->Msg.Buffer[d->Msg.Length-1]; if (d->Msg.Type == FBUS2_ACK_BYTE) { if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { smprintf(s, "[Received Ack of type %02x, seq %02x]\n",d->Msg.Buffer[0],seq_num); } + free(d->Msg.Buffer); d->MsgRXState = RX_Sync; return ERR_NONE; } frm_num = d->Msg.Buffer[d->Msg.Length-2]; if ((seq_num & 0x40) == 0x40) { d->FramesToGo = frm_num; d->MultiMsg.Length = 0; d->MultiMsg.Type = d->Msg.Type; d->MultiMsg.Destination = d->Msg.Destination; d->MultiMsg.Source = d->Msg.Source; } if ((seq_num & 0x40) != 0x40 && d->FramesToGo != frm_num) { 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, "[ERROR: Missed part of multiframe msg]\n"); } free(d->Msg.Buffer); d->Msg.Length = 0; d->Msg.Buffer = NULL; d->MsgRXState = RX_Sync; return ERR_NONE; } if ((seq_num & 0x40) != 0x40 && d->Msg.Type != d->MultiMsg.Type) { 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, "[ERROR: Multiframe msg in multiframe msg]\n"); } free(d->Msg.Buffer); d->Msg.Length = 0; d->Msg.Buffer = NULL; d->MsgRXState = RX_Sync; return ERR_NONE; } if (d->MultiMsg.BufferUsed < d->MultiMsg.Length+d->Msg.Length-2) { d->MultiMsg.BufferUsed = d->MultiMsg.Length+d->Msg.Length-2; d->MultiMsg.Buffer = (unsigned char *)realloc(d->MultiMsg.Buffer,d->MultiMsg.BufferUsed); } memcpy(d->MultiMsg.Buffer+d->MultiMsg.Length,d->Msg.Buffer,d->Msg.Length-2); d->MultiMsg.Length = d->MultiMsg.Length+d->Msg.Length-2; free(d->Msg.Buffer); d->Msg.Length = 0; d->Msg.Buffer = NULL; d->FramesToGo--; /* do not ack debug trace, as this could generate a * (feedback loop) flood of which even Noah would be scared. */ if (d->Msg.Type != 0) { FBUS2_SendAck(s,d->Msg.Type,((unsigned char)(seq_num & 0x0f))); } if (d->FramesToGo == 0) { s->Phone.Data.RequestMsg = &d->MultiMsg; s->Phone.Data.DispatchError = s->Phone.Functions->DispatchMessage(s); } d->MsgRXState = RX_Sync; return ERR_NONE; } if (d->MsgRXState == RX_GetLength2) { d->Msg.Length = d->Msg.Length + rx_char; d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length+3); d->MsgRXState = RX_GetMessage; return ERR_NONE; } if (d->MsgRXState == RX_GetLength1) { d->Msg.Length = rx_char * 256; d->MsgRXState = RX_GetLength2; return ERR_NONE; } if (d->MsgRXState == RX_GetType) { d->Msg.Type = rx_char; d->MsgRXState = RX_GetLength1; return ERR_NONE; } if (d->MsgRXState == RX_GetSource) { if (rx_char != FBUS2_DEVICE_PHONE) { 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,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, FBUS2_DEVICE_PHONE); } d->MsgRXState = RX_Sync; return ERR_NONE; } diff --git a/gammu/emb/common/protocol/nokia/fbus2.h b/gammu/emb/common/protocol/nokia/fbus2.h index 8dbcb07..3d31006 100644 --- a/gammu/emb/common/protocol/nokia/fbus2.h +++ b/gammu/emb/common/protocol/nokia/fbus2.h @@ -1,42 +1,51 @@ /* (c) 2002-2003 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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 /* 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 db5bd72..495a1bf 100644 --- a/gammu/emb/common/protocol/nokia/phonet.c +++ b/gammu/emb/common/protocol/nokia/phonet.c @@ -1,101 +1,110 @@ /* (c) 2002-2003 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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 } buffer2[3] = MsgType; buffer2[4] = MsgLength / 256; buffer2[5] = MsgLength % 256; memcpy(buffer2 + 6, MsgBuffer, MsgLength); GSM_DumpMessageLevel2(s, buffer2+6, MsgLength, MsgType); /* Sending to phone */ sent = s->Device.Functions->WriteDevice(s,buffer2,MsgLength+6); free(buffer2); if (sent!=MsgLength+6) return ERR_DEVICEWRITEERROR; return ERR_NONE; } static GSM_Error PHONET_StateMachine(GSM_StateMachine *s, unsigned char rx_char) { GSM_Protocol_PHONETData *d = &s->Protocol.Data.PHONET; bool correct = false; if (d->MsgRXState==RX_GetMessage) { d->Msg.Buffer[d->Msg.Count] = rx_char; d->Msg.Count++; /* This is not last byte in frame */ if (d->Msg.Count != d->Msg.Length) return ERR_NONE; s->Phone.Data.RequestMsg = &d->Msg; s->Phone.Data.DispatchError = s->Phone.Functions->DispatchMessage(s); free(d->Msg.Buffer); d->Msg.Length = 0; d->Msg.Buffer = NULL; d->MsgRXState = RX_Sync; return ERR_NONE; } if (d->MsgRXState==RX_GetLength2) { d->Msg.Length = d->Msg.Length + rx_char; d->Msg.Buffer = (unsigned char *)malloc(d->Msg.Length); d->MsgRXState = RX_GetMessage; return ERR_NONE; } if (d->MsgRXState==RX_GetLength1) { d->Msg.Length = rx_char * 256; d->MsgRXState = RX_GetLength2; return ERR_NONE; } if (d->MsgRXState==RX_GetType) { d->Msg.Type = rx_char; d->MsgRXState = RX_GetLength1; return ERR_NONE; } if (d->MsgRXState==RX_GetSource) { if (rx_char != PHONET_DEVICE_PHONE) { 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,"[ERROR: incorrect char - %02x, not %02x]\n", rx_char, PHONET_DEVICE_PHONE); diff --git a/gammu/emb/common/protocol/nokia/phonet.h b/gammu/emb/common/protocol/nokia/phonet.h index e750bbd..7626c23 100644 --- a/gammu/emb/common/protocol/nokia/phonet.h +++ b/gammu/emb/common/protocol/nokia/phonet.h @@ -1,38 +1,47 @@ /* (c) 2002-2003 by Marcin Wiacek */ /* 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 */ +/* Due to a problem in the source code management, the names of some of + * the authors have unfortunately been lost. We do not mean to belittle + * their efforts and hope they will contact us to see their names + * properly added to the Copyright notice above. + * Having published their contributions under the terms of the GNU + * General Public License (GPL) [version 2], the Copyright of these + * authors will remain respected by adhering to the license they chose + * to publish their code under. + */ #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 9a930fc..9d97954 100644 --- a/gammu/emb/common/service/backup/backgen.h +++ b/gammu/emb/common/service/backup/backgen.h @@ -1,73 +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); +extern GSM_Error GSM_AddSMSBackupFile (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 4cb1bb7..07a3b22 100644 --- a/gammu/emb/common/service/backup/backtext.c +++ b/gammu/emb/common/service/backup/backtext.c @@ -2903,207 +2903,211 @@ static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMes SMS->MessageReference = 0; readvalue = ReadCFGText(file_info, section, buffer, false); if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue); sprintf(buffer,"State"); SMS->State = SMS_UnRead; readvalue = ReadCFGText(file_info, section, buffer, false); if (readvalue!=NULL) { if (mystrncasecmp(readvalue,"Read",0)) SMS->State = SMS_Read; else if (mystrncasecmp(readvalue,"Sent",0)) SMS->State = SMS_Sent; else if (mystrncasecmp(readvalue,"UnSent",0)) SMS->State = SMS_UnSent; } sprintf(buffer,"Number"); ReadBackupText(file_info, section, buffer, SMS->Number, false); sprintf(buffer,"Name"); ReadBackupText(file_info, section, buffer, SMS->Name, false); sprintf(buffer,"Length"); SMS->Length = 0; readvalue = ReadCFGText(file_info, section, buffer, false); if (readvalue!=NULL) SMS->Length = atoi(readvalue); sprintf(buffer,"Coding"); SMS->Coding = SMS_Coding_Default; readvalue = ReadCFGText(file_info, section, buffer, false); if (readvalue!=NULL) { if (mystrncasecmp(readvalue,"Unicode",0)) { SMS->Coding = SMS_Coding_Unicode; } else if (mystrncasecmp(readvalue,"8bit",0)) { SMS->Coding = SMS_Coding_8bit; } } ReadLinkedBackupText(file_info, section, "Text", buffer, false); DecodeHexBin (SMS->Text, buffer, strlen(buffer)); SMS->Text[strlen(buffer)/2] = 0; SMS->Text[strlen(buffer)/2+1] = 0; sprintf(buffer,"Folder"); readvalue = ReadCFGText(file_info, section, buffer, false); if (readvalue!=NULL) SMS->Folder = atoi(readvalue); SMS->UDH.Type = UDH_NoUDH; SMS->UDH.Length = 0; SMS->UDH.ID8bit = -1; SMS->UDH.ID16bit = -1; SMS->UDH.PartNumber = -1; SMS->UDH.AllParts = -1; sprintf(buffer,"UDH"); readvalue = ReadCFGText(file_info, section, buffer, false); if (readvalue!=NULL) { DecodeHexBin (SMS->UDH.Text, readvalue, strlen(readvalue)); SMS->UDH.Length = strlen(readvalue)/2; GSM_DecodeUDHHeader(&SMS->UDH); } } static GSM_Error GSM_ReadSMSBackupTextFile(char *FileName, GSM_SMS_Backup *backup) { INI_Section *file_info, *h; char *readvalue; int num; backup->SMS[0] = NULL; file_info = INI_ReadFile(FileName, false); num = 0; for (h = file_info; h != NULL; h = h->Next) { if (mystrncasecmp("SMSBackup", h->SectionName, 9)) { readvalue = ReadCFGText(file_info, h->SectionName, "Number", false); if (readvalue==NULL) break; if (num < GSM_BACKUP_MAX_SMS) { backup->SMS[num] = malloc(sizeof(GSM_SMSMessage)); if (backup->SMS[num] == NULL) return ERR_MOREMEMORY; backup->SMS[num + 1] = NULL; } else { dbgprintf("Increase GSM_BACKUP_MAX_SMS\n"); return ERR_MOREMEMORY; } backup->SMS[num]->Location = num + 1; ReadSMSBackupEntry(file_info, h->SectionName, backup->SMS[num]); num++; } } return ERR_NONE; } GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) { FILE *file; backup->SMS[0] = NULL; file = fopen(FileName, "rb"); if (file == NULL) return(ERR_CANTOPENFILE); fclose(file); return GSM_ReadSMSBackupTextFile(FileName, backup); } -GSM_Error SaveSMSBackupTextFile(FILE *file, GSM_SMS_Backup *backup) +static GSM_Error SaveSMSBackupTextFile(FILE *file, GSM_SMS_Backup *backup) { int i,w,current; unsigned char buffer[10000]; GSM_DateTime DT; fprintf(file,"\n# File created by Gammu (www.mwiacek.com) version %s\n",VERSION); GSM_GetCurrentDateTime (&DT); - fprintf(file,"# Saved %s\n\n",OSDateTime(DT,false)); + fprintf(file,"# Saved "); + fprintf(file, "%04d%02d%02dT%02d%02d%02d", + DT.Year, DT.Month, DT.Day, + DT.Hour, DT.Minute, DT.Second); + fprintf(file," (%s)\n\n",OSDateTime(DT,false)); i=0; while (backup->SMS[i]!=NULL) { fprintf(file,"[SMSBackup%03i]\n",i); switch (backup->SMS[i]->Coding) { case SMS_Coding_Unicode: case SMS_Coding_Default: sprintf(buffer,"%s",DecodeUnicodeString(backup->SMS[i]->Text)); fprintf(file,"#"); current = 0; for (w=0;w<(int)(strlen(buffer));w++) { switch (buffer[w]) { case 10: fprintf(file,"\n#"); current = 0; break; case 13: break; default: if (isprint(buffer[w])) { fprintf(file,"%c",buffer[w]); current ++; } if (current == 75) { fprintf(file,"\n#"); current = 0; } } } fprintf(file,"\n"); break; default: break; } if (backup->SMS[i]->PDU == SMS_Deliver) { SaveBackupText(file, "SMSC", backup->SMS[i]->SMSC.Number, false); if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"SMSCReply = true\n"); fprintf(file,"Sent"); SaveVCalDateTime(file,&backup->SMS[i]->DateTime, false); } fprintf(file,"State = "); switch (backup->SMS[i]->State) { case SMS_UnRead : fprintf(file,"UnRead\n"); break; case SMS_Read : fprintf(file,"Read\n"); break; case SMS_Sent : fprintf(file,"Sent\n"); break; case SMS_UnSent : fprintf(file,"UnSent\n"); break; } SaveBackupText(file, "Number", backup->SMS[i]->Number, false); SaveBackupText(file, "Name", backup->SMS[i]->Name, false); if (backup->SMS[i]->UDH.Type != UDH_NoUDH) { EncodeHexBin(buffer,backup->SMS[i]->UDH.Text,backup->SMS[i]->UDH.Length); fprintf(file,"UDH = %s\n",buffer); } switch (backup->SMS[i]->Coding) { case SMS_Coding_Unicode: case SMS_Coding_Default: EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length*2); break; default: EncodeHexBin(buffer,backup->SMS[i]->Text,backup->SMS[i]->Length); break; } SaveLinkedBackupText(file, "Text", buffer, false); switch (backup->SMS[i]->Coding) { case SMS_Coding_Unicode : fprintf(file,"Coding = Unicode\n"); break; case SMS_Coding_Default : fprintf(file,"Coding = Default\n"); break; case SMS_Coding_8bit : fprintf(file,"Coding = 8bit\n"); break; } fprintf(file,"Folder = %i\n",backup->SMS[i]->Folder); fprintf(file,"Length = %i\n",backup->SMS[i]->Length); fprintf(file,"Class = %i\n",backup->SMS[i]->Class); fprintf(file,"ReplySMSC = "); if (backup->SMS[i]->ReplyViaSameSMSC) fprintf(file,"True\n"); else fprintf(file,"False\n"); fprintf(file,"RejectDuplicates = "); if (backup->SMS[i]->RejectDuplicates) fprintf(file,"True\n"); else fprintf(file,"False\n"); fprintf(file,"ReplaceMessage = %i\n",backup->SMS[i]->ReplaceMessage); fprintf(file,"MessageReference = %i\n",backup->SMS[i]->MessageReference); fprintf(file,"\n"); i++; } return ERR_NONE; } -GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) +GSM_Error GSM_AddSMSBackupFile(char *FileName, GSM_SMS_Backup *backup) { FILE *file; - file = fopen(FileName, "wb"); + file = fopen(FileName, "ab"); if (file == NULL) return(ERR_CANTOPENFILE); SaveSMSBackupTextFile(file,backup); fclose(file); return ERR_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/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h index 2d2dd7a..33e5424 100644 --- a/gammu/emb/common/service/gsmring.h +++ b/gammu/emb/common/service/gsmring.h @@ -78,127 +78,127 @@ typedef enum { typedef enum { Scale_55 = 1, /* 55 Hz for note A */ Scale_110, /* 110 Hz for note A */ Scale_220, Scale_440, /* first scale for Nokia */ Scale_880, Scale_1760, Scale_3520, /* last scale for Nokia */ Scale_7040, Scale_14080 } GSM_RingNoteScale; 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[50000]; int Length; } GSM_NokiaBinaryRingtone; typedef struct { unsigned char *Buffer; int Length; } GSM_BinaryTone; typedef enum { RING_NOTETONE = 1, RING_NOKIABINARY, 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; typedef struct { int Number; - GSM_RingtoneInfo Ringtone[100]; + GSM_RingtoneInfo *Ringtone; } GSM_AllRingtonesInfo; GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone); GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone); void saveott(FILE *file, GSM_Ringtone *ringtone); void savemid(FILE *file, GSM_Ringtone *ringtone); void saverng(FILE *file, GSM_Ringtone *ringtone); void saveimelody(FILE *file, GSM_Ringtone *ringtone); GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone); GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone); unsigned char GSM_EncodeNokiaRTTLRingtone (GSM_Ringtone ringtone, unsigned char *package, int *maxlength); unsigned char GSM_EncodeEMSSound (GSM_Ringtone ringtone, unsigned char *package, int *maxlength, double version, bool start); GSM_Error GSM_DecodeNokiaRTTLRingtone (GSM_Ringtone *ringtone, unsigned char *package, int maxlength); GSM_Error GSM_RingtoneConvert(GSM_Ringtone *dest, GSM_Ringtone *src, GSM_RingtoneFormat Format); int GSM_RTTLGetTempo (int Beats); int GSM_RingNoteGetFrequency (GSM_RingNote Note); int GSM_RingNoteGetFullDuration (GSM_RingNote Note); char *GSM_GetRingtoneName(GSM_AllRingtonesInfo *Info, int ID); #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/gammu.c b/gammu/emb/gammu/gammu.c index 684e67c..4c6486d 100644 --- a/gammu/emb/gammu/gammu.c +++ b/gammu/emb/gammu/gammu.c @@ -342,390 +342,398 @@ static void GetDateTime(int argc, char *argv[]) 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"); break; case ERR_NONE: if (alarm.Repeating) { printmsg("Date: %s\n","Every day"); } else { printmsg("Date: %s\n",OSDate(alarm.DateTime)); } printmsg("Time: %02d:%02d\n",alarm.DateTime.Hour, alarm.DateTime.Minute); if (alarm.Text[0] != 0 || alarm.Text[1] != 0) { printmsg("Text: \"%s\"\n", DecodeUnicodeConsole(alarm.Text)); } break; default: Print_Error(error); } GSM_Terminate(); } static void SetAlarm(int argc, char *argv[]) { GSM_Alarm alarm; alarm.DateTime.Hour = atoi(argv[2]); alarm.DateTime.Minute = atoi(argv[3]); alarm.DateTime.Second = 0; alarm.Location = 1; alarm.Repeating = true; alarm.Text[0] = 0; alarm.Text[1] = 0; GSM_Init(true); error=Phone->SetAlarm(&s, &alarm); Print_Error(error); GSM_Terminate(); } GSM_Bitmap caller[5]; -GSM_AllRingtonesInfo Info; +GSM_AllRingtonesInfo Info = {0, NULL}; bool callerinit[5] = {false, false, false, false, false}; bool ringinit = false; static void PrintMemoryEntry(GSM_MemoryEntry *entry) { GSM_Category Category; bool unknown; int z; for (i=0;i<entry->EntriesNum;i++) { unknown = false; switch (entry->Entries[i].EntryType) { case PBK_Date: printmsg("Date and time : %s\n",OSDateTime(entry->Entries[i].Date,false)); continue; case PBK_Category: Category.Location = entry->Entries[i].Number; Category.Type = Category_Phonebook; error=Phone->GetCategory(&s, &Category); if (error == ERR_NONE) { printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), entry->Entries[i].Number); } else { printmsg("Category : %i\n", entry->Entries[i].Number); } continue; case PBK_Private: printmsg("Private : %s\n", entry->Entries[i].Number == 1 ? "Yes" : "No"); continue; case PBK_Number_General : printmsg("General number "); break; case PBK_Number_Mobile : printmsg("Mobile number "); break; case PBK_Number_Work : printmsg("Work number "); break; case PBK_Number_Fax : printmsg("Fax number "); break; case PBK_Number_Home : printmsg("Home number "); break; case PBK_Number_Pager : printmsg("Pager number "); break; case PBK_Number_Other : printmsg("Other number "); break; case PBK_Text_Note : printmsg("Text "); break; case PBK_Text_Postal : printmsg("Snail address "); break; case PBK_Text_Email : printmsg("Email address 1 "); break; case PBK_Text_Email2 : printmsg("Email address 2 "); break; case PBK_Text_URL : printmsg("URL address "); break; case PBK_Text_Name : printmsg("Name "); break; case PBK_Text_LastName : printmsg("Last name "); break; case PBK_Text_FirstName : printmsg("First name "); break; case PBK_Text_Company : printmsg("Company "); break; case PBK_Text_JobTitle : printmsg("Job title "); break; case PBK_Text_StreetAddress : printmsg("Street address "); break; case PBK_Text_City : printmsg("City "); break; case PBK_Text_State : printmsg("State "); break; case PBK_Text_Zip : printmsg("Zip code "); break; case PBK_Text_Country : printmsg("Country "); break; case PBK_Text_Custom1 : printmsg("Custom text 1 "); break; case PBK_Text_Custom2 : printmsg("Custom text 2 "); break; case PBK_Text_Custom3 : printmsg("Custom text 3 "); break; case PBK_Text_Custom4 : printmsg("Custom text 4 "); break; case PBK_Caller_Group : unknown = true; if (!callerinit[entry->Entries[i].Number]) { caller[entry->Entries[i].Number].Type = GSM_CallerGroupLogo; caller[entry->Entries[i].Number].Location = entry->Entries[i].Number; error=Phone->GetBitmap(&s,&caller[entry->Entries[i].Number]); Print_Error(error); if (caller[entry->Entries[i].Number].DefaultName) { NOKIA_GetDefaultCallerGroupName(&s,&caller[entry->Entries[i].Number]); } callerinit[entry->Entries[i].Number]=true; } printmsg("Caller group : \"%s\"\n",DecodeUnicodeConsole(caller[entry->Entries[i].Number].Text)); break; case PBK_RingtoneID : unknown = true; if (!ringinit) { error=Phone->GetRingtonesInfo(&s,&Info); if (error != ERR_NOTSUPPORTED) Print_Error(error); if (error == ERR_NONE) ringinit = true; } if (ringinit) { for (z=0;z<Info.Number;z++) { if (Info.Ringtone[z].ID == entry->Entries[i].Number) { printmsg("Ringtone : \"%s\"\n",DecodeUnicodeConsole(Info.Ringtone[z].Name)); break; } } } else { printmsg("Ringtone ID : %i\n",entry->Entries[i].Number); } break; case PBK_PictureID : unknown = true; printmsg("Picture ID : 0x%x\n",entry->Entries[i].Number); break; default : printmsg("UNKNOWN\n"); unknown = true; break; } if (!unknown) printmsg(" : \"%s\"\n", DecodeUnicodeConsole(entry->Entries[i].Text)); } printf("\n"); } static void GetAllMemory(int argc, char *argv[]) { GSM_MemoryEntry Entry; bool start = true; signal(SIGINT, interrupt); printmsgerr("Press Ctrl+C to break...\n"); 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; + if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone); Print_Error(error); printmsg("Memory %s, Location %i\n",argv[2],Entry.Location); PrintMemoryEntry(&Entry); start = false; } + if (Info.Ringtone) free(Info.Ringtone); + GSM_Terminate(); } static void GetMemory(int argc, char *argv[]) { 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++) { 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) { + if (Info.Ringtone) free(Info.Ringtone); + 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); + + if (Info.Ringtone) free(Info.Ringtone); 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 (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); SearchOneEntry(&Entry, Text); start = false; } } else { while (i < Status.MemoryUsed) { Entry.Location = l; error = Phone->GetMemory(&s, &Entry); if (error != ERR_EMPTY) { Print_Error(error); i++; SearchOneEntry(&Entry, Text); } fprintf(stderr,"%c%s: %i%%", 13, Title, (i+1)*100/(Status.MemoryUsed+1)); l++; } } fprintf(stderr,"\n"); @@ -1530,203 +1538,206 @@ static void GetEachSMS(int argc, char *argv[]) GSM_PhoneBeep(); #endif error = GSM_LinkSMS(GetSMS, SortedSMS, ems); Print_Error(error); i=0; while(GetSMS[i] != NULL) { free(GetSMS[i]); GetSMS[i] = NULL; i++; } i=0; while(SortedSMS[i] != NULL) { for (j=0;j<SortedSMS[i]->Number;j++) { if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) { printmsg("Location %i, folder \"%s\"",SortedSMS[i]->SMS[j].Location,DecodeUnicodeConsole(folders.Folder[SortedSMS[i]->SMS[j].Folder-1].Name)); switch(SortedSMS[i]->SMS[j].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 (SortedSMS[i]->SMS[j].InboxFolder) printmsg(", Inbox folder"); printf("\n"); } } displaymultismsinfo(*SortedSMS[i],true,ems); free(SortedSMS[i]); SortedSMS[i] = NULL; i++; } GSM_Terminate(); } static void GetSMSFolders(int argc, char *argv[]) { GSM_SMSFolders folders; GSM_Init(true); error=Phone->GetSMSFolders(&s,&folders); Print_Error(error); for (i=0;i<folders.Number;i++) { printmsg("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name)); 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"); 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; + GSM_AllRingtonesInfo Info = {0, NULL}; int i; GSM_Init(true); error=Phone->GetRingtonesInfo(&s,&Info); + if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone); Print_Error(error); GSM_Terminate(); for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); + + if (Info.Ringtone) free(Info.Ringtone); } 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; } else if (mystrncasecmp(argv[3],"hide",0)) { ShowNumber = GSM_CALL_HideNumber; } else { printmsg("Unknown parameter (\"%s\")\n",argv[3]); exit(-1); } } GSM_Init(true); error=Phone->DialVoice(&s, argv[2], ShowNumber); Print_Error(error); GSM_Terminate(); } static void CancelCall(int argc, char *argv[]) { GSM_Init(true); if (argc>2) { error=Phone->CancelCall(&s,atoi(argv[2]),false); } else { error=Phone->CancelCall(&s,0,true); } Print_Error(error); GSM_Terminate(); } static void AnswerCall(int argc, char *argv[]) { GSM_Init(true); if (argc>2) { error=Phone->AnswerCall(&s,atoi(argv[2]),false); } else { error=Phone->AnswerCall(&s,0,true); } Print_Error(error); GSM_Terminate(); } static void UnholdCall(int argc, char *argv[]) { GSM_Init(true); error=Phone->UnholdCall(&s,atoi(argv[2])); Print_Error(error); GSM_Terminate(); } static void HoldCall(int argc, char *argv[]) { GSM_Init(true); error=Phone->HoldCall(&s,atoi(argv[2])); Print_Error(error); GSM_Terminate(); } static void ConferenceCall(int argc, char *argv[]) { GSM_Init(true); error=Phone->ConferenceCall(&s,atoi(argv[2])); Print_Error(error); GSM_Terminate(); } static void SplitCall(int argc, char *argv[]) { GSM_Init(true); error=Phone->SplitCall(&s,atoi(argv[2])); Print_Error(error); GSM_Terminate(); } static void SwitchCall(int argc, char *argv[]) { GSM_Init(true); if (argc > 2) { @@ -2084,263 +2095,265 @@ 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[]) { GSM_WAPBookmark bookmark; int start,stop; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { bookmark.Location=i; error=Phone->GetWAPBookmark(&s,&bookmark); Print_Error(error); printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title)); printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address)); } GSM_Terminate(); } static void DeleteWAPBookmark(int argc, char *argv[]) { GSM_WAPBookmark bookmark; int start, stop; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { bookmark.Location=i; error=Phone->DeleteWAPBookmark(&s, &bookmark); Print_Error(error); } GSM_Terminate(); } static void GetGPRSPoint(int argc, char *argv[]) { GSM_GPRSAccessPoint point; int start,stop; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { point.Location=i; error=Phone->GetGPRSAccessPoint(&s,&point); if (error != ERR_EMPTY) { Print_Error(error); printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name)); } else { printmsg("%i. Access point %i",point.Location,point.Location); } if (point.Active) printmsg(" (active)"); if (error != ERR_EMPTY) { printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL)); } else { printmsg("\n\n"); } } GSM_Terminate(); } static void GetBitmap(int argc, char *argv[]) { GSM_File File; GSM_MultiBitmap MultiBitmap; int location=0; - GSM_AllRingtonesInfo Info; + GSM_AllRingtonesInfo Info = {0, NULL}; if (mystrncasecmp(argv[2],"STARTUP",0)) { MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; } else if (mystrncasecmp(argv[2],"CALLER",0)) { MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo; GetStartStop(&location, NULL, 3, argc, argv); if (location>5) { printmsg("Maximal location for caller logo can be 5\n"); exit (-1); } } else if (mystrncasecmp(argv[2],"PICTURE",0)) { MultiBitmap.Bitmap[0].Type=GSM_PictureImage; GetStartStop(&location, NULL, 3, argc, argv); } else if (mystrncasecmp(argv[2],"TEXT",0)) { MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text; } else if (mystrncasecmp(argv[2],"DEALER",0)) { MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text; } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo; } else { printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]); exit(-1); } MultiBitmap.Bitmap[0].Location=location; GSM_Init(true); error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]); Print_Error(error); MultiBitmap.Number = 1; error=ERR_NONE; switch (MultiBitmap.Bitmap[0].Type) { case GSM_CallerGroupLogo: if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)"); printf("\n"); if (MultiBitmap.Bitmap[0].DefaultRingtone) { printmsg("Ringtone : default\n"); } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) { sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID); File.Buffer = NULL; File.Used = 0; error = ERR_NONE; // while (error == ERR_NONE) { error = Phone->GetFilePart(&s,&File); // } if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); error = ERR_NONE; printmsg("Ringtone : \"%s\" (file with ID %i)\n", DecodeUnicodeString(File.Name), MultiBitmap.Bitmap[0].RingtoneID); } else { error = Phone->GetRingtonesInfo(&s,&Info); if (error != ERR_NONE) Info.Number = 0; error = ERR_NONE; 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 (Info.Ringtone) free(Info.Ringtone); } 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; if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4; if (MultiBitmap.Bitmap[0].Location == 1) { error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); Print_Error(error); } memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); } else if (mystrncasecmp(argv[2],"TEXT",0)) { if (argc<4) { printmsg("More arguments required\n"); exit(-1); } Bitmap.Type=GSM_WelcomeNote_Text; EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); } else if (mystrncasecmp(argv[2],"DEALER",0)) { if (argc<4) { printmsg("More arguments required\n"); exit(-1); } Bitmap.Type=GSM_DealerNote_Text; EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); } else if (mystrncasecmp(argv[2],"CALLER",0)) { if (argc<4) { printmsg("More arguments required\n"); exit(-1); } GetStartStop(&i, NULL, 3, argc, argv); if (i>5 && i!=255) { printmsg("Maximal location for caller logo can be 5\n"); exit (-1); } MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo; MultiBitmap.Bitmap[0].Location = i; if (argc>4) { error=GSM_ReadBitmapFile(argv[4],&MultiBitmap); Print_Error(error); } memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); if (i!=255) { @@ -4552,192 +4565,193 @@ static void Backup(int argc, char *argv[]) GSM_Terminate(); exit(-1); } *Backup.Profiles[used]=Profile; used++; printmsgerr("*"); } printmsgerr("\n"); } DoBackup = false; if (Info.FMStation) { printmsg("Checking FM stations\n"); FMStation.Location = 1; error = Phone->GetFMStation(&s,&FMStation); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes(" Backup phone FM stations")) DoBackup=true; } } if (DoBackup) { used = 0; i = 1; printmsgerr(" Reading: "); while (error == ERR_NONE || error == ERR_EMPTY) { error = Phone->GetFMStation(&s,&FMStation); if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_FMSTATIONS) { Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.FMStation[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); GSM_Terminate(); exit(-1); } *Backup.FMStation[used]=FMStation; used++; } i++; FMStation.Location = i; printmsgerr("*"); } printmsgerr("\n"); } DoBackup = false; if (Info.GPRSPoint) { printmsg("Checking GPRS access points\n"); GPRSPoint.Location = 1; error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes(" Backup GPRS access points")) DoBackup = true; } } if (DoBackup) { used = 0; i = 1; printmsgerr(" Reading: "); while (error == ERR_NONE || error == ERR_EMPTY) { error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_GPRSPOINT) { Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.GPRSPoint[used + 1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); GSM_Terminate(); exit(-1); } *Backup.GPRSPoint[used]=GPRSPoint; used++; } i++; GPRSPoint.Location = i; 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_NoteEntry Note; 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); /* LR 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++; dbgprintf("Location %i\n",Pbk.Location); if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); } } if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.SIMPhonebook[0] != NULL) { MemStatus.MemoryType = MEM_SM; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE) { max = 0; while (Backup.SIMPhonebook[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); if (answer_yes("Restore SIM phonebook")) DoRestore = true; } } if (DoRestore) { used = 0; for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_SM; Pbk.Location = i + 1; Pbk.EntriesNum = 0; if (used<max) { if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { Pbk = *Backup.SIMPhonebook[used]; used++; dbgprintf("Location %i\n",Pbk.Location); if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); } } if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); @@ -4821,192 +4835,228 @@ static void Restore(int argc, char *argv[]) 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) { max = 0; while (Backup.ToDo[max]!=NULL) max++; printmsgerr("%i entries in backup file\n",max); //LR if (answer_yes("Restore ToDo")) DoRestore = true; } } if (DoRestore) { 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; error = Phone->GetNextToDo(&s,&ToDo,true); while (error == ERR_NONE) { used++; Found = false; for (i=0;i<max;i++) { if (Backup.ToDo[i]->Location == ToDo.Location) { Found = true; break; } } if (!Found) { error=Phone->DeleteToDo(&s,&ToDo); Print_Error(error); } error = Phone->GetNextToDo(&s,&ToDo,false); printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); /* Now write modified/new entries */ for (i=0;i<max;i++) { ToDo = *Backup.ToDo[i]; error = Phone->SetToDo(&s,&ToDo); 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->GetNotesStatus(&s,&ToDoStatus); + if (error == ERR_NONE) { + max = 0; + while (Backup.Note[max]!=NULL) max++; + printmsgerr("%i entries in backup file\n",max); + + if (answer_yes("Restore Notes")) DoRestore = true; + } + } + if (DoRestore) { + printmsgerr("Deleting old Notes: "); + while (1) { + error = Phone->GetNextNote(&s,&Note,true); + if (error != ERR_NONE) break; + error = Phone->DeleteNote(&s,&Note); + Print_Error(error); + printmsgerr("*"); + } + printmsgerr("\n"); + + for (i=0;i<max;i++) { + Note = *Backup.Note[i]; + Note.Location = 0; + error=Phone->AddNote(&s,&Note); + Print_Error(error); + printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); + if (gshutdown) { + GSM_Terminate(); + exit(0); + } + } + printmsgerr("\n"); + } + if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { max = 0; while (Backup.SMSC[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetSMSC(&s,Backup.SMSC[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { error=Phone->SetBitmap(&s,Backup.StartupLogo); Print_Error(error); } if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { error=Phone->SetBitmap(&s,Backup.OperatorLogo); Print_Error(error); } DoRestore = false; if (Backup.WAPBookmark[0] != NULL) { Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { if (answer_yes("Restore WAP bookmarks")) DoRestore = true; } } if (DoRestore) { printmsgerr("Deleting old bookmarks: "); /* One thing to explain: DCT4 phones seems to have bug here. * When delete for example first bookmark, phone change * numeration for getting frame, not for deleting. So, we try to * get 1'st bookmark. Inside frame is "correct" location. We use * it later */ while (error==ERR_NONE) { error = Phone->DeleteWAPBookmark(&s,&Bookmark); Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); printmsgerr("*"); } printmsgerr("\n"); max = 0; while (Backup.WAPBookmark[max]!=NULL) max++; for (i=0;i<max;i++) { Bookmark = *Backup.WAPBookmark[i]; Bookmark.Location = 0; error=Phone->SetWAPBookmark(&s,&Bookmark); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.WAPSettings[0] != NULL) { Settings.Location = 1; error = Phone->GetWAPSettings(&s,&Settings); if (error == ERR_NONE) { if (answer_yes("Restore WAP settings")) DoRestore = true; } } if (DoRestore) { max = 0; while (Backup.WAPSettings[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } DoRestore = false; if (Backup.MMSSettings[0] != NULL) { Settings.Location = 1; error = Phone->GetMMSSettings(&s,&Settings); if (error == ERR_NONE) { if (answer_yes("Restore MMS settings")) DoRestore = true; } } if (DoRestore) { max = 0; while (Backup.MMSSettings[max]!=NULL) max++; for (i=0;i<max;i++) { error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); Print_Error(error); @@ -5194,301 +5244,319 @@ static void AddNew(int argc, char *argv[]) Pbk.MemoryType = MEM_SM; 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"); } } } if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { if (true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) { GSM_GetCurrentDateTime(&date_time); error=Phone->SetDateTime(&s, &date_time); Print_Error(error); } } if (Backup.Calendar[0] != NULL) { error = Phone->GetNextCalendar(&s,&Calendar,true); if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { if (answer_yes("Add calendar notes")) { max = 0; while (Backup.Calendar[max]!=NULL) max++; for (i=0;i<max;i++) { 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"); } } } if (Backup.ToDo[0] != NULL) { ToDo.Location = 1; error=Phone->GetToDoStatus(&s,&ToDoStatus); if (error == ERR_NONE) { if (answer_yes("Add ToDo")) { max = 0; while (Backup.ToDo[max]!=NULL) max++; for (i=0;i<max;i++) { ToDo = *Backup.ToDo[i]; 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"); } } } if (Backup.WAPBookmark[0] != NULL) { Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { if (answer_yes("Add WAP bookmarks")) { max = 0; while (Backup.WAPBookmark[max]!=NULL) max++; for (i=0;i<max;i++) { Bookmark = *Backup.WAPBookmark[i]; Bookmark.Location = 0; error=Phone->SetWAPBookmark(&s,&Bookmark); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } } } GSM_Terminate(); } #endif static void ClearAll(int argc, char *argv[]) { GSM_MemoryStatus MemStatus; GSM_ToDoStatus ToDoStatus; GSM_CalendarEntry Calendar; GSM_ToDoEntry ToDo; + GSM_NoteEntry Note; GSM_WAPBookmark Bookmark; GSM_FMStation Station; GSM_MemoryEntry Pbk; bool DoClear; GSM_Init(true); DoClear = false; MemStatus.MemoryType = MEM_ME; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { if (answer_yes("Delete phone phonebook")) DoClear = true; } if (DoClear) { error = Phone->DeleteAllMemory(&s,MEM_ME); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_ME; Pbk.Location = i + 1; Pbk.EntriesNum = 0; error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } } DoClear = false; MemStatus.MemoryType = MEM_SM; error=Phone->GetMemoryStatus(&s, &MemStatus); if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { if (answer_yes("Delete SIM phonebook")) DoClear = true; } if (DoClear) { error = Phone->DeleteAllMemory(&s,MEM_SM); if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { Pbk.MemoryType = MEM_SM; Pbk.Location = i + 1; Pbk.EntriesNum = 0; error=Phone->DeleteMemory(&s, &Pbk); Print_Error(error); printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); if (gshutdown) { GSM_Terminate(); exit(0); } } printmsgerr("\n"); } else { printmsgerr("Done\n"); Print_Error(error); } } DoClear = false; error = Phone->GetNextCalendar(&s,&Calendar,true); if (error == ERR_NONE) { if (answer_yes("Delete calendar notes")) DoClear = true; } if (DoClear) { printmsgerr("Deleting: "); 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); } } DoClear = false; error = Phone->GetToDoStatus(&s,&ToDoStatus); if (error == ERR_NONE && ToDoStatus.Used != 0) { if (answer_yes("Delete ToDo")) DoClear = true; } if (DoClear) { printmsgerr("Deleting: "); 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); } } + DoClear = false; + error = Phone->GetNotesStatus(&s,&ToDoStatus); + if (error == ERR_NONE && ToDoStatus.Used != 0) { + if (answer_yes("Delete Notes")) DoClear = true; + } + if (DoClear) { + printmsgerr("Deleting: "); + while (1) { + error = Phone->GetNextNote(&s,&Note,true); + if (error != ERR_NONE) break; + error = Phone->DeleteNote(&s,&Note); + Print_Error(error); + printmsgerr("*"); + } + printmsgerr("\n"); + } + Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { if (answer_yes("Delete WAP bookmarks")) { printmsgerr("Deleting: "); /* One thing to explain: DCT4 phones seems to have bug here. * When delete for example first bookmark, phone change * numeration for getting frame, not for deleting. So, we try to * get 1'st bookmark. Inside frame is "correct" location. We use * it later */ while (error==ERR_NONE) { error = Phone->DeleteWAPBookmark(&s,&Bookmark); Bookmark.Location = 1; error = Phone->GetWAPBookmark(&s,&Bookmark); printmsgerr("*"); } printmsgerr("\n"); } } if (Phone->DeleteUserRingtones != NOTSUPPORTED) { if (answer_yes("Delete all user ringtones")) { printmsgerr("Deleting: "); error=Phone->DeleteUserRingtones(&s); Print_Error(error); printmsgerr("Done\n"); } } Station.Location=i; error=Phone->GetFMStation(&s,&Station); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes("Delete all FM station")) { error=Phone->ClearFMStations(&s); Print_Error(error); } } GSM_Terminate(); } static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) { if (settings->Settings[j].IsContinuous) { printmsg("Connection type : Continuous\n"); } else { printmsg("Connection type : Temporary\n"); } if (settings->Settings[j].IsSecurity) { printmsg("Connection security : On\n"); } else { printmsg("Connection security : Off\n"); } printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); switch (settings->Settings[j].Bearer) { case WAPSETTINGS_BEARER_SMS: printmsg("Bearer : SMS"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); break; case WAPSETTINGS_BEARER_DATA: printmsg("Bearer : Data (CSD)"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); if (settings->Settings[j].ManualLogin) { printmsg("Login Type : Manual\n"); } else { printmsg("Login Type : Automatic\n"); } if (settings->Settings[j].IsNormalAuthentication) { printmsg("Authentication type : Normal\n"); } else { printmsg("Authentication type : Secure\n"); } if (settings->Settings[j].IsISDNCall) { printmsg("Data call type : ISDN\n"); } else { printmsg("Data call type : Analogue\n"); } switch (settings->Settings[j].Speed) { case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; } printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); break; case WAPSETTINGS_BEARER_USSD: printmsg("Bearer : USSD"); if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); if (settings->Settings[j].IsIP) { printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); } else { @@ -5549,321 +5617,325 @@ static void GetSyncMLSettings(int argc, char *argv[]) if (settings.SyncCalendar) printmsg("yes\n"); if (!settings.SyncCalendar) printmsg("no\n"); printmsg("\n"); for (j=0;j<settings.Connection.Number;j++) { if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { printmsg("Connection set name : Set %i\n",i); } else { printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); } DisplayConnectionSettings(&settings.Connection,j); printf("\n"); } } GSM_Terminate(); } static void GetChatSettings(int argc, char *argv[]) { GSM_ChatSettings settings; int start,stop,j; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { settings.Location=i; error=Phone->GetChatSettings(&s,&settings); Print_Error(error); printmsg("%i. ",i); if (settings.Name[0]==0 && settings.Name[1]==0) { printmsg("Set %i",i); } else { printmsg("%s",DecodeUnicodeConsole(settings.Name)); } if (settings.Active) printmsg(" (active)"); // if (settings.ReadOnly) printmsg("\nRead only : yes"); printmsg("\n"); printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); printmsg("\n"); for (j=0;j<settings.Connection.Number;j++) { if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { printmsg("Connection set name : Set %i\n",i); } else { printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); } DisplayConnectionSettings(&settings.Connection,j); printf("\n"); } } GSM_Terminate(); } static void GetWAPMMSSettings(int argc, char *argv[]) { GSM_MultiWAPSettings settings; int start,stop,j; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { settings.Location=i; if (mystrncasecmp(argv[1],"--getwapsettings",0)) { error=Phone->GetWAPSettings(&s,&settings); } else { error=Phone->GetMMSSettings(&s,&settings); } Print_Error(error); for (j=0;j<settings.Number;j++) { printmsg("%i. ",i); if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { printmsg("Set %i",i); } else { printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); } if (settings.Active) printmsg(" (active)"); if (settings.ReadOnly) printmsg("\nRead only : yes"); printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); DisplayConnectionSettings(&settings,j); printf("\n"); } } GSM_Terminate(); } #ifdef GSM_ENABLE_BACKUP static void BackupSMS(int argc, char *argv[]) { GSM_SMS_Backup Backup; GSM_MultiSMSMessage sms; GSM_SMSFolders folders; bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; - bool start = true; + bool start = true; bool DeleteAfter; - int j, smsnum; + int j, smsnum = 0; char buffer[200]; - /* We ignore return code, because (when file doesn't exist) we - * will create new later - */ - GSM_ReadSMSBackupFile(argv[2], &Backup); - smsnum = 0; - while (Backup.SMS[smsnum]!=NULL) smsnum++; - GSM_Init(true); error=Phone->GetSMSFolders(&s, &folders); Print_Error(error); DeleteAfter=answer_yes("Delete each sms after backup"); for (j=0;j<folders.Number;j++) { BackupFromFolder[j] = false; sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); + if (folders.Folder[j].Memory == MEM_SM) strcat(buffer," (SIM)"); if (answer_yes(buffer)) BackupFromFolder[j] = true; } 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); for (j=0;j<sms.Number;j++) { if (BackupFromFolder[sms.SMS[j].Folder-1]) { switch (sms.SMS[j].PDU) { case SMS_Status_Report: break; case SMS_Submit: case SMS_Deliver: if (sms.SMS[j].Length == 0) break; if (smsnum < GSM_BACKUP_MAX_SMS) { Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SMS[smsnum+1] = NULL; } else { printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); GSM_Terminate(); exit(-1); } *Backup.SMS[smsnum] = sms.SMS[j]; smsnum++; break; } } } } start=false; } - error = GSM_SaveSMSBackupFile(argv[2],&Backup); + error = GSM_AddSMSBackupFile(argv[2],&Backup); Print_Error(error); if (DeleteAfter) { for (j=0;j<smsnum;j++) { Backup.SMS[j]->Folder = 0; error=Phone->DeleteSMS(&s, Backup.SMS[j]); Print_Error(error); printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); } } GSM_Terminate(); } static void AddSMS(int argc, char *argv[]) { GSM_MultiSMSMessage SMS; GSM_SMS_Backup Backup; int smsnum = 0; int folder; folder = atoi(argv[2]); error = GSM_ReadSMSBackupFile(argv[3], &Backup); Print_Error(error); GSM_Init(true); while (Backup.SMS[smsnum] != NULL) { Backup.SMS[smsnum]->Folder = folder; Backup.SMS[smsnum]->SMSC.Location = 1; SMS.Number = 1; SMS.SMS[0] = *Backup.SMS[smsnum]; displaymultismsinfo(SMS,false,false); 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]; + bool restore8bit,doit; error=GSM_ReadSMSBackupFile(argv[2], &Backup); Print_Error(error); + sprintf(buffer,"Do you want to restore binary SMS"); + restore8bit = answer_yes(buffer); + 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)) { - error=Phone->AddSMS(&s, Backup.SMS[smsnum]); - Print_Error(error); + doit = true; + if (!restore8bit && Backup.SMS[smsnum]->Coding == SMS_Coding_8bit) doit = false; + if (doit) { + SMS.Number = 1; + memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); + displaymultismsinfo(SMS,false,false); + sprintf(buffer,"Restore %03i sms to folder \"%s\"",smsnum+1,DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); + if (folders.Folder[Backup.SMS[smsnum]->Folder-1].Memory == MEM_SM) strcat(buffer," (SIM)"); + if (answer_yes(buffer)) { + smprintf(&s,"saving %i SMS\n",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 { if (argc == 5) { for (i=0;i<Bitmap.Number;i++) { if (mystrncasecmp(argv[4],"PICTURE",0)) { Bitmap.Bitmap[i].Type = GSM_PictureImage; } else if (mystrncasecmp(argv[4],"STARTUP",0)) { Bitmap.Bitmap[i].Type = GSM_StartupLogo; } else if (mystrncasecmp(argv[4],"CALLER",0)) { Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { Bitmap.Bitmap[i].Type = GSM_OperatorLogo; } else { printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); exit(-1); } } } error=GSM_SaveBitmapFile(argv[3],&Bitmap); Print_Error(error); } } static void NokiaComposer(int argc, char *argv[]) { GSM_Ringtone ringtone; bool started; int i,j; GSM_RingNote *Note; GSM_RingNoteDuration Duration; GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ unsigned int DefNoteScale = Scale_880; ringtone.Format = 0; error=GSM_ReadRingtoneFile(argv[2],&ringtone); if (ringtone.Format != RING_NOTETONE) { printmsg("It can be RTTL ringtone only used with this option\n"); exit(-1); } started = false; j = 0; for (i=0;i<ringtone.NoteTone.NrCommands;i++) { if (ringtone.NoteTone.Commands[i].Type == RING_Note) { Note = &ringtone.NoteTone.Commands[i].Note; if (!started) { if (Note->Note != Note_Pause) { printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); started = true; } } if (started) j++; } } if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); started = false; for (i=0;i<ringtone.NoteTone.NrCommands;i++) { if (ringtone.NoteTone.Commands[i].Type == RING_Note) { Note = &ringtone.NoteTone.Commands[i].Note; if (!started) { if (Note->Note != Note_Pause) started = true; } if (started) { switch (Note->Duration) { @@ -6267,319 +6339,322 @@ static void GetToDo(int argc, char *argv[]) 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 GetAllNotes(int argc, char *argv[]) { GSM_NoteEntry Note; bool start = true; signal(SIGINT, interrupt); printmsgerr("Press Ctrl+C to break...\n"); GSM_Init(true); 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"); 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); GSM_Terminate(); } static void GetProfile(int argc, char *argv[]) { GSM_Profile Profile; int start,stop,j,k; GSM_Bitmap caller[5]; bool callerinit[5],special; - GSM_AllRingtonesInfo Info; + GSM_AllRingtonesInfo Info = {0, NULL}; GetStartStop(&start, &stop, 2, argc, argv); for (i=0;i<5;i++) callerinit[i] = false; GSM_Init(true); error=Phone->GetRingtonesInfo(&s,&Info); if (error != ERR_NONE) Info.Number = 0; for (i=start;i<=stop;i++) { Profile.Location=i; error=Phone->GetProfile(&s,&Profile); + if (error != ERR_NONE && Info.Ringtone) free(Info.Ringtone); Print_Error(error); printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); if (Profile.Active) printmsg(" (active)"); if (Profile.DefaultName) printmsg(" (default name)"); if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); printf("\n"); for (j=0;j<Profile.FeaturesNumber;j++) { special = false; switch (Profile.FeatureID[j]) { case Profile_MessageToneID: case Profile_RingtoneID: special = true; if (Profile.FeatureID[j] == Profile_RingtoneID) { printmsg("Ringtone ID : "); } else { printmsg("Message alert tone ID : "); } if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); } else { printmsg("%i\n",Profile.FeatureValue[j]); } break; case Profile_CallerGroups: special = true; printmsg("Call alert for :"); for (k=0;k<5;k++) { if (Profile.CallerGroups[k]) { if (!callerinit[k]) { caller[k].Type = GSM_CallerGroupLogo; caller[k].Location = k + 1; error=Phone->GetBitmap(&s,&caller[k]); if (error == ERR_SECURITYERROR) { NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); } else { Print_Error(error); } callerinit[k] = true; } printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); } } printf("\n"); break; case Profile_ScreenSaverNumber: special = true; printmsg("Screen saver number : "); printmsg("%i\n",Profile.FeatureValue[j]); break; case Profile_CallAlert : printmsg("Incoming call alert : "); break; case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; case Profile_Vibration : printmsg("Vibrating alert : "); break; case Profile_MessageTone : printmsg("Message alert tone : "); break; case Profile_KeypadTone : printmsg("Keypad tones : "); break; case Profile_WarningTone : printmsg("Warning (games) tones : "); break; case Profile_ScreenSaver : printmsg("Screen saver : "); break; case Profile_ScreenSaverTime : printmsg("Screen saver timeout : "); break; case Profile_AutoAnswer : printmsg("Automatic answer : "); break; case Profile_Lights : printmsg("Lights : "); break; default: printmsg("Unknown\n"); special = true; } if (!special) { switch (Profile.FeatureValue[j]) { case PROFILE_VOLUME_LEVEL1 : case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; case PROFILE_VOLUME_LEVEL2 : case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; case PROFILE_VOLUME_LEVEL3 : case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; case PROFILE_MESSAGE_NOTONE : case PROFILE_AUTOANSWER_OFF : case PROFILE_LIGHTS_OFF : case PROFILE_SAVER_OFF : case PROFILE_WARNING_OFF : case PROFILE_CALLALERT_OFF : case PROFILE_VIBRATION_OFF : case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; case PROFILE_CALLALERT_BEEPONCE : case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n"); break; case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n"); break; case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; case PROFILE_AUTOANSWER_ON : case PROFILE_WARNING_ON : case PROFILE_SAVER_ON : case PROFILE_VIBRATION_ON : printmsg("On\n"); break; case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n"); break; case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n"); break; case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n"); break; case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n"); break; default : printmsg("UNKNOWN\n"); } } } printf("\n"); } GSM_Terminate(); + + if (Info.Ringtone) free(Info.Ringtone); } static void GetSpeedDial(int argc, char *argv[]) { GSM_SpeedDial SpeedDial; GSM_MemoryEntry Phonebook; int start,stop,Name,Number,Group; GetStartStop(&start, &stop, 2, argc, argv); GSM_Init(true); for (i=start;i<=stop;i++) { SpeedDial.Location=i; error=Phone->GetSpeedDial(&s,&SpeedDial); printmsg("%i.",i); switch (error) { case ERR_EMPTY: printmsg(" speed dial not assigned\n"); break; default: Print_Error(error); Phonebook.Location = SpeedDial.MemoryLocation; Phonebook.MemoryType = SpeedDial.MemoryType; error=Phone->GetMemory(&s,&Phonebook); GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); } printf("\n"); } GSM_Terminate(); } static void ResetPhoneSettings(int argc, char *argv[]) { GSM_ResetSettingsType Type; if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; } else { printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); exit(-1); } GSM_Init(true); error=Phone->ResetPhoneSettings(&s,Type); Print_Error(error); GSM_Terminate(); } #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) static void NokiaSecurityCode(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3GetSecurityCode(argc,argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 // DCT4ResetSecurityCode(argc, argv); DCT4GetSecurityCode(argc,argv); #endif GSM_Terminate(); } static void NokiaSetPhoneMenus(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3SetPhoneMenus (argc, argv); #endif #ifdef GSM_ENABLE_NOKIA_DCT4 DCT4SetPhoneMenus (argc, argv); #endif GSM_Terminate(); } static void NokiaSelfTests(int argc, char *argv[]) { GSM_Init(true); #ifdef GSM_ENABLE_NOKIA_DCT3 DCT3SelfTests(argc, argv); @@ -7886,193 +7961,193 @@ static void SearchPhone(int argc, char *argv[]) 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 */ 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, 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}, ""}, + {"--playsavedringtone", 1, 1, DCT4PlaySavedRingtone, {H_Ringtone,0}, "number"}, {"--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, 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}, ""}, diff --git a/gammu/emb/gammu/smsd/s_files.c b/gammu/emb/gammu/smsd/s_files.c index b791e58..e1c626f 100644 --- a/gammu/emb/gammu/smsd/s_files.c +++ b/gammu/emb/gammu/smsd/s_files.c @@ -1,165 +1,165 @@ /* (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; for (i=0;i<sms.Number && !done;i++) { strcpy(ext, "txt"); if (sms.SMS[i].Coding == SMS_Coding_8bit) strcpy(ext, "bin"); DecodeUnicode(sms.SMS[i].Number,buffer2); /* we loop on yy for the first SMS assuming that if xxxx_yy_00.ext is absent, any xxxx_yy_01,02, must be garbage, that can be overwritten */ file = NULL; do { sprintf(FileName, "IN%02d%02d%02d_%02d%02d%02d_%02i_%s_%02i.%s", 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, j, buffer2, i, ext); strcpy(FullName, Config->inboxpath); strcat(FullName, FileName); if (file) fclose(file); file = fopen(FullName, "r"); } while ((i == 0) && (file && (++j < 100))); if (file) { fclose(file); if (i == 0) { WriteSMSDLog("Cannot save %s. No available file names", FileName); return ERR_CANTOPENFILE; } } errno = 0; 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); } else { #ifdef GSM_ENABLE_BACKUP if (mystrncasecmp(Config->inboxformat, "detail", 0)) { for (j=0;j<sms.Number;j++) backup.SMS[j] = &sms.SMS[j]; backup.SMS[sms.Number] = NULL; - error = GSM_SaveSMSBackupFile(FullName, &backup); + error = GSM_AddSMSBackupFile(FullName, &backup); done = true; } #endif if (!mystrncasecmp(Config->inboxformat, "detail", 0)) { file = fopen(FullName, "wb"); if (file) { switch (sms.SMS[i].Coding) { 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, *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) == '.') || // directory and UNIX hidden file !mystrncasecmp(namelist[m]->d_name,"out", 3) || // must start with 'out' ((strlen(namelist[m]->d_name) >= 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*"); if((hFile = _findfirst( FullName, &c_file )) == -1L ) { return ERR_EMPTY; } else { strcpy(FileName,c_file.name); } _findclose( hFile ); error = ERR_NONE; #endif #endif diff --git a/gammu/emb/gammu/smsd/smsdcore.c b/gammu/emb/gammu/smsd/smsdcore.c index cc9accc..e69a6e7 100644 --- a/gammu/emb/gammu/smsd/smsdcore.c +++ b/gammu/emb/gammu/smsd/smsdcore.c @@ -17,309 +17,314 @@ 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, 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("Warning: No PIN code in %s file",filename); + fprintf(stderr,"Warning: No PIN code in %s file\n",filename); + } else { + if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode); } - if (log) WriteSMSDLog("PIN code is \"%s\"",Config->PINCode); 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; 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); + if (Config->PINCode==NULL) { + WriteSMSDLog("Warning: no PIN in config"); return false; - } + } else { + 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; int i; start=true; while (error == ERR_NONE && !gshutdown) { sms.SMS[0].Folder=0x00; error=Phone->GetNextSMS(&s, &sms, start); switch (error) { case ERR_EMPTY: break; case ERR_NONE: /* Not Inbox SMS - exit */ if (!sms.SMS[0].InboxFolder) break; process=true; DecodeUnicode(sms.SMS[0].Number,buffer); if (Config->IncludeNumbers != NULL) { e=Config->IncludeNumbers; process=false; while (1) { if (e == NULL) break; if (strcmp(buffer,e->EntryValue)==0) { process=true; break; } e = e->Prev; } } else if (Config->ExcludeNumbers != NULL) { e=Config->ExcludeNumbers; process=true; while (1) { if (e == NULL) break; if (strcmp(buffer,e->EntryValue)==0) { process=false; break; } e = e->Prev; } } if (process) { Service->SaveInboxSMS(sms, Config); } else { WriteSMSDLog("Excluded %s", buffer); } break; default: WriteSMSDLog("Error getting SMS (%i)", error); return false; } if (error == ERR_NONE && sms.SMS[0].InboxFolder) { for (i=0;i<sms.Number;i++) { sms.SMS[i].Folder=0; error=Phone->DeleteSMS(&s,&sms.SMS[i]); switch (error) { case ERR_NONE: case ERR_EMPTY: break; default: WriteSMSDLog("Error deleting SMS (%i)", error); return false; } } } start=false; } return true; } bool SMSD_CheckSMSStatus(GSM_SMSDConfig *Config,GSM_SMSDService *Service) { GSM_SMSMemoryStatus SMSStatus; GSM_Error error; /* 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; } |