summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/at
authorzautrix <zautrix>2004-10-25 08:56:23 (UTC)
committer zautrix <zautrix>2004-10-25 08:56:23 (UTC)
commit62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3 (patch) (unidiff)
treec2b7a41b0c8fffdc0786b84ff86724ea8f08d6a1 /gammu/emb/common/phone/at
parentfeff0930372dd51af24dc3b46697e70838277ea5 (diff)
downloadkdepimpi-62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3.zip
kdepimpi-62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3.tar.gz
kdepimpi-62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3.tar.bz2
gammu updates
Diffstat (limited to 'gammu/emb/common/phone/at') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/at/atgen.c8
-rw-r--r--gammu/emb/common/phone/at/sonyeric.c19
2 files changed, 17 insertions, 10 deletions
diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c
index ba23eb2..a875f0a 100644
--- a/gammu/emb/common/phone/at/atgen.c
+++ b/gammu/emb/common/phone/at/atgen.c
@@ -675,49 +675,49 @@ GSM_Error ATGEN_Initialise(GSM_StateMachine *s)
675 675
676 smprintf(s, "Enabling CME errors\n"); 676 smprintf(s, "Enabling CME errors\n");
677 /* Try numeric errors */ 677 /* Try numeric errors */
678 if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { 678 if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
679 /* Try textual errors */ 679 /* Try textual errors */
680 if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { 680 if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) {
681 smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n"); 681 smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n");
682 } 682 }
683 } 683 }
684 684
685 error = ATGEN_GetModel(s); 685 error = ATGEN_GetModel(s);
686 if (error != ERR_NONE) return error; 686 if (error != ERR_NONE) return error;
687 687
688 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) { 688 if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) {
689 s->Protocol.Data.AT.FastWrite = true; 689 s->Protocol.Data.AT.FastWrite = true;
690 } 690 }
691 691
692 return error; 692 return error;
693} 693}
694 694
695GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) 695GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
696{ 696{
697 unsigned char req[50]; 697 unsigned char req[50];
698 698
699 if (smsc->Location!=1) return ERR_NOTSUPPORTED; 699 if (smsc->Location!=1) return ERR_INVALIDLOCATION;
700 700
701 sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number)); 701 sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number));
702 702
703 smprintf(s, "Setting SMSC\n"); 703 smprintf(s, "Setting SMSC\n");
704 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC); 704 return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC);
705} 705}
706 706
707GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s) 707GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s)
708{ 708{
709 switch (s->Phone.Data.Priv.ATGEN.ReplyState) { 709 switch (s->Phone.Data.Priv.ATGEN.ReplyState) {
710 case AT_Reply_OK: 710 case AT_Reply_OK:
711 /* Reply here is: 711 /* Reply here is:
712 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]] 712 * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]]
713 * each memory is in quotes, 713 * each memory is in quotes,
714 * Example: ("SM"), ("SM"), ("SM") 714 * Example: ("SM"), ("SM"), ("SM")
715 * 715 *
716 * We need to get from this supported memories. For this case 716 * We need to get from this supported memories. For this case
717 * we assume, that just appearence of memory makes it 717 * we assume, that just appearence of memory makes it
718 * available for everything. Then we need to find out whether 718 * available for everything. Then we need to find out whether
719 * phone supports writing to memory. This is done by searching 719 * phone supports writing to memory. This is done by searching
720 * for "), (", which will appear between lists. 720 * for "), (", which will appear between lists.
721 */ 721 */
722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false; 722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) { 723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
@@ -3818,45 +3818,51 @@ GSM_Phone_Functions ATGENPhone = {
3818 NOTSUPPORTED, /* GetMMSSettings */ 3818 NOTSUPPORTED, /* GetMMSSettings */
3819 NOTSUPPORTED, /* SetMMSSettings */ 3819 NOTSUPPORTED, /* SetMMSSettings */
3820 NOTSUPPORTED, /* GetSyncMLSettings*/ 3820 NOTSUPPORTED, /* GetSyncMLSettings*/
3821 NOTSUPPORTED, /* SetSyncMLSettings*/ 3821 NOTSUPPORTED, /* SetSyncMLSettings*/
3822 NOTSUPPORTED, /* GetChatSettings */ 3822 NOTSUPPORTED, /* GetChatSettings */
3823 NOTSUPPORTED, /* SetChatSettings */ 3823 NOTSUPPORTED, /* SetChatSettings */
3824 ATGEN_GetBitmap, /* GetBitmap */ 3824 ATGEN_GetBitmap, /* GetBitmap */
3825 ATGEN_SetBitmap, /* SetBitmap */ 3825 ATGEN_SetBitmap, /* SetBitmap */
3826 SONYERIC_GetToDoStatus, 3826 SONYERIC_GetToDoStatus,
3827 NOTSUPPORTED, /* GetToDo */ 3827 NOTSUPPORTED, /* GetToDo */
3828 SONYERIC_GetNextToDo, 3828 SONYERIC_GetNextToDo,
3829 NOTSUPPORTED, /* SetToDo */ 3829 NOTSUPPORTED, /* SetToDo */
3830 SONYERIC_AddToDo, 3830 SONYERIC_AddToDo,
3831 NOTSUPPORTED, /* DeleteToDo */ 3831 NOTSUPPORTED, /* DeleteToDo */
3832 SONYERIC_DeleteAllToDo, 3832 SONYERIC_DeleteAllToDo,
3833 SONYERIC_GetCalendarStatus, 3833 SONYERIC_GetCalendarStatus,
3834 NOTIMPLEMENTED, /* GetCalendar */ 3834 NOTIMPLEMENTED, /* GetCalendar */
3835 ATGEN_GetNextCalendar, 3835 ATGEN_GetNextCalendar,
3836 NOTIMPLEMENTED, /* SetCalendar */ 3836 NOTIMPLEMENTED, /* SetCalendar */
3837 ATGEN_AddCalendarNote, 3837 ATGEN_AddCalendarNote,
3838 ATGEN_DelCalendarNote, 3838 ATGEN_DelCalendarNote,
3839 NOTIMPLEMENTED, /* DeleteAllCalendar*/ 3839 NOTIMPLEMENTED, /* DeleteAllCalendar*/
3840 NOTSUPPORTED, /* GetCalendarSettings*/ 3840 NOTSUPPORTED, /* GetCalendarSettings*/
3841 NOTSUPPORTED, /* SetCalendarSettings*/ 3841 NOTSUPPORTED, /* SetCalendarSettings*/
3842 NOTSUPPORTED, /* GetNoteStatus */
3843 NOTSUPPORTED, /* GetNote */
3842 NOTSUPPORTED, /* GetNextNote */ 3844 NOTSUPPORTED, /* GetNextNote */
3845 NOTSUPPORTED, /* SetNote */
3846 NOTSUPPORTED, /* AddNote */
3847 NOTSUPPORTED, /* DeleteNote */
3848 NOTSUPPORTED, /* DeleteAllNotes */
3843 NOTSUPPORTED, /* GetProfile */ 3849 NOTSUPPORTED, /* GetProfile */
3844 NOTSUPPORTED, /* SetProfile */ 3850 NOTSUPPORTED, /* SetProfile */
3845 NOTSUPPORTED, /* GetFMStation */ 3851 NOTSUPPORTED, /* GetFMStation */
3846 NOTSUPPORTED, /* SetFMStation */ 3852 NOTSUPPORTED, /* SetFMStation */
3847 NOTSUPPORTED, /* ClearFMStations */ 3853 NOTSUPPORTED, /* ClearFMStations */
3848 NOTSUPPORTED, /* GetNextFileFolder*/ 3854 NOTSUPPORTED, /* GetNextFileFolder*/
3849 NOTSUPPORTED, /* GetFilePart */ 3855 NOTSUPPORTED, /* GetFilePart */
3850 NOTSUPPORTED, /* AddFile */ 3856 NOTSUPPORTED, /* AddFile */
3851 NOTSUPPORTED, /* GetFileSystemStatus*/ 3857 NOTSUPPORTED, /* GetFileSystemStatus*/
3852 NOTSUPPORTED, /* DeleteFile */ 3858 NOTSUPPORTED, /* DeleteFile */
3853 NOTSUPPORTED, /* AddFolder */ 3859 NOTSUPPORTED, /* AddFolder */
3854 NOTSUPPORTED, /* GetGPRSAccessPoint*/ 3860 NOTSUPPORTED, /* GetGPRSAccessPoint*/
3855 NOTSUPPORTED /* SetGPRSAccessPoint*/ 3861 NOTSUPPORTED /* SetGPRSAccessPoint*/
3856}; 3862};
3857 3863
3858#endif 3864#endif
3859 3865
3860/* How should editor hadle tabs in this file? Add editor commands here. 3866/* How should editor hadle tabs in this file? Add editor commands here.
3861 * vim: noexpandtab sw=8 ts=8 sts=8: 3867 * vim: noexpandtab sw=8 ts=8 sts=8:
3862 */ 3868 */
diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c
index 8eeb39b..363e043 100644
--- a/gammu/emb/common/phone/at/sonyeric.c
+++ b/gammu/emb/common/phone/at/sonyeric.c
@@ -1,44 +1,45 @@
1/* (c) 2003 by Marcin Wiacek */ 1/* (c) 2003 by Marcin Wiacek */
2 2
3#include "../../gsmstate.h" 3#include "../../gsmstate.h"
4 4
5#ifdef GSM_ENABLE_ATGEN 5#ifdef GSM_ENABLE_ATGEN
6 6
7#include <string.h> 7#include <string.h>
8#include <time.h> 8#include <time.h>
9#include <ctype.h> 9#include <ctype.h>
10 10
11#include "../../gsmcomon.h" 11#include "../../gsmcomon.h"
12#include "../../misc/coding/coding.h" 12#include "../../misc/coding/coding.h"
13 13
14#include "atgen.h" 14#include "atgen.h"
15#include "sonyeric.h" 15#include "sonyeric.h"
16 16
17#ifdef GSM_ENABLE_OBEXGEN 17#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
18 18
19#include "../obex/obexgen.h" 19#include "../obex/obexgen.h"
20 20
21 extern GSM_Protocol_Functions OBEXProtocol;
21 extern GSM_Reply_FunctionOBEXGENReplyFunctions[]; 22 extern GSM_Reply_FunctionOBEXGENReplyFunctions[];
22 extern GSM_Reply_FunctionATGENReplyFunctions[]; 23 extern GSM_Reply_FunctionATGENReplyFunctions[];
23 24
24static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s) 25static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s)
25{ 26{
26 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 27 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
27 GSM_Error error; 28 GSM_Error error;
28 29
29 if (Priv->OBEX) return ERR_NONE; 30 if (Priv->OBEX) return ERR_NONE;
30 31
31 dbgprintf ("Changing to OBEX\n"); 32 dbgprintf ("Changing to OBEX\n");
32 33
33 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX); 34 error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX);
34 if (error != ERR_NONE) return error; 35 if (error != ERR_NONE) return error;
35 36
36 error = s->Protocol.Functions->Terminate(s); 37 error = s->Protocol.Functions->Terminate(s);
37 if (error != ERR_NONE) return error; 38 if (error != ERR_NONE) return error;
38 39
39 s->Protocol.Functions = &OBEXProtocol; 40 s->Protocol.Functions = &OBEXProtocol;
40 error = s->Protocol.Functions->Initialise(s); 41 error = s->Protocol.Functions->Initialise(s);
41 if (error != ERR_NONE) { 42 if (error != ERR_NONE) {
42 s->Protocol.Functions = &ATProtocol; 43 s->Protocol.Functions = &ATProtocol;
43 return error; 44 return error;
44 } 45 }
@@ -103,190 +104,190 @@ static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName,
103 GSM_File File; 104 GSM_File File;
104 int Pos = 0; 105 int Pos = 0;
105 106
106 error = SONYERIC_SetOBEXMode(s); 107 error = SONYERIC_SetOBEXMode(s);
107 if (error != ERR_NONE) return error; 108 if (error != ERR_NONE) return error;
108 109
109 strcpy(File.ID_FullName,FileName); 110 strcpy(File.ID_FullName,FileName);
110 EncodeUnicode(File.Name,FileName,strlen(FileName)); 111 EncodeUnicode(File.Name,FileName,strlen(FileName));
111 File.Used = Length; 112 File.Used = Length;
112 File.Buffer = malloc(Length); 113 File.Buffer = malloc(Length);
113 memcpy(File.Buffer,Buffer,Length); 114 memcpy(File.Buffer,Buffer,Length);
114 115
115 error = ERR_NONE; 116 error = ERR_NONE;
116 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos); 117 while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos);
117 free(File.Buffer); 118 free(File.Buffer);
118 if (error != ERR_EMPTY) return error; 119 if (error != ERR_EMPTY) return error;
119 120
120 return SONYERIC_SetATMode(s); 121 return SONYERIC_SetATMode(s);
121} 122}
122 123
123#endif 124#endif
124 125
125GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) 126GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
126{ 127{
127#ifdef GSM_ENABLE_OBEXGEN 128#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
128 GSM_Error error; 129 GSM_Error error;
129 GSM_ToDoEntry ToDo; 130 GSM_ToDoEntry ToDo;
130 int Pos, num, Loc; 131 int Pos, num, Loc;
131 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 132 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
132 133
133 if (start) { 134 if (start) {
134 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 135 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
135 if (error != ERR_NONE) return error; 136 if (error != ERR_NONE) return error;
136 137
137 Note->Location = 1; 138 Note->Location = 1;
138 } else { 139 } else {
139 Note->Location++; 140 Note->Location++;
140 } 141 }
141 smprintf(s, "Getting calendar note %i\n",Note->Location); 142 smprintf(s, "Getting calendar note %i\n",Note->Location);
142 143
143 Loc = Note->Location; 144 Loc = Note->Location;
144 Pos = 0; 145 Pos = 0;
145 num = 0; 146 num = 0;
146 while (1) { 147 while (1) {
147 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 148 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
148 if (error == ERR_EMPTY) break; 149 if (error == ERR_EMPTY) break;
149 if (error != ERR_NONE) return error; 150 if (error != ERR_NONE) return error;
150 if (Note->EntriesNum != 0) { 151 if (Note->EntriesNum != 0) {
151 num++; 152 num++;
152 if (num == Loc) return ERR_NONE; 153 if (num == Loc) return ERR_NONE;
153 } 154 }
154 } 155 }
155 return ERR_EMPTY; 156 return ERR_EMPTY;
156#else 157#else
157 return ERR_SOURCENOTAVAILABLE; 158 return ERR_SOURCENOTAVAILABLE;
158#endif 159#endif
159} 160}
160 161
161GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) 162GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start)
162{ 163{
163#ifdef GSM_ENABLE_OBEXGEN 164#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
164 GSM_Error error; 165 GSM_Error error;
165 GSM_CalendarEntryCalendar; 166 GSM_CalendarEntryCalendar;
166 int Pos, num, Loc; 167 int Pos, num, Loc;
167 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 168 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
168 169
169 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 170 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
170 171
171 if (start) { 172 if (start) {
172 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 173 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
173 if (error != ERR_NONE) return error; 174 if (error != ERR_NONE) return error;
174 175
175 ToDo->Location = 1; 176 ToDo->Location = 1;
176 } else { 177 } else {
177 ToDo->Location++; 178 ToDo->Location++;
178 } 179 }
179 smprintf(s,"Getting ToDo %i\n",ToDo->Location); 180 smprintf(s,"Getting ToDo %i\n",ToDo->Location);
180 181
181 Loc = ToDo->Location; 182 Loc = ToDo->Location;
182 Pos = 0; 183 Pos = 0;
183 num = 0; 184 num = 0;
184 while (1) { 185 while (1) {
185 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 186 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
186 if (error == ERR_EMPTY) break; 187 if (error == ERR_EMPTY) break;
187 if (error != ERR_NONE) return error; 188 if (error != ERR_NONE) return error;
188 if (ToDo->EntriesNum != 0) { 189 if (ToDo->EntriesNum != 0) {
189 num++; 190 num++;
190 if (num == Loc) return ERR_NONE; 191 if (num == Loc) return ERR_NONE;
191 } 192 }
192 } 193 }
193 194
194 return ERR_EMPTY; 195 return ERR_EMPTY;
195#else 196#else
196 return ERR_SOURCENOTAVAILABLE; 197 return ERR_SOURCENOTAVAILABLE;
197#endif 198#endif
198} 199}
199 200
200GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 201GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status)
201{ 202{
202#ifdef GSM_ENABLE_OBEXGEN 203#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
203 GSM_Error error; 204 GSM_Error error;
204 GSM_ToDoEntry ToDo; 205 GSM_ToDoEntry ToDo;
205 GSM_CalendarEntry Calendar; 206 GSM_CalendarEntry Calendar;
206 int Pos; 207 int Pos;
207 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 208 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
208 209
209 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 210 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
210 211
211 smprintf(s,"Getting ToDo status\n"); 212 smprintf(s,"Getting ToDo status\n");
212 213
213 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 214 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
214 if (error != ERR_NONE) return error; 215 if (error != ERR_NONE) return error;
215 216
216 status->Used = 0; 217 status->Used = 0;
217 Pos = 0; 218 Pos = 0;
218 while (1) { 219 while (1) {
219 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 220 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
220 if (error == ERR_EMPTY) break; 221 if (error == ERR_EMPTY) break;
221 if (error != ERR_NONE) return error; 222 if (error != ERR_NONE) return error;
222 if (ToDo.EntriesNum != 0) status->Used++; 223 if (ToDo.EntriesNum != 0) status->Used++;
223 } 224 }
224 225
225 return ERR_NONE; 226 return ERR_NONE;
226#else 227#else
227 return ERR_SOURCENOTAVAILABLE; 228 return ERR_SOURCENOTAVAILABLE;
228#endif 229#endif
229} 230}
230 231
231GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 232GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
232{ 233{
233#ifdef GSM_ENABLE_OBEXGEN 234#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
234 unsigned char req[5000]; 235 unsigned char req[5000];
235 int size=0; 236 int size=0;
236 237
237 smprintf(s,"Adding calendar note\n"); 238 smprintf(s,"Adding calendar note\n");
238 239
239 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar); 240 GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar);
240 241
241 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 242 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
242#else 243#else
243 return ERR_SOURCENOTAVAILABLE; 244 return ERR_SOURCENOTAVAILABLE;
244#endif 245#endif
245} 246}
246 247
247GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 248GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo)
248{ 249{
249#ifdef GSM_ENABLE_OBEXGEN 250#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
250 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 251 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
251 unsigned char req[5000]; 252 unsigned char req[5000];
252 int size=0; 253 int size=0;
253 254
254 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 255 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
255 256
256 smprintf(s,"Adding ToDo\n"); 257 smprintf(s,"Adding ToDo\n");
257 258
258 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo); 259 GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo);
259 260
260 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); 261 return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size);
261#else 262#else
262 return ERR_SOURCENOTAVAILABLE; 263 return ERR_SOURCENOTAVAILABLE;
263#endif 264#endif
264} 265}
265 266
266GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) 267GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
267{ 268{
268#ifdef GSM_ENABLE_OBEXGEN 269#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
269 GSM_Error error; 270 GSM_Error error;
270 int Pos,Level = 0,Used; 271 int Pos,Level = 0,Used;
271 unsigned char *Buf; 272 unsigned char *Buf;
272 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 273 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
273 unsigned char Line[2000]; 274 unsigned char Line[2000];
274 275
275 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 276 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
276 277
277 smprintf(s,"Deleting all ToDo\n"); 278 smprintf(s,"Deleting all ToDo\n");
278 279
279 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 280 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
280 if (error != ERR_NONE) return error; 281 if (error != ERR_NONE) return error;
281 282
282 Pos = 0; 283 Pos = 0;
283 Buf = NULL; 284 Buf = NULL;
284 Used = 0; 285 Used = 0;
285 while (1) { 286 while (1) {
286 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); 287 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
287 if (strlen(Line) == 0) break; 288 if (strlen(Line) == 0) break;
288 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); 289 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
289 switch (Level) { 290 switch (Level) {
290 case 0: 291 case 0:
291 if (strstr(Line,"BEGIN:VTODO")) { 292 if (strstr(Line,"BEGIN:VTODO")) {
292 Level = 2; 293 Level = 2;
@@ -296,49 +297,49 @@ GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s)
296 strcpy(Buf+Used,Line); 297 strcpy(Buf+Used,Line);
297 Used=Used+strlen(Line)+3; 298 Used=Used+strlen(Line)+3;
298 Buf[Used-3] = 13; 299 Buf[Used-3] = 13;
299 Buf[Used-2] = 10; 300 Buf[Used-2] = 10;
300 Buf[Used-1] = 0x00; 301 Buf[Used-1] = 0x00;
301 break; 302 break;
302 case 2: /* ToDo note */ 303 case 2: /* ToDo note */
303 if (strstr(Line,"END:VTODO")) { 304 if (strstr(Line,"END:VTODO")) {
304 Level = 0; 305 Level = 0;
305 } 306 }
306 break; 307 break;
307 } 308 }
308 } 309 }
309 310
310 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 311 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
311 //if (Buf != NULL) free(Buf); 312 //if (Buf != NULL) free(Buf);
312 return error; 313 return error;
313#else 314#else
314 return ERR_SOURCENOTAVAILABLE; 315 return ERR_SOURCENOTAVAILABLE;
315#endif 316#endif
316} 317}
317 318
318GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 319GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
319{ 320{
320#ifdef GSM_ENABLE_OBEXGEN 321#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
321 GSM_Error error; 322 GSM_Error error;
322 int Pos,Level = 0,Loc=0,Used; 323 int Pos,Level = 0,Loc=0,Used;
323 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 324 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
324 unsigned char Line[2000]; 325 unsigned char Line[2000];
325 unsigned char *Buf; 326 unsigned char *Buf;
326 327
327 smprintf(s, "Deleting calendar note %i\n",Note->Location); 328 smprintf(s, "Deleting calendar note %i\n",Note->Location);
328 329
329 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 330 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
330 if (error != ERR_NONE) return error; 331 if (error != ERR_NONE) return error;
331 332
332 Pos = 0; 333 Pos = 0;
333 Buf = NULL; 334 Buf = NULL;
334 Used = 0; 335 Used = 0;
335 while (1) { 336 while (1) {
336 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); 337 MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used);
337 if (strlen(Line) == 0) break; 338 if (strlen(Line) == 0) break;
338 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); 339 dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos);
339 switch (Level) { 340 switch (Level) {
340 case 0: 341 case 0:
341 if (strstr(Line,"BEGIN:VEVENT")) { 342 if (strstr(Line,"BEGIN:VEVENT")) {
342 Loc++; 343 Loc++;
343 if (Loc == Note->Location) { 344 if (Loc == Note->Location) {
344 Level = 1; 345 Level = 1;
@@ -351,49 +352,49 @@ GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
351 Buf[Used-3] = 13; 352 Buf[Used-3] = 13;
352 Buf[Used-2] = 10; 353 Buf[Used-2] = 10;
353 Buf[Used-1] = 0x00; 354 Buf[Used-1] = 0x00;
354 break; 355 break;
355 case 1: /* Calendar note */ 356 case 1: /* Calendar note */
356 if (strstr(Line,"END:VEVENT")) { 357 if (strstr(Line,"END:VEVENT")) {
357 Level = 0; 358 Level = 0;
358 } 359 }
359 break; 360 break;
360 } 361 }
361 } 362 }
362 363
363 DumpMessage(s->di.df, s->di.dl, Buf, Used); 364 DumpMessage(s->di.df, s->di.dl, Buf, Used);
364 365
365 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); 366 error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used);
366 if (Buf != NULL) free(Buf); 367 if (Buf != NULL) free(Buf);
367 return error; 368 return error;
368#else 369#else
369 return ERR_SOURCENOTAVAILABLE; 370 return ERR_SOURCENOTAVAILABLE;
370#endif 371#endif
371} 372}
372 373
373GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) 374GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
374{ 375{
375#ifdef GSM_ENABLE_OBEXGEN 376#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX)
376 GSM_Error error; 377 GSM_Error error;
377 GSM_ToDoEntry ToDo; 378 GSM_ToDoEntry ToDo;
378 GSM_CalendarEntry Calendar; 379 GSM_CalendarEntry Calendar;
379 int Pos; 380 int Pos;
380 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN; 381 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
381 382
382 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; 383 if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED;
383 384
384 smprintf(s, "Getting calendar status\n"); 385 smprintf(s, "Getting calendar status\n");
385 386
386 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); 387 error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs");
387 if (error != ERR_NONE) return error; 388 if (error != ERR_NONE) return error;
388 389
389 Status->Used = 0; 390 Status->Used = 0;
390 Pos = 0; 391 Pos = 0;
391 while (1) { 392 while (1) {
392 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); 393 error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo);
393 if (error == ERR_EMPTY) break; 394 if (error == ERR_EMPTY) break;
394 if (error != ERR_NONE) return error; 395 if (error != ERR_NONE) return error;
395 if (Calendar.EntriesNum != 0) Status->Used++; 396 if (Calendar.EntriesNum != 0) Status->Used++;
396 } 397 }
397 398
398 return ERR_NONE; 399 return ERR_NONE;
399#else 400#else