summaryrefslogtreecommitdiff
path: root/libgammu
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2011-01-07 15:26:40 +0100
committerMichal Čihař <michal@cihar.com>2011-01-07 15:26:40 +0100
commit35925197481d458417cadb3ec06a05278a4799e4 (patch)
tree94226d629f4a8f18b4f06bfb6000a9c880b6ff99 /libgammu
parent2114cf03831e54c9777c31eb3ad19257b9fa128c (diff)
Imported Upstream version 1.28.95
Diffstat (limited to 'libgammu')
-rw-r--r--libgammu/gsmphones.c4
-rw-r--r--libgammu/misc/coding/coding.c19
-rw-r--r--libgammu/misc/misc.c10
-rw-r--r--libgammu/phone/at/at-sms.c4
-rw-r--r--libgammu/phone/at/atgen.c36
-rw-r--r--libgammu/phone/at/atgen.h3
-rw-r--r--libgammu/phone/at/samsung.c21
-rw-r--r--libgammu/phone/dummy/dummy.c10
-rw-r--r--libgammu/phone/nokia/dct4s40/6510/6510file.c4
-rw-r--r--libgammu/phone/nokia/nauto.c21
-rw-r--r--libgammu/phone/obex/mobex.c52
-rw-r--r--libgammu/phone/obex/obexgen.c105
-rw-r--r--libgammu/phone/obex/obexgen.h14
-rw-r--r--libgammu/service/backup/backics.c4
-rw-r--r--libgammu/service/backup/backics.h4
-rw-r--r--libgammu/service/backup/backlmb.c4
-rw-r--r--libgammu/service/backup/backlmb.h4
-rw-r--r--libgammu/service/backup/backtext.c28
-rw-r--r--libgammu/service/backup/backtext.h4
-rw-r--r--libgammu/service/backup/backvcf.c4
-rw-r--r--libgammu/service/backup/backvcf.h4
-rw-r--r--libgammu/service/backup/backvcs.c6
-rw-r--r--libgammu/service/backup/backvcs.h6
-rw-r--r--libgammu/service/backup/backvnt.c2
-rw-r--r--libgammu/service/backup/backvnt.h4
-rw-r--r--libgammu/service/backup/gsmback.c2
-rw-r--r--libgammu/service/gsmcal.c2
-rw-r--r--libgammu/service/sms/gsmsms.c6
28 files changed, 284 insertions, 103 deletions
diff --git a/libgammu/gsmphones.c b/libgammu/gsmphones.c
index 609acbc..3d0f35e 100644
--- a/libgammu/gsmphones.c
+++ b/libgammu/gsmphones.c
@@ -120,6 +120,7 @@ GSM_FeatureName AllFeatureNames[] = {
{"TSSPCSW", F_TSSPCSW},
{"DISABLE_GETNEXT", F_DISABLE_GETNEXT},
{"DISABLE_GETNEXTSMS", F_DISABLE_GETNEXTSMS},
+ {"DISABLE_CMGL", F_DISABLE_CMGL},
{"", 0},
};
@@ -382,6 +383,7 @@ GSM_PhoneModel allmodels[] = {
{"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}},
{"C3" ,"RM-614","Nokia C3", {F_SERIES40_30,F_FILES2,F_TODO66,F_RADIO,F_NOTES,F_SMS_FILES,0}},/* fixme */
+ {"X3" ,"RM-540","Nokia X3", {F_SERIES40_30,F_FILES2,F_TODO66,F_RADIO,F_NOTES,F_SMS_FILES,0}},/* fixme */
#endif
#ifdef GSM_ENABLE_NOKIA3320
{"3320" ,"NPC-1" ,"Nokia 3320", {F_CAL62,F_DAYMONTH,0}},/* fixme */
@@ -443,7 +445,7 @@ GSM_PhoneModel allmodels[] = {
{"D357", "SGH-D357" , "", {F_EXTRA_PBK_FIELD, 0}},
{"J750", "SGH-J750" , "", {F_NO_ATOBEX, 0}},
{"J700", "SGH-J700" , "", {F_NO_ATOBEX, 0}},
- {"J700", "SAMSUNG SGH-J700" , "", {F_NO_ATOBEX, 0}},
+ {"J700", "SAMSUNG SGH-J700" , "", {F_NO_ATOBEX, F_DISABLE_CMGL, 0}},
{"D980", "SAMSUNG SGH-D980" , "", {F_NO_ATOBEX, 0}},
/* Philips */
diff --git a/libgammu/misc/coding/coding.c b/libgammu/misc/coding/coding.c
index 7332d18..4c99240 100644
--- a/libgammu/misc/coding/coding.c
+++ b/libgammu/misc/coding/coding.c
@@ -814,7 +814,7 @@ out:
int GSM_PackSemiOctetNumber(const unsigned char *Number, unsigned char *Output, gboolean semioctet)
{
unsigned char format;
- int length, i;
+ int length, i, skip = 0;
unsigned char *buffer;
length = UnicodeLength(Number);
@@ -824,12 +824,19 @@ int GSM_PackSemiOctetNumber(const unsigned char *Number, unsigned char *Output,
return 0;
}
- memset(buffer, 0, length + 2);
- memcpy(buffer, DecodeUnicodeString(Number), length + 1);
+ DecodeUnicode(Number, buffer);
/* Checking for format number */
- if (buffer[0] == '+' || (buffer[0] == '0' && buffer[1] == '0')) {
+ if (buffer[0] == '+') {
format = NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN;
+ skip = 1;
+ } else if (buffer[0] == '0' && buffer[1] == '0') {
+ format = NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN;
+ skip = 2;
+ } else if (buffer[0] == '+' && buffer[1] == '0' && buffer[2] == '0') {
+ /* This is obviously wrong, but try to cope with that */
+ format = NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN;
+ skip = 3;
} else {
format = NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN;
}
@@ -854,8 +861,8 @@ int GSM_PackSemiOctetNumber(const unsigned char *Number, unsigned char *Output,
if (strlen(buffer)==7) length--;
break;
case NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN:
- length--;
- EncodeBCD (Output+1, buffer+1, length, TRUE);
+ length -= skip;
+ EncodeBCD (Output+1, buffer + skip, length, TRUE);
break;
default:
EncodeBCD (Output+1, buffer, length, TRUE);
diff --git a/libgammu/misc/misc.c b/libgammu/misc/misc.c
index 65a0110..8576a31 100644
--- a/libgammu/misc/misc.c
+++ b/libgammu/misc/misc.c
@@ -183,7 +183,15 @@ time_t Fill_Time_T(GSM_DateTime DT)
tm_starttime.tm_hour = DT.Hour;
tm_starttime.tm_min = DT.Minute;
tm_starttime.tm_sec = DT.Second;
- tm_starttime.tm_isdst = -1;
+
+ tzset();
+
+ tm_starttime.tm_isdst = daylight;
+#ifdef HAVE_STRUCT_TM_TM_ZONE
+ /* No time zone information */
+ tm_starttime.tm_gmtoff = timezone;
+ tm_starttime.tm_zone = *tzname;
+#endif
return mktime(&tm_starttime);
}
diff --git a/libgammu/phone/at/at-sms.c b/libgammu/phone/at/at-sms.c
index 3be2be5..c01527e 100644
--- a/libgammu/phone/at/at-sms.c
+++ b/libgammu/phone/at/at-sms.c
@@ -1032,6 +1032,10 @@ GSM_Error ATGEN_GetSMSList(GSM_StateMachine *s, gboolean first)
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
int used = 0;
+ if (GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_DISABLE_CMGL)) {
+ return ERR_NOTSUPPORTED;
+ }
+
/* Set mode of SMS */
error = ATGEN_GetSMSMode(s);
diff --git a/libgammu/phone/at/atgen.c b/libgammu/phone/at/atgen.c
index f0e6916..3b0df27 100644
--- a/libgammu/phone/at/atgen.c
+++ b/libgammu/phone/at/atgen.c
@@ -1039,6 +1039,18 @@ GSM_Error ATGEN_ParseReply(GSM_StateMachine *s, const unsigned char *input, cons
smprintf(s, "Parsed int %d\n", *out_i);
inp = endptr;
break;
+ case 'n':
+ out_i = va_arg(ap, int *);
+ length = ATGEN_GrabString(s, inp, &buffer);
+ *out_i = strtol(buffer, &endptr, 10);
+ free(buffer);
+ if (endptr == (char *)buffer) {
+ error = ERR_UNKNOWNRESPONSE;
+ goto end;
+ }
+ smprintf(s, "Parsed int %d\n", *out_i);
+ inp += length;
+ break;
case 'I':
out_i = va_arg(ap, int *);
*out_i = strtol(inp, &endptr, 10);
@@ -1134,6 +1146,17 @@ GSM_Error ATGEN_ParseReply(GSM_StateMachine *s, const unsigned char *input, cons
}
inp += length;
break;
+ case 'u':
+ out_s = va_arg(ap, char *);
+ storage_size = va_arg(ap, size_t);
+ length = ATGEN_GrabString(s, inp, &buffer);
+ smprintf(s, "Parsed utf-8 string \"%s\"\n", buffer);
+ DecodeUTF8(out_s, buffer, strlen(buffer));
+ smprintf(s, "utf-8 string with length decoded as \"%s\"\n", DecodeUnicodeString(out_s));
+ free(buffer);
+ buffer = NULL;
+ inp += length;
+ break;
case 'T':
out_s = va_arg(ap, char *);
storage_size = va_arg(ap, size_t);
@@ -1761,6 +1784,10 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine
strcpy(s->Phone.Data.Manufacturer,"Samsung");
Priv->Manufacturer = AT_Samsung;
}
+ if (strstr(msg.Buffer,"philips")) {
+ strcpy(s->Phone.Data.Manufacturer,"Philips");
+ Priv->Manufacturer = AT_Philips;
+ }
if (strstr(msg.Buffer,"Mitsubishi")) {
strcpy(s->Phone.Data.Manufacturer,"Mitsubishi");
Priv->Manufacturer = AT_Mitsubishi;
@@ -4185,6 +4212,7 @@ GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg UNUSED, GSM_Stat
GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
{
GSM_Error error;
+ GSM_SecurityCodeType Status;
unsigned char req[GSM_SECURITY_CODE_LEN + 12] = {'\0'};
size_t len;
@@ -4192,6 +4220,14 @@ GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code)
s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Siemens) {
len = sprintf(req, "AT+CPIN2=\"%s\"\r", Code.Code);
} else {
+ error = ATGEN_GetSecurityStatus(s, &Status);
+ if (error != ERR_NONE) {
+ return error;
+ }
+ if (Status != Code.Type) {
+ smprintf(s, "Phone is expecting different security code!\n");
+ return ERR_SECURITYERROR;
+ }
len = sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code);
}
smprintf(s, "Entering security code\n");
diff --git a/libgammu/phone/at/atgen.h b/libgammu/phone/at/atgen.h
index ea64aeb..857eb7b 100644
--- a/libgammu/phone/at/atgen.h
+++ b/libgammu/phone/at/atgen.h
@@ -76,6 +76,7 @@ typedef enum {
AT_Option,
AT_Motorola,
AT_Wavecom,
+ AT_Philips,
AT_Unknown
} GSM_AT_Manufacturer;
@@ -436,11 +437,13 @@ GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s);
*
* \par Parser tokens:
* - \b \@i - Number, expects pointer to int.
+ * - \b \@n - Quoted number, expects pointer to int.
* - \b \@I - Optional number (string can be empty), expects pointer to int.
* - \b \@l - Number, expects pointer to long int.
* - \b \@s - String, will be converted from phone encoding, stripping
* quotes, expects pointer to unsigned char and size of storage.
* Encoding is somehow guessed.
+ * - \b \@u - String in utf-8, expects pointer to unsigned char and size of storage.
* - \b \@t - String with length as first element (eg. "5,test1"), will be
* converted from phone encoding, stripping quotes, expects pointer to
* unsigned char and size of storage.
diff --git a/libgammu/phone/at/samsung.c b/libgammu/phone/at/samsung.c
index 986511b..bfd5ff8 100644
--- a/libgammu/phone/at/samsung.c
+++ b/libgammu/phone/at/samsung.c
@@ -555,6 +555,27 @@ GSM_Error SAMSUNG_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
/* Empty entry */
if (strcmp(str, "OK") == 0) return ERR_EMPTY;
+ /* Philips has it's SPBR as well, but different reply */
+ if ( Priv->Manufacturer == AT_Philips) {
+ error = ATGEN_ParseReply(s,
+ GetLineString(msg.Buffer, &Priv->Lines, 2),
+ "+SPBR: @n, @u, @p",
+ &Memory->Location,
+ Memory->Entries[0].Text, sizeof(Memory->Entries[0].Text),
+ Memory->Entries[1].Text, sizeof(Memory->Entries[1].Text));
+ if (error == ERR_NONE) {
+ /* Set name type */
+ Memory->Entries[0].EntryType = PBK_Text_Name;
+
+ /* Set number type */
+ Memory->Entries[1].EntryType = PBK_Number_General;
+ Memory->Entries[1].VoiceTag = 0;
+ Memory->Entries[1].SMSList[0] = 0;
+
+ return ERR_NONE;
+ }
+ }
+
/*
* Parse reply string
*
diff --git a/libgammu/phone/dummy/dummy.c b/libgammu/phone/dummy/dummy.c
index 7d145ed..01c9c56 100644
--- a/libgammu/phone/dummy/dummy.c
+++ b/libgammu/phone/dummy/dummy.c
@@ -59,14 +59,14 @@
GSM_Error DUMMY_Error(GSM_StateMachine *s, const char *message)
{
- int i;
- i = errno;
+ int tmp_errno;
+ tmp_errno = errno;
GSM_OSErrorInfo(s, message);
- if (i == ENOENT) {
+ if (tmp_errno == ENOENT) {
return ERR_EMPTY;
- } else if (i == EACCES) {
+ } else if (tmp_errno == EACCES) {
return ERR_PERMISSION;
- } else if (i == EEXIST) {
+ } else if (tmp_errno == EEXIST) {
return ERR_FILEALREADYEXIST;
} else {
return ERR_UNKNOWN;
diff --git a/libgammu/phone/nokia/dct4s40/6510/6510file.c b/libgammu/phone/nokia/dct4s40/6510/6510file.c
index 2e6e780..7591384 100644
--- a/libgammu/phone/nokia/dct4s40/6510/6510file.c
+++ b/libgammu/phone/nokia/dct4s40/6510/6510file.c
@@ -2377,6 +2377,10 @@ GSM_Error N6510_DecodeFilesystemSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sm
while (pos < FFF->Used) {
unknown = FALSE;
if (pos + 1 >= FFF->Used) {
+ if (pos + 1 == FFF->Used && FFF->Buffer[pos] == 0x00) {
+ smprintf(s, "File padded with 0x00, assuming it is okay\n");
+ break;
+ }
smprintf(s, "ERROR: Reach end of file before type of block!\n");
return ERR_BUG;
}
diff --git a/libgammu/phone/nokia/nauto.c b/libgammu/phone/nokia/nauto.c
index 30b7c1a..4095c67 100644
--- a/libgammu/phone/nokia/nauto.c
+++ b/libgammu/phone/nokia/nauto.c
@@ -16,10 +16,29 @@ static GSM_Reply_Function NAUTOReplyFunctions[] = {
{NULL, "\x00",0x00,0x00,ID_None }
};
+/**
+ * Some phones/cables need some time to initialize, this function gives
+ * them the time while not slowing down the usual case (GetModel is
+ * anyway later called).
+ */
+static GSM_Error NAUTO_Initialise(GSM_StateMachine *s)
+{
+ GSM_Error error = ERR_TIMEOUT;
+ int repeats = 3;
+
+ while (repeats > 0 && error == ERR_TIMEOUT) {
+ error = DCT3DCT4_GetModel(s);
+ if (error == ERR_NONE) return ERR_NONE;
+ repeats--;
+ }
+
+ return error;
+}
+
GSM_Phone_Functions NAUTOPhone = {
"NAUTO",
NAUTOReplyFunctions,
- NONEFUNCTION, /* Initialise */
+ NAUTO_Initialise, /* Initialise */
NONEFUNCTION, /* Terminate */
GSM_DispatchMessage,
NOTSUPPORTED, /* ShowStartInfo */
diff --git a/libgammu/phone/obex/mobex.c b/libgammu/phone/obex/mobex.c
index a5803f6..96b1ff7 100644
--- a/libgammu/phone/obex/mobex.c
+++ b/libgammu/phone/obex/mobex.c
@@ -41,7 +41,7 @@ GSM_Error MOBEX_GetStatus(GSM_StateMachine *s, const char *path, int *free_recor
{
GSM_Error error;
unsigned char *buffer = NULL;
- int len = 0, total;
+ size_t len = 0, total;
GSM_Phone_OBEXGENData *Priv = &s->Phone.Data.Priv.OBEXGEN;
char appdata[] = {'\x01'};
@@ -59,14 +59,14 @@ GSM_Error MOBEX_GetStatus(GSM_StateMachine *s, const char *path, int *free_recor
}
if (len < 2) {
- smprintf(s, "Unknown length of data file: %d\n", len);
+ smprintf(s, "Unknown length of data file: %ld\n", (long int)len);
free(buffer);
return ERR_UNKNOWNRESPONSE;
}
total = (buffer[0] << 8) + buffer[1];
- *used = (buffer[1] << 8) + buffer[3];
+ *used = (buffer[2] << 8) + buffer[3];
*free_records = total - *used;
free(buffer);
@@ -103,8 +103,8 @@ GSM_Error MOBEX_UpdateEntry(GSM_StateMachine *s, const char *path, const int loc
GSM_Phone_OBEXGENData *Priv = &s->Phone.Data.Priv.OBEXGEN;
char appdata[] = {'\x01', 0, 0};
- appdata[1] = (location && 0xff00) >> 8;
- appdata[2] = (location && 0xff);
+ appdata[1] = (location & 0xff00) >> 8;
+ appdata[2] = (location & 0xff);
Priv->m_obex_appdata = appdata;
Priv->m_obex_appdata_len = sizeof(appdata);
@@ -127,8 +127,8 @@ GSM_Error MOBEX_GetEntry(GSM_StateMachine *s, const char *path, const int locati
GSM_Phone_OBEXGENData *Priv = &s->Phone.Data.Priv.OBEXGEN;
char appdata[] = {'\x01', 0, 0};
- appdata[1] = (location && 0xff00) >> 8;
- appdata[2] = (location && 0xff);
+ appdata[1] = (location & 0xff00) >> 8;
+ appdata[2] = (location & 0xff);
Priv->m_obex_appdata = appdata;
Priv->m_obex_appdata_len = sizeof(appdata);
@@ -192,11 +192,11 @@ GSM_Error MOBEX_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Entry)
return ERR_NONE;
}
-GSM_Error MOBEX_GetNextEntry(GSM_StateMachine *s, const char *path, const gboolean start, int *nextid, int *nexterror, unsigned char **data, int *pos, int *size, char **entry, int *location)
+GSM_Error MOBEX_GetNextEntry(GSM_StateMachine *s, const char *path, const gboolean start, int *nextid, int *nexterror, unsigned char **data, size_t *pos, size_t *size, char **entry, int *location)
{
GSM_Error error;
GSM_Phone_OBEXGENData *Priv = &s->Phone.Data.Priv.OBEXGEN;
- char appdata[] = {'\x01', 0, 0, '\x0a'};
+ char appdata[] = {'\x01', 0, 0};
if (start) {
*nextid = 0;
@@ -205,22 +205,28 @@ GSM_Error MOBEX_GetNextEntry(GSM_StateMachine *s, const char *path, const gboole
*data = NULL;
*pos = 0;
*size = 0;
- } else {
- *nextid += 1;
}
/* Increment to next */
if (*data != NULL) {
- *pos += (*data[*pos + 2] << 8) + *data[*pos + 3];
+ *pos += ((*data)[*pos + 2] << 8) + (*data)[*pos + 3];
+ /* To take in account the space used by the ID and the size
+ * of the record */
+ *pos += 4;
}
/* Need to fetch new data */
if (*pos >= *size) {
+ /* Increment mobex fetch ID only if we really fetch informations */
+ if (! start) {
+ (*nextid)++;
+ }
if (*nexterror == 0) {
return ERR_EMPTY;
}
- appdata[1] = (*nextid && 0xff00) >> 8;
- appdata[2] = (*nextid && 0xff);
+ appdata[1] = (*nextid & 0xff00) >> 8;
+ appdata[2] = (*nextid & 0xff);
+ *pos = 0;
Priv->m_obex_appdata = appdata;
Priv->m_obex_appdata_len = sizeof(appdata);
@@ -244,7 +250,7 @@ GSM_Error MOBEX_GetNextEntry(GSM_StateMachine *s, const char *path, const gboole
/* Return values */
*entry = *data + *pos + 4;
- *location = (*data[*pos + 0] << 8) + *data[*pos + 1];
+ *location = ((*data)[*pos + 0] << 8) + (*data)[*pos + 1];
return ERR_NONE;
}
@@ -257,12 +263,26 @@ GSM_Error MOBEX_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *Entry, gbool
size_t pos = 0;
- error = MOBEX_GetNextEntry(s, "m-obex/contacts/load", start, &Priv->m_obex_contacts_nextid, &Priv->m_obex_contacts_nexterror, &Priv->m_obex_contacts_buffer, &Priv->m_obex_contacts_buffer_pos, &Priv->m_obex_contacts_buffer_size, &data, &(Entry->Location));
+ error = MOBEX_GetNextEntry(s, "m-obex/contacts/load",
+ start, &Priv->m_obex_contacts_nextid, &Priv->m_obex_contacts_nexterror,
+ &Priv->m_obex_contacts_buffer, &Priv->m_obex_contacts_buffer_pos,
+ &Priv->m_obex_contacts_buffer_size, &data, &(Entry->Location));
+
+ smprintf(s, "Error: %d\n", error);
if (error != ERR_NONE) {
return error;
}
error = GSM_DecodeVCARD(&(s->di), data, &pos, Entry, SonyEricsson_VCard21_Phone);
+ /* If we have room in the buffer and next chars are \r and \n then
+ * skip them they have been left by the VCARD parsing
+ */
+
+ if ((pos < (Priv->m_obex_contacts_buffer_size + 2)) &&
+ data[pos] == 0x0D && data[pos + 1] == 0x0A) {
+ pos += 2;
+ }
+
if (error != ERR_NONE) {
return error;
}
diff --git a/libgammu/phone/obex/obexgen.c b/libgammu/phone/obex/obexgen.c
index a5f4b18..c80f414 100644
--- a/libgammu/phone/obex/obexgen.c
+++ b/libgammu/phone/obex/obexgen.c
@@ -94,6 +94,20 @@ static GSM_Error OBEXGEN_HandleError(GSM_Protocol_Message msg, GSM_StateMachine
}
/**
+ * Adds connection ID block to the request.
+ */
+void OBEXGEN_AddConnectionID(GSM_StateMachine *s, char *Buffer, int *Pos)
+{
+ GSM_Phone_OBEXGENData *Priv = &s->Phone.Data.Priv.OBEXGEN;
+
+ Buffer[(*Pos)++] = 0xCB;
+ Buffer[(*Pos)++] = Priv->connection_id[0];
+ Buffer[(*Pos)++] = Priv->connection_id[1];
+ Buffer[(*Pos)++] = Priv->connection_id[2];
+ Buffer[(*Pos)++] = Priv->connection_id[3];
+}
+
+/**
* \defgroup OBEXinit OBEX initialisation and terminating
* \ingroup OBEXPhone
* @{
@@ -101,13 +115,39 @@ static GSM_Error OBEXGEN_HandleError(GSM_Protocol_Message msg, GSM_StateMachine
static GSM_Error OBEXGEN_ReplyConnect(GSM_Protocol_Message msg, GSM_StateMachine *s)
{
+ size_t i;
+ GSM_Phone_OBEXGENData *Priv = &s->Phone.Data.Priv.OBEXGEN;
+
switch (msg.Type) {
case 0xA0:
smprintf(s,"Connected/disconnected OK\n");
- if (msg.Length != 0) {
- s->Phone.Data.Priv.OBEXGEN.FrameSize = msg.Buffer[2]*256+msg.Buffer[3];
+ /* Sample: 10 |00 |20 |00 |CB |00 |00 |00 |10 |4AJ|00 |08 |4DM|4FO|42B|45E|58X */
+ /* Byte 0 - OBEX version */
+ /* Byte 1 - flags */
+ /* Bytes 2,3 - maximal size of packet */
+ if (msg.Length >= 4) {
+ s->Phone.Data.Priv.OBEXGEN.FrameSize = msg.Buffer[2]*256 + msg.Buffer[3];
smprintf(s,"Maximal size of frame is %i 0x%x\n",s->Phone.Data.Priv.OBEXGEN.FrameSize,s->Phone.Data.Priv.OBEXGEN.FrameSize);
}
+ /* Remaining bytes - optional headers */
+ for (i = 4; i < msg.Length;) {
+ switch (msg.Buffer[i]) {
+ case 0xCB:
+ /* Connection ID */
+ memcpy(Priv->connection_id, msg.Buffer + i + 1, 4);
+ i += 5;
+ break;
+ case 0x4A:
+ /* Peer */
+ /* We just skip it */
+ i += (msg.Buffer[i + 1] << 8) + msg.Buffer[i + 2];
+ break;
+ default:
+ smprintf(s, "Unknown OBEX header: 0x%02X, skipping rest\n", msg.Buffer[i]);
+ i = msg.Length;
+ break;
+ }
+ }
return ERR_NONE;
case 0xC0:
smprintf(s, "Wrong request sent to phone!\n");
@@ -277,6 +317,12 @@ GSM_Error OBEXGEN_InitialiseVars(GSM_StateMachine *s)
Priv->m_obex_contacts_buffer_pos = 0;
Priv->m_obex_contacts_buffer_size = 0;
+ /* Default connection ID */
+ Priv->connection_id[0] = 0;
+ Priv->connection_id[1] = 0;
+ Priv->connection_id[2] = 0;
+ Priv->connection_id[3] = 1;
+
IRMC_InitCapabilities(&(Priv->NoteCap));
IRMC_InitCapabilities(&(Priv->PbCap));
IRMC_InitCapabilities(&(Priv->CalCap));
@@ -522,10 +568,7 @@ static GSM_Error OBEXGEN_ChangePath(GSM_StateMachine *s, char *Name, unsigned ch
OBEXAddBlock(req, &Current, 0x01, NULL, 0);
}
- /* connection ID block */
- req[Current++] = 0xCB; /* ID */
- req[Current++] = 0x00; req[Current++] = 0x00;
- req[Current++] = 0x00; req[Current++] = 0x01;
+ OBEXGEN_AddConnectionID(s, req, &Current);
return GSM_WaitFor (s, req, Current, 0x85, OBEX_TIMEOUT, ID_SetPath);
}
@@ -713,6 +756,11 @@ GSM_Error OBEXGEN_PrivAddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos,
s->Phone.Data.File = File;
+ if (Priv->Service == OBEX_BrowsingFolders || Priv->Service == OBEX_m_OBEX) {
+ OBEXGEN_AddConnectionID(s, req, &Current);
+ }
+
+ /* Are we sending first request or continuation? */
if (*Pos == 0) {
if (!strcmp(DecodeUnicodeString(File->ID_FullName),"")) {
error = OBEXGEN_Connect(s,OBEX_None);
@@ -725,7 +773,16 @@ GSM_Error OBEXGEN_PrivAddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos,
}
/* Name block */
- OBEXAddBlock(req, &Current, 0x01, File->Name, UnicodeLength(File->Name)*2+2);
+ if (Priv->Service == OBEX_m_OBEX) {
+ OBEXAddBlock(req, &Current, 0x42, DecodeUnicodeString(File->ID_FullName), UnicodeLength(File->ID_FullName) + 1);
+ } else {
+ OBEXAddBlock(req, &Current, 0x01, File->Name, UnicodeLength(File->Name)*2+2);
+ }
+
+ /* Include m-obex application data */
+ if (Priv->Service == OBEX_m_OBEX && Priv->m_obex_appdata != NULL && Priv->m_obex_appdata_len != 0) {
+ OBEXAddBlock(req, &Current, 0x4C, Priv->m_obex_appdata, Priv->m_obex_appdata_len);
+ }
/* File size block */
req[Current++] = 0xC3; /* ID */
@@ -740,18 +797,6 @@ GSM_Error OBEXGEN_PrivAddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos,
}
}
- if (Priv->Service == OBEX_BrowsingFolders || Priv->Service == OBEX_m_OBEX) {
- /* connection ID block */
- req[Current++] = 0xCB; /* ID */
- req[Current++] = 0x00; req[Current++] = 0x00;
- req[Current++] = 0x00; req[Current++] = 0x01;
- }
-
- /* Include m-obex application data */
- if (Priv->Service == OBEX_m_OBEX && Priv->m_obex_appdata != NULL && Priv->m_obex_appdata_len != 0) {
- OBEXAddBlock(req, &Current, 0x4C, Priv->m_obex_appdata, Priv->m_obex_appdata_len);
- }
-
j = Priv->FrameSize - Current - 20;
if (j > 1000) j = 1000;
@@ -911,10 +956,7 @@ static GSM_Error OBEXGEN_PrivGetFilePart(GSM_StateMachine *s, GSM_File *File, gb
File->ModifiedEmpty = TRUE;
if (Priv->Service == OBEX_BrowsingFolders || Priv->Service == OBEX_m_OBEX) {
- /* connection ID block */
- req[Current++] = 0xCB; /* ID */
- req[Current++] = 0x00; req[Current++] = 0x00;
- req[Current++] = 0x00; req[Current++] = 0x01;
+ OBEXGEN_AddConnectionID(s, req, &Current);
}
if (File->Used == 0x00) {
@@ -991,10 +1033,7 @@ static GSM_Error OBEXGEN_PrivGetFilePart(GSM_StateMachine *s, GSM_File *File, gb
while (!Priv->FileLastPart) {
Current = 0;
if (Priv->Service == OBEX_BrowsingFolders || Priv->Service == OBEX_m_OBEX) {
- /* connection ID block */
- req[Current++] = 0xCB; /* ID */
- req[Current++] = 0x00; req[Current++] = 0x00;
- req[Current++] = 0x00; req[Current++] = 0x01;
+ OBEXGEN_AddConnectionID(s, req, &Current);
}
/* Include m-obex application data */
if (Priv->Service == OBEX_m_OBEX && Priv->m_obex_appdata != NULL && Priv->m_obex_appdata_len != 0) {
@@ -1234,9 +1273,7 @@ GSM_Error OBEXGEN_DeleteFile(GSM_StateMachine *s, unsigned char *ID)
OBEXAddBlock(req, &Current, 0x01, req2, UnicodeLength(req2)*2+2);
/* connection ID block */
- req[Current++] = 0xCB; /* ID */
- req[Current++] = 0x00; req[Current++] = 0x00;
- req[Current++] = 0x00; req[Current++] = 0x01;
+ OBEXGEN_AddConnectionID(s, req, &Current);
return GSM_WaitFor (s, req, Current, 0x82, OBEX_TIMEOUT, ID_AddFile);
}
@@ -1278,7 +1315,7 @@ GSM_Error OBEXGEN_AddFolder(GSM_StateMachine *s, GSM_File *File)
/**
* Grabs complete single file
*/
-GSM_Error OBEXGEN_GetFile(GSM_StateMachine *s, const char *FileName, unsigned char ** Buffer, int *len)
+GSM_Error OBEXGEN_GetFile(GSM_StateMachine *s, const char *FileName, unsigned char ** Buffer, size_t *len)
{
GSM_Error error = ERR_NONE;
GSM_File File;
@@ -1312,7 +1349,7 @@ GSM_Error OBEXGEN_GetFile(GSM_StateMachine *s, const char *FileName, unsigned ch
/**
* Grabs complete single binary file
*/
-GSM_Error OBEXGEN_GetBinaryFile(GSM_StateMachine *s, const char *FileName, unsigned char ** Buffer, int *len)
+GSM_Error OBEXGEN_GetBinaryFile(GSM_StateMachine *s, const char *FileName, unsigned char ** Buffer, size_t *len)
{
GSM_Error error = ERR_NONE;
@@ -1321,7 +1358,7 @@ GSM_Error OBEXGEN_GetBinaryFile(GSM_StateMachine *s, const char *FileName, unsig
if (error != ERR_NONE) return error;
/* Return data we got */
- smprintf(s, "Got %d data\n", *len);
+ smprintf(s, "Got %ld bytes of data\n", (long int)*len);
*Buffer = (unsigned char *)realloc(*Buffer, *len + 1);
if (*Buffer == NULL) {
return ERR_MOREMEMORY;
@@ -1335,7 +1372,7 @@ GSM_Error OBEXGEN_GetBinaryFile(GSM_StateMachine *s, const char *FileName, unsig
*/
GSM_Error OBEXGEN_GetTextFile(GSM_StateMachine *s, const char *FileName, char ** Buffer)
{
- int len;
+ size_t len;
return OBEXGEN_GetBinaryFile(s, FileName, (unsigned char **)Buffer, &len);
}
diff --git a/libgammu/phone/obex/obexgen.h b/libgammu/phone/obex/obexgen.h
index 3187187..be8fe72 100644
--- a/libgammu/phone/obex/obexgen.h
+++ b/libgammu/phone/obex/obexgen.h
@@ -268,11 +268,11 @@ typedef struct {
/**
* m-obex contacts buffer position.
*/
- int m_obex_contacts_buffer_pos;
+ size_t m_obex_contacts_buffer_pos;
/**
* m-obex contacts buffer size.
*/
- int m_obex_contacts_buffer_size;
+ size_t m_obex_contacts_buffer_size;
/**
* m-obex calendar buffer.
*/
@@ -280,14 +280,18 @@ typedef struct {
/**
* m-obex calendar buffer position.
*/
- int m_obex_calendar_buffer_pos;
+ size_t m_obex_calendar_buffer_pos;
/**
* m-obex calendar buffer size.
*/
- int m_obex_calendar_buffer_size;
+ size_t m_obex_calendar_buffer_size;
+ /**
+ * OBEX connection ID.
+ */
+ unsigned char connection_id[4];
} GSM_Phone_OBEXGENData;
-GSM_Error OBEXGEN_GetBinaryFile(GSM_StateMachine *s, const char *FileName, unsigned char ** Buffer, int *len);
+GSM_Error OBEXGEN_GetBinaryFile(GSM_StateMachine *s, const char *FileName, unsigned char ** Buffer, size_t *len);
GSM_Error OBEXGEN_GetTextFile(GSM_StateMachine *s, const char *FileName, char ** Buffer);
GSM_Error OBEXGEN_SetFile(GSM_StateMachine *s, const char *FileName, const unsigned char *Buffer, size_t Length, gboolean HardDelete);
diff --git a/libgammu/service/backup/backics.c b/libgammu/service/backup/backics.c
index 7407938..0529ba9 100644
--- a/libgammu/service/backup/backics.c
+++ b/libgammu/service/backup/backics.c
@@ -20,7 +20,7 @@
#define chk_fwrite(data, size, count, file) \
if (fwrite(data, size, count, file) != count) goto fail;
-GSM_Error SaveICS(char *FileName, GSM_Backup *backup)
+GSM_Error SaveICS(const char *FileName, GSM_Backup *backup)
{
int i;
size_t Length = 0;
@@ -72,7 +72,7 @@ fail:
return ERR_WRITING_FILE;
}
-GSM_Error LoadICS(char *FileName, GSM_Backup *backup)
+GSM_Error LoadICS(const char *FileName, GSM_Backup *backup)
{
return LoadVCalendarPrivate(FileName, backup, Mozilla_iCalendar, Mozilla_VToDo);
}
diff --git a/libgammu/service/backup/backics.h b/libgammu/service/backup/backics.h
index 58c2391..3157337 100644
--- a/libgammu/service/backup/backics.h
+++ b/libgammu/service/backup/backics.h
@@ -7,8 +7,8 @@
#include <gammu-backup.h>
#ifdef GSM_ENABLE_BACKUP
-GSM_Error SaveICS(char *FileName, GSM_Backup *backup);
-GSM_Error LoadICS(char *FileName, GSM_Backup *backup);
+GSM_Error SaveICS(const char *FileName, GSM_Backup *backup);
+GSM_Error LoadICS(const char *FileName, GSM_Backup *backup);
#endif
#endif
diff --git a/libgammu/service/backup/backlmb.c b/libgammu/service/backup/backlmb.c
index 7fcb807..ce8433b 100644
--- a/libgammu/service/backup/backlmb.c
+++ b/libgammu/service/backup/backlmb.c
@@ -144,7 +144,7 @@ fail:
return ERR_WRITING_FILE;
}
-GSM_Error SaveLMB(char *FileName, GSM_Backup *backup)
+GSM_Error SaveLMB(const char *FileName, GSM_Backup *backup)
{
FILE *file;
int i;
@@ -401,7 +401,7 @@ static GSM_Error LoadLMBPbkEntry(unsigned char *buffer, unsigned char *buffer2,
return ERR_NONE;
}
-GSM_Error LoadLMB(char *FileName, GSM_Backup *backup)
+GSM_Error LoadLMB(const char *FileName, GSM_Backup *backup)
{
#ifdef DEBUG
int i;
diff --git a/libgammu/service/backup/backlmb.h b/libgammu/service/backup/backlmb.h
index e31c901..8fa43fc 100644
--- a/libgammu/service/backup/backlmb.h
+++ b/libgammu/service/backup/backlmb.h
@@ -7,8 +7,8 @@
#include <gammu-backup.h>
#ifdef GSM_ENABLE_BACKUP
-GSM_Error SaveLMB(char *FileName, GSM_Backup *backup);
-GSM_Error LoadLMB(char *FileName, GSM_Backup *backup);
+GSM_Error SaveLMB(const char *FileName, GSM_Backup *backup);
+GSM_Error LoadLMB(const char *FileName, GSM_Backup *backup);
#endif
#endif
diff --git a/libgammu/service/backup/backtext.c b/libgammu/service/backup/backtext.c
index 1ae5bf9..3abf385 100644
--- a/libgammu/service/backup/backtext.c
+++ b/libgammu/service/backup/backtext.c
@@ -28,7 +28,7 @@
#define chk_fwrite(data, size, count, file) \
if (fwrite(data, size, count, file) != count) goto fail;
-GSM_Error FindBackupChecksum(char *FileName, gboolean UseUnicode, char *checksum)
+GSM_Error FindBackupChecksum(const char *FileName, gboolean UseUnicode, char *checksum)
{
INI_Section *file_info, *h;
INI_Entry *e;
@@ -1584,7 +1584,7 @@ static GSM_Error SaveGPRSPointEntry(FILE *file, GSM_GPRSAccessPoint *GPRSPoint,
return ERR_NONE;
}
-GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, gboolean UseUnicode)
+GSM_Error SaveBackup(const char *FileName, GSM_Backup *backup, gboolean UseUnicode)
{
int i=0;
unsigned char buffer[1000]={0},checksum[200]={0};
@@ -3073,9 +3073,10 @@ static void ReadProfileEntry(INI_Section *file_info, char *section, GSM_Profile
}
}
-static void ReadFMStationEntry(INI_Section *file_info, char *section, GSM_FMStation *FMStation, gboolean UseUnicode)
+static GSM_Error ReadFMStationEntry(INI_Section *file_info, char *section, GSM_FMStation *FMStation, gboolean UseUnicode)
{
unsigned char buffer[10000]={0}, *readvalue=NULL;
+ char *endptr;
FMStation->Location = 0;
FMStation->Frequency = 0;
@@ -3089,7 +3090,13 @@ static void ReadFMStationEntry(INI_Section *file_info, char *section, GSM_FMStat
sprintf(buffer,"Frequency");
readvalue = ReadCFGText(file_info, section, buffer, UseUnicode);
- if (readvalue!=NULL) StringToDouble(readvalue, &FMStation->Frequency);
+ if (readvalue != NULL) {
+ FMStation->Frequency = strtod(readvalue, &endptr);
+ if (*endptr != 0) {
+ return ERR_FILENOTSUPPORTED;
+ }
+ }
+ return ERR_NONE;
}
static void ReadGPRSPointEntry(INI_Section *file_info, char *section, GSM_GPRSAccessPoint *GPRSPoint, gboolean UseUnicode)
@@ -3128,7 +3135,7 @@ static void ReadNoteEntry(INI_Section *file_info, char *section, GSM_NoteEntry *
ReadBackupText(file_info, section, buffer, Note->Text,UseUnicode);
}
-GSM_Error LoadBackup(char *FileName, GSM_Backup *backup)
+GSM_Error LoadBackup(const char *FileName, GSM_Backup *backup)
{
INI_Section *file_info, *h;
char buffer[100]={0}, *readvalue=NULL;
@@ -3514,7 +3521,10 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup)
return ERR_MOREMEMORY;
}
backup->FMStation[num]->Location = num + 1;
- ReadFMStationEntry(file_info, h->SectionName, backup->FMStation[num],UseUnicode);
+ error = ReadFMStationEntry(file_info, h->SectionName, backup->FMStation[num],UseUnicode);
+ if (error != ERR_NONE) {
+ return error;
+ }
num++;
}
}
@@ -3798,7 +3808,7 @@ static GSM_Error ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_S
return ERR_NONE;
}
-static GSM_Error GSM_ReadSMSBackupTextFile(char *FileName, GSM_SMS_Backup *backup)
+static GSM_Error GSM_ReadSMSBackupTextFile(const char *FileName, GSM_SMS_Backup *backup)
{
INI_Section *file_info, *h;
char *readvalue=NULL;
@@ -3839,7 +3849,7 @@ done:
return error;
}
-GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup)
+GSM_Error GSM_ReadSMSBackupFile(const char *FileName, GSM_SMS_Backup *backup)
{
FILE *file;
@@ -3973,7 +3983,7 @@ static GSM_Error SaveSMSBackupTextFile(FILE *file, GSM_SMS_Backup *backup)
return ERR_NONE;
}
-GSM_Error GSM_AddSMSBackupFile(char *FileName, GSM_SMS_Backup *backup)
+GSM_Error GSM_AddSMSBackupFile(const char *FileName, GSM_SMS_Backup *backup)
{
FILE *file;
diff --git a/libgammu/service/backup/backtext.h b/libgammu/service/backup/backtext.h
index 989ecb2..c5e5c61 100644
--- a/libgammu/service/backup/backtext.h
+++ b/libgammu/service/backup/backtext.h
@@ -8,8 +8,8 @@
#include <gammu-backup.h>
#ifdef GSM_ENABLE_BACKUP
-GSM_Error LoadBackup(char *FileName, GSM_Backup *backup);
-GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, gboolean UseUnicode);
+GSM_Error LoadBackup(const char *FileName, GSM_Backup *backup);
+GSM_Error SaveBackup(const char *FileName, GSM_Backup *backup, gboolean UseUnicode);
#endif
#endif
diff --git a/libgammu/service/backup/backvcf.c b/libgammu/service/backup/backvcf.c
index 2899e18..5a89ecd 100644
--- a/libgammu/service/backup/backvcf.c
+++ b/libgammu/service/backup/backvcf.c
@@ -19,7 +19,7 @@
#define chk_fwrite(data, size, count, file) \
if (fwrite(data, size, count, file) != count) goto fail;
-GSM_Error SaveVCard(char *FileName, GSM_Backup *backup)
+GSM_Error SaveVCard(const char *FileName, GSM_Backup *backup)
{
int i;
size_t Length = 0;
@@ -65,7 +65,7 @@ fail:
return ERR_WRITING_FILE;
}
-GSM_Error LoadVCard(char *FileName, GSM_Backup *backup)
+GSM_Error LoadVCard(const char *FileName, GSM_Backup *backup)
{
GSM_File File;
GSM_Error error;
diff --git a/libgammu/service/backup/backvcf.h b/libgammu/service/backup/backvcf.h
index 3244de8..d5b4e7d 100644
--- a/libgammu/service/backup/backvcf.h
+++ b/libgammu/service/backup/backvcf.h
@@ -7,8 +7,8 @@
#include <gammu-backup.h>
#ifdef GSM_ENABLE_BACKUP
-GSM_Error SaveVCard(char *FileName, GSM_Backup *backup);
-GSM_Error LoadVCard(char *FileName, GSM_Backup *backup);
+GSM_Error SaveVCard(const char *FileName, GSM_Backup *backup);
+GSM_Error LoadVCard(const char *FileName, GSM_Backup *backup);
#endif
#endif
diff --git a/libgammu/service/backup/backvcs.c b/libgammu/service/backup/backvcs.c
index b6ba628..b7e9925 100644
--- a/libgammu/service/backup/backvcs.c
+++ b/libgammu/service/backup/backvcs.c
@@ -19,7 +19,7 @@
#define chk_fwrite(data, size, count, file) \
if (fwrite(data, size, count, file) != count) goto fail;
-GSM_Error SaveVCalendar(char *FileName, GSM_Backup *backup)
+GSM_Error SaveVCalendar(const char *FileName, GSM_Backup *backup)
{
int i;
size_t Length = 0;
@@ -71,7 +71,7 @@ fail:
return ERR_WRITING_FILE;
}
-GSM_Error LoadVCalendarPrivate(char *FileName, GSM_Backup *backup, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer)
+GSM_Error LoadVCalendarPrivate(const char *FileName, GSM_Backup *backup, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer)
{
GSM_File File;
GSM_Error error;
@@ -132,7 +132,7 @@ GSM_Error LoadVCalendarPrivate(char *FileName, GSM_Backup *backup, GSM_VCalendar
return error;
}
-GSM_Error LoadVCalendar(char *FileName, GSM_Backup *backup)
+GSM_Error LoadVCalendar(const char *FileName, GSM_Backup *backup)
{
return LoadVCalendarPrivate(FileName, backup, Nokia_VCalendar, Nokia_VToDo);
}
diff --git a/libgammu/service/backup/backvcs.h b/libgammu/service/backup/backvcs.h
index 4227bcf..058b901 100644
--- a/libgammu/service/backup/backvcs.h
+++ b/libgammu/service/backup/backvcs.h
@@ -7,9 +7,9 @@
#include <gammu-backup.h>
#ifdef GSM_ENABLE_BACKUP
-GSM_Error SaveVCalendar(char *FileName, GSM_Backup *backup);
-GSM_Error LoadVCalendar(char *FileName, GSM_Backup *backup);
-GSM_Error LoadVCalendarPrivate(char *FileName, GSM_Backup *backup, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer);
+GSM_Error SaveVCalendar(const char *FileName, GSM_Backup *backup);
+GSM_Error LoadVCalendar(const char *FileName, GSM_Backup *backup);
+GSM_Error LoadVCalendarPrivate(const char *FileName, GSM_Backup *backup, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer);
#endif
#endif
diff --git a/libgammu/service/backup/backvnt.c b/libgammu/service/backup/backvnt.c
index 861fe18..3d4f114 100644
--- a/libgammu/service/backup/backvnt.c
+++ b/libgammu/service/backup/backvnt.c
@@ -56,7 +56,7 @@ fail:
return ERR_WRITING_FILE;
}
-GSM_Error LoadVNT(char *FileName, GSM_Backup *backup)
+GSM_Error LoadVNT(const char *FileName, GSM_Backup *backup)
{
GSM_File File;
GSM_Error error;
diff --git a/libgammu/service/backup/backvnt.h b/libgammu/service/backup/backvnt.h
index 1978aed..5e3453f 100644
--- a/libgammu/service/backup/backvnt.h
+++ b/libgammu/service/backup/backvnt.h
@@ -11,8 +11,8 @@
#include <gammu-backup.h>
#ifdef GSM_ENABLE_BACKUP
-GSM_Error SaveVNT(char *FileName, GSM_Backup *backup);
-GSM_Error LoadVNT(char *FileName, GSM_Backup *backup);
+GSM_Error SaveVNT(const char *FileName, GSM_Backup *backup);
+GSM_Error LoadVNT(const char *FileName, GSM_Backup *backup);
#endif
#endif
diff --git a/libgammu/service/backup/gsmback.c b/libgammu/service/backup/gsmback.c
index 5505073..7c70944 100644
--- a/libgammu/service/backup/gsmback.c
+++ b/libgammu/service/backup/gsmback.c
@@ -187,7 +187,7 @@ GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, GSM_BackupForma
}
}
-GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup, GSM_BackupFormat Format)
+GSM_Error GSM_ReadBackupFile(const char *FileName, GSM_Backup *backup, GSM_BackupFormat Format)
{
GSM_ClearBackup(backup);
diff --git a/libgammu/service/gsmcal.c b/libgammu/service/gsmcal.c
index 3955e9c..65e2d1b 100644
--- a/libgammu/service/gsmcal.c
+++ b/libgammu/service/gsmcal.c
@@ -832,7 +832,7 @@ void GSM_ToDo_AdjustDate(GSM_ToDoEntry *note, GSM_DeltaTime *delta)
}
}
-GSM_Error GSM_EncodeVCALENDAR(char *Buffer, const size_t buff_len, size_t *Length, GSM_CalendarEntry *note, gboolean header, GSM_VCalendarVersion Version)
+GSM_Error GSM_EncodeVCALENDAR(char *Buffer, const size_t buff_len, size_t *Length, GSM_CalendarEntry *note, const gboolean header, const GSM_VCalendarVersion Version)
{
GSM_DateTime deltatime;
char dtstr[20];
diff --git a/libgammu/service/sms/gsmsms.c b/libgammu/service/sms/gsmsms.c
index 1a53940..076024a 100644
--- a/libgammu/service/sms/gsmsms.c
+++ b/libgammu/service/sms/gsmsms.c
@@ -101,6 +101,12 @@ static GSM_Error GSM_DecodeSMSDateTime(GSM_Debug_Info *di, GSM_DateTime *DT, con
if (req[6]&0x08) DT->Timezone = -DT->Timezone;
+ if (!CheckDate(DT) || !CheckTime(DT)) {
+ smfprintf(di, "Invalid date & time!\n");
+ DT->Year = 0;
+ return ERR_NONE;
+ }
+
smfprintf(di, "Decoding date & time: %s\n", OSDateTime(*DT, TRUE));
return ERR_NONE;