summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service/backup
Side-by-side diff
Diffstat (limited to 'gammu/emb/common/service/backup') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/backup/backgen.h4
-rw-r--r--gammu/emb/common/service/backup/backtext.c229
-rw-r--r--gammu/emb/common/service/backup/gsmback.c36
-rw-r--r--gammu/emb/common/service/backup/gsmback.h2
4 files changed, 248 insertions, 23 deletions
diff --git a/gammu/emb/common/service/backup/backgen.h b/gammu/emb/common/service/backup/backgen.h
index 9d7d973..9a930fc 100644
--- a/gammu/emb/common/service/backup/backgen.h
+++ b/gammu/emb/common/service/backup/backgen.h
@@ -23,2 +23,4 @@
#define GSM_BACKUP_MAX_MMSSETTINGS 30
+#define GSM_BACKUP_MAX_SYNCMLSETTINGS 10
+#define GSM_BACKUP_MAX_CHATSETTINGS 10
#define GSM_BACKUP_MAX_RINGTONES 30
@@ -45,2 +47,4 @@ typedef struct {
GSM_MultiWAPSettings *MMSSettings [GSM_BACKUP_MAX_MMSSETTINGS + 1];
+ GSM_SyncMLSettings *SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
+ GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
GSM_Ringtone *Ringtone [GSM_BACKUP_MAX_RINGTONES + 1];
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c
index fee0f73..4cb1bb7 100644
--- a/gammu/emb/common/service/backup/backtext.c
+++ b/gammu/emb/common/service/backup/backtext.c
@@ -153,3 +153,3 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
- fwrite(myvalue,1,UnicodeLength(myvalue)*2,file);
+ fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
@@ -159,3 +159,3 @@ static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnic
} else {
- sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10);
+ sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
fprintf(file,"%s",buffer);
@@ -170,3 +170,3 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
{
- unsigned char paramname[10000],*readvalue;
+ unsigned char paramname[10000],*readvalue;
@@ -176,5 +176,6 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
if (readvalue!=NULL) {
- CopyUnicodeString(myvalue,readvalue+2);
- myvalue[UnicodeLength(readvalue)*2-4]=0;
- myvalue[UnicodeLength(readvalue)*2-3]=0;
+ CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
+ myvalue[UnicodeLength(myvalue)*2-2]=0;
+ myvalue[UnicodeLength(myvalue)*2-1]=0;
+
dbgprintf("%s\n",DecodeUnicodeString(readvalue));
@@ -199,3 +200,3 @@ static bool ReadBackupText(INI_Section *file_info, char *section, char *myname,
if (readvalue!=NULL) {
- EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2);
+ EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
} else {
@@ -420,2 +421,13 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
+static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
+{
+ char buffer[1000];
+
+ sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveBackupText(file, "Text", Note->Text, UseUnicode);
+ sprintf(buffer, "%c%c",13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+}
+
static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
@@ -435,5 +447,5 @@ static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnico
case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
- case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
+ case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
- case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
+ case GSM_CAL_DAILY_ALARM: sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
@@ -659,2 +671,44 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
+static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"HomePage");
+ SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
+static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ sprintf(buffer,"PhonebookDB");
+ SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
+ sprintf(buffer,"CalendarDB");
+ SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
+ sprintf(buffer,"Server");
+ SaveBackupText(file, buffer, settings->Server, UseUnicode);
+ if (settings->SyncPhonebook) {
+ sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ if (settings->SyncCalendar) {
+ sprintf(buffer,"SyncCalendar = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncCalendar = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
@@ -766,4 +820,3 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
{
- unsigned char buffer[45000];
- int i,j;
+ unsigned char buffer[45000];
@@ -774,3 +827,2 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
case RING_NOKIABINARY:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
@@ -779,3 +831,2 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
case RING_MIDI:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
@@ -783,2 +834,6 @@ static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicod
break;
+ case RING_MMF:
+ EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
+ SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
+ break;
case RING_NOTETONE:
@@ -1077,2 +1132,9 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
i=0;
+ while (backup->Note[i]!=NULL) {
+ sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveNoteEntry(file, backup->Note[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->CallerLogos[i]!=NULL) {
@@ -1112,2 +1174,16 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
@@ -2658,3 +2734,128 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
}
-
+ for (h = file_info; h != NULL; h = h->Next) {
+ found = false;
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Backup",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Checksum",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Profile",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"PhonePBK",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SIMPBK",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Calendar",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Caller",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SMSC",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPBookmark",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Bookmark",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPSettings",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Settings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"MMSSettings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Ringtone",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"TODO",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Startup",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Operator",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"FMStation",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"GPRSPoint",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Note",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
+ }
+ if (!found) return ERR_NOTIMPLEMENTED;
+ }
return ERR_NONE;
diff --git a/gammu/emb/common/service/backup/gsmback.c b/gammu/emb/common/service/backup/gsmback.c
index 91ac745..c94a4d2 100644
--- a/gammu/emb/common/service/backup/gsmback.c
+++ b/gammu/emb/common/service/backup/gsmback.c
@@ -75,2 +75,14 @@ void GSM_FreeBackup(GSM_Backup *backup)
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ free(backup->SyncMLSettings[i]);
+ backup->SyncMLSettings[i] = NULL;
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ free(backup->ChatSettings[i]);
+ backup->ChatSettings[i] = NULL;
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
@@ -122,11 +134,11 @@ GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode
{
- if (strstr(FileName,".lmb")) {
+ if (mystrcasestr(FileName,".lmb")) {
return SaveLMB(FileName,backup);
- } else if (strstr(FileName,".vcs")) {
+ } else if (mystrcasestr(FileName,".vcs")) {
return SaveVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return SaveVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return SaveLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return SaveICS(FileName,backup);
@@ -150,9 +162,9 @@ GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
/* Attempt to identify filetype */
- if (strstr(FileName,".vcs")) {
+ if (mystrcasestr(FileName,".vcs")) {
return LoadVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return LoadVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return LoadLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return LoadICS(FileName,backup);
@@ -179,2 +191,4 @@ void GSM_ClearBackup(GSM_Backup *backup)
backup->MMSSettings [0] = NULL;
+ backup->SyncMLSettings [0] = NULL;
+ backup->ChatSettings [0] = NULL;
backup->Ringtone [0] = NULL;
@@ -211,2 +225,4 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
info->MMSSettings = false;
+ info->SyncMLSettings = false;
+ info->ChatSettings = false;
info->Ringtone = false;
@@ -248,2 +264,4 @@ void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
info->MMSSettings = true;
+ info->SyncMLSettings = true;
+ info->ChatSettings = true;
info->Ringtone = true;
diff --git a/gammu/emb/common/service/backup/gsmback.h b/gammu/emb/common/service/backup/gsmback.h
index 1fd99b0..791e81d 100644
--- a/gammu/emb/common/service/backup/gsmback.h
+++ b/gammu/emb/common/service/backup/gsmback.h
@@ -31,2 +31,4 @@ typedef struct {
bool MMSSettings;
+ bool SyncMLSettings;
+ bool ChatSettings;
bool Ringtone;