summaryrefslogtreecommitdiff
path: root/libgammu
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2011-12-13 10:35:32 +0100
committerMichal Čihař <michal@cihar.com>2011-12-13 10:35:32 +0100
commit32f1cc1d448700f86a5129c5d0ec7cacd7a0f53a (patch)
tree5a691465afa3d5e9cd6566a9d96d9131e453a57f /libgammu
parent3dd6a43ccd4feb5e2a041eb8192ce718f03dd885 (diff)
Imported Upstream version 1.30.92
Diffstat (limited to 'libgammu')
-rw-r--r--libgammu/CMakeLists.txt13
-rw-r--r--libgammu/gsmphones.c2
-rw-r--r--libgammu/gsmstate.c83
-rw-r--r--libgammu/gsmstate.h4
-rw-r--r--libgammu/misc/coding/md5-glib.c11
-rw-r--r--libgammu/misc/coding/md5.c4
-rw-r--r--libgammu/misc/coding/md5.h2
-rw-r--r--libgammu/phone/at/at-sms.c266
-rw-r--r--libgammu/phone/nokia/dct3/n6110.c2
-rw-r--r--libgammu/phone/nokia/dct4s40/6510/6510file.c6
-rw-r--r--libgammu/phone/nokia/dct4s40/6510/n6510.c41
-rw-r--r--libgammu/phone/nokia/ncommon.h2
-rw-r--r--libgammu/phone/nokia/nfunc.c20
-rw-r--r--libgammu/phone/obex/mobex.c2
-rw-r--r--libgammu/service/gsmcal.c94
-rw-r--r--libgammu/service/gsmdata.c20
-rw-r--r--libgammu/service/gsmmisc.c92
-rw-r--r--libgammu/service/gsmmisc.h3
-rw-r--r--libgammu/service/gsmpbk.c342
-rw-r--r--libgammu/service/sms/gsmsms.c322
20 files changed, 631 insertions, 700 deletions
diff --git a/libgammu/CMakeLists.txt b/libgammu/CMakeLists.txt
index d7656c5..a284a60 100644
--- a/libgammu/CMakeLists.txt
+++ b/libgammu/CMakeLists.txt
@@ -15,7 +15,6 @@ set (LIBRARY_SRC
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
@@ -74,6 +73,13 @@ set (LIBRARY_SRC
phone/symbian/gnapgen.c
phone/s60/s60phone.c)
+# Own or glib based MD5 implementation
+if (GLIB_FOUND)
+ list (APPEND LIBRARY_SRC misc/coding/md5-glib.c)
+else (GLIB_FOUND)
+ list (APPEND LIBRARY_SRC misc/coding/md5.c)
+endif (GLIB_FOUND)
+
if (WITH_BACKUP)
list (APPEND LIBRARY_SRC phone/dummy/dummy.c)
endif (WITH_BACKUP)
@@ -120,6 +126,11 @@ endif(CMAKE_COMPILER_IS_MINGW AND BUILD_SHARED_LIBS)
target_link_libraries (libGammu string)
+if (GLIB_FOUND)
+ target_link_libraries (libGammu ${GLIB_LIBRARIES} ${GOBJECT_LIBRARIES})
+ include_directories(${GLIB_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS})
+endif (GLIB_FOUND)
+
if (BLUEZ_FOUND)
target_link_libraries (libGammu ${BLUEZ_LIBRARIES})
include_directories (${BLUEZ_INCLUDE_DIR})
diff --git a/libgammu/gsmphones.c b/libgammu/gsmphones.c
index 79e0e01..ede8386 100644
--- a/libgammu/gsmphones.c
+++ b/libgammu/gsmphones.c
@@ -468,6 +468,7 @@ GSM_PhoneModel allmodels[] = {
F_SMS_SM, F_SMS_ME,
F_SMS_UTF8_ENCODED,
F_READ_SMSTEXTMODE,
+ F_FORCE_UTF8,
F_NO_UTF8, F_SAMSUNG_UTF8,
F_TSSPCSW, F_OBEX, F_IRMC_LEVEL_2, 0}},
@@ -940,6 +941,7 @@ GSM_PhoneModel allmodels[] = {
{"E162G", "E162G", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
{"E169", "E169", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
{"E169G", "E169G", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
+ {"E171", "E171", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
{"E173", "E173", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
{"E1556", "E1556", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
{"E1550", "E1550", "", {F_SMS_LOCATION_0, F_ENCODED_USSD, F_FOUR_DIGIT_YEAR, 0}},
diff --git a/libgammu/gsmstate.c b/libgammu/gsmstate.c
index 1b83a45..df86897 100644
--- a/libgammu/gsmstate.c
+++ b/libgammu/gsmstate.c
@@ -1589,89 +1589,6 @@ void GSM_OSErrorInfo(GSM_StateMachine *s, const char *description)
#endif
}
-#ifdef GSM_ENABLE_BACKUP
-
-void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info)
-{
- GSM_Error error;
- GSM_MemoryStatus MemStatus;
- GSM_ToDoStatus ToDoStatus;
- GSM_CalendarEntry Note;
- GSM_WAPBookmark Bookmark;
- GSM_MultiWAPSettings WAPSettings;
- GSM_FMStation FMStation;
- GSM_GPRSAccessPoint GPRSPoint;
-
- if (info->PhonePhonebook) {
- MemStatus.MemoryType = MEM_ME;
- error=s->Phone.Functions->GetMemoryStatus(s, &MemStatus);
- if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
- } else {
- info->PhonePhonebook = FALSE;
- }
- }
- if (info->SIMPhonebook) {
- MemStatus.MemoryType = MEM_SM;
- error=s->Phone.Functions->GetMemoryStatus(s, &MemStatus);
- if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
- } else {
- info->SIMPhonebook = FALSE;
- }
- }
- if (info->Calendar) {
- error=s->Phone.Functions->GetNextCalendar(s,&Note,TRUE);
- if (error!=ERR_NONE) info->Calendar = FALSE;
- }
- if (info->ToDo) {
- error=s->Phone.Functions->GetToDoStatus(s,&ToDoStatus);
- if (error == ERR_NONE && ToDoStatus.Used != 0) {
- } else {
- info->ToDo = FALSE;
- }
- }
- if (info->WAPBookmark) {
- Bookmark.Location = 1;
- error=s->Phone.Functions->GetWAPBookmark(s,&Bookmark);
- if (error == ERR_NONE) {
- } else {
- info->WAPBookmark = FALSE;
- }
- }
- if (info->WAPSettings) {
- WAPSettings.Location = 1;
- error=s->Phone.Functions->GetWAPSettings(s,&WAPSettings);
- if (error == ERR_NONE) {
- } else {
- info->WAPSettings = FALSE;
- }
- }
- if (info->MMSSettings) {
- WAPSettings.Location = 1;
- error=s->Phone.Functions->GetMMSSettings(s,&WAPSettings);
- if (error == ERR_NONE) {
- } else {
- info->WAPSettings = FALSE;
- }
- }
- if (info->FMStation) {
- FMStation.Location = 1;
- error = s->Phone.Functions->GetFMStation(s,&FMStation);
- if (error == ERR_NONE || error == ERR_EMPTY) {
- } else {
- info->FMStation = FALSE;
- }
- }
- if (info->GPRSPoint) {
- GPRSPoint.Location = 1;
- error = s->Phone.Functions->GetGPRSAccessPoint(s,&GPRSPoint);
- if (error == ERR_NONE || error == ERR_EMPTY) {
- } else {
- info->GPRSPoint = FALSE;
- }
- }
-}
-#endif
-
void GSM_SetIncomingCallCallback(GSM_StateMachine *s, IncomingCallCallback callback, void *user_data)
{
s->User.IncomingCall = callback;
diff --git a/libgammu/gsmstate.h b/libgammu/gsmstate.h
index 099c724..474c9fb 100644
--- a/libgammu/gsmstate.h
+++ b/libgammu/gsmstate.h
@@ -1457,10 +1457,6 @@ void GSM_DumpMessageLevel3Recv(GSM_StateMachine *s, unsigned const char *message
void GSM_OSErrorInfo(GSM_StateMachine *s, const char *description);
-#ifdef GSM_ENABLE_BACKUP
-void GSM_GetPhoneFeaturesForBackup(GSM_StateMachine *s, GSM_Backup_Info *info);
-#endif
-
#endif
/*@}*/
diff --git a/libgammu/misc/coding/md5-glib.c b/libgammu/misc/coding/md5-glib.c
new file mode 100644
index 0000000..731b742
--- /dev/null
+++ b/libgammu/misc/coding/md5-glib.c
@@ -0,0 +1,11 @@
+/**
+ * Wrapper for glib checksum functionality.
+ */
+#include "md5.h"
+#include <glib.h>
+#include <string.h>
+
+void CalculateMD5(unsigned char *buffer, int length, char *checksum)
+{
+ strcpy(checksum, g_compute_checksum_for_data(G_CHECKSUM_MD5, buffer, length));
+}
diff --git a/libgammu/misc/coding/md5.c b/libgammu/misc/coding/md5.c
index e8ccdc1..7e5f519 100644
--- a/libgammu/misc/coding/md5.c
+++ b/libgammu/misc/coding/md5.c
@@ -1,5 +1,6 @@
#include "md5.h"
#include <stdio.h>
+#include <string.h>
/*
* This code implements the MD5 message-digest algorithm.
@@ -40,7 +41,6 @@ void MD5Transform(uint32 buf[4], uint32 const in[16]);
typedef struct MD5Context MD5_CTX;
/* md5.c */
-#include <string.h>
/*
* Note: this code is harmless on little-endian machines.
@@ -272,7 +272,7 @@ void MD5Transform(uint32 buf[4], uint32 const in[16])
buf[3] += d;
}
-void CalculateMD5(unsigned char *buffer, int length, unsigned char *checksum)
+void CalculateMD5(unsigned char *buffer, int length, char *checksum)
{
int i;
struct MD5Context m_md5;
diff --git a/libgammu/misc/coding/md5.h b/libgammu/misc/coding/md5.h
index 9da9229..73d627c 100644
--- a/libgammu/misc/coding/md5.h
+++ b/libgammu/misc/coding/md5.h
@@ -1,6 +1,6 @@
#ifndef __md5_h
#define __md5_h
-void CalculateMD5(unsigned char *buffer, int length, unsigned char *checksum);
+void CalculateMD5(unsigned char *buffer, int length, char *checksum);
#endif
diff --git a/libgammu/phone/at/at-sms.c b/libgammu/phone/at/at-sms.c
index fe401ea..59769dd 100644
--- a/libgammu/phone/at/at-sms.c
+++ b/libgammu/phone/at/at-sms.c
@@ -548,15 +548,48 @@ GSM_Error ATGEN_DecodePDUMessage(GSM_StateMachine *s, const char *PDU, const int
return ERR_NONE;
}
+GSM_Error ATGEN_ReadSMSText(GSM_Protocol_Message *msg, GSM_StateMachine *s, GSM_SMSMessage *sms)
+{
+ int i;
+ const char *line;
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
+ size_t length = 0;
+ GSM_Error error;
+
+ /* Go trough all lines till OK */
+ for (i = 3; strcmp(line = GetLineString(msg->Buffer, &Priv->Lines, i), "OK") != 0; i++) {
+ if (i > 3) {
+ /* Include new line */
+ sms->Text[(2 * sms->Length) + 0] = 0;
+ sms->Text[(2 * sms->Length) + 1] = '\n';
+ sms->Text[(2 * sms->Length) + 2] = 0;
+ sms->Text[(2 * sms->Length) + 3] = 0;
+ sms->Length++;
+ }
+ length = GetLineLength(msg->Buffer, &Priv->Lines, i);
+ error = ATGEN_DecodeText(s, line, length,
+ sms->Text + (2 * sms->Length),
+ sizeof(sms->Text) - (2 * sms->Length),
+ TRUE, FALSE);
+ if (error != ERR_NONE) {
+ return error;
+ }
+ sms->Length += length;
+ }
+ return ERR_NONE;
+}
+
GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *s)
{
GSM_Error error = ERR_UNKNOWN;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_SMSMessage *sms = &s->Phone.Data.GetSMSMessage->SMS[0];
- unsigned char buffer[300] = {'\0'}, firstbyte = 0, TPDCS = 0, TPUDL = 0, TPStatus = 0;
- const char *line;
- size_t length = 0;
+ unsigned char buffer[3000] = {'\0'}, firstbyte = 0, TPDCS = 0, TPUDL = 0, TPStatus = 0, TPPID = 0;
int current = 0, i = 0;
+ int state;
+ unsigned char *ptr;
+ char *comma;
+ char *expected_comma;
switch (Priv->ReplyState) {
case AT_Reply_OK:
@@ -569,25 +602,60 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
case SMS_AT_PDU:
CopyLineString(buffer, msg->Buffer, &Priv->Lines, 2);
+ /* Parse reply */
+ error = ATGEN_ParseReply(s, buffer, "+CMGR: @i, @0", &state);
+ if (error != ERR_NONE) {
+ return error;
+ }
+
/* Siemens MC35 (only ?) */
- if (strstr(msg->Buffer,"+CMGR: 0,,0")!=NULL) {
+ if (strcmp(buffer, "+CMGR: 0,,0") == 0) {
return ERR_EMPTY;
}
- /* @bug Hardcoded position is wrong! */
- return ATGEN_DecodePDUMessage(s,
- GetLineString(msg->Buffer,&Priv->Lines,3),
- atoi(buffer + 7));
+
+ error = ATGEN_DecodePDUMessage(s, GetLineString(msg->Buffer,&Priv->Lines,3), state);
+ return error;
case SMS_AT_TXT:
GSM_SetDefaultReceivedSMSData(sms);
- error = ATGEN_ParseReply(s,
- GetLineString(msg->Buffer, &Priv->Lines, 2),
- "+CMGR: @r, @p, @d",
- buffer, sizeof(buffer), sms->Number, sizeof(sms->Number),
- &sms->DateTime);
- if (error != ERR_NONE) {
- return error;
+ /*
+ * This is just a hack until proper parsing of text mode is done.
+ * It uses old style of manual parsing, to skip entries parsed above.
+ */
+ current = 0;
+
+ /* Skip to first : */
+ while (msg->Buffer[current] != ':') {
+ current++;
}
+ current++;
+ /* Skip any spaces */
+ while (msg->Buffer[current] == ' ') {
+ current++;
+ }
+
+ /* Grab first parameter */
+ current += ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
+
+ /* Remove leading " */
+ for (ptr = buffer; *ptr == '"'; ptr++);
+ if (ptr != buffer) {
+ memmove (buffer, ptr, strlen (ptr) + 1);
+ }
+
+ /* Go to the end of string */
+ for (ptr = buffer; *ptr; ptr++);
+ /* Remove trailing " */
+ ptr--;
+ while (ptr >= buffer && *ptr == '"') {
+ ptr--;
+ }
+ ptr++;
+ *ptr = 0;
+
+ smprintf(s, "Message type: %s\n", buffer);
+
+ /* Check message type */
if (!strcmp(buffer,"0") || !strcmp(buffer,"REC UNREAD")) {
smprintf(s, "SMS type - deliver\n");
sms->State = SMS_UnRead;
@@ -632,7 +700,12 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
sms->Folder = 4; /*OUTBOX ME*/
}
sms->InboxFolder = FALSE;
+ } else {
+ smprintf(s, "Uknown message state: %s\n", buffer);
+ return ERR_UNKNOWN;
}
+
+ /* Do we have detailed format? */
if (Priv->SMSTextDetails == FALSE) {
sms->Class = 1;
sms->Coding = SMS_Coding_Default_No_Compression;
@@ -642,61 +715,25 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
sms->SMSC.Number[1]=0;
sms->ReplyViaSameSMSC = FALSE;
- /* Go trough all lines till OK */
- for (i = 3; strcmp(line = GetLineString(msg->Buffer, &Priv->Lines, i), "OK") != 0; i++) {
- if (i > 3) {
- /* Include new line */
- sms->Text[(2 * sms->Length) + 0] = 0;
- sms->Text[(2 * sms->Length) + 1] = '\n';
- sms->Text[(2 * sms->Length) + 2] = 0;
- sms->Text[(2 * sms->Length) + 3] = 0;
- sms->Length++;
- }
- length = GetLineLength(msg->Buffer, &Priv->Lines, i);
- error = ATGEN_DecodeText(s, line, length,
- sms->Text + (2 * sms->Length),
- sizeof(sms->Text) - (2 * sms->Length),
- TRUE, FALSE);
- if (error != ERR_NONE)
- return error;
- sms->Length += length;
- }
- return ERR_NONE;
+ return ATGEN_ReadSMSText(msg, s, sms);
}
- /*
- * This is just a hack until proper parsing of text mode is done.
- * It uses old style of manual parsing, to skip entries parsed above.
- */
- current = 0;
-
- while (msg->Buffer[current]!='"') {
- current++;
- }
- current += ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
current += ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
-
/* It's delivery report according to Nokia AT standards */
- if (sms->Folder == 1 && buffer[0]!=0 && buffer[0]!='"') {
+ if ((sms->Folder == 1 || sms->Folder == 3) && buffer[0]!=0 && buffer[0]!='"') {
/* ??? */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
- /* format of sender number */
+ /* Sender number */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
- /* Sender number */
/* FIXME: support for all formats */
EncodeUnicode(sms->Number,buffer+1,strlen(buffer)-2);
smprintf(s, "Sender \"%s\"\n",DecodeUnicodeString(sms->Number));
- /* ??? */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
+ firstbyte = atoi(buffer);
- /* Sending datetime */
- current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
- i = strlen(buffer);
- buffer[i] = ',';
- i++;
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer+i);
smprintf(s, "\"%s\"\n",buffer);
error = ATGEN_DecodeDateTime(s, &sms->DateTime, buffer);
@@ -719,6 +756,7 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
/* TPStatus */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
TPStatus = atoi(buffer);
+ buffer[PHONE_SMSDeliver.firstbyte] = firstbyte;
buffer[PHONE_SMSStatusReport.TPStatus] = TPStatus;
error = GSM_DecodeSMSFrameStatusReportData(&(s->di), sms, buffer, PHONE_SMSStatusReport);
@@ -731,37 +769,28 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
sms->PDU = SMS_Status_Report;
sms->ReplyViaSameSMSC = FALSE;
} else {
- /* Sender number */
/* FIXME: support for all formats */
EncodeUnicode(sms->Number,buffer+1,strlen(buffer)-2);
- /* Sender number in alphanumeric format ? */
- current += ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
-
if (strlen(buffer)!=0) {
EncodeUnicode(sms->Number,buffer+1,strlen(buffer)-2);
}
smprintf(s, "Sender \"%s\"\n",DecodeUnicodeString(sms->Number));
+ current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
/* Sending datetime */
+
if (sms->Folder == 1 || sms->Folder == 3) {
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
- /* FIXME: ATGEN_ExtractOneParameter() is broken as it doesn't respect
- * quoting of parameters and thus +FOO: "ab","cd,ef" will consider
- * as three arguments: "ab" >> "cd >> ef"
- */
- if (*buffer=='"') {
- i = strlen(buffer);
- buffer[i] = ',';
- i++;
- current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer+i);
- }
+
smprintf(s, "\"%s\"\n",buffer);
- if (*buffer)
+ if (*buffer) {
error = ATGEN_DecodeDateTime(s, &sms->DateTime, buffer);
- if (error != ERR_NONE) return error;
- else {
+ if (error != ERR_NONE) {
+ return error;
+ }
+ } else {
/* FIXME: What is the proper undefined GSM_DateTime ? */
memset(&sms->DateTime, 0, sizeof(sms->DateTime));
}
@@ -771,40 +800,47 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
return error;
}
}
- /* Sender number format */
+
+ /* address type */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
/* First byte */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
firstbyte = atoi(buffer);
sms->ReplyViaSameSMSC = FALSE;
+ smprintf (s, "buffer firstbyte:%s\n", buffer);
- /* GSM 03.40 section 9.2.3.17 (TP-Reply-Path) */
- if ((firstbyte & 128)==128) {
- sms->ReplyViaSameSMSC = TRUE;
- }
/* TP PID */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
sms->ReplaceMessage = 0;
- if (atoi(buffer) > 0x40 && atoi(buffer) < 0x48) {
- sms->ReplaceMessage = atoi(buffer) - 0x40;
- }
- smprintf(s, "TPPID: %02x %i\n",atoi(buffer),atoi(buffer));
+ TPPID = atoi(buffer);
/* TP DCS */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
TPDCS = atoi(buffer);
+ smprintf(s, "TPDCS: %02x\n", TPDCS);
+ /* SMSC number */
+ /* FIXME: support for all formats */
+ current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
- if (sms->Folder == 2 || sms->Folder == 4) {
+ if (buffer[0] != '"' && buffer[0]) {
/*TP VP */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
}
- /* SMSC number */
- /* FIXME: support for all formats */
- current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
+
EncodeUnicode(sms->SMSC.Number,buffer+1,strlen(buffer)-2);
+ /* GSM 03.40 section 9.2.3.17 (TP-Reply-Path) */
+ if ((firstbyte & 128)==128) {
+ sms->ReplyViaSameSMSC = TRUE;
+ }
+
+ if (TPPID > 0x40 && TPPID < 0x48) {
+ sms->ReplaceMessage = TPPID - 0x40;
+ }
+ smprintf(s, "TPPID: %02x %i\n", TPPID, TPPID);
+
/* Format of SMSC number */
current+=ATGEN_ExtractOneParameter(msg->Buffer+current, buffer);
@@ -814,22 +850,11 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
current++;
sms->Coding = GSM_GetMessageCoding(&(s->di), TPDCS);
sms->Class = -1;
-
- if ((TPDCS & 0xD0) == 0x10) {
- /* bits 7..4 set to 00x1 */
- if ((TPDCS & 0xC) == 0xC) {
- smprintf(s, "WARNING: reserved alphabet value in TPDCS\n");
- } else {
- sms->Class = (TPDCS & 3);
- }
- } else if ((TPDCS & 0xF0) == 0xF0) {
- /* bits 7..4 set to 1111 */
- if ((TPDCS & 8) == 8) {
- smprintf(s, "WARNING: set reserved bit 3 in TPDCS\n");
- } else {
- sms->Class = (TPDCS & 3);
- }
+ /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */
+ if ((TPDCS & 0xD0) == 0x10 || (TPDCS & 0xF0) == 0xF0) {
+ sms->Class = TPDCS & 3;
}
+
smprintf(s, "SMS class: %i\n",sms->Class);
switch (sms->Coding) {
@@ -839,14 +864,51 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
/* If UDH available, treat it as Unicode or 8 bit */
if ((firstbyte & 0x40)!=0x40) {
sms->UDH.Type = UDH_NoUDH;
- sms->Length = TPUDL;
- EncodeUnicode(sms->Text,msg->Buffer+Priv->Lines.numbers[2*2],TPUDL);
+ error = ATGEN_ReadSMSText(msg, s, sms);
+ if (sms->Length == TPUDL + 4) {
+ char *tail;
+ tail = sms->Text + 2 * (UnicodeLength (sms->Text) - 4);
+ if (tail[0] == 0 && tail[1] == ',' && tail[4] == 0 && tail[5] == ',') {
+ tail[1] = 0;
+ sms->Length = TPUDL;
+ }
+ }
+ if (sms->Length != TPUDL) {
+ smprintf(s, "WARNING: Indicated message length (%d) does not match real (%d)\n", TPUDL, sms->Length);
+ }
break;
}
case SMS_Coding_Unicode_No_Compression:
case SMS_Coding_8bit:
+ if ((firstbyte & 0x40)==0x40 && GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SMS_UTF8_ENCODED)) {
+ comma = strchr (msg->Buffer+current, ',');
+
+ if (sms->Coding == SMS_Coding_Default_No_Compression) {
+ expected_comma = (char *)msg->Buffer+current + ((7 * TPUDL + 7) / 8) * 2;
+ } else {
+ expected_comma = (char *)msg->Buffer+current + TPUDL * 2;
+ }
+ if (comma == expected_comma || !comma) {
+ comma = expected_comma;
+ } else {
+ smprintf (s, "UDL fix: %d,", TPUDL);
+ if (sms->Coding == SMS_Coding_Default_No_Compression) {
+ TPUDL = ((comma - ((char *)msg->Buffer+current)) * 4) / 7;
+ } else {
+ TPUDL = (comma - ((char *)msg->Buffer+current)) / 2;
+ }
+ smprintf (s, "%d\n", TPUDL);
+ }
+ DecodeHexBin(buffer+PHONE_SMSDeliver.Text, msg->Buffer+current, comma - (char *) (msg->Buffer+current));
+ buffer[PHONE_SMSDeliver.firstbyte] = firstbyte;
+ buffer[PHONE_SMSDeliver.TPDCS] = TPDCS;
+ buffer[PHONE_SMSDeliver.TPUDL] = TPUDL;
+ return GSM_DecodeSMSFrameText(&(s->di), sms, buffer, PHONE_SMSDeliver);
+ }
+
if (sms->Coding == SMS_Coding_Unicode_No_Compression && GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SMS_UTF8_ENCODED)) {
DecodeUTF8(buffer+PHONE_SMSDeliver.Text, msg->Buffer+current, TPUDL);
+ TPUDL = 2 * UnicodeLength (buffer+PHONE_SMSDeliver.Text);
} else {
DecodeHexBin(buffer+PHONE_SMSDeliver.Text, msg->Buffer+current, TPUDL*2);
}
diff --git a/libgammu/phone/nokia/dct3/n6110.c b/libgammu/phone/nokia/dct3/n6110.c
index 67810e3..f31fe82 100644
--- a/libgammu/phone/nokia/dct3/n6110.c
+++ b/libgammu/phone/nokia/dct3/n6110.c
@@ -2113,7 +2113,7 @@ static GSM_Error N6110_ReplyIncomingSMS(GSM_Protocol_Message *msg, GSM_StateMach
static GSM_Error N6110_ReplyAddCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
{
- smprintf(s, "Writting calendar note: ");
+ smprintf(s, "Writing calendar note: ");
switch (msg->Buffer[4]) {
case 0x01:
smprintf(s, "OK\n");
diff --git a/libgammu/phone/nokia/dct4s40/6510/6510file.c b/libgammu/phone/nokia/dct4s40/6510/6510file.c
index 57c6e08..3f26207 100644
--- a/libgammu/phone/nokia/dct4s40/6510/6510file.c
+++ b/libgammu/phone/nokia/dct4s40/6510/6510file.c
@@ -210,10 +210,8 @@ GSM_Error N6510_ReplyGetFileFolderInfo1(GSM_Protocol_Message *msg, GSM_StateMach
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:
@@ -611,7 +609,6 @@ static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, int *Po
case GSM_File_Sound_NRT : Header[231]=0x04; Header[233]=0x06; break;
case GSM_File_Video_3GP : Header[231]=0x08; Header[233]=0x05; break;
case GSM_File_Java_JAR : Header[231]=0x10; Header[233]=0x01; break;
-#ifdef DEVELOP
case GSM_File_MMS:
Header[214]=0x07;
Header[215]=0xd3;
@@ -622,7 +619,6 @@ static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, int *Po
Header[220]=0x29;
Header[233]=0x01;
break;
-#endif
default : Header[231]=0x01; Header[233]=0x05;
}
Header[235] = 0x01;
@@ -690,7 +686,6 @@ static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, int *Po
case GSM_File_Sound_NRT : Header[231]=0x04; Header[233]=0x06; break;
case GSM_File_Video_3GP : Header[231]=0x08; Header[233]=0x05; break;
case GSM_File_Java_JAR : Header[231]=0x10; Header[233]=0x01; break;
-#ifdef DEVELOP
case GSM_File_MMS:
Header[214]=0x07;
Header[215]=0xd3;
@@ -701,7 +696,6 @@ static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, int *Po
Header[220]=0x29;
Header[233]=0x01;
break;
-#endif
default : Header[231]=0x01; Header[233]=0x05;
}
Header[235] = 0x01;
diff --git a/libgammu/phone/nokia/dct4s40/6510/n6510.c b/libgammu/phone/nokia/dct4s40/6510/n6510.c
index 573384b..32a6f76 100644
--- a/libgammu/phone/nokia/dct4s40/6510/n6510.c
+++ b/libgammu/phone/nokia/dct4s40/6510/n6510.c
@@ -3811,34 +3811,6 @@ static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, gboolean enable)
}
}
-#ifdef DEVELOP
-
-static GSM_Error N6510_ReplyEnableGPRSAccessPoint(GSM_Protocol_Message *msg, GSM_StateMachine *s)
-{
- if (msg->Buffer[13] == 0x02) return ERR_NONE;
- return ERR_UNKNOWNRESPONSE;
-}
-
-static GSM_Error N6510_EnableGPRSAccessPoint(GSM_StateMachine *s)
-{
- GSM_Error error;
- int i;
- unsigned char req[] = {
- N7110_FRAME_HEADER, 0x05, 0x00, 0x00, 0x00, 0x2C, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00};
-
- if (GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOGPRSPOINT)) return ERR_NOTSUPPORTED;
-
- for (i=0;i<3;i++) {
- smprintf(s, "Activating full GPRS access point support\n");
- error = GSM_WaitFor (s, req, 16, 0x43, s->Phone.Data.Priv.N6510.Timeout, ID_EnableGPRSPoint);
- if (error != ERR_NONE) return error;
- }
- return error;
-}
-
-#endif
-
static GSM_Error N6510_ReplyGetGPRSAccessPoint(GSM_Protocol_Message *msg, GSM_StateMachine *s)
{
GSM_GPRSAccessPoint *point = s->Phone.Data.GPRSPoint;
@@ -3882,11 +3854,6 @@ static GSM_Error N6510_GetGPRSAccessPoint(GSM_StateMachine *s, GSM_GPRSAccessPoi
s->Phone.Data.GPRSPoint = point;
-#ifdef DEVELOP
- error = N6510_EnableGPRSAccessPoint(s);
- if (error != ERR_NONE) return error;
-#endif
-
smprintf(s, "Getting GPRS access point name\n");
error=GSM_WaitFor (s, Name, 16, 0x43, s->Phone.Data.Priv.N6510.Timeout, ID_GetGPRSPoint);
if (error != ERR_NONE) return error;
@@ -3936,11 +3903,6 @@ static GSM_Error N6510_SetGPRSAccessPoint(GSM_StateMachine *s, GSM_GPRSAccessPoi
s->Phone.Data.GPRSPoint = point;
-#ifdef DEVELOP
- error = N6510_EnableGPRSAccessPoint(s);
- if (error != ERR_NONE) return error;
-#endif
-
smprintf(s, "Getting GPRS access point name\n");
error=GSM_WaitFor (s, Name, 16, 0x43, s->Phone.Data.Priv.N6510.Timeout, ID_SetGPRSPoint);
if (error != ERR_NONE) return error;
@@ -4422,9 +4384,6 @@ static GSM_Reply_Function N6510ReplyFunctions[] = {
{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 },
diff --git a/libgammu/phone/nokia/ncommon.h b/libgammu/phone/nokia/ncommon.h
index fc48c8d..93685c0 100644
--- a/libgammu/phone/nokia/ncommon.h
+++ b/libgammu/phone/nokia/ncommon.h
@@ -25,7 +25,7 @@ typedef enum {
N7110_PBK_NUMBER = 0x0B, /* Phone number */
N7110_PBK_RINGTONE_ID = 0x0C, /* Ringtone ID */
N7110_PBK_DATETIME = 0x13, /* Call register: date and time */
- N7110_PBK_UNKNOWN1 = 0x19, /* Call register: with missed calls */
+ N7110_PBK_MISSED = 0x19, /* Call register: with missed calls */
N7110_PBK_SPEEDDIAL = 0x1A, /* Speed dial */
N7110_PBK_GROUPLOGO = 0x1B, /* Caller group: logo */
N7110_PBK_LOGOON = 0x1C, /* Caller group: is logo on ? */
diff --git a/libgammu/phone/nokia/nfunc.c b/libgammu/phone/nokia/nfunc.c
index 96ca03c..3d77df9 100644
--- a/libgammu/phone/nokia/nfunc.c
+++ b/libgammu/phone/nokia/nfunc.c
@@ -375,6 +375,7 @@ GSM_Error N71_65_DecodePhonebook(GSM_StateMachine *s,
GSM_EntryLocation Location = PBK_Location_Unknown;
gboolean found=FALSE;
gboolean foundbb5add=FALSE;
+ gboolean missed_call = FALSE;
int favorite_messaging_numbers[10];
size_t used_favorite_messaging_numbers = 0;
@@ -858,8 +859,12 @@ GSM_Error N71_65_DecodePhonebook(GSM_StateMachine *s,
entry->Entries[Block[5]-1].SMSList[i] = Block[9];
continue;
}
- if (Block[0] == N7110_PBK_UNKNOWN1
- || Block[0] == N7110_PBK_UNKNOWN2
+ if (Block[0] == N7110_PBK_MISSED) {
+ missed_call = TRUE;
+ smprintf(s,"Unknown entry type 0x%02x data length %d\n", Block[0], bs-6);
+ continue;
+ }
+ if (Block[0] == N7110_PBK_UNKNOWN2
|| Block[0] == N7110_PBK_UNKNOWN3
|| Block[0] == N3600_PBK_UNKNOWN1
|| Block[0] == N6303_PBK_UNKNOWN1) {
@@ -915,7 +920,16 @@ GSM_Error N71_65_DecodePhonebook(GSM_StateMachine *s,
return ERR_UNKNOWNRESPONSE;
}
- if (entry->EntriesNum == 0) return ERR_EMPTY;
+ if (entry->EntriesNum == 0) {
+ if (missed_call) {
+ smprintf(s, "Empty entry with missed call reference, adding blank number!\n");
+ entry->Entries[entry->EntriesNum].EntryType = PBK_Number_General;
+ entry->Entries[entry->EntriesNum].Location = PBK_Location_Unknown;
+ EncodeUnicode(entry->Entries[entry->EntriesNum].Text, "", 0);
+ } else {
+ return ERR_EMPTY;
+ }
+ }
/* Process favorite messaging numbers */
for (i = 0; i < (int)used_favorite_messaging_numbers; i++) {
diff --git a/libgammu/phone/obex/mobex.c b/libgammu/phone/obex/mobex.c
index 0e5a052..81dcd4f 100644
--- a/libgammu/phone/obex/mobex.c
+++ b/libgammu/phone/obex/mobex.c
@@ -244,7 +244,7 @@ GSM_Error MOBEX_GetNextEntry(GSM_StateMachine *s, const char *path, const gboole
/* 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;
diff --git a/libgammu/service/gsmcal.c b/libgammu/service/gsmcal.c
index 1cfa99d..6853c90 100644
--- a/libgammu/service/gsmcal.c
+++ b/libgammu/service/gsmcal.c
@@ -435,27 +435,6 @@ GSM_Error GSM_Translate_Category_To_VCal (char *string, const GSM_CalendarNoteTy
}
/**
- * Grabs single value of type from calendar note starting with record
- * start.
- */
-GSM_Error GSM_Calendar_GetValue(const GSM_CalendarEntry *note, int *start, const GSM_CalendarType type, int *number, GSM_DateTime *date)
-{
- for (; *start < note->EntriesNum; (*start)++) {
- if (note->Entries[*start].EntryType == type) {
- if (number != NULL) {
- *number = note->Entries[*start].Number;
- }
- if (date != NULL) {
- *date = note->Entries[*start].Date;
- }
- (*start)++;
- return ERR_NONE;
- }
- }
- return ERR_EMPTY;
-}
-
-/**
* Converts Gammu recurrence to vCal format. See GSM_DecodeVCAL_RRULE
* for grammar description.
*/
@@ -1221,15 +1200,6 @@ GSM_Error GSM_EncodeVTODO(char *Buffer, const size_t buff_len, size_t *Length, c
return ERR_NONE;
}
-GSM_TimeUnit ReadVCALTimeUnits (unsigned char *Buffer)
-{
- if (strcasestr(Buffer,"days")) return GSM_TimeUnit_Days;
- if (strcasestr(Buffer,"hours")) return GSM_TimeUnit_Hours;
- if (strcasestr(Buffer,"minutes")) return GSM_TimeUnit_Minutes;
- if (strcasestr(Buffer,"seconds")) return GSM_TimeUnit_Seconds;
- return GSM_TimeUnit_Unknown;
-}
-
GSM_DeltaTime ReadVCALTriggerTime (unsigned char *Buffer)
{
GSM_DeltaTime dt;
@@ -1806,18 +1776,11 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(GSM_Debug_Info *di, char *Buffer, size_t *Po
/* Read Mozilla calendar entries. Some of them will not be used here. Notably alarm time
can defined in several ways. We will use the trigger value only since this is the value
Mozilla calendar uses when importing ics-files. */
- if (strncmp(Line, "UID:", 4) == 0) {
- ReadVCALText(Line, "UID", Buff, CalVer == Mozilla_iCalendar); /* Any use for UIDs? */
+ if (ReadVCALText(Line, "UID", Buff, CalVer == Mozilla_iCalendar, NULL)) {
+ /* Any use for UIDs? */
break;
}
-#if 0
- if (strstr(Line,"X-MOZILLA-ALARM-DEFAULT-UNITS:")) {
- if (ReadVCALText(Line, "X-MOZILLA-ALARM-DEFAULT-UNITS", Buff, CalVer == Mozilla_iCalendar)) {
- unit = ReadVCALTimeUnits(DecodeUnicodeString(Buff));
- break;
- }
- }
-#endif
+
if (strstr(Line,"X-MOZILLA-ALARM-DEFAULT-LENGTH:")) {
if (ReadVCALInt(Line, "X-MOZILLA-ALARM-DEFAULT-LENGTH", &deltatime)) {
break;
@@ -1828,7 +1791,7 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(GSM_Debug_Info *di, char *Buffer, size_t *Po
error = MyGetLine(Buffer, Pos, Line, lBuffer, sizeof(Line), TRUE);
if (error != ERR_NONE) return error;
if (strlen(Line) == 0) break;
- if (ReadVCALText(Line, "TRIGGER;VALUE=DURATION", Buff, CalVer == Mozilla_iCalendar)) {
+ if (ReadVCALText(Line, "TRIGGER;VALUE=DURATION", Buff, CalVer == Mozilla_iCalendar, NULL)) {
trigger = ReadVCALTriggerTime(DecodeUnicodeString(Buff));
break;
}
@@ -1850,31 +1813,31 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(GSM_Debug_Info *di, char *Buffer, size_t *Po
break;
}
- if ((ReadVCALText(Line, "SUMMARY", Buff, CalVer == Mozilla_iCalendar))) {
+ if ((ReadVCALText(Line, "SUMMARY", Buff, CalVer == Mozilla_iCalendar, NULL))) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text, Buff);
Calendar->Entries[Calendar->EntriesNum].AddError = ERR_NONE;
Calendar->EntriesNum++;
}
- if ((ReadVCALText(Line, "DESCRIPTION", Buff, CalVer == Mozilla_iCalendar))) {
+ if ((ReadVCALText(Line, "DESCRIPTION", Buff, CalVer == Mozilla_iCalendar, NULL))) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text, Buff);
Calendar->Entries[Calendar->EntriesNum].AddError = ERR_NONE;
Calendar->EntriesNum++;
}
- if (ReadVCALText(Line, "LOCATION", Buff, CalVer == Mozilla_iCalendar)) {
+ if (ReadVCALText(Line, "LOCATION", Buff, CalVer == Mozilla_iCalendar, NULL)) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text, Buff);
Calendar->Entries[Calendar->EntriesNum].AddError = ERR_NONE;
Calendar->EntriesNum++;
}
- if ((ReadVCALText(Line, "X-IRMC-LUID", Buff, CalVer == Mozilla_iCalendar))) {
+ if ((ReadVCALText(Line, "X-IRMC-LUID", Buff, CalVer == Mozilla_iCalendar, NULL))) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LUID;
CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text, Buff);
Calendar->Entries[Calendar->EntriesNum].AddError = ERR_NONE;
Calendar->EntriesNum++;
}
- if ((ReadVCALText(Line, "CLASS", Buff, CalVer == Mozilla_iCalendar))) {
+ if ((ReadVCALText(Line, "CLASS", Buff, CalVer == Mozilla_iCalendar, NULL))) {
Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_PRIVATE;
if (mywstrncasecmp(Buff, "\0P\0U\0B\0L\0I\0C\0\0", 0)) {
Calendar->Entries[Calendar->EntriesNum].Number = 0;
@@ -1952,27 +1915,16 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(GSM_Debug_Info *di, char *Buffer, size_t *Po
GSM_Translate_Category_From_VCal(Line+11, &ToDo->Type);
}
- if (strncmp(Line, "UID:", 4) == 0) {
- ReadVCALText(Line, "UID", Buff, ToDoVer == Mozilla_VToDo); /* Any use for UIDs? */
+ if (ReadVCALText(Line, "UID", Buff, ToDoVer == Mozilla_VToDo, NULL)){
+ /* Any use for UIDs? */
break;
}
-#if 0
- if (strstr(Line,"X-MOZILLA-ALARM-DEFAULT-UNITS:")) {
- if (ReadVCALText(Line, "X-MOZILLA-ALARM-DEFAULT-UNITS", Buff, ToDoVer == Mozilla_VToDo)) {
- unit = ReadVCALTimeUnits(DecodeUnicodeString(Buff));
- break;
- }
- }
-#endif
- if (strstr(Line,"X-MOZILLA-ALARM-DEFAULT-LENGTH:")) {
- if (ReadVCALInt(Line, "X-MOZILLA-ALARM-DEFAULT-LENGTH", &deltatime)) {
- break;
- }
+
+ if (ReadVCALInt(Line, "X-MOZILLA-ALARM-DEFAULT-LENGTH", &deltatime)) {
+ break;
}
- if (strstr(Line,"X-SONYERICSSON-DST:")) {
- if (ReadVCALInt(Line, "X-SONYERICSSON-DST", &dstflag)) {
- break;
- }
+ if (ReadVCALInt(Line, "X-SONYERICSSON-DST", &dstflag)) {
+ break;
}
if (ReadVCALDate(Line, "DUE", &Date, &is_date_only)) {
@@ -2012,22 +1964,22 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(GSM_Debug_Info *di, char *Buffer, size_t *Po
ToDo->EntriesNum++;
}
- if ((ReadVCALText(Line, "SUMMARY", Buff, ToDoVer == Mozilla_VToDo))) {
+ if ((ReadVCALText(Line, "SUMMARY", Buff, ToDoVer == Mozilla_VToDo, NULL))) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT;
CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text, Buff);
ToDo->EntriesNum++;
}
- if ((ReadVCALText(Line, "DESCRIPTION", Buff, ToDoVer == Mozilla_VToDo))) {
+ if ((ReadVCALText(Line, "DESCRIPTION", Buff, ToDoVer == Mozilla_VToDo, NULL))) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_DESCRIPTION;
CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text, Buff);
ToDo->EntriesNum++;
}
- if ((ReadVCALText(Line, "LOCATION", Buff, ToDoVer == Mozilla_VToDo))) {
+ if ((ReadVCALText(Line, "LOCATION", Buff, ToDoVer == Mozilla_VToDo, NULL))) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_LOCATION;
CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text, Buff);
ToDo->EntriesNum++;
}
- if (ReadVCALText(Line, "PRIORITY", Buff, ToDoVer == Mozilla_VToDo)) {
+ if (ReadVCALText(Line, "PRIORITY", Buff, ToDoVer == Mozilla_VToDo, NULL)) {
if (atoi(DecodeUnicodeString(Buff))==3) ToDo->Priority = GSM_Priority_Low;
else if (atoi(DecodeUnicodeString(Buff))==2) ToDo->Priority = GSM_Priority_Medium;
else if (atoi(DecodeUnicodeString(Buff))==1) ToDo->Priority = GSM_Priority_High;
@@ -2043,12 +1995,12 @@ GSM_Error GSM_DecodeVCALENDAR_VTODO(GSM_Debug_Info *di, char *Buffer, size_t *Po
ToDo->Entries[ToDo->EntriesNum].Number = 0;
ToDo->EntriesNum++;
}
- if ((ReadVCALText(Line, "X-IRMC-LUID", Buff, ToDoVer == Mozilla_VToDo))) {
+ if ((ReadVCALText(Line, "X-IRMC-LUID", Buff, ToDoVer == Mozilla_VToDo, NULL))) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_LUID;
CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text, Buff);
ToDo->EntriesNum++;
}
- if ((ReadVCALText(Line, "CLASS", Buff, ToDoVer == Mozilla_VToDo))) {
+ if ((ReadVCALText(Line, "CLASS", Buff, ToDoVer == Mozilla_VToDo, NULL))) {
ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_PRIVATE;
if (mywstrncasecmp(Buff, "\0P\0U\0B\0L\0I\0C\0", 0)) {
ToDo->Entries[ToDo->EntriesNum].Number = 0;
@@ -2089,7 +2041,7 @@ GSM_Error GSM_DecodeVNOTE(char *Buffer, size_t *Pos, GSM_NoteEntry *Note)
if (UnicodeLength(Note->Text) == 0) return ERR_EMPTY;
return ERR_NONE;
}
- if (ReadVCALText(Line, "BODY", Buff, FALSE)) {
+ if (ReadVCALText(Line, "BODY", Buff, FALSE, NULL)) {
CopyUnicodeString(Note->Text, Buff);
empty = FALSE;
}
diff --git a/libgammu/service/gsmdata.c b/libgammu/service/gsmdata.c
index c5a7510..8546895 100644
--- a/libgammu/service/gsmdata.c
+++ b/libgammu/service/gsmdata.c
@@ -134,29 +134,9 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, size_t *Length, GS
/* PPP_AUTHSECRET (password) */
AddWAPSMSParameterText(Buffer, Length, 0x24, DecodeUnicodeString(settings->Password), UnicodeLength(settings->Password));
break;
-#ifdef DEVELOP
- case WAPSETTINGS_BEARER_SMS:
- /* Bearer */
- AddWAPSMSParameterInt(Buffer, Length, 0x12, 0x41);
- /* PROXY */
- AddWAPSMSParameterText(Buffer, Length, 0x13, DecodeUnicodeString(settings->Server), UnicodeLength(settings->Server));
- /* SMS_SMSC_ADDRESS */
- /* ..... */
- break;
- case WAPSETTINGS_BEARER_USSD:
- /* FIXME */
- /* Bearer */
- AddWAPSMSParameterInt(Buffer, Length, 0x12, 0x41);
- /* PROXY */
- AddWAPSMSParameterText(Buffer, Length, 0x13, DecodeUnicodeString(settings->Service), UnicodeLength(settings->Service));
- /* USSD_SERVICE_CODE */
- /* FIXME */
- AddWAPSMSParameterText(Buffer, Length, 0x13, DecodeUnicodeString(settings->Code), UnicodeLength(settings->Code));
-#else
case WAPSETTINGS_BEARER_SMS:
case WAPSETTINGS_BEARER_USSD:
break;
-#endif
}
/* PORT */
if (settings->IsSecurity) {
diff --git a/libgammu/service/gsmmisc.c b/libgammu/service/gsmmisc.c
index 0f9ea5f..0bc7a6a 100644
--- a/libgammu/service/gsmmisc.c
+++ b/libgammu/service/gsmmisc.c
@@ -337,11 +337,11 @@ gboolean ReadVCALDate(char *Buffer, const char *Start, GSM_DateTime *Date, gbool
char fullstart[200];
unsigned char datestring[200];
- if (!ReadVCALText(Buffer, Start, datestring, FALSE)) {
+ if (!ReadVCALText(Buffer, Start, datestring, FALSE, NULL)) {
fullstart[0] = 0;
strcat(fullstart, Start);
strcat(fullstart, ";VALUE=DATE");
- if (!ReadVCALText(Buffer, fullstart, datestring, FALSE)) {
+ if (!ReadVCALText(Buffer, fullstart, datestring, FALSE, NULL)) {
return FALSE;
}
*is_date_only = TRUE;
@@ -458,9 +458,14 @@ unsigned char *VCALGetTextPart(unsigned char *Buff, int *pos)
* We separate matching text (Start) to tokens and then try to find all
* tokens in Buffer. We also accept tokens like PREF, CHARSET or ENCODING.
*
+ * Also it parses TYPE=* tokens, matching it to text types passed in Start
+ * parameter. For example Start "TEL;FAX;VOICE" matches "TEL;TYPE=FAX,VOICE"
+ * or "TEL;FAX;TYPE=VOICE" or "TEL;TYPE=FAX;TYPE=VOICE" and of course
+ * "TEL;FAX;VOICE".
+ *
* When all tokens are matched we found matching line.
*/
-gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, const gboolean UTF8)
+gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, const gboolean UTF8, GSM_EntryLocation *location)
{
char *line = NULL;
char **tokens = NULL;
@@ -520,13 +525,17 @@ gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, con
pos += len;
/* No need to check this token anymore */
tokens[0][0] = 0;
+ /* Initialize location */
+ if (location != NULL) {
+ *location = PBK_Location_Unknown;
+ }
/* Check remaining tokens */
while (*pos != ':') {
if (*pos == ';') {
pos++;
} else {
- dbgprintf(NULL, "Could not parse!\n");
+ dbgprintf(NULL, "Could not parse! (stopped at string: %s)\n", pos);
goto fail;
}
found = FALSE;
@@ -593,14 +602,83 @@ gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, con
}
pos = end;
found = TRUE;
- } else if (strncasecmp(pos, "TYPE=PREF", 9) == 0) {
+ } else if (strncasecmp(pos, "TYPE=", 5) == 0) {
+ /* We ignore TYPE= prefix */
+ pos += 5;
+
+ /* Now process types, which should be comma separated */
+ while (*pos != ':' && *pos != ';') {
+ found = FALSE;
+
+ /* Go through tokens to match */
+ for (token = 0; token < numtokens; token++) {
+ len = strlen(tokens[token]);
+ /* Skip already matched tokens */
+ if (len == 0) {
+ continue;
+ }
+ if (strncasecmp(pos, tokens[token], len) == 0) {
+ dbgprintf(NULL, "Found %s\n", tokens[token]);
+ /* Advance position */
+ pos += len;
+ /* We need to check one token less */
+ tokens[token][0] = 0;
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ if (strncasecmp(pos, "PREF", 4) == 0) {
+ /* We ignore pref token */
+ pos += 4;
+ found = TRUE;
+ } else if (strncasecmp(pos, "WORK", 4) == 0) {
+ /* We ignore work token */
+ pos += 4;
+ found = TRUE;
+ if (location != NULL) {
+ *location = PBK_Location_Work;
+ }
+ } else if (strncasecmp(pos, "HOME", 4) == 0) {
+ /* We ignore home token */
+ pos += 4;
+ found = TRUE;
+ if (location != NULL) {
+ *location = PBK_Location_Home;
+ }
+ } else {
+ dbgprintf(NULL, "%s not found! (%s)\n", Start, pos);
+ goto fail;
+ }
+ }
+
+ if (*pos == ';' || *pos == ':') {
+ dbgprintf(NULL, "End of TYPE= string\n");
+ break;
+ } else if (*pos == ',') {
+ /* Advance past separator */
+ pos++;
+ } else {
+ dbgprintf(NULL, "Could not parse TYPE=! (stopped at string: %s)\n", pos);
+ goto fail;
+ }
+
+ }
+ } else if (strncasecmp(pos, "PREF", 4) == 0) {
+ /* We ignore pref token */
+ pos += 4;
+ found = TRUE;
+ } else if (location && strncasecmp(pos, "WORK", 4) == 0) {
/* We ignore pref token */
- pos += 9;
+ pos += 4;
found = TRUE;
- } else if (strncasecmp(pos, "PREF", 4) == 0) {
+ *location = PBK_Location_Work;
+ } else if (location && strncasecmp(pos, "HOME", 4) == 0) {
/* We ignore pref token */
pos += 4;
found = TRUE;
+ *location = PBK_Location_Home;
}
if (!found) {
dbgprintf(NULL, "%s not found!\n", Start);
diff --git a/libgammu/service/gsmmisc.h b/libgammu/service/gsmmisc.h
index 2b560ab..2f9a621 100644
--- a/libgammu/service/gsmmisc.h
+++ b/libgammu/service/gsmmisc.h
@@ -5,6 +5,7 @@
#include <gammu-file.h>
#include <gammu-info.h>
+#include <gammu-memory.h>
/**
* Resets all members of GSM_BatteryCharge structure.
@@ -54,7 +55,7 @@ GSM_Error VC_StoreText(char *Buffer, const size_t buff_len, size_t *Length, cons
* \param Value Storage for value.
* \param UTF8 Whether string should be treated as utf-8.
*/
-gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, const gboolean UTF8);
+gboolean ReadVCALText(char *Buffer, const char *Start, unsigned char *Value, const gboolean UTF8, GSM_EntryLocation *location);
gboolean ReadVCALInt(char *Buffer, const char *Start, int *Value);
diff --git a/libgammu/service/gsmpbk.c b/libgammu/service/gsmpbk.c
index d4f4668..38ed6fa 100644
--- a/libgammu/service/gsmpbk.c
+++ b/libgammu/service/gsmpbk.c
@@ -683,6 +683,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
int version = 1;
GSM_Error error;
char *Line = NULL;
+ GSM_EntryLocation location;
Buff[0] = 0;
Pbk->EntriesNum = 0;
@@ -710,7 +711,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
version = atoi(Line + 8);
dbgprintf(di, "vCard version %d\n", version);
}
- if (ReadVCALText(Line, "N", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "N", Buff, (version >= 3), NULL)) {
pos = 0;
s = VCALGetTextPart(Buff, &pos);
if (s == NULL) {
@@ -767,262 +768,120 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
continue;
}
- if (ReadVCALText(Line, "TEL", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=MAIN", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=VOICE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;VOICE", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;MAIN", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "TEL;VIDEO", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=VIDEO", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL;VIDEO", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Video;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "TEL;CELL", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;CELL;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL,VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;VOICE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL;CELL", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;CELL;VOICE", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "TEL;CELL;WORK", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;CELL;WORK;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=WORK", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=WORK;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=WORK;VOICE", Buff, (version >= 3))) {
- if (Buff[1] == '+') {
- GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
- }
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
- Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
- Pbk->EntriesNum++;
- continue;
- }
- if (ReadVCALText(Line, "TEL;CELL;HOME", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;CELL;HOME;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=HOME", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=HOME;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=CELL;TYPE=HOME;VOICE", Buff, (version >= 3))) {
- if (Buff[1] == '+') {
- GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
- }
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
- Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
- Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
- Pbk->EntriesNum++;
- continue;
- }
- if (ReadVCALText(Line, "TEL;WORK", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=WORK", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;WORK;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=WORK;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=WORK;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=WORK,VOICE", Buff, (version >= 3))) {
- if (Buff[1] == '+') {
- GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
- }
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
- Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
- Pbk->EntriesNum++;
- continue;
- }
- if (ReadVCALText(Line, "TEL;OTHER", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=OTHER", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;OTHER;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=OTHER;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=OTHER;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=OTHER,VOICE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL;OTHER", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;OTHER;VOICE", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Other;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "TEL;PAGER", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=PAGER", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;PAGER;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=PAGER;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=PAGER;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=PAGER,VOICE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL;PAGER", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;PAGER;VOICE", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Other;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "TEL;MSG", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=MSG", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;MSG;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=MSG;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=MSG;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=MSG,VOICE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL;MSG", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;MSG;VOICE", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Other;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
/* FAX + VOICE looks like nonsense */
- if (ReadVCALText(Line, "TEL;FAX", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=FAX", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;FAX;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=FAX;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=FAX;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=FAX,VOICE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TEL;FAX", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "TEL;FAX;VOICE", Buff, (version >= 3), &location)) {
if (Buff[1] == '+') {
GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
}
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Fax;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "TEL;HOME", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=HOME", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;HOME;VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=HOME,VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=HOME;TYPE=VOICE", Buff, (version >= 3)) ||
- ReadVCALText(Line, "TEL;TYPE=HOME;VOICE", Buff, (version >= 3))) {
- if (Buff[1] == '+') {
- GSM_TweakInternationalNumber(Buff, NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN);
- }
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
- Pbk->Entries[Pbk->EntriesNum].SMSList[0] = 0;
- Pbk->Entries[Pbk->EntriesNum].VoiceTag = 0;
- Pbk->EntriesNum++;
- continue;
- }
- if (ReadVCALText(Line, "TITLE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "TITLE", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_JobTitle;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "NOTE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "NOTE", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Note;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "LABEL", Buff, (version >= 3)) ||
- ReadVCALText(Line, "ADR", Buff, (version >= 3))) {
- pos = 0;
- s = VCALGetTextPart(Buff, &pos); /* PO box, ignore for now */
- if (s == NULL) {
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
- Pbk->EntriesNum++;
- continue;
- } else {
- s = VCALGetTextPart(Buff, &pos); /* Don't know ... */
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_StreetAddress;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_City;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_State;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Zip;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Country;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
- Pbk->EntriesNum++;
- continue;
- }
- }
- if (ReadVCALText(Line, "ADR;HOME", Buff, (version >= 3)) ||
- ReadVCALText(Line, "ADR;TYPE=HOME", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "LABEL", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "ADR", Buff, (version >= 3), &location)) {
pos = 0;
s = VCALGetTextPart(Buff, &pos); /* PO box, ignore for now */
if (s == NULL) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
} else {
@@ -1032,7 +891,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
if (s == NULL) continue;
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_StreetAddress;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
CHECK_NUM_ENTRIES;
@@ -1040,7 +899,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
if (s == NULL) continue;
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_City;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
CHECK_NUM_ENTRIES;
@@ -1048,7 +907,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
if (s == NULL) continue;
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_State;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
CHECK_NUM_ENTRIES;
@@ -1056,7 +915,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
if (s == NULL) continue;
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Zip;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
CHECK_NUM_ENTRIES;
@@ -1064,175 +923,120 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
if (s == NULL) continue;
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Country;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Home;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
}
- if (ReadVCALText(Line, "ADR;WORK", Buff, (version >= 3)) ||
- ReadVCALText(Line, "ADR;TYPE=WORK", Buff, (version >= 3))) {
- pos = 0;
- s = VCALGetTextPart(Buff, &pos); /* PO box, ignore for now */
- if (s == NULL) {
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->EntriesNum++;
- continue;
- } else {
- s = VCALGetTextPart(Buff, &pos); /* Don't know ... */
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_StreetAddress;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_City;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_State;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Zip;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->EntriesNum++;
- CHECK_NUM_ENTRIES;
-
- s = VCALGetTextPart(Buff, &pos);
- if (s == NULL) continue;
- CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text, s);
- Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Country;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Work;
- Pbk->EntriesNum++;
- continue;
- }
- }
- if (ReadVCALText(Line, "EMAIL", Buff, (version >= 3)) ||
- ReadVCALText(Line, "EMAIL;TYPE=OTHER", Buff, (version >= 3)) ||
- ReadVCALText(Line, "EMAIL;TYPE=INTERNET", Buff, (version >= 3)) ||
- ReadVCALText(Line, "EMAIL;INTERNET", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "EMAIL", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "EMAIL;OTHER", Buff, (version >= 3), &location) ||
+ ReadVCALText(Line, "EMAIL;INTERNET", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Email;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-IRMC-LUID", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-IRMC-LUID", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_LUID;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-DTMF", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-DTMF", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_DTMF;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-SIP", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-SIP", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_SIP;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-SIP;VOIP", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-SIP;VOIP", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_VOIP;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-WV-ID", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-WV-ID", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_WVID;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-SIP;SWIS", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-SIP;SWIS", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_SWIS;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-SIP;POC", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-SIP;POC", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_PushToTalkID;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "URL", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "URL", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_URL;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "ORG", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "ORG", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Company;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "NICKNAME", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "NICKNAME", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_NickName;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "FN", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "FN", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_FormalName;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-NAME-PREFIX", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-NAME-PREFIX", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_NamePrefix;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-NAME-SUFFIX", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-NAME-SUFFIX", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_NameSuffix;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "CATEGORIES", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "CATEGORIES", Buff, (version >= 3), &location)) {
CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
Pbk->Entries[Pbk->EntriesNum].Number = -1;
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Category;
- Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
+ Pbk->Entries[Pbk->EntriesNum].Location = location;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "BDAY", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "BDAY", Buff, (version >= 3), NULL)) {
if (ReadVCALDateTime(DecodeUnicodeString(Buff), &Pbk->Entries[Pbk->EntriesNum].Date)) {
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Date;
Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
@@ -1240,7 +1044,7 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
continue;
}
}
- if (ReadVCALText(Line, "LAST-MODIFIED", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "LAST-MODIFIED", Buff, (version >= 3), NULL)) {
if (ReadVCALDateTime(DecodeUnicodeString(Buff), &Pbk->Entries[Pbk->EntriesNum].Date)) {
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_LastModified;
Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
@@ -1248,24 +1052,24 @@ GSM_Error GSM_DecodeVCARD(GSM_Debug_Info *di, char *Buffer, size_t *Pos, GSM_Mem
continue;
}
}
- if (ReadVCALText(Line, "X-PRIVATE", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-PRIVATE", Buff, (version >= 3), NULL)) {
Pbk->Entries[Pbk->EntriesNum].Number = atoi(DecodeUnicodeString(Buff));
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Private;
Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-CALLER-GROUP", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-CALLER-GROUP", Buff, (version >= 3), NULL)) {
Pbk->Entries[Pbk->EntriesNum].Number = atoi(DecodeUnicodeString(Buff));
Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Caller_Group;
Pbk->Entries[Pbk->EntriesNum].Location = PBK_Location_Unknown;
Pbk->EntriesNum++;
continue;
}
- if (ReadVCALText(Line, "X-GAMMU-LOCATION", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-GAMMU-LOCATION", Buff, (version >= 3), NULL)) {
Pbk->Location = atoi(DecodeUnicodeString(Buff));
}
- if (ReadVCALText(Line, "X-GAMMU-MEMORY", Buff, (version >= 3))) {
+ if (ReadVCALText(Line, "X-GAMMU-MEMORY", Buff, (version >= 3), NULL)) {
Pbk->MemoryType = GSM_StringToMemoryType(DecodeUnicodeString(Buff));
}
break;
diff --git a/libgammu/service/sms/gsmsms.c b/libgammu/service/sms/gsmsms.c
index d4f436a..68c2514 100644
--- a/libgammu/service/sms/gsmsms.c
+++ b/libgammu/service/sms/gsmsms.c
@@ -89,7 +89,11 @@ static GSM_UDHHeader UDHHeaders[] = {
static GSM_Error GSM_DecodeSMSDateTime(GSM_Debug_Info *di, GSM_DateTime *DT, const unsigned char *req)
{
DT->Year = DecodeWithBCDAlphabet(req[0]);
- if (DT->Year<90) DT->Year=DT->Year+2000; else DT->Year=DT->Year+1990;
+ if (DT->Year < 90) {
+ DT->Year = DT->Year + 2000;
+ } else {
+ DT->Year = DT->Year + 1990;
+ }
DT->Month = DecodeWithBCDAlphabet(req[1]);
DT->Day = DecodeWithBCDAlphabet(req[2]);
DT->Hour = DecodeWithBCDAlphabet(req[3]);
@@ -97,9 +101,11 @@ static GSM_Error GSM_DecodeSMSDateTime(GSM_Debug_Info *di, GSM_DateTime *DT, con
DT->Second = DecodeWithBCDAlphabet(req[5]);
/* Base for timezone is GMT. It's in quarters */
- DT->Timezone=(10*(req[6]&0x07)+(req[6]>>4))*3600/4;
+ DT->Timezone = (10 * (req[6] & 0x07) + (req[6] >> 4)) *3600 / 4;
- if (req[6]&0x08) DT->Timezone = -DT->Timezone;
+ if (req[6] & 0x08) {
+ DT->Timezone = -DT->Timezone;
+ }
if (!CheckDate(DT) || !CheckTime(DT)) {
smfprintf(di, "Invalid date & time!\n");
@@ -130,24 +136,40 @@ void GSM_DecodeUDHHeader(GSM_Debug_Info *di, GSM_UDHHeader *UDH)
/* if length is the same */
if (tmp==UDH->Text[0]) {
- if (tmp==0x05) tmp=tmp-3;/*three last bytes can be different for such UDH*/
- if (tmp==0x0b) tmp=tmp-3;/*three last bytes can be different for such UDH*/
- if (tmp==0x06 && UDH->Text[1] == 0x08) tmp=tmp-4;
+ if (tmp == 0x05) {
+ /* three last bytes can be different for such UDH */
+ tmp = tmp - 3;
+ }
+ if (tmp == 0x0b) {
+ /* three last bytes can be different for such UDH */
+ tmp = tmp - 3;
+ }
+ if (tmp == 0x06 && UDH->Text[1] == 0x08) {
+ tmp=tmp-4;
+ }
- UDHOK=TRUE;
- for (w=0;w<tmp;w++) {
- if (UDHHeaders[i].Text[w]!=UDH->Text[w+1]) {
- UDHOK=FALSE;
+ UDHOK = TRUE;
+ for (w = 0; w < tmp; w++) {
+ if (UDHHeaders[i].Text[w] != UDH->Text[w + 1]) {
+ UDHOK = FALSE;
break;
}
}
if (UDHOK) {
UDH->Type=UDHHeaders[i].Type;
- if (UDHHeaders[i].ID8bit !=-1) UDH->ID8bit = UDH->Text[UDHHeaders[i].ID8bit+1];
- if (UDHHeaders[i].ID16bit !=-1) UDH->ID16bit = UDH->Text[UDHHeaders[i].ID16bit+1]*256+UDH->Text[UDHHeaders[i].ID16bit+2];
- if (UDHHeaders[i].PartNumber !=-1) UDH->PartNumber = UDH->Text[UDHHeaders[i].PartNumber+1];
- if (UDHHeaders[i].AllParts !=-1) UDH->AllParts = UDH->Text[UDHHeaders[i].AllParts+1];
+ if (UDHHeaders[i].ID8bit !=-1) {
+ UDH->ID8bit = UDH->Text[UDHHeaders[i].ID8bit+1];
+ }
+ if (UDHHeaders[i].ID16bit !=-1) {
+ UDH->ID16bit = UDH->Text[UDHHeaders[i].ID16bit+1]*256+UDH->Text[UDHHeaders[i].ID16bit+2];
+ }
+ if (UDHHeaders[i].PartNumber !=-1) {
+ UDH->PartNumber = UDH->Text[UDHHeaders[i].PartNumber+1];
+ }
+ if (UDHHeaders[i].AllParts !=-1) {
+ UDH->AllParts = UDH->Text[UDHHeaders[i].AllParts+1];
+ }
break;
}
}
@@ -156,31 +178,78 @@ void GSM_DecodeUDHHeader(GSM_Debug_Info *di, GSM_UDHHeader *UDH)
#ifdef DEBUG
smfprintf(di, "Type of UDH: ");
switch (UDH->Type) {
- case UDH_ConcatenatedMessages : smfprintf(di, "Concatenated (linked) message"); break;
- case UDH_ConcatenatedMessages16bit : smfprintf(di, "Concatenated (linked) message"); break;
- case UDH_DisableVoice : smfprintf(di, "Disables voice indicator"); break;
- case UDH_EnableVoice : smfprintf(di, "Enables voice indicator"); break;
- case UDH_DisableFax : smfprintf(di, "Disables fax indicator"); break;
- case UDH_EnableFax : smfprintf(di, "Enables fax indicator"); break;
- case UDH_DisableEmail : smfprintf(di, "Disables email indicator"); break;
- case UDH_EnableEmail : smfprintf(di, "Enables email indicator"); break;
- case UDH_VoidSMS : smfprintf(di, "Void SMS"); break;
- case UDH_NokiaWAP : smfprintf(di, "Nokia WAP Bookmark"); break;
- case UDH_NokiaOperatorLogoLong : smfprintf(di, "Nokia operator logo"); break;
- case UDH_NokiaWAPLong : smfprintf(di, "Nokia WAP Bookmark or WAP/MMS Settings"); break;
- case UDH_NokiaRingtone : smfprintf(di, "Nokia ringtone"); break;
- case UDH_NokiaRingtoneLong : smfprintf(di, "Nokia ringtone"); break;
- case UDH_NokiaOperatorLogo : smfprintf(di, "Nokia GSM operator logo"); break;
- case UDH_NokiaCallerLogo : smfprintf(di, "Nokia caller logo"); break;
- case UDH_NokiaProfileLong : smfprintf(di, "Nokia profile"); break;
- case UDH_NokiaCalendarLong : smfprintf(di, "Nokia calendar note"); break;
- case UDH_NokiaPhonebookLong : smfprintf(di, "Nokia phonebook entry"); break;
- case UDH_UserUDH : smfprintf(di, "User UDH"); break;
- case UDH_MMSIndicatorLong : smfprintf(di, "MMS indicator"); break;
- case UDH_NoUDH: break;
+ case UDH_ConcatenatedMessages:
+ smfprintf(di, "Concatenated (linked) message");
+ break;
+ case UDH_ConcatenatedMessages16bit:
+ smfprintf(di, "Concatenated (linked) message");
+ break;
+ case UDH_DisableVoice:
+ smfprintf(di, "Disables voice indicator");
+ break;
+ case UDH_EnableVoice:
+ smfprintf(di, "Enables voice indicator");
+ break;
+ case UDH_DisableFax:
+ smfprintf(di, "Disables fax indicator");
+ break;
+ case UDH_EnableFax:
+ smfprintf(di, "Enables fax indicator");
+ break;
+ case UDH_DisableEmail:
+ smfprintf(di, "Disables email indicator");
+ break;
+ case UDH_EnableEmail:
+ smfprintf(di, "Enables email indicator");
+ break;
+ case UDH_VoidSMS:
+ smfprintf(di, "Void SMS");
+ break;
+ case UDH_NokiaWAP:
+ smfprintf(di, "Nokia WAP Bookmark");
+ break;
+ case UDH_NokiaOperatorLogoLong:
+ smfprintf(di, "Nokia operator logo");
+ break;
+ case UDH_NokiaWAPLong:
+ smfprintf(di, "Nokia WAP Bookmark or WAP/MMS Settings");
+ break;
+ case UDH_NokiaRingtone:
+ smfprintf(di, "Nokia ringtone");
+ break;
+ case UDH_NokiaRingtoneLong:
+ smfprintf(di, "Nokia ringtone");
+ break;
+ case UDH_NokiaOperatorLogo:
+ smfprintf(di, "Nokia GSM operator logo");
+ break;
+ case UDH_NokiaCallerLogo:
+ smfprintf(di, "Nokia caller logo");
+ break;
+ case UDH_NokiaProfileLong:
+ smfprintf(di, "Nokia profile");
+ break;
+ case UDH_NokiaCalendarLong:
+ smfprintf(di, "Nokia calendar note");
+ break;
+ case UDH_NokiaPhonebookLong:
+ smfprintf(di, "Nokia phonebook entry");
+ break;
+ case UDH_UserUDH:
+ smfprintf(di, "User UDH");
+ break;
+ case UDH_MMSIndicatorLong:
+ smfprintf(di, "MMS indicator");
+ break;
+ case UDH_NoUDH:
+ break;
+ }
+ if (UDH->ID8bit != -1) {
+ smfprintf(di, ", ID 8 bit %i", UDH->ID8bit);
+ }
+ if (UDH->ID16bit != -1) {
+ smfprintf(di, ", ID 16 bit %i", UDH->ID16bit);
}
- if (UDH->ID8bit != -1) smfprintf(di, ", ID 8 bit %i",UDH->ID8bit);
- if (UDH->ID16bit != -1) smfprintf(di, ", ID 16 bit %i",UDH->ID16bit);
if (UDH->PartNumber != -1 && UDH->AllParts != -1) {
smfprintf(di, ", part %i of %i",UDH->PartNumber,UDH->AllParts);
}
@@ -197,11 +266,21 @@ GSM_Coding_Type GSM_GetMessageCoding(GSM_Debug_Info *di, const char TPDCS) {
if ((TPDCS & 0xC) == 0xC) {
smfprintf(di, "WARNING: reserved alphabet value in TPDCS\n");
} else {
- if (TPDCS == 0) return SMS_Coding_Default_No_Compression;
- if ((TPDCS & 0x2C) == 0x00) return SMS_Coding_Default_No_Compression;
- if ((TPDCS & 0x2C) == 0x20) return SMS_Coding_Default_Compression;
- if ((TPDCS & 0x2C) == 0x08) return SMS_Coding_Unicode_No_Compression;
- if ((TPDCS & 0x2C) == 0x28) return SMS_Coding_Unicode_Compression;
+ if (TPDCS == 0) {
+ return SMS_Coding_Default_No_Compression;
+ }
+ if ((TPDCS & 0x2C) == 0x00) {
+ return SMS_Coding_Default_No_Compression;
+ }
+ if ((TPDCS & 0x2C) == 0x20) {
+ return SMS_Coding_Default_Compression;
+ }
+ if ((TPDCS & 0x2C) == 0x08) {
+ return SMS_Coding_Unicode_No_Compression;
+ }
+ if ((TPDCS & 0x2C) == 0x28) {
+ return SMS_Coding_Unicode_Compression;
+ }
}
} else if ((TPDCS & 0xF0) >= 0x40 &&
(TPDCS & 0xF0) <= 0xB0) {
@@ -335,32 +414,84 @@ GSM_Error GSM_DecodeSMSStatusReportData(GSM_Debug_Info *di, GSM_SMSMessage *SMS,
smfprintf(di, "Temporary error, SC still trying to transfer SM\n");
}
switch (TP_ST) {
- case 0x00: smfprintf(di, "SM received by the SME"); break;
- case 0x01: smfprintf(di, "SM forwarded by the SC to the SME but the SC is unable to confirm delivery");break;
- case 0x02: smfprintf(di, "SM replaced by the SC"); break;
- case 0x20: smfprintf(di, "Congestion"); break;
- case 0x21: smfprintf(di, "SME busy"); break;
- case 0x22: smfprintf(di, "No response from SME"); break;
- case 0x23: smfprintf(di, "Service rejected"); break;
- case 0x24: smfprintf(di, "Quality of service not available"); break;
- case 0x25: smfprintf(di, "Error in SME"); break;
- case 0x40: smfprintf(di, "Remote procedure error"); break;
- case 0x41: smfprintf(di, "Incompatibile destination"); break;
- case 0x42: smfprintf(di, "Connection rejected by SME"); break;
- case 0x43: smfprintf(di, "Not obtainable"); break;
- case 0x44: smfprintf(di, "Quality of service not available"); break;
- case 0x45: smfprintf(di, "No internetworking available"); break;
- case 0x46: smfprintf(di, "SM Validity Period Expired"); break;
- case 0x47: smfprintf(di, "SM deleted by originating SME"); break;
- case 0x48: smfprintf(di, "SM Deleted by SC Administration"); break;
- case 0x49: smfprintf(di, "SM does not exist"); break;
- case 0x60: smfprintf(di, "Congestion"); break;
- case 0x61: smfprintf(di, "SME busy"); break;
- case 0x62: smfprintf(di, "No response from SME"); break;
- case 0x63: smfprintf(di, "Service rejected"); break;
- case 0x64: smfprintf(di, "Quality of service not available"); break;
- case 0x65: smfprintf(di, "Error in SME"); break;
- default : smfprintf(di, "Reserved/Specific to SC: %x",TP_ST); break;
+ case 0x00:
+ smfprintf(di, "SM received by the SME");
+ break;
+ case 0x01:
+ smfprintf(di, "SM forwarded by the SC to the SME but the SC is unable to confirm delivery");
+ break;
+ case 0x02:
+ smfprintf(di, "SM replaced by the SC");
+ break;
+ case 0x20:
+ smfprintf(di, "Congestion");
+ break;
+ case 0x21:
+ smfprintf(di, "SME busy");
+ break;
+ case 0x22:
+ smfprintf(di, "No response from SME");
+ break;
+ case 0x23:
+ smfprintf(di, "Service rejected");
+ break;
+ case 0x24:
+ smfprintf(di, "Quality of service not available");
+ break;
+ case 0x25:
+ smfprintf(di, "Error in SME");
+ break;
+ case 0x40:
+ smfprintf(di, "Remote procedure error");
+ break;
+ case 0x41:
+ smfprintf(di, "Incompatibile destination");
+ break;
+ case 0x42:
+ smfprintf(di, "Connection rejected by SME");
+ break;
+ case 0x43:
+ smfprintf(di, "Not obtainable");
+ break;
+ case 0x44:
+ smfprintf(di, "Quality of service not available");
+ break;
+ case 0x45:
+ smfprintf(di, "No internetworking available");
+ break;
+ case 0x46:
+ smfprintf(di, "SM Validity Period Expired");
+ break;
+ case 0x47:
+ smfprintf(di, "SM deleted by originating SME");
+ break;
+ case 0x48:
+ smfprintf(di, "SM Deleted by SC Administration");
+ break;
+ case 0x49:
+ smfprintf(di, "SM does not exist");
+ break;
+ case 0x60:
+ smfprintf(di, "Congestion");
+ break;
+ case 0x61:
+ smfprintf(di, "SME busy");
+ break;
+ case 0x62:
+ smfprintf(di, "No response from SME");
+ break;
+ case 0x63:
+ smfprintf(di, "Service rejected");
+ break;
+ case 0x64:
+ smfprintf(di, "Quality of service not available");
+ break;
+ case 0x65:
+ smfprintf(di, "Error in SME");
+ break;
+ default:
+ smfprintf(di, "Reserved/Specific to SC: %x",TP_ST);
+ break;
}
smfprintf(di, "\n");
#endif
@@ -1057,14 +1188,28 @@ gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info *di, GSM_SiemensOTASMSInfo *Info
{
int current;
- if (SMS->PDU != SMS_Deliver) return FALSE;
- if (SMS->Coding != SMS_Coding_8bit) return FALSE;
- if (SMS->Class != 1) return FALSE;
- if (SMS->UDH.Type != UDH_NoUDH) return FALSE;
- if (SMS->Length < 22) return FALSE;
+ if (SMS->PDU != SMS_Deliver) {
+ return FALSE;
+ }
+ if (SMS->Coding != SMS_Coding_8bit) {
+ return FALSE;
+ }
+ if (SMS->Class != 1) {
+ return FALSE;
+ }
+ if (SMS->UDH.Type != UDH_NoUDH) {
+ return FALSE;
+ }
+ if (SMS->Length < 22) {
+ return FALSE;
+ }
- if (strncmp(SMS->Text,"//SEO",5)!=0) return FALSE; /* Siemens Exchange Object */
- if (SMS->Text[5]!=1) return FALSE; /* version 1 */
+ if (strncmp(SMS->Text, "//SEO",5) != 0) {
+ return FALSE; /* Siemens Exchange Object */
+ }
+ if (SMS->Text[5] != 1) {
+ return FALSE; /* version 1 */
+ }
Info->DataLen = SMS->Text[6] + SMS->Text[7]*256;
Info->SequenceID = SMS->Text[8] + SMS->Text[9]*256 +
SMS->Text[10]*256*256 + SMS->Text[11]*256*256*256;
@@ -1075,13 +1220,17 @@ gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info *di, GSM_SiemensOTASMSInfo *Info
SMS->Text[18]*256*256 + SMS->Text[19]*256*256*256;
smfprintf(di, "DataLen %i/%lu\n",Info->DataLen,Info->AllDataLen);
- if (SMS->Text[20] > 9) return FALSE;
+ if (SMS->Text[20] > 9) {
+ return FALSE;
+ }
memcpy(Info->DataType,SMS->Text+21,SMS->Text[20]);
Info->DataType[SMS->Text[20]] = 0;
smfprintf(di, "DataType '%s'\n",Info->DataType);
current = 21+SMS->Text[20];
- if (SMS->Text[current] > 39) return FALSE;
+ if (SMS->Text[current] > 39) {
+ return FALSE;
+ }
memcpy(Info->DataName,SMS->Text+current+1,SMS->Text[current]);
Info->DataName[SMS->Text[current]] = 0;
smfprintf(di, "DataName '%s'\n",Info->DataName);
@@ -1095,22 +1244,23 @@ gboolean GSM_DecodeSiemensOTASMS(GSM_Debug_Info *di, GSM_SiemensOTASMSInfo *Info
GSM_Coding_Type GSM_StringToSMSCoding(const char *s)
{
/* Maintain those without compression for backward compatibility */
- if (s == NULL)
+ if (s == NULL) {
return SMS_Coding_Default_No_Compression;
- else if (strcmp("Unicode", s) == 0)
+ } else if (strcmp("Unicode", s) == 0) {
return SMS_Coding_Unicode_No_Compression;
- else if (strcmp("Unicode_No_Compression", s) == 0)
+ } else if (strcmp("Unicode_No_Compression", s) == 0) {
return SMS_Coding_Unicode_No_Compression;
- else if (strcmp("Unicode_Compression", s) == 0)
+ } else if (strcmp("Unicode_Compression", s) == 0) {
return SMS_Coding_Unicode_Compression;
- else if (strcmp("Default", s) == 0)
+ } else if (strcmp("Default", s) == 0) {
return SMS_Coding_Default_No_Compression;
- else if (strcmp("Default_No_Compression", s) == 0)
+ } else if (strcmp("Default_No_Compression", s) == 0) {
return SMS_Coding_Default_No_Compression;
- else if (strcmp("Default_Compression", s) == 0)
+ } else if (strcmp("Default_Compression", s) == 0) {
return SMS_Coding_Default_Compression;
- else if (strcmp("8bit", s) == 0)
+ } else if (strcmp("8bit", s) == 0) {
return SMS_Coding_8bit;
+ }
return 0;
}