Diffstat (limited to 'gammu/emb/common/service/gsmdata.c') (more/less context) (show whitespace changes)
-rw-r--r-- | gammu/emb/common/service/gsmdata.c | 120 |
1 files changed, 99 insertions, 21 deletions
diff --git a/gammu/emb/common/service/gsmdata.c b/gammu/emb/common/service/gsmdata.c index 94e9b7b..9303b57 100644 --- a/gammu/emb/common/service/gsmdata.c +++ b/gammu/emb/common/service/gsmdata.c | |||
@@ -237,71 +237,149 @@ void NOKIA_EncodeWAPMMSSettingsSMSText(unsigned char *Buffer, int *Length, GSM_W | |||
237 | 237 | ||
238 | /* ISP_NAME (name) */ | 238 | /* ISP_NAME (name) */ |
239 | Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes | 239 | Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes |
240 | Buffer[(*Length)++] = 0x08; //TYPE=NAME | 240 | Buffer[(*Length)++] = 0x08; //TYPE=NAME |
241 | Buffer[(*Length)++] = 0x01; //END PARMeter | 241 | Buffer[(*Length)++] = 0x01; //END PARMeter |
242 | /* Settings name */ | 242 | /* Settings name */ |
243 | AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title)); | 243 | AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title)); |
244 | Buffer[(*Length)++] = 0x01; //END PARMeter | 244 | Buffer[(*Length)++] = 0x01; //END PARMeter |
245 | Buffer[(*Length)++] = 0x01; //END PARMeter | 245 | Buffer[(*Length)++] = 0x01; //END PARMeter |
246 | } | 246 | } |
247 | 247 | ||
248 | /* http://forum.nokia.com: OTA Settings 7.0 */ | 248 | /* http://forum.nokia.com: OTA Settings 7.0 */ |
249 | /* first it used default/ISO coding */ | ||
250 | /* Joergen Thomsen changed to UTF8 */ | ||
249 | void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark) | 251 | void NOKIA_EncodeWAPBookmarkSMSText(unsigned char *Buffer, int *Length, GSM_WAPBookmark *bookmark) |
250 | { | 252 | { |
251 | unsigned charbuffer[100]; | 253 | unsigned charbuffer[100]; |
252 | bool UnicodeCoding = false; | ||
253 | 254 | ||
254 | EncodeUTF8QuotedPrintable(buffer,bookmark->Title); | 255 | // bool UnicodeCoding = false; |
255 | if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true; | 256 | //EncodeUTF8QuotedPrintable(buffer,bookmark->Title); |
257 | //if (UnicodeLength(bookmark->Title)!=strlen(buffer)) UnicodeCoding = true; | ||
256 | 258 | ||
257 | Buffer[(*Length)++] = 0x01; //Push ID | 259 | Buffer[(*Length)++] = 0x01; //Push ID |
258 | Buffer[(*Length)++] = 0x06; //PDU Type (push) | 260 | Buffer[(*Length)++] = 0x06; //PDU Type (push) |
259 | Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers) | 261 | Buffer[(*Length)++] = 0x2D; //Headers length (content type + headers) |
260 | strcpy(Buffer+(*Length),"\x1F\x2B"); | 262 | strcpy(Buffer+(*Length),"\x1F\x2B"); |
261 | (*Length)=(*Length)+2; //Value length | 263 | (*Length)=(*Length)+2; //Value length |
262 | strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks"); | 264 | strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks"); |
263 | (*Length)=(*Length)+40; //MIME-Type | 265 | (*Length)=(*Length)+40; //MIME-Type |
264 | Buffer[(*Length)++] = 0x00; //end inline string | 266 | Buffer[(*Length)++] = 0x00; //end inline string |
265 | strcpy(Buffer+(*Length),"\x81\xEA"); | 267 | strcpy(Buffer+(*Length),"\x81\xEA"); |
266 | (*Length)=(*Length)+2; //charset UTF-8 short int. | 268 | (*Length)=(*Length)+2; //charset UTF-8 short int. |
267 | 269 | ||
270 | /* removed by Joergen Thomsen */ | ||
268 | /* Block from sniffs. UNKNOWN */ | 271 | /* Block from sniffs. UNKNOWN */ |
269 | if (!UnicodeCoding) { | 272 | //if (!UnicodeCoding) { |
270 | Buffer[(*Length)++] = 0x00; | 273 | // Buffer[(*Length)++] = 0x00; |
271 | Buffer[(*Length)++] = 0x01; | 274 | // Buffer[(*Length)++] = 0x01; |
272 | } else { | 275 | //} else { |
273 | strcpy(Buffer+(*Length),"\x01\x01\x87\x68"); | 276 | // strcpy(Buffer+(*Length),"\x01\x01\x87\x68"); |
274 | (*Length)=(*Length)+4; | 277 | // (*Length)=(*Length)+4; |
275 | } | 278 | //} |
276 | Buffer[(*Length)++] = 0x00; | 279 | //Buffer[(*Length)++] = 0x00; |
280 | |||
281 | /* added by Joergen Thomsen */ | ||
282 | Buffer[(*Length)++] = 0x01; // Version WBXML 1.1 | ||
283 | Buffer[(*Length)++] = 0x01; // Unknown public identifier | ||
284 | Buffer[(*Length)++] = 0x6A; // charset UTF-8 | ||
285 | Buffer[(*Length)++] = 0x00; // string table length | ||
277 | 286 | ||
278 | Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content | 287 | Buffer[(*Length)++] = 0x45; //CHARACTERISTIC-LIST with content |
279 | /* URL */ | 288 | /* URL */ |
280 | Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes | 289 | Buffer[(*Length)++] = 0xC6; //CHARACTERISTIC with content and attributes |
281 | Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK | 290 | Buffer[(*Length)++] = 0x7F; //TYPE = BOOKMARK |
282 | Buffer[(*Length)++] = 0x01; //END PARMeter | 291 | Buffer[(*Length)++] = 0x01; //END PARMeter |
283 | if (!UnicodeCoding) { | 292 | |
284 | /* TITLE */ | 293 | /* removed by Joergen Thomsen */ |
285 | AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title)); | 294 | // if (!UnicodeCoding) { |
286 | /* URL */ | 295 | // /* TITLE */ |
287 | AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address)); | 296 | // AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(bookmark->Title), UnicodeLength(bookmark->Title)); |
288 | } else { | 297 | // /* URL */ |
298 | // AddWAPSMSParameterText(Buffer, Length, 0x17, DecodeUnicodeString(bookmark->Address), UnicodeLength(bookmark->Address)); | ||
299 | // } else { | ||
300 | // /* TITLE */ | ||
301 | // AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1); | ||
302 | // /* URL */ | ||
303 | // AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1); | ||
304 | // } | ||
305 | |||
306 | /* added by Joergen Thomsen */ | ||
289 | /* TITLE */ | 307 | /* TITLE */ |
290 | AddWAPSMSParameterText(Buffer, Length, 0x15, bookmark->Title, UnicodeLength(bookmark->Title)*2+1); | 308 | EncodeUTF8(buffer, bookmark->Title); |
309 | AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer)); | ||
291 | /* URL */ | 310 | /* URL */ |
292 | AddWAPSMSParameterText(Buffer, Length, 0x17, bookmark->Address, UnicodeLength(bookmark->Address)*2+1); | 311 | EncodeUTF8(buffer, bookmark->Address); |
312 | AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer)); | ||
313 | |||
314 | Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC) | ||
315 | Buffer[(*Length)++] = 0x01; //END (CHARACTERISTIC-LIST) | ||
293 | } | 316 | } |
294 | Buffer[(*Length)++] = 0x01; //END PARMeter | 317 | |
295 | Buffer[(*Length)++] = 0x01; //END PARMeter | 318 | void GSM_EncodeWAPIndicatorSMSText(unsigned char *Buffer, int *Length, char *Text, char *URL) |
319 | { | ||
320 | int i; | ||
321 | |||
322 | Buffer[(*Length)++] = 0x01; //Push ID | ||
323 | Buffer[(*Length)++] = 0x06; //PDU Type (push) | ||
324 | Buffer[(*Length)++] = 28; //Headers length (content type + headers) | ||
325 | strcpy(Buffer+(*Length),"\x1F\x23"); | ||
326 | (*Length)=(*Length)+2; //Value length | ||
327 | strcpy(Buffer+(*Length),"application/vnd.wap.sic"); | ||
328 | (*Length)=(*Length)+23; //MIME-Type | ||
329 | Buffer[(*Length)++] = 0x00; //end inline string | ||
330 | strcpy(Buffer+(*Length),"\x81\xEA"); | ||
331 | (*Length)=(*Length)+2; //charset UTF-8 short int. | ||
332 | |||
333 | Buffer[(*Length)++] = 0x02; // WBXML 1.2 | ||
334 | Buffer[(*Length)++] = 0x05; // SI 1.0 Public Identifier | ||
335 | Buffer[(*Length)++] = 0x6A; // charset UTF-8 | ||
336 | Buffer[(*Length)++] = 0x00; // string table length | ||
337 | Buffer[(*Length)++] = 0x45; // SI with content | ||
338 | Buffer[(*Length)++] = 0xC6; // indication with content and attributes | ||
339 | Buffer[(*Length)++] = 0x0B;// address | ||
340 | Buffer[(*Length)++] = 0x03; // Inline string | ||
341 | for (i=0;i<(int)strlen(URL);i++) { | ||
342 | Buffer[(*Length)++] = URL[i];//Text | ||
343 | } | ||
344 | Buffer[(*Length)++] = 0x00; // END Inline string | ||
345 | |||
346 | #ifdef XXX | ||
347 | Buffer[(*Length)++] = 0x0A;// created... | ||
348 | Buffer[(*Length)++] = 0xC3;// OPAQUE | ||
349 | Buffer[(*Length)++] = 0x07;// length | ||
350 | Buffer[(*Length)++] = 0x19;// year | ||
351 | Buffer[(*Length)++] = 0x80;// year | ||
352 | Buffer[(*Length)++] = 0x21;// month | ||
353 | Buffer[(*Length)++] = 0x12;// .. | ||
354 | Buffer[(*Length)++] = 0x00;// .. | ||
355 | Buffer[(*Length)++] = 0x00;// .. | ||
356 | Buffer[(*Length)++] = 0x00;// .. | ||
357 | Buffer[(*Length)++] = 0x10;// expires | ||
358 | Buffer[(*Length)++] = 0xC3;// OPAQUE | ||
359 | Buffer[(*Length)++] = 0x04;// length | ||
360 | Buffer[(*Length)++] = 0x20;// year | ||
361 | Buffer[(*Length)++] = 0x10;// year | ||
362 | Buffer[(*Length)++] = 0x06;// month | ||
363 | Buffer[(*Length)++] = 0x25;// day | ||
364 | #endif | ||
365 | |||
366 | Buffer[(*Length)++] = 0x01; // END (indication) | ||
367 | Buffer[(*Length)++] = 0x03; // Inline string | ||
368 | for (i=0;i<(int)strlen(Text);i++) { | ||
369 | Buffer[(*Length)++] = Text[i];//Text | ||
370 | } | ||
371 | Buffer[(*Length)++] = 0x00; // END Inline string | ||
372 | Buffer[(*Length)++] = 0x01; // END (indication) | ||
373 | Buffer[(*Length)++] = 0x01; // END (SI) | ||
296 | } | 374 | } |
297 | 375 | ||
298 | void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) | 376 | void GSM_EncodeMMSFile(GSM_EncodeMultiPartMMSInfo *Info, unsigned char *Buffer, int *Length) |
299 | { | 377 | { |
300 | int i; | 378 | int i; |
301 | 379 | ||
302 | strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F"); | 380 | strcpy(Buffer+(*Length),"\x8C\x80\x98\x4F"); |
303 | (*Length)=(*Length)+4; | 381 | (*Length)=(*Length)+4; |
304 | 382 | ||
305 | /* Unique MMS ID ? */ | 383 | /* Unique MMS ID ? */ |
306 | strcpy(Buffer+(*Length),"123456789"); | 384 | strcpy(Buffer+(*Length),"123456789"); |
307 | (*Length)=(*Length)+9; | 385 | (*Length)=(*Length)+9; |