summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service/backup
Side-by-side diff
Diffstat (limited to 'gammu/emb/common/service/backup') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/service/backup/backgen.h4
-rw-r--r--gammu/emb/common/service/backup/backtext.c221
-rw-r--r--gammu/emb/common/service/backup/gsmback.c36
-rw-r--r--gammu/emb/common/service/backup/gsmback.h2
4 files changed, 244 insertions, 19 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
@@ -1,69 +1,73 @@
/* (c) 2002-2004 by Marcin Wiacek */
#ifndef __gsm_backgen_h
#define __gsm_backgen_h
#include "../../config.h"
#include "../../misc/misc.h"
#include "../gsmpbk.h"
#include "../gsmcal.h"
#include "../gsmlogo.h"
#include "../gsmring.h"
#include "../gsmdata.h"
#include "../gsmprof.h"
#include "../gsmmisc.h"
#include "../sms/gsmsms.h"
#define GSM_BACKUP_MAX_PHONEPHONEBOOK 501
#define GSM_BACKUP_MAX_SIMPHONEBOOK 251
#define GSM_BACKUP_MAX_CALLER 6
#define GSM_BACKUP_MAX_SMSC 10
#define GSM_BACKUP_MAX_WAPBOOKMARK 40
#define GSM_BACKUP_MAX_WAPSETTINGS 30
#define GSM_BACKUP_MAX_MMSSETTINGS 30
+#define GSM_BACKUP_MAX_SYNCMLSETTINGS 10
+#define GSM_BACKUP_MAX_CHATSETTINGS 10
#define GSM_BACKUP_MAX_RINGTONES 30
#define GSM_BACKUP_MAX_PROFILES 10
#define GSM_BACKUP_MAX_FMSTATIONS 20
#define GSM_BACKUP_MAX_GPRSPOINT 10
#define GSM_BACKUP_MAX_NOTE 10 /* FIXME */
typedef struct {
char IMEI [MAX_IMEI_LENGTH];
char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH];
char Creator [80];
GSM_DateTime DateTime;
bool DateTimeAvailable;
char MD5Original [100];
char MD5Calculated [100];
GSM_MemoryEntry *PhonePhonebook [GSM_BACKUP_MAX_PHONEPHONEBOOK + 1];
GSM_MemoryEntry *SIMPhonebook [GSM_BACKUP_MAX_SIMPHONEBOOK + 1];
GSM_CalendarEntry *Calendar [GSM_MAXCALENDARTODONOTES + 1];
GSM_Bitmap *CallerLogos [GSM_BACKUP_MAX_CALLER + 1];
GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1];
GSM_WAPBookmark *WAPBookmark [GSM_BACKUP_MAX_WAPBOOKMARK + 1];
GSM_MultiWAPSettings *WAPSettings [GSM_BACKUP_MAX_WAPSETTINGS + 1];
GSM_MultiWAPSettings *MMSSettings [GSM_BACKUP_MAX_MMSSETTINGS + 1];
+ GSM_SyncMLSettings *SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
+ GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
GSM_Ringtone *Ringtone [GSM_BACKUP_MAX_RINGTONES + 1];
GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1];
GSM_Profile *Profiles [GSM_BACKUP_MAX_PROFILES + 1];
GSM_FMStation *FMStation [GSM_BACKUP_MAX_FMSTATIONS +1];
GSM_GPRSAccessPoint *GPRSPoint [GSM_BACKUP_MAX_GPRSPOINT + 1];
GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1];
GSM_Bitmap *StartupLogo;
GSM_Bitmap *OperatorLogo;
} GSM_Backup;
#define GSM_BACKUP_MAX_SMS 500
typedef struct {
GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS];
} GSM_SMS_Backup;
extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
diff --git a/gammu/emb/common/service/backup/backtext.c b/gammu/emb/common/service/backup/backtext.c
index fee0f73..4cb1bb7 100644
--- a/gammu/emb/common/service/backup/backtext.c
+++ b/gammu/emb/common/service/backup/backtext.c
@@ -106,143 +106,144 @@ static void SaveLinkedBackupText(FILE *file, char *myname, char *myvalue, bool U
current = 0;
}
if (UseUnicode) {
sprintf(buffer3,"%s%02i = %s%c%c",myname,w,buffer2,13,10);
EncodeUnicode(buffer2,buffer3,strlen(buffer3));
fwrite(buffer2,1,strlen(buffer3)*2,file);
} else {
fprintf(file,"%s%02i = %s%c%c",myname,w,buffer2,13,10);
}
if (current == 0) break;
w++;
}
}
static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode)
{
unsigned char buffer2[300];
char *readvalue;
int i;
i=0;
myvalue[0] = 0;
while (true) {
sprintf(buffer2,"%s%02i",myname,i);
readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode);
if (readvalue!=NULL) {
myvalue[strlen(myvalue)+strlen(readvalue)]=0;
memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue));
} else break;
i++;
}
}
static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode)
{
unsigned char buffer[10000], buffer2[10000];
if (myname[0] == 0x00) {
if (UseUnicode) {
EncodeUnicode(buffer,myvalue,strlen(myvalue));
fwrite(buffer,1,strlen(myvalue)*2,file);
} else fprintf(file,"%s",myvalue);
} else {
if (UseUnicode) {
sprintf(buffer,"%s = \"",myname);
EncodeUnicode(buffer2,buffer,strlen(buffer));
fwrite(buffer2,1,strlen(buffer)*2,file);
- fwrite(myvalue,1,UnicodeLength(myvalue)*2,file);
+ fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
sprintf(buffer,"\"%c%c",13,10);
EncodeUnicode(buffer2,buffer,strlen(buffer));
fwrite(buffer2,1,strlen(buffer)*2,file);
} else {
- sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10);
+ sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
fprintf(file,"%s",buffer);
EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2);
fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10);
}
}
}
static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode)
{
unsigned char paramname[10000],*readvalue;
if (UseUnicode) {
EncodeUnicode(paramname,myname,strlen(myname));
readvalue = INI_GetValue(file_info, section, paramname, UseUnicode);
if (readvalue!=NULL) {
- CopyUnicodeString(myvalue,readvalue+2);
- myvalue[UnicodeLength(readvalue)*2-4]=0;
- myvalue[UnicodeLength(readvalue)*2-3]=0;
+ CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
+ myvalue[UnicodeLength(myvalue)*2-2]=0;
+ myvalue[UnicodeLength(myvalue)*2-1]=0;
+
dbgprintf("%s\n",DecodeUnicodeString(readvalue));
} else {
myvalue[0]=0;
myvalue[1]=0;
return false;
}
} else {
strcpy(paramname,myname);
strcat(paramname,"Unicode");
readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
if (readvalue!=NULL) {
dbgprintf("%s %i\n",readvalue,strlen(readvalue));
DecodeHexBin (myvalue, readvalue, strlen(readvalue));
myvalue[strlen(readvalue)/2]=0;
myvalue[strlen(readvalue)/2+1]=0;
dbgprintf("%s\n",DecodeUnicodeString(myvalue));
} else {
strcpy(paramname,myname);
readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
if (readvalue!=NULL) {
- EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2);
+ EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
} else {
myvalue[0]=0;
myvalue[1]=0;
return false;
}
}
}
return true;
}
static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode)
{
unsigned char buffer[100];
int Length = 3;
sprintf(buffer, " = ");
SaveVCALDateTime(buffer, &Length, dt, NULL);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode)
{
unsigned char buffer[100];
sprintf(buffer, " = %04d%02d%02d%c%c", dt->Year, dt->Month, dt->Day,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
/* ---------------------- backup files ------------------------------------- */
static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
{
bool text;
char buffer[1000];
int j, i;
sprintf(buffer,"Location = %03i%c%c",Pbk->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
for (j=0;j<Pbk->EntriesNum;j++) {
text = true;
switch (Pbk->Entries[j].EntryType) {
case PBK_Number_General:
sprintf(buffer,"Entry%02iType = NumberGeneral%c%c",j,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
break;
case PBK_Number_Mobile:
sprintf(buffer,"Entry%02iType = NumberMobile%c%c",j,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
@@ -373,96 +374,107 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
case PBK_Text_Custom2:
sprintf(buffer,"Entry%02iType = Custom2%c%c",j,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
break;
case PBK_Text_Custom3:
sprintf(buffer,"Entry%02iType = Custom3%c%c",j,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
break;
case PBK_Text_Custom4:
sprintf(buffer,"Entry%02iType = Custom4%c%c",j,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
break;
case PBK_SMSListID:
case PBK_RingtoneFileSystemID:
case PBK_Date:
break;
}
if (text) {
sprintf(buffer,"Entry%02iText",j);
SaveBackupText(file,buffer,Pbk->Entries[j].Text, UseUnicode);
}
switch (Pbk->Entries[j].EntryType) {
case PBK_Number_General:
case PBK_Number_Mobile:
case PBK_Number_Work:
case PBK_Number_Fax:
case PBK_Number_Home:
case PBK_Number_Other:
case PBK_Number_Pager:
if (Pbk->Entries[j].VoiceTag!=0) {
sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
i = 0;
while (Pbk->Entries[j].SMSList[i]!=0) {
sprintf(buffer,"Entry%02iSMSList%02i = %i%c%c",j,i,Pbk->Entries[j].SMSList[i],13,10);
SaveBackupText(file, "", buffer, UseUnicode);
i++;
}
break;
default:
break;
}
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
+static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
+{
+ char buffer[1000];
+
+ sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveBackupText(file, "Text", Note->Text, UseUnicode);
+ sprintf(buffer, "%c%c",13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+}
+
static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
{
int i;
char buffer[1000];
sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBackupText(file, "", "Type = ", UseUnicode);
switch (Note->Type) {
case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break;
case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break;
case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break;
case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break;
case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break;
case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break;
case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break;
case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break;
case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break;
case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break;
case GSM_CAL_T_FOOT : sprintf(buffer,"Training/Football%c%c", 13,10); break;
case GSM_CAL_T_GOLF : sprintf(buffer,"Training/Golf%c%c", 13,10); break;
case GSM_CAL_T_GYM : sprintf(buffer,"Training/Gym%c%c", 13,10); break;
case GSM_CAL_T_HORS : sprintf(buffer,"Training/HorseRaces%c%c", 13,10); break;
case GSM_CAL_T_HOCK : sprintf(buffer,"Training/Hockey%c%c", 13,10); break;
case GSM_CAL_T_RACE : sprintf(buffer,"Training/Races%c%c", 13,10); break;
case GSM_CAL_T_RUGB : sprintf(buffer,"Training/Rugby%c%c", 13,10); break;
case GSM_CAL_T_SAIL : sprintf(buffer,"Training/Sailing%c%c", 13,10); break;
case GSM_CAL_T_STRE : sprintf(buffer,"Training/StreetGames%c%c", 13,10); break;
case GSM_CAL_T_SWIM : sprintf(buffer,"Training/Swimming%c%c", 13,10); break;
case GSM_CAL_T_TENN : sprintf(buffer,"Training/Tennis%c%c", 13,10); break;
case GSM_CAL_T_TRAV : sprintf(buffer,"Training/Travels%c%c", 13,10); break;
case GSM_CAL_T_WINT : sprintf(buffer,"Training/WinterGames%c%c", 13,10); break;
}
SaveBackupText(file, "", buffer, UseUnicode);
for (i=0;i<Note->EntriesNum;i++) {
switch (Note->Entries[i].EntryType) {
case CAL_START_DATETIME:
SaveBackupText(file, "", "StartTime", UseUnicode);
SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode);
break;
case CAL_END_DATETIME:
SaveBackupText(file, "", "StopTime", UseUnicode);
SaveVCalDateTime(file, &Note->Entries[i].Date, UseUnicode);
@@ -612,96 +624,138 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
SaveBackupText(file, buffer, settings->Settings[i].DialUp, UseUnicode);
if (settings->Settings[i].ManualLogin) {
sprintf(buffer,"Login%02i = Manual%c%c",i,13,10);
} else {
sprintf(buffer,"Login%02i = Automatic%c%c",i,13,10);
}
SaveBackupText(file, "", buffer, UseUnicode);
if (settings->Settings[i].IsNormalAuthentication) {
sprintf(buffer,"Authentication%02i = Normal%c%c",i,13,10);
} else {
sprintf(buffer,"Authentication%02i = Secure%c%c",i,13,10);
}
SaveBackupText(file, "", buffer, UseUnicode);
switch (settings->Settings[i].Speed) {
case WAPSETTINGS_SPEED_9600 : sprintf(buffer,"CallSpeed%02i = 9600%c%c" ,i,13,10); break;
case WAPSETTINGS_SPEED_14400: sprintf(buffer,"CallSpeed%02i = 14400%c%c",i,13,10); break;
case WAPSETTINGS_SPEED_AUTO : sprintf(buffer,"CallSpeed%02i = auto%c%c" ,i,13,10); break;
}
switch (settings->Settings[i].Speed) {
case WAPSETTINGS_SPEED_9600 :
case WAPSETTINGS_SPEED_14400:
case WAPSETTINGS_SPEED_AUTO :
SaveBackupText(file, "", buffer, UseUnicode);
default:
break;
}
sprintf(buffer,"User%02i",i);
SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode);
sprintf(buffer,"Password%02i",i);
SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode);
break;
case WAPSETTINGS_BEARER_USSD:
sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"ServiceCode%02i",i);
SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode);
if (settings->Settings[i].IsIP) {
sprintf(buffer,"IP%02i",i);
} else {
sprintf(buffer,"Number%02i",i);
}
SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode);
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
}
+static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"HomePage");
+ SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
+static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
+{
+ char buffer[10000];
+
+ sprintf(buffer,"User");
+ SaveBackupText(file, buffer, settings->User, UseUnicode);
+ sprintf(buffer,"Password");
+ SaveBackupText(file, buffer, settings->Password, UseUnicode);
+ sprintf(buffer,"PhonebookDB");
+ SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
+ sprintf(buffer,"CalendarDB");
+ SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
+ sprintf(buffer,"Server");
+ SaveBackupText(file, buffer, settings->Server, UseUnicode);
+ if (settings->SyncPhonebook) {
+ sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ if (settings->SyncCalendar) {
+ sprintf(buffer,"SyncCalendar = True%c%c",13,10);
+ } else {
+ sprintf(buffer,"SyncCalendar = False%c%c",13,10);
+ }
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
+}
+
static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
{
unsigned char buffer[10000],buffer2[10000];
int x,y;
sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
for (y=0;y<bitmap->BitmapHeight;y++) {
for (x=0;x<bitmap->BitmapWidth;x++) {
buffer[x] = ' ';
if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#';
}
buffer[bitmap->BitmapWidth] = 0;
sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10);
SaveBackupText(file, "", buffer2, UseUnicode);
}
}
static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
{
unsigned char buffer[1000];
sprintf(buffer,"Location = %03i%c%c",bitmap->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
if (!bitmap->DefaultName) SaveBackupText(file, "Name", bitmap->Text, UseUnicode);
if (!bitmap->DefaultRingtone) {
if (bitmap->FileSystemRingtone) {
sprintf(buffer,"FileRingtone = %02x%c%c",bitmap->RingtoneID,13,10);
} else {
sprintf(buffer,"Ringtone = %02x%c%c",bitmap->RingtoneID,13,10);
}
SaveBackupText(file, "", buffer, UseUnicode);
}
if (bitmap->BitmapEnabled) {
sprintf(buffer,"Enabled = True%c%c",13,10);
} else {
sprintf(buffer,"Enabled = False%c%c",13,10);
}
SaveBackupText(file, "", buffer, UseUnicode);
if (!bitmap->DefaultBitmap) SaveBitmapEntry(file, bitmap, UseUnicode);
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveWAPBookmarkEntry(FILE *file, GSM_WAPBookmark *bookmark, bool UseUnicode)
{
@@ -720,112 +774,113 @@ static void SaveStartupEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
sprintf(buffer,"[Startup]%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
if (bitmap->Type == GSM_WelcomeNote_Text) {
SaveBackupText(file, "Text", bitmap->Text, UseUnicode);
}
if (bitmap->Type == GSM_StartupLogo) {
SaveBitmapEntry(file, bitmap, UseUnicode);
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode)
{
unsigned char buffer[1000];
sprintf(buffer,"Location = %03i%c%c",SMSC->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBackupText(file, "Name", SMSC->Name, UseUnicode);
SaveBackupText(file, "Number", SMSC->Number, UseUnicode);
SaveBackupText(file, "DefaultNumber", SMSC->DefaultNumber, UseUnicode);
SaveBackupText(file, "", "Format = ", UseUnicode);
switch (SMSC->Format) {
case SMS_FORMAT_Text : sprintf(buffer,"Text"); break;
case SMS_FORMAT_Fax : sprintf(buffer,"Fax"); break;
case SMS_FORMAT_Email : sprintf(buffer,"Email"); break;
case SMS_FORMAT_Pager : sprintf(buffer,"Pager"); break;
}
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"%c%cValidity = ",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
switch (SMSC->Validity.Relative) {
case SMS_VALID_1_Hour : sprintf(buffer, "1hour" ); break;
case SMS_VALID_6_Hours : sprintf(buffer, "6hours" ); break;
case SMS_VALID_1_Day : sprintf(buffer, "24hours" ); break;
case SMS_VALID_3_Days : sprintf(buffer, "72hours" ); break;
case SMS_VALID_1_Week : sprintf(buffer, "1week" ); break;
case SMS_VALID_Max_Time :
default : sprintf(buffer,"MaximumTime" ); break;
}
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"%c%c%c%c",13,10,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode)
{
unsigned char buffer[45000];
- int i,j;
sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBackupText(file, "Name", ringtone->Name, UseUnicode);
switch (ringtone->Format) {
case RING_NOKIABINARY:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode);
break;
case RING_MIDI:
- j = 0; i = 0;
EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode);
break;
+ case RING_MMF:
+ EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
+ SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
+ break;
case RING_NOTETONE:
break;
}
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
{
unsigned char buffer[1000];
sprintf(buffer,"[Operator]%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveBitmapEntry(file, bitmap, UseUnicode);
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode)
{
unsigned char buffer[1000];
int j;
sprintf(buffer,"Location = %i%c%c",ToDo->Location,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
switch (ToDo->Priority) {
case GSM_Priority_High:
sprintf(buffer,"Priority = High%c%c",13,10);
break;
case GSM_Priority_Medium:
sprintf(buffer,"Priority = Medium%c%c",13,10);
break;
case GSM_Priority_Low:
sprintf(buffer,"Priority = Low%c%c",13,10);
break;
}
SaveBackupText(file, "", buffer, UseUnicode);
for (j=0;j<ToDo->EntriesNum;j++) {
switch (ToDo->Entries[j].EntryType) {
case TODO_END_DATETIME:
SaveBackupText(file, "", "DueTime", UseUnicode);
SaveVCalDateTime(file, &ToDo->Entries[j].Date, UseUnicode);
break;
case TODO_COMPLETED:
sprintf(buffer,"Completed = %s%c%c",ToDo->Entries[j].Number == 1 ? "yes" : "no" ,13,10);
@@ -1030,131 +1085,152 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
if (UseUnicode) {
sprintf(buffer,"%c%c", 0xFE, 0xFF);
SaveBackupText(file, "", buffer, false);
}
sprintf(buffer,"# Format of this file was designed for Gammu (see www.mwiacek.com)%c%c%c%c",13,10,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"[Backup]%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"IMEI = \"%s\"%c%c",backup->IMEI,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"Phone = \"%s\"%c%c",backup->Model,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
if (backup->Creator[0] != 0) {
sprintf(buffer,"Creator = \"%s\"%c%c",backup->Creator,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
}
if (backup->DateTimeAvailable) {
SaveBackupText(file, "", "DateTime", UseUnicode);
SaveVCalDateTime(file, &backup->DateTime, UseUnicode);
}
sprintf(buffer,"Format = 1.03%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
sprintf(buffer,"%c%c",13,10);
SaveBackupText(file, "", buffer, UseUnicode);
i=0;
while (backup->PhonePhonebook[i]!=NULL) {
sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode);
i++;
}
i=0;
while (backup->SIMPhonebook[i]!=NULL) {
sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode);
i++;
}
i=0;
while (backup->Calendar[i]!=NULL) {
sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveCalendarEntry(file, backup->Calendar[i], UseUnicode);
i++;
}
i=0;
+ while (backup->Note[i]!=NULL) {
+ sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveNoteEntry(file, backup->Note[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->CallerLogos[i]!=NULL) {
sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode);
i++;
}
i=0;
while (backup->SMSC[i]!=NULL) {
sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveSMSCEntry(file, backup->SMSC[i], UseUnicode);
i++;
}
i=0;
while (backup->WAPBookmark[i]!=NULL) {
sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode);
i++;
}
i=0;
while (backup->WAPSettings[i]!=NULL) {
sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode);
i++;
}
i=0;
while (backup->MMSSettings[i]!=NULL) {
sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode);
i++;
}
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
+ SaveBackupText(file, "", buffer, UseUnicode);
+ SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode);
i++;
}
i=0;
while (backup->ToDo[i]!=NULL) {
sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveToDoEntry(file, backup->ToDo[i], UseUnicode);
i++;
}
i=0;
while (backup->Profiles[i]!=NULL) {
sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveProfileEntry(file, backup->Profiles[i], UseUnicode);
i++;
}
i=0;
while (backup->FMStation[i]!=NULL) {
sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveFMStationEntry(file, backup->FMStation[i], UseUnicode);
i++;
}
i=0;
while (backup->GPRSPoint[i]!=NULL) {
sprintf(buffer,"[GPRSPoint%03i]%c%c",i+1,13,10);
SaveBackupText(file, "", buffer, UseUnicode);
SaveGPRSPointEntry(file, backup->GPRSPoint[i], UseUnicode);
i++;
}
if (backup->StartupLogo!=NULL) {
SaveStartupEntry(file, backup->StartupLogo, UseUnicode);
}
if (backup->OperatorLogo!=NULL) {
SaveOperatorEntry(file, backup->OperatorLogo, UseUnicode);
}
fclose(file);
FindBackupChecksum(FileName, UseUnicode, checksum);
file = fopen(FileName, "ab");
if (file == NULL) return ERR_CANTOPENFILE;
@@ -2611,97 +2687,222 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
EncodeUnicode(buffer,"GPRSPoint",9);
if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
} else {
if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
}
if (found) {
readvalue = ReadCFGText(file_info, h->SectionName, "Location", UseUnicode);
if (readvalue==NULL) break;
if (num < GSM_BACKUP_MAX_GPRSPOINT) {
backup->GPRSPoint[num] = malloc(sizeof(GSM_GPRSAccessPoint));
if (backup->GPRSPoint[num] == NULL) return ERR_MOREMEMORY;
backup->GPRSPoint[num + 1] = NULL;
} else {
dbgprintf("Increase GSM_BACKUP_MAX_GPRSPOINT\n");
return ERR_MOREMEMORY;
}
backup->GPRSPoint[num]->Location = num + 1;
ReadGPRSPointEntry(file_info, h->SectionName, backup->GPRSPoint[num],UseUnicode);
num++;
}
}
num = 0;
for (h = file_info; h != NULL; h = h->Next) {
found = false;
if (UseUnicode) {
EncodeUnicode(buffer,"Note",4);
if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
} else {
if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
}
if (found) {
readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode);
if (readvalue==NULL) break;
if (num < GSM_BACKUP_MAX_NOTE) {
backup->Note[num] = malloc(sizeof(GSM_NoteEntry));
if (backup->Note[num] == NULL) return ERR_MOREMEMORY;
backup->Note[num + 1] = NULL;
} else {
dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n");
return ERR_MOREMEMORY;
}
ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode);
num++;
}
}
if (backup->MD5Original[0]!=0) {
FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated);
}
-
+ for (h = file_info; h != NULL; h = h->Next) {
+ found = false;
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Backup",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Checksum",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Profile",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"PhonePBK",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SIMPBK",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Calendar",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Caller",6);
+ if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
+ } else {
+ if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"SMSC",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPBookmark",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Bookmark",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"WAPSettings",11);
+ if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
+ if (!found) {
+ EncodeUnicode(buffer,"Settings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ }
+ } else {
+ if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
+ if (!found) {
+ if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
+ }
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"MMSSettings",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Ringtone",8);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"TODO",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Startup",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
+ } else {
+ if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Operator",7);
+ if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
+ } else {
+ if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"FMStation",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"GPRSPoint",9);
+ if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
+ } else {
+ if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
+ }
+ if (UseUnicode) {
+ EncodeUnicode(buffer,"Note",4);
+ if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
+ } else {
+ if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
+ }
+ if (!found) return ERR_NOTIMPLEMENTED;
+ }
return ERR_NONE;
}
/* ---------------------- backup files for SMS ----------------------------- */
static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS)
{
unsigned char buffer[10000], *readvalue;
GSM_SetDefaultSMSData(SMS);
SMS->PDU = SMS_Submit;
SMS->SMSC.Location = 0;
sprintf(buffer,"SMSC");
ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false);
sprintf(buffer,"ReplySMSC");
SMS->ReplyViaSameSMSC = false;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) {
if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true;
}
sprintf(buffer,"Class");
SMS->Class = -1;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) SMS->Class = atoi(readvalue);
sprintf(buffer,"Sent");
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) {
ReadVCALDateTime(readvalue, &SMS->DateTime);
SMS->PDU = SMS_Deliver;
}
sprintf(buffer,"RejectDuplicates");
SMS->RejectDuplicates = false;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) {
if (mystrncasecmp(readvalue,"True",0)) SMS->RejectDuplicates = true;
}
sprintf(buffer,"ReplaceMessage");
SMS->ReplaceMessage = 0;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) SMS->ReplaceMessage = atoi(readvalue);
sprintf(buffer,"MessageReference");
SMS->MessageReference = 0;
readvalue = ReadCFGText(file_info, section, buffer, false);
if (readvalue!=NULL) SMS->MessageReference = atoi(readvalue);
sprintf(buffer,"State");
SMS->State = SMS_UnRead;
readvalue = ReadCFGText(file_info, section, buffer, false);
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
@@ -28,253 +28,271 @@ void GSM_FreeBackup(GSM_Backup *backup)
while (backup->PhonePhonebook[i]!=NULL) {
free(backup->PhonePhonebook[i]);
backup->PhonePhonebook[i] = NULL;
i++;
}
i=0;
while (backup->SIMPhonebook[i]!=NULL) {
free(backup->SIMPhonebook[i]);
backup->SIMPhonebook[i] = NULL;
i++;
}
i=0;
while (backup->Calendar[i]!=NULL) {
free(backup->Calendar[i]);
backup->Calendar[i] = NULL;
i++;
}
i=0;
while (backup->CallerLogos[i]!=NULL) {
free(backup->CallerLogos[i]);
backup->CallerLogos[i] = NULL;
i++;
}
i=0;
while (backup->SMSC[i]!=NULL) {
free(backup->SMSC[i]);
backup->SMSC[i] = NULL;
i++;
}
i=0;
while (backup->WAPBookmark[i]!=NULL) {
free(backup->WAPBookmark[i]);
backup->WAPBookmark[i] = NULL;
i++;
}
i=0;
while (backup->WAPSettings[i]!=NULL) {
free(backup->WAPSettings[i]);
backup->WAPSettings[i] = NULL;
i++;
}
i=0;
while (backup->MMSSettings[i]!=NULL) {
free(backup->MMSSettings[i]);
backup->MMSSettings[i] = NULL;
i++;
}
i=0;
+ while (backup->SyncMLSettings[i]!=NULL) {
+ free(backup->SyncMLSettings[i]);
+ backup->SyncMLSettings[i] = NULL;
+ i++;
+ }
+ i=0;
+ while (backup->ChatSettings[i]!=NULL) {
+ free(backup->ChatSettings[i]);
+ backup->ChatSettings[i] = NULL;
+ i++;
+ }
+ i=0;
while (backup->Ringtone[i]!=NULL) {
free(backup->Ringtone[i]);
backup->Ringtone[i] = NULL;
i++;
}
i=0;
while (backup->ToDo[i]!=NULL) {
free(backup->ToDo[i]);
backup->ToDo[i] = NULL;
i++;
}
i=0;
while (backup->Profiles[i]!=NULL) {
free(backup->Profiles[i]);
backup->Profiles[i] = NULL;
i++;
}
i=0;
while (backup->FMStation[i]!=NULL) {
free(backup->FMStation[i]);
backup->FMStation[i] = NULL;
i++;
}
if (backup->StartupLogo!=NULL) {
free(backup->StartupLogo);
backup->StartupLogo = NULL;
}
if (backup->OperatorLogo!=NULL) {
free(backup->OperatorLogo);
backup->OperatorLogo = NULL;
}
i=0;
while (backup->GPRSPoint[i]!=NULL) {
free(backup->GPRSPoint[i]);
backup->GPRSPoint[i] = NULL;
i++;
}
i=0;
while (backup->Note[i]!=NULL) {
free(backup->Note[i]);
backup->Note[i] = NULL;
i++;
}
}
GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode)
{
- if (strstr(FileName,".lmb")) {
+ if (mystrcasestr(FileName,".lmb")) {
return SaveLMB(FileName,backup);
- } else if (strstr(FileName,".vcs")) {
+ } else if (mystrcasestr(FileName,".vcs")) {
return SaveVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return SaveVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return SaveLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return SaveICS(FileName,backup);
} else {
return SaveBackup(FileName,backup, UseUnicode);
}
}
GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
{
FILE *file;
unsigned char buffer[300];
file = fopen(FileName, "rb");
if (file == NULL) return ERR_CANTOPENFILE;
fread(buffer, 1, 9, file); /* Read the header of the file. */
fclose(file);
GSM_ClearBackup(backup);
/* Attempt to identify filetype */
- if (strstr(FileName,".vcs")) {
+ if (mystrcasestr(FileName,".vcs")) {
return LoadVCalendar(FileName,backup);
- } else if (strstr(FileName,".vcf")) {
+ } else if (mystrcasestr(FileName,".vcf")) {
return LoadVCard(FileName,backup);
- } else if (strstr(FileName,".ldif")) {
+ } else if (mystrcasestr(FileName,".ldif")) {
return LoadLDIF(FileName,backup);
- } else if (strstr(FileName,".ics")) {
+ } else if (mystrcasestr(FileName,".ics")) {
return LoadICS(FileName,backup);
} else if (memcmp(buffer, "LMB ",4)==0) {
return LoadLMB(FileName,backup);
} else if (buffer[0] == 0xFE && buffer[1] == 0xFF) {
return LoadBackup(FileName,backup,true);
} else if (buffer[0] == 0xFF && buffer[1] == 0xFE) {
return LoadBackup(FileName,backup,true);
} else {
return LoadBackup(FileName,backup,false);
}
}
void GSM_ClearBackup(GSM_Backup *backup)
{
backup->PhonePhonebook [0] = NULL;
backup->SIMPhonebook [0] = NULL;
backup->Calendar [0] = NULL;
backup->CallerLogos [0] = NULL;
backup->SMSC [0] = NULL;
backup->WAPBookmark [0] = NULL;
backup->WAPSettings [0] = NULL;
backup->MMSSettings [0] = NULL;
+ backup->SyncMLSettings [0] = NULL;
+ backup->ChatSettings [0] = NULL;
backup->Ringtone [0] = NULL;
backup->Profiles [0] = NULL;
backup->ToDo [0] = NULL;
backup->GPRSPoint [0] = NULL;
backup->FMStation [0] = NULL;
backup->Note [0] = NULL;
backup->StartupLogo = NULL;
backup->OperatorLogo = NULL;
backup->Creator [0] = 0;
backup->IMEI [0] = 0;
backup->Model [0] = 0;
backup->DateTimeAvailable = false;
backup->MD5Original [0] = 0;
backup->MD5Calculated [0] = 0;
}
void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
{
info->UseUnicode = false;
info->IMEI = false;
info->Model = false;
info->DateTime = false;
info->PhonePhonebook = false;
info->SIMPhonebook = false;
info->ToDo = false;
info->Calendar = false;
info->CallerLogos = false;
info->SMSC = false;
info->WAPBookmark = false;
info->WAPSettings = false;
info->MMSSettings = false;
+ info->SyncMLSettings = false;
+ info->ChatSettings = false;
info->Ringtone = false;
info->StartupLogo = false;
info->OperatorLogo = false;
info->Profiles = false;
info->FMStation = false;
info->GPRSPoint = false;
info->Note = false;
if (strstr(FileName,".lmb")) {
info->PhonePhonebook = true;
info->SIMPhonebook = true;
info->CallerLogos = true;
info->StartupLogo = true;
} else if (strstr(FileName,".vcs")) {
info->ToDo = true;
info->Calendar = true;
} else if (strstr(FileName,".vcf")) {
info->PhonePhonebook = true;
} else if (strstr(FileName,".ics")) {
info->ToDo = true;
info->Calendar = true;
} else if (strstr(FileName,".ldif")) {
info->PhonePhonebook = true;
} else {
info->UseUnicode = true;
info->IMEI = true;
info->Model = true;
info->DateTime = true;
info->PhonePhonebook = true;
info->SIMPhonebook = true;
info->ToDo = true;
info->Calendar = true;
info->CallerLogos = true;
info->SMSC = true;
info->WAPBookmark = true;
info->WAPSettings = true;
info->MMSSettings = true;
+ info->SyncMLSettings = true;
+ info->ChatSettings = true;
info->Ringtone = true;
info->StartupLogo = true;
info->OperatorLogo = true;
info->Profiles = true;
info->FMStation = true;
info->GPRSPoint = true;
info->Note = true;
}
}
void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup)
{
GSM_GetBackupFormatFeatures(FileName, info);
if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false;
if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false;
if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false;
if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false;
if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false;
if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false;
if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false;
if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false;
if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false;
if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false;
/* .... */
}
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
diff --git a/gammu/emb/common/service/backup/gsmback.h b/gammu/emb/common/service/backup/gsmback.h
index 1fd99b0..791e81d 100644
--- a/gammu/emb/common/service/backup/gsmback.h
+++ b/gammu/emb/common/service/backup/gsmback.h
@@ -1,48 +1,50 @@
/* (c) 2003-2004 by Marcin Wiacek */
#ifndef __gsm_back_h
#define __gsm_back_h
#include "backgen.h"
#ifdef GSM_ENABLE_BACKUP
GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode);
GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup);
void GSM_ClearBackup (GSM_Backup *backup);
void GSM_FreeBackup (GSM_Backup *backup);
typedef struct {
bool UseUnicode;
bool IMEI;
bool Model;
bool DateTime;
bool ToDo;
bool PhonePhonebook;
bool SIMPhonebook;
bool Calendar;
bool CallerLogos;
bool SMSC;
bool WAPBookmark;
bool Profiles;
bool WAPSettings;
bool MMSSettings;
+ bool SyncMLSettings;
+ bool ChatSettings;
bool Ringtone;
bool StartupLogo;
bool OperatorLogo;
bool FMStation;
bool GPRSPoint;
bool Note;
} GSM_Backup_Info;
void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info);
void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup);
#endif
#endif
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/