2 #include <string.h> /* memcpy only */
7 #include "../../misc/coding/coding.h"
8 #include "../../gsmstate.h"
9 #include "../../service/sms/gsmsms.h"
14 static void N71_65_GetCalendarAlarm(GSM_StateMachine
*s
, unsigned char *buffer
, GSM_CalendarEntry
*entry
, int DT
, GSM_Phone_Data
*Data
)
18 if (buffer
[0] == 0x00 && buffer
[1] == 0x00 && buffer
[2] == 0xff && buffer
[3] == 0xff)
20 smprintf(s
, "No alarm\n");
22 memcpy(&entry
->Entries
[entry
->EntriesNum
].Date
,&entry
->Entries
[DT
].Date
,sizeof(GSM_DateTime
));
24 diff
= ((unsigned int)buffer
[0]) << 24;
25 diff
+= ((unsigned int)buffer
[1]) << 16;
26 diff
+= ((unsigned int)buffer
[2]) << 8;
28 smprintf(s
, " Difference : %i seconds\n", diff
);
30 switch (entry
->Type
) {
32 GetTimeDifference(diff
, &entry
->Entries
[entry
->EntriesNum
].Date
, false, 60);
35 if (!IsPhoneFeatureAvailable(Data
->ModelInfo
, F_CAL35
)) {
36 GetTimeDifference(diff
, &entry
->Entries
[entry
->EntriesNum
].Date
, false, 60);
40 if (!IsPhoneFeatureAvailable(Data
->ModelInfo
, F_CAL35
)) {
41 GetTimeDifference(diff
, &entry
->Entries
[entry
->EntriesNum
].Date
, false, 60);
45 GetTimeDifference(diff
, &entry
->Entries
[entry
->EntriesNum
].Date
, false, 1);
47 smprintf(s
, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n",
48 entry
->Entries
[entry
->EntriesNum
].Date
.Day
, entry
->Entries
[entry
->EntriesNum
].Date
.Month
,
49 entry
->Entries
[entry
->EntriesNum
].Date
.Year
, entry
->Entries
[entry
->EntriesNum
].Date
.Hour
,
50 entry
->Entries
[entry
->EntriesNum
].Date
.Minute
,entry
->Entries
[entry
->EntriesNum
].Date
.Second
);
52 entry
->Entries
[entry
->EntriesNum
].EntryType
= CAL_ALARM_DATETIME
;
53 if (entry
->Type
== GCN_BIRTHDAY
) {
54 if (buffer
[14]!=0x00) entry
->Entries
[entry
->EntriesNum
].EntryType
= CAL_SILENT_ALARM_DATETIME
;
55 smprintf(s
, "Alarm type : Silent\n");
63 GSM_Error
N71_65_ReplyGetNextCalendar2(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
66 GSM_CalendarEntry
*entry
= s
->Phone
.Data
.Cal
;
67 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
71 smprintf(s
, "Calendar note received method 2\n");
73 if (msg
.Length
< 10) return GE_EMPTY
;
75 entry
->Location
= msg
.Buffer
[4]*256 + msg
.Buffer
[5];
76 smprintf(s
, "Location: %i\n",entry
->Location
);
79 if (msg
.Buffer
[21] != 0x04) {
80 Date
.Year
= 2030; Date
.Month
= 01; Date
.Day
= 01;
81 Date
.Hour
= 00; Date
.Minute
= 00; Date
.Second
= 00;
83 Date
.Year
= 2029; Date
.Month
= 12; Date
.Day
= 31;
84 Date
.Hour
= 22; Date
.Minute
= 59; Date
.Second
= 58;
86 diff
= ((unsigned int)msg
.Buffer
[12]) << 24;
87 diff
+= ((unsigned int)msg
.Buffer
[13]) << 16;
88 diff
+= ((unsigned int)msg
.Buffer
[14]) << 8;
89 diff
+= msg
.Buffer
[15];
90 smprintf(s
, " Difference : %i seconds\n", diff
);
91 GetTimeDifference(diff
, &Date
, true, 1);
93 entry
->Entries
[0].EntryType
= CAL_START_DATETIME
;
95 smprintf(s
, "Note type %02x: ",msg
.Buffer
[21]);
96 switch (msg
.Buffer
[21]) {
99 if (msg
.Buffer
[21] == 0x01) {
100 smprintf(s
, "Meeting or Reminder\n");
101 entry
->Type
= GCN_MEETING
;
103 smprintf(s
, "Memo\n");
104 Data
->Cal
->Type
= GCN_MEMO
;
107 memcpy(&entry
->Entries
[0].Date
,&Date
,sizeof(GSM_DateTime
));
110 N71_65_GetCalendarAlarm(s
, msg
.Buffer
+16, entry
, 0, Data
);
111 N71_65_GetCalendarRecurrance(s
, msg
.Buffer
+22, entry
);
113 memcpy(entry
->Entries
[entry
->EntriesNum
].Text
, msg
.Buffer
+30, msg
.Buffer
[28]*2);
114 entry
->Entries
[entry
->EntriesNum
].Text
[msg
.Buffer
[28]*2] = 0;
115 entry
->Entries
[entry
->EntriesNum
].Text
[msg
.Buffer
[28]*2+1] = 0;
116 entry
->Entries
[entry
->EntriesNum
].EntryType
= CAL_TEXT
;
119 smprintf(s
, "Call\n");
120 entry
->Type
= GCN_CALL
;
122 memcpy(&entry
->Entries
[0].Date
,&Date
,sizeof(GSM_DateTime
));
125 N71_65_GetCalendarAlarm(s
, msg
.Buffer
+16, entry
, 0, Data
);
126 N71_65_GetCalendarRecurrance(s
, msg
.Buffer
+22, entry
);
128 i
= msg
.Buffer
[28] * 2;
130 memcpy(entry
->Entries
[entry
->EntriesNum
].Text
, msg
.Buffer
+30, i
);
131 entry
->Entries
[entry
->EntriesNum
].Text
[i
] = 0;
132 entry
->Entries
[entry
->EntriesNum
].Text
[i
+1] = 0;
133 entry
->Entries
[entry
->EntriesNum
].EntryType
= CAL_PHONE
;
134 smprintf(s
, "Phone : \"%s\"\n", DecodeUnicodeString(entry
->Entries
[entry
->EntriesNum
].Text
));
138 memcpy(entry
->Entries
[entry
->EntriesNum
].Text
, msg
.Buffer
+30+i
, msg
.Buffer
[29]*2);
139 entry
->Entries
[entry
->EntriesNum
].Text
[msg
.Buffer
[29]*2] = 0;
140 entry
->Entries
[entry
->EntriesNum
].Text
[msg
.Buffer
[29]*2+1] = 0;
141 entry
->Entries
[entry
->EntriesNum
].EntryType
= CAL_TEXT
;
144 smprintf(s
, "Birthday\n");
145 Data
->Cal
->Type
= GCN_BIRTHDAY
;
147 /* Year was set earlier */
148 entry
->Entries
[0].Date
.Month
= Date
.Month
;
149 entry
->Entries
[0].Date
.Day
= Date
.Day
;
150 entry
->Entries
[0].Date
.Hour
= 23;
151 entry
->Entries
[0].Date
.Minute
= 59;
152 entry
->Entries
[0].Date
.Second
= 58;
155 N71_65_GetCalendarAlarm(s
, msg
.Buffer
+16, entry
, 0, Data
);
156 N71_65_GetCalendarRecurrance(s
, msg
.Buffer
+22, entry
);
159 entry
->Entries
[0].Date
.Year
= msg
.Buffer
[28]*256 + msg
.Buffer
[29];
160 if (msg
.Buffer
[28] == 0xff && msg
.Buffer
[29] == 0xff) entry
->Entries
[0].Date
.Year
= 0;
161 smprintf(s
, "Birthday date: %02i-%02i-%04i\n",
162 entry
->Entries
[0].Date
.Day
,entry
->Entries
[0].Date
.Month
,
163 entry
->Entries
[0].Date
.Year
);
165 memcpy(entry
->Entries
[entry
->EntriesNum
].Text
, msg
.Buffer
+32, msg
.Buffer
[31]*2);
166 entry
->Entries
[entry
->EntriesNum
].Text
[msg
.Buffer
[31]*2] = 0;
167 entry
->Entries
[entry
->EntriesNum
].Text
[msg
.Buffer
[31]*2+1] = 0;
168 entry
->Entries
[entry
->EntriesNum
].EntryType
= CAL_TEXT
;
171 smprintf(s
, "ERROR: unknown %i\n",msg
.Buffer
[6]);
172 return GE_UNKNOWNRESPONSE
;
174 smprintf(s
, "Text : \"%s\"\n", DecodeUnicodeString(entry
->Entries
[entry
->EntriesNum
].Text
));
180 /* Note: in known phones texts of notes cut to 50 chars */
181 GSM_Error
N71_65_GetNextCalendar2(GSM_StateMachine
*s
, GSM_CalendarEntry
*Note
, bool start
, int *LastCalendarYear
, int *LastCalendarPos
)
184 GSM_DateTime date_time
;
185 unsigned char req
[] = {
186 N6110_FRAME_HEADER
, 0x3e,
187 0xFF, 0xFE}; /* Location */
190 /* We have to get current year. It's NOT written in frame for
193 error
=s
->Phone
.Functions
->GetDateTime(s
,&date_time
);
196 case GE_NOTIMPLEMENTED
:
197 GSM_GetCurrentDateTime(&date_time
);
204 *LastCalendarYear
= date_time
.Year
;
206 /* First location at all */
210 req
[4] = *LastCalendarPos
>> 8;
211 req
[5] = *LastCalendarPos
& 0xff;
213 Note
->EntriesNum
= 0;
214 Note
->Entries
[0].Date
.Year
= *LastCalendarYear
;
216 s
->Phone
.Data
.Cal
= Note
;
217 smprintf(s
, "Getting calendar note method 2\n");
218 error
=GSM_WaitFor (s
, req
, 6, 0x13, 4, ID_GetCalendarNote
);
219 *LastCalendarPos
= Note
->Location
;
225 /* How should editor hadle tabs in this file? Add editor commands here.
226 * vim: noexpandtab sw=8 ts=8 sts=8: