Diffstat (limited to 'gammu/emb/common/phone/alcatel/alcatel.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/phone/alcatel/alcatel.c | 298 |
1 files changed, 155 insertions, 143 deletions
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c index f004ad4..3821f13 100644 --- a/gammu/emb/common/phone/alcatel/alcatel.c +++ b/gammu/emb/common/phone/alcatel/alcatel.c | |||
@@ -1,494 +1,495 @@ | |||
1 | /* (c) 2002-2004 by Michal Cihar */ | 1 | /* (c) 2002-2004 by Michal Cihar */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * High level functions for communication with Alcatel One Touch 501 and | 4 | * High level functions for communication with Alcatel One Touch 501 and |
5 | * compatible mobile phone. | 5 | * compatible mobile phone. |
6 | * | 6 | * |
7 | * This code implements functions to communicate with Alcatel phones, | 7 | * This code implements functions to communicate with Alcatel phones, |
8 | * currently seem to work: | 8 | * currently seem to work: |
9 | * - BE5 series (501/701) | 9 | * - BE5 series (501/701) |
10 | * - BF5 series (715) | 10 | * - BF5 series (715) |
11 | * - BH4 series (535/735) | 11 | * - BH4 series (535/735) |
12 | * For some functions it uses normal AT mode (not implemented here, look at | 12 | * For some functions it uses normal AT mode (not implemented here, look at |
13 | * ../at/atgen.[ch]) for others it switches into binary mode and initialises | 13 | * ../at/atgen.[ch]) for others it switches into binary mode and initialises |
14 | * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and | 14 | * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and |
15 | * communicates over it. Don't ask me why Alcatel uses such silly thing... | 15 | * communicates over it. Don't ask me why Alcatel uses such silly thing... |
16 | * | 16 | * |
17 | * Notes for future features: | 17 | * Notes for future features: |
18 | * - max phone number length is 61 (BE5) | 18 | * - max phone number length is 61 (BE5) |
19 | * - max name length is 50 (BE5) | 19 | * - max name length is 50 (BE5) |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "../../gsmstate.h" | 22 | #include "../../gsmstate.h" |
23 | 23 | ||
24 | #ifdef GSM_ENABLE_ALCATEL | 24 | #ifdef GSM_ENABLE_ALCATEL |
25 | #ifdef GSM_ENABLE_ATGEN | 25 | #ifdef GSM_ENABLE_ATGEN |
26 | 26 | ||
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <time.h> | 28 | #include <time.h> |
29 | 29 | ||
30 | #include "../../gsmcomon.h" | 30 | #include "../../gsmcomon.h" |
31 | #include "../../misc/coding/coding.h" | 31 | #include "../../misc/coding/coding.h" |
32 | #include "../../misc/misc.h" | 32 | #include "../../misc/misc.h" |
33 | #include "../../service/sms/gsmsms.h" | 33 | #include "../../service/sms/gsmsms.h" |
34 | #include "../pfunc.h" | 34 | #include "../pfunc.h" |
35 | #include "alcatel.h" | 35 | #include "alcatel.h" |
36 | 36 | ||
37 | /* Timeout for GSM_WaitFor calls. */ | 37 | /* Timeout for GSM_WaitFor calls. */ |
38 | #define ALCATEL_TIMEOUT 64 | 38 | #define ALCATEL_TIMEOUT 64 |
39 | 39 | ||
40 | /* Some magic numbers for protocol follow */ | 40 | /* Some magic numbers for protocol follow */ |
41 | 41 | ||
42 | /* synchronisation types (for everything except begin transfer): */ | 42 | /* synchronisation types (for everything except begin transfer): */ |
43 | #define ALCATEL_SYNC_TYPE_CALENDAR0x64 | 43 | #define ALCATEL_SYNC_TYPE_CALENDAR0x64 |
44 | #define ALCATEL_SYNC_TYPE_TODO 0x68 | 44 | #define ALCATEL_SYNC_TYPE_TODO 0x68 |
45 | #define ALCATEL_SYNC_TYPE_CONTACTS0x6C | 45 | #define ALCATEL_SYNC_TYPE_CONTACTS0x6C |
46 | 46 | ||
47 | /* synchronisation types (for begin transfer): */ | 47 | /* synchronisation types (for begin transfer): */ |
48 | #define ALCATEL_BEGIN_SYNC_CALENDAR0x00 | 48 | #define ALCATEL_BEGIN_SYNC_CALENDAR0x00 |
49 | #define ALCATEL_BEGIN_SYNC_TODO 0x02 | 49 | #define ALCATEL_BEGIN_SYNC_TODO 0x02 |
50 | #define ALCATEL_BEGIN_SYNC_CONTACTS0x01 | 50 | #define ALCATEL_BEGIN_SYNC_CONTACTS0x01 |
51 | 51 | ||
52 | /* category types */ | 52 | /* category types */ |
53 | #define ALCATEL_LIST_TODO_CAT 0x9B | 53 | #define ALCATEL_LIST_TODO_CAT 0x9B |
54 | #define ALCATEL_LIST_CONTACTS_CAT0x96 | 54 | #define ALCATEL_LIST_CONTACTS_CAT0x96 |
55 | 55 | ||
56 | 56 | ||
57 | /* We need lot of ATGEN functions, because Alcatel is an AT device. */ | 57 | /* We need lot of ATGEN functions, because Alcatel is an AT device. */ |
58 | 58 | ||
59 | extern GSM_Reply_Function ALCATELReplyFunctions[]; | 59 | extern GSM_Reply_Function ALCATELReplyFunctions[]; |
60 | extern GSM_Reply_Function ATGENReplyFunctions[]; | 60 | extern GSM_Reply_Function ATGENReplyFunctions[]; |
61 | 61 | ||
62 | extern GSM_Error ATGEN_Initialise (GSM_StateMachine *s); | 62 | extern GSM_Error ATGEN_Initialise (GSM_StateMachine *s); |
63 | extern GSM_Error ATGEN_Terminate (GSM_StateMachine *s); | 63 | extern GSM_Error ATGEN_Terminate (GSM_StateMachine *s); |
64 | extern GSM_Error ATGEN_GetIMEI (GSM_StateMachine *s); | 64 | extern GSM_Error ATGEN_GetIMEI (GSM_StateMachine *s); |
65 | extern GSM_Error ATGEN_GetFirmware (GSM_StateMachine *s); | 65 | extern GSM_Error ATGEN_GetFirmware (GSM_StateMachine *s); |
66 | extern GSM_Error ATGEN_GetModel (GSM_StateMachine *s); | 66 | extern GSM_Error ATGEN_GetModel (GSM_StateMachine *s); |
67 | extern GSM_Error ATGEN_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); | 67 | extern GSM_Error ATGEN_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); |
68 | extern GSM_Error ATGEN_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); | 68 | extern GSM_Error ATGEN_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); |
69 | extern GSM_Error ATGEN_GetNextMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start); | 69 | extern GSM_Error ATGEN_GetNextMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start); |
70 | extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); | 70 | extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); |
71 | extern GSM_Error ATGEN_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); | 71 | extern GSM_Error ATGEN_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); |
72 | extern GSM_Error ATGEN_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); | 72 | extern GSM_Error ATGEN_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); |
73 | extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *Status); | 73 | extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *Status); |
74 | extern GSM_Error ATGEN_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); | 74 | extern GSM_Error ATGEN_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); |
75 | extern GSM_Error ATGEN_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); | 75 | extern GSM_Error ATGEN_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); |
76 | extern GSM_Error ATGEN_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders); | 76 | extern GSM_Error ATGEN_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders); |
77 | extern GSM_Error ATGEN_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status); | 77 | extern GSM_Error ATGEN_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status); |
78 | extern GSM_Error ATGEN_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms); | 78 | extern GSM_Error ATGEN_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms); |
79 | extern GSM_Error ATGEN_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start); | 79 | extern GSM_Error ATGEN_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start); |
80 | extern GSM_Error ATGEN_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location); | 80 | extern GSM_Error ATGEN_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location); |
81 | extern GSM_Error ATGEN_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); | 81 | extern GSM_Error ATGEN_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); |
82 | extern GSM_Error ATGEN_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); | 82 | extern GSM_Error ATGEN_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); |
83 | extern GSM_Error ATGEN_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); | 83 | extern GSM_Error ATGEN_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); |
84 | extern GSM_Error ATGEN_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat); | 84 | extern GSM_Error ATGEN_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat); |
85 | extern GSM_Error ATGEN_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig); | 85 | extern GSM_Error ATGEN_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig); |
86 | extern GSM_Error ATGEN_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber); | 86 | extern GSM_Error ATGEN_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber); |
87 | extern GSM_Error ATGEN_AnswerCall (GSM_StateMachine *s, int ID, bool all); | 87 | extern GSM_Error ATGEN_AnswerCall (GSM_StateMachine *s, int ID, bool all); |
88 | extern GSM_Error ATGEN_CancelCall (GSM_StateMachine *s, int ID, bool all); | 88 | extern GSM_Error ATGEN_CancelCall (GSM_StateMachine *s, int ID, bool all); |
89 | extern GSM_Error ATGEN_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); | 89 | extern GSM_Error ATGEN_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); |
90 | extern GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code); | 90 | extern GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code); |
91 | extern GSM_Error ATGEN_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status); | 91 | extern GSM_Error ATGEN_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status); |
92 | extern GSM_Error ATGEN_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type); | 92 | extern GSM_Error ATGEN_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type); |
93 | extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence); | 93 | extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence); |
94 | extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); | 94 | extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); |
95 | extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s); | 95 | extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s); |
96 | extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); | 96 | extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); |
97 | extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard); | 97 | extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard); |
98 | extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); | 98 | extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); |
99 | extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features); | 99 | extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features); |
100 | extern GSM_Error ATGEN_SetAutoNetworkLogin(GSM_StateMachine *s); | 100 | extern GSM_Error ATGEN_SetAutoNetworkLogin(GSM_StateMachine *s); |
101 | extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type); | 101 | extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type); |
102 | 102 | ||
103 | extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s); | 103 | extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s); |
104 | extern GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable); | ||
104 | extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); | 105 | extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); |
105 | extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); | 106 | extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); |
106 | 107 | ||
107 | /** | 108 | /** |
108 | * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table | 109 | * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table |
109 | * attempts to decode it, it is probably not complete, here are just chars | 110 | * attempts to decode it, it is probably not complete, here are just chars |
110 | * that I found... | 111 | * that I found... |
111 | */ | 112 | */ |
112 | unsigned char GSM_AlcatelAlphabet[] = | 113 | unsigned char GSM_AlcatelAlphabet[] = |
113 | { | 114 | { |
114 | /* in phone unicode description*/ | 115 | /* in phone unicode description*/ |
115 | 0x80, 0x00,0x20, /* empty */ | 116 | 0x80, 0x00,0x20, /* empty */ |
116 | 0x81, 0x00,0x20, /* empty*/ | 117 | 0x81, 0x00,0x20, /* empty*/ |
117 | 0x82, 0x00,0x20, /* empty*/ | 118 | 0x82, 0x00,0x20, /* empty*/ |
118 | 0x83, 0x00,0x20, /* empty*/ | 119 | 0x83, 0x00,0x20, /* empty*/ |
119 | 120 | ||
120 | 0x84, 0x00,0xe7, /* c cedilla*/ | 121 | 0x84, 0x00,0xe7, /* c cedilla*/ |
121 | 0x85, 0x20,0x26, /* ... */ | 122 | 0x85, 0x20,0x26, /* ... */ |
122 | 0x86, 0x03,0xc0, /* pi */ | 123 | 0x86, 0x03,0xc0, /* pi */ |
123 | 0x87, 0x01,0x3e, /* l caron*/ | 124 | 0x87, 0x01,0x3e, /* l caron*/ |
124 | 0x88, 0x00,0xc0, /* A grave*/ | 125 | 0x88, 0x00,0xc0, /* A grave*/ |
125 | 0x89, 0x00,0xc1, /* A acute*/ | 126 | 0x89, 0x00,0xc1, /* A acute*/ |
126 | 0x8a, 0x00,0xc2, /* A circumflex*/ | 127 | 0x8a, 0x00,0xc2, /* A circumflex*/ |
127 | 0x8b, 0x00,0xc3, /* A tilde*/ | 128 | 0x8b, 0x00,0xc3, /* A tilde*/ |
128 | 0x8c, 0x00,0xc8, /* E grave*/ | 129 | 0x8c, 0x00,0xc8, /* E grave*/ |
129 | 0x8d, 0x00,0xca, /* E circumflex*/ | 130 | 0x8d, 0x00,0xca, /* E circumflex*/ |
130 | 0x8e, 0x00,0xcb, /* E diaresis*/ | 131 | 0x8e, 0x00,0xcb, /* E diaresis*/ |
131 | 0x8f, 0x00,0xcc, /* I grave*/ | 132 | 0x8f, 0x00,0xcc, /* I grave*/ |
132 | 0x90, 0x00,0xcd, /* I acute*/ | 133 | 0x90, 0x00,0xcd, /* I acute*/ |
133 | 0x91, 0x00,0xd0, /* ETH */ | 134 | 0x91, 0x00,0xd0, /* ETH */ |
134 | 0x92, 0x00,0xd2, /* O grave*/ | 135 | 0x92, 0x00,0xd2, /* O grave*/ |
135 | 0x93, 0x00,0xd3, /* O acute*/ | 136 | 0x93, 0x00,0xd3, /* O acute*/ |
136 | 0x94, 0x00,0xd4, /* O circumflex*/ | 137 | 0x94, 0x00,0xd4, /* O circumflex*/ |
137 | 0x95, 0x00,0xd5, /* O tilde*/ | 138 | 0x95, 0x00,0xd5, /* O tilde*/ |
138 | 0x96, 0x00,0xd9, /* U grave*/ | 139 | 0x96, 0x00,0xd9, /* U grave*/ |
139 | 0x97, 0x00,0xda, /* U acute*/ | 140 | 0x97, 0x00,0xda, /* U acute*/ |
140 | 0x98, 0x00,0xe1, /* a acute*/ | 141 | 0x98, 0x00,0xe1, /* a acute*/ |
141 | 0x99, 0x00,0xe2, /* a circumflex*/ | 142 | 0x99, 0x00,0xe2, /* a circumflex*/ |
142 | 0x9a, 0x00,0xe3, /* a tilde*/ | 143 | 0x9a, 0x00,0xe3, /* a tilde*/ |
143 | 0x9b, 0x00,0xea, /* e circumflex*/ | 144 | 0x9b, 0x00,0xea, /* e circumflex*/ |
144 | 0x9c, 0x00,0xeb, /* e diaresis*/ | 145 | 0x9c, 0x00,0xeb, /* e diaresis*/ |
145 | 0x9d, 0x00,0xed, /* i acute*/ | 146 | 0x9d, 0x00,0xed, /* i acute*/ |
146 | 0x9e, 0x00,0xee, /* i circumflex*/ | 147 | 0x9e, 0x00,0xee, /* i circumflex*/ |
147 | 0x9f, 0x00,0xef, /* i diaresis*/ | 148 | 0x9f, 0x00,0xef, /* i diaresis*/ |
148 | 0xa0, 0x00,0xf3, /* o acute*/ | 149 | 0xa0, 0x00,0xf3, /* o acute*/ |
149 | 0xa1, 0x00,0xf4, /* o circumflex*/ | 150 | 0xa1, 0x00,0xf4, /* o circumflex*/ |
150 | 0xa2, 0x00,0xf5, /* o tilde*/ | 151 | 0xa2, 0x00,0xf5, /* o tilde*/ |
151 | 0xa3, 0x00,0xfa, /* u acute*/ | 152 | 0xa3, 0x00,0xfa, /* u acute*/ |
152 | 0xa4, 0x00,0xa2, /* cent */ | 153 | 0xa4, 0x00,0xa2, /* cent */ |
153 | 0xa5, 0x00,0x5b, /* [ */ | 154 | 0xa5, 0x00,0x5b, /* [ */ |
154 | 0xa6, 0x01,0x59, /* r caron*/ | 155 | 0xa6, 0x01,0x59, /* r caron*/ |
155 | 0xa7, 0x01,0x0d, /* c caron*/ | 156 | 0xa7, 0x01,0x0d, /* c caron*/ |
156 | 0xa8, 0x01,0x61, /* s caron*/ | 157 | 0xa8, 0x01,0x61, /* s caron*/ |
157 | 0xa9, 0x01,0x1b, /* e caron*/ | 158 | 0xa9, 0x01,0x1b, /* e caron*/ |
158 | 0xaa, 0x01,0x6f, /* u ring*/ | 159 | 0xaa, 0x01,0x6f, /* u ring*/ |
159 | 0xab, 0x00,0xfd, /* y acute*/ | 160 | 0xab, 0x00,0xfd, /* y acute*/ |
160 | 0xac, 0x00,0xf0, /* eth */ | 161 | 0xac, 0x00,0xf0, /* eth */ |
161 | 0xad, 0x01,0x07, /* c acute*/ | 162 | 0xad, 0x01,0x07, /* c acute*/ |
162 | 0xae, 0x01,0x19, /* e ogonek*/ | 163 | 0xae, 0x01,0x19, /* e ogonek*/ |
163 | 0xaf, 0x01,0x05, /* a ogonek*/ | 164 | 0xaf, 0x01,0x05, /* a ogonek*/ |
164 | 0xb0, 0x01,0x7c, /* z dot*/ | 165 | 0xb0, 0x01,0x7c, /* z dot*/ |
165 | 0xb1, 0x01,0x7a, /* z acute*/ | 166 | 0xb1, 0x01,0x7a, /* z acute*/ |
166 | 0xb2, 0x01,0x5b, /* s acute*/ | 167 | 0xb2, 0x01,0x5b, /* s acute*/ |
167 | 0xb3, 0x01,0x44, /* n acute*/ | 168 | 0xb3, 0x01,0x44, /* n acute*/ |
168 | 0xb4, 0x01,0x42, /* l stroke*/ | 169 | 0xb4, 0x01,0x42, /* l stroke*/ |
169 | 170 | ||
170 | 0xb5, 0x00,0x20, /* empty*/ | 171 | 0xb5, 0x00,0x20, /* empty*/ |
171 | 172 | ||
172 | 0xb6, 0x01,0x48, /* n caron*/ | 173 | 0xb6, 0x01,0x48, /* n caron*/ |
173 | 0xb7, 0x01,0x65, /* t caron*/ | 174 | 0xb7, 0x01,0x65, /* t caron*/ |
174 | 175 | ||
175 | 0xb8, 0x00,0x20, /* empty*/ | 176 | 0xb8, 0x00,0x20, /* empty*/ |
176 | 177 | ||
177 | 0xb9, 0x01,0x7e, /* z caron*/ | 178 | 0xb9, 0x01,0x7e, /* z caron*/ |
178 | 0xba, 0x01,0xe7, /* g caron*/ | 179 | 0xba, 0x01,0xe7, /* g caron*/ |
179 | 180 | ||
180 | 0xbb, 0x00,0x20, /* empty*/ | 181 | 0xbb, 0x00,0x20, /* empty*/ |
181 | 0xbc, 0x00,0x20, /* empty*/ | 182 | 0xbc, 0x00,0x20, /* empty*/ |
182 | 183 | ||
183 | 0xbd, 0x1e,0x20, /* G macron*/ | 184 | 0xbd, 0x1e,0x20, /* G macron*/ |
184 | 0xbe, 0x1e,0x21, /* g macron*/ | 185 | 0xbe, 0x1e,0x21, /* g macron*/ |
185 | 0xbf, 0x01,0x5e, /* S cedilla*/ | 186 | 0xbf, 0x01,0x5e, /* S cedilla*/ |
186 | 0xc0, 0x01,0x5f, /* s cedilla*/ | 187 | 0xc0, 0x01,0x5f, /* s cedilla*/ |
187 | 0xc1, 0x01,0x2f, /* i ogonek*/ /* FIXME: not sure with this, it look like normal i */ | 188 | 0xc1, 0x01,0x2f, /* i ogonek*/ /* FIXME: not sure with this, it look like normal i */ |
188 | 0xc2, 0x01,0x31, /* i dotless*/ | 189 | 0xc2, 0x01,0x31, /* i dotless*/ |
189 | 0xc3, 0x01,0x68, /* U tilde*/ | 190 | 0xc3, 0x01,0x68, /* U tilde*/ |
190 | 0xc4, 0x01,0x50, /* O dbl acute*/ | 191 | 0xc4, 0x01,0x50, /* O dbl acute*/ |
191 | 0xc5, 0x01,0x69, /* u tilde*/ | 192 | 0xc5, 0x01,0x69, /* u tilde*/ |
192 | 0xc6, 0x01,0x51, /* o dbl acute*/ | 193 | 0xc6, 0x01,0x51, /* o dbl acute*/ |
193 | 0xc7, 0x27,0xa9, /* => */ | 194 | 0xc7, 0x27,0xa9, /* => */ |
194 | 0xc8, 0x27,0xa8, /* filled =>*/ | 195 | 0xc8, 0x27,0xa8, /* filled =>*/ |
195 | 0xc9, 0x00,0xd7, /* x */ | 196 | 0xc9, 0x00,0xd7, /* x */ |
196 | 0xca, 0x00,0x5d, /* ] */ | 197 | 0xca, 0x00,0x5d, /* ] */ |
197 | 0xcb, 0x26,0x0f, /* phone*/ | 198 | 0xcb, 0x26,0x0f, /* phone*/ |
198 | 0xcc, 0x01,0x0f, /* d caron*/ | 199 | 0xcc, 0x01,0x0f, /* d caron*/ |
199 | 200 | ||
200 | 0xcd, 0x00,0x20, /* empty*/ | 201 | 0xcd, 0x00,0x20, /* empty*/ |
201 | 202 | ||
202 | 0xce, 0x00,0x7e, /* ~ */ | 203 | 0xce, 0x00,0x7e, /* ~ */ |
203 | 0xcf, 0x00,0x5c, /* \ */ | 204 | 0xcf, 0x00,0x5c, /* \ */ |
204 | 0xd0, 0x00,0x5e, /* ^ */ | 205 | 0xd0, 0x00,0x5e, /* ^ */ |
205 | 206 | ||
206 | 0xd1, 0x00,0x20, /* empty*/ | 207 | 0xd1, 0x00,0x20, /* empty*/ |
207 | 208 | ||
208 | 0xd2, 0x00,0x7b, /* { */ | 209 | 0xd2, 0x00,0x7b, /* { */ |
209 | 0xd3, 0x00,0x7c, /* | */ | 210 | 0xd3, 0x00,0x7c, /* | */ |
210 | 0xd4, 0x00,0x7d, /* } */ | 211 | 0xd4, 0x00,0x7d, /* } */ |
211 | 212 | ||
212 | 0xd5, 0x00,0x20, /* empty*/ | 213 | 0xd5, 0x00,0x20, /* empty*/ |
213 | 214 | ||
214 | 0xd6, 0x01,0x63, /* t cedilla*/ | 215 | 0xd6, 0x01,0x63, /* t cedilla*/ |
215 | 216 | ||
216 | 0xd7, 0x00,0x20, /* empty*/ | 217 | 0xd7, 0x00,0x20, /* empty*/ |
217 | 0xd8, 0x00,0x20, /* empty*/ | 218 | 0xd8, 0x00,0x20, /* empty*/ |
218 | 0xd9, 0x00,0x20, /* empty*/ | 219 | 0xd9, 0x00,0x20, /* empty*/ |
219 | 0xda, 0x00,0x20, /* empty*/ | 220 | 0xda, 0x00,0x20, /* empty*/ |
220 | 0xdb, 0x00,0x20, /* empty*/ | 221 | 0xdb, 0x00,0x20, /* empty*/ |
221 | 0xdc, 0x00,0x20, /* empty*/ | 222 | 0xdc, 0x00,0x20, /* empty*/ |
222 | 0xdd, 0x00,0x20, /* empty*/ | 223 | 0xdd, 0x00,0x20, /* empty*/ |
223 | 0xde, 0x00,0x20, /* empty*/ | 224 | 0xde, 0x00,0x20, /* empty*/ |
224 | 0xdf, 0x00,0x20, /* empty*/ | 225 | 0xdf, 0x00,0x20, /* empty*/ |
225 | 0xe0, 0x00,0x20, /* empty*/ | 226 | 0xe0, 0x00,0x20, /* empty*/ |
226 | 227 | ||
227 | 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */ | 228 | 0xe1, 0x00,0x20, /* two candles*/ /* FIXME */ |
228 | 229 | ||
229 | 0xe2, 0x00,0x20, /* empty*/ | 230 | 0xe2, 0x00,0x20, /* empty*/ |
230 | 0xe3, 0x00,0x20, /* empty*/ | 231 | 0xe3, 0x00,0x20, /* empty*/ |
231 | 0xe4, 0x00,0x20, /* empty*/ | 232 | 0xe4, 0x00,0x20, /* empty*/ |
232 | 233 | ||
233 | 0xe5, 0x01,0xce, /* a caron*/ | 234 | 0xe5, 0x01,0xce, /* a caron*/ |
234 | 0xe6, 0x01,0x01, /* a macron*/ | 235 | 0xe6, 0x01,0x01, /* a macron*/ |
235 | 0xe7, 0x01,0x13, /* e macron*/ | 236 | 0xe7, 0x01,0x13, /* e macron*/ |
236 | 0xe8, 0x01,0x2b, /* i macron*/ | 237 | 0xe8, 0x01,0x2b, /* i macron*/ |
237 | 0xe9, 0x01,0x4d, /* o macron*/ | 238 | 0xe9, 0x01,0x4d, /* o macron*/ |
238 | 0xea, 0x01,0x6b, /* u macron*/ | 239 | 0xea, 0x01,0x6b, /* u macron*/ |
239 | 0xeb, 0x00,0x41, /* A */ | 240 | 0xeb, 0x00,0x41, /* A */ |
240 | 0xec, 0x00,0x40, /* @ */ | 241 | 0xec, 0x00,0x40, /* @ */ |
241 | 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */ | 242 | 0xed, 0x00,0x20,/* some strange char :-) */ /* FIXME */ |
242 | 243 | ||
243 | 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */ | 244 | 0xee, 0x00,0x20, /* big key stroken*/ /* FIXME */ |
244 | 0xef, 0x00,0x20, /* big key*/ /* FIXME */ | 245 | 0xef, 0x00,0x20, /* big key*/ /* FIXME */ |
245 | 246 | ||
246 | 0xf0, 0x00,0x20, /* empty*/ | 247 | 0xf0, 0x00,0x20, /* empty*/ |
247 | 248 | ||
248 | 0xf1, 0x00,0x31, /* 1 */ | 249 | 0xf1, 0x00,0x31, /* 1 */ |
249 | 0xf2, 0x00,0x21, /* bold !*/ | 250 | 0xf2, 0x00,0x21, /* bold !*/ |
250 | 0xf3, 0x26,0x0e, /* black phone*/ | 251 | 0xf3, 0x26,0x0e, /* black phone*/ |
251 | 0xf4, 0x00,0x26, /* & */ | 252 | 0xf4, 0x00,0x26, /* & */ |
252 | 0xf5, 0x23,0x7e, /* bell */ | 253 | 0xf5, 0x23,0x7e, /* bell */ |
253 | 0xf6, 0x26,0x6a, /* note */ | 254 | 0xf6, 0x26,0x6a, /* note */ |
254 | 255 | ||
255 | 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */ | 256 | 0xf7, 0x27,0x13, /* okay inv*/ /* FIXME */ |
256 | 0xf8, 0x27,0x13, /* okay */ | 257 | 0xf8, 0x27,0x13, /* okay */ |
257 | 258 | ||
258 | 0xf9, 0x00,0x20, /* empty*/ | 259 | 0xf9, 0x00,0x20, /* empty*/ |
259 | 260 | ||
260 | 0xfa, 0x00,0x20, /* key */ /* FIXME */ | 261 | 0xfa, 0x00,0x20, /* key */ /* FIXME */ |
261 | 262 | ||
262 | 0xfb, 0x00,0x20, /* empty*/ | 263 | 0xfb, 0x00,0x20, /* empty*/ |
263 | 264 | ||
264 | 0xfc, 0x20,0xac, /* Euro */ | 265 | 0xfc, 0x20,0xac, /* Euro */ |
265 | 0xfd, 0x21,0x97, /* NE arrow*/ | 266 | 0xfd, 0x21,0x97, /* NE arrow*/ |
266 | 0xfe, 0x21,0x98, /* SE arrow*/ | 267 | 0xfe, 0x21,0x98, /* SE arrow*/ |
267 | 268 | ||
268 | 0xff, 0x00,0x20, /* empty*/ | 269 | 0xff, 0x00,0x20, /* empty*/ |
269 | 270 | ||
270 | 0x00, 0x00,0x00 | 271 | 0x00, 0x00,0x00 |
271 | }; | 272 | }; |
272 | 273 | ||
273 | /* This is being called from atgen */ | 274 | /* This is being called from atgen */ |
274 | GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s) | 275 | GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s) |
275 | { | 276 | { |
276 | char *str, *str2; | 277 | char *str, *str2; |
277 | /* | 278 | /* |
278 | * Reply received here looks like: | 279 | * Reply received here looks like: |
279 | * 1 "AT+CPROT=?" | 280 | * 1 "AT+CPROT=?" |
280 | * 2 "+CPROT: 0,"V1.0",1" | 281 | * 2 "+CPROT: 0,"V1.0",1" |
281 | * 3 "+CPROT: 16,"V1.1",16" | 282 | * 3 "+CPROT: 16,"V1.1",16" |
282 | * 4 "OK" | 283 | * 4 "OK" |
283 | */ | 284 | */ |
284 | switch (s->Phone.Data.Priv.ATGEN.ReplyState) { | 285 | switch (s->Phone.Data.Priv.ATGEN.ReplyState) { |
285 | case AT_Reply_OK: | 286 | case AT_Reply_OK: |
286 | str = strstr(msg.Buffer, "\"V"); | 287 | str = strstr(msg.Buffer, "\"V"); |
287 | if (str == NULL) return ERR_UNKNOWNRESPONSE; | 288 | if (str == NULL) return ERR_UNKNOWNRESPONSE; |
288 | str += 2; | 289 | str += 2; |
289 | while((str2 = strstr(str, "\"V")) != NULL) str = str2 + 2; | 290 | while((str2 = strstr(str, "\"V")) != NULL) str = str2 + 2; |
290 | if (strncmp(str, "1.0", 3) == 0) { | 291 | if (strncmp(str, "1.0", 3) == 0) { |
291 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_0; | 292 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_0; |
292 | } else if (strncmp(str, "1.1", 3) == 0) { | 293 | } else if (strncmp(str, "1.1", 3) == 0) { |
293 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_1; | 294 | s->Phone.Data.Priv.ALCATEL.ProtocolVersion = V_1_1; |
294 | } else { | 295 | } else { |
295 | smprintf(s, "Unknown protocol version. Please send debug log and phone info to author.\n"); | 296 | smprintf(s, "Unknown protocol version. Please send debug log and phone info to author.\n"); |
296 | return ERR_NOTIMPLEMENTED; | 297 | return ERR_NOTIMPLEMENTED; |
297 | } | 298 | } |
298 | return ERR_NONE; | 299 | return ERR_NONE; |
299 | case AT_Reply_Error: | 300 | case AT_Reply_Error: |
300 | case AT_Reply_CMSError: | 301 | case AT_Reply_CMSError: |
301 | return ATGEN_HandleCMSError(s); | 302 | return ATGEN_HandleCMSError(s); |
302 | default: | 303 | default: |
303 | return ERR_UNKNOWNRESPONSE; | 304 | return ERR_UNKNOWNRESPONSE; |
304 | } | 305 | } |
305 | } | 306 | } |
306 | 307 | ||
307 | static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) | 308 | static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) |
308 | { | 309 | { |
309 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 310 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
310 | GSM_Error error; | 311 | GSM_Error error; |
311 | 312 | ||
312 | if (Priv->Mode == ModeBinary) return ERR_NONE; | 313 | if (Priv->Mode == ModeBinary) return ERR_NONE; |
313 | 314 | ||
314 | dbgprintf ("Changing to binary mode\n"); | 315 | dbgprintf ("Changing to binary mode\n"); |
315 | 316 | ||
316 | error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl); | 317 | error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl); |
317 | if (error != ERR_NONE) return error; | 318 | if (error != ERR_NONE) return error; |
318 | 319 | ||
319 | error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol); | 320 | error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol); |
320 | if (error != ERR_NONE) return error; | 321 | if (error != ERR_NONE) return error; |
321 | 322 | ||
322 | if (Priv->ProtocolVersion == V_1_0) { | 323 | if (Priv->ProtocolVersion == V_1_0) { |
323 | error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.0\",16\r", 22, 0x00, 4, ID_AlcatelConnect); | 324 | error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.0\",16\r", 22, 0x00, 4, ID_AlcatelConnect); |
324 | } else { | 325 | } else { |
325 | error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect); | 326 | error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect); |
326 | } | 327 | } |
327 | 328 | ||
328 | if (error == ERR_TIMEOUT && s->Speed != 19200) { | 329 | if (error == ERR_TIMEOUT && s->Speed != 19200) { |
329 | smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n"); | 330 | smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n"); |
330 | } | 331 | } |
331 | 332 | ||
332 | if (error != ERR_NONE) return error; | 333 | if (error != ERR_NONE) return error; |
333 | 334 | ||
334 | dbgprintf ("Changing protocol to Alcabus\n"); | 335 | dbgprintf ("Changing protocol to Alcabus\n"); |
335 | 336 | ||
336 | s->Protocol.Functions = &ALCABUSProtocol; | 337 | s->Protocol.Functions = &ALCABUSProtocol; |
337 | error = s->Protocol.Functions->Initialise(s); | 338 | error = s->Protocol.Functions->Initialise(s); |
338 | if (error != ERR_NONE) { | 339 | if (error != ERR_NONE) { |
339 | s->Protocol.Functions = &ATProtocol; | 340 | s->Protocol.Functions = &ATProtocol; |
340 | return error; | 341 | return error; |
341 | } | 342 | } |
342 | s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions; | 343 | s->Phone.Functions->ReplyFunctions= ALCATELReplyFunctions; |
343 | Priv->Mode = ModeBinary; | 344 | Priv->Mode = ModeBinary; |
344 | Priv->BinaryItem = 0; | 345 | Priv->BinaryItem = 0; |
345 | Priv->BinaryType = 0; | 346 | Priv->BinaryType = 0; |
346 | Priv->BinaryState = StateAttached; | 347 | Priv->BinaryState = StateAttached; |
347 | return ERR_NONE; | 348 | return ERR_NONE; |
348 | } | 349 | } |
349 | 350 | ||
350 | static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_BinaryState state, GSM_Alcatel_BinaryType type, int item) { | 351 | static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_BinaryState state, GSM_Alcatel_BinaryType type, int item) { |
351 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 352 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
352 | GSM_Error error; | 353 | GSM_Error error; |
353 | unsigned char attach_buffer[] = {0x00, 0x00, 0x7C ,0x20}; | 354 | unsigned char attach_buffer[] = {0x00, 0x00, 0x7C ,0x20}; |
354 | unsigned char detach_buffer[] = {0x00, 0x01, 0x7C ,0x00}; | 355 | unsigned char detach_buffer[] = {0x00, 0x01, 0x7C ,0x00}; |
355 | unsigned char start_buffer[] = | 356 | unsigned char start_buffer[] = |
356 | {0x00, 0x04, 0x7C, 0x80, /* 4 byte database id follows */ | 357 | {0x00, 0x04, 0x7C, 0x80, /* 4 byte database id follows */ |
357 | 0x12, 0x34, 0x56, 0x78}; | 358 | 0x12, 0x34, 0x56, 0x78}; |
358 | unsigned char end_buffer[] = | 359 | unsigned char end_buffer[] = |
359 | {0x00, 0x04, 0x7C, 0x82, | 360 | {0x00, 0x04, 0x7C, 0x82, |
360 | 0x00, /* type */ | 361 | 0x00, /* type */ |
361 | 0x00, 0x00, 0x00, 0x00}; /* TimeStamp */ | 362 | 0x00, 0x00, 0x00, 0x00}; /* TimeStamp */ |
362 | unsigned char close_buffer[] = | 363 | unsigned char close_buffer[] = |
363 | {0x00, 0x04, | 364 | {0x00, 0x04, |
364 | 0x00, /*type */ | 365 | 0x00, /*type */ |
365 | 0x23, 0x01}; | 366 | 0x23, 0x01}; |
366 | unsigned char select1_buffer[] = | 367 | unsigned char select1_buffer[] = |
367 | {0x00, 0x00, | 368 | {0x00, 0x00, |
368 | 0x00, /*type */ | 369 | 0x00, /*type */ |
369 | 0x20}; | 370 | 0x20}; |
370 | unsigned char select2_buffer[] = | 371 | unsigned char select2_buffer[] = |
371 | {0x00, 0x04, | 372 | {0x00, 0x04, |
372 | 0x00, /*type */ | 373 | 0x00, /*type */ |
373 | 0x22, 0x01, 0x00}; | 374 | 0x22, 0x01, 0x00}; |
374 | unsigned char begin_buffer[] = | 375 | unsigned char begin_buffer[] = |
375 | {0x00, 0x04, 0x7C, 0x81, | 376 | {0x00, 0x04, 0x7C, 0x81, |
376 | 0x00, /*type */ | 377 | 0x00, /*type */ |
377 | 0x00, 0x85, 0x00}; | 378 | 0x00, 0x85, 0x00}; |
378 | unsigned char commit_buffer[] = | 379 | unsigned char commit_buffer[] = |
379 | {0x00, 0x04, | 380 | {0x00, 0x04, |
380 | 0x00, /*type */ | 381 | 0x00, /*type */ |
381 | 0x20, 0x01}; | 382 | 0x20, 0x01}; |
382 | 383 | ||
383 | smprintf(s, "Alcatel state switcher: %d -> %d, %d -> %d, %d -> %d\n", Priv->BinaryState, state, Priv->BinaryType, type, Priv->BinaryItem, item); | 384 | smprintf(s, "Alcatel state switcher: %d -> %d, %d -> %d, %d -> %d\n", Priv->BinaryState, state, Priv->BinaryType, type, Priv->BinaryItem, item); |
384 | error = ALCATEL_SetBinaryMode(s); | 385 | error = ALCATEL_SetBinaryMode(s); |
385 | if (error != ERR_NONE) return error; | 386 | if (error != ERR_NONE) return error; |
386 | 387 | ||
387 | /* Do we need to do anything? */ | 388 | /* Do we need to do anything? */ |
388 | if ((state == Priv->BinaryState) && (type == Priv->BinaryType) && (item == Priv->BinaryItem)) return ERR_NONE; | 389 | if ((state == Priv->BinaryState) && (type == Priv->BinaryType) && (item == Priv->BinaryItem)) return ERR_NONE; |
389 | 390 | ||
390 | /* We're editing, but the next state is not the same. so commit editing */ | 391 | /* We're editing, but the next state is not the same. so commit editing */ |
391 | if (Priv->BinaryState == StateEdit) { | 392 | if (Priv->BinaryState == StateEdit) { |
392 | /* Something has changed, we will have to reread fields! */ | 393 | /* Something has changed, we will have to reread fields! */ |
393 | Priv->CurrentFieldsItem = -1; | 394 | Priv->CurrentFieldsItem = -1; |
394 | switch (Priv->BinaryType) { | 395 | switch (Priv->BinaryType) { |
395 | case TypeCalendar: | 396 | case TypeCalendar: |
396 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 397 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
397 | break; | 398 | break; |
398 | case TypeContacts: | 399 | case TypeContacts: |
399 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 400 | commit_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
400 | break; | 401 | break; |
401 | case TypeToDo: | 402 | case TypeToDo: |
402 | commit_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 403 | commit_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
403 | break; | 404 | break; |
404 | } | 405 | } |
405 | dbgprintf ("Commiting edited record\n"); | 406 | dbgprintf ("Commiting edited record\n"); |
406 | error=GSM_WaitFor (s, commit_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelCommit); | 407 | error=GSM_WaitFor (s, commit_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelCommit); |
407 | if (error != ERR_NONE) return error; | 408 | if (error != ERR_NONE) return error; |
408 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelCommit2); | 409 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelCommit2); |
409 | if (error != ERR_NONE) return error; | 410 | if (error != ERR_NONE) return error; |
410 | Priv->BinaryState = StateSession; | 411 | Priv->BinaryState = StateSession; |
411 | Priv->BinaryItem = 0; | 412 | Priv->BinaryItem = 0; |
412 | } | 413 | } |
413 | 414 | ||
414 | /* Do we want to edit something of same type? */ | 415 | /* Do we want to edit something of same type? */ |
415 | if ((state == StateEdit) && (type == Priv->BinaryType)) { | 416 | if ((state == StateEdit) && (type == Priv->BinaryType)) { |
416 | /* Edit state doesn't need any switching, it is needed only for | 417 | /* Edit state doesn't need any switching, it is needed only for |
417 | * indication that e have to commit record before we switch to other | 418 | * indication that e have to commit record before we switch to other |
418 | * mode. | 419 | * mode. |
419 | */ | 420 | */ |
420 | Priv->BinaryState = StateEdit; | 421 | Priv->BinaryState = StateEdit; |
421 | Priv->BinaryItem = item; | 422 | Priv->BinaryItem = item; |
422 | return ERR_NONE; | 423 | return ERR_NONE; |
423 | } | 424 | } |
424 | 425 | ||
425 | /* Now we can be only in Attached or Session state, so if states and types matches, just keep them as they are */ | 426 | /* Now we can be only in Attached or Session state, so if states and types matches, just keep them as they are */ |
426 | if ((state == Priv->BinaryState) && (type == Priv->BinaryType)) { | 427 | if ((state == Priv->BinaryState) && (type == Priv->BinaryType)) { |
427 | return ERR_NONE; | 428 | return ERR_NONE; |
428 | } | 429 | } |
429 | 430 | ||
430 | /* Do we need to close session? */ | 431 | /* Do we need to close session? */ |
431 | if (Priv->BinaryState == StateSession) { | 432 | if (Priv->BinaryState == StateSession) { |
432 | dbgprintf ("Ending session\n"); | 433 | dbgprintf ("Ending session\n"); |
433 | switch (Priv->BinaryType) { | 434 | switch (Priv->BinaryType) { |
434 | case TypeCalendar: | 435 | case TypeCalendar: |
435 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; | 436 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; |
436 | break; | 437 | break; |
437 | case TypeContacts: | 438 | case TypeContacts: |
438 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; | 439 | end_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; |
439 | break; | 440 | break; |
440 | case TypeToDo: | 441 | case TypeToDo: |
441 | end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; | 442 | end_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; |
442 | break; | 443 | break; |
443 | } | 444 | } |
444 | error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd); | 445 | error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd); |
445 | if (error != ERR_NONE) return error; | 446 | if (error != ERR_NONE) return error; |
446 | 447 | ||
447 | switch (Priv->BinaryType) { | 448 | switch (Priv->BinaryType) { |
448 | case TypeCalendar: | 449 | case TypeCalendar: |
449 | close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 450 | close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
450 | break; | 451 | break; |
451 | case TypeContacts: | 452 | case TypeContacts: |
452 | close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 453 | close_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
453 | break; | 454 | break; |
454 | case TypeToDo: | 455 | case TypeToDo: |
455 | close_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 456 | close_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
456 | break; | 457 | break; |
457 | } | 458 | } |
458 | dbgprintf ("Closing session\n"); | 459 | dbgprintf ("Closing session\n"); |
459 | error=GSM_WaitFor (s, close_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelClose); | 460 | error=GSM_WaitFor (s, close_buffer, 5, 0x02, ALCATEL_TIMEOUT, ID_AlcatelClose); |
460 | if (error != ERR_NONE) return error; | 461 | if (error != ERR_NONE) return error; |
461 | 462 | ||
462 | dbgprintf ("Detaching binary mode\n"); | 463 | dbgprintf ("Detaching binary mode\n"); |
463 | GSM_WaitFor (s, detach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDetach); | 464 | GSM_WaitFor (s, detach_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDetach); |
464 | 465 | ||
465 | Priv->BinaryState = StateAttached; | 466 | Priv->BinaryState = StateAttached; |
466 | Priv->BinaryType = 0; | 467 | Priv->BinaryType = 0; |
467 | } | 468 | } |
468 | 469 | ||
469 | /* Do we need to open session? */ | 470 | /* Do we need to open session? */ |
470 | if (state == StateSession || state == StateEdit) { | 471 | if (state == StateSession || state == StateEdit) { |
471 | dbgprintf ("Starting session for %s\n", | 472 | dbgprintf ("Starting session for %s\n", |
472 | (type == TypeCalendar ? "Calendar" : | 473 | (type == TypeCalendar ? "Calendar" : |
473 | (type == TypeToDo ? "Todo" : | 474 | (type == TypeToDo ? "Todo" : |
474 | (type == TypeContacts ? "Contacts" : | 475 | (type == TypeContacts ? "Contacts" : |
475 | "Unknown!")))); | 476 | "Unknown!")))); |
476 | /* Fill up buffers */ | 477 | /* Fill up buffers */ |
477 | switch (type) { | 478 | switch (type) { |
478 | case TypeCalendar: | 479 | case TypeCalendar: |
479 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 480 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
480 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 481 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
481 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; | 482 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CALENDAR; |
482 | break; | 483 | break; |
483 | case TypeContacts: | 484 | case TypeContacts: |
484 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 485 | select1_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
485 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 486 | select2_buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
486 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; | 487 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_CONTACTS; |
487 | break; | 488 | break; |
488 | case TypeToDo: | 489 | case TypeToDo: |
489 | select1_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 490 | select1_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
490 | select2_buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 491 | select2_buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
491 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; | 492 | begin_buffer[4] = ALCATEL_BEGIN_SYNC_TODO; |
492 | break; | 493 | break; |
493 | } | 494 | } |
494 | dbgprintf ("Attaching in binary mode\n"); | 495 | dbgprintf ("Attaching in binary mode\n"); |
@@ -499,185 +500,187 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary | |||
499 | 500 | ||
500 | smprintf(s,"Start session\n"); | 501 | smprintf(s,"Start session\n"); |
501 | error=GSM_WaitFor (s, start_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelStart); | 502 | error=GSM_WaitFor (s, start_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelStart); |
502 | if (error != ERR_NONE) return error; | 503 | if (error != ERR_NONE) return error; |
503 | 504 | ||
504 | smprintf(s,"Select type\n"); | 505 | smprintf(s,"Select type\n"); |
505 | error=GSM_WaitFor (s, select1_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect1); | 506 | error=GSM_WaitFor (s, select1_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect1); |
506 | if (error != ERR_NONE) return error; | 507 | if (error != ERR_NONE) return error; |
507 | error=GSM_WaitFor (s, select2_buffer, 6, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect2); | 508 | error=GSM_WaitFor (s, select2_buffer, 6, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect2); |
508 | if (error != ERR_NONE) return error; | 509 | if (error != ERR_NONE) return error; |
509 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3); | 510 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3); |
510 | if (error != ERR_NONE) return error; | 511 | if (error != ERR_NONE) return error; |
511 | 512 | ||
512 | smprintf(s,"Begin transfer\n"); | 513 | smprintf(s,"Begin transfer\n"); |
513 | error=GSM_WaitFor (s, begin_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelBegin1); | 514 | error=GSM_WaitFor (s, begin_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelBegin1); |
514 | if (error != ERR_NONE) return error; | 515 | if (error != ERR_NONE) return error; |
515 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2); | 516 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2); |
516 | if (error != ERR_NONE) return error; | 517 | if (error != ERR_NONE) return error; |
517 | 518 | ||
518 | Priv->BinaryState = StateSession; | 519 | Priv->BinaryState = StateSession; |
519 | Priv->BinaryType = type; | 520 | Priv->BinaryType = type; |
520 | /* Do we want to edit something of same type? */ | 521 | /* Do we want to edit something of same type? */ |
521 | if ((state == StateEdit) && (type == Priv->BinaryType)) { | 522 | if ((state == StateEdit) && (type == Priv->BinaryType)) { |
522 | Priv->BinaryState = StateEdit; | 523 | Priv->BinaryState = StateEdit; |
523 | Priv->BinaryItem = item; | 524 | Priv->BinaryItem = item; |
524 | return ERR_NONE; | 525 | return ERR_NONE; |
525 | } | 526 | } |
526 | } | 527 | } |
527 | return ERR_NONE; | 528 | return ERR_NONE; |
528 | } | 529 | } |
529 | 530 | ||
530 | static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) | 531 | static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) |
531 | { | 532 | { |
532 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 533 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
533 | GSM_Error error; | 534 | GSM_Error error; |
534 | 535 | ||
535 | if (Priv->Mode == ModeAT) return ERR_NONE; | 536 | if (Priv->Mode == ModeAT) return ERR_NONE; |
536 | 537 | ||
537 | error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); | 538 | error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); |
538 | if (error != ERR_NONE) return error; | 539 | if (error != ERR_NONE) return error; |
539 | 540 | ||
540 | error = s->Protocol.Functions->Terminate(s); | 541 | error = s->Protocol.Functions->Terminate(s); |
541 | if (error != ERR_NONE) return error; | 542 | if (error != ERR_NONE) return error; |
542 | 543 | ||
543 | dbgprintf ("Changing protocol to AT\n"); | 544 | dbgprintf ("Changing protocol to AT\n"); |
544 | s->Protocol.Functions = &ATProtocol; | 545 | s->Protocol.Functions = &ATProtocol; |
545 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; | 546 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; |
546 | Priv->Mode = ModeAT; | 547 | Priv->Mode = ModeAT; |
548 | s->Phone.Data.Priv.ATGEN.PBKCharset= 0; | ||
549 | s->Phone.Data.Priv.ATGEN.PBKMemory= 0; | ||
547 | 550 | ||
548 | my_sleep(100); | 551 | my_sleep(100); |
549 | 552 | ||
550 | /* In case we don't send AT command short after closing binary mode, | 553 | /* In case we don't send AT command short after closing binary mode, |
551 | * phone takes VERY long to react next time. The error code in | 554 | * phone takes VERY long to react next time. The error code in |
552 | * intetionally ignored. | 555 | * intetionally ignored. |
553 | */ | 556 | */ |
554 | GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); | 557 | GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); |
555 | 558 | ||
556 | return ERR_NONE; | 559 | return ERR_NONE; |
557 | } | 560 | } |
558 | 561 | ||
559 | static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s) | 562 | static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s) |
560 | { | 563 | { |
561 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 564 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
562 | GSM_Error error; | 565 | GSM_Error error; |
563 | 566 | ||
564 | Priv->Mode = ModeAT; | 567 | Priv->Mode = ModeAT; |
565 | 568 | ||
566 | Priv->CalendarItems = NULL; | 569 | Priv->CalendarItems = NULL; |
567 | Priv->ContactsItems = NULL; | 570 | Priv->ContactsItems = NULL; |
568 | Priv->ToDoItems = NULL; | 571 | Priv->ToDoItems = NULL; |
569 | Priv->CalendarItemsCount = 0; | 572 | Priv->CalendarItemsCount = 0; |
570 | Priv->ToDoItemsCount = 0; | 573 | Priv->ToDoItemsCount = 0; |
571 | Priv->ContactsItemsCount = 0; | 574 | Priv->ContactsItemsCount = 0; |
572 | Priv->CurrentFields[0] = 0; | 575 | Priv->CurrentFields[0] = 0; |
573 | Priv->CurrentFieldsCount = 0; | 576 | Priv->CurrentFieldsCount = 0; |
574 | Priv->CurrentFieldsItem = 0; | 577 | Priv->CurrentFieldsItem = 0; |
575 | Priv->CurrentFieldsType = 0; | 578 | Priv->CurrentFieldsType = 0; |
576 | Priv->ProtocolVersion = V_1_0; | 579 | Priv->ProtocolVersion = V_1_0; |
577 | Priv->CurrentFieldsItem = -1; | 580 | Priv->CurrentFieldsItem = -1; |
578 | 581 | ||
579 | Priv->CurrentCategoriesCount = 0; | 582 | Priv->CurrentCategoriesCount = 0; |
580 | Priv->CurrentCategoriesType = 0; | 583 | Priv->CurrentCategoriesType = 0; |
581 | 584 | ||
582 | s->Protocol.Functions = &ATProtocol; | 585 | s->Protocol.Functions = &ATProtocol; |
583 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; | 586 | s->Phone.Functions->ReplyFunctions= ATGENReplyFunctions; |
584 | 587 | ||
585 | if (ATGEN_Initialise(s) != ERR_NONE || GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame) != ERR_NONE) { | 588 | if (ATGEN_Initialise(s) != ERR_NONE || GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame) != ERR_NONE) { |
586 | smprintf(s,"AT initialisation failed, trying to stop binary mode...\n"); | 589 | smprintf(s,"AT initialisation failed, trying to stop binary mode...\n"); |
587 | s->Protocol.Functions = &ALCABUSProtocol; | 590 | s->Protocol.Functions = &ALCABUSProtocol; |
588 | error = s->Protocol.Functions->Terminate(s); | 591 | error = s->Protocol.Functions->Terminate(s); |
589 | s->Protocol.Functions = &ATProtocol; | 592 | s->Protocol.Functions = &ATProtocol; |
590 | 593 | ||
591 | error = ATGEN_Initialise(s); | 594 | error = ATGEN_Initialise(s); |
592 | if (error != ERR_NONE) return error; | 595 | if (error != ERR_NONE) return error; |
593 | } | 596 | } |
594 | 597 | ||
595 | return ERR_NONE; | 598 | return ERR_NONE; |
596 | } | 599 | } |
597 | 600 | ||
598 | static GSM_Error ALCATEL_Terminate(GSM_StateMachine *s) | 601 | static GSM_Error ALCATEL_Terminate(GSM_StateMachine *s) |
599 | { | 602 | { |
600 | GSM_Error error; | 603 | GSM_Error error; |
601 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 604 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
602 | 605 | ||
603 | free(Priv->CalendarItems); | 606 | free(Priv->CalendarItems); |
604 | free(Priv->ContactsItems); | 607 | free(Priv->ContactsItems); |
605 | free(Priv->ToDoItems); | 608 | free(Priv->ToDoItems); |
606 | error = ALCATEL_SetATMode(s); | 609 | error = ALCATEL_SetATMode(s); |
607 | return ATGEN_Terminate(s); | 610 | return ATGEN_Terminate(s); |
608 | } | 611 | } |
609 | 612 | ||
610 | /* finds whether id is set in the phone */ | 613 | /* finds whether id is set in the phone */ |
611 | static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) { | 614 | static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) { |
612 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 615 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
613 | int i; | 616 | int i; |
614 | 617 | ||
615 | if (id > ALCATEL_MAX_LOCATION) return ERR_INVALIDLOCATION; | 618 | if (id > ALCATEL_MAX_LOCATION) return ERR_INVALIDLOCATION; |
616 | 619 | ||
617 | switch (Priv->BinaryType) { | 620 | switch (Priv->BinaryType) { |
618 | case TypeCalendar: | 621 | case TypeCalendar: |
619 | Priv->CurrentList = &(Priv->CalendarItems); | 622 | Priv->CurrentList = &(Priv->CalendarItems); |
620 | Priv->CurrentCount = &(Priv->CalendarItemsCount); | 623 | Priv->CurrentCount = &(Priv->CalendarItemsCount); |
621 | break; | 624 | break; |
622 | case TypeContacts: | 625 | case TypeContacts: |
623 | Priv->CurrentList = &(Priv->ContactsItems); | 626 | Priv->CurrentList = &(Priv->ContactsItems); |
624 | Priv->CurrentCount = &(Priv->ContactsItemsCount); | 627 | Priv->CurrentCount = &(Priv->ContactsItemsCount); |
625 | break; | 628 | break; |
626 | case TypeToDo: | 629 | case TypeToDo: |
627 | Priv->CurrentList = &(Priv->ToDoItems); | 630 | Priv->CurrentList = &(Priv->ToDoItems); |
628 | Priv->CurrentCount = &(Priv->ToDoItemsCount); | 631 | Priv->CurrentCount = &(Priv->ToDoItemsCount); |
629 | break; | 632 | break; |
630 | } | 633 | } |
631 | 634 | ||
632 | for (i=0; i<*Priv->CurrentCount; i++) { | 635 | for (i=0; i<*Priv->CurrentCount; i++) { |
633 | if ((*Priv->CurrentList)[i] == id) return ERR_NONE; | 636 | if ((*Priv->CurrentList)[i] == id) return ERR_NONE; |
634 | } | 637 | } |
635 | 638 | ||
636 | return ERR_EMPTY; | 639 | return ERR_EMPTY; |
637 | } | 640 | } |
638 | 641 | ||
639 | /* finds next id that is available in the phone */ | 642 | /* finds next id that is available in the phone */ |
640 | static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) { | 643 | static GSM_Error ALCATEL_GetNextId(GSM_StateMachine *s, int *id) { |
641 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 644 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
642 | int i = 0; | 645 | int i = 0; |
643 | int next = ALCATEL_MAX_LOCATION; | 646 | int next = ALCATEL_MAX_LOCATION; |
644 | 647 | ||
645 | switch (Priv->BinaryType) { | 648 | switch (Priv->BinaryType) { |
646 | case TypeCalendar: | 649 | case TypeCalendar: |
647 | Priv->CurrentList = &(Priv->CalendarItems); | 650 | Priv->CurrentList = &(Priv->CalendarItems); |
648 | Priv->CurrentCount = &(Priv->CalendarItemsCount); | 651 | Priv->CurrentCount = &(Priv->CalendarItemsCount); |
649 | break; | 652 | break; |
650 | case TypeContacts: | 653 | case TypeContacts: |
651 | Priv->CurrentList = &(Priv->ContactsItems); | 654 | Priv->CurrentList = &(Priv->ContactsItems); |
652 | Priv->CurrentCount = &(Priv->ContactsItemsCount); | 655 | Priv->CurrentCount = &(Priv->ContactsItemsCount); |
653 | break; | 656 | break; |
654 | case TypeToDo: | 657 | case TypeToDo: |
655 | Priv->CurrentList = &(Priv->ToDoItems); | 658 | Priv->CurrentList = &(Priv->ToDoItems); |
656 | Priv->CurrentCount = &(Priv->ToDoItemsCount); | 659 | Priv->CurrentCount = &(Priv->ToDoItemsCount); |
657 | break; | 660 | break; |
658 | } | 661 | } |
659 | 662 | ||
660 | for (i=0; i<*Priv->CurrentCount; i++) { | 663 | for (i=0; i<*Priv->CurrentCount; i++) { |
661 | if (((*Priv->CurrentList)[i] > *id) && ((*Priv->CurrentList)[i] < next )) { | 664 | if (((*Priv->CurrentList)[i] > *id) && ((*Priv->CurrentList)[i] < next )) { |
662 | next = (*Priv->CurrentList)[i]; | 665 | next = (*Priv->CurrentList)[i]; |
663 | } | 666 | } |
664 | } | 667 | } |
665 | if (next == ALCATEL_MAX_LOCATION) { | 668 | if (next == ALCATEL_MAX_LOCATION) { |
666 | return ERR_EMPTY; | 669 | return ERR_EMPTY; |
667 | } else { | 670 | } else { |
668 | *id = next; | 671 | *id = next; |
669 | return ERR_NONE; | 672 | return ERR_NONE; |
670 | } | 673 | } |
671 | } | 674 | } |
672 | 675 | ||
673 | static GSM_Error ALCATEL_ReplyGetIds(GSM_Protocol_Message msg, GSM_StateMachine *s) | 676 | static GSM_Error ALCATEL_ReplyGetIds(GSM_Protocol_Message msg, GSM_StateMachine *s) |
674 | { | 677 | { |
675 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 678 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
676 | int count,i,pos; | 679 | int count,i,pos; |
677 | 680 | ||
678 | count = msg.Buffer[10]; | 681 | count = msg.Buffer[10]; |
679 | *Priv->CurrentCount += count; | 682 | *Priv->CurrentCount += count; |
680 | 683 | ||
681 | *Priv->CurrentList = (int *)realloc(*Priv->CurrentList, (*Priv->CurrentCount + 1)* sizeof(int)); | 684 | *Priv->CurrentList = (int *)realloc(*Priv->CurrentList, (*Priv->CurrentCount + 1)* sizeof(int)); |
682 | if (*Priv->CurrentList == NULL) return ERR_MOREMEMORY; | 685 | if (*Priv->CurrentList == NULL) return ERR_MOREMEMORY; |
683 | 686 | ||
@@ -801,97 +804,97 @@ static GSM_Error ALCATEL_GetFields(GSM_StateMachine *s, int id) { | |||
801 | case TypeContacts: | 804 | case TypeContacts: |
802 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 805 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
803 | break; | 806 | break; |
804 | case TypeToDo: | 807 | case TypeToDo: |
805 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 808 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
806 | break; | 809 | break; |
807 | } | 810 | } |
808 | 811 | ||
809 | Priv->CurrentFieldsItem = id; | 812 | Priv->CurrentFieldsItem = id; |
810 | Priv->CurrentFieldsType = Priv->BinaryType; | 813 | Priv->CurrentFieldsType = Priv->BinaryType; |
811 | 814 | ||
812 | error=GSM_WaitFor (s, buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFields1); | 815 | error=GSM_WaitFor (s, buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetFields1); |
813 | if (error != ERR_NONE) return error; | 816 | if (error != ERR_NONE) return error; |
814 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFields2); | 817 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetFields2); |
815 | if (error != ERR_NONE) return error; | 818 | if (error != ERR_NONE) return error; |
816 | 819 | ||
817 | i = 0; | 820 | i = 0; |
818 | smprintf(s,"Received %d fields: ", Priv->CurrentFieldsCount); | 821 | smprintf(s,"Received %d fields: ", Priv->CurrentFieldsCount); |
819 | for (i=0; i < Priv->CurrentFieldsCount; i++) { | 822 | for (i=0; i < Priv->CurrentFieldsCount; i++) { |
820 | smprintf(s,"%x ", Priv->CurrentFields[i]); | 823 | smprintf(s,"%x ", Priv->CurrentFields[i]); |
821 | } | 824 | } |
822 | smprintf(s,"\n"); | 825 | smprintf(s,"\n"); |
823 | 826 | ||
824 | return ERR_NONE; | 827 | return ERR_NONE; |
825 | } | 828 | } |
826 | 829 | ||
827 | static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateMachine *s) | 830 | static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateMachine *s) |
828 | { | 831 | { |
829 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 832 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
830 | unsigned char *buffer = &(msg.Buffer[16]); | 833 | unsigned char *buffer = &(msg.Buffer[16]); |
831 | 834 | ||
832 | if (buffer[1] == 0x05 && buffer[2] == 0x67) { | 835 | if (buffer[1] == 0x05 && buffer[2] == 0x67) { |
833 | /* date */ | 836 | /* date */ |
834 | Priv->ReturnType = Alcatel_date; | 837 | Priv->ReturnType = Alcatel_date; |
835 | Priv->ReturnDateTime.Day= buffer[4]; | 838 | Priv->ReturnDateTime.Day= buffer[4]; |
836 | Priv->ReturnDateTime.Month= buffer[5]; | 839 | Priv->ReturnDateTime.Month= buffer[5]; |
837 | Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8); | 840 | Priv->ReturnDateTime.Year= buffer[7] + (buffer[6] << 8); |
838 | Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */ | 841 | Priv->ReturnDateTime.Timezone= 0; /* FIXME: how to acquire this? */ |
839 | 842 | ||
840 | Priv->ReturnDateTime.Hour= 0; | 843 | Priv->ReturnDateTime.Hour= 0; |
841 | Priv->ReturnDateTime.Minute= 0; | 844 | Priv->ReturnDateTime.Minute= 0; |
842 | Priv->ReturnDateTime.Second= 0; | 845 | Priv->ReturnDateTime.Second= 0; |
843 | } else if (buffer[1] == 0x06 && buffer[2] == 0x68) { | 846 | } else if (buffer[1] == 0x06 && buffer[2] == 0x68) { |
844 | /* time */ | 847 | /* time */ |
845 | Priv->ReturnType = Alcatel_time; | 848 | Priv->ReturnType = Alcatel_time; |
846 | Priv->ReturnDateTime.Hour= buffer[4]; | 849 | Priv->ReturnDateTime.Hour= buffer[4]; |
847 | Priv->ReturnDateTime.Minute= buffer[5]; | 850 | Priv->ReturnDateTime.Minute= buffer[5]; |
848 | Priv->ReturnDateTime.Second= buffer[6]; | 851 | Priv->ReturnDateTime.Second= buffer[6]; |
849 | 852 | ||
850 | Priv->ReturnDateTime.Day= 0; | 853 | Priv->ReturnDateTime.Day= 0; |
851 | Priv->ReturnDateTime.Month= 0; | 854 | Priv->ReturnDateTime.Month= 0; |
852 | Priv->ReturnDateTime.Year= 0; | 855 | Priv->ReturnDateTime.Year= 0; |
853 | Priv->ReturnDateTime.Timezone= 0; | 856 | Priv->ReturnDateTime.Timezone= 0; |
854 | } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) { | 857 | } else if (buffer[1] == 0x08 && buffer[2] == 0x3C) { |
855 | /* string */ | 858 | /* string */ |
856 | Priv->ReturnType = Alcatel_string; | 859 | Priv->ReturnType = Alcatel_string; |
857 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) | 860 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) |
858 | smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); | 861 | smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); |
859 | if (Priv->ProtocolVersion == V_1_0) { | 862 | if (Priv->ProtocolVersion == V_1_0) { |
860 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); | 863 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); |
861 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { | 864 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { |
862 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); | 865 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); |
863 | Priv->ReturnString[buffer[3] + 1] = 0; | 866 | Priv->ReturnString[buffer[3] + 1] = 0; |
864 | Priv->ReturnString[buffer[3] + 2] = 0; | 867 | Priv->ReturnString[buffer[3] + 2] = 0; |
865 | ReverseUnicodeString(Priv->ReturnString); | 868 | ReverseUnicodeString(Priv->ReturnString); |
866 | } else { | 869 | } else { |
867 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); | 870 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); |
868 | } | 871 | } |
869 | } else if (buffer[1] == 0x07 && buffer[2] == 0x3C) { | 872 | } else if (buffer[1] == 0x07 && buffer[2] == 0x3C) { |
870 | /* phone */ | 873 | /* phone */ |
871 | Priv->ReturnType = Alcatel_phone; | 874 | Priv->ReturnType = Alcatel_phone; |
872 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) | 875 | if (GSM_PHONEBOOK_TEXT_LENGTH < buffer[3]) |
873 | smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); | 876 | smprintf(s, "WARNING: Text truncated, you should increase GSM_PHONEBOOK_TEXT_LENGTH to at least %d\n", buffer[3] + 1); |
874 | if (Priv->ProtocolVersion == V_1_0) { | 877 | if (Priv->ProtocolVersion == V_1_0) { |
875 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); | 878 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); |
876 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { | 879 | } else if(Priv->ProtocolVersion == V_1_1 && (buffer[4] & 0x80)) { |
877 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); | 880 | memcpy(Priv->ReturnString, buffer + 5, buffer[3]); |
878 | Priv->ReturnString[buffer[3] + 1] = 0; | 881 | Priv->ReturnString[buffer[3] + 1] = 0; |
879 | Priv->ReturnString[buffer[3] + 2] = 0; | 882 | Priv->ReturnString[buffer[3] + 2] = 0; |
880 | ReverseUnicodeString(Priv->ReturnString); | 883 | ReverseUnicodeString(Priv->ReturnString); |
881 | } else { | 884 | } else { |
882 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); | 885 | DecodeDefault( Priv->ReturnString, buffer + 4, MIN(GSM_PHONEBOOK_TEXT_LENGTH, buffer[3]), false, GSM_AlcatelAlphabet); |
883 | } | 886 | } |
884 | } else if (buffer[1] == 0x03 && buffer[2] == 0x3B) { | 887 | } else if (buffer[1] == 0x03 && buffer[2] == 0x3B) { |
885 | /* boolean */ | 888 | /* boolean */ |
886 | Priv->ReturnType = Alcatel_bool; | 889 | Priv->ReturnType = Alcatel_bool; |
887 | Priv->ReturnInt = buffer[3]; | 890 | Priv->ReturnInt = buffer[3]; |
888 | } else if (buffer[1] == 0x02 && buffer[2] == 0x3A) { | 891 | } else if (buffer[1] == 0x02 && buffer[2] == 0x3A) { |
889 | /* integer */ | 892 | /* integer */ |
890 | Priv->ReturnType = Alcatel_int; | 893 | Priv->ReturnType = Alcatel_int; |
891 | Priv->ReturnInt = buffer[6] + (buffer[5] << 8) + (buffer[4] << 16) + (buffer[3] << 24); | 894 | Priv->ReturnInt = buffer[6] + (buffer[5] << 8) + (buffer[4] << 16) + (buffer[3] << 24); |
892 | } else if (buffer[1] == 0x04 && buffer[2] == 0x38) { | 895 | } else if (buffer[1] == 0x04 && buffer[2] == 0x38) { |
893 | /* enumeration */ | 896 | /* enumeration */ |
894 | Priv->ReturnType = Alcatel_enum; | 897 | Priv->ReturnType = Alcatel_enum; |
895 | Priv->ReturnInt = buffer[3]; | 898 | Priv->ReturnInt = buffer[3]; |
896 | } else if (buffer[1] == 0x00 && buffer[2] == 0x38) { | 899 | } else if (buffer[1] == 0x00 && buffer[2] == 0x38) { |
897 | /* byte */ | 900 | /* byte */ |
@@ -1051,216 +1054,216 @@ static GSM_Error ALCATEL_AddCategoryText(GSM_StateMachine *s, const unsigned cha | |||
1051 | case TypeContacts: | 1054 | case TypeContacts: |
1052 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1055 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1053 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; | 1056 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; |
1054 | break; | 1057 | break; |
1055 | case TypeToDo: | 1058 | case TypeToDo: |
1056 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1059 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1057 | buffer[4] = ALCATEL_LIST_TODO_CAT; | 1060 | buffer[4] = ALCATEL_LIST_TODO_CAT; |
1058 | break; | 1061 | break; |
1059 | default: | 1062 | default: |
1060 | return ERR_NOTSUPPORTED; | 1063 | return ERR_NOTSUPPORTED; |
1061 | } | 1064 | } |
1062 | 1065 | ||
1063 | error=GSM_WaitFor (s, buffer, 8 + len, 0x02, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText1); | 1066 | error=GSM_WaitFor (s, buffer, 8 + len, 0x02, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText1); |
1064 | if (error != ERR_NONE) return error; | 1067 | if (error != ERR_NONE) return error; |
1065 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText2); | 1068 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelAddCategoryText2); |
1066 | if (error != ERR_NONE) return error; | 1069 | if (error != ERR_NONE) return error; |
1067 | 1070 | ||
1068 | /* Refresh list */ | 1071 | /* Refresh list */ |
1069 | Priv->CurrentCategoriesType = 0; | 1072 | Priv->CurrentCategoriesType = 0; |
1070 | return ALCATEL_GetAvailableCategoryIds(s); | 1073 | return ALCATEL_GetAvailableCategoryIds(s); |
1071 | } | 1074 | } |
1072 | 1075 | ||
1073 | static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1076 | static GSM_Error ALCATEL_ReplyGetCategoryText(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1074 | { | 1077 | { |
1075 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 1078 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
1076 | int len; | 1079 | int len; |
1077 | 1080 | ||
1078 | len = msg.Buffer[14]; | 1081 | len = msg.Buffer[14]; |
1079 | if (len > GSM_MAX_CATEGORY_NAME_LENGTH) { | 1082 | if (len > GSM_MAX_CATEGORY_NAME_LENGTH) { |
1080 | smprintf(s, "WARNING: Category name truncated, you should increase GSM_MAX_CATEGORY_NAME_LENGTH to at least %d\n", len); | 1083 | smprintf(s, "WARNING: Category name truncated, you should increase GSM_MAX_CATEGORY_NAME_LENGTH to at least %d\n", len); |
1081 | } | 1084 | } |
1082 | if (Priv->ProtocolVersion == V_1_0) { | 1085 | if (Priv->ProtocolVersion == V_1_0) { |
1083 | DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); | 1086 | DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); |
1084 | } else if(Priv->ProtocolVersion == V_1_1 && (msg.Buffer[15] & 0x80)) { | 1087 | } else if(Priv->ProtocolVersion == V_1_1 && (msg.Buffer[15] & 0x80)) { |
1085 | memcpy(Priv->ReturnString, msg.Buffer + 16, len); | 1088 | memcpy(Priv->ReturnString, msg.Buffer + 16, len); |
1086 | Priv->ReturnString[len + 1] = 0; | 1089 | Priv->ReturnString[len + 1] = 0; |
1087 | Priv->ReturnString[len + 2] = 0; | 1090 | Priv->ReturnString[len + 2] = 0; |
1088 | ReverseUnicodeString(Priv->ReturnString); | 1091 | ReverseUnicodeString(Priv->ReturnString); |
1089 | } else { | 1092 | } else { |
1090 | DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); | 1093 | DecodeDefault( Priv->ReturnString, msg.Buffer + 15, MIN(GSM_MAX_CATEGORY_NAME_LENGTH, len), false, GSM_AlcatelAlphabet); |
1091 | } | 1094 | } |
1092 | return ERR_NONE; | 1095 | return ERR_NONE; |
1093 | } | 1096 | } |
1094 | 1097 | ||
1095 | static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { | 1098 | static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { |
1096 | unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ }; | 1099 | unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ }; |
1097 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1100 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1098 | GSM_Error error; | 1101 | GSM_Error error; |
1099 | 1102 | ||
1100 | if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { | 1103 | if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { |
1101 | CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); | 1104 | CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); |
1102 | return ERR_NONE; | 1105 | return ERR_NONE; |
1103 | } | 1106 | } |
1104 | 1107 | ||
1105 | smprintf(s,"Reading category %d\n", id); | 1108 | smprintf(s,"Reading category %d\n", id); |
1106 | 1109 | ||
1107 | switch (Priv->BinaryType) { | 1110 | switch (Priv->BinaryType) { |
1108 | case TypeContacts: | 1111 | case TypeContacts: |
1109 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1112 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1110 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; | 1113 | buffer[4] = ALCATEL_LIST_CONTACTS_CAT; |
1111 | break; | 1114 | break; |
1112 | case TypeToDo: | 1115 | case TypeToDo: |
1113 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1116 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1114 | buffer[4] = ALCATEL_LIST_TODO_CAT; | 1117 | buffer[4] = ALCATEL_LIST_TODO_CAT; |
1115 | break; | 1118 | break; |
1116 | default: | 1119 | default: |
1117 | return ERR_NOTSUPPORTED; | 1120 | return ERR_NOTSUPPORTED; |
1118 | } | 1121 | } |
1119 | 1122 | ||
1120 | buffer[7] = (id & 0xff); | 1123 | buffer[7] = (id & 0xff); |
1121 | 1124 | ||
1122 | error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1); | 1125 | error=GSM_WaitFor (s, buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText1); |
1123 | if (error != ERR_NONE) return error; | 1126 | if (error != ERR_NONE) return error; |
1124 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); | 1127 | error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); |
1125 | if (error != ERR_NONE) return error; | 1128 | if (error != ERR_NONE) return error; |
1126 | 1129 | ||
1127 | CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); | 1130 | CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); |
1128 | 1131 | ||
1129 | return ERR_NONE; | 1132 | return ERR_NONE; |
1130 | } | 1133 | } |
1131 | 1134 | ||
1132 | static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) { | 1135 | static GSM_Error ALCATEL_DeleteField(GSM_StateMachine *s, int id, int field) { |
1133 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1136 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1134 | GSM_Error error; | 1137 | GSM_Error error; |
1135 | unsigned char buffer[] = | 1138 | unsigned char buffer[] = |
1136 | {0x00, 0x04, | 1139 | {0x00, 0x04, |
1137 | 0x00, /* type */ | 1140 | 0x00, /* type */ |
1138 | 0x26, 0x01, | 1141 | 0x26, 0x01, |
1139 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ | 1142 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ |
1140 | 0x65, 0x01, | 1143 | 0x65, 0x01, |
1141 | 0x00, /* field */ | 1144 | 0x00, /* field */ |
1142 | 0x01}; | 1145 | 0x01}; |
1143 | 1146 | ||
1144 | smprintf(s,"Deleting field (%08x.%02x)\n", id, field); | 1147 | smprintf(s,"Deleting field (%08x.%02x)\n", id, field); |
1145 | 1148 | ||
1146 | switch (Priv->BinaryType) { | 1149 | switch (Priv->BinaryType) { |
1147 | case TypeCalendar: | 1150 | case TypeCalendar: |
1148 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1151 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1149 | break; | 1152 | break; |
1150 | case TypeContacts: | 1153 | case TypeContacts: |
1151 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1154 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1152 | break; | 1155 | break; |
1153 | case TypeToDo: | 1156 | case TypeToDo: |
1154 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1157 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1155 | break; | 1158 | break; |
1156 | } | 1159 | } |
1157 | 1160 | ||
1158 | buffer[5] = (id >> 24); | 1161 | buffer[5] = (id >> 24); |
1159 | buffer[6] = ((id >> 16) & 0xff); | 1162 | buffer[6] = ((id >> 16) & 0xff); |
1160 | buffer[7] = ((id >> 8) & 0xff); | 1163 | buffer[7] = ((id >> 8) & 0xff); |
1161 | buffer[8] = (id & 0xff); | 1164 | buffer[8] = (id & 0xff); |
1162 | buffer[11] = (field & 0xff); | 1165 | buffer[11] = (field & 0xff); |
1163 | 1166 | ||
1164 | error=GSM_WaitFor (s, buffer, 13, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteField); | 1167 | error=GSM_WaitFor (s, buffer, 13, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteField); |
1165 | if (error != ERR_NONE) return error; | 1168 | if (error != ERR_NONE) return error; |
1166 | 1169 | ||
1167 | return ERR_NONE; | 1170 | return ERR_NONE; |
1168 | } | 1171 | } |
1169 | 1172 | ||
1170 | static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) { | 1173 | static GSM_Error ALCATEL_DeleteItem(GSM_StateMachine *s, int id) { |
1171 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1174 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1172 | GSM_Error error; | 1175 | GSM_Error error; |
1173 | unsigned char buffer[] = | 1176 | unsigned char buffer[] = |
1174 | {0x00, 0x04, | 1177 | {0x00, 0x04, |
1175 | 0x00, /* type */ | 1178 | 0x00, /* type */ |
1176 | 0x27, 0x01, | 1179 | 0x27, 0x01, |
1177 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ | 1180 | 0x00, 0x00, 0x00, 0x00,/* here follows 4byte id */ |
1178 | 0x42}; | 1181 | 0x42}; |
1179 | 1182 | ||
1180 | smprintf(s,"Deleting item (%08x)\n", id); | 1183 | smprintf(s,"Deleting item (%08x)\n", id); |
1181 | 1184 | ||
1182 | switch (Priv->BinaryType) { | 1185 | switch (Priv->BinaryType) { |
1183 | case TypeCalendar: | 1186 | case TypeCalendar: |
1184 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1187 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1185 | break; | 1188 | break; |
1186 | case TypeContacts: | 1189 | case TypeContacts: |
1187 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1190 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1188 | break; | 1191 | break; |
1189 | case TypeToDo: | 1192 | case TypeToDo: |
1190 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1193 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1191 | break; | 1194 | break; |
1192 | } | 1195 | } |
1193 | 1196 | ||
1194 | buffer[5] = (id >> 24); | 1197 | buffer[5] = (id >> 24); |
1195 | buffer[6] = ((id >> 16) & 0xff); | 1198 | buffer[6] = ((id >> 16) & 0xff); |
1196 | buffer[7] = ((id >> 8) & 0xff); | 1199 | buffer[7] = ((id >> 8) & 0xff); |
1197 | buffer[8] = (id & 0xff); | 1200 | buffer[8] = (id & 0xff); |
1198 | 1201 | ||
1199 | error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem1); | 1202 | error=GSM_WaitFor (s, buffer, 10, 0x02, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem1); |
1200 | if (error != ERR_NONE) return error; | 1203 | if (error != ERR_NONE) return error; |
1201 | 1204 | ||
1202 | error=GSM_WaitFor (s, 0, 0, 0x0, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem2); | 1205 | error=GSM_WaitFor (s, 0, 0, 0x0, ALCATEL_TIMEOUT, ID_AlcatelDeleteItem2); |
1203 | if (error != ERR_NONE) return error; | 1206 | if (error != ERR_NONE) return error; |
1204 | 1207 | ||
1205 | return ERR_NONE; | 1208 | return ERR_NONE; |
1206 | } | 1209 | } |
1207 | 1210 | ||
1208 | static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1211 | static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1209 | { | 1212 | { |
1210 | if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE; | 1213 | if (msg.Buffer[8] != 0x25) return ERR_UNKNOWNRESPONSE; |
1211 | return ERR_NONE; | 1214 | return ERR_NONE; |
1212 | } | 1215 | } |
1213 | 1216 | ||
1214 | static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { | 1217 | static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { |
1215 | int len; | 1218 | int len; |
1216 | 1219 | ||
1217 | buffer[1] = field & 0xff; | 1220 | buffer[1] = field & 0xff; |
1218 | 1221 | ||
1219 | switch(type) { | 1222 | switch(type) { |
1220 | case Alcatel_date: | 1223 | case Alcatel_date: |
1221 | if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; | 1224 | if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; |
1222 | 1225 | ||
1223 | buffer[3] = 0x05; | 1226 | buffer[3] = 0x05; |
1224 | buffer[4] = 0x67; | 1227 | buffer[4] = 0x67; |
1225 | 1228 | ||
1226 | buffer[0] = 0x09; | 1229 | buffer[0] = 0x09; |
1227 | buffer[5] = 0x04; | 1230 | buffer[5] = 0x04; |
1228 | buffer[6] = ((GSM_DateTime *)data)->Day & 0xff; | 1231 | buffer[6] = ((GSM_DateTime *)data)->Day & 0xff; |
1229 | buffer[7] = ((GSM_DateTime *)data)->Month & 0xff; | 1232 | buffer[7] = ((GSM_DateTime *)data)->Month & 0xff; |
1230 | buffer[8] = ((GSM_DateTime *)data)->Year >> 8; | 1233 | buffer[8] = ((GSM_DateTime *)data)->Year >> 8; |
1231 | buffer[9] = ((GSM_DateTime *)data)->Year & 0xff; | 1234 | buffer[9] = ((GSM_DateTime *)data)->Year & 0xff; |
1232 | buffer[10] = 0x00; | 1235 | buffer[10] = 0x00; |
1233 | break; | 1236 | break; |
1234 | case Alcatel_time: | 1237 | case Alcatel_time: |
1235 | if (!CheckTime((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; | 1238 | if (!CheckTime((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; |
1236 | 1239 | ||
1237 | buffer[3] = 0x06; | 1240 | buffer[3] = 0x06; |
1238 | buffer[4] = 0x68; | 1241 | buffer[4] = 0x68; |
1239 | 1242 | ||
1240 | buffer[0] = 0x08; | 1243 | buffer[0] = 0x08; |
1241 | buffer[5] = 0x03; | 1244 | buffer[5] = 0x03; |
1242 | buffer[6] = ((GSM_DateTime *)data)->Hour & 0xff; | 1245 | buffer[6] = ((GSM_DateTime *)data)->Hour & 0xff; |
1243 | buffer[7] = ((GSM_DateTime *)data)->Minute & 0xff; | 1246 | buffer[7] = ((GSM_DateTime *)data)->Minute & 0xff; |
1244 | buffer[8] = ((GSM_DateTime *)data)->Second & 0xff; | 1247 | buffer[8] = ((GSM_DateTime *)data)->Second & 0xff; |
1245 | buffer[9] = 0x00; | 1248 | buffer[9] = 0x00; |
1246 | break; | 1249 | break; |
1247 | case Alcatel_string: | 1250 | case Alcatel_string: |
1248 | buffer[3] = 0x08; | 1251 | buffer[3] = 0x08; |
1249 | buffer[4] = 0x3c; | 1252 | buffer[4] = 0x3c; |
1250 | 1253 | ||
1251 | len = MIN(UnicodeLength((char *)data),62); | 1254 | len = MIN(UnicodeLength((char *)data),62); |
1252 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); | 1255 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); |
1253 | buffer[5] = len; | 1256 | buffer[5] = len; |
1254 | buffer[0] = 5 + len; | 1257 | buffer[0] = 5 + len; |
1255 | buffer[6 + len] = 0x00; | 1258 | buffer[6 + len] = 0x00; |
1256 | break; | 1259 | break; |
1257 | case Alcatel_phone: | 1260 | case Alcatel_phone: |
1258 | buffer[3] = 0x07; | 1261 | buffer[3] = 0x07; |
1259 | buffer[4] = 0x3c; | 1262 | buffer[4] = 0x3c; |
1260 | 1263 | ||
1261 | len = MIN(UnicodeLength((char *)data),50); | 1264 | len = MIN(UnicodeLength((char *)data),50); |
1262 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); | 1265 | EncodeDefault(buffer + 6, (char *)data, &len, true, GSM_AlcatelAlphabet); |
1263 | buffer[5] = len; | 1266 | buffer[5] = len; |
1264 | buffer[0] = 5 + len; | 1267 | buffer[0] = 5 + len; |
1265 | buffer[6 + len] = 0x00; | 1268 | buffer[6 + len] = 0x00; |
1266 | break; | 1269 | break; |
@@ -1284,140 +1287,140 @@ static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_Fi | |||
1284 | buffer[3] = 0x02; | 1287 | buffer[3] = 0x02; |
1285 | buffer[4] = 0x3a; | 1288 | buffer[4] = 0x3a; |
1286 | 1289 | ||
1287 | buffer[0] = 0x08; | 1290 | buffer[0] = 0x08; |
1288 | buffer[5] = *(unsigned int *)data >> 24; | 1291 | buffer[5] = *(unsigned int *)data >> 24; |
1289 | buffer[6] = (*(unsigned int *)data >> 16) & 0xff; | 1292 | buffer[6] = (*(unsigned int *)data >> 16) & 0xff; |
1290 | buffer[7] = (*(unsigned int *)data >> 8) & 0xff; | 1293 | buffer[7] = (*(unsigned int *)data >> 8) & 0xff; |
1291 | buffer[8] = *(unsigned int *)data & 0xff; | 1294 | buffer[8] = *(unsigned int *)data & 0xff; |
1292 | buffer[9] = 0x00; | 1295 | buffer[9] = 0x00; |
1293 | break; | 1296 | break; |
1294 | case Alcatel_byte: | 1297 | case Alcatel_byte: |
1295 | buffer[3] = 0x00; | 1298 | buffer[3] = 0x00; |
1296 | buffer[4] = 0x38; | 1299 | buffer[4] = 0x38; |
1297 | 1300 | ||
1298 | buffer[0] = 0x05; | 1301 | buffer[0] = 0x05; |
1299 | buffer[5] = *(int *)data & 0xff; | 1302 | buffer[5] = *(int *)data & 0xff; |
1300 | buffer[6] = 0x00; | 1303 | buffer[6] = 0x00; |
1301 | break; | 1304 | break; |
1302 | } | 1305 | } |
1303 | return ERR_NONE; | 1306 | return ERR_NONE; |
1304 | } | 1307 | } |
1305 | 1308 | ||
1306 | static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int field, void *data) { | 1309 | static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int field, void *data) { |
1307 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1310 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1308 | GSM_Error error; | 1311 | GSM_Error error; |
1309 | unsigned char buffer[200] = | 1312 | unsigned char buffer[200] = |
1310 | {0x00, 0x04, | 1313 | {0x00, 0x04, |
1311 | 0x00, /* type */ | 1314 | 0x00, /* type */ |
1312 | 0x25, 0x01, 0x65, | 1315 | 0x25, 0x01, 0x65, |
1313 | 0x00, /* length of remaining part */ | 1316 | 0x00, /* length of remaining part */ |
1314 | 0x00, /* field */ | 1317 | 0x00, /* field */ |
1315 | 0x37}; /* data follows here */ | 1318 | 0x37}; /* data follows here */ |
1316 | 1319 | ||
1317 | smprintf(s,"Creating field (%02x)\n", field); | 1320 | smprintf(s,"Creating field (%02x)\n", field); |
1318 | 1321 | ||
1319 | switch (Priv->BinaryType) { | 1322 | switch (Priv->BinaryType) { |
1320 | case TypeCalendar: | 1323 | case TypeCalendar: |
1321 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1324 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1322 | break; | 1325 | break; |
1323 | case TypeContacts: | 1326 | case TypeContacts: |
1324 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1327 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1325 | break; | 1328 | break; |
1326 | case TypeToDo: | 1329 | case TypeToDo: |
1327 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1330 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1328 | break; | 1331 | break; |
1329 | } | 1332 | } |
1330 | error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); | 1333 | error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); |
1331 | if (error != ERR_NONE) return error; | 1334 | if (error != ERR_NONE) return error; |
1332 | 1335 | ||
1333 | error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField); | 1336 | error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField); |
1334 | if (error != ERR_NONE) return error; | 1337 | if (error != ERR_NONE) return error; |
1335 | 1338 | ||
1336 | return ERR_NONE; | 1339 | return ERR_NONE; |
1337 | } | 1340 | } |
1338 | 1341 | ||
1339 | static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) { | 1342 | static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType type, int id, int field, void *data) { |
1340 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1343 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1341 | GSM_Error error; | 1344 | GSM_Error error; |
1342 | unsigned char buffer[200] = | 1345 | unsigned char buffer[200] = |
1343 | {0x00, 0x04, | 1346 | {0x00, 0x04, |
1344 | 0x00, /* type */ | 1347 | 0x00, /* type */ |
1345 | 0x26, 0x01, | 1348 | 0x26, 0x01, |
1346 | 0x00, 0x00, 0x00, 0x00,/* id */ | 1349 | 0x00, 0x00, 0x00, 0x00,/* id */ |
1347 | 0x65, | 1350 | 0x65, |
1348 | 0x00, /* length of remaining part */ | 1351 | 0x00, /* length of remaining part */ |
1349 | 0x00, /* field */ | 1352 | 0x00, /* field */ |
1350 | 0x37}; /* data follows here */ | 1353 | 0x37}; /* data follows here */ |
1351 | 1354 | ||
1352 | smprintf(s,"Updating field (%08x.%02x)\n", id, field); | 1355 | smprintf(s,"Updating field (%08x.%02x)\n", id, field); |
1353 | 1356 | ||
1354 | buffer[5] = (id >> 24); | 1357 | buffer[5] = (id >> 24); |
1355 | buffer[6] = ((id >> 16) & 0xff); | 1358 | buffer[6] = ((id >> 16) & 0xff); |
1356 | buffer[7] = ((id >> 8) & 0xff); | 1359 | buffer[7] = ((id >> 8) & 0xff); |
1357 | buffer[8] = (id & 0xff); | 1360 | buffer[8] = (id & 0xff); |
1358 | 1361 | ||
1359 | switch (Priv->BinaryType) { | 1362 | switch (Priv->BinaryType) { |
1360 | case TypeCalendar: | 1363 | case TypeCalendar: |
1361 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; | 1364 | buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; |
1362 | break; | 1365 | break; |
1363 | case TypeContacts: | 1366 | case TypeContacts: |
1364 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; | 1367 | buffer[2] = ALCATEL_SYNC_TYPE_CONTACTS; |
1365 | break; | 1368 | break; |
1366 | case TypeToDo: | 1369 | case TypeToDo: |
1367 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; | 1370 | buffer[2] = ALCATEL_SYNC_TYPE_TODO; |
1368 | break; | 1371 | break; |
1369 | } | 1372 | } |
1370 | error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); | 1373 | error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); |
1371 | if (error != ERR_NONE) return error; | 1374 | if (error != ERR_NONE) return error; |
1372 | 1375 | ||
1373 | error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField); | 1376 | error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField); |
1374 | if (error != ERR_NONE) return error; | 1377 | if (error != ERR_NONE) return error; |
1375 | 1378 | ||
1376 | return ERR_NONE; | 1379 | return ERR_NONE; |
1377 | } | 1380 | } |
1378 | 1381 | ||
1379 | static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s) | 1382 | static GSM_Error ALCATEL_GetManufacturer(GSM_StateMachine *s) |
1380 | { | 1383 | { |
1381 | strcpy(s->Phone.Data.Manufacturer, "Alcatel"); | 1384 | strcpy(s->Phone.Data.Manufacturer, "Alcatel"); |
1382 | return ERR_NONE; | 1385 | return ERR_NONE; |
1383 | } | 1386 | } |
1384 | 1387 | ||
1385 | static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s) | 1388 | static GSM_Error ALCATEL_GetIMEI (GSM_StateMachine *s) |
1386 | { | 1389 | { |
1387 | GSM_Error error; | 1390 | GSM_Error error; |
1388 | 1391 | ||
1389 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1392 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1390 | return ATGEN_GetIMEI(s); | 1393 | return ATGEN_GetIMEI(s); |
1391 | } | 1394 | } |
1392 | 1395 | ||
1393 | static GSM_Error ALCATEL_GetFirmware(GSM_StateMachine *s) | 1396 | static GSM_Error ALCATEL_GetFirmware(GSM_StateMachine *s) |
1394 | { | 1397 | { |
1395 | GSM_Error error; | 1398 | GSM_Error error; |
1396 | 1399 | ||
1397 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1400 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1398 | return ATGEN_GetFirmware(s); | 1401 | return ATGEN_GetFirmware(s); |
1399 | } | 1402 | } |
1400 | 1403 | ||
1401 | static GSM_Error ALCATEL_GetModel(GSM_StateMachine *s) | 1404 | static GSM_Error ALCATEL_GetModel(GSM_StateMachine *s) |
1402 | { | 1405 | { |
1403 | GSM_Error error; | 1406 | GSM_Error error; |
1404 | 1407 | ||
1405 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1408 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1406 | return ATGEN_GetModel(s); | 1409 | return ATGEN_GetModel(s); |
1407 | } | 1410 | } |
1408 | 1411 | ||
1409 | static GSM_Error ALCATEL_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) | 1412 | static GSM_Error ALCATEL_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) |
1410 | { | 1413 | { |
1411 | GSM_Error error; | 1414 | GSM_Error error; |
1412 | 1415 | ||
1413 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1416 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1414 | return ATGEN_GetDateTime(s, date_time); | 1417 | return ATGEN_GetDateTime(s, date_time); |
1415 | } | 1418 | } |
1416 | 1419 | ||
1417 | static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 1420 | static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
1418 | { | 1421 | { |
1419 | GSM_Error error; | 1422 | GSM_Error error; |
1420 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1423 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1421 | int i; | 1424 | int i; |
1422 | int j = 0; | 1425 | int j = 0; |
1423 | 1426 | ||
@@ -1698,427 +1701,427 @@ static GSM_Error ALCATEL_GetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | |||
1698 | entry->Entries[i - j].EntryType = PBK_PictureID; | 1701 | entry->Entries[i - j].EntryType = PBK_PictureID; |
1699 | entry->Entries[i - j].Number = Priv->ReturnInt; | 1702 | entry->Entries[i - j].Number = Priv->ReturnInt; |
1700 | } else { | 1703 | } else { |
1701 | entry->EntriesNum--; | 1704 | entry->EntriesNum--; |
1702 | j++; | 1705 | j++; |
1703 | } | 1706 | } |
1704 | break; | 1707 | break; |
1705 | default: | 1708 | default: |
1706 | entry->EntriesNum--; | 1709 | entry->EntriesNum--; |
1707 | j++; | 1710 | j++; |
1708 | smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); | 1711 | smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); |
1709 | switch (Priv->ReturnType) { | 1712 | switch (Priv->ReturnType) { |
1710 | case Alcatel_date: | 1713 | case Alcatel_date: |
1711 | smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); | 1714 | smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); |
1712 | break; | 1715 | break; |
1713 | case Alcatel_time: | 1716 | case Alcatel_time: |
1714 | smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); | 1717 | smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); |
1715 | break; | 1718 | break; |
1716 | case Alcatel_string: | 1719 | case Alcatel_string: |
1717 | case Alcatel_phone: | 1720 | case Alcatel_phone: |
1718 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); | 1721 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); |
1719 | break; | 1722 | break; |
1720 | case Alcatel_enum: | 1723 | case Alcatel_enum: |
1721 | case Alcatel_bool: | 1724 | case Alcatel_bool: |
1722 | case Alcatel_int: | 1725 | case Alcatel_int: |
1723 | case Alcatel_byte: | 1726 | case Alcatel_byte: |
1724 | smprintf(s, "%d", Priv->ReturnInt); | 1727 | smprintf(s, "%d", Priv->ReturnInt); |
1725 | break; | 1728 | break; |
1726 | } | 1729 | } |
1727 | smprintf(s,"\n"); | 1730 | smprintf(s,"\n"); |
1728 | } | 1731 | } |
1729 | } | 1732 | } |
1730 | return ERR_NONE; | 1733 | return ERR_NONE; |
1731 | } else { | 1734 | } else { |
1732 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1735 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1733 | return ATGEN_GetMemory(s, entry); | 1736 | return ATGEN_GetMemory(s, entry); |
1734 | } | 1737 | } |
1735 | } | 1738 | } |
1736 | 1739 | ||
1737 | static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start) | 1740 | static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start) |
1738 | { | 1741 | { |
1739 | GSM_Error error; | 1742 | GSM_Error error; |
1740 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1743 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1741 | 1744 | ||
1742 | if (entry->MemoryType == MEM_ME) { | 1745 | if (entry->MemoryType == MEM_ME) { |
1743 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 1746 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
1744 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 1747 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
1745 | if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; | 1748 | if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; |
1746 | 1749 | ||
1747 | if (start) entry->Location = 0; | 1750 | if (start) entry->Location = 0; |
1748 | if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; | 1751 | if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; |
1749 | 1752 | ||
1750 | return ALCATEL_GetMemory(s, entry); | 1753 | return ALCATEL_GetMemory(s, entry); |
1751 | } else { | 1754 | } else { |
1752 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1755 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1753 | return ATGEN_GetNextMemory(s, entry, start); | 1756 | return ATGEN_GetNextMemory(s, entry, start); |
1754 | } | 1757 | } |
1755 | } | 1758 | } |
1756 | 1759 | ||
1757 | static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 1760 | static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
1758 | { | 1761 | { |
1759 | GSM_Error error; | 1762 | GSM_Error error; |
1760 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1763 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1761 | int NamePosition = -1; | 1764 | int NamePosition = -1; |
1762 | bool NameSet = false; | 1765 | bool NameSet = false; |
1763 | int i; | 1766 | int i; |
1764 | 1767 | ||
1765 | 1768 | ||
1766 | if (entry->MemoryType == MEM_ME) { | 1769 | if (entry->MemoryType == MEM_ME) { |
1767 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 1770 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
1768 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error; | 1771 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error; |
1769 | for (i = 0; i < entry->EntriesNum; i++) { | 1772 | for (i = 0; i < entry->EntriesNum; i++) { |
1770 | switch (entry->Entries[i].EntryType) { | 1773 | switch (entry->Entries[i].EntryType) { |
1771 | case PBK_Number_General: | 1774 | case PBK_Number_General: |
1772 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error; | 1775 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error; |
1773 | break; | 1776 | break; |
1774 | case PBK_Number_Mobile: | 1777 | case PBK_Number_Mobile: |
1775 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 12, entry->Entries[i].Text)) != ERR_NONE) return error; | 1778 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 12, entry->Entries[i].Text)) != ERR_NONE) return error; |
1776 | break; | 1779 | break; |
1777 | case PBK_Number_Work: | 1780 | case PBK_Number_Work: |
1778 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error; | 1781 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error; |
1779 | break; | 1782 | break; |
1780 | case PBK_Number_Fax: | 1783 | case PBK_Number_Fax: |
1781 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error; | 1784 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error; |
1782 | break; | 1785 | break; |
1783 | case PBK_Number_Home: | 1786 | case PBK_Number_Home: |
1784 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 13, entry->Entries[i].Text)) != ERR_NONE) return error; | 1787 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 13, entry->Entries[i].Text)) != ERR_NONE) return error; |
1785 | break; | 1788 | break; |
1786 | case PBK_Number_Pager: | 1789 | case PBK_Number_Pager: |
1787 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 11, entry->Entries[i].Text)) != ERR_NONE) return error; | 1790 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 11, entry->Entries[i].Text)) != ERR_NONE) return error; |
1788 | break; | 1791 | break; |
1789 | case PBK_Number_Other: | 1792 | case PBK_Number_Other: |
1790 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 10, entry->Entries[i].Text)) != ERR_NONE) return error; | 1793 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 10, entry->Entries[i].Text)) != ERR_NONE) return error; |
1791 | break; | 1794 | break; |
1792 | case PBK_Text_Note: | 1795 | case PBK_Text_Note: |
1793 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, entry->Entries[i].Text)) != ERR_NONE) return error; | 1796 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, entry->Entries[i].Text)) != ERR_NONE) return error; |
1794 | break; | 1797 | break; |
1795 | case PBK_Text_Email: | 1798 | case PBK_Text_Email: |
1796 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 14, entry->Entries[i].Text)) != ERR_NONE) return error; | 1799 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 14, entry->Entries[i].Text)) != ERR_NONE) return error; |
1797 | break; | 1800 | break; |
1798 | case PBK_Text_Email2: | 1801 | case PBK_Text_Email2: |
1799 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 15, entry->Entries[i].Text)) != ERR_NONE) return error; | 1802 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 15, entry->Entries[i].Text)) != ERR_NONE) return error; |
1800 | break; | 1803 | break; |
1801 | case PBK_Text_LastName: | 1804 | case PBK_Text_LastName: |
1802 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 0, entry->Entries[i].Text)) != ERR_NONE) return error; | 1805 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 0, entry->Entries[i].Text)) != ERR_NONE) return error; |
1803 | NameSet = true; | 1806 | NameSet = true; |
1804 | break; | 1807 | break; |
1805 | case PBK_Text_FirstName: | 1808 | case PBK_Text_FirstName: |
1806 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; | 1809 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; |
1807 | NameSet = true; | 1810 | NameSet = true; |
1808 | break; | 1811 | break; |
1809 | case PBK_Text_Company: | 1812 | case PBK_Text_Company: |
1810 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error; | 1813 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error; |
1811 | break; | 1814 | break; |
1812 | case PBK_Text_JobTitle: | 1815 | case PBK_Text_JobTitle: |
1813 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error; | 1816 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error; |
1814 | break; | 1817 | break; |
1815 | case PBK_Category: | 1818 | case PBK_Category: |
1816 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; | 1819 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; |
1817 | break; | 1820 | break; |
1818 | case PBK_Private: | 1821 | case PBK_Private: |
1819 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; | 1822 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; |
1820 | break; | 1823 | break; |
1821 | case PBK_Text_StreetAddress: | 1824 | case PBK_Text_StreetAddress: |
1822 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 16, entry->Entries[i].Text)) != ERR_NONE) return error; | 1825 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 16, entry->Entries[i].Text)) != ERR_NONE) return error; |
1823 | break; | 1826 | break; |
1824 | case PBK_Text_City: | 1827 | case PBK_Text_City: |
1825 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 17, entry->Entries[i].Text)) != ERR_NONE) return error; | 1828 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 17, entry->Entries[i].Text)) != ERR_NONE) return error; |
1826 | break; | 1829 | break; |
1827 | case PBK_Text_State: | 1830 | case PBK_Text_State: |
1828 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 18, entry->Entries[i].Text)) != ERR_NONE) return error; | 1831 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 18, entry->Entries[i].Text)) != ERR_NONE) return error; |
1829 | break; | 1832 | break; |
1830 | case PBK_Text_Zip: | 1833 | case PBK_Text_Zip: |
1831 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 19, entry->Entries[i].Text)) != ERR_NONE) return error; | 1834 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 19, entry->Entries[i].Text)) != ERR_NONE) return error; |
1832 | break; | 1835 | break; |
1833 | case PBK_Text_Country: | 1836 | case PBK_Text_Country: |
1834 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 20, entry->Entries[i].Text)) != ERR_NONE) return error; | 1837 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 20, entry->Entries[i].Text)) != ERR_NONE) return error; |
1835 | break; | 1838 | break; |
1836 | case PBK_Text_Custom1: | 1839 | case PBK_Text_Custom1: |
1837 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 21, entry->Entries[i].Text)) != ERR_NONE) return error; | 1840 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 21, entry->Entries[i].Text)) != ERR_NONE) return error; |
1838 | break; | 1841 | break; |
1839 | case PBK_Text_Custom2: | 1842 | case PBK_Text_Custom2: |
1840 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error; | 1843 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error; |
1841 | break; | 1844 | break; |
1842 | case PBK_Text_Custom3: | 1845 | case PBK_Text_Custom3: |
1843 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error; | 1846 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error; |
1844 | break; | 1847 | break; |
1845 | case PBK_Text_Custom4: | 1848 | case PBK_Text_Custom4: |
1846 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error; | 1849 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error; |
1847 | break; | 1850 | break; |
1848 | case PBK_PictureID: | 1851 | case PBK_PictureID: |
1849 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 1852 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
1850 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; | 1853 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; |
1851 | } else { | 1854 | } else { |
1852 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); | 1855 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); |
1853 | } | 1856 | } |
1854 | break; | 1857 | break; |
1855 | 1858 | ||
1856 | case PBK_Text_Name: NamePosition = i; break; | 1859 | case PBK_Text_Name: NamePosition = i; break; |
1857 | /* Following fields are not supported: */ | 1860 | /* Following fields are not supported: */ |
1858 | case PBK_Text_UserID: | 1861 | case PBK_Text_UserID: |
1859 | case PBK_SMSListID: | 1862 | case PBK_SMSListID: |
1860 | case PBK_RingtoneFileSystemID: | 1863 | case PBK_RingtoneFileSystemID: |
1861 | case PBK_Date: | 1864 | case PBK_Date: |
1862 | case PBK_Caller_Group: | 1865 | case PBK_Caller_Group: |
1863 | case PBK_RingtoneID: | 1866 | case PBK_RingtoneID: |
1864 | case PBK_Text_Postal: | 1867 | case PBK_Text_Postal: |
1865 | case PBK_Text_URL: | 1868 | case PBK_Text_URL: |
1866 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); | 1869 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); |
1867 | break; | 1870 | break; |
1868 | } | 1871 | } |
1869 | } | 1872 | } |
1870 | if (NamePosition != -1) { | 1873 | if (NamePosition != -1) { |
1871 | if (NameSet) { | 1874 | if (NameSet) { |
1872 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); | 1875 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); |
1873 | } else { | 1876 | } else { |
1874 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; | 1877 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 1, entry->Entries[i].Text)) != ERR_NONE) return error; |
1875 | } | 1878 | } |
1876 | } | 1879 | } |
1877 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 1880 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
1878 | entry->Location = Priv->CommitedRecord; | 1881 | entry->Location = Priv->CommitedRecord; |
1879 | /* Refresh list */ | 1882 | /* Refresh list */ |
1880 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 1883 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
1881 | return ERR_NONE; | 1884 | return ERR_NONE; |
1882 | } else { | 1885 | } else { |
1883 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 1886 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
1884 | return ATGEN_AddMemory(s, entry); | 1887 | return ATGEN_AddMemory(s, entry); |
1885 | } | 1888 | } |
1886 | } | 1889 | } |
1887 | 1890 | ||
1888 | static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 1891 | static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
1889 | { | 1892 | { |
1890 | GSM_Error error; | 1893 | GSM_Error error; |
1891 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 1894 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
1892 | int NamePosition = -1; | 1895 | int NamePosition = -1; |
1893 | bool NameSet = false; | 1896 | bool NameSet = false; |
1894 | int i; | 1897 | int i; |
1895 | bool UpdatedFields[26]; | 1898 | bool UpdatedFields[26]; |
1896 | 1899 | ||
1897 | if (entry->Location == 0) return ERR_INVALIDLOCATION; | 1900 | if (entry->Location == 0) return ERR_INVALIDLOCATION; |
1898 | 1901 | ||
1899 | if (entry->MemoryType == MEM_ME) { | 1902 | if (entry->MemoryType == MEM_ME) { |
1900 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 1903 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
1901 | /* Save modified entry */ | 1904 | /* Save modified entry */ |
1902 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 1905 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
1903 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { | 1906 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { |
1904 | /* Entry doesn't exist, we will create new one */ | 1907 | /* Entry doesn't exist, we will create new one */ |
1905 | return ALCATEL_AddMemory(s, entry); | 1908 | return ALCATEL_AddMemory(s, entry); |
1906 | } | 1909 | } |
1907 | /* Get fields for current item */ | 1910 | /* Get fields for current item */ |
1908 | if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; | 1911 | if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; |
1909 | 1912 | ||
1910 | for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } | 1913 | for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } |
1911 | 1914 | ||
1912 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error; | 1915 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error; |
1913 | for (i = 0; i < entry->EntriesNum; i++) { | 1916 | for (i = 0; i < entry->EntriesNum; i++) { |
1914 | switch (entry->Entries[i].EntryType) { | 1917 | switch (entry->Entries[i].EntryType) { |
1915 | case PBK_Number_General: | 1918 | case PBK_Number_General: |
1916 | UpdatedFields[8] = true; | 1919 | UpdatedFields[8] = true; |
1917 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error; | 1920 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error; |
1918 | break; | 1921 | break; |
1919 | case PBK_Number_Mobile: | 1922 | case PBK_Number_Mobile: |
1920 | UpdatedFields[12] = true; | 1923 | UpdatedFields[12] = true; |
1921 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error; | 1924 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error; |
1922 | break; | 1925 | break; |
1923 | case PBK_Number_Work: | 1926 | case PBK_Number_Work: |
1924 | UpdatedFields[7] = true; | 1927 | UpdatedFields[7] = true; |
1925 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error; | 1928 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error; |
1926 | break; | 1929 | break; |
1927 | case PBK_Number_Fax: | 1930 | case PBK_Number_Fax: |
1928 | UpdatedFields[9] = true; | 1931 | UpdatedFields[9] = true; |
1929 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error; | 1932 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error; |
1930 | break; | 1933 | break; |
1931 | case PBK_Number_Home: | 1934 | case PBK_Number_Home: |
1932 | UpdatedFields[13] = true; | 1935 | UpdatedFields[13] = true; |
1933 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error; | 1936 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error; |
1934 | break; | 1937 | break; |
1935 | case PBK_Number_Pager: | 1938 | case PBK_Number_Pager: |
1936 | UpdatedFields[11] = true; | 1939 | UpdatedFields[11] = true; |
1937 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error; | 1940 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error; |
1938 | break; | 1941 | break; |
1939 | case PBK_Number_Other: | 1942 | case PBK_Number_Other: |
1940 | UpdatedFields[10] = true; | 1943 | UpdatedFields[10] = true; |
1941 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error; | 1944 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error; |
1942 | break; | 1945 | break; |
1943 | case PBK_Text_Note: | 1946 | case PBK_Text_Note: |
1944 | UpdatedFields[4] = true; | 1947 | UpdatedFields[4] = true; |
1945 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error; | 1948 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error; |
1946 | break; | 1949 | break; |
1947 | case PBK_Text_Email: | 1950 | case PBK_Text_Email: |
1948 | UpdatedFields[14] = true; | 1951 | UpdatedFields[14] = true; |
1949 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error; | 1952 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error; |
1950 | break; | 1953 | break; |
1951 | case PBK_Text_Email2: | 1954 | case PBK_Text_Email2: |
1952 | UpdatedFields[15] = true; | 1955 | UpdatedFields[15] = true; |
1953 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error; | 1956 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error; |
1954 | break; | 1957 | break; |
1955 | case PBK_Text_LastName: | 1958 | case PBK_Text_LastName: |
1956 | UpdatedFields[0] = true; | 1959 | UpdatedFields[0] = true; |
1957 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; | 1960 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; |
1958 | break; | 1961 | break; |
1959 | case PBK_Text_FirstName: | 1962 | case PBK_Text_FirstName: |
1960 | UpdatedFields[1] = true; | 1963 | UpdatedFields[1] = true; |
1961 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; | 1964 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; |
1962 | break; | 1965 | break; |
1963 | case PBK_Text_Company: | 1966 | case PBK_Text_Company: |
1964 | UpdatedFields[2] = true; | 1967 | UpdatedFields[2] = true; |
1965 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error; | 1968 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error; |
1966 | break; | 1969 | break; |
1967 | case PBK_Text_JobTitle: | 1970 | case PBK_Text_JobTitle: |
1968 | UpdatedFields[3] = true; | 1971 | UpdatedFields[3] = true; |
1969 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error; | 1972 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error; |
1970 | break; | 1973 | break; |
1971 | case PBK_Category: | 1974 | case PBK_Category: |
1972 | UpdatedFields[5] = true; | 1975 | UpdatedFields[5] = true; |
1973 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; | 1976 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; |
1974 | break; | 1977 | break; |
1975 | case PBK_Private: | 1978 | case PBK_Private: |
1976 | UpdatedFields[6] = true; | 1979 | UpdatedFields[6] = true; |
1977 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; | 1980 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; |
1978 | break; | 1981 | break; |
1979 | case PBK_Text_StreetAddress: | 1982 | case PBK_Text_StreetAddress: |
1980 | UpdatedFields[16] = true; | 1983 | UpdatedFields[16] = true; |
1981 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error; | 1984 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error; |
1982 | break; | 1985 | break; |
1983 | case PBK_Text_City: | 1986 | case PBK_Text_City: |
1984 | UpdatedFields[17] = true; | 1987 | UpdatedFields[17] = true; |
1985 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error; | 1988 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error; |
1986 | break; | 1989 | break; |
1987 | case PBK_Text_State: | 1990 | case PBK_Text_State: |
1988 | UpdatedFields[18] = true; | 1991 | UpdatedFields[18] = true; |
1989 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error; | 1992 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error; |
1990 | break; | 1993 | break; |
1991 | case PBK_Text_Zip: | 1994 | case PBK_Text_Zip: |
1992 | UpdatedFields[19] = true; | 1995 | UpdatedFields[19] = true; |
1993 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error; | 1996 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error; |
1994 | break; | 1997 | break; |
1995 | case PBK_Text_Country: | 1998 | case PBK_Text_Country: |
1996 | UpdatedFields[20] = true; | 1999 | UpdatedFields[20] = true; |
1997 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 20, entry->Entries[i].Text)) != ERR_NONE) return error; | 2000 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 20, entry->Entries[i].Text)) != ERR_NONE) return error; |
1998 | break; | 2001 | break; |
1999 | case PBK_Text_Custom1: | 2002 | case PBK_Text_Custom1: |
2000 | UpdatedFields[21] = true; | 2003 | UpdatedFields[21] = true; |
2001 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error; | 2004 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error; |
2002 | break; | 2005 | break; |
2003 | case PBK_Text_Custom2: | 2006 | case PBK_Text_Custom2: |
2004 | UpdatedFields[22] = true; | 2007 | UpdatedFields[22] = true; |
2005 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error; | 2008 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error; |
2006 | break; | 2009 | break; |
2007 | case PBK_Text_Custom3: | 2010 | case PBK_Text_Custom3: |
2008 | UpdatedFields[23] = true; | 2011 | UpdatedFields[23] = true; |
2009 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error; | 2012 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error; |
2010 | break; | 2013 | break; |
2011 | case PBK_Text_Custom4: | 2014 | case PBK_Text_Custom4: |
2012 | UpdatedFields[24] = true; | 2015 | UpdatedFields[24] = true; |
2013 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error | 2016 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error |
2014 | ; break; | 2017 | ; break; |
2015 | case PBK_PictureID: | 2018 | case PBK_PictureID: |
2016 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 2019 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
2017 | UpdatedFields[25] = true; | 2020 | UpdatedFields[25] = true; |
2018 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; | 2021 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; |
2019 | } else { | 2022 | } else { |
2020 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); | 2023 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); |
2021 | } | 2024 | } |
2022 | break; | 2025 | break; |
2023 | 2026 | ||
2024 | case PBK_Text_Name: NamePosition = i; break; | 2027 | case PBK_Text_Name: NamePosition = i; break; |
2025 | /* Following fields are not supported: */ | 2028 | /* Following fields are not supported: */ |
2026 | case PBK_SMSListID: | 2029 | case PBK_SMSListID: |
2027 | case PBK_Text_UserID: | 2030 | case PBK_Text_UserID: |
2028 | case PBK_RingtoneFileSystemID: | 2031 | case PBK_RingtoneFileSystemID: |
2029 | case PBK_Date: | 2032 | case PBK_Date: |
2030 | case PBK_Caller_Group: | 2033 | case PBK_Caller_Group: |
2031 | case PBK_RingtoneID: | 2034 | case PBK_RingtoneID: |
2032 | case PBK_Text_Postal: | 2035 | case PBK_Text_Postal: |
2033 | case PBK_Text_URL: | 2036 | case PBK_Text_URL: |
2034 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); | 2037 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", entry->Entries[i].EntryType); |
2035 | break; | 2038 | break; |
2036 | } | 2039 | } |
2037 | } | 2040 | } |
2038 | if (NamePosition != -1) { | 2041 | if (NamePosition != -1) { |
2039 | if (NameSet) { | 2042 | if (NameSet) { |
2040 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); | 2043 | smprintf(s,"WARNING: Ignoring name, not supported by phone\n"); |
2041 | } else { | 2044 | } else { |
2042 | UpdatedFields[1] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; | 2045 | UpdatedFields[1] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; |
2043 | } | 2046 | } |
2044 | } | 2047 | } |
2045 | /* If we didn't update some field, we have to delete it... */ | 2048 | /* If we didn't update some field, we have to delete it... */ |
2046 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 2049 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
2047 | if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, entry->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; | 2050 | if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, entry->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; |
2048 | } | 2051 | } |
2049 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 2052 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
2050 | entry->Location = Priv->CommitedRecord; | 2053 | entry->Location = Priv->CommitedRecord; |
2051 | return ERR_NONE; | 2054 | return ERR_NONE; |
2052 | } else { | 2055 | } else { |
2053 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2056 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2054 | return ATGEN_SetMemory(s, entry); | 2057 | return ATGEN_SetMemory(s, entry); |
2055 | } | 2058 | } |
2056 | } | 2059 | } |
2057 | 2060 | ||
2058 | static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) | 2061 | static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) |
2059 | { | 2062 | { |
2060 | GSM_Error error; | 2063 | GSM_Error error; |
2061 | 2064 | ||
2062 | if (entry->MemoryType == MEM_ME) { | 2065 | if (entry->MemoryType == MEM_ME) { |
2063 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 2066 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
2064 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2067 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2065 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { | 2068 | if ((error = ALCATEL_IsIdAvailable(s, entry->Location))!= ERR_NONE) { |
2066 | /* Entry was empty => no error */ | 2069 | /* Entry was empty => no error */ |
2067 | return ERR_NONE; | 2070 | return ERR_NONE; |
2068 | } | 2071 | } |
2069 | /* Do real delete */ | 2072 | /* Do real delete */ |
2070 | error = ALCATEL_DeleteItem(s, entry->Location); | 2073 | error = ALCATEL_DeleteItem(s, entry->Location); |
2071 | if (error != ERR_NONE) return error; | 2074 | if (error != ERR_NONE) return error; |
2072 | 2075 | ||
2073 | /* Refresh list */ | 2076 | /* Refresh list */ |
2074 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 2077 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
2075 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2078 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2076 | 2079 | ||
2077 | return ERR_NONE; | 2080 | return ERR_NONE; |
2078 | } else { | 2081 | } else { |
2079 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2082 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2080 | return ATGEN_DeleteMemory(s, entry); | 2083 | return ATGEN_DeleteMemory(s, entry); |
2081 | } | 2084 | } |
2082 | } | 2085 | } |
2083 | 2086 | ||
2084 | static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) | 2087 | static GSM_Error ALCATEL_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) |
2085 | { | 2088 | { |
2086 | GSM_Error error; | 2089 | GSM_Error error; |
2087 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2090 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2088 | int i; | 2091 | int i; |
2089 | 2092 | ||
2090 | if (type == MEM_ME) { | 2093 | if (type == MEM_ME) { |
2091 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 2094 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
2092 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2095 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2093 | 2096 | ||
2094 | for (i=0; i<Priv->ContactsItemsCount; i++) { | 2097 | for (i=0; i<Priv->ContactsItemsCount; i++) { |
2095 | error = ALCATEL_DeleteItem(s, Priv->ContactsItems[i]); | 2098 | error = ALCATEL_DeleteItem(s, Priv->ContactsItems[i]); |
2096 | if (error != ERR_NONE) return error; | 2099 | if (error != ERR_NONE) return error; |
2097 | } | 2100 | } |
2098 | 2101 | ||
2099 | /* Refresh list */ | 2102 | /* Refresh list */ |
2100 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; | 2103 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; |
2101 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2104 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2102 | 2105 | ||
2103 | return ERR_NONE; | 2106 | return ERR_NONE; |
2104 | } else { | 2107 | } else { |
2105 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2108 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2106 | return ATGEN_DeleteAllMemory(s, type); | 2109 | return ATGEN_DeleteAllMemory(s, type); |
2107 | } | 2110 | } |
2108 | } | 2111 | } |
2109 | 2112 | ||
2110 | static GSM_Error ALCATEL_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) | 2113 | static GSM_Error ALCATEL_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) |
2111 | { | 2114 | { |
2112 | GSM_Error error; | 2115 | GSM_Error error; |
2113 | 2116 | ||
2114 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2117 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2115 | return ATGEN_GetSMSC(s, smsc); | 2118 | return ATGEN_GetSMSC(s, smsc); |
2116 | } | 2119 | } |
2117 | 2120 | ||
2118 | 2121 | ||
2119 | static GSM_Error ALCATEL_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) | 2122 | static GSM_Error ALCATEL_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) |
2120 | { | 2123 | { |
2121 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; | 2124 | GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; |
2122 | GSM_Error error; | 2125 | GSM_Error error; |
2123 | 2126 | ||
2124 | if (Status->MemoryType == MEM_ME) { | 2127 | if (Status->MemoryType == MEM_ME) { |
@@ -2183,97 +2186,97 @@ static GSM_Error ALCATEL_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *fold | |||
2183 | 2186 | ||
2184 | static GSM_Error ALCATEL_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start) | 2187 | static GSM_Error ALCATEL_GetNextSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start) |
2185 | { | 2188 | { |
2186 | GSM_Error error; | 2189 | GSM_Error error; |
2187 | 2190 | ||
2188 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2191 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2189 | return ATGEN_GetNextSMS(s, sms, start); | 2192 | return ATGEN_GetNextSMS(s, sms, start); |
2190 | } | 2193 | } |
2191 | 2194 | ||
2192 | static GSM_Error ALCATEL_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status) | 2195 | static GSM_Error ALCATEL_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status) |
2193 | { | 2196 | { |
2194 | GSM_Error error; | 2197 | GSM_Error error; |
2195 | 2198 | ||
2196 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2199 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2197 | return ATGEN_GetSMSStatus(s, status); | 2200 | return ATGEN_GetSMSStatus(s, status); |
2198 | } | 2201 | } |
2199 | 2202 | ||
2200 | static GSM_Error ALCATEL_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) | 2203 | static GSM_Error ALCATEL_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) |
2201 | { | 2204 | { |
2202 | GSM_Error error; | 2205 | GSM_Error error; |
2203 | 2206 | ||
2204 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2207 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2205 | return ATGEN_DialVoice(s, number, ShowNumber); | 2208 | return ATGEN_DialVoice(s, number, ShowNumber); |
2206 | } | 2209 | } |
2207 | 2210 | ||
2208 | static GSM_Error ALCATEL_AnswerCall(GSM_StateMachine *s, int ID, bool all) | 2211 | static GSM_Error ALCATEL_AnswerCall(GSM_StateMachine *s, int ID, bool all) |
2209 | { | 2212 | { |
2210 | GSM_Error error; | 2213 | GSM_Error error; |
2211 | 2214 | ||
2212 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2215 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2213 | return ATGEN_AnswerCall(s,ID,all); | 2216 | return ATGEN_AnswerCall(s,ID,all); |
2214 | } | 2217 | } |
2215 | 2218 | ||
2216 | static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) | 2219 | static GSM_Error ALCATEL_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo) |
2217 | { | 2220 | { |
2218 | GSM_Error error; | 2221 | GSM_Error error; |
2219 | 2222 | ||
2220 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2223 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2221 | return ATGEN_GetNetworkInfo(s, netinfo); | 2224 | return ATGEN_GetNetworkInfo(s, netinfo); |
2222 | } | 2225 | } |
2223 | 2226 | ||
2224 | static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features) | 2227 | static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features) |
2225 | { | 2228 | { |
2226 | GSM_Error error; | 2229 | GSM_Error error; |
2227 | 2230 | ||
2228 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2231 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2229 | return ATGEN_GetDisplayStatus(s, features); | 2232 | return ATGEN_GetDisplayStatus(s, features); |
2230 | } | 2233 | } |
2231 | 2234 | ||
2232 | static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) | 2235 | static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) |
2233 | { | 2236 | { |
2234 | GSM_Error error; | 2237 | GSM_Error error; |
2235 | 2238 | ||
2236 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2239 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2237 | return ATGEN_SetAutoNetworkLogin(s); | 2240 | return ATGEN_SetAutoNetworkLogin(s); |
2238 | } | 2241 | } |
2239 | 2242 | ||
2240 | static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) | 2243 | static GSM_Error ALCATEL_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) |
2241 | { | 2244 | { |
2242 | GSM_Error error; | 2245 | GSM_Error error; |
2243 | 2246 | ||
2244 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2247 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2245 | return ATGEN_PressKey(s, Key, Press); | 2248 | return ATGEN_PressKey(s, Key, Press); |
2246 | } | 2249 | } |
2247 | 2250 | ||
2248 | static GSM_Error ALCATEL_Reset(GSM_StateMachine *s, bool hard) | 2251 | static GSM_Error ALCATEL_Reset(GSM_StateMachine *s, bool hard) |
2249 | { | 2252 | { |
2250 | GSM_Error error; | 2253 | GSM_Error error; |
2251 | 2254 | ||
2252 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2255 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2253 | return ATGEN_Reset(s, hard); | 2256 | return ATGEN_Reset(s, hard); |
2254 | } | 2257 | } |
2255 | 2258 | ||
2256 | static GSM_Error ALCATEL_CancelCall(GSM_StateMachine *s, int ID, bool all) | 2259 | static GSM_Error ALCATEL_CancelCall(GSM_StateMachine *s, int ID, bool all) |
2257 | { | 2260 | { |
2258 | GSM_Error error; | 2261 | GSM_Error error; |
2259 | 2262 | ||
2260 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2263 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2261 | return ATGEN_CancelCall(s,ID,all); | 2264 | return ATGEN_CancelCall(s,ID,all); |
2262 | } | 2265 | } |
2263 | 2266 | ||
2264 | static GSM_Error ALCATEL_SendSavedSMS(GSM_StateMachine *s, int Folder, int Location) | 2267 | static GSM_Error ALCATEL_SendSavedSMS(GSM_StateMachine *s, int Folder, int Location) |
2265 | { | 2268 | { |
2266 | GSM_Error error; | 2269 | GSM_Error error; |
2267 | 2270 | ||
2268 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2271 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2269 | return ATGEN_SendSavedSMS(s, Folder, Location); | 2272 | return ATGEN_SendSavedSMS(s, Folder, Location); |
2270 | } | 2273 | } |
2271 | 2274 | ||
2272 | static GSM_Error ALCATEL_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) | 2275 | static GSM_Error ALCATEL_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) |
2273 | { | 2276 | { |
2274 | GSM_Error error; | 2277 | GSM_Error error; |
2275 | 2278 | ||
2276 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2279 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2277 | return ATGEN_SendSMS(s, sms); | 2280 | return ATGEN_SendSMS(s, sms); |
2278 | } | 2281 | } |
2279 | 2282 | ||
@@ -2292,99 +2295,99 @@ static GSM_Error ALCATEL_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) | |||
2292 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2295 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2293 | return ATGEN_SetSMSC(s, smsc); | 2296 | return ATGEN_SetSMSC(s, smsc); |
2294 | } | 2297 | } |
2295 | 2298 | ||
2296 | static GSM_Error ALCATEL_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) | 2299 | static GSM_Error ALCATEL_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) |
2297 | { | 2300 | { |
2298 | GSM_Error error; | 2301 | GSM_Error error; |
2299 | 2302 | ||
2300 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2303 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2301 | return ATGEN_EnterSecurityCode(s, Code); | 2304 | return ATGEN_EnterSecurityCode(s, Code); |
2302 | } | 2305 | } |
2303 | 2306 | ||
2304 | static GSM_Error ALCATEL_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) | 2307 | static GSM_Error ALCATEL_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) |
2305 | { | 2308 | { |
2306 | GSM_Error error; | 2309 | GSM_Error error; |
2307 | 2310 | ||
2308 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2311 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2309 | return ATGEN_GetSecurityStatus(s, Status); | 2312 | return ATGEN_GetSecurityStatus(s, Status); |
2310 | } | 2313 | } |
2311 | 2314 | ||
2312 | static GSM_Error ALCATEL_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type) | 2315 | static GSM_Error ALCATEL_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type) |
2313 | { | 2316 | { |
2314 | GSM_Error error; | 2317 | GSM_Error error; |
2315 | 2318 | ||
2316 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2319 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2317 | return ATGEN_ResetPhoneSettings(s, Type); | 2320 | return ATGEN_ResetPhoneSettings(s, Type); |
2318 | } | 2321 | } |
2319 | 2322 | ||
2320 | static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence) | 2323 | static GSM_Error ALCATEL_SendDTMF(GSM_StateMachine *s, char *sequence) |
2321 | { | 2324 | { |
2322 | GSM_Error error; | 2325 | GSM_Error error; |
2323 | 2326 | ||
2324 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2327 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2325 | return ATGEN_SendDTMF(s, sequence); | 2328 | return ATGEN_SendDTMF(s, sequence); |
2326 | } | 2329 | } |
2327 | 2330 | ||
2328 | static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI) | 2331 | static GSM_Error ALCATEL_GetSIMIMSI(GSM_StateMachine *s, char *IMSI) |
2329 | { | 2332 | { |
2330 | GSM_Error error; | 2333 | GSM_Error error; |
2331 | 2334 | ||
2332 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 2335 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
2333 | return ATGEN_GetSIMIMSI(s, IMSI); | 2336 | return ATGEN_GetSIMIMSI(s, IMSI); |
2334 | } | 2337 | } |
2335 | 2338 | ||
2336 | static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status) | 2339 | static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *status) |
2337 | { | 2340 | { |
2338 | GSM_Error error; | 2341 | GSM_Error error; |
2339 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2342 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2340 | 2343 | ||
2341 | status->Used = 0; | 2344 | status->Used = 0; |
2342 | 2345 | ||
2343 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2346 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2344 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2347 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2345 | 2348 | ||
2346 | status->Used = Priv->CalendarItemsCount; | 2349 | status->Used = Priv->CalendarItemsCount; |
2347 | return ERR_NONE; | 2350 | return ERR_NONE; |
2348 | } | 2351 | } |
2349 | 2352 | ||
2350 | static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2353 | static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2351 | { | 2354 | { |
2352 | GSM_Error error; | 2355 | GSM_Error error; |
2353 | GSM_DateTime *dt = NULL; | 2356 | GSM_DateTime *dt = NULL; |
2354 | GSM_DateTime evdate; | 2357 | GSM_DateTime evdate; |
2355 | bool evdateused = true; | 2358 | bool evdateused = true; |
2356 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2359 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2357 | int i; | 2360 | int i; |
2358 | int j=0; | 2361 | int j=0; |
2359 | 2362 | ||
2360 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2363 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2361 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2364 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2362 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { | 2365 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { |
2363 | Note->EntriesNum = 0; | 2366 | Note->EntriesNum = 0; |
2364 | return error; | 2367 | return error; |
2365 | } | 2368 | } |
2366 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; | 2369 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; |
2367 | 2370 | ||
2368 | Note->EntriesNum = Priv->CurrentFieldsCount; | 2371 | Note->EntriesNum = Priv->CurrentFieldsCount; |
2369 | 2372 | ||
2370 | for (i=0; i < Priv->CurrentFieldsCount; i++) { | 2373 | for (i=0; i < Priv->CurrentFieldsCount; i++) { |
2371 | if ((error = ALCATEL_GetFieldValue(s, Note->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; | 2374 | if ((error = ALCATEL_GetFieldValue(s, Note->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; |
2372 | switch (Priv->CurrentFields[i]) { | 2375 | switch (Priv->CurrentFields[i]) { |
2373 | case 0: | 2376 | case 0: |
2374 | if (Priv->ReturnType != Alcatel_date) { | 2377 | if (Priv->ReturnType != Alcatel_date) { |
2375 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 2378 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
2376 | Note->EntriesNum--; | 2379 | Note->EntriesNum--; |
2377 | j++; | 2380 | j++; |
2378 | break; | 2381 | break; |
2379 | } | 2382 | } |
2380 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 2383 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
2381 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 2384 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
2382 | Note->EntriesNum--; | 2385 | Note->EntriesNum--; |
2383 | j++; | 2386 | j++; |
2384 | break; | 2387 | break; |
2385 | } | 2388 | } |
2386 | j++; | 2389 | j++; |
2387 | Note->EntriesNum--; | 2390 | Note->EntriesNum--; |
2388 | evdate = Priv->ReturnDateTime; | 2391 | evdate = Priv->ReturnDateTime; |
2389 | evdateused = false; | 2392 | evdateused = false; |
2390 | break; | 2393 | break; |
@@ -2682,556 +2685,556 @@ static GSM_Error ALCATEL_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not | |||
2682 | break; | 2685 | break; |
2683 | } | 2686 | } |
2684 | /* This entry had always same value as the 4th (alarm time) */ | 2687 | /* This entry had always same value as the 4th (alarm time) */ |
2685 | j++; | 2688 | j++; |
2686 | Note->EntriesNum--; | 2689 | Note->EntriesNum--; |
2687 | break; | 2690 | break; |
2688 | default: | 2691 | default: |
2689 | Note->EntriesNum--; | 2692 | Note->EntriesNum--; |
2690 | j++; | 2693 | j++; |
2691 | smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); | 2694 | smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); |
2692 | switch (Priv->ReturnType) { | 2695 | switch (Priv->ReturnType) { |
2693 | case Alcatel_date: | 2696 | case Alcatel_date: |
2694 | smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); | 2697 | smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); |
2695 | break; | 2698 | break; |
2696 | case Alcatel_time: | 2699 | case Alcatel_time: |
2697 | smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); | 2700 | smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); |
2698 | break; | 2701 | break; |
2699 | case Alcatel_string: | 2702 | case Alcatel_string: |
2700 | case Alcatel_phone: | 2703 | case Alcatel_phone: |
2701 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); | 2704 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); |
2702 | break; | 2705 | break; |
2703 | case Alcatel_enum: | 2706 | case Alcatel_enum: |
2704 | case Alcatel_bool: | 2707 | case Alcatel_bool: |
2705 | case Alcatel_int: | 2708 | case Alcatel_int: |
2706 | case Alcatel_byte: | 2709 | case Alcatel_byte: |
2707 | smprintf(s, "%d", Priv->ReturnInt); | 2710 | smprintf(s, "%d", Priv->ReturnInt); |
2708 | break; | 2711 | break; |
2709 | } | 2712 | } |
2710 | smprintf(s,"\n"); | 2713 | smprintf(s,"\n"); |
2711 | } | 2714 | } |
2712 | } | 2715 | } |
2713 | /* The event didn't have start/stop time -> we need only date */ | 2716 | /* The event didn't have start/stop time -> we need only date */ |
2714 | if (!evdateused) { | 2717 | if (!evdateused) { |
2715 | Note->EntriesNum++; | 2718 | Note->EntriesNum++; |
2716 | Note->Entries[i-j].EntryType = CAL_START_DATETIME; | 2719 | Note->Entries[i-j].EntryType = CAL_START_DATETIME; |
2717 | Note->Entries[i-j].Date = evdate; | 2720 | Note->Entries[i-j].Date = evdate; |
2718 | } | 2721 | } |
2719 | return ERR_NONE; | 2722 | return ERR_NONE; |
2720 | } | 2723 | } |
2721 | 2724 | ||
2722 | static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) | 2725 | static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) |
2723 | { | 2726 | { |
2724 | GSM_Error error; | 2727 | GSM_Error error; |
2725 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2728 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2726 | 2729 | ||
2727 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2730 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2728 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2731 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2729 | if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; | 2732 | if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; |
2730 | 2733 | ||
2731 | if (start) Note->Location = 0; | 2734 | if (start) Note->Location = 0; |
2732 | if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; | 2735 | if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; |
2733 | 2736 | ||
2734 | return ALCATEL_GetCalendar(s, Note); | 2737 | return ALCATEL_GetCalendar(s, Note); |
2735 | } | 2738 | } |
2736 | 2739 | ||
2737 | 2740 | ||
2738 | static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2741 | static GSM_Error ALCATEL_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2739 | { | 2742 | { |
2740 | GSM_Error error; | 2743 | GSM_Error error; |
2741 | 2744 | ||
2742 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2745 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2743 | /* Delete Calendar */ | 2746 | /* Delete Calendar */ |
2744 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2747 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2745 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { | 2748 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { |
2746 | /* Entry was empty => no error */ | 2749 | /* Entry was empty => no error */ |
2747 | return ERR_NONE; | 2750 | return ERR_NONE; |
2748 | } | 2751 | } |
2749 | error = ALCATEL_DeleteItem(s, Note->Location); | 2752 | error = ALCATEL_DeleteItem(s, Note->Location); |
2750 | if (error != ERR_NONE) return error; | 2753 | if (error != ERR_NONE) return error; |
2751 | /* Refresh list */ | 2754 | /* Refresh list */ |
2752 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2755 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2753 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2756 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2754 | return ERR_NONE; | 2757 | return ERR_NONE; |
2755 | } | 2758 | } |
2756 | 2759 | ||
2757 | 2760 | ||
2758 | static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2761 | static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2759 | { | 2762 | { |
2760 | GSM_Error error; | 2763 | GSM_Error error; |
2761 | unsigned int val; | 2764 | unsigned int val; |
2762 | bool contact_set = false; | 2765 | bool contact_set = false; |
2763 | bool phone_set = false; | 2766 | bool phone_set = false; |
2764 | bool date_set = false; | 2767 | bool date_set = false; |
2765 | bool repeating = false; | 2768 | bool repeating = false; |
2766 | int i; | 2769 | int i; |
2767 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2770 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2768 | 2771 | ||
2769 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2772 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2770 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error; | 2773 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error; |
2771 | 2774 | ||
2772 | for (i = 0; i < Note->EntriesNum; i++) { | 2775 | for (i = 0; i < Note->EntriesNum; i++) { |
2773 | switch (Note->Entries[i].EntryType) { | 2776 | switch (Note->Entries[i].EntryType) { |
2774 | case CAL_START_DATETIME: | 2777 | case CAL_START_DATETIME: |
2775 | if (!date_set) { | 2778 | if (!date_set) { |
2776 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2779 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2777 | date_set = true; | 2780 | date_set = true; |
2778 | } | 2781 | } |
2779 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2782 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2780 | break; | 2783 | break; |
2781 | case CAL_END_DATETIME: | 2784 | case CAL_END_DATETIME: |
2782 | if (!date_set) { | 2785 | if (!date_set) { |
2783 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2786 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2784 | date_set = true; | 2787 | date_set = true; |
2785 | } | 2788 | } |
2786 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2789 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2787 | break; | 2790 | break; |
2788 | case CAL_ALARM_DATETIME: | 2791 | case CAL_ALARM_DATETIME: |
2789 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2792 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2790 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2793 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2791 | if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) { | 2794 | if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) { |
2792 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2795 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2793 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2796 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2794 | } | 2797 | } |
2795 | break; | 2798 | break; |
2796 | case CAL_TEXT: | 2799 | case CAL_TEXT: |
2797 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 5, Note->Entries[i].Text)) != ERR_NONE) return error; | 2800 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 5, Note->Entries[i].Text)) != ERR_NONE) return error; |
2798 | break; | 2801 | break; |
2799 | case CAL_PRIVATE: | 2802 | case CAL_PRIVATE: |
2800 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2803 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2801 | break; | 2804 | break; |
2802 | case CAL_CONTACTID: | 2805 | case CAL_CONTACTID: |
2803 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2806 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2804 | contact_set = true; | 2807 | contact_set = true; |
2805 | break; | 2808 | break; |
2806 | case CAL_PHONE: | 2809 | case CAL_PHONE: |
2807 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error; | 2810 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error; |
2808 | phone_set = true; | 2811 | phone_set = true; |
2809 | break; | 2812 | break; |
2810 | case CAL_REPEAT_DAYOFWEEK: | 2813 | case CAL_REPEAT_DAYOFWEEK: |
2811 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2814 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2812 | repeating = true; | 2815 | repeating = true; |
2813 | break; | 2816 | break; |
2814 | case CAL_REPEAT_DAY: | 2817 | case CAL_REPEAT_DAY: |
2815 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2818 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2816 | repeating = true; | 2819 | repeating = true; |
2817 | break; | 2820 | break; |
2818 | case CAL_REPEAT_WEEKOFMONTH: | 2821 | case CAL_REPEAT_WEEKOFMONTH: |
2819 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2822 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2820 | repeating = true; | 2823 | repeating = true; |
2821 | break; | 2824 | break; |
2822 | case CAL_REPEAT_MONTH: | 2825 | case CAL_REPEAT_MONTH: |
2823 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2826 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2824 | repeating = true; | 2827 | repeating = true; |
2825 | break; | 2828 | break; |
2826 | case CAL_REPEAT_FREQUENCY: | 2829 | case CAL_REPEAT_FREQUENCY: |
2827 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2830 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2828 | repeating = true; | 2831 | repeating = true; |
2829 | break; | 2832 | break; |
2830 | case CAL_REPEAT_STARTDATE: | 2833 | case CAL_REPEAT_STARTDATE: |
2831 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2834 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2832 | repeating = true; | 2835 | repeating = true; |
2833 | break; | 2836 | break; |
2834 | case CAL_REPEAT_STOPDATE: | 2837 | case CAL_REPEAT_STOPDATE: |
2835 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2838 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2836 | repeating = true; | 2839 | repeating = true; |
2837 | break; | 2840 | break; |
2838 | case CAL_SILENT_ALARM_DATETIME: | 2841 | case CAL_SILENT_ALARM_DATETIME: |
2839 | case CAL_RECURRANCE: | 2842 | case CAL_RECURRANCE: |
2840 | case CAL_LOCATION: | 2843 | case CAL_LOCATION: |
2841 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); | 2844 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); |
2842 | break; | 2845 | break; |
2843 | } | 2846 | } |
2844 | } | 2847 | } |
2845 | 2848 | ||
2846 | switch (Note->Type) { | 2849 | switch (Note->Type) { |
2847 | case GSM_CAL_CALL: | 2850 | case GSM_CAL_CALL: |
2848 | val = 3; | 2851 | val = 3; |
2849 | break; | 2852 | break; |
2850 | case GSM_CAL_BIRTHDAY: | 2853 | case GSM_CAL_BIRTHDAY: |
2851 | val = 2; | 2854 | val = 2; |
2852 | break; | 2855 | break; |
2853 | case GSM_CAL_ALARM: | 2856 | case GSM_CAL_ALARM: |
2854 | val = 4; | 2857 | val = 4; |
2855 | break; | 2858 | break; |
2856 | case GSM_CAL_DAILY_ALARM: | 2859 | case GSM_CAL_DAILY_ALARM: |
2857 | val = 5; | 2860 | val = 5; |
2858 | break; | 2861 | break; |
2859 | default: | 2862 | default: |
2860 | if (repeating) { | 2863 | if (repeating) { |
2861 | val = 9; | 2864 | val = 9; |
2862 | } else { | 2865 | } else { |
2863 | val = 0; | 2866 | val = 0; |
2864 | } | 2867 | } |
2865 | } | 2868 | } |
2866 | if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; | 2869 | if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; |
2867 | 2870 | ||
2868 | if (!contact_set) { | 2871 | if (!contact_set) { |
2869 | if (phone_set) { | 2872 | if (phone_set) { |
2870 | val = 0xffffffff; | 2873 | val = 0xffffffff; |
2871 | } else { | 2874 | } else { |
2872 | val = 0; | 2875 | val = 0; |
2873 | } | 2876 | } |
2874 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error; | 2877 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error; |
2875 | } | 2878 | } |
2876 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2879 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2877 | Note->Location = Priv->CommitedRecord; | 2880 | Note->Location = Priv->CommitedRecord; |
2878 | /* Refresh list */ | 2881 | /* Refresh list */ |
2879 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 2882 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
2880 | return ERR_NONE; | 2883 | return ERR_NONE; |
2881 | } | 2884 | } |
2882 | 2885 | ||
2883 | static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) | 2886 | static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) |
2884 | { | 2887 | { |
2885 | GSM_Error error; | 2888 | GSM_Error error; |
2886 | unsigned int val; | 2889 | unsigned int val; |
2887 | bool contact_set = false; | 2890 | bool contact_set = false; |
2888 | bool phone_set = false; | 2891 | bool phone_set = false; |
2889 | bool date_set = false; | 2892 | bool date_set = false; |
2890 | bool repeating = false; | 2893 | bool repeating = false; |
2891 | int i; | 2894 | int i; |
2892 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 2895 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
2893 | bool UpdatedFields[22]; | 2896 | bool UpdatedFields[22]; |
2894 | 2897 | ||
2895 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 2898 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
2896 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 2899 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
2897 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { | 2900 | if ((error = ALCATEL_IsIdAvailable(s, Note->Location))!= ERR_NONE) { |
2898 | /* Entry doesn't exist, we will create new one */ | 2901 | /* Entry doesn't exist, we will create new one */ |
2899 | return ALCATEL_AddCalendar(s, Note); | 2902 | return ALCATEL_AddCalendar(s, Note); |
2900 | } | 2903 | } |
2901 | /* Get fields for current item */ | 2904 | /* Get fields for current item */ |
2902 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; | 2905 | if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; |
2903 | 2906 | ||
2904 | for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } | 2907 | for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } |
2905 | 2908 | ||
2906 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error; | 2909 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error; |
2907 | 2910 | ||
2908 | for (i = 0; i < Note->EntriesNum; i++) { | 2911 | for (i = 0; i < Note->EntriesNum; i++) { |
2909 | switch (Note->Entries[i].EntryType) { | 2912 | switch (Note->Entries[i].EntryType) { |
2910 | case CAL_START_DATETIME: | 2913 | case CAL_START_DATETIME: |
2911 | if (!date_set) { | 2914 | if (!date_set) { |
2912 | UpdatedFields[0] = true; | 2915 | UpdatedFields[0] = true; |
2913 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2916 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2914 | date_set = true; | 2917 | date_set = true; |
2915 | } | 2918 | } |
2916 | UpdatedFields[1] = true; | 2919 | UpdatedFields[1] = true; |
2917 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2920 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 1, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2918 | break; | 2921 | break; |
2919 | case CAL_END_DATETIME: | 2922 | case CAL_END_DATETIME: |
2920 | if (!date_set) { | 2923 | if (!date_set) { |
2921 | UpdatedFields[0] = true; | 2924 | UpdatedFields[0] = true; |
2922 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2925 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2923 | date_set = true; | 2926 | date_set = true; |
2924 | } | 2927 | } |
2925 | UpdatedFields[2] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2928 | UpdatedFields[2] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 2, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2926 | break; | 2929 | break; |
2927 | case CAL_ALARM_DATETIME: | 2930 | case CAL_ALARM_DATETIME: |
2928 | UpdatedFields[3] = true; | 2931 | UpdatedFields[3] = true; |
2929 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2932 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 3, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2930 | UpdatedFields[4] = true; | 2933 | UpdatedFields[4] = true; |
2931 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2934 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 4, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2932 | if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) { | 2935 | if (Note->Type == GSM_CAL_ALARM || Note->Type == GSM_CAL_DAILY_ALARM) { |
2933 | UpdatedFields[20] = true; | 2936 | UpdatedFields[20] = true; |
2934 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2937 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 20, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2935 | UpdatedFields[21] = true; | 2938 | UpdatedFields[21] = true; |
2936 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2939 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, Note->Location, 21, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2937 | } | 2940 | } |
2938 | break; | 2941 | break; |
2939 | case CAL_TEXT: | 2942 | case CAL_TEXT: |
2940 | UpdatedFields[5] = true; | 2943 | UpdatedFields[5] = true; |
2941 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, Note->Location, 5, Note->Entries[i].Text)) != ERR_NONE) return error; | 2944 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, Note->Location, 5, Note->Entries[i].Text)) != ERR_NONE) return error; |
2942 | break; | 2945 | break; |
2943 | case CAL_PRIVATE: | 2946 | case CAL_PRIVATE: |
2944 | UpdatedFields[6] = true; | 2947 | UpdatedFields[6] = true; |
2945 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, Note->Location, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2948 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, Note->Location, 6, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2946 | break; | 2949 | break; |
2947 | case CAL_CONTACTID: | 2950 | case CAL_CONTACTID: |
2948 | UpdatedFields[8] = true; | 2951 | UpdatedFields[8] = true; |
2949 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2952 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2950 | contact_set = true; | 2953 | contact_set = true; |
2951 | break; | 2954 | break; |
2952 | case CAL_PHONE: | 2955 | case CAL_PHONE: |
2953 | UpdatedFields[9] = true; | 2956 | UpdatedFields[9] = true; |
2954 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error; | 2957 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error; |
2955 | phone_set = true; | 2958 | phone_set = true; |
2956 | break; | 2959 | break; |
2957 | case CAL_REPEAT_DAYOFWEEK: | 2960 | case CAL_REPEAT_DAYOFWEEK: |
2958 | UpdatedFields[10] = true; | 2961 | UpdatedFields[10] = true; |
2959 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2962 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2960 | repeating = true; | 2963 | repeating = true; |
2961 | break; | 2964 | break; |
2962 | case CAL_REPEAT_DAY: | 2965 | case CAL_REPEAT_DAY: |
2963 | UpdatedFields[11] = true; | 2966 | UpdatedFields[11] = true; |
2964 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2967 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 11, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2965 | repeating = true; | 2968 | repeating = true; |
2966 | break; | 2969 | break; |
2967 | case CAL_REPEAT_WEEKOFMONTH: | 2970 | case CAL_REPEAT_WEEKOFMONTH: |
2968 | UpdatedFields[12] = true; | 2971 | UpdatedFields[12] = true; |
2969 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2972 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 12, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2970 | repeating = true; | 2973 | repeating = true; |
2971 | break; | 2974 | break; |
2972 | case CAL_REPEAT_MONTH: | 2975 | case CAL_REPEAT_MONTH: |
2973 | UpdatedFields[13] = true; | 2976 | UpdatedFields[13] = true; |
2974 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2977 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 13, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2975 | repeating = true; | 2978 | repeating = true; |
2976 | break; | 2979 | break; |
2977 | case CAL_REPEAT_FREQUENCY: | 2980 | case CAL_REPEAT_FREQUENCY: |
2978 | UpdatedFields[17] = true; | 2981 | UpdatedFields[17] = true; |
2979 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error; | 2982 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 17, &(Note->Entries[i].Number))) != ERR_NONE) return error; |
2980 | repeating = true; | 2983 | repeating = true; |
2981 | break; | 2984 | break; |
2982 | case CAL_REPEAT_STARTDATE: | 2985 | case CAL_REPEAT_STARTDATE: |
2983 | UpdatedFields[18] = true; | 2986 | UpdatedFields[18] = true; |
2984 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2987 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 18, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2985 | repeating = true; | 2988 | repeating = true; |
2986 | break; | 2989 | break; |
2987 | case CAL_REPEAT_STOPDATE: | 2990 | case CAL_REPEAT_STOPDATE: |
2988 | UpdatedFields[19] = true; | 2991 | UpdatedFields[19] = true; |
2989 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; | 2992 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 19, &(Note->Entries[i].Date))) != ERR_NONE) return error; |
2990 | repeating = true; | 2993 | repeating = true; |
2991 | break; | 2994 | break; |
2992 | case CAL_SILENT_ALARM_DATETIME: | 2995 | case CAL_SILENT_ALARM_DATETIME: |
2993 | case CAL_RECURRANCE: | 2996 | case CAL_RECURRANCE: |
2994 | case CAL_LOCATION: | 2997 | case CAL_LOCATION: |
2995 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); | 2998 | smprintf(s,"WARNING: Ignoring entry %d, not supported by phone\n", Note->Entries[i].EntryType); |
2996 | break; | 2999 | break; |
2997 | } | 3000 | } |
2998 | } | 3001 | } |
2999 | 3002 | ||
3000 | switch (Note->Type) { | 3003 | switch (Note->Type) { |
3001 | case GSM_CAL_CALL: | 3004 | case GSM_CAL_CALL: |
3002 | val = 3; | 3005 | val = 3; |
3003 | break; | 3006 | break; |
3004 | case GSM_CAL_BIRTHDAY: | 3007 | case GSM_CAL_BIRTHDAY: |
3005 | val = 2; | 3008 | val = 2; |
3006 | break; | 3009 | break; |
3007 | case GSM_CAL_ALARM: | 3010 | case GSM_CAL_ALARM: |
3008 | val = 4; | 3011 | val = 4; |
3009 | break; | 3012 | break; |
3010 | case GSM_CAL_DAILY_ALARM: | 3013 | case GSM_CAL_DAILY_ALARM: |
3011 | val = 5; | 3014 | val = 5; |
3012 | break; | 3015 | break; |
3013 | default: | 3016 | default: |
3014 | if (repeating) { | 3017 | if (repeating) { |
3015 | val = 9; | 3018 | val = 9; |
3016 | } else { | 3019 | } else { |
3017 | val = 0; | 3020 | val = 0; |
3018 | } | 3021 | } |
3019 | } | 3022 | } |
3020 | UpdatedFields[7] = true; | 3023 | UpdatedFields[7] = true; |
3021 | if ((error = ALCATEL_UpdateField(s, Alcatel_enum, Note->Location, 7, &val)) != ERR_NONE) return error; | 3024 | if ((error = ALCATEL_UpdateField(s, Alcatel_enum, Note->Location, 7, &val)) != ERR_NONE) return error; |
3022 | 3025 | ||
3023 | if (!contact_set) { | 3026 | if (!contact_set) { |
3024 | if (phone_set) { | 3027 | if (phone_set) { |
3025 | val = 0xffffffff; | 3028 | val = 0xffffffff; |
3026 | } else { | 3029 | } else { |
3027 | val = 0; | 3030 | val = 0; |
3028 | } | 3031 | } |
3029 | UpdatedFields[8] = true; | 3032 | UpdatedFields[8] = true; |
3030 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &val)) != ERR_NONE) return error; | 3033 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, Note->Location, 8, &val)) != ERR_NONE) return error; |
3031 | } | 3034 | } |
3032 | /* If we didn't update some field, we have to delete it... */ | 3035 | /* If we didn't update some field, we have to delete it... */ |
3033 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 3036 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
3034 | if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, Note->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; | 3037 | if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, Note->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; |
3035 | } | 3038 | } |
3036 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 3039 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
3037 | return ERR_NONE; | 3040 | return ERR_NONE; |
3038 | } | 3041 | } |
3039 | 3042 | ||
3040 | static GSM_Error ALCATEL_DeleteAllCalendar (GSM_StateMachine *s) | 3043 | static GSM_Error ALCATEL_DeleteAllCalendar (GSM_StateMachine *s) |
3041 | { | 3044 | { |
3042 | GSM_Error error; | 3045 | GSM_Error error; |
3043 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3046 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3044 | int i; | 3047 | int i; |
3045 | 3048 | ||
3046 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 3049 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
3047 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3050 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3048 | 3051 | ||
3049 | for (i=0; i<Priv->CalendarItemsCount; i++) { | 3052 | for (i=0; i<Priv->CalendarItemsCount; i++) { |
3050 | error = ALCATEL_DeleteItem(s, Priv->CalendarItems[i]); | 3053 | error = ALCATEL_DeleteItem(s, Priv->CalendarItems[i]); |
3051 | if (error != ERR_NONE) return error; | 3054 | if (error != ERR_NONE) return error; |
3052 | } | 3055 | } |
3053 | 3056 | ||
3054 | /* Refresh list */ | 3057 | /* Refresh list */ |
3055 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 3058 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
3056 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3059 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3057 | 3060 | ||
3058 | return ERR_NONE; | 3061 | return ERR_NONE; |
3059 | } | 3062 | } |
3060 | 3063 | ||
3061 | 3064 | ||
3062 | static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) | 3065 | static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) |
3063 | { | 3066 | { |
3064 | GSM_Error error; | 3067 | GSM_Error error; |
3065 | GSM_CalendarEntryNote; | 3068 | GSM_CalendarEntryNote; |
3066 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3069 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3067 | int i; | 3070 | int i; |
3068 | bool Found = false; | 3071 | bool Found = false; |
3069 | bool DateSet = false; | 3072 | bool DateSet = false; |
3070 | int alarm_number = alarm->Location; | 3073 | int alarm_number = alarm->Location; |
3071 | static GSM_DateTimenulldt = {0,0,0,0,0,0,0}; | 3074 | static GSM_DateTimenulldt = {0,0,0,0,0,0,0}; |
3072 | 3075 | ||
3073 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 3076 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
3074 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3077 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3075 | 3078 | ||
3076 | for (i=0; i<Priv->CalendarItemsCount; i++) { | 3079 | for (i=0; i<Priv->CalendarItemsCount; i++) { |
3077 | if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; | 3080 | if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; |
3078 | if (Priv->ReturnType != Alcatel_enum) { | 3081 | if (Priv->ReturnType != Alcatel_enum) { |
3079 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3082 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3080 | continue; | 3083 | continue; |
3081 | } | 3084 | } |
3082 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { | 3085 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { |
3083 | alarm_number--; | 3086 | alarm_number--; |
3084 | if (alarm_number == 0) { | 3087 | if (alarm_number == 0) { |
3085 | Found = true; | 3088 | Found = true; |
3086 | break; | 3089 | break; |
3087 | } | 3090 | } |
3088 | } | 3091 | } |
3089 | } | 3092 | } |
3090 | 3093 | ||
3091 | if (!Found) return ERR_EMPTY; | 3094 | if (!Found) return ERR_EMPTY; |
3092 | 3095 | ||
3093 | Note.Location = Priv->CalendarItems[i]; | 3096 | Note.Location = Priv->CalendarItems[i]; |
3094 | 3097 | ||
3095 | if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; | 3098 | if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; |
3096 | 3099 | ||
3097 | if (Note.Type == GSM_CAL_ALARM) { | 3100 | if (Note.Type == GSM_CAL_ALARM) { |
3098 | alarm->Repeating = false; | 3101 | alarm->Repeating = false; |
3099 | } else { | 3102 | } else { |
3100 | alarm->Repeating = true; | 3103 | alarm->Repeating = true; |
3101 | } | 3104 | } |
3102 | 3105 | ||
3103 | alarm->Text[0] = 0; alarm->Text[1] = 0; | 3106 | alarm->Text[0] = 0; alarm->Text[1] = 0; |
3104 | 3107 | ||
3105 | 3108 | ||
3106 | for (i = 0; i < Note.EntriesNum; i++) { | 3109 | for (i = 0; i < Note.EntriesNum; i++) { |
3107 | if (Note.Entries[i].EntryType == CAL_TEXT) { | 3110 | if (Note.Entries[i].EntryType == CAL_TEXT) { |
3108 | CopyUnicodeString(alarm->Text, Note.Entries[i].Text); | 3111 | CopyUnicodeString(alarm->Text, Note.Entries[i].Text); |
3109 | } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) { | 3112 | } else if (Note.Entries[i].EntryType == CAL_ALARM_DATETIME) { |
3110 | alarm->DateTime = Note.Entries[i].Date; | 3113 | alarm->DateTime = Note.Entries[i].Date; |
3111 | DateSet = false; | 3114 | DateSet = false; |
3112 | } | 3115 | } |
3113 | } | 3116 | } |
3114 | if (!DateSet) { | 3117 | if (!DateSet) { |
3115 | alarm->DateTime = nulldt; | 3118 | alarm->DateTime = nulldt; |
3116 | } | 3119 | } |
3117 | 3120 | ||
3118 | return ERR_NONE; | 3121 | return ERR_NONE; |
3119 | } | 3122 | } |
3120 | 3123 | ||
3121 | 3124 | ||
3122 | static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm) | 3125 | static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm) |
3123 | { | 3126 | { |
3124 | GSM_Error error; | 3127 | GSM_Error error; |
3125 | GSM_CalendarEntryNote; | 3128 | GSM_CalendarEntryNote; |
3126 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3129 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3127 | GSM_DateTime dt; | 3130 | GSM_DateTime dt; |
3128 | int i; | 3131 | int i; |
3129 | bool Found = false; | 3132 | bool Found = false; |
3130 | int alarm_number = alarm->Location; | 3133 | int alarm_number = alarm->Location; |
3131 | 3134 | ||
3132 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; | 3135 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; |
3133 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3136 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3134 | 3137 | ||
3135 | for (i=0; i<Priv->CalendarItemsCount; i++) { | 3138 | for (i=0; i<Priv->CalendarItemsCount; i++) { |
3136 | if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; | 3139 | if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; |
3137 | if (Priv->ReturnType != Alcatel_enum) { | 3140 | if (Priv->ReturnType != Alcatel_enum) { |
3138 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3141 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3139 | continue; | 3142 | continue; |
3140 | } | 3143 | } |
3141 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { | 3144 | if (Priv->ReturnInt == 4 || Priv->ReturnInt == 5) { |
3142 | alarm_number--; | 3145 | alarm_number--; |
3143 | if (alarm_number == 0) { | 3146 | if (alarm_number == 0) { |
3144 | Found = true; | 3147 | Found = true; |
3145 | break; | 3148 | break; |
3146 | } | 3149 | } |
3147 | } | 3150 | } |
3148 | } | 3151 | } |
3149 | 3152 | ||
3150 | if (Found) { | 3153 | if (Found) { |
3151 | Note.Location = Priv->CalendarItems[i]; | 3154 | Note.Location = Priv->CalendarItems[i]; |
3152 | } | 3155 | } |
3153 | 3156 | ||
3154 | Note.EntriesNum = 1; | 3157 | Note.EntriesNum = 1; |
3155 | 3158 | ||
3156 | Note.Entries[0].EntryType = CAL_ALARM_DATETIME; | 3159 | Note.Entries[0].EntryType = CAL_ALARM_DATETIME; |
3157 | Note.Entries[0].Date = alarm->DateTime; | 3160 | Note.Entries[0].Date = alarm->DateTime; |
3158 | 3161 | ||
3159 | if (alarm->Repeating) { | 3162 | if (alarm->Repeating) { |
3160 | Note.Type = GSM_CAL_DAILY_ALARM; | 3163 | Note.Type = GSM_CAL_DAILY_ALARM; |
3161 | GSM_GetCurrentDateTime(&dt); | 3164 | GSM_GetCurrentDateTime(&dt); |
3162 | Note.Entries[0].Date.Day = dt.Day; | 3165 | Note.Entries[0].Date.Day = dt.Day; |
3163 | Note.Entries[0].Date.Month = dt.Month; | 3166 | Note.Entries[0].Date.Month = dt.Month; |
3164 | Note.Entries[0].Date.Year = dt.Year; | 3167 | Note.Entries[0].Date.Year = dt.Year; |
3165 | } else { | 3168 | } else { |
3166 | Note.Type = GSM_CAL_ALARM; | 3169 | Note.Type = GSM_CAL_ALARM; |
3167 | } | 3170 | } |
3168 | 3171 | ||
3169 | if (alarm->Text[0] != 0 || alarm->Text[1] != 0) { | 3172 | if (alarm->Text[0] != 0 || alarm->Text[1] != 0) { |
3170 | Note.EntriesNum++; | 3173 | Note.EntriesNum++; |
3171 | Note.Entries[1].EntryType = CAL_TEXT; | 3174 | Note.Entries[1].EntryType = CAL_TEXT; |
3172 | CopyUnicodeString(Note.Entries[1].Text, alarm->Text); | 3175 | CopyUnicodeString(Note.Entries[1].Text, alarm->Text); |
3173 | } | 3176 | } |
3174 | 3177 | ||
3175 | if (Found) { | 3178 | if (Found) { |
3176 | return ALCATEL_SetCalendar(s, &Note); | 3179 | return ALCATEL_SetCalendar(s, &Note); |
3177 | } else { | 3180 | } else { |
3178 | return ALCATEL_AddCalendar(s, &Note); | 3181 | return ALCATEL_AddCalendar(s, &Note); |
3179 | } | 3182 | } |
3180 | } | 3183 | } |
3181 | 3184 | ||
3182 | 3185 | ||
3183 | static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) | 3186 | static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) |
3184 | { | 3187 | { |
3185 | GSM_Error error; | 3188 | GSM_Error error; |
3186 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3189 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3187 | 3190 | ||
3188 | status->Used = 0; | 3191 | status->Used = 0; |
3189 | 3192 | ||
3190 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3193 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3191 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3194 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3192 | 3195 | ||
3193 | status->Used = Priv->ToDoItemsCount; | 3196 | status->Used = Priv->ToDoItemsCount; |
3194 | return ERR_NONE; | 3197 | return ERR_NONE; |
3195 | } | 3198 | } |
3196 | 3199 | ||
3197 | static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3200 | static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3198 | { | 3201 | { |
3199 | GSM_Error error; | 3202 | GSM_Error error; |
3200 | GSM_DateTime *dt = NULL; | 3203 | GSM_DateTime *dt = NULL; |
3201 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3204 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3202 | int i; | 3205 | int i; |
3203 | int j=0; | 3206 | int j=0; |
3204 | 3207 | ||
3205 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3208 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3206 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3209 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3207 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { | 3210 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { |
3208 | ToDo->EntriesNum = 0; | 3211 | ToDo->EntriesNum = 0; |
3209 | return error; | 3212 | return error; |
3210 | } | 3213 | } |
3211 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; | 3214 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; |
3212 | 3215 | ||
3213 | ToDo->EntriesNum = Priv->CurrentFieldsCount; | 3216 | ToDo->EntriesNum = Priv->CurrentFieldsCount; |
3214 | 3217 | ||
3215 | for (i=0; i < Priv->CurrentFieldsCount; i++) { | 3218 | for (i=0; i < Priv->CurrentFieldsCount; i++) { |
3216 | if ((error = ALCATEL_GetFieldValue(s, ToDo->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; | 3219 | if ((error = ALCATEL_GetFieldValue(s, ToDo->Location, Priv->CurrentFields[i]))!= ERR_NONE) return error; |
3217 | switch (Priv->CurrentFields[i]) { | 3220 | switch (Priv->CurrentFields[i]) { |
3218 | case 0: | 3221 | case 0: |
3219 | if (Priv->ReturnType != Alcatel_date) { | 3222 | if (Priv->ReturnType != Alcatel_date) { |
3220 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3223 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3221 | ToDo->EntriesNum--; | 3224 | ToDo->EntriesNum--; |
3222 | j++; | 3225 | j++; |
3223 | break; | 3226 | break; |
3224 | } | 3227 | } |
3225 | if (!CheckDate(&(Priv->ReturnDateTime))) { | 3228 | if (!CheckDate(&(Priv->ReturnDateTime))) { |
3226 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); | 3229 | smprintf(s,"WARNING: Invalid date in phone, ignoring\n"); |
3227 | ToDo->EntriesNum--; | 3230 | ToDo->EntriesNum--; |
3228 | j++; | 3231 | j++; |
3229 | break; | 3232 | break; |
3230 | } | 3233 | } |
3231 | ToDo->Entries[i-j].EntryType = TODO_END_DATETIME; | 3234 | ToDo->Entries[i-j].EntryType = TODO_END_DATETIME; |
3232 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; | 3235 | ToDo->Entries[i-j].Date = Priv->ReturnDateTime; |
3233 | break; | 3236 | break; |
3234 | case 1: | 3237 | case 1: |
3235 | if (Priv->ReturnType != Alcatel_bool) { | 3238 | if (Priv->ReturnType != Alcatel_bool) { |
3236 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); | 3239 | smprintf(s,"WARNING: Received unexpected type %02X, ignoring\n", Priv->ReturnType); |
3237 | ToDo->EntriesNum--; | 3240 | ToDo->EntriesNum--; |
@@ -3406,289 +3409,289 @@ static GSM_Error ALCATEL_GetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | |||
3406 | break; | 3409 | break; |
3407 | } | 3410 | } |
3408 | if (!CheckTime(&(Priv->ReturnDateTime))) { | 3411 | if (!CheckTime(&(Priv->ReturnDateTime))) { |
3409 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); | 3412 | smprintf(s,"WARNING: Invalid time in phone, ignoring\n"); |
3410 | ToDo->EntriesNum--; | 3413 | ToDo->EntriesNum--; |
3411 | j++; | 3414 | j++; |
3412 | break; | 3415 | break; |
3413 | } | 3416 | } |
3414 | /* This entry had always same value as the 3rd (alarm time) */ | 3417 | /* This entry had always same value as the 3rd (alarm time) */ |
3415 | j++; | 3418 | j++; |
3416 | ToDo->EntriesNum--; | 3419 | ToDo->EntriesNum--; |
3417 | break; | 3420 | break; |
3418 | default: | 3421 | default: |
3419 | ToDo->EntriesNum--; | 3422 | ToDo->EntriesNum--; |
3420 | j++; | 3423 | j++; |
3421 | smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); | 3424 | smprintf(s,"WARNING: Received unknown field %02X, ignoring. Type = %02X. Value = ", Priv->CurrentFields[i], Priv->ReturnType); |
3422 | switch (Priv->ReturnType) { | 3425 | switch (Priv->ReturnType) { |
3423 | case Alcatel_date: | 3426 | case Alcatel_date: |
3424 | smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); | 3427 | smprintf(s, "%d.%d.%d", Priv->ReturnDateTime.Day, Priv->ReturnDateTime.Month, Priv->ReturnDateTime.Year); |
3425 | break; | 3428 | break; |
3426 | case Alcatel_time: | 3429 | case Alcatel_time: |
3427 | smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); | 3430 | smprintf(s, "%d:%d:%d", Priv->ReturnDateTime.Hour, Priv->ReturnDateTime.Minute, Priv->ReturnDateTime.Second); |
3428 | break; | 3431 | break; |
3429 | case Alcatel_string: | 3432 | case Alcatel_string: |
3430 | case Alcatel_phone: | 3433 | case Alcatel_phone: |
3431 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); | 3434 | smprintf(s, "\"%s\"",DecodeUnicodeString(Priv->ReturnString)); |
3432 | break; | 3435 | break; |
3433 | case Alcatel_enum: | 3436 | case Alcatel_enum: |
3434 | case Alcatel_bool: | 3437 | case Alcatel_bool: |
3435 | case Alcatel_int: | 3438 | case Alcatel_int: |
3436 | case Alcatel_byte: | 3439 | case Alcatel_byte: |
3437 | smprintf(s, "%d", Priv->ReturnInt); | 3440 | smprintf(s, "%d", Priv->ReturnInt); |
3438 | break; | 3441 | break; |
3439 | } | 3442 | } |
3440 | smprintf(s,"\n"); | 3443 | smprintf(s,"\n"); |
3441 | } | 3444 | } |
3442 | } | 3445 | } |
3443 | return ERR_NONE; | 3446 | return ERR_NONE; |
3444 | } | 3447 | } |
3445 | 3448 | ||
3446 | static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) | 3449 | static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) |
3447 | { | 3450 | { |
3448 | GSM_Error error; | 3451 | GSM_Error error; |
3449 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3452 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3450 | 3453 | ||
3451 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3454 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3452 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3455 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3453 | if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; | 3456 | if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; |
3454 | 3457 | ||
3455 | if (start) ToDo->Location = 0; | 3458 | if (start) ToDo->Location = 0; |
3456 | if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; | 3459 | if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; |
3457 | 3460 | ||
3458 | return ALCATEL_GetToDo(s, ToDo); | 3461 | return ALCATEL_GetToDo(s, ToDo); |
3459 | } | 3462 | } |
3460 | 3463 | ||
3461 | static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s) | 3464 | static GSM_Error ALCATEL_DeleteAllToDo (GSM_StateMachine *s) |
3462 | { | 3465 | { |
3463 | GSM_Error error; | 3466 | GSM_Error error; |
3464 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3467 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3465 | int i; | 3468 | int i; |
3466 | 3469 | ||
3467 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3470 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3468 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3471 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3469 | 3472 | ||
3470 | for (i=0; i<Priv->ToDoItemsCount; i++) { | 3473 | for (i=0; i<Priv->ToDoItemsCount; i++) { |
3471 | error = ALCATEL_DeleteItem(s, Priv->ToDoItems[i]); | 3474 | error = ALCATEL_DeleteItem(s, Priv->ToDoItems[i]); |
3472 | if (error != ERR_NONE) return error; | 3475 | if (error != ERR_NONE) return error; |
3473 | } | 3476 | } |
3474 | 3477 | ||
3475 | /* Refresh list */ | 3478 | /* Refresh list */ |
3476 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3479 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3477 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3480 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3478 | 3481 | ||
3479 | return ERR_NONE; | 3482 | return ERR_NONE; |
3480 | } | 3483 | } |
3481 | 3484 | ||
3482 | static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3485 | static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3483 | { | 3486 | { |
3484 | GSM_Error error; | 3487 | GSM_Error error; |
3485 | unsigned int val; | 3488 | unsigned int val; |
3486 | bool contact_set = false; | 3489 | bool contact_set = false; |
3487 | bool phone_set = false; | 3490 | bool phone_set = false; |
3488 | int i; | 3491 | int i; |
3489 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3492 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3490 | 3493 | ||
3491 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3494 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3492 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error; | 3495 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error; |
3493 | 3496 | ||
3494 | switch (ToDo->Priority) { | 3497 | switch (ToDo->Priority) { |
3495 | case GSM_Priority_High: | 3498 | case GSM_Priority_High: |
3496 | val = 0; | 3499 | val = 0; |
3497 | break; | 3500 | break; |
3498 | case GSM_Priority_Low: | 3501 | case GSM_Priority_Low: |
3499 | val = 2; | 3502 | val = 2; |
3500 | break; | 3503 | break; |
3501 | case GSM_Priority_Medium: | 3504 | case GSM_Priority_Medium: |
3502 | default: | 3505 | default: |
3503 | val = 1; | 3506 | val = 1; |
3504 | break; | 3507 | break; |
3505 | } | 3508 | } |
3506 | /* This one seems to be byte for BF5 and enum for BE5 */ | 3509 | /* This one seems to be byte for BF5 and enum for BE5 */ |
3507 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 3510 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
3508 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 7, &val)) != ERR_NONE) return error; | 3511 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 7, &val)) != ERR_NONE) return error; |
3509 | } else { | 3512 | } else { |
3510 | if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; | 3513 | if ((error = ALCATEL_CreateField(s, Alcatel_enum, 7, &val)) != ERR_NONE) return error; |
3511 | } | 3514 | } |
3512 | 3515 | ||
3513 | for (i = 0; i < ToDo->EntriesNum; i++) { | 3516 | for (i = 0; i < ToDo->EntriesNum; i++) { |
3514 | switch (ToDo->Entries[i].EntryType) { | 3517 | switch (ToDo->Entries[i].EntryType) { |
3515 | case TODO_END_DATETIME: | 3518 | case TODO_END_DATETIME: |
3516 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3519 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3517 | break; | 3520 | break; |
3518 | case TODO_COMPLETED: | 3521 | case TODO_COMPLETED: |
3519 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3522 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3520 | break; | 3523 | break; |
3521 | case TODO_ALARM_DATETIME: | 3524 | case TODO_ALARM_DATETIME: |
3522 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3525 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3523 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3526 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3524 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3527 | if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3525 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3528 | if ((error = ALCATEL_CreateField(s, Alcatel_time, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3526 | break; | 3529 | break; |
3527 | case TODO_TEXT: | 3530 | case TODO_TEXT: |
3528 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; | 3531 | if ((error = ALCATEL_CreateField(s, Alcatel_string, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; |
3529 | break; | 3532 | break; |
3530 | case TODO_PRIVATE: | 3533 | case TODO_PRIVATE: |
3531 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3534 | if ((error = ALCATEL_CreateField(s, Alcatel_bool, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3532 | break; | 3535 | break; |
3533 | case TODO_CATEGORY: | 3536 | case TODO_CATEGORY: |
3534 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3537 | if ((error = ALCATEL_CreateField(s, Alcatel_byte, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3535 | break; | 3538 | break; |
3536 | case TODO_CONTACTID: | 3539 | case TODO_CONTACTID: |
3537 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3540 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3538 | contact_set = true; | 3541 | contact_set = true; |
3539 | break; | 3542 | break; |
3540 | case TODO_PHONE: | 3543 | case TODO_PHONE: |
3541 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; | 3544 | if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; |
3542 | phone_set = true; | 3545 | phone_set = true; |
3543 | break; | 3546 | break; |
3544 | default: | 3547 | default: |
3545 | break; | 3548 | break; |
3546 | } | 3549 | } |
3547 | } | 3550 | } |
3548 | if (!contact_set) { | 3551 | if (!contact_set) { |
3549 | if (phone_set) { | 3552 | if (phone_set) { |
3550 | val = 0xffffffff; | 3553 | val = 0xffffffff; |
3551 | } else { | 3554 | } else { |
3552 | val = 0; | 3555 | val = 0; |
3553 | } | 3556 | } |
3554 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error; | 3557 | if ((error = ALCATEL_CreateField(s, Alcatel_int, 8, &val)) != ERR_NONE) return error; |
3555 | } | 3558 | } |
3556 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3559 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3557 | ToDo->Location = Priv->CommitedRecord; | 3560 | ToDo->Location = Priv->CommitedRecord; |
3558 | /* Refresh list */ | 3561 | /* Refresh list */ |
3559 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3562 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3560 | return ERR_NONE; | 3563 | return ERR_NONE; |
3561 | } | 3564 | } |
3562 | 3565 | ||
3563 | static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3566 | static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3564 | { | 3567 | { |
3565 | GSM_Error error; | 3568 | GSM_Error error; |
3566 | unsigned int val; | 3569 | unsigned int val; |
3567 | bool contact_set = false; | 3570 | bool contact_set = false; |
3568 | bool phone_set = false; | 3571 | bool phone_set = false; |
3569 | bool UpdatedFields[12]; | 3572 | bool UpdatedFields[12]; |
3570 | int i; | 3573 | int i; |
3571 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; | 3574 | GSM_Phone_ALCATELData*Priv = &s->Phone.Data.Priv.ALCATEL; |
3572 | 3575 | ||
3573 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3576 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3574 | /* Save modified ToDo */ | 3577 | /* Save modified ToDo */ |
3575 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3578 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3576 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { | 3579 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { |
3577 | /* Entry doesn't exist, we will create new one */ | 3580 | /* Entry doesn't exist, we will create new one */ |
3578 | return ALCATEL_AddToDo(s, ToDo); | 3581 | return ALCATEL_AddToDo(s, ToDo); |
3579 | } | 3582 | } |
3580 | /* Get fields for current item */ | 3583 | /* Get fields for current item */ |
3581 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; | 3584 | if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; |
3582 | 3585 | ||
3583 | for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } | 3586 | for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } |
3584 | 3587 | ||
3585 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error; | 3588 | if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error; |
3586 | 3589 | ||
3587 | switch (ToDo->Priority) { | 3590 | switch (ToDo->Priority) { |
3588 | case GSM_Priority_High: | 3591 | case GSM_Priority_High: |
3589 | val = 0; | 3592 | val = 0; |
3590 | break; | 3593 | break; |
3591 | case GSM_Priority_Low: | 3594 | case GSM_Priority_Low: |
3592 | val = 2; | 3595 | val = 2; |
3593 | break; | 3596 | break; |
3594 | case GSM_Priority_Medium: | 3597 | case GSM_Priority_Medium: |
3595 | default: | 3598 | default: |
3596 | val = 1; | 3599 | val = 1; |
3597 | break; | 3600 | break; |
3598 | } | 3601 | } |
3599 | /* This one seems to be byte for BF5 and enum for BE5 */ | 3602 | /* This one seems to be byte for BF5 and enum for BE5 */ |
3600 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { | 3603 | if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { |
3601 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error; | 3604 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 7, &val)) != ERR_NONE) return error; |
3602 | } else { | 3605 | } else { |
3603 | if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error; | 3606 | if ((error = ALCATEL_UpdateField(s, Alcatel_enum, ToDo->Location, 7, &val)) != ERR_NONE) return error; |
3604 | } | 3607 | } |
3605 | UpdatedFields[7] = true; | 3608 | UpdatedFields[7] = true; |
3606 | 3609 | ||
3607 | for (i = 0; i < ToDo->EntriesNum; i++) { | 3610 | for (i = 0; i < ToDo->EntriesNum; i++) { |
3608 | switch (ToDo->Entries[i].EntryType) { | 3611 | switch (ToDo->Entries[i].EntryType) { |
3609 | case TODO_END_DATETIME: | 3612 | case TODO_END_DATETIME: |
3610 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3613 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3611 | UpdatedFields[0] = true; | 3614 | UpdatedFields[0] = true; |
3612 | break; | 3615 | break; |
3613 | case TODO_COMPLETED: | 3616 | case TODO_COMPLETED: |
3614 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3617 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3615 | UpdatedFields[1] = true; | 3618 | UpdatedFields[1] = true; |
3616 | break; | 3619 | break; |
3617 | case TODO_ALARM_DATETIME: | 3620 | case TODO_ALARM_DATETIME: |
3618 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3621 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3619 | UpdatedFields[2] = true; | 3622 | UpdatedFields[2] = true; |
3620 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3623 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3621 | UpdatedFields[3] = true; | 3624 | UpdatedFields[3] = true; |
3622 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3625 | if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3623 | UpdatedFields[10] = true; | 3626 | UpdatedFields[10] = true; |
3624 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; | 3627 | if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; |
3625 | UpdatedFields[11] = true; | 3628 | UpdatedFields[11] = true; |
3626 | break; | 3629 | break; |
3627 | case TODO_TEXT: | 3630 | case TODO_TEXT: |
3628 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; | 3631 | if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; |
3629 | UpdatedFields[4] = true; | 3632 | UpdatedFields[4] = true; |
3630 | break; | 3633 | break; |
3631 | case TODO_PRIVATE: | 3634 | case TODO_PRIVATE: |
3632 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3635 | if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3633 | UpdatedFields[5] = true; | 3636 | UpdatedFields[5] = true; |
3634 | break; | 3637 | break; |
3635 | case TODO_CATEGORY: | 3638 | case TODO_CATEGORY: |
3636 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3639 | if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3637 | UpdatedFields[6] = true; | 3640 | UpdatedFields[6] = true; |
3638 | break; | 3641 | break; |
3639 | case TODO_CONTACTID: | 3642 | case TODO_CONTACTID: |
3640 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; | 3643 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; |
3641 | UpdatedFields[8] = true; | 3644 | UpdatedFields[8] = true; |
3642 | contact_set = true; | 3645 | contact_set = true; |
3643 | break; | 3646 | break; |
3644 | case TODO_PHONE: | 3647 | case TODO_PHONE: |
3645 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; | 3648 | if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; |
3646 | UpdatedFields[9] = true; | 3649 | UpdatedFields[9] = true; |
3647 | phone_set = true; | 3650 | phone_set = true; |
3648 | break; | 3651 | break; |
3649 | default: | 3652 | default: |
3650 | break; | 3653 | break; |
3651 | } | 3654 | } |
3652 | } | 3655 | } |
3653 | if (!contact_set) { | 3656 | if (!contact_set) { |
3654 | if (phone_set) { | 3657 | if (phone_set) { |
3655 | val = 0xffffffff; | 3658 | val = 0xffffffff; |
3656 | } else { | 3659 | } else { |
3657 | val = 0; | 3660 | val = 0; |
3658 | } | 3661 | } |
3659 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &val)) != ERR_NONE) return error; | 3662 | if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &val)) != ERR_NONE) return error; |
3660 | UpdatedFields[8] = true; | 3663 | UpdatedFields[8] = true; |
3661 | } | 3664 | } |
3662 | 3665 | ||
3663 | 3666 | ||
3664 | /* If we didn't update some field, we have to delete it... */ | 3667 | /* If we didn't update some field, we have to delete it... */ |
3665 | for (i=0; i<Priv->CurrentFieldsCount; i++) { | 3668 | for (i=0; i<Priv->CurrentFieldsCount; i++) { |
3666 | if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, ToDo->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; | 3669 | if (!UpdatedFields[Priv->CurrentFields[i]]) if ((error = ALCATEL_DeleteField(s, ToDo->Location, Priv->CurrentFields[i])) != ERR_NONE) return error; |
3667 | } | 3670 | } |
3668 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3671 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3669 | return ERR_NONE; | 3672 | return ERR_NONE; |
3670 | } | 3673 | } |
3671 | 3674 | ||
3672 | static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) | 3675 | static GSM_Error ALCATEL_DeleteToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) |
3673 | { | 3676 | { |
3674 | GSM_Error error; | 3677 | GSM_Error error; |
3675 | 3678 | ||
3676 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3679 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3677 | /* Delete ToDo */ | 3680 | /* Delete ToDo */ |
3678 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; | 3681 | if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; |
3679 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { | 3682 | if ((error = ALCATEL_IsIdAvailable(s, ToDo->Location))!= ERR_NONE) { |
3680 | /* Entry was empty => no error */ | 3683 | /* Entry was empty => no error */ |
3681 | return ERR_NONE; | 3684 | return ERR_NONE; |
3682 | } | 3685 | } |
3683 | error = ALCATEL_DeleteItem(s, ToDo->Location); | 3686 | error = ALCATEL_DeleteItem(s, ToDo->Location); |
3684 | if (error != ERR_NONE) return error; | 3687 | if (error != ERR_NONE) return error; |
3685 | /* Refresh list */ | 3688 | /* Refresh list */ |
3686 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; | 3689 | if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; |
3687 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; | 3690 | if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; |
3688 | return ERR_NONE; | 3691 | return ERR_NONE; |
3689 | } | 3692 | } |
3690 | 3693 | ||
3691 | static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status) | 3694 | static GSM_Error ALCATEL_GetCategoryStatus(GSM_StateMachine *s, GSM_CategoryStatus *Status) |
3692 | { | 3695 | { |
3693 | GSM_Alcatel_BinaryTypetype; | 3696 | GSM_Alcatel_BinaryTypetype; |
3694 | GSM_Error error; | 3697 | GSM_Error error; |
@@ -3777,215 +3780,224 @@ static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine | |||
3777 | *- phone needs PIN code | 3780 | *- phone needs PIN code |
3778 | *- we want to close not opened session | 3781 | *- we want to close not opened session |
3779 | * For normal users the second case shouldn't occur... | 3782 | * For normal users the second case shouldn't occur... |
3780 | */ | 3783 | */ |
3781 | return ERR_SECURITYERROR; | 3784 | return ERR_SECURITYERROR; |
3782 | case 0x14: /* Bad data */ | 3785 | case 0x14: /* Bad data */ |
3783 | case 0x2f: /* Closing session when not opened */ | 3786 | case 0x2f: /* Closing session when not opened */ |
3784 | case 0x1f: /* Bad in/out counter in packet/ack */ | 3787 | case 0x1f: /* Bad in/out counter in packet/ack */ |
3785 | case 0x0e: /* Openning session when not closed */ | 3788 | case 0x0e: /* Openning session when not closed */ |
3786 | case 0x0C: /* Bad id (item/database) */ | 3789 | case 0x0C: /* Bad id (item/database) */ |
3787 | case 0x11: /* Bad list id */ | 3790 | case 0x11: /* Bad list id */ |
3788 | case 0x2A: /* Nonexistant field/item id */ | 3791 | case 0x2A: /* Nonexistant field/item id */ |
3789 | case 0x35: /* Too long text */ | 3792 | case 0x35: /* Too long text */ |
3790 | return ERR_BUG; | 3793 | return ERR_BUG; |
3791 | case 0x23: /* Session opened */ | 3794 | case 0x23: /* Session opened */ |
3792 | case 0x80: /* Transfer started */ | 3795 | case 0x80: /* Transfer started */ |
3793 | return ERR_NONE; | 3796 | return ERR_NONE; |
3794 | case 0x82: /* Transfer canceled */ | 3797 | case 0x82: /* Transfer canceled */ |
3795 | return ERR_CANCELED; | 3798 | return ERR_CANCELED; |
3796 | default: | 3799 | default: |
3797 | smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]); | 3800 | smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]); |
3798 | return ERR_NONE; | 3801 | return ERR_NONE; |
3799 | } | 3802 | } |
3800 | } | 3803 | } |
3801 | 3804 | ||
3802 | static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) | 3805 | static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) |
3803 | { | 3806 | { |
3804 | s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24); | 3807 | s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24); |
3805 | smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord); | 3808 | smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord); |
3806 | return ERR_NONE; | 3809 | return ERR_NONE; |
3807 | } | 3810 | } |
3808 | 3811 | ||
3809 | static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) | 3812 | static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) |
3810 | { | 3813 | { |
3811 | GSM_Error error; | 3814 | GSM_Error error; |
3812 | 3815 | ||
3813 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 3816 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
3814 | return ATGEN_SetIncomingCB(s, enable); | 3817 | return ATGEN_SetIncomingCB(s, enable); |
3815 | } | 3818 | } |
3816 | 3819 | ||
3817 | static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) | 3820 | static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) |
3818 | { | 3821 | { |
3819 | GSM_Error error; | 3822 | GSM_Error error; |
3820 | 3823 | ||
3821 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | 3824 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; |
3822 | return ATGEN_SetIncomingSMS(s, enable); | 3825 | return ATGEN_SetIncomingSMS(s, enable); |
3823 | } | 3826 | } |
3824 | 3827 | ||
3828 | static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable) | ||
3829 | { | ||
3830 | GSM_Error error; | ||
3831 | |||
3832 | if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; | ||
3833 | return ATGEN_SetFastSMSSending(s, enable); | ||
3834 | } | ||
3835 | |||
3825 | static GSM_Reply_Function ALCATELReplyFunctions[] = { | 3836 | static GSM_Reply_Function ALCATELReplyFunctions[] = { |
3826 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, | 3837 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, |
3827 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, | 3838 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, |
3828 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, | 3839 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, |
3829 | {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, | 3840 | {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, |
3830 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, | 3841 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, |
3831 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, | 3842 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, |
3832 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, | 3843 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, |
3833 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, | 3844 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, |
3834 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, | 3845 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, |
3835 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, | 3846 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, |
3836 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, | 3847 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, |
3837 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, | 3848 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, |
3838 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, | 3849 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, |
3839 | {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, | 3850 | {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, |
3840 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1}, | 3851 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1}, |
3841 | {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2}, | 3852 | {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2}, |
3842 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1}, | 3853 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1}, |
3843 | {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2}, | 3854 | {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2}, |
3844 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1}, | 3855 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1}, |
3845 | {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2}, | 3856 | {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2}, |
3846 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, | 3857 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, |
3847 | {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, | 3858 | {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, |
3848 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1}, | 3859 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1}, |
3849 | {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2}, | 3860 | {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2}, |
3850 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, | 3861 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, |
3851 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, | 3862 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, |
3852 | {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, | 3863 | {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, |
3853 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, | 3864 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, |
3854 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, | 3865 | {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, |
3855 | {NULL, "\x00",0x00,0x00, ID_None } | 3866 | {NULL, "\x00",0x00,0x00, ID_None } |
3856 | }; | 3867 | }; |
3857 | 3868 | ||
3858 | GSM_Phone_Functions ALCATELPhone = { | 3869 | GSM_Phone_Functions ALCATELPhone = { |
3859 | /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all | 3870 | /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all |
3860 | * they were ever really released, if yes add them here also. | 3871 | * they were ever really released, if yes add them here also. |
3861 | */ | 3872 | */ |
3862 | "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", | 3873 | "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", |
3863 | ALCATELReplyFunctions, | 3874 | ALCATELReplyFunctions, |
3864 | ALCATEL_Initialise, | 3875 | ALCATEL_Initialise, |
3865 | ALCATEL_Terminate, | 3876 | ALCATEL_Terminate, |
3866 | ALCATEL_DispatchMessage, | 3877 | ALCATEL_DispatchMessage, |
3867 | NOTSUPPORTED, /* ShowStartInfo */ | 3878 | NOTSUPPORTED, /* ShowStartInfo */ |
3868 | ALCATEL_GetManufacturer, | 3879 | ALCATEL_GetManufacturer, |
3869 | ALCATEL_GetModel, | 3880 | ALCATEL_GetModel, |
3870 | ALCATEL_GetFirmware, | 3881 | ALCATEL_GetFirmware, |
3871 | ALCATEL_GetIMEI, | 3882 | ALCATEL_GetIMEI, |
3872 | NOTSUPPORTED, /* GetOriginalIMEI */ | 3883 | NOTSUPPORTED, /* GetOriginalIMEI */ |
3873 | NOTSUPPORTED, /* GetManufactureMonth*/ | 3884 | NOTSUPPORTED, /* GetManufactureMonth*/ |
3874 | ALCATEL_GetProductCode, | 3885 | ALCATEL_GetProductCode, |
3875 | NOTSUPPORTED, /* GetHardware */ | 3886 | NOTSUPPORTED, /* GetHardware */ |
3876 | NOTSUPPORTED, /* GetPPM */ | 3887 | NOTSUPPORTED, /* GetPPM */ |
3877 | ALCATEL_GetSIMIMSI, | 3888 | ALCATEL_GetSIMIMSI, |
3878 | ALCATEL_GetDateTime, | 3889 | ALCATEL_GetDateTime, |
3879 | ALCATEL_SetDateTime, | 3890 | ALCATEL_SetDateTime, |
3880 | ALCATEL_GetAlarm, | 3891 | ALCATEL_GetAlarm, |
3881 | ALCATEL_SetAlarm, | 3892 | ALCATEL_SetAlarm, |
3882 | NOTSUPPORTED, /* GetLocale */ | 3893 | NOTSUPPORTED, /* GetLocale */ |
3883 | NOTSUPPORTED, /* SetLocale */ | 3894 | NOTSUPPORTED, /* SetLocale */ |
3884 | ALCATEL_PressKey, | 3895 | ALCATEL_PressKey, |
3885 | ALCATEL_Reset, | 3896 | ALCATEL_Reset, |
3886 | ALCATEL_ResetPhoneSettings, | 3897 | ALCATEL_ResetPhoneSettings, |
3887 | ALCATEL_EnterSecurityCode, | 3898 | ALCATEL_EnterSecurityCode, |
3888 | ALCATEL_GetSecurityStatus, | 3899 | ALCATEL_GetSecurityStatus, |
3889 | ALCATEL_GetDisplayStatus, | 3900 | ALCATEL_GetDisplayStatus, |
3890 | ALCATEL_SetAutoNetworkLogin, | 3901 | ALCATEL_SetAutoNetworkLogin, |
3891 | ALCATEL_GetBatteryCharge, | 3902 | ALCATEL_GetBatteryCharge, |
3892 | ALCATEL_GetSignalStrength, | 3903 | ALCATEL_GetSignalStrength, |
3893 | ALCATEL_GetNetworkInfo, | 3904 | ALCATEL_GetNetworkInfo, |
3894 | ALCATEL_GetCategory, | 3905 | ALCATEL_GetCategory, |
3895 | ALCATEL_AddCategory, | 3906 | ALCATEL_AddCategory, |
3896 | ALCATEL_GetCategoryStatus, | 3907 | ALCATEL_GetCategoryStatus, |
3897 | ALCATEL_GetMemoryStatus, | 3908 | ALCATEL_GetMemoryStatus, |
3898 | ALCATEL_GetMemory, | 3909 | ALCATEL_GetMemory, |
3899 | ALCATEL_GetNextMemory, | 3910 | ALCATEL_GetNextMemory, |
3900 | ALCATEL_SetMemory, | 3911 | ALCATEL_SetMemory, |
3901 | ALCATEL_AddMemory, | 3912 | ALCATEL_AddMemory, |
3902 | ALCATEL_DeleteMemory, | 3913 | ALCATEL_DeleteMemory, |
3903 | ALCATEL_DeleteAllMemory, | 3914 | ALCATEL_DeleteAllMemory, |
3904 | NOTSUPPORTED, /* GetSpeedDial */ | 3915 | NOTSUPPORTED, /* GetSpeedDial */ |
3905 | NOTSUPPORTED, /* SetSpeedDial */ | 3916 | NOTSUPPORTED, /* SetSpeedDial */ |
3906 | ALCATEL_GetSMSC, | 3917 | ALCATEL_GetSMSC, |
3907 | ALCATEL_SetSMSC, | 3918 | ALCATEL_SetSMSC, |
3908 | ALCATEL_GetSMSStatus, | 3919 | ALCATEL_GetSMSStatus, |
3909 | ALCATEL_GetSMS, | 3920 | ALCATEL_GetSMS, |
3910 | ALCATEL_GetNextSMS, | 3921 | ALCATEL_GetNextSMS, |
3911 | NOTSUPPORTED, /* SetSMS */ | 3922 | NOTSUPPORTED, /* SetSMS */ |
3912 | ALCATEL_AddSMS, | 3923 | ALCATEL_AddSMS, |
3913 | ALCATEL_DeleteSMS, | 3924 | ALCATEL_DeleteSMS, |
3914 | ALCATEL_SendSMS, | 3925 | ALCATEL_SendSMS, |
3915 | ALCATEL_SendSavedSMS, | 3926 | ALCATEL_SendSavedSMS, |
3927 | ALCATEL_SetFastSMSSending, | ||
3916 | ALCATEL_SetIncomingSMS, | 3928 | ALCATEL_SetIncomingSMS, |
3917 | ALCATEL_SetIncomingCB, | 3929 | ALCATEL_SetIncomingCB, |
3918 | ALCATEL_GetSMSFolders, | 3930 | ALCATEL_GetSMSFolders, |
3919 | NOTSUPPORTED, /* AddSMSFolder */ | 3931 | NOTSUPPORTED, /* AddSMSFolder */ |
3920 | NOTSUPPORTED, /* DeleteSMSFolder */ | 3932 | NOTSUPPORTED, /* DeleteSMSFolder */ |
3921 | ALCATEL_DialVoice, | 3933 | ALCATEL_DialVoice, |
3922 | ALCATEL_AnswerCall, | 3934 | ALCATEL_AnswerCall, |
3923 | ALCATEL_CancelCall, | 3935 | ALCATEL_CancelCall, |
3924 | NOTSUPPORTED, /* HoldCall */ | 3936 | NOTSUPPORTED, /* HoldCall */ |
3925 | NOTSUPPORTED, /* UnholdCall */ | 3937 | NOTSUPPORTED, /* UnholdCall */ |
3926 | NOTSUPPORTED, /* ConferenceCall */ | 3938 | NOTSUPPORTED, /* ConferenceCall */ |
3927 | NOTSUPPORTED, /* SplitCall */ | 3939 | NOTSUPPORTED, /* SplitCall */ |
3928 | NOTSUPPORTED, /* TransferCall */ | 3940 | NOTSUPPORTED, /* TransferCall */ |
3929 | NOTSUPPORTED, /* SwitchCall */ | 3941 | NOTSUPPORTED, /* SwitchCall */ |
3930 | NOTSUPPORTED, /* GetCallDivert */ | 3942 | NOTSUPPORTED, /* GetCallDivert */ |
3931 | NOTSUPPORTED, /* SetCallDivert */ | 3943 | NOTSUPPORTED, /* SetCallDivert */ |
3932 | NOTSUPPORTED, /* CancelAllDiverts*/ | 3944 | NOTSUPPORTED, /* CancelAllDiverts*/ |
3933 | NONEFUNCTION, /* SetIncomingCall */ | 3945 | NONEFUNCTION, /* SetIncomingCall */ |
3934 | NOTSUPPORTED, /* SetIncomingUSSD */ | 3946 | NOTSUPPORTED, /* SetIncomingUSSD */ |
3935 | ALCATEL_SendDTMF, | 3947 | ALCATEL_SendDTMF, |
3936 | NOTSUPPORTED, /* GetRingtone */ | 3948 | NOTSUPPORTED, /* GetRingtone */ |
3937 | NOTSUPPORTED, /* SetRingtone */ | 3949 | NOTSUPPORTED, /* SetRingtone */ |
3938 | NOTSUPPORTED, /* GetRingtonesInfo*/ | 3950 | NOTSUPPORTED, /* GetRingtonesInfo*/ |
3939 | NOTSUPPORTED, /* DeleteUserRingtones*/ | 3951 | NOTSUPPORTED, /* DeleteUserRingtones*/ |
3940 | NOTSUPPORTED, /* PlayTone */ | 3952 | NOTSUPPORTED, /* PlayTone */ |
3941 | NOTSUPPORTED, /* GetWAPBookmark */ | 3953 | NOTSUPPORTED, /* GetWAPBookmark */ |
3942 | NOTSUPPORTED, /* SetWAPBookmark */ | 3954 | NOTSUPPORTED, /* SetWAPBookmark */ |
3943 | NOTSUPPORTED, /* DeleteWAPBookmark*/ | 3955 | NOTSUPPORTED, /* DeleteWAPBookmark*/ |
3944 | NOTSUPPORTED, /* GetWAPSettings */ | 3956 | NOTSUPPORTED, /* GetWAPSettings */ |
3945 | NOTSUPPORTED, /* SetWAPSettings */ | 3957 | NOTSUPPORTED, /* SetWAPSettings */ |
3946 | NOTSUPPORTED, /* GetMMSSettings */ | 3958 | NOTSUPPORTED, /* GetMMSSettings */ |
3947 | NOTSUPPORTED, /* SetMMSSettings */ | 3959 | NOTSUPPORTED, /* SetMMSSettings */ |
3948 | NOTSUPPORTED, /* GetSyncMLSettings*/ | 3960 | NOTSUPPORTED, /* GetSyncMLSettings*/ |
3949 | NOTSUPPORTED, /* SetSyncMLSettings*/ | 3961 | NOTSUPPORTED, /* SetSyncMLSettings*/ |
3950 | NOTSUPPORTED, /* GetChatSettings */ | 3962 | NOTSUPPORTED, /* GetChatSettings */ |
3951 | NOTSUPPORTED, /* SetChatSettings */ | 3963 | NOTSUPPORTED, /* SetChatSettings */ |
3952 | NOTSUPPORTED, /* GetBitmap */ | 3964 | NOTSUPPORTED, /* GetBitmap */ |
3953 | NOTSUPPORTED, /* SetBitmap */ | 3965 | NOTSUPPORTED, /* SetBitmap */ |
3954 | ALCATEL_GetToDoStatus, | 3966 | ALCATEL_GetToDoStatus, |
3955 | ALCATEL_GetToDo, | 3967 | ALCATEL_GetToDo, |
3956 | ALCATEL_GetNextToDo, | 3968 | ALCATEL_GetNextToDo, |
3957 | ALCATEL_SetToDo, | 3969 | ALCATEL_SetToDo, |
3958 | ALCATEL_AddToDo, | 3970 | ALCATEL_AddToDo, |
3959 | ALCATEL_DeleteToDo, | 3971 | ALCATEL_DeleteToDo, |
3960 | ALCATEL_DeleteAllToDo, | 3972 | ALCATEL_DeleteAllToDo, |
3961 | ALCATEL_GetCalendarStatus, | 3973 | ALCATEL_GetCalendarStatus, |
3962 | ALCATEL_GetCalendar, | 3974 | ALCATEL_GetCalendar, |
3963 | ALCATEL_GetNextCalendar, | 3975 | ALCATEL_GetNextCalendar, |
3964 | ALCATEL_SetCalendar, | 3976 | ALCATEL_SetCalendar, |
3965 | ALCATEL_AddCalendar, | 3977 | ALCATEL_AddCalendar, |
3966 | ALCATEL_DeleteCalendar, | 3978 | ALCATEL_DeleteCalendar, |
3967 | ALCATEL_DeleteAllCalendar, | 3979 | ALCATEL_DeleteAllCalendar, |
3968 | NOTSUPPORTED, /* GetCalendarSettings*/ | 3980 | NOTSUPPORTED, /* GetCalendarSettings*/ |
3969 | NOTSUPPORTED, /* SetCalendarSettings*/ | 3981 | NOTSUPPORTED, /* SetCalendarSettings*/ |
3970 | NOTSUPPORTED, /* GetNote */ | 3982 | NOTSUPPORTED, /* GetNextNote */ |
3971 | NOTSUPPORTED, /* GetProfile */ | 3983 | NOTSUPPORTED, /* GetProfile */ |
3972 | NOTSUPPORTED, /* SetProfile */ | 3984 | NOTSUPPORTED, /* SetProfile */ |
3973 | NOTSUPPORTED, /* GetFMStation */ | 3985 | NOTSUPPORTED, /* GetFMStation */ |
3974 | NOTSUPPORTED, /* SetFMStation */ | 3986 | NOTSUPPORTED, /* SetFMStation */ |
3975 | NOTSUPPORTED, /* ClearFMStations */ | 3987 | NOTSUPPORTED, /* ClearFMStations */ |
3976 | NOTSUPPORTED, /* GetNextFileFolder*/ | 3988 | NOTSUPPORTED, /* GetNextFileFolder*/ |
3977 | NOTSUPPORTED, /* GetFilePart */ | 3989 | NOTSUPPORTED, /* GetFilePart */ |
3978 | NOTSUPPORTED, /* AddFilePart */ | 3990 | NOTSUPPORTED, /* AddFilePart */ |
3979 | NOTSUPPORTED, /* GetFileSystemStatus*/ | 3991 | NOTSUPPORTED, /* GetFileSystemStatus*/ |
3980 | NOTSUPPORTED, /* DeleteFile */ | 3992 | NOTSUPPORTED, /* DeleteFile */ |
3981 | NOTSUPPORTED, /* AddFolder */ | 3993 | NOTSUPPORTED, /* AddFolder */ |
3982 | NOTSUPPORTED, /* GetGPRSAccessPoint*/ | 3994 | NOTSUPPORTED, /* GetGPRSAccessPoint*/ |
3983 | NOTSUPPORTED /* SetGPRSAccessPoint*/ | 3995 | NOTSUPPORTED /* SetGPRSAccessPoint*/ |
3984 | }; | 3996 | }; |
3985 | 3997 | ||
3986 | #endif | 3998 | #endif |
3987 | #endif | 3999 | #endif |
3988 | 4000 | ||
3989 | /* How should editor hadle tabs in this file? Add editor commands here. | 4001 | /* How should editor hadle tabs in this file? Add editor commands here. |
3990 | * vim: noexpandtab sw=8 ts=8 sts=8: | 4002 | * vim: noexpandtab sw=8 ts=8 sts=8: |
3991 | */ | 4003 | */ |