summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service
authorzautrix <zautrix>2004-10-05 11:13:51 (UTC)
committer zautrix <zautrix>2004-10-05 11:13:51 (UTC)
commit50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff)
tree0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/service
parentcf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff)
downloadkdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz
kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2
updated to latest gammu version
Diffstat (limited to 'gammu/emb/common/service') (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
-rw-r--r--gammu/emb/common/service/gsmcal.h2
-rw-r--r--gammu/emb/common/service/gsmdata.c120
-rw-r--r--gammu/emb/common/service/gsmdata.h2
-rw-r--r--gammu/emb/common/service/gsmlogo.c47
-rw-r--r--gammu/emb/common/service/gsmlogo.h28
-rw-r--r--gammu/emb/common/service/gsmmisc.h7
-rw-r--r--gammu/emb/common/service/gsmring.c45
-rw-r--r--gammu/emb/common/service/gsmring.h8
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.c5
-rw-r--r--gammu/emb/common/service/sms/gsmmulti.h11
-rw-r--r--gammu/emb/common/service/sms/gsmsms.c5
-rw-r--r--gammu/emb/common/service/sms/gsmsms.h5
16 files changed, 491 insertions, 57 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 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_backgen_h 3#ifndef __gsm_backgen_h
4#define __gsm_backgen_h 4#define __gsm_backgen_h
5 5
6#include "../../config.h" 6#include "../../config.h"
7#include "../../misc/misc.h" 7#include "../../misc/misc.h"
8#include "../gsmpbk.h" 8#include "../gsmpbk.h"
9#include "../gsmcal.h" 9#include "../gsmcal.h"
10#include "../gsmlogo.h" 10#include "../gsmlogo.h"
11#include "../gsmring.h" 11#include "../gsmring.h"
12#include "../gsmdata.h" 12#include "../gsmdata.h"
13#include "../gsmprof.h" 13#include "../gsmprof.h"
14#include "../gsmmisc.h" 14#include "../gsmmisc.h"
15#include "../sms/gsmsms.h" 15#include "../sms/gsmsms.h"
16 16
17 #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501 17 #define GSM_BACKUP_MAX_PHONEPHONEBOOK 501
18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251 18 #define GSM_BACKUP_MAX_SIMPHONEBOOK 251
19 #define GSM_BACKUP_MAX_CALLER 6 19 #define GSM_BACKUP_MAX_CALLER 6
20 #define GSM_BACKUP_MAX_SMSC 10 20 #define GSM_BACKUP_MAX_SMSC 10
21 #define GSM_BACKUP_MAX_WAPBOOKMARK40 21 #define GSM_BACKUP_MAX_WAPBOOKMARK40
22 #define GSM_BACKUP_MAX_WAPSETTINGS30 22 #define GSM_BACKUP_MAX_WAPSETTINGS30
23 #define GSM_BACKUP_MAX_MMSSETTINGS30 23 #define GSM_BACKUP_MAX_MMSSETTINGS30
24 #define GSM_BACKUP_MAX_SYNCMLSETTINGS10
25 #define GSM_BACKUP_MAX_CHATSETTINGS10
24 #define GSM_BACKUP_MAX_RINGTONES30 26 #define GSM_BACKUP_MAX_RINGTONES30
25 #define GSM_BACKUP_MAX_PROFILES 10 27 #define GSM_BACKUP_MAX_PROFILES 10
26 #define GSM_BACKUP_MAX_FMSTATIONS20 28 #define GSM_BACKUP_MAX_FMSTATIONS20
27 #define GSM_BACKUP_MAX_GPRSPOINT10 29 #define GSM_BACKUP_MAX_GPRSPOINT10
28 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */ 30 #define GSM_BACKUP_MAX_NOTE 10/* FIXME */
29 31
30typedef struct { 32typedef struct {
31 char IMEI [MAX_IMEI_LENGTH]; 33 char IMEI [MAX_IMEI_LENGTH];
32 char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH]; 34 char Model [MAX_MODEL_LENGTH+MAX_VERSION_LENGTH];
33 char Creator [80]; 35 char Creator [80];
34 GSM_DateTime DateTime; 36 GSM_DateTime DateTime;
35 bool DateTimeAvailable; 37 bool DateTimeAvailable;
36 char MD5Original[100]; 38 char MD5Original[100];
37 char MD5Calculated[100]; 39 char MD5Calculated[100];
38 GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1]; 40 GSM_MemoryEntry *PhonePhonebook[GSM_BACKUP_MAX_PHONEPHONEBOOK + 1];
39 GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1]; 41 GSM_MemoryEntry *SIMPhonebook[GSM_BACKUP_MAX_SIMPHONEBOOK + 1];
40 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1]; 42 GSM_CalendarEntry *Calendar[GSM_MAXCALENDARTODONOTES + 1];
41 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1]; 43 GSM_Bitmap *CallerLogos[GSM_BACKUP_MAX_CALLER + 1];
42 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1]; 44 GSM_SMSC *SMSC [GSM_BACKUP_MAX_SMSC + 1];
43 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1]; 45 GSM_WAPBookmark *WAPBookmark[GSM_BACKUP_MAX_WAPBOOKMARK + 1];
44 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1]; 46 GSM_MultiWAPSettings *WAPSettings[GSM_BACKUP_MAX_WAPSETTINGS + 1];
45 GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1]; 47 GSM_MultiWAPSettings *MMSSettings[GSM_BACKUP_MAX_MMSSETTINGS + 1];
48 GSM_SyncMLSettings*SyncMLSettings [GSM_BACKUP_MAX_SYNCMLSETTINGS + 1];
49 GSM_ChatSettings *ChatSettings [GSM_BACKUP_MAX_CHATSETTINGS + 1];
46 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1]; 50 GSM_Ringtone *Ringtone[GSM_BACKUP_MAX_RINGTONES + 1];
47 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1]; 51 GSM_ToDoEntry *ToDo [GSM_MAXCALENDARTODONOTES + 1];
48 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1]; 52 GSM_Profile *Profiles[GSM_BACKUP_MAX_PROFILES + 1];
49 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1]; 53 GSM_FMStation *FMStation[GSM_BACKUP_MAX_FMSTATIONS +1];
50 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1]; 54 GSM_GPRSAccessPoint *GPRSPoint[GSM_BACKUP_MAX_GPRSPOINT + 1];
51 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1]; 55 GSM_NoteEntry *Note [GSM_BACKUP_MAX_NOTE + 1];
52 GSM_Bitmap *StartupLogo; 56 GSM_Bitmap *StartupLogo;
53 GSM_Bitmap *OperatorLogo; 57 GSM_Bitmap *OperatorLogo;
54} GSM_Backup; 58} GSM_Backup;
55 59
56 #define GSM_BACKUP_MAX_SMS500 60 #define GSM_BACKUP_MAX_SMS500
57 61
58typedef struct { 62typedef struct {
59 GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS]; 63 GSM_SMSMessage *SMS[GSM_BACKUP_MAX_SMS];
60} GSM_SMS_Backup; 64} GSM_SMS_Backup;
61 65
62extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); 66extern GSM_Error GSM_ReadSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
63extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup); 67extern GSM_Error GSM_SaveSMSBackupFile(char *FileName, GSM_SMS_Backup *backup);
64 68
65#endif 69#endif
66 70
67/* How should editor hadle tabs in this file? Add editor commands here. 71/* How should editor hadle tabs in this file? Add editor commands here.
68 * vim: noexpandtab sw=8 ts=8 sts=8: 72 * vim: noexpandtab sw=8 ts=8 sts=8:
69 */ 73 */
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
@@ -130,95 +130,96 @@ static void ReadLinkedBackupText(INI_Section *file_info, char *section, char *my
130 readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode); 130 readvalue = ReadCFGText(file_info, section, buffer2, UseUnicode);
131 if (readvalue!=NULL) { 131 if (readvalue!=NULL) {
132 myvalue[strlen(myvalue)+strlen(readvalue)]=0; 132 myvalue[strlen(myvalue)+strlen(readvalue)]=0;
133 memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue)); 133 memcpy(myvalue+strlen(myvalue),readvalue,strlen(readvalue));
134 } else break; 134 } else break;
135 i++; 135 i++;
136 } 136 }
137} 137}
138 138
139static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode) 139static void SaveBackupText(FILE *file, char *myname, char *myvalue, bool UseUnicode)
140{ 140{
141 unsigned char buffer[10000], buffer2[10000]; 141 unsigned char buffer[10000], buffer2[10000];
142 142
143 if (myname[0] == 0x00) { 143 if (myname[0] == 0x00) {
144 if (UseUnicode) { 144 if (UseUnicode) {
145 EncodeUnicode(buffer,myvalue,strlen(myvalue)); 145 EncodeUnicode(buffer,myvalue,strlen(myvalue));
146 fwrite(buffer,1,strlen(myvalue)*2,file); 146 fwrite(buffer,1,strlen(myvalue)*2,file);
147 } else fprintf(file,"%s",myvalue); 147 } else fprintf(file,"%s",myvalue);
148 } else { 148 } else {
149 if (UseUnicode) { 149 if (UseUnicode) {
150 sprintf(buffer,"%s = \"",myname); 150 sprintf(buffer,"%s = \"",myname);
151 EncodeUnicode(buffer2,buffer,strlen(buffer)); 151 EncodeUnicode(buffer2,buffer,strlen(buffer));
152 fwrite(buffer2,1,strlen(buffer)*2,file); 152 fwrite(buffer2,1,strlen(buffer)*2,file);
153 153
154 fwrite(myvalue,1,UnicodeLength(myvalue)*2,file); 154 fwrite(EncodeUnicodeSpecialChars(myvalue),1,UnicodeLength(EncodeUnicodeSpecialChars(myvalue))*2,file);
155 155
156 sprintf(buffer,"\"%c%c",13,10); 156 sprintf(buffer,"\"%c%c",13,10);
157 EncodeUnicode(buffer2,buffer,strlen(buffer)); 157 EncodeUnicode(buffer2,buffer,strlen(buffer));
158 fwrite(buffer2,1,strlen(buffer)*2,file); 158 fwrite(buffer2,1,strlen(buffer)*2,file);
159 } else { 159 } else {
160 sprintf(buffer,"%s = \"%s\"%c%c",myname,DecodeUnicodeString(myvalue),13,10); 160 sprintf(buffer,"%s = \"%s\"%c%c",myname,EncodeSpecialChars(DecodeUnicodeString(myvalue)),13,10);
161 fprintf(file,"%s",buffer); 161 fprintf(file,"%s",buffer);
162 162
163 EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2); 163 EncodeHexBin(buffer,myvalue,UnicodeLength(myvalue)*2);
164 fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10); 164 fprintf(file,"%sUnicode = %s%c%c",myname,buffer,13,10);
165 } 165 }
166 } 166 }
167} 167}
168 168
169static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode) 169static bool ReadBackupText(INI_Section *file_info, char *section, char *myname, char *myvalue, bool UseUnicode)
170{ 170{
171 unsigned char paramname[10000],*readvalue; 171 unsigned char paramname[10000],*readvalue;
172 172
173 if (UseUnicode) { 173 if (UseUnicode) {
174 EncodeUnicode(paramname,myname,strlen(myname)); 174 EncodeUnicode(paramname,myname,strlen(myname));
175 readvalue = INI_GetValue(file_info, section, paramname, UseUnicode); 175 readvalue = INI_GetValue(file_info, section, paramname, UseUnicode);
176 if (readvalue!=NULL) { 176 if (readvalue!=NULL) {
177 CopyUnicodeString(myvalue,readvalue+2); 177 CopyUnicodeString(myvalue,DecodeUnicodeSpecialChars(readvalue+2));
178 myvalue[UnicodeLength(readvalue)*2-4]=0; 178 myvalue[UnicodeLength(myvalue)*2-2]=0;
179 myvalue[UnicodeLength(readvalue)*2-3]=0; 179 myvalue[UnicodeLength(myvalue)*2-1]=0;
180
180 dbgprintf("%s\n",DecodeUnicodeString(readvalue)); 181 dbgprintf("%s\n",DecodeUnicodeString(readvalue));
181 } else { 182 } else {
182 myvalue[0]=0; 183 myvalue[0]=0;
183 myvalue[1]=0; 184 myvalue[1]=0;
184 return false; 185 return false;
185 } 186 }
186 } else { 187 } else {
187 strcpy(paramname,myname); 188 strcpy(paramname,myname);
188 strcat(paramname,"Unicode"); 189 strcat(paramname,"Unicode");
189 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); 190 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
190 if (readvalue!=NULL) { 191 if (readvalue!=NULL) {
191 dbgprintf("%s %i\n",readvalue,strlen(readvalue)); 192 dbgprintf("%s %i\n",readvalue,strlen(readvalue));
192 DecodeHexBin (myvalue, readvalue, strlen(readvalue)); 193 DecodeHexBin (myvalue, readvalue, strlen(readvalue));
193 myvalue[strlen(readvalue)/2]=0; 194 myvalue[strlen(readvalue)/2]=0;
194 myvalue[strlen(readvalue)/2+1]=0; 195 myvalue[strlen(readvalue)/2+1]=0;
195 dbgprintf("%s\n",DecodeUnicodeString(myvalue)); 196 dbgprintf("%s\n",DecodeUnicodeString(myvalue));
196 } else { 197 } else {
197 strcpy(paramname,myname); 198 strcpy(paramname,myname);
198 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode); 199 readvalue = ReadCFGText(file_info, section, paramname, UseUnicode);
199 if (readvalue!=NULL) { 200 if (readvalue!=NULL) {
200 EncodeUnicode(myvalue,readvalue+1,strlen(readvalue)-2); 201 EncodeUnicode(myvalue,DecodeSpecialChars(readvalue+1),strlen(DecodeSpecialChars(readvalue+1))-1);
201 } else { 202 } else {
202 myvalue[0]=0; 203 myvalue[0]=0;
203 myvalue[1]=0; 204 myvalue[1]=0;
204 return false; 205 return false;
205 } 206 }
206 } 207 }
207 } 208 }
208 return true; 209 return true;
209} 210}
210 211
211static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode) 212static void SaveVCalDateTime(FILE *file, GSM_DateTime *dt, bool UseUnicode)
212{ 213{
213 unsigned char buffer[100]; 214 unsigned char buffer[100];
214 int Length = 3; 215 int Length = 3;
215 216
216 sprintf(buffer, " = "); 217 sprintf(buffer, " = ");
217 SaveVCALDateTime(buffer, &Length, dt, NULL); 218 SaveVCALDateTime(buffer, &Length, dt, NULL);
218 SaveBackupText(file, "", buffer, UseUnicode); 219 SaveBackupText(file, "", buffer, UseUnicode);
219} 220}
220 221
221static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode) 222static void SaveVCalDate(FILE *file, GSM_DateTime *dt, bool UseUnicode)
222{ 223{
223 unsigned char buffer[100]; 224 unsigned char buffer[100];
224 225
@@ -397,48 +398,59 @@ static void SavePbkEntry(FILE *file, GSM_MemoryEntry *Pbk, bool UseUnicode)
397 case PBK_Number_Work: 398 case PBK_Number_Work:
398 case PBK_Number_Fax: 399 case PBK_Number_Fax:
399 case PBK_Number_Home: 400 case PBK_Number_Home:
400 case PBK_Number_Other: 401 case PBK_Number_Other:
401 case PBK_Number_Pager: 402 case PBK_Number_Pager:
402 if (Pbk->Entries[j].VoiceTag!=0) { 403 if (Pbk->Entries[j].VoiceTag!=0) {
403 sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10); 404 sprintf(buffer,"Entry%02iVoiceTag = %i%c%c",j,Pbk->Entries[j].VoiceTag,13,10);
404 SaveBackupText(file, "", buffer, UseUnicode); 405 SaveBackupText(file, "", buffer, UseUnicode);
405 } 406 }
406 i = 0; 407 i = 0;
407 while (Pbk->Entries[j].SMSList[i]!=0) { 408 while (Pbk->Entries[j].SMSList[i]!=0) {
408 sprintf(buffer,"Entry%02iSMSList%02i = %i%c%c",j,i,Pbk->Entries[j].SMSList[i],13,10); 409 sprintf(buffer,"Entry%02iSMSList%02i = %i%c%c",j,i,Pbk->Entries[j].SMSList[i],13,10);
409 SaveBackupText(file, "", buffer, UseUnicode); 410 SaveBackupText(file, "", buffer, UseUnicode);
410 i++; 411 i++;
411 } 412 }
412 break; 413 break;
413 default: 414 default:
414 break; 415 break;
415 } 416 }
416 } 417 }
417 sprintf(buffer,"%c%c",13,10); 418 sprintf(buffer,"%c%c",13,10);
418 SaveBackupText(file, "", buffer, UseUnicode); 419 SaveBackupText(file, "", buffer, UseUnicode);
419} 420}
420 421
422static void SaveNoteEntry(FILE *file, GSM_NoteEntry *Note, bool UseUnicode)
423{
424 char buffer[1000];
425
426 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
427 SaveBackupText(file, "", buffer, UseUnicode);
428 SaveBackupText(file, "Text", Note->Text, UseUnicode);
429 sprintf(buffer, "%c%c",13,10);
430 SaveBackupText(file, "", buffer, UseUnicode);
431}
432
421static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode) 433static void SaveCalendarEntry(FILE *file, GSM_CalendarEntry *Note, bool UseUnicode)
422{ 434{
423 int i; 435 int i;
424 charbuffer[1000]; 436 charbuffer[1000];
425 437
426 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10); 438 sprintf(buffer,"Location = %d%c%c", Note->Location,13,10);
427 SaveBackupText(file, "", buffer, UseUnicode); 439 SaveBackupText(file, "", buffer, UseUnicode);
428 SaveBackupText(file, "", "Type = ", UseUnicode); 440 SaveBackupText(file, "", "Type = ", UseUnicode);
429 switch (Note->Type) { 441 switch (Note->Type) {
430 case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break; 442 case GSM_CAL_REMINDER : sprintf(buffer,"Reminder%c%c", 13,10); break;
431 case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break; 443 case GSM_CAL_CALL : sprintf(buffer,"Call%c%c", 13,10); break;
432 case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break; 444 case GSM_CAL_MEETING : sprintf(buffer,"Meeting%c%c", 13,10); break;
433 case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break; 445 case GSM_CAL_BIRTHDAY : sprintf(buffer,"Birthday%c%c", 13,10); break;
434 case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break; 446 case GSM_CAL_TRAVEL : sprintf(buffer,"Travel%c%c", 13,10); break;
435 case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break; 447 case GSM_CAL_VACATION : sprintf(buffer,"Vacation%c%c", 13,10); break;
436 case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break; 448 case GSM_CAL_MEMO : sprintf(buffer,"Memo%c%c", 13,10); break;
437 case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break; 449 case GSM_CAL_ALARM : sprintf(buffer,"Alarm%c%c", 13,10); break;
438 case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break; 450 case GSM_CAL_DAILY_ALARM : sprintf(buffer,"DailyAlarm%c%c", 13,10); break;
439 case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break; 451 case GSM_CAL_T_ATHL : sprintf(buffer,"Training/Athletism%c%c", 13,10); break;
440 case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break; 452 case GSM_CAL_T_BALL : sprintf(buffer,"Training/BallGames%c%c", 13,10); break;
441 case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break; 453 case GSM_CAL_T_CYCL : sprintf(buffer,"Training/Cycling%c%c", 13,10); break;
442 case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break; 454 case GSM_CAL_T_BUDO : sprintf(buffer,"Training/Budo%c%c", 13,10); break;
443 case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break; 455 case GSM_CAL_T_DANC : sprintf(buffer,"Training/Dance%c%c", 13,10); break;
444 case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break; 456 case GSM_CAL_T_EXTR : sprintf(buffer,"Training/ExtremeSports%c%c", 13,10); break;
@@ -636,48 +648,90 @@ static void SaveWAPSettingsEntry(FILE *file, GSM_MultiWAPSettings *settings, boo
636 break; 648 break;
637 } 649 }
638 sprintf(buffer,"User%02i",i); 650 sprintf(buffer,"User%02i",i);
639 SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode); 651 SaveBackupText(file, buffer, settings->Settings[i].User, UseUnicode);
640 sprintf(buffer,"Password%02i",i); 652 sprintf(buffer,"Password%02i",i);
641 SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode); 653 SaveBackupText(file, buffer, settings->Settings[i].Password, UseUnicode);
642 break; 654 break;
643 case WAPSETTINGS_BEARER_USSD: 655 case WAPSETTINGS_BEARER_USSD:
644 sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10); 656 sprintf(buffer,"Bearer%02i = USSD%c%c",i,13,10);
645 SaveBackupText(file, "", buffer, UseUnicode); 657 SaveBackupText(file, "", buffer, UseUnicode);
646 sprintf(buffer,"ServiceCode%02i",i); 658 sprintf(buffer,"ServiceCode%02i",i);
647 SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode); 659 SaveBackupText(file, buffer, settings->Settings[i].Code, UseUnicode);
648 if (settings->Settings[i].IsIP) { 660 if (settings->Settings[i].IsIP) {
649 sprintf(buffer,"IP%02i",i); 661 sprintf(buffer,"IP%02i",i);
650 } else { 662 } else {
651 sprintf(buffer,"Number%02i",i); 663 sprintf(buffer,"Number%02i",i);
652 } 664 }
653 SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode); 665 SaveBackupText(file, buffer, settings->Settings[i].Service, UseUnicode);
654 } 666 }
655 sprintf(buffer,"%c%c",13,10); 667 sprintf(buffer,"%c%c",13,10);
656 SaveBackupText(file, "", buffer, UseUnicode); 668 SaveBackupText(file, "", buffer, UseUnicode);
657 } 669 }
658} 670}
659 671
672static void SaveChatSettingsEntry(FILE *file, GSM_ChatSettings *settings, bool UseUnicode)
673{
674 char buffer[10000];
675
676 sprintf(buffer,"HomePage");
677 SaveBackupText(file, buffer, settings->HomePage, UseUnicode);
678 sprintf(buffer,"User");
679 SaveBackupText(file, buffer, settings->User, UseUnicode);
680 sprintf(buffer,"Password");
681 SaveBackupText(file, buffer, settings->Password, UseUnicode);
682 SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
683}
684
685static void SaveSyncMLSettingsEntry(FILE *file, GSM_SyncMLSettings *settings, bool UseUnicode)
686{
687 char buffer[10000];
688
689 sprintf(buffer,"User");
690 SaveBackupText(file, buffer, settings->User, UseUnicode);
691 sprintf(buffer,"Password");
692 SaveBackupText(file, buffer, settings->Password, UseUnicode);
693 sprintf(buffer,"PhonebookDB");
694 SaveBackupText(file, buffer, settings->PhonebookDataBase, UseUnicode);
695 sprintf(buffer,"CalendarDB");
696 SaveBackupText(file, buffer, settings->CalendarDataBase, UseUnicode);
697 sprintf(buffer,"Server");
698 SaveBackupText(file, buffer, settings->Server, UseUnicode);
699 if (settings->SyncPhonebook) {
700 sprintf(buffer,"SyncPhonebook = True%c%c",13,10);
701 } else {
702 sprintf(buffer,"SyncPhonebook = False%c%c",13,10);
703 }
704 SaveBackupText(file, "", buffer, UseUnicode);
705 if (settings->SyncCalendar) {
706 sprintf(buffer,"SyncCalendar = True%c%c",13,10);
707 } else {
708 sprintf(buffer,"SyncCalendar = False%c%c",13,10);
709 }
710 SaveBackupText(file, "", buffer, UseUnicode);
711 SaveWAPSettingsEntry(file, &settings->Connection, UseUnicode);
712}
713
660static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) 714static void SaveBitmapEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
661{ 715{
662 unsigned char buffer[10000],buffer2[10000]; 716 unsigned char buffer[10000],buffer2[10000];
663 int x,y; 717 int x,y;
664 718
665 sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10); 719 sprintf(buffer,"Width = %i%c%c",bitmap->BitmapWidth,13,10);
666 SaveBackupText(file, "", buffer, UseUnicode); 720 SaveBackupText(file, "", buffer, UseUnicode);
667 sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10); 721 sprintf(buffer,"Height = %i%c%c",bitmap->BitmapHeight,13,10);
668 SaveBackupText(file, "", buffer, UseUnicode); 722 SaveBackupText(file, "", buffer, UseUnicode);
669 for (y=0;y<bitmap->BitmapHeight;y++) { 723 for (y=0;y<bitmap->BitmapHeight;y++) {
670 for (x=0;x<bitmap->BitmapWidth;x++) { 724 for (x=0;x<bitmap->BitmapWidth;x++) {
671 buffer[x] = ' '; 725 buffer[x] = ' ';
672 if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#'; 726 if (GSM_IsPointBitmap(bitmap,x,y)) buffer[x]='#';
673 } 727 }
674 buffer[bitmap->BitmapWidth] = 0; 728 buffer[bitmap->BitmapWidth] = 0;
675 sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10); 729 sprintf(buffer2,"Bitmap%02i = \"%s\"%c%c",y,buffer,13,10);
676 SaveBackupText(file, "", buffer2, UseUnicode); 730 SaveBackupText(file, "", buffer2, UseUnicode);
677 } 731 }
678} 732}
679 733
680static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) 734static void SaveCallerEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
681{ 735{
682 unsigned char buffer[1000]; 736 unsigned char buffer[1000];
683 737
@@ -744,64 +798,65 @@ static void SaveSMSCEntry(FILE *file, GSM_SMSC *SMSC, bool UseUnicode)
744 case SMS_FORMAT_Fax: sprintf(buffer,"Fax"); break; 798 case SMS_FORMAT_Fax: sprintf(buffer,"Fax"); break;
745 case SMS_FORMAT_Email: sprintf(buffer,"Email"); break; 799 case SMS_FORMAT_Email: sprintf(buffer,"Email"); break;
746 case SMS_FORMAT_Pager: sprintf(buffer,"Pager"); break; 800 case SMS_FORMAT_Pager: sprintf(buffer,"Pager"); break;
747 } 801 }
748 SaveBackupText(file, "", buffer, UseUnicode); 802 SaveBackupText(file, "", buffer, UseUnicode);
749 sprintf(buffer,"%c%cValidity = ",13,10); 803 sprintf(buffer,"%c%cValidity = ",13,10);
750 SaveBackupText(file, "", buffer, UseUnicode); 804 SaveBackupText(file, "", buffer, UseUnicode);
751 switch (SMSC->Validity.Relative) { 805 switch (SMSC->Validity.Relative) {
752 case SMS_VALID_1_Hour : sprintf(buffer, "1hour"); break; 806 case SMS_VALID_1_Hour : sprintf(buffer, "1hour"); break;
753 case SMS_VALID_6_Hours : sprintf(buffer, "6hours"); break; 807 case SMS_VALID_6_Hours : sprintf(buffer, "6hours"); break;
754 case SMS_VALID_1_Day : sprintf(buffer, "24hours"); break; 808 case SMS_VALID_1_Day : sprintf(buffer, "24hours"); break;
755 case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break; 809 case SMS_VALID_3_Days : sprintf(buffer, "72hours"); break;
756 case SMS_VALID_1_Week : sprintf(buffer, "1week"); break; 810 case SMS_VALID_1_Week : sprintf(buffer, "1week"); break;
757 case SMS_VALID_Max_Time: 811 case SMS_VALID_Max_Time:
758 default : sprintf(buffer,"MaximumTime"); break; 812 default : sprintf(buffer,"MaximumTime"); break;
759 } 813 }
760 SaveBackupText(file, "", buffer, UseUnicode); 814 SaveBackupText(file, "", buffer, UseUnicode);
761 sprintf(buffer,"%c%c%c%c",13,10,13,10); 815 sprintf(buffer,"%c%c%c%c",13,10,13,10);
762 SaveBackupText(file, "", buffer, UseUnicode); 816 SaveBackupText(file, "", buffer, UseUnicode);
763} 817}
764 818
765static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode) 819static void SaveRingtoneEntry(FILE *file, GSM_Ringtone *ringtone, bool UseUnicode)
766{ 820{
767 unsigned char buffer[45000]; 821 unsigned char buffer[45000];
768 int i,j;
769 822
770 sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10); 823 sprintf(buffer,"Location = %i%c%c",ringtone->Location,13,10);
771 SaveBackupText(file, "", buffer, UseUnicode); 824 SaveBackupText(file, "", buffer, UseUnicode);
772 SaveBackupText(file, "Name", ringtone->Name, UseUnicode); 825 SaveBackupText(file, "Name", ringtone->Name, UseUnicode);
773 switch (ringtone->Format) { 826 switch (ringtone->Format) {
774 case RING_NOKIABINARY: 827 case RING_NOKIABINARY:
775 j = 0; i = 0;
776 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); 828 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
777 SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode); 829 SaveLinkedBackupText(file, "NokiaBinary", buffer, UseUnicode);
778 break; 830 break;
779 case RING_MIDI: 831 case RING_MIDI:
780 j = 0; i = 0;
781 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length); 832 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
782 SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode); 833 SaveLinkedBackupText(file, "Pure Midi", buffer, UseUnicode);
783 break; 834 break;
835 case RING_MMF:
836 EncodeHexBin(buffer,ringtone->NokiaBinary.Frame,ringtone->NokiaBinary.Length);
837 SaveLinkedBackupText(file, "SMAF", buffer, UseUnicode);
838 break;
784 case RING_NOTETONE: 839 case RING_NOTETONE:
785 break; 840 break;
786 } 841 }
787 sprintf(buffer,"%c%c",13,10); 842 sprintf(buffer,"%c%c",13,10);
788 SaveBackupText(file, "", buffer, UseUnicode); 843 SaveBackupText(file, "", buffer, UseUnicode);
789} 844}
790 845
791static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode) 846static void SaveOperatorEntry(FILE *file, GSM_Bitmap *bitmap, bool UseUnicode)
792{ 847{
793 unsigned char buffer[1000]; 848 unsigned char buffer[1000];
794 849
795 sprintf(buffer,"[Operator]%c%c",13,10); 850 sprintf(buffer,"[Operator]%c%c",13,10);
796 SaveBackupText(file, "", buffer, UseUnicode); 851 SaveBackupText(file, "", buffer, UseUnicode);
797 sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10); 852 sprintf(buffer,"Network = \"%s\"%c%c", bitmap->NetworkCode,13,10);
798 SaveBackupText(file, "", buffer, UseUnicode); 853 SaveBackupText(file, "", buffer, UseUnicode);
799 SaveBitmapEntry(file, bitmap, UseUnicode); 854 SaveBitmapEntry(file, bitmap, UseUnicode);
800 sprintf(buffer,"%c%c",13,10); 855 sprintf(buffer,"%c%c",13,10);
801 SaveBackupText(file, "", buffer, UseUnicode); 856 SaveBackupText(file, "", buffer, UseUnicode);
802} 857}
803 858
804static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode) 859static void SaveToDoEntry(FILE *file, GSM_ToDoEntry *ToDo, bool UseUnicode)
805{ 860{
806 unsigned char buffer[1000]; 861 unsigned char buffer[1000];
807 int j; 862 int j;
@@ -1054,83 +1109,104 @@ GSM_Error SaveBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
1054 SaveBackupText(file, "", buffer, UseUnicode); 1109 SaveBackupText(file, "", buffer, UseUnicode);
1055 1110
1056 i=0; 1111 i=0;
1057 while (backup->PhonePhonebook[i]!=NULL) { 1112 while (backup->PhonePhonebook[i]!=NULL) {
1058 sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10); 1113 sprintf(buffer,"[PhonePBK%03i]%c%c",i+1,13,10);
1059 SaveBackupText(file, "", buffer, UseUnicode); 1114 SaveBackupText(file, "", buffer, UseUnicode);
1060 SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode); 1115 SavePbkEntry(file, backup->PhonePhonebook[i], UseUnicode);
1061 i++; 1116 i++;
1062 } 1117 }
1063 i=0; 1118 i=0;
1064 while (backup->SIMPhonebook[i]!=NULL) { 1119 while (backup->SIMPhonebook[i]!=NULL) {
1065 sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10); 1120 sprintf(buffer,"[SIMPBK%03i]%c%c",i+1,13,10);
1066 SaveBackupText(file, "", buffer, UseUnicode); 1121 SaveBackupText(file, "", buffer, UseUnicode);
1067 SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode); 1122 SavePbkEntry(file, backup->SIMPhonebook[i], UseUnicode);
1068 i++; 1123 i++;
1069 } 1124 }
1070 i=0; 1125 i=0;
1071 while (backup->Calendar[i]!=NULL) { 1126 while (backup->Calendar[i]!=NULL) {
1072 sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10); 1127 sprintf(buffer,"[Calendar%03i]%c%c",i+1,13,10);
1073 SaveBackupText(file, "", buffer, UseUnicode); 1128 SaveBackupText(file, "", buffer, UseUnicode);
1074 SaveCalendarEntry(file, backup->Calendar[i], UseUnicode); 1129 SaveCalendarEntry(file, backup->Calendar[i], UseUnicode);
1075 i++; 1130 i++;
1076 } 1131 }
1077 i=0; 1132 i=0;
1133 while (backup->Note[i]!=NULL) {
1134 sprintf(buffer,"[Note%03i]%c%c",i+1,13,10);
1135 SaveBackupText(file, "", buffer, UseUnicode);
1136 SaveNoteEntry(file, backup->Note[i], UseUnicode);
1137 i++;
1138 }
1139 i=0;
1078 while (backup->CallerLogos[i]!=NULL) { 1140 while (backup->CallerLogos[i]!=NULL) {
1079 sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10); 1141 sprintf(buffer,"[Caller%03i]%c%c",i+1,13,10);
1080 SaveBackupText(file, "", buffer, UseUnicode); 1142 SaveBackupText(file, "", buffer, UseUnicode);
1081 SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode); 1143 SaveCallerEntry(file, backup->CallerLogos[i], UseUnicode);
1082 i++; 1144 i++;
1083 } 1145 }
1084 i=0; 1146 i=0;
1085 while (backup->SMSC[i]!=NULL) { 1147 while (backup->SMSC[i]!=NULL) {
1086 sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10); 1148 sprintf(buffer,"[SMSC%03i]%c%c",i+1,13,10);
1087 SaveBackupText(file, "", buffer, UseUnicode); 1149 SaveBackupText(file, "", buffer, UseUnicode);
1088 SaveSMSCEntry(file, backup->SMSC[i], UseUnicode); 1150 SaveSMSCEntry(file, backup->SMSC[i], UseUnicode);
1089 i++; 1151 i++;
1090 } 1152 }
1091 i=0; 1153 i=0;
1092 while (backup->WAPBookmark[i]!=NULL) { 1154 while (backup->WAPBookmark[i]!=NULL) {
1093 sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10); 1155 sprintf(buffer,"[WAPBookmark%03i]%c%c",i+1,13,10);
1094 SaveBackupText(file, "", buffer, UseUnicode); 1156 SaveBackupText(file, "", buffer, UseUnicode);
1095 SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode); 1157 SaveWAPBookmarkEntry(file, backup->WAPBookmark[i], UseUnicode);
1096 i++; 1158 i++;
1097 } 1159 }
1098 i=0; 1160 i=0;
1099 while (backup->WAPSettings[i]!=NULL) { 1161 while (backup->WAPSettings[i]!=NULL) {
1100 sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10); 1162 sprintf(buffer,"[WAPSettings%03i]%c%c",i+1,13,10);
1101 SaveBackupText(file, "", buffer, UseUnicode); 1163 SaveBackupText(file, "", buffer, UseUnicode);
1102 SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode); 1164 SaveWAPSettingsEntry(file, backup->WAPSettings[i], UseUnicode);
1103 i++; 1165 i++;
1104 } 1166 }
1105 i=0; 1167 i=0;
1106 while (backup->MMSSettings[i]!=NULL) { 1168 while (backup->MMSSettings[i]!=NULL) {
1107 sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10); 1169 sprintf(buffer,"[MMSSettings%03i]%c%c",i+1,13,10);
1108 SaveBackupText(file, "", buffer, UseUnicode); 1170 SaveBackupText(file, "", buffer, UseUnicode);
1109 SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode); 1171 SaveWAPSettingsEntry(file, backup->MMSSettings[i], UseUnicode);
1110 i++; 1172 i++;
1111 } 1173 }
1112 i=0; 1174 i=0;
1175 while (backup->SyncMLSettings[i]!=NULL) {
1176 sprintf(buffer,"[SyncMLSettings%03i]%c%c",i+1,13,10);
1177 SaveBackupText(file, "", buffer, UseUnicode);
1178 SaveSyncMLSettingsEntry(file, backup->SyncMLSettings[i], UseUnicode);
1179 i++;
1180 }
1181 i=0;
1182 while (backup->ChatSettings[i]!=NULL) {
1183 sprintf(buffer,"[ChatSettings%03i]%c%c",i+1,13,10);
1184 SaveBackupText(file, "", buffer, UseUnicode);
1185 SaveChatSettingsEntry(file, backup->ChatSettings[i], UseUnicode);
1186 i++;
1187 }
1188 i=0;
1113 while (backup->Ringtone[i]!=NULL) { 1189 while (backup->Ringtone[i]!=NULL) {
1114 sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10); 1190 sprintf(buffer,"[Ringtone%03i]%c%c",i+1,13,10);
1115 SaveBackupText(file, "", buffer, UseUnicode); 1191 SaveBackupText(file, "", buffer, UseUnicode);
1116 SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode); 1192 SaveRingtoneEntry(file, backup->Ringtone[i], UseUnicode);
1117 i++; 1193 i++;
1118 } 1194 }
1119 i=0; 1195 i=0;
1120 while (backup->ToDo[i]!=NULL) { 1196 while (backup->ToDo[i]!=NULL) {
1121 sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10); 1197 sprintf(buffer,"[TODO%03i]%c%c",i+1,13,10);
1122 SaveBackupText(file, "", buffer, UseUnicode); 1198 SaveBackupText(file, "", buffer, UseUnicode);
1123 SaveToDoEntry(file, backup->ToDo[i], UseUnicode); 1199 SaveToDoEntry(file, backup->ToDo[i], UseUnicode);
1124 i++; 1200 i++;
1125 } 1201 }
1126 i=0; 1202 i=0;
1127 while (backup->Profiles[i]!=NULL) { 1203 while (backup->Profiles[i]!=NULL) {
1128 sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10); 1204 sprintf(buffer,"[Profile%03i]%c%c",i+1,13,10);
1129 SaveBackupText(file, "", buffer, UseUnicode); 1205 SaveBackupText(file, "", buffer, UseUnicode);
1130 SaveProfileEntry(file, backup->Profiles[i], UseUnicode); 1206 SaveProfileEntry(file, backup->Profiles[i], UseUnicode);
1131 i++; 1207 i++;
1132 } 1208 }
1133 i=0; 1209 i=0;
1134 while (backup->FMStation[i]!=NULL) { 1210 while (backup->FMStation[i]!=NULL) {
1135 sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10); 1211 sprintf(buffer,"[FMStation%03i]%c%c",i+1,13,10);
1136 SaveBackupText(file, "", buffer, UseUnicode); 1212 SaveBackupText(file, "", buffer, UseUnicode);
@@ -2635,49 +2711,174 @@ GSM_Error LoadBackup(char *FileName, GSM_Backup *backup, bool UseUnicode)
2635 if (UseUnicode) { 2711 if (UseUnicode) {
2636 EncodeUnicode(buffer,"Note",4); 2712 EncodeUnicode(buffer,"Note",4);
2637 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true; 2713 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2638 } else { 2714 } else {
2639 if (mystrncasecmp("Note", h->SectionName, 4)) found = true; 2715 if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
2640 } 2716 }
2641 if (found) { 2717 if (found) {
2642 readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode); 2718 readvalue = ReadCFGText(file_info, h->SectionName, "Text", UseUnicode);
2643 if (readvalue==NULL) break; 2719 if (readvalue==NULL) break;
2644 if (num < GSM_BACKUP_MAX_NOTE) { 2720 if (num < GSM_BACKUP_MAX_NOTE) {
2645 backup->Note[num] = malloc(sizeof(GSM_NoteEntry)); 2721 backup->Note[num] = malloc(sizeof(GSM_NoteEntry));
2646 if (backup->Note[num] == NULL) return ERR_MOREMEMORY; 2722 if (backup->Note[num] == NULL) return ERR_MOREMEMORY;
2647 backup->Note[num + 1] = NULL; 2723 backup->Note[num + 1] = NULL;
2648 } else { 2724 } else {
2649 dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n"); 2725 dbgprintf("Increase GSM_BACKUP_MAX_NOTE\n");
2650 return ERR_MOREMEMORY; 2726 return ERR_MOREMEMORY;
2651 } 2727 }
2652 ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode); 2728 ReadNoteEntry(file_info, h->SectionName, backup->Note[num],UseUnicode);
2653 num++; 2729 num++;
2654 } 2730 }
2655 } 2731 }
2656 if (backup->MD5Original[0]!=0) { 2732 if (backup->MD5Original[0]!=0) {
2657 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated); 2733 FindBackupChecksum(FileName, UseUnicode, backup->MD5Calculated);
2658 } 2734 }
2659 2735 for (h = file_info; h != NULL; h = h->Next) {
2736 found = false;
2737 if (UseUnicode) {
2738 EncodeUnicode(buffer,"Backup",4);
2739 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2740 } else {
2741 if (mystrncasecmp("Backup", h->SectionName, 6)) found = true;
2742 }
2743 if (UseUnicode) {
2744 EncodeUnicode(buffer,"Checksum",4);
2745 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2746 } else {
2747 if (mystrncasecmp("Checksum", h->SectionName, 8)) found = true;
2748 }
2749 if (UseUnicode) {
2750 EncodeUnicode(buffer,"Profile",7);
2751 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2752 } else {
2753 if (mystrncasecmp("Profile", h->SectionName, 7)) found = true;
2754 }
2755 if (UseUnicode) {
2756 EncodeUnicode(buffer,"PhonePBK",8);
2757 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2758 } else {
2759 if (mystrncasecmp("PhonePBK", h->SectionName, 8)) found = true;
2760 }
2761 if (UseUnicode) {
2762 EncodeUnicode(buffer,"SIMPBK",6);
2763 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2764 } else {
2765 if (mystrncasecmp("SIMPBK", h->SectionName, 6)) found = true;
2766 }
2767 if (UseUnicode) {
2768 EncodeUnicode(buffer,"Calendar",8);
2769 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2770 } else {
2771 if (mystrncasecmp("Calendar", h->SectionName, 8)) found = true;
2772 }
2773 if (UseUnicode) {
2774 EncodeUnicode(buffer,"Caller",6);
2775 if (mywstrncasecmp(buffer, h->SectionName, 6)) found = true;
2776 } else {
2777 if (mystrncasecmp("Caller", h->SectionName, 6)) found = true;
2778 }
2779 if (UseUnicode) {
2780 EncodeUnicode(buffer,"SMSC",4);
2781 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2782 } else {
2783 if (mystrncasecmp("SMSC", h->SectionName, 4)) found = true;
2784 }
2785 if (UseUnicode) {
2786 EncodeUnicode(buffer,"WAPBookmark",11);
2787 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2788 if (!found) {
2789 EncodeUnicode(buffer,"Bookmark",8);
2790 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2791 }
2792 } else {
2793 if (mystrncasecmp("WAPBookmark", h->SectionName, 11)) found = true;
2794 if (!found) {
2795 if (mystrncasecmp("Bookmark", h->SectionName, 8)) found = true;
2796 }
2797 }
2798 if (UseUnicode) {
2799 EncodeUnicode(buffer,"WAPSettings",11);
2800 if (mywstrncasecmp(buffer, h->SectionName, 11)) found = true;
2801 if (!found) {
2802 EncodeUnicode(buffer,"Settings",8);
2803 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2804 }
2805 } else {
2806 if (mystrncasecmp("WAPSettings", h->SectionName, 11)) found = true;
2807 if (!found) {
2808 if (mystrncasecmp("Settings", h->SectionName, 8)) found = true;
2809 }
2810 }
2811 if (UseUnicode) {
2812 EncodeUnicode(buffer,"MMSSettings",8);
2813 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2814 } else {
2815 if (mystrncasecmp("MMSSettings", h->SectionName, 8)) found = true;
2816 }
2817 if (UseUnicode) {
2818 EncodeUnicode(buffer,"Ringtone",8);
2819 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2820 } else {
2821 if (mystrncasecmp("Ringtone", h->SectionName, 8)) found = true;
2822 }
2823 if (UseUnicode) {
2824 EncodeUnicode(buffer,"TODO",4);
2825 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2826 } else {
2827 if (mystrncasecmp("TODO", h->SectionName, 4)) found = true;
2828 }
2829 if (UseUnicode) {
2830 EncodeUnicode(buffer,"Startup",7);
2831 if (mywstrncasecmp(buffer, h->SectionName, 7)) found = true;
2832 } else {
2833 if (mystrncasecmp("Startup", h->SectionName, 7)) found = true;
2834 }
2835 if (UseUnicode) {
2836 EncodeUnicode(buffer,"Operator",7);
2837 if (mywstrncasecmp(buffer, h->SectionName, 8)) found = true;
2838 } else {
2839 if (mystrncasecmp("Operator", h->SectionName, 8)) found = true;
2840 }
2841 if (UseUnicode) {
2842 EncodeUnicode(buffer,"FMStation",9);
2843 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2844 } else {
2845 if (mystrncasecmp("FMStation", h->SectionName, 9)) found = true;
2846 }
2847 if (UseUnicode) {
2848 EncodeUnicode(buffer,"GPRSPoint",9);
2849 if (mywstrncasecmp(buffer, h->SectionName, 9)) found = true;
2850 } else {
2851 if (mystrncasecmp("GPRSPoint", h->SectionName, 9)) found = true;
2852 }
2853 if (UseUnicode) {
2854 EncodeUnicode(buffer,"Note",4);
2855 if (mywstrncasecmp(buffer, h->SectionName, 4)) found = true;
2856 } else {
2857 if (mystrncasecmp("Note", h->SectionName, 4)) found = true;
2858 }
2859 if (!found) return ERR_NOTIMPLEMENTED;
2860 }
2660 return ERR_NONE; 2861 return ERR_NONE;
2661} 2862}
2662 2863
2663/* ---------------------- backup files for SMS ----------------------------- */ 2864/* ---------------------- backup files for SMS ----------------------------- */
2664 2865
2665static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS) 2866static void ReadSMSBackupEntry(INI_Section *file_info, char *section, GSM_SMSMessage *SMS)
2666{ 2867{
2667 unsigned char buffer[10000], *readvalue; 2868 unsigned char buffer[10000], *readvalue;
2668 2869
2669 GSM_SetDefaultSMSData(SMS); 2870 GSM_SetDefaultSMSData(SMS);
2670 2871
2671 SMS->PDU = SMS_Submit; 2872 SMS->PDU = SMS_Submit;
2672 SMS->SMSC.Location = 0; 2873 SMS->SMSC.Location = 0;
2673 sprintf(buffer,"SMSC"); 2874 sprintf(buffer,"SMSC");
2674 ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false); 2875 ReadBackupText(file_info, section, buffer, SMS->SMSC.Number, false);
2675 sprintf(buffer,"ReplySMSC"); 2876 sprintf(buffer,"ReplySMSC");
2676 SMS->ReplyViaSameSMSC = false; 2877 SMS->ReplyViaSameSMSC = false;
2677 readvalue = ReadCFGText(file_info, section, buffer, false); 2878 readvalue = ReadCFGText(file_info, section, buffer, false);
2678 if (readvalue!=NULL) { 2879 if (readvalue!=NULL) {
2679 if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true; 2880 if (mystrncasecmp(readvalue,"True",0)) SMS->ReplyViaSameSMSC = true;
2680 } 2881 }
2681 sprintf(buffer,"Class"); 2882 sprintf(buffer,"Class");
2682 SMS->Class = -1; 2883 SMS->Class = -1;
2683 readvalue = ReadCFGText(file_info, section, buffer, false); 2884 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
@@ -52,221 +52,239 @@ void GSM_FreeBackup(GSM_Backup *backup)
52 while (backup->SMSC[i]!=NULL) { 52 while (backup->SMSC[i]!=NULL) {
53 free(backup->SMSC[i]); 53 free(backup->SMSC[i]);
54 backup->SMSC[i] = NULL; 54 backup->SMSC[i] = NULL;
55 i++; 55 i++;
56 } 56 }
57 i=0; 57 i=0;
58 while (backup->WAPBookmark[i]!=NULL) { 58 while (backup->WAPBookmark[i]!=NULL) {
59 free(backup->WAPBookmark[i]); 59 free(backup->WAPBookmark[i]);
60 backup->WAPBookmark[i] = NULL; 60 backup->WAPBookmark[i] = NULL;
61 i++; 61 i++;
62 } 62 }
63 i=0; 63 i=0;
64 while (backup->WAPSettings[i]!=NULL) { 64 while (backup->WAPSettings[i]!=NULL) {
65 free(backup->WAPSettings[i]); 65 free(backup->WAPSettings[i]);
66 backup->WAPSettings[i] = NULL; 66 backup->WAPSettings[i] = NULL;
67 i++; 67 i++;
68 } 68 }
69 i=0; 69 i=0;
70 while (backup->MMSSettings[i]!=NULL) { 70 while (backup->MMSSettings[i]!=NULL) {
71 free(backup->MMSSettings[i]); 71 free(backup->MMSSettings[i]);
72 backup->MMSSettings[i] = NULL; 72 backup->MMSSettings[i] = NULL;
73 i++; 73 i++;
74 } 74 }
75 i=0; 75 i=0;
76 while (backup->SyncMLSettings[i]!=NULL) {
77 free(backup->SyncMLSettings[i]);
78 backup->SyncMLSettings[i] = NULL;
79 i++;
80 }
81 i=0;
82 while (backup->ChatSettings[i]!=NULL) {
83 free(backup->ChatSettings[i]);
84 backup->ChatSettings[i] = NULL;
85 i++;
86 }
87 i=0;
76 while (backup->Ringtone[i]!=NULL) { 88 while (backup->Ringtone[i]!=NULL) {
77 free(backup->Ringtone[i]); 89 free(backup->Ringtone[i]);
78 backup->Ringtone[i] = NULL; 90 backup->Ringtone[i] = NULL;
79 i++; 91 i++;
80 } 92 }
81 i=0; 93 i=0;
82 while (backup->ToDo[i]!=NULL) { 94 while (backup->ToDo[i]!=NULL) {
83 free(backup->ToDo[i]); 95 free(backup->ToDo[i]);
84 backup->ToDo[i] = NULL; 96 backup->ToDo[i] = NULL;
85 i++; 97 i++;
86 } 98 }
87 i=0; 99 i=0;
88 while (backup->Profiles[i]!=NULL) { 100 while (backup->Profiles[i]!=NULL) {
89 free(backup->Profiles[i]); 101 free(backup->Profiles[i]);
90 backup->Profiles[i] = NULL; 102 backup->Profiles[i] = NULL;
91 i++; 103 i++;
92 } 104 }
93 i=0; 105 i=0;
94 while (backup->FMStation[i]!=NULL) { 106 while (backup->FMStation[i]!=NULL) {
95 free(backup->FMStation[i]); 107 free(backup->FMStation[i]);
96 backup->FMStation[i] = NULL; 108 backup->FMStation[i] = NULL;
97 i++; 109 i++;
98 } 110 }
99 if (backup->StartupLogo!=NULL) { 111 if (backup->StartupLogo!=NULL) {
100 free(backup->StartupLogo); 112 free(backup->StartupLogo);
101 backup->StartupLogo = NULL; 113 backup->StartupLogo = NULL;
102 } 114 }
103 if (backup->OperatorLogo!=NULL) { 115 if (backup->OperatorLogo!=NULL) {
104 free(backup->OperatorLogo); 116 free(backup->OperatorLogo);
105 backup->OperatorLogo = NULL; 117 backup->OperatorLogo = NULL;
106 } 118 }
107 i=0; 119 i=0;
108 while (backup->GPRSPoint[i]!=NULL) { 120 while (backup->GPRSPoint[i]!=NULL) {
109 free(backup->GPRSPoint[i]); 121 free(backup->GPRSPoint[i]);
110 backup->GPRSPoint[i] = NULL; 122 backup->GPRSPoint[i] = NULL;
111 i++; 123 i++;
112 } 124 }
113 i=0; 125 i=0;
114 while (backup->Note[i]!=NULL) { 126 while (backup->Note[i]!=NULL) {
115 free(backup->Note[i]); 127 free(backup->Note[i]);
116 backup->Note[i] = NULL; 128 backup->Note[i] = NULL;
117 i++; 129 i++;
118 } 130 }
119} 131}
120 132
121GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode) 133GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode)
122{ 134{
123 if (strstr(FileName,".lmb")) { 135 if (mystrcasestr(FileName,".lmb")) {
124 return SaveLMB(FileName,backup); 136 return SaveLMB(FileName,backup);
125 } else if (strstr(FileName,".vcs")) { 137 } else if (mystrcasestr(FileName,".vcs")) {
126 return SaveVCalendar(FileName,backup); 138 return SaveVCalendar(FileName,backup);
127 } else if (strstr(FileName,".vcf")) { 139 } else if (mystrcasestr(FileName,".vcf")) {
128 return SaveVCard(FileName,backup); 140 return SaveVCard(FileName,backup);
129 } else if (strstr(FileName,".ldif")) { 141 } else if (mystrcasestr(FileName,".ldif")) {
130 return SaveLDIF(FileName,backup); 142 return SaveLDIF(FileName,backup);
131 } else if (strstr(FileName,".ics")) { 143 } else if (mystrcasestr(FileName,".ics")) {
132 return SaveICS(FileName,backup); 144 return SaveICS(FileName,backup);
133 } else { 145 } else {
134 return SaveBackup(FileName,backup, UseUnicode); 146 return SaveBackup(FileName,backup, UseUnicode);
135 } 147 }
136} 148}
137 149
138GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup) 150GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup)
139{ 151{
140 FILE *file; 152 FILE *file;
141 unsigned charbuffer[300]; 153 unsigned charbuffer[300];
142 154
143 file = fopen(FileName, "rb"); 155 file = fopen(FileName, "rb");
144 if (file == NULL) return ERR_CANTOPENFILE; 156 if (file == NULL) return ERR_CANTOPENFILE;
145 fread(buffer, 1, 9, file); /* Read the header of the file. */ 157 fread(buffer, 1, 9, file); /* Read the header of the file. */
146 fclose(file); 158 fclose(file);
147 159
148 GSM_ClearBackup(backup); 160 GSM_ClearBackup(backup);
149 161
150 /* Attempt to identify filetype */ 162 /* Attempt to identify filetype */
151 if (strstr(FileName,".vcs")) { 163 if (mystrcasestr(FileName,".vcs")) {
152 return LoadVCalendar(FileName,backup); 164 return LoadVCalendar(FileName,backup);
153 } else if (strstr(FileName,".vcf")) { 165 } else if (mystrcasestr(FileName,".vcf")) {
154 return LoadVCard(FileName,backup); 166 return LoadVCard(FileName,backup);
155 } else if (strstr(FileName,".ldif")) { 167 } else if (mystrcasestr(FileName,".ldif")) {
156 return LoadLDIF(FileName,backup); 168 return LoadLDIF(FileName,backup);
157 } else if (strstr(FileName,".ics")) { 169 } else if (mystrcasestr(FileName,".ics")) {
158 return LoadICS(FileName,backup); 170 return LoadICS(FileName,backup);
159 } else if (memcmp(buffer, "LMB ",4)==0) { 171 } else if (memcmp(buffer, "LMB ",4)==0) {
160 return LoadLMB(FileName,backup); 172 return LoadLMB(FileName,backup);
161 } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) { 173 } else if (buffer[0] == 0xFE && buffer[1] == 0xFF) {
162 return LoadBackup(FileName,backup,true); 174 return LoadBackup(FileName,backup,true);
163 } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) { 175 } else if (buffer[0] == 0xFF && buffer[1] == 0xFE) {
164 return LoadBackup(FileName,backup,true); 176 return LoadBackup(FileName,backup,true);
165 } else { 177 } else {
166 return LoadBackup(FileName,backup,false); 178 return LoadBackup(FileName,backup,false);
167 } 179 }
168} 180}
169 181
170void GSM_ClearBackup(GSM_Backup *backup) 182void GSM_ClearBackup(GSM_Backup *backup)
171{ 183{
172 backup->PhonePhonebook[0] = NULL; 184 backup->PhonePhonebook[0] = NULL;
173 backup->SIMPhonebook[0] = NULL; 185 backup->SIMPhonebook[0] = NULL;
174 backup->Calendar[0] = NULL; 186 backup->Calendar[0] = NULL;
175 backup->CallerLogos[0] = NULL; 187 backup->CallerLogos[0] = NULL;
176 backup->SMSC [0] = NULL; 188 backup->SMSC [0] = NULL;
177 backup->WAPBookmark[0] = NULL; 189 backup->WAPBookmark[0] = NULL;
178 backup->WAPSettings[0] = NULL; 190 backup->WAPSettings[0] = NULL;
179 backup->MMSSettings[0] = NULL; 191 backup->MMSSettings[0] = NULL;
192 backup->SyncMLSettings[0] = NULL;
193 backup->ChatSettings[0] = NULL;
180 backup->Ringtone[0] = NULL; 194 backup->Ringtone[0] = NULL;
181 backup->Profiles[0] = NULL; 195 backup->Profiles[0] = NULL;
182 backup->ToDo [0] = NULL; 196 backup->ToDo [0] = NULL;
183 backup->GPRSPoint[0] = NULL; 197 backup->GPRSPoint[0] = NULL;
184 backup->FMStation[0] = NULL; 198 backup->FMStation[0] = NULL;
185 backup->Note [0] = NULL; 199 backup->Note [0] = NULL;
186 backup->StartupLogo = NULL; 200 backup->StartupLogo = NULL;
187 backup->OperatorLogo = NULL; 201 backup->OperatorLogo = NULL;
188 202
189 backup->Creator [0] = 0; 203 backup->Creator [0] = 0;
190 backup->IMEI [0] = 0; 204 backup->IMEI [0] = 0;
191 backup->Model [0] = 0; 205 backup->Model [0] = 0;
192 backup->DateTimeAvailable = false; 206 backup->DateTimeAvailable = false;
193 backup->MD5Original[0] = 0; 207 backup->MD5Original[0] = 0;
194 backup->MD5Calculated[0] = 0; 208 backup->MD5Calculated[0] = 0;
195} 209}
196 210
197void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info) 211void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info)
198{ 212{
199 info->UseUnicode= false; 213 info->UseUnicode= false;
200 info->IMEI = false; 214 info->IMEI = false;
201 info->Model = false; 215 info->Model = false;
202 info->DateTime = false; 216 info->DateTime = false;
203 info->PhonePhonebook = false; 217 info->PhonePhonebook = false;
204 info->SIMPhonebook = false; 218 info->SIMPhonebook = false;
205 info->ToDo = false; 219 info->ToDo = false;
206 info->Calendar = false; 220 info->Calendar = false;
207 info->CallerLogos = false; 221 info->CallerLogos = false;
208 info->SMSC = false; 222 info->SMSC = false;
209 info->WAPBookmark = false; 223 info->WAPBookmark = false;
210 info->WAPSettings = false; 224 info->WAPSettings = false;
211 info->MMSSettings = false; 225 info->MMSSettings = false;
226 info->SyncMLSettings = false;
227 info->ChatSettings = false;
212 info->Ringtone = false; 228 info->Ringtone = false;
213 info->StartupLogo = false; 229 info->StartupLogo = false;
214 info->OperatorLogo = false; 230 info->OperatorLogo = false;
215 info->Profiles = false; 231 info->Profiles = false;
216 info->FMStation = false; 232 info->FMStation = false;
217 info->GPRSPoint = false; 233 info->GPRSPoint = false;
218 info->Note = false; 234 info->Note = false;
219 235
220 if (strstr(FileName,".lmb")) { 236 if (strstr(FileName,".lmb")) {
221 info->PhonePhonebook = true; 237 info->PhonePhonebook = true;
222 info->SIMPhonebook = true; 238 info->SIMPhonebook = true;
223 info->CallerLogos = true; 239 info->CallerLogos = true;
224 info->StartupLogo = true; 240 info->StartupLogo = true;
225 } else if (strstr(FileName,".vcs")) { 241 } else if (strstr(FileName,".vcs")) {
226 info->ToDo = true; 242 info->ToDo = true;
227 info->Calendar = true; 243 info->Calendar = true;
228 } else if (strstr(FileName,".vcf")) { 244 } else if (strstr(FileName,".vcf")) {
229 info->PhonePhonebook= true; 245 info->PhonePhonebook= true;
230 } else if (strstr(FileName,".ics")) { 246 } else if (strstr(FileName,".ics")) {
231 info->ToDo = true; 247 info->ToDo = true;
232 info->Calendar = true; 248 info->Calendar = true;
233 } else if (strstr(FileName,".ldif")) { 249 } else if (strstr(FileName,".ldif")) {
234 info->PhonePhonebook= true; 250 info->PhonePhonebook= true;
235 } else { 251 } else {
236 info->UseUnicode= true; 252 info->UseUnicode= true;
237 info->IMEI = true; 253 info->IMEI = true;
238 info->Model = true; 254 info->Model = true;
239 info->DateTime = true; 255 info->DateTime = true;
240 info->PhonePhonebook = true; 256 info->PhonePhonebook = true;
241 info->SIMPhonebook = true; 257 info->SIMPhonebook = true;
242 info->ToDo = true; 258 info->ToDo = true;
243 info->Calendar = true; 259 info->Calendar = true;
244 info->CallerLogos = true; 260 info->CallerLogos = true;
245 info->SMSC = true; 261 info->SMSC = true;
246 info->WAPBookmark = true; 262 info->WAPBookmark = true;
247 info->WAPSettings = true; 263 info->WAPSettings = true;
248 info->MMSSettings = true; 264 info->MMSSettings = true;
265 info->SyncMLSettings = true;
266 info->ChatSettings = true;
249 info->Ringtone = true; 267 info->Ringtone = true;
250 info->StartupLogo = true; 268 info->StartupLogo = true;
251 info->OperatorLogo = true; 269 info->OperatorLogo = true;
252 info->Profiles = true; 270 info->Profiles = true;
253 info->FMStation = true; 271 info->FMStation = true;
254 info->GPRSPoint = true; 272 info->GPRSPoint = true;
255 info->Note = true; 273 info->Note = true;
256 } 274 }
257} 275}
258 276
259void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup) 277void GSM_GetBackupFileFeatures(char *FileName, GSM_Backup_Info *info, GSM_Backup *backup)
260{ 278{
261 GSM_GetBackupFormatFeatures(FileName, info); 279 GSM_GetBackupFormatFeatures(FileName, info);
262 280
263 if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false; 281 if (info->PhonePhonebook && backup->PhonePhonebook[0] == NULL) info->PhonePhonebook = false;
264 if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false; 282 if (info->SIMPhonebook && backup->SIMPhonebook[0] == NULL) info->SIMPhonebook = false;
265 if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false; 283 if (info->Calendar && backup->Calendar[0] == NULL) info->Calendar = false;
266 if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false; 284 if (info->ToDo && backup->ToDo[0] == NULL) info->ToDo = false;
267 if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false; 285 if (info->WAPBookmark && backup->WAPBookmark[0] == NULL) info->WAPBookmark = false;
268 if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false; 286 if (info->WAPSettings && backup->WAPSettings[0] == NULL) info->WAPSettings = false;
269 if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false; 287 if (info->MMSSettings && backup->MMSSettings[0] == NULL) info->MMSSettings = false;
270 if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false; 288 if (info->FMStation && backup->FMStation[0] == NULL) info->FMStation = false;
271 if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false; 289 if (info->GPRSPoint && backup->GPRSPoint[0] == NULL) info->GPRSPoint = false;
272 if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false; 290 if (info->Profiles && backup->Profiles[0] == NULL) info->Profiles = false;
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
@@ -8,41 +8,43 @@
8#ifdef GSM_ENABLE_BACKUP 8#ifdef GSM_ENABLE_BACKUP
9 9
10GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode); 10GSM_Error GSM_SaveBackupFile(char *FileName, GSM_Backup *backup, bool UseUnicode);
11GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup); 11GSM_Error GSM_ReadBackupFile(char *FileName, GSM_Backup *backup);
12 12
13void GSM_ClearBackup (GSM_Backup *backup); 13void GSM_ClearBackup (GSM_Backup *backup);
14void GSM_FreeBackup (GSM_Backup *backup); 14void GSM_FreeBackup (GSM_Backup *backup);
15 15
16typedef struct { 16typedef struct {
17 bool UseUnicode; 17 bool UseUnicode;
18 18
19 bool IMEI; 19 bool IMEI;
20 bool Model; 20 bool Model;
21 bool DateTime; 21 bool DateTime;
22 bool ToDo; 22 bool ToDo;
23 bool PhonePhonebook; 23 bool PhonePhonebook;
24 bool SIMPhonebook; 24 bool SIMPhonebook;
25 bool Calendar; 25 bool Calendar;
26 bool CallerLogos; 26 bool CallerLogos;
27 bool SMSC; 27 bool SMSC;
28 bool WAPBookmark; 28 bool WAPBookmark;
29 bool Profiles; 29 bool Profiles;
30 bool WAPSettings; 30 bool WAPSettings;
31 bool MMSSettings; 31 bool MMSSettings;
32 bool SyncMLSettings;
33 bool ChatSettings;
32 bool Ringtone; 34 bool Ringtone;
33 bool StartupLogo; 35 bool StartupLogo;
34 bool OperatorLogo; 36 bool OperatorLogo;
35 bool FMStation; 37 bool FMStation;
36 bool GPRSPoint; 38 bool GPRSPoint;
37 bool Note; 39 bool Note;
38} GSM_Backup_Info; 40} GSM_Backup_Info;
39 41
40void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info); 42void GSM_GetBackupFormatFeatures(char *FileName, GSM_Backup_Info *info);
41void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup); 43void GSM_GetBackupFileFeatures (char *FileName, GSM_Backup_Info *info, GSM_Backup *backup);
42 44
43#endif 45#endif
44#endif 46#endif
45 47
46/* How should editor hadle tabs in this file? Add editor commands here. 48/* How should editor hadle tabs in this file? Add editor commands here.
47 * vim: noexpandtab sw=8 ts=8 sts=8: 49 * vim: noexpandtab sw=8 ts=8 sts=8:
48 */ 50 */
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h
index 067a4a4..0a41b7b 100644
--- a/gammu/emb/common/service/gsmcal.h
+++ b/gammu/emb/common/service/gsmcal.h
@@ -384,49 +384,49 @@ typedef struct {
384 384
385void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); 385void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone);
386 386
387typedef enum { 387typedef enum {
388 Nokia_VToDo = 1, 388 Nokia_VToDo = 1,
389 SonyEricsson_VToDo 389 SonyEricsson_VToDo
390} GSM_VToDoVersion; 390} GSM_VToDoVersion;
391 391
392GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); 392GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version);
393 393
394/** 394/**
395 * Status of to do entries. 395 * Status of to do entries.
396 */ 396 */
397typedef struct { 397typedef struct {
398 /** 398 /**
399 * Number of used positions. 399 * Number of used positions.
400 */ 400 */
401 int Used; 401 int Used;
402} GSM_ToDoStatus; 402} GSM_ToDoStatus;
403 403
404/* --------------------------- note ---------------------------------------- */ 404/* --------------------------- note ---------------------------------------- */
405 405
406typedef struct { 406typedef struct {
407 int Location; 407 int Location;
408 char Text[100]; 408 char Text[3000*2];
409} GSM_NoteEntry; 409} GSM_NoteEntry;
410 410
411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); 411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note);
412 412
413/* --------------------------- alarm --------------------------------------- */ 413/* --------------------------- alarm --------------------------------------- */
414 414
415/** 415/**
416 * Alarm values. 416 * Alarm values.
417 */ 417 */
418typedef struct { 418typedef struct {
419 /** 419 /**
420 * Location where it is stored. 420 * Location where it is stored.
421 */ 421 */
422 int Location; 422 int Location;
423 /** 423 /**
424 * Date and time of alarm. 424 * Date and time of alarm.
425 */ 425 */
426 GSM_DateTime DateTime; 426 GSM_DateTime DateTime;
427 /** 427 /**
428 * Whether it repeats each day. 428 * Whether it repeats each day.
429 */ 429 */
430 bool Repeating; 430 bool Repeating;
431 /** 431 /**
432 * Text that is shown on display. 432 * Text that is shown on display.
diff --git a/gammu/emb/common/service/gsmdata.c b/gammu/emb/common/service/gsmdata.c
index 94e9b7b..9303b57 100644
--- a/gammu/emb/common/service/gsmdata.c
+++ b/gammu/emb/common/service/gsmdata.c
@@ -225,95 +225,173 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W
225 Buffer[(*Length)++] = 0x7C; //TYPE = MMSURL 225 Buffer[(*Length)++] = 0x7C; //TYPE = MMSURL
226 } else { 226 } else {
227 Buffer[(*Length)++] = 0x07; //TYPE = URL 227 Buffer[(*Length)++] = 0x07; //TYPE = URL
228 } 228 }
229 Buffer[(*Length)++] = 0x11; //VALUE 229 Buffer[(*Length)++] = 0x11; //VALUE
230 Buffer[(*Length)++] = 0x03; //Inline string 230 Buffer[(*Length)++] = 0x03; //Inline string
231 sprintf(buffer,"%s",DecodeUnicodeString(settings->HomePage)); 231 sprintf(buffer,"%s",DecodeUnicodeString(settings->HomePage));
232 for (i=0;i<(int)strlen(buffer);i++) { 232 for (i=0;i<(int)strlen(buffer);i++) {
233 Buffer[(*Length)++] = buffer[i];//Text 233 Buffer[(*Length)++] = buffer[i];//Text
234 } 234 }
235 Buffer[(*Length)++] = 0x00; //END Inline string 235 Buffer[(*Length)++] = 0x00; //END Inline string
236 Buffer[(*Length)++] = 0x01; //END PARMeter 236 Buffer[(*Length)++] = 0x01; //END PARMeter
237 237
238 /* ISP_NAME (name) */ 238 /* ISP_NAME (name) */
239 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes 239 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
240 Buffer[(*Length)++] = 0x08; //TYPE=NAME 240 Buffer[(*Length)++] = 0x08; //TYPE=NAME
241 Buffer[(*Length)++] = 0x01; //END PARMeter 241 Buffer[(*Length)++] = 0x01; //END PARMeter
242 /* Settings name */ 242 /* Settings name */
243 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title)); 243 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title));
244 Buffer[(*Length)++] = 0x01; //END PARMeter 244 Buffer[(*Length)++] = 0x01; //END PARMeter
245 Buffer[(*Length)++] = 0x01; //END PARMeter 245 Buffer[(*Length)++] = 0x01; //END PARMeter
246} 246}
247 247
248/* http://forum.nokia.com: OTA Settings 7.0 */ 248/* http://forum.nokia.com: OTA Settings 7.0 */
249/* first it used default/ISO coding */
250/* Joergen Thomsen changed to UTF8 */
249void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark) 251void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark)
250{ 252{
251 unsigned charbuffer[100]; 253 unsigned charbuffer[100];
252 bool UnicodeCoding = false;
253 254
254 EncodeUTF8QuotedPrintable(buffer,bookmark->Title); 255 // bool UnicodeCoding = false;
255 if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true; 256 //EncodeUTF8QuotedPrintable(buffer,bookmark->Title);
257 //if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true;
256 258
257 Buffer[(*Length)++] = 0x01; //Push ID 259 Buffer[(*Length)++] = 0x01; //Push ID
258 Buffer[(*Length)++] = 0x06; //PDU Type (push) 260 Buffer[(*Length)++] = 0x06; //PDU Type (push)
259 Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers) 261 Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers)
260 strcpy(Buffer+(*Length),"\x1F\x2B"); 262 strcpy(Buffer+(*Length),"\x1F\x2B");
261 (*Length)=(*Length)+2; //Value length 263 (*Length)=(*Length)+2; //Value length
262 strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks"); 264 strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks");
263 (*Length)=(*Length)+40; //MIME-Type 265 (*Length)=(*Length)+40; //MIME-Type
264 Buffer[(*Length)++] = 0x00; //end inline string 266 Buffer[(*Length)++] = 0x00; //end inline string
265 strcpy(Buffer+(*Length),"\x81\xEA"); 267 strcpy(Buffer+(*Length),"\x81\xEA");
266 (*Length)=(*Length)+2; //charset UTF-8 short int. 268 (*Length)=(*Length)+2; //charset UTF-8 short int.
267 269
270 /* removed by Joergen Thomsen */
268 /* Block from sniffs. UNKNOWN */ 271 /* Block from sniffs. UNKNOWN */
269 if (!UnicodeCoding) { 272 //if (!UnicodeCoding) {
270 Buffer[(*Length)++] = 0x00; 273 // Buffer[(*Length)++] = 0x00;
271 Buffer[(*Length)++] = 0x01; 274 // Buffer[(*Length)++] = 0x01;
272 } else { 275 //} else {
273 strcpy(Buffer+(*Length),"\x01\x01\x87\x68"); 276 // strcpy(Buffer+(*Length),"\x01\x01\x87\x68");
274 (*Length)=(*Length)+4; 277 // (*Length)=(*Length)+4;
275 } 278 //}
276 Buffer[(*Length)++] = 0x00; 279 //Buffer[(*Length)++] = 0x00;
280
281 /* added by Joergen Thomsen */
282 Buffer[(*Length)++] = 0x01; // Version WBXML 1.1
283 Buffer[(*Length)++] = 0x01; // Unknown public identifier
284 Buffer[(*Length)++] = 0x6A; // charset UTF-8
285 Buffer[(*Length)++] = 0x00; // string table length
277 286
278 Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content 287 Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content
279 /* URL */ 288 /* URL */
280 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes 289 Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes
281 Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK 290 Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK
282 Buffer[(*Length)++] = 0x01; //END PARMeter 291 Buffer[(*Length)++] = 0x01; //END PARMeter
283 if (!UnicodeCoding) { 292
284 /* TITLE */ 293 /* removed by Joergen Thomsen */
285 AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title)); 294 // if (!UnicodeCoding) {
286 /* URL */ 295 // /* TITLE */
287 AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address)); 296 // AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title));
288 } else { 297 // /* URL */
298 // AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address));
299 // } else {
300 // /* TITLE */
301 // AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1);
302 // /* URL */
303 // AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1);
304 // }
305
306 /* added by Joergen Thomsen */
289 /* TITLE */ 307 /* TITLE */
290 AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1); 308 EncodeUTF8(buffer, bookmark->Title);
309 AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer));
291 /* URL */ 310 /* URL */
292 AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1); 311 EncodeUTF8(buffer, bookmark->Address);
312 AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer));
313
314 Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC)
315 Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC-LIST)
293 } 316 }
294 Buffer[(*Length)++] = 0x01; //END PARMeter 317
295 Buffer[(*Length)++] = 0x01; //END PARMeter 318void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL)
319{
320 int i;
321
322 Buffer[(*Length)++] = 0x01; //Push ID
323 Buffer[(*Length)++] = 0x06; //PDU Type (push)
324 Buffer[(*Length)++] = 28; //Headers length (content type + headers)
325 strcpy(Buffer+(*Length),"\x1F\x23");
326 (*Length)=(*Length)+2; //Value length
327 strcpy(Buffer+(*Length),"application/vnd.wap.sic");
328 (*Length)=(*Length)+23; //MIME-Type
329 Buffer[(*Length)++] = 0x00; //end inline string
330 strcpy(Buffer+(*Length),"\x81\xEA");
331 (*Length)=(*Length)+2; //charset UTF-8 short int.
332
333 Buffer[(*Length)++] = 0x02; // WBXML 1.2
334 Buffer[(*Length)++] = 0x05; // SI 1.0 Public Identifier
335 Buffer[(*Length)++] = 0x6A; // charset UTF-8
336 Buffer[(*Length)++] = 0x00; // string table length
337 Buffer[(*Length)++] = 0x45; // SI with content
338 Buffer[(*Length)++] = 0xC6; // indication with content and attributes
339 Buffer[(*Length)++] = 0x0B;// address
340 Buffer[(*Length)++] = 0x03; // Inline string
341 for (i=0;i<(int)strlen(URL);i++) {
342 Buffer[(*Length)++] = URL[i];//Text
343 }
344 Buffer[(*Length)++] = 0x00; // END Inline string
345
346#ifdef XXX
347 Buffer[(*Length)++] = 0x0A;// created...
348 Buffer[(*Length)++] = 0xC3;// OPAQUE
349 Buffer[(*Length)++] = 0x07;// length
350 Buffer[(*Length)++] = 0x19;// year
351 Buffer[(*Length)++] = 0x80;// year
352 Buffer[(*Length)++] = 0x21;// month
353 Buffer[(*Length)++] = 0x12;// ..
354 Buffer[(*Length)++] = 0x00;// ..
355 Buffer[(*Length)++] = 0x00;// ..
356 Buffer[(*Length)++] = 0x00;// ..
357 Buffer[(*Length)++] = 0x10;// expires
358 Buffer[(*Length)++] = 0xC3;// OPAQUE
359 Buffer[(*Length)++] = 0x04;// length
360 Buffer[(*Length)++] = 0x20;// year
361 Buffer[(*Length)++] = 0x10;// year
362 Buffer[(*Length)++] = 0x06;// month
363 Buffer[(*Length)++] = 0x25;// day
364#endif
365
366 Buffer[(*Length)++] = 0x01; // END (indication)
367 Buffer[(*Length)++] = 0x03; // Inline string
368 for (i=0;i<(int)strlen(Text);i++) {
369 Buffer[(*Length)++] = Text[i];//Text
370 }
371 Buffer[(*Length)++] = 0x00; // END Inline string
372 Buffer[(*Length)++] = 0x01; // END (indication)
373 Buffer[(*Length)++] = 0x01; // END (SI)
296} 374}
297 375
298void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) 376void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length)
299{ 377{
300 int i; 378 int i;
301 379
302 strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F"); 380 strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F");
303 (*Length)=(*Length)+4; 381 (*Length)=(*Length)+4;
304 382
305 /* Unique MMS ID ? */ 383 /* Unique MMS ID ? */
306 strcpy(Buffer+(*Length),"123456789"); 384 strcpy(Buffer+(*Length),"123456789");
307 (*Length)=(*Length)+9; 385 (*Length)=(*Length)+9;
308 Buffer[(*Length)++] = 0x00; 386 Buffer[(*Length)++] = 0x00;
309 387
310 strcpy(Buffer+(*Length),"\x8D\x90\x89"); 388 strcpy(Buffer+(*Length),"\x8D\x90\x89");
311 (*Length)=(*Length)+3; 389 (*Length)=(*Length)+3;
312 390
313 strcpy(Buffer+(*Length),"\x01\x81\x86\x81\x96"); 391 strcpy(Buffer+(*Length),"\x01\x81\x86\x81\x96");
314 (*Length)=(*Length)+5; 392 (*Length)=(*Length)+5;
315 393
316 if (UnicodeLength(Info->Subject) != 0) { 394 if (UnicodeLength(Info->Subject) != 0) {
317 sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Subject)); 395 sprintf(Buffer+(*Length),"%s",DecodeUnicodeString(Info->Subject));
318 (*Length)=(*Length)+UnicodeLength(Info->Subject); 396 (*Length)=(*Length)+UnicodeLength(Info->Subject);
319 Buffer[(*Length)++] = 0x00; 397 Buffer[(*Length)++] = 0x00;
diff --git a/gammu/emb/common/service/gsmdata.h b/gammu/emb/common/service/gsmdata.h
index f5f8e07..e81589f 100644
--- a/gammu/emb/common/service/gsmdata.h
+++ b/gammu/emb/common/service/gsmdata.h
@@ -67,48 +67,50 @@ typedef struct {
67 67
68void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_WAPSettings *settings, bool MMS); 68void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_WAPSettings *settings, bool MMS);
69 69
70/* -------------------------------- WAP Bookmark --------------------------- */ 70/* -------------------------------- WAP Bookmark --------------------------- */
71 71
72typedef struct { 72typedef struct {
73 char Address [(255+1)*2]; 73 char Address [(255+1)*2];
74 char Title [(50+1)*2]; 74 char Title [(50+1)*2];
75 int Location; 75 int Location;
76} GSM_WAPBookmark; 76} GSM_WAPBookmark;
77 77
78 void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); 78 void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark);
79 GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark); 79 GSM_Error GSM_EncodeURLFile (unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark);
80 80
81/* ------------------------------ MMS Indicator ---------------------------- */ 81/* ------------------------------ MMS Indicator ---------------------------- */
82 82
83typedef struct { 83typedef struct {
84 unsigned char Address[500]; 84 unsigned char Address[500];
85 unsigned char Title[200]; 85 unsigned char Title[200];
86 unsigned char Sender[200]; 86 unsigned char Sender[200];
87} GSM_MMSIndicator; 87} GSM_MMSIndicator;
88 88
89void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator); 89void GSM_EncodeMMSIndicatorSMSText(unsigned char *Buffer, int *Length, GSM_MMSIndicator Indicator);
90 90
91void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL);
92
91/* ------------------------------ MMS file --------------------------------- */ 93/* ------------------------------ MMS file --------------------------------- */
92 94
93#define MAX_MULTI_MMS 20 95#define MAX_MULTI_MMS 20
94 96
95typedef enum { 97typedef enum {
96 MMS_Text = 1, 98 MMS_Text = 1,
97 MMS_Bitmap_JPG 99 MMS_Bitmap_JPG
98} EncodeMultiPartMMSID; 100} EncodeMultiPartMMSID;
99 101
100typedef struct { 102typedef struct {
101 EncodeMultiPartMMSID ID; 103 EncodeMultiPartMMSID ID;
102 104
103 GSM_File File; 105 GSM_File File;
104 unsigned char *Buffer; 106 unsigned char *Buffer;
105} EncodeMultiPartMMSEntry; 107} EncodeMultiPartMMSEntry;
106 108
107typedef struct { 109typedef struct {
108 /* Input values */ 110 /* Input values */
109 EncodeMultiPartMMSEntry Entries[MAX_MULTI_MMS]; 111 EncodeMultiPartMMSEntry Entries[MAX_MULTI_MMS];
110 int EntriesNum; 112 int EntriesNum;
111 113
112 unsigned char Source[200]; 114 unsigned char Source[200];
113 unsigned char Destination[200]; 115 unsigned char Destination[200];
114 unsigned char Subject[200]; 116 unsigned char Subject[200];
diff --git a/gammu/emb/common/service/gsmlogo.c b/gammu/emb/common/service/gsmlogo.c
index c992915..7c19967 100644
--- a/gammu/emb/common/service/gsmlogo.c
+++ b/gammu/emb/common/service/gsmlogo.c
@@ -1,28 +1,29 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <sys/stat.h>
5 6
6#include "../misc/misc.h" 7#include "../misc/misc.h"
7#include "../misc/coding/coding.h" 8#include "../misc/coding/coding.h"
8#include "gsmlogo.h" 9#include "gsmlogo.h"
9#include "gsmnet.h" 10#include "gsmnet.h"
10 11
11void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height) 12void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, int *width, int *height)
12{ 13{
13 *width = 0; 14 *width = 0;
14 *height= 0; 15 *height= 0;
15 switch (Type) { 16 switch (Type) {
16 case GSM_EMSSmallPicture: *width=8; *height=8; break; 17 case GSM_EMSSmallPicture: *width=8; *height=8; break;
17 case GSM_EMSMediumPicture: *width=16; *height=16; break; 18 case GSM_EMSMediumPicture: *width=16; *height=16; break;
18 case GSM_EMSBigPicture : *width=32; *height=32; break; 19 case GSM_EMSBigPicture : *width=32; *height=32; break;
19 case GSM_NokiaOperatorLogo: 20 case GSM_NokiaOperatorLogo:
20 case GSM_NokiaCallerLogo: *width=72; *height=14; break; 21 case GSM_NokiaCallerLogo: *width=72; *height=14; break;
21 case GSM_NokiaPictureImage: *width=72; *height=28; break; 22 case GSM_NokiaPictureImage: *width=72; *height=28; break;
22 case GSM_Nokia7110OperatorLogo: 23 case GSM_Nokia7110OperatorLogo:
23 case GSM_Nokia6510OperatorLogo: *width=78; *height=21; break; 24 case GSM_Nokia6510OperatorLogo: *width=78; *height=21; break;
24 case GSM_NokiaStartupLogo: *width=84; *height=48; break; 25 case GSM_NokiaStartupLogo: *width=84; *height=48; break;
25 case GSM_Nokia6210StartupLogo: *width=96; *height=60; break; 26 case GSM_Nokia6210StartupLogo: *width=96; *height=60; break;
26 case GSM_Nokia7110StartupLogo: *width=96; *height=65; break; 27 case GSM_Nokia7110StartupLogo: *width=96; *height=65; break;
27 case GSM_EMSVariablePicture : break; 28 case GSM_EMSVariablePicture : break;
28 case GSM_AlcatelBMMIPicture : break; 29 case GSM_AlcatelBMMIPicture : break;
@@ -140,48 +141,49 @@ void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *B
140 case GSM_NokiaCallerLogo : Bitmap->Type=GSM_CallerGroupLogo;break; 141 case GSM_NokiaCallerLogo : Bitmap->Type=GSM_CallerGroupLogo;break;
141 case GSM_AlcatelBMMIPicture : 142 case GSM_AlcatelBMMIPicture :
142 case GSM_NokiaStartupLogo: 143 case GSM_NokiaStartupLogo:
143 case GSM_Nokia7110StartupLogo: 144 case GSM_Nokia7110StartupLogo:
144 case GSM_Nokia6210StartupLogo : Bitmap->Type=GSM_StartupLogo; break; 145 case GSM_Nokia6210StartupLogo : Bitmap->Type=GSM_StartupLogo; break;
145 case GSM_NokiaPictureImage: 146 case GSM_NokiaPictureImage:
146 case GSM_EMSVariablePicture: 147 case GSM_EMSVariablePicture:
147 case GSM_EMSSmallPicture: 148 case GSM_EMSSmallPicture:
148 case GSM_EMSMediumPicture: 149 case GSM_EMSMediumPicture:
149 case GSM_EMSBigPicture : Bitmap->Type=GSM_PictureImage;break; 150 case GSM_EMSBigPicture : Bitmap->Type=GSM_PictureImage;break;
150 } 151 }
151 152
152 Bitmap->Location = 0; 153 Bitmap->Location = 0;
153 Bitmap->Text[0] = 0; 154 Bitmap->Text[0] = 0;
154 Bitmap->Text[1] = 0; 155 Bitmap->Text[1] = 0;
155 Bitmap->BitmapEnabled = false; 156 Bitmap->BitmapEnabled = false;
156 Bitmap->DefaultName = false; 157 Bitmap->DefaultName = false;
157 Bitmap->DefaultBitmap = false; 158 Bitmap->DefaultBitmap = false;
158 Bitmap->DefaultRingtone = false; 159 Bitmap->DefaultRingtone = false;
159 Bitmap->RingtoneID = 0; 160 Bitmap->RingtoneID = 0;
160 Bitmap->NetworkCode[0] = 0; 161 Bitmap->NetworkCode[0] = 0;
161 Bitmap->Sender[0] = 0; 162 Bitmap->Sender[0] = 0;
162 Bitmap->Sender[1] = 0; 163 Bitmap->Sender[1] = 0;
163 Bitmap->ID = 0; 164 Bitmap->ID = 0;
165 Bitmap->Name = NULL;
164 166
165 GSM_ClearBitmap(Bitmap); 167 GSM_ClearBitmap(Bitmap);
166 for (x=0;x<Bitmap->BitmapWidth;x++) { 168 for (x=0;x<Bitmap->BitmapWidth;x++) {
167 for (y=0;y<Bitmap->BitmapHeight;y++) { 169 for (y=0;y<Bitmap->BitmapHeight;y++) {
168 if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) { 170 if (PHONE_IsPointBitmap(Type, buffer, x, y, Bitmap->BitmapWidth, Bitmap->BitmapHeight)) {
169 GSM_SetPointBitmap(Bitmap,x,y); 171 GSM_SetPointBitmap(Bitmap,x,y);
170 } 172 }
171 } 173 }
172 } 174 }
173} 175}
174 176
175void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height) 177void PHONE_ClearBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, int width, int height)
176{ 178{
177 memset(buffer,0,PHONE_GetBitmapSize(Type,width,height)); 179 memset(buffer,0,PHONE_GetBitmapSize(Type,width,height));
178} 180}
179 181
180void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap) 182void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
181{ 183{
182 int width, height, x, y; 184 int width, height, x, y;
183 GSM_Bitmapdest; 185 GSM_Bitmapdest;
184 186
185 PHONE_GetBitmapWidthHeight(Type, &width, &height); 187 PHONE_GetBitmapWidthHeight(Type, &width, &height);
186 if (width == 0 && height == 0) { 188 if (width == 0 && height == 0) {
187 width = Bitmap->BitmapWidth; 189 width = Bitmap->BitmapWidth;
@@ -605,59 +607,59 @@ static GSM_Error savensl(FILE *file, GSM_MultiBitmap *bitmap)
605static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap) 607static GSM_Error savewbmp(FILE *file, GSM_MultiBitmap *bitmap)
606{ 608{
607 unsigned char buffer[4]; 609 unsigned char buffer[4];
608 610
609 buffer[0] = 0x00; 611 buffer[0] = 0x00;
610 buffer[1] = 0x00; 612 buffer[1] = 0x00;
611 buffer[2] = bitmap->Bitmap[0].BitmapWidth; 613 buffer[2] = bitmap->Bitmap[0].BitmapWidth;
612 buffer[3] = bitmap->Bitmap[0].BitmapHeight; 614 buffer[3] = bitmap->Bitmap[0].BitmapHeight;
613 fwrite(buffer,1,4,file); 615 fwrite(buffer,1,4,file);
614 616
615 PrivSaveNLMWBMP(file, &bitmap->Bitmap[0]); 617 PrivSaveNLMWBMP(file, &bitmap->Bitmap[0]);
616 618
617 return ERR_NONE; 619 return ERR_NONE;
618} 620}
619 621
620GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) 622GSM_Error GSM_SaveBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
621{ 623{
622 FILE *file; 624 FILE *file;
623 GSM_Error error=ERR_NONE; 625 GSM_Error error=ERR_NONE;
624 626
625 file = fopen(FileName, "wb"); 627 file = fopen(FileName, "wb");
626 if (file == NULL) return ERR_CANTOPENFILE; 628 if (file == NULL) return ERR_CANTOPENFILE;
627 629
628 /* Attempt to identify filetype */ 630 /* Attempt to identify filetype */
629 if (strstr(FileName,".nlm")) { 631 if (mystrcasestr(FileName,".nlm")) {
630 error=savenlm(file,bitmap); 632 error=savenlm(file,bitmap);
631 } else if (strstr(FileName,".ngg")) { 633 } else if (mystrcasestr(FileName,".ngg")) {
632 error=savengg(file,bitmap); 634 error=savengg(file,bitmap);
633 } else if (strstr(FileName,".nol")) { 635 } else if (mystrcasestr(FileName,".nol")) {
634 error=savenol(file,bitmap); 636 error=savenol(file,bitmap);
635 } else if (strstr(FileName,".xpm")) { 637 } else if (mystrcasestr(FileName,".xpm")) {
636 error=savexpm(file,bitmap); 638 error=savexpm(file,bitmap);
637 } else if (strstr(FileName,".nsl")) { 639 } else if (mystrcasestr(FileName,".nsl")) {
638 error=savensl(file,bitmap); 640 error=savensl(file,bitmap);
639 } else if (strstr(FileName,".wbmp")) { 641 } else if (mystrcasestr(FileName,".wbmp")) {
640 error=savewbmp(file,bitmap); 642 error=savewbmp(file,bitmap);
641 } else { 643 } else {
642 error=savebmp(file,bitmap); 644 error=savebmp(file,bitmap);
643 } 645 }
644 fclose(file); 646 fclose(file);
645 647
646 return error; 648 return error;
647} 649}
648 650
649GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap) 651GSM_Error BMP2Bitmap(unsigned char *buffer, FILE *file,GSM_Bitmap *bitmap)
650{ 652{
651 bool first_white,isfile=false; 653 bool first_white,isfile=false;
652 unsigned char buff[34]; 654 unsigned char buff[34];
653 int w,h,pos,y,x,i,buffpos=0; 655 int w,h,pos,y,x,i,buffpos=0;
654#ifdef DEBUG 656#ifdef DEBUG
655 int sizeimage=0; 657 int sizeimage=0;
656#endif 658#endif
657 659
658 if (bitmap->Type == GSM_None) bitmap->Type = GSM_StartupLogo; 660 if (bitmap->Type == GSM_None) bitmap->Type = GSM_StartupLogo;
659 if (file!=NULL) isfile=true; 661 if (file!=NULL) isfile=true;
660 if (isfile) { 662 if (isfile) {
661 fread(buff, 1, 34, file); 663 fread(buff, 1, 34, file);
662 } else { 664 } else {
663 memcpy(buff,buffer,34); 665 memcpy(buff,buffer,34);
@@ -934,70 +936,103 @@ static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap)
934 } 936 }
935 } 937 }
936 } 938 }
937 } 939 }
938 bitmap->Number = 1; 940 bitmap->Number = 1;
939 return(ERR_NONE); 941 return(ERR_NONE);
940} 942}
941 943
942static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap) 944static GSM_Error loadwbmp(FILE *file, GSM_MultiBitmap *bitmap)
943{ 945{
944 unsigned char buffer[10000]; 946 unsigned char buffer[10000];
945 947
946 fread(buffer,1,4,file); 948 fread(buffer,1,4,file);
947 bitmap->Bitmap[0].BitmapWidth = buffer[2]; 949 bitmap->Bitmap[0].BitmapWidth = buffer[2];
948 bitmap->Bitmap[0].BitmapHeight = buffer[3]; 950 bitmap->Bitmap[0].BitmapHeight = buffer[3];
949 bitmap->Number = 1; 951 bitmap->Number = 1;
950 952
951 fread(buffer,1,10000,file); 953 fread(buffer,1,10000,file);
952 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]); 954 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo, buffer, &bitmap->Bitmap[0]);
953 GSM_ReverseBitmap(&bitmap->Bitmap[0]); 955 GSM_ReverseBitmap(&bitmap->Bitmap[0]);
954 956
955 return ERR_NONE; 957 return ERR_NONE;
956} 958}
957 959
960static GSM_Error loadgif(FILE *file, GSM_MultiBitmap *bitmap)
961{
962 GSM_Bitmap *bmap = &bitmap->Bitmap[0];
963 char *buffer;
964 struct stat st;
965 int length;
966
967 dbgprintf("loading gif file\n");
968 fstat(fileno(file), &st);
969 bmap->BinaryPic.Length = length = st.st_size;
970 bmap->BinaryPic.Buffer = buffer = malloc(length);
971 if (bmap->BinaryPic.Buffer == NULL)
972 return ERR_MOREMEMORY;
973
974 fread(buffer, 1, length, file);
975 dbgprintf("Length %i name \"%s\"\n", length,
976 DecodeUnicodeString(bmap->Name));
977
978 bmap->Type = GSM_PictureBinary;
979 bmap->BinaryPic.Type = PICTURE_GIF;
980 bmap->BitmapWidth = 256 * buffer[7] + buffer[6];
981 bmap->BitmapHeight = 256 * buffer[9] + buffer[8];
982 bitmap->Number = 1;
983
984 return ERR_NONE;
985}
986
958GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap) 987GSM_Error GSM_ReadBitmapFile(char *FileName, GSM_MultiBitmap *bitmap)
959{ 988{
960 FILE *file; 989 FILE *file;
961 unsigned charbuffer[300]; 990 unsigned charbuffer[300];
962 991
963 file = fopen(FileName, "rb"); 992 file = fopen(FileName, "rb");
964 if (file == NULL) return ERR_CANTOPENFILE; 993 if (file == NULL) return ERR_CANTOPENFILE;
965 994
995 bitmap->Bitmap[0].Name = malloc((strlen(FileName) + 1) * 2);
996 if (bitmap->Bitmap[0].Name == NULL) return ERR_MOREMEMORY;
997 EncodeUnicode(bitmap->Bitmap[0].Name, FileName, strlen(FileName));
998
966 fread(buffer, 1, 9, file); /* Read the header of the file. */ 999 fread(buffer, 1, 9, file); /* Read the header of the file. */
967 rewind(file); 1000 rewind(file);
968 1001
969 bitmap->Bitmap[0].DefaultBitmap = false; 1002 bitmap->Bitmap[0].DefaultBitmap = false;
970 1003
971 /* Attempt to identify filetype */ 1004 /* Attempt to identify filetype */
972 if (memcmp(buffer, "BM",2)==0) { 1005 if (memcmp(buffer, "BM",2)==0) {
973 return loadbmp(file,bitmap); 1006 return loadbmp(file,bitmap);
974 } else if (buffer[0] == 0x00 && buffer[1] == 0x00) { 1007 } else if (buffer[0] == 0x00 && buffer[1] == 0x00) {
975 return loadwbmp(file,bitmap); 1008 return loadwbmp(file,bitmap);
976 } else if (memcmp(buffer, "NLM",3)==0) { 1009 } else if (memcmp(buffer, "NLM",3)==0) {
977 return loadnlm(file,bitmap); 1010 return loadnlm(file,bitmap);
978 } else if (memcmp(buffer, "NOL",3)==0) { 1011 } else if (memcmp(buffer, "NOL",3)==0) {
979 return loadnolngg(file,bitmap,true); 1012 return loadnolngg(file,bitmap,true);
980 } else if (memcmp(buffer, "NGG",3)==0) { 1013 } else if (memcmp(buffer, "NGG",3)==0) {
981 return loadnolngg(file,bitmap,false); 1014 return loadnolngg(file,bitmap,false);
982 } else if (memcmp(buffer, "FORM",4)==0) { 1015 } else if (memcmp(buffer, "FORM",4)==0) {
983 return loadnsl(file,bitmap); 1016 return loadnsl(file,bitmap);
1017 } else if (memcmp(buffer, "GIF",3)==0) {
1018 return loadgif(file,bitmap);
984 } 1019 }
985 return ERR_UNKNOWN; 1020 return ERR_UNKNOWN;
986} 1021}
987 1022
988void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length) 1023void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, int *Length)
989{ 1024{
990 int Width, Height; 1025 int Width, Height;
991 1026
992 Buffer[(*Length)++] = 0x00; 1027 Buffer[(*Length)++] = 0x00;
993 PHONE_GetBitmapWidthHeight(Type, &Width, &Height); 1028 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
994 Buffer[(*Length)++] = Width; 1029 Buffer[(*Length)++] = Width;
995 Buffer[(*Length)++] = Height; 1030 Buffer[(*Length)++] = Height;
996 Buffer[(*Length)++] = 0x01; 1031 Buffer[(*Length)++] = 0x01;
997 PHONE_EncodeBitmap(Type, Buffer + (*Length), Bitmap); 1032 PHONE_EncodeBitmap(Type, Buffer + (*Length), Bitmap);
998 (*Length) = (*Length) + PHONE_GetBitmapSize(Type,0,0); 1033 (*Length) = (*Length) + PHONE_GetBitmapSize(Type,0,0);
999} 1034}
1000 1035
1001/* How should editor hadle tabs in this file? Add editor commands here. 1036/* How should editor hadle tabs in this file? Add editor commands here.
1002 * vim: noexpandtab sw=8 ts=8 sts=8: 1037 * vim: noexpandtab sw=8 ts=8 sts=8:
1003 */ 1038 */
diff --git a/gammu/emb/common/service/gsmlogo.h b/gammu/emb/common/service/gsmlogo.h
index b1b579d..6c6e2d8 100644
--- a/gammu/emb/common/service/gsmlogo.h
+++ b/gammu/emb/common/service/gsmlogo.h
@@ -1,72 +1,90 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_bitmaps_h 3#ifndef __gsm_bitmaps_h
4#define __gsm_bitmaps_h 4#define __gsm_bitmaps_h
5 5
6#include "../gsmcomon.h" 6#include "../gsmcomon.h"
7 7
8typedef enum {
9 PICTURE_BMP = 1,
10 PICTURE_GIF,
11 PICTURE_JPG,
12 PICTURE_ICN,
13 PICTURE_PNG
14} GSM_BinaryPicture_Types;
15
16typedef struct {
17 GSM_BinaryPicture_Types Type;
18 unsigned char *Buffer;
19 int Length;
20} GSM_BinaryPicture;
21
8/** 22/**
9 * Enum to handle all possible bitmaps, which are not saved in various filesystems. 23 * Enum to handle all possible bitmaps, which are not saved in various filesystems.
10 */ 24 */
11typedef enum { 25typedef enum {
12 GSM_None = 1, 26 GSM_None = 1,
13 /** 27 /**
14 * ID of static file in filesystem displayed during startup 28 * ID of static file in filesystem displayed during startup
15 */ 29 */
16 GSM_ColourStartupLogo_ID, 30 GSM_ColourStartupLogo_ID,
17 /** 31 /**
18 * Static mono bitmap/ID of animated mono bitmap displayed during startup 32 * Static mono bitmap/ID of animated mono bitmap displayed during startup
19 */ 33 */
20 GSM_StartupLogo, 34 GSM_StartupLogo,
21 /** 35 /**
22 * ID of static file in filesystem displayed instead of operator name 36 * ID of static file in filesystem displayed instead of operator name
23 */ 37 */
24 GSM_ColourOperatorLogo_ID, 38 GSM_ColourOperatorLogo_ID,
25 /** 39 /**
26 * Mono bitmap displayed instead of operator name 40 * Mono bitmap displayed instead of operator name
27 */ 41 */
28 GSM_OperatorLogo, 42 GSM_OperatorLogo,
29 /** 43 /**
30 * ID of static file in filesystem displayed as wallpaper 44 * ID of static file in filesystem displayed as wallpaper
31 */ 45 */
32 GSM_ColourWallPaper_ID, 46 GSM_ColourWallPaper_ID,
33 /** 47 /**
34 * Mono bitmap assigned to caller group 48 * Mono bitmap assigned to caller group
35 */ 49 */
36 GSM_CallerGroupLogo, 50 GSM_CallerGroupLogo,
37 /** 51 /**
38 * Text displayed during startup, which can't be removed from phone menu 52 * Text displayed during startup, which can't be removed from phone menu
39 */ 53 */
40 GSM_DealerNote_Text, 54 GSM_DealerNote_Text,
41 /** 55 /**
42 * Text displayed during startup 56 * Text displayed during startup
43 */ 57 */
44 GSM_WelcomeNote_Text, 58 GSM_WelcomeNote_Text,
45 /** 59 /**
46 * Image defined in Smart Messaging specification 60 * Image defined in Smart Messaging specification
47 */ 61 */
48 GSM_PictureImage 62 GSM_PictureImage,
63 /**
64 * Binary picture (BMP, GIF, etc.)
65 */
66 GSM_PictureBinary
49} GSM_Bitmap_Types; 67} GSM_Bitmap_Types;
50 68
51 #define GSM_BITMAP_SIZE(65+7)/8*96 69 #define GSM_BITMAP_SIZE(65+7)/8*96
52#define GSM_BITMAP_TEXT_LENGTH 128 70#define GSM_BITMAP_TEXT_LENGTH 128
53 71
54/** 72/**
55 * Structure for all possible bitmaps, which are not saved in various filesystems 73 * Structure for all possible bitmaps, which are not saved in various filesystems
56 */ 74 */
57typedef struct { 75typedef struct {
58 /** 76 /**
59 * For all: bitmap type 77 * For all: bitmap type
60 */ 78 */
61 GSM_Bitmap_Types Type; 79 GSM_Bitmap_Types Type;
62 /** 80 /**
63 * For caller group logos: number of group 81 * For caller group logos: number of group
64 * For startup logos: number of animated bitmap 82 * For startup logos: number of animated bitmap
65 */ 83 */
66 unsigned char Location; 84 unsigned char Location;
67 /** 85 /**
68 * For dealer/welcome note text: text 86 * For dealer/welcome note text: text
69 * For caller group logo: name of group 87 * For caller group logo: name of group
70 * For picture images: text assigned to it 88 * For picture images: text assigned to it
71 */ 89 */
72 unsigned char Text[2 * (GSM_BITMAP_TEXT_LENGTH + 1)]; 90 unsigned char Text[2 * (GSM_BITMAP_TEXT_LENGTH + 1)];
@@ -94,48 +112,56 @@ typedef struct {
94 /** 112 /**
95 * For mono bitmaps: body of bitmap 113 * For mono bitmaps: body of bitmap
96 */ 114 */
97 unsigned char BitmapPoints[GSM_BITMAP_SIZE]; 115 unsigned char BitmapPoints[GSM_BITMAP_SIZE];
98 /** 116 /**
99 * For mono bitmaps: height specified in pixels 117 * For mono bitmaps: height specified in pixels
100 */ 118 */
101 unsigned char BitmapHeight; 119 unsigned char BitmapHeight;
102 /** 120 /**
103 * For mono bitmaps: width specified in pixels 121 * For mono bitmaps: width specified in pixels
104 */ 122 */
105 unsigned char BitmapWidth; 123 unsigned char BitmapWidth;
106 /** 124 /**
107 * For operator logos: Network operator code 125 * For operator logos: Network operator code
108 */ 126 */
109 char NetworkCode[7]; 127 char NetworkCode[7];
110 /** 128 /**
111 * For picture images: number of sender 129 * For picture images: number of sender
112 */ 130 */
113 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)]; 131 unsigned char Sender[2 * (GSM_MAX_NUMBER_LENGTH + 1)];
114 /** 132 /**
115 * For colour bitmaps: ID 133 * For colour bitmaps: ID
116 */ 134 */
117 unsigned char ID; 135 unsigned char ID;
136 /**
137 * For binary pictures (GIF, BMP, etc.): frame and length
138 */
139 GSM_BinaryPicture BinaryPic;
140 /**
141 * Bitmap name
142 */
143 char *Name;
118} GSM_Bitmap; 144} GSM_Bitmap;
119 145
120#define MAX_MULTI_BITMAP 6 146#define MAX_MULTI_BITMAP 6
121 147
122/** 148/**
123 * Structure to handle more than one bitmap 149 * Structure to handle more than one bitmap
124 */ 150 */
125typedef struct { 151typedef struct {
126 /** 152 /**
127 * Number of bitmaps 153 * Number of bitmaps
128 */ 154 */
129 unsigned char Number; 155 unsigned char Number;
130 /** 156 /**
131 * All bitmaps 157 * All bitmaps
132 */ 158 */
133 GSM_Bitmap Bitmap[MAX_MULTI_BITMAP]; 159 GSM_Bitmap Bitmap[MAX_MULTI_BITMAP];
134} GSM_MultiBitmap; 160} GSM_MultiBitmap;
135 161
136typedef enum { 162typedef enum {
137 GSM_NokiaStartupLogo = 1,/*size 84*48*/ 163 GSM_NokiaStartupLogo = 1,/*size 84*48*/
138 GSM_NokiaOperatorLogo, /*size 72*14*/ 164 GSM_NokiaOperatorLogo, /*size 72*14*/
139 GSM_Nokia7110OperatorLogo,/*size 78*21*/ 165 GSM_Nokia7110OperatorLogo,/*size 78*21*/
140 GSM_Nokia6510OperatorLogo,/*size 78*21*/ 166 GSM_Nokia6510OperatorLogo,/*size 78*21*/
141 GSM_NokiaCallerLogo, /*size 72*14*/ 167 GSM_NokiaCallerLogo, /*size 72*14*/
diff --git a/gammu/emb/common/service/gsmmisc.h b/gammu/emb/common/service/gsmmisc.h
index 37501ad..793d3d1 100644
--- a/gammu/emb/common/service/gsmmisc.h
+++ b/gammu/emb/common/service/gsmmisc.h
@@ -271,46 +271,51 @@ GSM_Error GSM_ReadFile(char *FileName, GSM_File *File);
271 271
272GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size); 272GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size);
273 273
274void GSM_IdentifyFileFormat(GSM_File *File); 274void GSM_IdentifyFileFormat(GSM_File *File);
275 275
276typedef struct { 276typedef struct {
277 int Free; 277 int Free;
278 int Used; 278 int Used;
279} GSM_FileSystemStatus; 279} GSM_FileSystemStatus;
280 280
281/* ----------------------------- GPRS access points ----------------------- */ 281/* ----------------------------- GPRS access points ----------------------- */
282 282
283typedef struct { 283typedef struct {
284 int Location; 284 int Location;
285 unsigned char Name[300]; 285 unsigned char Name[300];
286 unsigned char URL[500]; 286 unsigned char URL[500];
287 bool Active; 287 bool Active;
288} GSM_GPRSAccessPoint; 288} GSM_GPRSAccessPoint;
289 289
290/* ------------------------------------------------------------------------ */ 290/* ------------------------------------------------------------------------ */
291 291
292typedef enum { 292typedef enum {
293 GSM_Date_DDMMYYYY = 1, 293 GSM_Date_DDMMYYYY = 1,
294 GSM_Date_MMDDYYYY, 294 GSM_Date_MMDDYYYY,
295 GSM_Date_YYYYMMDD 295 GSM_Date_YYYYMMDD,
296 GSM_Date_DDMMMYY,
297 GSM_Date_MMDDYY,
298 GSM_Date_DDMMYY,
299 GSM_Date_YYMMDD,
300 GSM_Date_OFF
296} GSM_DateFormat; 301} GSM_DateFormat;
297 302
298typedef struct { 303typedef struct {
299 unsigned char DateSeparator; 304 unsigned char DateSeparator;
300 GSM_DateFormatDateFormat; 305 GSM_DateFormatDateFormat;
301 bool AMPMTime; 306 bool AMPMTime;
302} GSM_Locale; 307} GSM_Locale;
303 308
304/* ------------------------------------------------------------------------ */ 309/* ------------------------------------------------------------------------ */
305 310
306void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt); 311void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt);
307void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start); 312void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start);
308 313
309void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start); 314void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start);
310bool ReadVCALText(char *Buffer, char *Start, char *Value); 315bool ReadVCALText(char *Buffer, char *Start, char *Value);
311 316
312#endif 317#endif
313 318
314/* How should editor hadle tabs in this file? Add editor commands here. 319/* How should editor hadle tabs in this file? Add editor commands here.
315 * vim: noexpandtab sw=8 ts=8 sts=8: 320 * vim: noexpandtab sw=8 ts=8 sts=8:
316 */ 321 */
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index 7df46f1..dab028c 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -1,33 +1,36 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* Based on some work from Ralf Thelen (7110 ringtones), 2/* Based on some work from Ralf Thelen (7110 ringtones) and others */
3 * Gnokii (RTTL and SM) and others 3/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
4 */ 6 */
5 7
6#include <stdlib.h> 8#include <stdlib.h>
7#include <string.h> 9#include <string.h>
8#include <ctype.h> 10#include <ctype.h>
9#include <math.h> 11#include <math.h>
12#include <sys/stat.h>
10#ifdef WIN32 13#ifdef WIN32
11# include <windows.h> 14# include <windows.h>
12#endif 15#endif
13 16
14#include "../gsmcomon.h" 17#include "../gsmcomon.h"
15#include "../misc/coding/coding.h" 18#include "../misc/coding/coding.h"
16#include "../gsmstate.h" 19#include "../gsmstate.h"
17#include "gsmring.h" 20#include "gsmring.h"
18#include "sms/gsmsms.h" 21#include "sms/gsmsms.h"
19 22
20int GSM_RingNoteGetFrequency(GSM_RingNote Note) 23int GSM_RingNoteGetFrequency(GSM_RingNote Note)
21{ 24{
22 double freq=0; 25 double freq=0;
23 26
24 /* Values according to the software from http://iki.fi/too/sw/xring/ 27 /* Values according to the software from http://iki.fi/too/sw/xring/
25 * generated with: 28 * generated with:
26 * perl -e 'print int(4400 * (2 **($_/12)) + .5)/10, "\n" for(3..14)' 29 * perl -e 'print int(4400 * (2 **($_/12)) + .5)/10, "\n" for(3..14)'
27 */ 30 */
28 switch (Note.Note) { 31 switch (Note.Note) {
29 case Note_C : freq = 523.3; break; 32 case Note_C : freq = 523.3; break;
30 case Note_Cis: freq = 554.4; break; 33 case Note_Cis: freq = 554.4; break;
31 case Note_D : freq = 587.3; break; 34 case Note_D : freq = 587.3; break;
32 case Note_Dis: freq = 622.3; break; 35 case Note_Dis: freq = 622.3; break;
33 case Note_E : freq = 659.3; break; 36 case Note_E : freq = 659.3; break;
@@ -135,48 +138,54 @@ GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone)
135 138
136 return ERR_NONE; 139 return ERR_NONE;
137} 140}
138 141
139static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone) 142static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone)
140{ 143{
141 char nullchar=0x00; 144 char nullchar=0x00;
142 145
143 fwrite(&nullchar,1,1,file); 146 fwrite(&nullchar,1,1,file);
144 fwrite(&nullchar,1,1,file); 147 fwrite(&nullchar,1,1,file);
145 fprintf(file,"\x0C\x01\x2C"); 148 fprintf(file,"\x0C\x01\x2C");
146 fprintf(file,"%s",DecodeUnicodeString(ringtone->Name)); 149 fprintf(file,"%s",DecodeUnicodeString(ringtone->Name));
147 fwrite(&nullchar,1,1,file); 150 fwrite(&nullchar,1,1,file);
148 fwrite(&nullchar,1,1,file); 151 fwrite(&nullchar,1,1,file);
149 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); 152 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
150 return ERR_NONE; 153 return ERR_NONE;
151} 154}
152 155
153static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone) 156static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
154{ 157{
155 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file); 158 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
156 return ERR_NONE; 159 return ERR_NONE;
157} 160}
158 161
162static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
163{
164 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
165 return ERR_NONE;
166}
167
159GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) 168GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
160{ 169{
161 GSM_RingNoteScaleDefNoteScale; 170 GSM_RingNoteScaleDefNoteScale;
162 GSM_RingNoteDurationDefNoteDuration; 171 GSM_RingNoteDurationDefNoteDuration;
163 172
164 GSM_RingNoteStyleDefNoteStyle=0; 173 GSM_RingNoteStyleDefNoteStyle=0;
165 int DefNoteTempo=0; 174 int DefNoteTempo=0;
166 175
167 bool started = false, firstcomma = true; 176 bool started = false, firstcomma = true;
168 GSM_RingNote *Note; 177 GSM_RingNote *Note;
169 178
170 unsigned char buffer[15]; 179 unsigned char buffer[15];
171 int i,j,k=0; 180 int i,j,k=0;
172 181
173 /* Saves ringtone name */ 182 /* Saves ringtone name */
174 fprintf(file,"%s:",DecodeUnicodeString(ringtone->Name)); 183 fprintf(file,"%s:",DecodeUnicodeString(ringtone->Name));
175 184
176 /* Find the most frequently used duration */ 185 /* Find the most frequently used duration */
177 for (i=0;i<6;i++) buffer[i]=0; 186 for (i=0;i<6;i++) buffer[i]=0;
178 for (i=0;i<ringtone->NoteTone.NrCommands;i++) { 187 for (i=0;i<ringtone->NoteTone.NrCommands;i++) {
179 if (ringtone->NoteTone.Commands[i].Type == RING_Note) { 188 if (ringtone->NoteTone.Commands[i].Type == RING_Note) {
180 Note = &ringtone->NoteTone.Commands[i].Note; 189 Note = &ringtone->NoteTone.Commands[i].Note;
181 /* some durations need 2 bytes in file, some 1 */ 190 /* some durations need 2 bytes in file, some 1 */
182 if (Note->Duration >= Duration_Full && Note->Duration <= Duration_1_8) { 191 if (Note->Duration >= Duration_Full && Note->Duration <= Duration_1_8) {
@@ -464,48 +473,51 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
464 if (strstr(FileName,".ott")) { 473 if (strstr(FileName,".ott")) {
465 saveott(file,ringtone); 474 saveott(file,ringtone);
466#ifndef ENABLE_LGPL 475#ifndef ENABLE_LGPL
467 } else if (strstr(FileName,".mid")) { 476 } else if (strstr(FileName,".mid")) {
468 savemid(file,ringtone); 477 savemid(file,ringtone);
469#endif 478#endif
470 } else if (strstr(FileName,".rng")) { 479 } else if (strstr(FileName,".rng")) {
471 saveott(file,ringtone); 480 saveott(file,ringtone);
472 } else if (strstr(FileName,".imy")) { 481 } else if (strstr(FileName,".imy")) {
473 saveimelody(file,ringtone); 482 saveimelody(file,ringtone);
474 } else if (strstr(FileName,".ime")) { 483 } else if (strstr(FileName,".ime")) {
475 saveimelody(file,ringtone); 484 saveimelody(file,ringtone);
476 } else if (strstr(FileName,".wav")) { 485 } else if (strstr(FileName,".wav")) {
477 savewav(file,ringtone); 486 savewav(file,ringtone);
478 } else { 487 } else {
479 saverttl(file, ringtone); 488 saverttl(file, ringtone);
480 } 489 }
481 break; 490 break;
482 case RING_NOKIABINARY: 491 case RING_NOKIABINARY:
483 savebin(file, ringtone); 492 savebin(file, ringtone);
484 break; 493 break;
485 case RING_MIDI: 494 case RING_MIDI:
486 savepuremidi(file, ringtone); 495 savepuremidi(file, ringtone);
487 break; 496 break;
497 case RING_MMF:
498 savemmf(file, ringtone);
499 break;
488 } 500 }
489 501
490 fclose(file); 502 fclose(file);
491 503
492 return ERR_NONE; 504 return ERR_NONE;
493} 505}
494 506
495static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone) 507static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone)
496{ 508{
497 GSM_RingNoteScale DefNoteScale= Scale_880; 509 GSM_RingNoteScale DefNoteScale= Scale_880;
498 GSM_RingNoteDuration DefNoteDuration= Duration_1_4; 510 GSM_RingNoteDuration DefNoteDuration= Duration_1_4;
499 GSM_RingNoteStyle DefNoteStyle= NaturalStyle; 511 GSM_RingNoteStyle DefNoteStyle= NaturalStyle;
500 int DefNoteTempo= 63, i=0; 512 int DefNoteTempo= 63, i=0;
501 513
502 unsigned char buffer[2000],Name[100]; 514 unsigned char buffer[2000],Name[100];
503 GSM_RingNote *Note; 515 GSM_RingNote *Note;
504 516
505 fread(buffer, 2000, 1, file); 517 fread(buffer, 2000, 1, file);
506 518
507 ringtone->NoteTone.NrCommands = 0; 519 ringtone->NoteTone.NrCommands = 0;
508 520
509 /* -------------- name ---------------- */ 521 /* -------------- name ---------------- */
510 while (buffer[i] != ':') { 522 while (buffer[i] != ':') {
511 if (buffer[i] == 0x00) return ERR_NONE; 523 if (buffer[i] == 0x00) return ERR_NONE;
@@ -748,121 +760,150 @@ static GSM_Error loadbin(FILE *file, GSM_Ringtone *ringtone)
748 i=5; 760 i=5;
749 while (buffer[i]!=0x00) i++; 761 while (buffer[i]!=0x00) i++;
750 EncodeUnicode(ringtone->Name,buffer+5,i-5); 762 EncodeUnicode(ringtone->Name,buffer+5,i-5);
751 while (buffer[i]!=0x02 && buffer[i+1]!=0xFC && buffer[i+2]!=0x09) { 763 while (buffer[i]!=0x02 && buffer[i+1]!=0xFC && buffer[i+2]!=0x09) {
752 i++; 764 i++;
753 } 765 }
754 ringtone->NokiaBinary.Length=ringtone->NokiaBinary.Length-i; 766 ringtone->NokiaBinary.Length=ringtone->NokiaBinary.Length-i;
755 memcpy(ringtone->NokiaBinary.Frame,buffer+i,ringtone->NokiaBinary.Length); 767 memcpy(ringtone->NokiaBinary.Frame,buffer+i,ringtone->NokiaBinary.Length);
756 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name)); 768 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
757 return ERR_NONE; 769 return ERR_NONE;
758} 770}
759 771
760static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone) 772static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
761{ 773{
762 unsigned char buffer[30000]; 774 unsigned char buffer[30000];
763 775
764 dbgprintf("loading midi\n"); 776 dbgprintf("loading midi\n");
765 EncodeUnicode(ringtone->Name,"MIDI",4); 777 EncodeUnicode(ringtone->Name,"MIDI",4);
766 ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file); 778 ringtone->NokiaBinary.Length=fread(buffer, 1, 30000, file);
767 memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length); 779 memcpy(ringtone->NokiaBinary.Frame,buffer,ringtone->NokiaBinary.Length);
768 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name)); 780 dbgprintf("Length %i name \"%s\"\n",ringtone->NokiaBinary.Length,DecodeUnicodeString(ringtone->Name));
769 return ERR_NONE; 781 return ERR_NONE;
770} 782}
771 783
784static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
785{
786 struct stat st;
787 char *buffer;
788 int length;
789
790 dbgprintf("loading smaf file\n");
791 fstat(fileno(file), &st);
792 ringtone->BinaryTone.Length = length = st.st_size;
793 ringtone->BinaryTone.Buffer = buffer = malloc(length);
794 if (buffer == NULL)
795 return ERR_MOREMEMORY;
796 fread(buffer, 1, length, file);
797
798 dbgprintf("Length %i name \"%s\"\n", length,
799 DecodeUnicodeString(ringtone->Name));
800
801 return ERR_NONE;
802}
803
772static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) 804static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
773{ 805{
774 unsigned char buffer[2000]; 806 unsigned char buffer[2000];
775 807
776 ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file); 808 ringtone->NokiaBinary.Length=fread(buffer, 1, 500, file);
777 809
778 if (buffer[18]==0x00 && buffer[21]!=0x02) { 810 if (buffer[18]==0x00 && buffer[21]!=0x02) {
779 /* DCT3, Unicode subformat, 62xx & 7110 */ 811 /* DCT3, Unicode subformat, 62xx & 7110 */
780 CopyUnicodeString(ringtone->Name,buffer+18); 812 CopyUnicodeString(ringtone->Name,buffer+18);
781 ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2); 813 ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (21+UnicodeLength(ringtone->Name)*2);
782 memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length); 814 memcpy(ringtone->NokiaBinary.Frame,buffer+21+UnicodeLength(ringtone->Name)*2,ringtone->NokiaBinary.Length);
783 } else { 815 } else {
784 /* DCT3, normal subformat, 32xx/33xx/51xx/5210/5510/61xx/8xxx */ 816 /* DCT3, normal subformat, 32xx/33xx/51xx/5210/5510/61xx/8xxx */
785 EncodeUnicode(ringtone->Name,buffer+17,buffer[16]); 817 EncodeUnicode(ringtone->Name,buffer+17,buffer[16]);
786 ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (19+UnicodeLength(ringtone->Name)); 818 ringtone->NokiaBinary.Length = ringtone->NokiaBinary.Length - (19+UnicodeLength(ringtone->Name));
787 memcpy(ringtone->NokiaBinary.Frame,buffer+19+UnicodeLength(ringtone->Name),ringtone->NokiaBinary.Length); 819 memcpy(ringtone->NokiaBinary.Frame,buffer+19+UnicodeLength(ringtone->Name),ringtone->NokiaBinary.Length);
788 } 820 }
789 dbgprintf("Name \"%s\"\n",DecodeUnicodeString(ringtone->Name)); 821 dbgprintf("Name \"%s\"\n",DecodeUnicodeString(ringtone->Name));
790 return ERR_NONE; 822 return ERR_NONE;
791} 823}
792 824
793GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone) 825GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
794{ 826{
795 FILE *file; 827 FILE *file;
796 unsigned charbuffer[300]; 828 unsigned charbuffer[300];
797 GSM_Errorerror = ERR_UNKNOWN; 829 GSM_Errorerror = ERR_UNKNOWN;
798 830
799 dbgprintf("Loading ringtone %s\n",FileName); 831 dbgprintf("Loading ringtone %s\n",FileName);
800 file = fopen(FileName, "rb"); 832 file = fopen(FileName, "rb");
801 if (file == NULL) return ERR_CANTOPENFILE; 833 if (file == NULL) return ERR_CANTOPENFILE;
802 834
803 /* Read the header of the file. */ 835 /* Read the header of the file. */
804 fread(buffer, 1, 4, file); 836 fread(buffer, 1, 4, file);
805 if (ringtone->Format == 0x00) { 837 if (ringtone->Format == 0x00) {
806 ringtone->Format = RING_NOTETONE; 838 ringtone->Format = RING_NOTETONE;
807 if (buffer[0]==0x00 && buffer[1]==0x00 && 839 if (buffer[0]==0x00 && buffer[1]==0x00 &&
808 buffer[2]==0x0C && buffer[3]==0x01) { 840 buffer[2]==0x0C && buffer[3]==0x01) {
809 ringtone->Format = RING_NOKIABINARY; 841 ringtone->Format = RING_NOKIABINARY;
810 } 842 }
811 if (buffer[0]==0x00 && buffer[1]==0x00 && 843 if (buffer[0]==0x00 && buffer[1]==0x00 &&
812 buffer[2]==0x00) { 844 buffer[2]==0x00) {
813 ringtone->Format = RING_NOKIABINARY; 845 ringtone->Format = RING_NOKIABINARY;
814 } 846 }
815 if (buffer[0]==0x4D && buffer[1]==0x54 && 847 if (buffer[0]==0x4D && buffer[1]==0x54 &&
816 buffer[2]==0x68 && buffer[3]==0x64) { 848 buffer[2]==0x68 && buffer[3]==0x64) {
817 ringtone->Format = RING_MIDI; 849 ringtone->Format = RING_MIDI;
818 } 850 }
851 if (buffer[0]==0x4D && buffer[1]==0x4D &&
852 buffer[2]==0x4D && buffer[3]==0x44) {
853 ringtone->Format = RING_MMF;
854 }
819 } 855 }
820 rewind(file); 856 rewind(file);
821 switch (ringtone->Format) { 857 switch (ringtone->Format) {
822 case RING_NOTETONE: 858 case RING_NOTETONE:
823 if (buffer[0]==0x02 && buffer[1]==0x4A) { 859 if (buffer[0]==0x02 && buffer[1]==0x4A) {
824 error=loadott(file,ringtone); 860 error=loadott(file,ringtone);
825 } else if (buffer[0]==0xC7 && buffer[1]==0x45) { 861 } else if (buffer[0]==0xC7 && buffer[1]==0x45) {
826 error=loadcommunicator(file,ringtone); 862 error=loadcommunicator(file,ringtone);
827 } else { 863 } else {
828 error=loadrttl(file,ringtone); 864 error=loadrttl(file,ringtone);
829 } 865 }
830 ringtone->NoteTone.AllNotesScale=false; 866 ringtone->NoteTone.AllNotesScale=false;
831 break; 867 break;
832 case RING_NOKIABINARY: 868 case RING_NOKIABINARY:
833 if (buffer[0]==0x00 && buffer[1]==0x00 && 869 if (buffer[0]==0x00 && buffer[1]==0x00 &&
834 buffer[2]==0x0C && buffer[3]==0x01) { 870 buffer[2]==0x0C && buffer[3]==0x01) {
835 error=loadbin(file,ringtone); 871 error=loadbin(file,ringtone);
836 } 872 }
837 if (buffer[0]==0x00 && buffer[1]==0x00 && 873 if (buffer[0]==0x00 && buffer[1]==0x00 &&
838 buffer[2]==0x00) { 874 buffer[2]==0x00) {
839 error=loadre(file,ringtone); 875 error=loadre(file,ringtone);
840 } 876 }
841 break; 877 break;
842 case RING_MIDI: 878 case RING_MIDI:
843 EncodeUnicode(ringtone->Name,FileName,strlen(FileName)); 879 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
844 error = loadpuremidi(file,ringtone); 880 error = loadpuremidi(file,ringtone);
881 break;
882 case RING_MMF:
883 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
884 error = loadmmf(file,ringtone);
885 break;
845 } 886 }
846 fclose(file); 887 fclose(file);
847 return(error); 888 return(error);
848} 889}
849 890
850/* -------------------------- required with Nokia & RTTL ------------------- */ 891/* -------------------------- required with Nokia & RTTL ------------------- */
851 892
852/* Beats per Minute like written in Smart Messaging */ 893/* Beats per Minute like written in Smart Messaging */
853static int SM_BeatsPerMinute[] = { 894static int SM_BeatsPerMinute[] = {
854 25, 28, 31, 35, 40, 45, 50, 56, 63,70, 895 25, 28, 31, 35, 40, 45, 50, 56, 63,70,
855 80, 90, 100, 112, 125, 140, 160, 180, 200,225, 896 80, 90, 100, 112, 125, 140, 160, 180, 200,225,
856 250, 285, 320, 355, 400, 450, 500, 565, 635,715, 897 250, 285, 320, 355, 400, 450, 500, 565, 635,715,
857 800,900 898 800,900
858}; 899};
859 900
860int GSM_RTTLGetTempo(int Beats) 901int GSM_RTTLGetTempo(int Beats)
861{ 902{
862 int i=0; 903 int i=0;
863 904
864 while (Beats > SM_BeatsPerMinute[i] && SM_BeatsPerMinute[i] != 900) i++; 905 while (Beats > SM_BeatsPerMinute[i] && SM_BeatsPerMinute[i] != 900) i++;
865 906
866 return i<<3; 907 return i<<3;
867} 908}
868 909
diff --git a/gammu/emb/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h
index 207cf31..2d2dd7a 100644
--- a/gammu/emb/common/service/gsmring.h
+++ b/gammu/emb/common/service/gsmring.h
@@ -99,63 +99,65 @@ typedef struct {
99 99
100typedef enum { 100typedef enum {
101 RING_Note = 1, 101 RING_Note = 1,
102 RING_EnableVibra, 102 RING_EnableVibra,
103 RING_DisableVibra, 103 RING_DisableVibra,
104 RING_EnableLight, 104 RING_EnableLight,
105 RING_DisableLight, 105 RING_DisableLight,
106 RING_EnableLED, 106 RING_EnableLED,
107 RING_DisableLED, 107 RING_DisableLED,
108 RING_Repeat 108 RING_Repeat
109} GSM_RingCommandType; 109} GSM_RingCommandType;
110 110
111typedef struct { 111typedef struct {
112 GSM_RingCommandType Type; 112 GSM_RingCommandType Type;
113 GSM_RingNote Note; 113 GSM_RingNote Note;
114 unsigned char Value; 114 unsigned char Value;
115} GSM_RingCommand; 115} GSM_RingCommand;
116 116
117typedef struct { 117typedef struct {
118 int NrCommands; 118 int NrCommands;
119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES]; 119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
120 bool AllNotesScale; 120 bool AllNotesScale;
121} GSM_NoteRingtone; 121} GSM_NoteRingtone;
122 122
123/* FIXME: should use BinaryTone instead? */
123/* Structure to hold Nokia binary ringtones. */ 124/* Structure to hold Nokia binary ringtones. */
124typedef struct { 125typedef struct {
125 unsigned char Frame[30000]; 126 unsigned char Frame[50000];
126 int Length; 127 int Length;
127} GSM_NokiaBinaryRingtone; 128} GSM_NokiaBinaryRingtone;
128 129
129typedef struct { 130typedef struct {
130 unsigned char *Frame; 131 unsigned char *Buffer;
131 int Length; 132 int Length;
132} GSM_BinaryTone; 133} GSM_BinaryTone;
133 134
134typedef enum { 135typedef enum {
135 RING_NOTETONE = 1, 136 RING_NOTETONE = 1,
136 RING_NOKIABINARY, 137 RING_NOKIABINARY,
137 RING_MIDI 138 RING_MIDI,
139 RING_MMF
138} GSM_RingtoneFormat; 140} GSM_RingtoneFormat;
139 141
140/** 142/**
141 * Structure for saving various ringtones formats 143 * Structure for saving various ringtones formats
142 */ 144 */
143typedef struct { 145typedef struct {
144 /** 146 /**
145 * Ringtone saved in one of three formats 147 * Ringtone saved in one of three formats
146 */ 148 */
147 GSM_NokiaBinaryRingtone NokiaBinary; 149 GSM_NokiaBinaryRingtone NokiaBinary;
148 GSM_BinaryTone BinaryTone; 150 GSM_BinaryTone BinaryTone;
149 GSM_NoteRingtone NoteTone; 151 GSM_NoteRingtone NoteTone;
150 /** 152 /**
151 * Ringtone format 153 * Ringtone format
152 */ 154 */
153 GSM_RingtoneFormat Format; 155 GSM_RingtoneFormat Format;
154 /** 156 /**
155 * Ringtone name 157 * Ringtone name
156 */ 158 */
157 char Name[20*2]; 159 char Name[20*2];
158 /** 160 /**
159 * Ringtone location 161 * Ringtone location
160 */ 162 */
161 int Location; 163 int Location;
diff --git a/gammu/emb/common/service/sms/gsmmulti.c b/gammu/emb/common/service/sms/gsmmulti.c
index 6c1cdcd..bdb5ee9 100644
--- a/gammu/emb/common/service/sms/gsmmulti.c
+++ b/gammu/emb/common/service/sms/gsmmulti.c
@@ -466,48 +466,53 @@ GSM_Error GSM_EncodeMultiPartSMS(GSM_MultiPartSMSInfo *Info,
466 466
467 Length = 4; 467 Length = 4;
468 j = 0; 468 j = 0;
469 469
470 /* Offsets to bitmaps */ 470 /* Offsets to bitmaps */
471 for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { 471 for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
472 Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) % 256; 472 Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) % 256;
473 Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) / 256; 473 Buffer[Length++] = (4+j+Info->Entries[0].Bitmap->Number*2) / 256;
474 j += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight)+2; 474 j += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight)+2;
475 } 475 }
476 476
477 /* Bitmaps */ 477 /* Bitmaps */
478 for (i=0;i<Info->Entries[0].Bitmap->Number;i++) { 478 for (i=0;i<Info->Entries[0].Bitmap->Number;i++) {
479 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth; 479 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth;
480 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight; 480 Buffer[Length++] = Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight;
481 PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]); 481 PHONE_EncodeBitmap(GSM_AlcatelBMMIPicture, Buffer+Length, &Info->Entries[0].Bitmap->Bitmap[i]);
482 Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight); 482 Length += PHONE_GetBitmapSize(GSM_AlcatelBMMIPicture,Info->Entries[0].Bitmap->Bitmap[i].BitmapWidth,Info->Entries[0].Bitmap->Bitmap[i].BitmapHeight);
483 } 483 }
484 return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION); 484 return GSM_EncodeAlcatelMultiPartSMS(SMS,Buffer,Length,Info->Entries[0].Bitmap->Bitmap[0].Text,ALCATELTDD_ANIMATION);
485 case SMS_MMSIndicatorLong: 485 case SMS_MMSIndicatorLong:
486 Class= 1; 486 Class= 1;
487 UDH= UDH_MMSIndicatorLong; 487 UDH= UDH_MMSIndicatorLong;
488 GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator); 488 GSM_EncodeMMSIndicatorSMSText(Buffer,&Length,*Info->Entries[0].MMSIndicator);
489 break; 489 break;
490 case SMS_WAPIndicatorLong:
491 Class= 1;
492 UDH= UDH_MMSIndicatorLong;
493 GSM_EncodeWAPIndicatorSMSText(Buffer,&Length,Info->Entries[0].MMSIndicator->Title,Info->Entries[0].MMSIndicator->Address);
494 break;
490 case SMS_NokiaRingtoneLong: 495 case SMS_NokiaRingtoneLong:
491 case SMS_NokiaRingtone: 496 case SMS_NokiaRingtone:
492 UDH= UDH_NokiaRingtone; 497 UDH= UDH_NokiaRingtone;
493 Class= 1; 498 Class= 1;
494 /* 7 = length of UDH_NokiaRingtone UDH header */ 499 /* 7 = length of UDH_NokiaRingtone UDH header */
495 Length = GSM_MAX_8BIT_SMS_LENGTH-7; 500 Length = GSM_MAX_8BIT_SMS_LENGTH-7;
496 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); 501 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length);
497 if (Info->Entries[0].ID == SMS_NokiaRingtone) break; 502 if (Info->Entries[0].ID == SMS_NokiaRingtone) break;
498 if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) { 503 if (Info->Entries[0].RingtoneNotes != Info->Entries[0].Ringtone->NoteTone.NrCommands) {
499 UDH = UDH_NokiaRingtoneLong; 504 UDH = UDH_NokiaRingtoneLong;
500 Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3; 505 Length = (GSM_MAX_8BIT_SMS_LENGTH-12)*3;
501 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length); 506 Info->Entries[0].RingtoneNotes = GSM_EncodeNokiaRTTLRingtone(*Info->Entries[0].Ringtone,Buffer,&Length);
502 } 507 }
503 break; 508 break;
504 case SMS_NokiaOperatorLogoLong: 509 case SMS_NokiaOperatorLogoLong:
505 if (Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth > 72 || Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight > 14) { 510 if (Info->Entries[0].Bitmap->Bitmap[0].BitmapWidth > 72 || Info->Entries[0].Bitmap->Bitmap[0].BitmapHeight > 14) {
506 UDH= UDH_NokiaOperatorLogoLong; 511 UDH= UDH_NokiaOperatorLogoLong;
507 Class = 1; 512 Class = 1;
508 NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode); 513 NOKIA_EncodeNetworkCode(Buffer, Info->Entries[0].Bitmap->Bitmap[0].NetworkCode);
509 Length = Length + 3; 514 Length = Length + 3;
510 NOKIA_CopyBitmap(GSM_Nokia7110OperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length); 515 NOKIA_CopyBitmap(GSM_Nokia7110OperatorLogo, &Info->Entries[0].Bitmap->Bitmap[0], Buffer, &Length);
511 break; 516 break;
512 } 517 }
513 case SMS_NokiaOperatorLogo: 518 case SMS_NokiaOperatorLogo:
diff --git a/gammu/emb/common/service/sms/gsmmulti.h b/gammu/emb/common/service/sms/gsmmulti.h
index c672261..3f70d81 100644
--- a/gammu/emb/common/service/sms/gsmmulti.h
+++ b/gammu/emb/common/service/sms/gsmmulti.h
@@ -1,29 +1,33 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __gsm_multi_h 3#ifndef __gsm_multi_h
4#define __gsm_multi_h 4#define __gsm_multi_h
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
7#include "../gsmlogo.h" 11#include "../gsmlogo.h"
8#include "../gsmcal.h" 12#include "../gsmcal.h"
9#include "../gsmpbk.h" 13#include "../gsmpbk.h"
10#include "../gsmdata.h" 14#include "../gsmdata.h"
11#include "../gsmring.h" 15#include "../gsmring.h"
12#include "gsmsms.h" 16#include "gsmsms.h"
13 17
14/* ---------------------- multi SMS --------------------------------------- */ 18/* ---------------------- multi SMS --------------------------------------- */
15 19
16/* Identifiers for Smart Messaging 3.0 multipart SMS */ 20/* Identifiers for Smart Messaging 3.0 multipart SMS */
17 21
18#define SM30_ISOTEXT 0 /* ISO 8859-1 text */ 22#define SM30_ISOTEXT 0 /* ISO 8859-1 text */
19#define SM30_UNICODETEXT 1 23#define SM30_UNICODETEXT 1
20 #define SM30_OTA 2 24 #define SM30_OTA 2
21#define SM30_RINGTONE 3 25#define SM30_RINGTONE 3
22#define SM30_PROFILENAME 4 26#define SM30_PROFILENAME 4
23/* ... */ 27/* ... */
24#define SM30_SCREENSAVER 6 28#define SM30_SCREENSAVER 6
25 29
26/* Identifiers for Alcatel Terminal Data Download */ 30/* Identifiers for Alcatel Terminal Data Download */
27#define ALCATELTDD_PICTURE 4 31#define ALCATELTDD_PICTURE 4
28#define ALCATELTDD_ANIMATION 5 32#define ALCATELTDD_ANIMATION 5
29#define ALCATELTDD_SMSTEMPLATE 6 33#define ALCATELTDD_SMSTEMPLATE 6
@@ -151,66 +155,67 @@ typedef enum {
151 SMS_VCARD21Long, 155 SMS_VCARD21Long,
152 SMS_DisableVoice, 156 SMS_DisableVoice,
153 SMS_DisableFax, 157 SMS_DisableFax,
154 SMS_DisableEmail, 158 SMS_DisableEmail,
155 SMS_EnableVoice, 159 SMS_EnableVoice,
156 SMS_EnableFax, 160 SMS_EnableFax,
157 SMS_EnableEmail, 161 SMS_EnableEmail,
158 SMS_VoidSMS, 162 SMS_VoidSMS,
159 /** 163 /**
160 * IMelody 1.0 164 * IMelody 1.0
161 */ 165 */
162 SMS_EMSSound10, 166 SMS_EMSSound10,
163 /** 167 /**
164 * IMelody 1.2 168 * IMelody 1.2
165 */ 169 */
166 SMS_EMSSound12, 170 SMS_EMSSound12,
167 /** 171 /**
168 * IMelody without header - SonyEricsson extension 172 * IMelody without header - SonyEricsson extension
169 */ 173 */
170 SMS_EMSSonyEricssonSound, 174 SMS_EMSSonyEricssonSound,
171 /** 175 /**
172 * IMelody 1.0 with UPI. 176 * IMelody 1.0 with UPI.
173 */ 177 */
174 SMS_EMSSound10Long, 178 SMS_EMSSound10Long,
175 /*** 179 /**
176 * IMelody 1.2 with UPI. 180 * IMelody 1.2 with UPI.
177 */ 181 */
178 SMS_EMSSound12Long, 182 SMS_EMSSound12Long,
179 /** 183 /**
180 * IMelody without header with UPI. 184 * IMelody without header with UPI.
181 */ 185 */
182 SMS_EMSSonyEricssonSoundLong, 186 SMS_EMSSonyEricssonSoundLong,
183 SMS_EMSPredefinedSound, 187 SMS_EMSPredefinedSound,
184 SMS_EMSPredefinedAnimation, 188 SMS_EMSPredefinedAnimation,
185 SMS_EMSAnimation, 189 SMS_EMSAnimation,
186 /** 190 /**
187 * Fixed bitmap of size 16x16 or 32x32. 191 * Fixed bitmap of size 16x16 or 32x32.
188 */ 192 */
189 SMS_EMSFixedBitmap, 193 SMS_EMSFixedBitmap,
190 SMS_EMSVariableBitmap, 194 SMS_EMSVariableBitmap,
191 SMS_EMSVariableBitmapLong, 195 SMS_EMSVariableBitmapLong,
192 SMS_MMSIndicatorLong, 196 SMS_MMSIndicatorLong,
197 SMS_WAPIndicatorLong,
193 /** 198 /**
194 * Variable bitmap with black and white colors 199 * Variable bitmap with black and white colors
195 */ 200 */
196 SMS_AlcatelMonoBitmapLong, 201 SMS_AlcatelMonoBitmapLong,
197 /** 202 /**
198 * Variable animation with black and white colors 203 * Variable animation with black and white colors
199 */ 204 */
200 SMS_AlcatelMonoAnimationLong, 205 SMS_AlcatelMonoAnimationLong,
201 SMS_AlcatelSMSTemplateName 206 SMS_AlcatelSMSTemplateName
202} EncodeMultiPartSMSID; 207} EncodeMultiPartSMSID;
203 208
204typedef struct { 209typedef struct {
205 EncodeMultiPartSMSID ID; 210 EncodeMultiPartSMSID ID;
206 211
207 int Number; 212 int Number;
208 GSM_Ringtone *Ringtone; 213 GSM_Ringtone *Ringtone;
209 GSM_MultiBitmap *Bitmap; 214 GSM_MultiBitmap *Bitmap;
210 GSM_WAPBookmark *Bookmark; 215 GSM_WAPBookmark *Bookmark;
211 GSM_WAPSettings *Settings; 216 GSM_WAPSettings *Settings;
212 GSM_MMSIndicator*MMSIndicator; 217 GSM_MMSIndicator*MMSIndicator;
213 GSM_MemoryEntry *Phonebook; 218 GSM_MemoryEntry *Phonebook;
214 GSM_CalendarEntry *Calendar; 219 GSM_CalendarEntry *Calendar;
215 GSM_ToDoEntry *ToDo; 220 GSM_ToDoEntry *ToDo;
216 bool Protected; 221 bool Protected;
@@ -243,29 +248,33 @@ typedef struct {
243 * Encodes multi part SMS from "readable" format. 248 * Encodes multi part SMS from "readable" format.
244 */ 249 */
245GSM_Error GSM_EncodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS); 250GSM_Error GSM_EncodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS);
246 251
247/** 252/**
248 * Decodes multi part SMS to "readable" format. 253 * Decodes multi part SMS to "readable" format.
249 */ 254 */
250bool GSM_DecodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, bool ems); 255bool GSM_DecodeMultiPartSMS (GSM_MultiPartSMSInfo *Info, GSM_MultiSMSMessage *SMS, bool ems);
251 256
252/** 257/**
253 * Clears @ref GSM_MultiPartSMSInfo to default values. 258 * Clears @ref GSM_MultiPartSMSInfo to default values.
254 */ 259 */
255void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); 260void GSM_ClearMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
256 261
257/** 262/**
258 * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo. 263 * Frees any allocated structures inside @ref GSM_MultiPartSMSInfo.
259 */ 264 */
260void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info); 265void GSM_FreeMultiPartSMSInfo (GSM_MultiPartSMSInfo *Info);
261 266
262/** 267/**
263 * Links SMS messages according to IDs. 268 * Links SMS messages according to IDs.
264 */ 269 */
265GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems); 270GSM_Error GSM_LinkSMS(GSM_MultiSMSMessage **INPUT, GSM_MultiSMSMessage **OUTPUT, bool ems);
266 271
272#if defined(_MSC_VER) && defined(__cplusplus)
273 }
274#endif
275
267#endif 276#endif
268 277
269/* How should editor hadle tabs in this file? Add editor commands here. 278/* How should editor hadle tabs in this file? Add editor commands here.
270 * vim: noexpandtab sw=8 ts=8 sts=8: 279 * vim: noexpandtab sw=8 ts=8 sts=8:
271 */ 280 */
diff --git a/gammu/emb/common/service/sms/gsmsms.c b/gammu/emb/common/service/sms/gsmsms.c
index 9920835..feceba4 100644
--- a/gammu/emb/common/service/sms/gsmsms.c
+++ b/gammu/emb/common/service/sms/gsmsms.c
@@ -1,26 +1,29 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */ 2/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
4#include <ctype.h> 7#include <ctype.h>
5#include <string.h> 8#include <string.h>
6#include <time.h> 9#include <time.h>
7 10
8#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
9#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
10#include "../gsmcal.h" 13#include "../gsmcal.h"
11#include "../gsmpbk.h" 14#include "../gsmpbk.h"
12#include "../gsmlogo.h" 15#include "../gsmlogo.h"
13#include "../gsmring.h" 16#include "../gsmring.h"
14#include "../gsmdata.h" 17#include "../gsmdata.h"
15#include "../gsmnet.h" 18#include "../gsmnet.h"
16#include "gsmsms.h" 19#include "gsmsms.h"
17 20
18/* User data headers */ 21/* User data headers */
19static GSM_UDHHeader UDHHeaders[] = { 22static GSM_UDHHeader UDHHeaders[] = {
20 /* See GSM 03.40 section 9.2.3.24.1 23 /* See GSM 03.40 section 9.2.3.24.1
21 * 1 byte 0x00 24 * 1 byte 0x00
22 * 1 byte 0x03 25 * 1 byte 0x03
23 * 1 byte 0x01: unique ID for message series 26 * 1 byte 0x01: unique ID for message series
24 * 1 byte 0x00: how many SMS in sequence 27 * 1 byte 0x00: how many SMS in sequence
25 * 1 byte 0x00: number of current SMS in sequence */ 28 * 1 byte 0x00: number of current SMS in sequence */
26 { UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3}, 29 { UDH_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00",2,-1,4,3},
diff --git a/gammu/emb/common/service/sms/gsmsms.h b/gammu/emb/common/service/sms/gsmsms.h
index d87ff60..0b950d3 100644
--- a/gammu/emb/common/service/sms/gsmsms.h
+++ b/gammu/emb/common/service/sms/gsmsms.h
@@ -1,26 +1,29 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Pawel Kot, others and Gnokii */ 2/* Based on some Pawel Kot and others work from Gnokii (www.gnokii.org)
3 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
4 * GNU GPL version 2 or later
5 */
3 6
4#ifndef __gsm_sms_h 7#ifndef __gsm_sms_h
5#define __gsm_sms_h 8#define __gsm_sms_h
6 9
7#include "../../gsmcomon.h" 10#include "../../gsmcomon.h"
8#include "../gsmlogo.h" 11#include "../gsmlogo.h"
9#include "../gsmcal.h" 12#include "../gsmcal.h"
10#include "../gsmpbk.h" 13#include "../gsmpbk.h"
11#include "../gsmdata.h" 14#include "../gsmdata.h"
12#include "../gsmring.h" 15#include "../gsmring.h"
13 16
14/* --------------------- Some general definitions ------------------------- */ 17/* --------------------- Some general definitions ------------------------- */
15 18
16 #define GSM_MAX_UDH_LENGTH 140 19 #define GSM_MAX_UDH_LENGTH 140
17 #define GSM_MAX_SMS_LENGTH 160 20 #define GSM_MAX_SMS_LENGTH 160
18 #define GSM_MAX_8BIT_SMS_LENGTH 140 21 #define GSM_MAX_8BIT_SMS_LENGTH 140
19 22
20/* -------------------- Cell Broadcast ------------------------------------ */ 23/* -------------------- Cell Broadcast ------------------------------------ */
21 24
22/** 25/**
23 * Structure for Cell Broadcast messages. 26 * Structure for Cell Broadcast messages.
24 */ 27 */
25typedef struct { 28typedef struct {
26 /** 29 /**