5 A Linux/Unix toolset and driver for Nokia mobile phones.
7 Released under the terms of the GNU GPL, see file COPYING for more details.
9 Functions for manipulating calendar
22 #include "misc_win32.h"
28 #include "gsm-coding.h"
30 char *GSM_GetVCALENDARStart(int version) {
32 static char Buffer[1000]="";
35 len+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
37 if (version==10) sprintf(Buffer+len, "VERSION:1.0%c%c",13,10);
38 if (version==30) sprintf(Buffer+len, "VERSION:3.0%c%c",13,10);
43 char *GSM_GetVCALENDARNote(GSM_CalendarNote *note, int version) {
45 static char Buffer[1000]="";
51 len+=sprintf(Buffer+len, "BEGIN:VEVENT%c%c",13,10);
52 len+=sprintf(Buffer+len, "CATEGORIES:");
55 len+=sprintf(Buffer+len, "MISCELLANEOUS%c%c",13,10);
58 len+=sprintf(Buffer+len, "PHONE CALL%c%c",13,10);
61 len+=sprintf(Buffer+len, "MEETING%c%c",13,10);
64 len+=sprintf(Buffer+len, "SPECIAL OCCASION%c%c",13,10);
67 len+=sprintf(Buffer+len, "UNKNOWN%c%c",13,10);
71 if( note->Type == GCN_CALL && strcmp( note->Phone, "" ) ) {
73 if (note->Text[0]!=0 && version==30)
74 len+=sprintf(Buffer+len, "DESCRIPTION:%s%c%c",note->Text,13,10);
76 EncodeUTF8(buffer,note->Phone,strlen(note->Phone));
77 if (strlen(note->Phone)==strlen(buffer)) {
78 len+=sprintf(Buffer+len, "SUMMARY:%s%c%c",note->Phone,13,10);
80 len+=sprintf(Buffer+len, "SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:%s%c%c",buffer,13,10);
85 EncodeUTF8(buffer,note->Text,strlen(note->Text));
86 if (strlen(note->Text)==strlen(buffer)) {
87 len+=sprintf(Buffer+len, "SUMMARY:%s%c%c",note->Text,13,10);
89 len+=sprintf(Buffer+len, "SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:%s%c%c",buffer,13,10);
94 /* For 3310: date is set to 2090! */
95 if (GetModelFeature (FN_CALENDAR)==F_CAL33) {
96 len+=sprintf(Buffer+len, "DTSTART:1999%02d%02dT%02d%02d%02d%c%c",
97 note->Time.Month, note->Time.Day, note->Time.Hour,
98 note->Time.Minute, note->Time.Second,13,10);
100 len+=sprintf(Buffer+len, "DTSTART:%04d%02d%02dT%02d%02d%02d%c%c", note->Time.Year,
101 note->Time.Month, note->Time.Day, note->Time.Hour,
102 note->Time.Minute, note->Time.Second,13,10);
105 if (note->Alarm.Year!=0) {
106 len+=sprintf(Buffer+len, "DALARM:%04d%02d%02dT%02d%02d%02d%c%c", note->Alarm.Year,
107 note->Alarm.Month, note->Alarm.Day, note->Alarm.Hour,
108 note->Alarm.Minute, note->Alarm.Second,13,10);
111 if ( GetModelFeature (FN_CALENDAR)==F_CAL71 && version==30 && note->Type == GCN_BIRTHDAY ) {
112 len+=sprintf(Buffer+len, "ALTYPE:%s%c%c", (note->AlarmType==0x00) ?
113 "TONE" : "SILENT",13,10);
116 if ( GetModelFeature (FN_CALENDAR)==F_CAL71 && note->Recurrance!= 0 ) {
117 switch(note->Recurrance/24) {
118 case 1 :len+=sprintf(Buffer+len, "RRULE:D1 #0%c%c",13,10);break;
119 case 7 :len+=sprintf(Buffer+len, "RRULE:W1 #0%c%c",13,10);break;
120 case 14 :len+=sprintf(Buffer+len, "RRULE:W2 #0%c%c",13,10);break;
121 case 365:len+=sprintf(Buffer+len, "RRULE:YD1 #0%c%c",13,10);break;
125 len+=sprintf(Buffer+len, "END:VEVENT%c%c",13,10);
130 char *GSM_GetVCALENDAREnd(int version) {
132 static char Buffer[1000]="";
134 sprintf(Buffer, "END:VCALENDAR%c%c",13,10);
139 int GSM_SaveCalendarNoteToSMS(GSM_MultiSMSMessage *SMS,
140 GSM_CalendarNote *note)
142 char Buffer[1000]="";
144 GSM_UDH UDH=GSM_NoUDH;
146 sprintf(Buffer,GSM_GetVCALENDARStart(10));
147 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDARNote(note,10));
148 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDAREnd(10));
151 if (strlen(Buffer)<=160-8) { //8==length of ..SCKE4.
152 sprintf(Buffer,"//SCKE4 ");
153 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDARStart(10));
154 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDARNote(note,10));
155 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDAREnd(10));
157 UDH=GSM_CalendarNoteUDH;
160 length=strlen(Buffer);
161 GSM_MakeMultiPartSMS2(SMS,Buffer,length, UDH, GSM_Coding_Default);