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
20 #include "misc_win32.h"
26 #include "gsm-coding.h"
28 char *GSM_GetVCALENDARStart(int version) {
30 static char Buffer[1000]="";
33 len+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
35 if (version==10) sprintf(Buffer+len, "VERSION:1.0%c%c",13,10);
36 if (version==30) sprintf(Buffer+len, "VERSION:3.0%c%c",13,10);
41 char *GSM_GetVCALENDARNote(GSM_CalendarNote *note, int version) {
43 static char Buffer[1000]="";
49 len+=sprintf(Buffer+len, "BEGIN:VEVENT%c%c",13,10);
50 len+=sprintf(Buffer+len, "CATEGORIES:");
53 len+=sprintf(Buffer+len, "MISCELLANEOUS%c%c",13,10);
56 len+=sprintf(Buffer+len, "PHONE CALL%c%c",13,10);
59 len+=sprintf(Buffer+len, "MEETING%c%c",13,10);
62 len+=sprintf(Buffer+len, "SPECIAL OCCASION%c%c",13,10);
65 len+=sprintf(Buffer+len, "UNKNOWN%c%c",13,10);
69 if( note->Type == GCN_CALL && strcmp( note->Phone, "" ) ) {
71 if (note->Text[0]!=0 && version==30)
72 len+=sprintf(Buffer+len, "DESCRIPTION:%s%c%c",note->Text,13,10);
74 EncodeUTF8(buffer,note->Phone,strlen(note->Phone));
75 if (strlen(note->Phone)==strlen(buffer)) {
76 len+=sprintf(Buffer+len, "SUMMARY:%s%c%c",note->Phone,13,10);
78 len+=sprintf(Buffer+len, "SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:%s%c%c",buffer,13,10);
83 EncodeUTF8(buffer,note->Text,strlen(note->Text));
84 if (strlen(note->Text)==strlen(buffer)) {
85 len+=sprintf(Buffer+len, "SUMMARY:%s%c%c",note->Text,13,10);
87 len+=sprintf(Buffer+len, "SUMMARY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:%s%c%c",buffer,13,10);
92 /* For 3310: date is set to 2090! */
93 if (GetModelFeature (FN_CALENDAR)==F_CAL33) {
94 len+=sprintf(Buffer+len, "DTSTART:1999%02d%02dT%02d%02d%02d%c%c",
95 note->Time.Month, note->Time.Day, note->Time.Hour,
96 note->Time.Minute, note->Time.Second,13,10);
98 len+=sprintf(Buffer+len, "DTSTART:%04d%02d%02dT%02d%02d%02d%c%c", note->Time.Year,
99 note->Time.Month, note->Time.Day, note->Time.Hour,
100 note->Time.Minute, note->Time.Second,13,10);
103 if (note->Alarm.Year!=0) {
104 len+=sprintf(Buffer+len, "DALARM:%04d%02d%02dT%02d%02d%02d%c%c", note->Alarm.Year,
105 note->Alarm.Month, note->Alarm.Day, note->Alarm.Hour,
106 note->Alarm.Minute, note->Alarm.Second,13,10);
109 if ( GetModelFeature (FN_CALENDAR)==F_CAL71 && version==30 && note->Type == GCN_BIRTHDAY ) {
110 len+=sprintf(Buffer+len, "ALTYPE:%s%c%c", (note->AlarmType==0x00) ?
111 "TONE" : "SILENT",13,10);
114 if ( GetModelFeature (FN_CALENDAR)==F_CAL71 && note->Recurrance!= 0 ) {
115 switch(note->Recurrance/24) {
116 case 1 :len+=sprintf(Buffer+len, "RRULE:D1 #0%c%c",13,10);break;
117 case 7 :len+=sprintf(Buffer+len, "RRULE:W1 #0%c%c",13,10);break;
118 case 14 :len+=sprintf(Buffer+len, "RRULE:W2 #0%c%c",13,10);break;
119 case 365:len+=sprintf(Buffer+len, "RRULE:YD1 #0%c%c",13,10);break;
123 len+=sprintf(Buffer+len, "END:VEVENT%c%c",13,10);
128 char *GSM_GetVCALENDAREnd(int version) {
130 static char Buffer[1000]="";
132 sprintf(Buffer, "END:VCALENDAR%c%c",13,10);
137 int GSM_SaveCalendarNoteToSMS(GSM_MultiSMSMessage *SMS,
138 GSM_CalendarNote *note)
140 char Buffer[1000]="";
142 GSM_UDH UDH=GSM_NoUDH;
144 sprintf(Buffer,GSM_GetVCALENDARStart(10));
145 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDARNote(note,10));
146 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDAREnd(10));
149 if (strlen(Buffer)<=160-8) { //8==length of ..SCKE4.
150 sprintf(Buffer,"//SCKE4 ");
151 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDARStart(10));
152 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDARNote(note,10));
153 sprintf(Buffer+strlen(Buffer),GSM_GetVCALENDAREnd(10));
155 UDH=GSM_CalendarNoteUDH;
158 length=strlen(Buffer);
159 GSM_MakeMultiPartSMS2(SMS,Buffer,length, UDH, GSM_Coding_Default);