comparison src/aci2/bmi/AUIWapPush.c @ 120:3c2acfa1a72f

src/aci2/bmi: file renames to make filename case consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 07 Oct 2016 03:46:05 +0000
parents src/aci2/bmi/auiwappush.c@93999a60b835
children
comparison
equal deleted inserted replaced
119:b92a33c204b6 120:3c2acfa1a72f
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name:
13 $Project code:
14 $Module:
15 $File: AUIWapPush.c
16 $Revision:
17
18 $Author: Condat(UK)
19 $Date:
20
21 ********************************************************************************
22
23 Description:
24 The user interface for WAP PUSH.
25
26 ********************************************************************************
27
28 $History: AUIWapPush.c
29
30 xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
31 Ignoring the duplicate push message part received. (The same part
32 already exists in the push message store)
33
34 xreddymn Mar-22-2005 MMI-SPR-29767
35 Modified behaviour of SL push message handling in MMI
36
37 xrashmic 9 May, 2005 MMI-SPR-30159
38 Concat PUSH msg are stored and sent to wap client once all parts are received
39
40 xreddymn Jan-10-2005 MMI-SPR-27618: Modified WAP push URL display screen
41 to prevent user from editing the contents.
42
43 21/07/03 - SH - Created
44
45 $End
46
47 *******************************************************************************/
48
49
50 #include <stdio.h>
51 #include <string.h>
52 #include <stdlib.h>
53
54
55 #if defined (NEW_FRAME)
56
57 #include "typedefs.h"
58 #include "vsi.h"
59 #include "pei.h"
60 #include "custom.h"
61 #include "gsm.h"
62
63 #else /* NEW_FRAME */
64
65 #include "STDDEFS.H"
66 #include "custom.h"
67 #include "gsm.h"
68 #include "vsi.h"
69
70 #endif /* NEW_FRAME */
71
72 #include "mfw_sys.h"
73
74 #include "mfw_mfw.h"
75 #include "mfw_win.h"
76 #include "mfw_kbd.h"
77 #include "mfw_edt.h"
78 #include "mfw_tim.h"
79 #include "mfw_phb.h"
80 #include "mfw_sms.h"
81 #include "mfw_icn.h"
82 #include "mfw_mnu.h"
83 #include "mfw_lng.h"
84 #include "mfw_sat.h"
85 #include "mfw_kbd.h"
86 #include "mfw_nm.h"
87 #include "mfw_cm.h"
88
89 #include "dspl.h"
90
91 #include "wapmic_types.h"
92
93 #include "MmiMmi.h"
94 #include "MmiMain.h"
95 #include "MmiDummy.h"
96 #include "MmiDialogs.h"
97 #include "MmiLists.h"
98 #include "mmiCall.h"
99
100 #include "MmiMenu.h"
101 #include "MmiSoftKeys.h"
102 #include "MmiResources.h"
103
104 #include "MmiBlkLangDB.h"
105 #include "MmiBookUtils.h"
106 //#include "MmiEditor.h"
107 //#include "MmiEditor_i.h"
108 #include "MmiBookShared.h"
109 #include "ATBData.h"
110 #include "ATBWapAUI.h"
111 #include "mmiSmsMenu.h"
112 #include "mmismssend.h"
113 #include "AUIWapext.h"
114 #include "AUIWap.h"
115 #ifdef MMI_GPRS_ENABLED
116 #include "MmiGprs.h"
117 #endif
118
119 #include "cus_aci.h"
120 #include "prim.h"
121 #ifndef PCM_2_FFS
122 #include "pcm.h"
123 #endif
124
125
126 #include "mmiColours.h"
127 #include "font_bitmaps.h"
128
129 //xrashmic 9 May, 2005 MMI-SPR-30159
130 #include "conc_sms.h"
131 #include "ffs/ffs.h"
132 #include "mfw_td.h"
133
134 //xrashmic 9 May, 2005 MMI-SPR-30159
135 //Maximum number of parts per message
136 #define MAX_PUSH_MSG_PARTS 5
137 //Maximum PUSH message that can be stored in FFS
138 #define MAX_PUSH_MSG_STORAGE 5
139 //Maximum duration after which the PUSH message will be deleted from FFS
140 #define MAX_DURATION 2 //no of days
141
142 typedef struct
143 {
144 U16 msg_ref;
145 U8 msg_saved;
146 U8 seq_num;
147 U8 num_msgs;
148 U8 year;
149 U8 month;
150 U8 day;
151 }AUI_PUSH_REPOSITORY_TABLE;
152 AUI_PUSH_REPOSITORY_TABLE PUSH_Table[MAX_PUSH_MSG_STORAGE];
153
154 enum PUSH_STORAGE
155 {
156 MSG_NONE=0,
157 MSG_FFS,
158 MSG_NEW
159 };
160 //xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
161 typedef enum
162 {
163 DUPLICATE=-1,
164 NOT_FOUND=0,
165 FOUND
166 }PUSHMSG_SEARCH_RESULT;
167 typedef struct
168 {
169 U8 storage;
170 U8 index;
171 }AUI_SORTED_PUSH_REPOSITORY;
172 AUI_SORTED_PUSH_REPOSITORY PUSH_Sorted_Parts[MAX_PUSH_MSG_PARTS];
173
174
175 static int AUI_wap_mfw_cb(MfwEvt event, MfwHnd hnd);
176 static void AUI_wap_push_start_load_SI(UBYTE result);
177
178 static void AUI_wap_push_start_cb(UBYTE result);
179 static void AUI_wap_push_show_cb(T_MFW_HND win, USHORT identifier, USHORT reason);
180 static void AUI_wap_push_list_cb(T_MFW_HND win, ListMenuData *EntryListData);
181
182
183 /*******************************************************************************
184
185 $Function: AUI_wap_push_start
186
187 $Description: Start PUSH
188 SPR#2086 - SH - Added
189
190 $Returns: None
191
192 $Arguments: None
193
194 *******************************************************************************/
195
196 void AUI_wap_push_start()
197 {
198
199 #ifdef TRACE_AUIWAP
200 TRACE_FUNCTION("AUI_wap_push_start()");
201 #endif
202
203 /* Create SMS handler */
204
205 AUI_wap_start(WAP_PUSH, (T_WAP_CB)AUI_wap_push_start_cb);
206
207 return;
208 }
209
210
211 static void AUI_wap_push_start_cb(UBYTE result)
212 {
213 T_WAP_DATA *data;
214
215 TRACE_FUNCTION("AUI_wap_push_start_cb");
216
217 if (!result)
218 {
219 TRACE_EVENT("*** Failed to start up for WAP PUSH ***");
220 return;
221 }
222
223 data = AUI_wap_data();
224
225 data->PushData = (T_WAP_PUSH_DATA *)AUI_wap_memory_alloc(sizeof(T_WAP_PUSH_DATA));
226 data->PushData->List = NULL;
227 data->PushData->list_created = FALSE;
228 data->PushData->service_indication = -1;
229 memset((void *)data->PushData->list_ids, 0, sizeof(WAP_PUSH_MAX_MESSAGES));
230
231 /* Create SMS handler */
232 data->PushData->Sms_handler = sms_create(0, E_SMS_WAP_MT_RECEIVED, (T_MFW_CB)AUI_wap_mfw_cb);
233
234 return;
235 }
236
237 /*******************************************************************************
238
239 $Function: AUI_wap_push_destroy
240
241 $Description: Start PUSH
242 SPR#2086 - SH - Added
243
244 $Returns: None
245
246 $Arguments: None
247
248 *******************************************************************************/
249
250 void AUI_wap_push_destroy()
251 {
252 T_WAP_DATA *data = AUI_wap_data();
253
254 #ifdef TRACE_AUIWAP
255 TRACE_FUNCTION("AUI_wap_push_destroy()");
256 #endif
257
258 if (!data)
259 {
260 return;
261 }
262
263 if (!data->PushData)
264 {
265 return;
266 }
267
268 if (data->PushData->List)
269 {
270 AUI_wap_push_list_destroy();
271 }
272
273 AUI_wap_memory_free((void *)data->PushData, sizeof(T_WAP_PUSH_DATA));
274
275 return;
276 }
277
278
279 /*******************************************************************************
280
281 $Function: AUI_read_PUSH_table
282
283 $Description: Reads the table from the FFS
284 //xrashmic 9 May, 2005 MMI-SPR-30159
285
286 $Returns:
287
288 $Arguments: event - The event received
289
290 *******************************************************************************/
291 void AUI_read_PUSH_table(void)
292 {
293 T_FFS_OPEN_FLAGS Ffsflags;
294 fd_t FfsFd;
295
296 Ffsflags = FFS_O_RDONLY;
297 FfsFd = ffs_open ("/mmi/concatwappush/table", Ffsflags);
298 if(FfsFd > 0)
299 {
300 ffs_read(FfsFd,(void*)PUSH_Table,sizeof(PUSH_Table));
301 ffs_close(FfsFd);
302 }
303 else
304 TRACE_EVENT("Table open failed");
305 }
306
307 /*******************************************************************************
308
309 $Function: AUI_store_PUSH_table
310
311 $Description: Stores the table into FFS
312 //xrashmic 9 May, 2005 MMI-SPR-30159
313
314 $Returns:
315
316 $Arguments: event - The event received
317
318 *******************************************************************************/
319 void AUI_store_PUSH_table(void)
320 {
321 T_FFS_OPEN_FLAGS Ffsflags;
322 fd_t FfsFd;
323
324 Ffsflags = FFS_O_WRONLY|FFS_O_CREATE;
325 FfsFd = ffs_open("/mmi/concatwappush/table",Ffsflags);
326 if(FfsFd > 0)
327 {
328 ffs_write(FfsFd,(void*)PUSH_Table,sizeof(PUSH_Table));
329 ffs_close(FfsFd);
330 }
331 else
332 TRACE_ERROR("Table write failed");
333 }
334
335 /*******************************************************************************
336
337 $Function: AUI_ffs_PUSH_init
338
339 $Description: Creates the concat push directory and initializes the push table
340 and creates a new push table file
341 //xrashmic 9 May, 2005 MMI-SPR-30159
342
343 $Returns:
344
345 $Arguments: event - The event received
346
347 *******************************************************************************/
348 void AUI_ffs_PUSH_init(void)
349 {
350 T_FFS_RET ffsResult;
351
352 ffsResult = ffs_mkdir("/mmi/concatwappush");
353 if(EFFS_OK == ffsResult)
354 {
355 //Initialize the table
356 memset(PUSH_Table,0,sizeof(PUSH_Table));
357 //write this to FFS
358 AUI_store_PUSH_table();
359 }
360 else
361 TRACE_EVENT("Create Dir Failed");
362 }
363
364 /*******************************************************************************
365
366 $Function: AUI_check_concat_msg
367
368 $Description: Checks for concat push msg
369 //xrashmic 9 May, 2005 MMI-SPR-30159
370
371 $Returns: TRUE - if it is a concat push message (also the msg ref, seq num and number of msgs are populates in this case)
372 FALSE - if it is not a concat push message
373
374 $Arguments: UdhData - UDH data from the sms push message received
375 UdhLength - UDH length
376 msg_ref - Msg ref of the rcvd sms push message
377 num_msgs - total number of msgs in the concat rcvd sms push message
378 seq_num - The sequence number of the push message
379
380 *******************************************************************************/
381 BOOL AUI_check_concat_msg( UBYTE* UdhData, UBYTE UdhLength,U16 *msg_ref,U8 *num_msgs,U8 *seq_num)
382 {
383 S32 offset = 0;
384 U8 IE_ID;
385 U8 IE_length;
386 BOOL concatSMS = FALSE;
387 *msg_ref = 0xffff;
388 *num_msgs = 0;
389 *seq_num = 0;
390 while(offset<UdhLength)
391 {
392 IE_ID = UdhData[offset++];
393 IE_length = UdhData[offset++];
394 switch(IE_ID)
395 {
396 case SMS_IEI_CONC_8BIT: /* 8-bit message reference number */
397 *msg_ref = UdhData[offset+0];
398 *num_msgs = UdhData[offset+1];
399 *seq_num = UdhData[offset+2];
400 concatSMS = TRUE;
401 break;
402
403 case SMS_IEI_CONC_16BIT: /* 16-bit message reference number */
404 *msg_ref = UdhData[offset+0];
405 *msg_ref|= (UdhData[offset+1] << 8);
406 *num_msgs = UdhData[offset+2];
407 *seq_num = UdhData[offset+3];
408 concatSMS = TRUE;
409 break;
410 }
411 if(TRUE == concatSMS)
412 break;
413 offset+=IE_length;
414 }
415 TRACE_EVENT_P3("Concat Push Msg Ref-%d, Seq-%d, Total-%d",*msg_ref,*seq_num,*num_msgs);
416 return concatSMS;
417 }
418
419 /*******************************************************************************
420
421 $Function: AUI_delete_PUSH_msg
422
423 $Description: Delets the push msg file from the FFS
424 //xrashmic 9 May, 2005 MMI-SPR-30159
425
426 $Returns:
427
428 $Arguments: Index: index of the messgae to be deleted
429
430 *******************************************************************************/
431 void AUI_delete_PUSH_msg(U8 index)
432 {
433 char filename[40];
434
435 sprintf(filename,"/mmi/concatwappush/push%d",index);
436 ffs_remove(filename);
437
438 //Removing the corresponding entry from the table
439 memset(&PUSH_Table[index],0,sizeof(AUI_PUSH_REPOSITORY_TABLE));
440 AUI_store_PUSH_table();
441 }
442
443 /*******************************************************************************
444
445 $Function: AUI_cleanup_PUSH_repository
446
447 $Description: Deletes the old push msg from the FFS
448 //xrashmic 9 May, 2005 MMI-SPR-30159
449
450 $Returns:
451
452 $Arguments: msg_ref: Msg ref of the rcvd msgs
453
454 *******************************************************************************/
455 void AUI_cleanup_PUSH_repository(U16 msg_ref)
456 {
457 U8 index;
458 T_MFW_DATE *currDate;
459 BOOL deletePUSHMsg;
460
461 currDate = mfw_td_get_date();
462
463 //Traverse throught the PUSH table and delete old push msg parts
464 for(index = 0; index < MAX_PUSH_MSG_STORAGE ; index++)
465 {
466 deletePUSHMsg = FALSE;
467 if((MSG_FFS == (int)PUSH_Table[index].msg_saved) &&( PUSH_Table[index].msg_ref != msg_ref))
468 {
469 //Need to take only the last two digits for the year
470 if ( (currDate->year%100) > (USHORT)PUSH_Table[index].year)
471 {
472 //very old one delete it
473 deletePUSHMsg = TRUE;
474 }
475 //Need to take only the last two digits for the year
476 else if ((currDate->year%100) == (USHORT)PUSH_Table[index].year)
477 {
478 //msg of same year check for the month
479 if ((USHORT)currDate->month >(USHORT) PUSH_Table[index].month)
480 {
481 //older than one month delete it
482 deletePUSHMsg = TRUE;
483 }
484 else if ((USHORT)currDate->month == (USHORT) PUSH_Table[index].month)
485 {
486 //older than MAX_DURATION, delete it
487 if ((USHORT)currDate->day - (USHORT)PUSH_Table[index].day>MAX_DURATION)
488 deletePUSHMsg = TRUE;
489 }
490 }
491 }
492 if(TRUE == deletePUSHMsg)
493 {
494 AUI_delete_PUSH_msg(index);
495 }
496 }
497 }
498
499 /*******************************************************************************
500
501 $Function: AUI_check_repository
502
503 $Description: Checks the repository for the complete PUSH msg
504 //xrashmic 9 May, 2005 MMI-SPR-30159
505
506 $Returns:
507
508 $Arguments: msg_ref: Msg ref of the rcvd msg
509 num_msgs: total num of parts for the concat msgs
510
511 *******************************************************************************/
512 //xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
513 //Added the seq number in the parameter list of this function to check for duplicate push messages
514 PUSHMSG_SEARCH_RESULT AUI_check_repository(U16 msg_ref,U8 num_msgs,U8 seq_num)
515 {
516 U8 index,parts = 1;
517 for( index = 0; index < MAX_PUSH_MSG_STORAGE ; index++ )
518 {
519 if((MSG_FFS == (int)PUSH_Table[index].msg_saved ) &&( PUSH_Table[index].msg_ref == msg_ref) )
520 {
521 PUSH_Sorted_Parts[PUSH_Table[index].seq_num-1].storage = (U8)MSG_FFS;
522 //Copy the FFS file index
523 PUSH_Sorted_Parts[PUSH_Table[index].seq_num-1].index = index;
524 //xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
525 //If the same seq number is already present in the repository, then this is a
526 //duplicate push message and needs to be discarded.
527 if((PUSH_Table[index].seq_num ==seq_num))
528 {
529 return DUPLICATE;
530 }
531 else
532 parts++;
533 }
534 //All parts found
535 if(parts == num_msgs)
536 return FOUND;
537 }
538 return NOT_FOUND;
539 }
540
541 /*******************************************************************************
542
543 $Function: AUI_store_PUSH_msg
544
545 $Description: Stores the new PUSH msg into FFS
546 //xrashmic 9 May, 2005 MMI-SPR-30159
547
548 $Returns:
549
550 $Arguments: message: Structure containing the udh and other msg details
551 msg_ref: Msg ref of the rcvd msg
552 num_msgs: total num of parts for the concat msgs
553 seq_num: Seq number of the rcvd msg
554
555 *******************************************************************************/
556 void AUI_store_PUSH_msg(T_MFW_SMS_MT *message, U16 msg_ref,U8 num_msgs,U8 seq_num)
557 {
558 int index=0;
559 char filename[40];
560 T_FFS_OPEN_FLAGS Ffsflags;
561 fd_t FfsFd;
562
563 //Locate a free space
564 for(index = 0 ; index < MAX_PUSH_MSG_STORAGE; index ++)
565 {
566 if(MSG_NONE == (int)PUSH_Table[index].msg_saved)
567 {
568 //Free space found
569 break;
570 }
571 }
572 //If space available in the reposiroty store it.
573 if( index < MAX_PUSH_MSG_STORAGE)
574 {
575 //Store the new msg part details into the table
576 PUSH_Table[index].msg_saved = (U8)MSG_FFS;
577 PUSH_Table[index].msg_ref = msg_ref;
578 PUSH_Table[index].num_msgs = num_msgs;
579 PUSH_Table[index].seq_num = seq_num;
580 PUSH_Table[index].year = message->sctp.year[0]*10+message->sctp.year[1];
581 PUSH_Table[index].month = message->sctp.month[0]*10+message->sctp.month[1];
582 PUSH_Table[index].day = message->sctp.day[0]*10+message->sctp.day[1];
583 AUI_store_PUSH_table();
584
585 //Save the msg part into a new file
586 sprintf(filename,"/mmi/concatwappush/push%d",index);
587 Ffsflags = FFS_O_WRONLY|FFS_O_CREATE;
588 FfsFd = ffs_open (filename, Ffsflags);
589 if(FfsFd > 0)
590 {
591 ffs_write(FfsFd,(void*)message,sizeof(T_MFW_SMS_MT));
592 ffs_close(FfsFd);
593 }
594 else
595 TRACE_EVENT("File open failed");
596 }
597 }
598
599 /*******************************************************************************
600
601 $Function: AUI_wap_mfw_cb
602
603 $Description: MFW callbacks
604 SPR#2086 - SH - Added
605
606 $Returns:
607
608 $Arguments: event - The event received
609
610 *******************************************************************************/
611 static int AUI_wap_mfw_cb(MfwEvt event, MfwHnd hnd)
612 {
613 T_WAP_DATA *data = AUI_wap_data();
614 T_MFW_SMS_MT *Message;
615 BOOL concatSMS = FALSE;
616 //xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
617 PUSHMSG_SEARCH_RESULT completeMsg = NOT_FOUND;
618 T_FFS_RET ffsResult;
619 U16 msg_ref;
620 U8 num_msgs, seq_num;
621 T_FFS_OPEN_FLAGS Ffsflags;
622 char filename[40];
623
624
625 #ifdef TRACE_AUIWAP
626 TRACE_FUNCTION("AUI_wap_mfw_cb()");
627 #endif
628
629 if (!data)
630 {
631 return;
632 }
633
634 switch(event)
635 {
636 case E_SMS_WAP_MT_RECEIVED:
637 {
638 Message = (T_MFW_SMS_MT *) hnd;
639 concatSMS = AUI_check_concat_msg(Message->udh,Message->udh_len, &msg_ref, &num_msgs, &seq_num);
640 if(concatSMS)
641 {
642 T_FFS_DIR dir;
643 ffsResult = ffs_opendir("/mmi/concatwappush",&dir);
644 if(EFFS_NOTFOUND == ffsResult)
645 //Directory does not exsists, create it and initialize the table and write it to FFS
646 AUI_ffs_PUSH_init();
647 else
648 //Read the table from ffs.
649 AUI_read_PUSH_table();
650
651 //Delete the old PUSH messages in FFS and update repository table
652 AUI_cleanup_PUSH_repository(msg_ref);
653
654 memset(PUSH_Sorted_Parts,0,sizeof(PUSH_Sorted_Parts));
655 //update the sorted Array with the new msg index
656 PUSH_Sorted_Parts[seq_num-1].storage = (U8)MSG_NEW;
657
658 //check for the complete message in repository and the new one.
659 //If present sort and update the index in the PUSH_Sorted_Parts.
660 completeMsg=AUI_check_repository( msg_ref,num_msgs,seq_num);
661
662 if(FOUND == completeMsg)
663 {
664 T_MFW_SMS_MT PUSH_Message;
665 U8 part = 0;
666 TRACE_EVENT("Complete Push msg found");
667 for( part = 0; part < num_msgs ; part++ )
668 {
669 //retrieve the complete message one by one in the correct order and send to wap client
670 switch( PUSH_Sorted_Parts[part].storage)
671 {
672 case MSG_NEW:
673 //copy new msg from hnd into the comon buffer
674 memcpy(&PUSH_Message,Message,sizeof(T_MFW_SMS_MT));
675 break;
676 case MSG_FFS:
677 {
678 //copy the stored msg from the ffs into the common buffer
679 fd_t FfsFd;
680 sprintf(filename,"/mmi/concatwappush/push%d",PUSH_Sorted_Parts[part].index);
681 Ffsflags = FFS_O_RDWR;
682 FfsFd = ffs_open (filename, Ffsflags);
683 ffs_read(FfsFd,(void*)&PUSH_Message,sizeof(T_MFW_SMS_MT));
684 ffs_close(FfsFd);
685 AUI_delete_PUSH_msg(PUSH_Sorted_Parts[part].index);
686 break;
687 }
688 }
689 //Send the msg part in the common buffer to the wap client
690 ATB_wap_push_SMS_received(
691 (char *)PUSH_Message.sc_addr,
692 (UBYTE)MFW_TON_INTERNATIONAL,
693 (char *)PUSH_Message.orig_addr.number,
694 (UBYTE)PUSH_Message.orig_addr.ton,
695 (char *)PUSH_Message.udh,
696 (ULONG)PUSH_Message.udh_len,
697 (char *)PUSH_Message.sms_msg,
698 (ULONG)PUSH_Message.msg_len);
699
700 }
701 }
702 //xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
703 //Store the new part into the ffs
704 else if(completeMsg == NOT_FOUND)
705 {
706 TRACE_EVENT("Storing the Push msg part to FFS");
707 //store this in push repository and update repository table
708 AUI_store_PUSH_msg(Message, msg_ref, num_msgs, seq_num);
709 }
710 else
711 {
712 //xrashmic 11 Jan, 2005 MMI-SPR-OMAPS00063638
713 //Duplicate part received , ignore/discard it.
714 TRACE_EVENT("Duplicate part received , ignore/discard it");
715 }
716 }
717 else
718 {
719 //Not a concat, so send it directly
720 ATB_wap_push_SMS_received(
721 (char *)Message->sc_addr,
722 (UBYTE)MFW_TON_INTERNATIONAL,
723 (char *)Message->orig_addr.number,
724 (UBYTE)Message->orig_addr.ton,
725 (char *)Message->udh,
726 (ULONG)Message->udh_len,
727 (char *)Message->sms_msg,
728 (ULONG)Message->msg_len);
729 }
730 break;
731 }
732 }
733 return;
734 }
735
736 /*******************************************************************************
737
738 $Function: AUI_wap_push_show
739
740 $Description: Push SI viewing screen
741 SPR#2086 - SH - Added
742
743 $Returns: void
744
745 $Arguments: Text - The text to be displayed
746 text_length - The length of the text to be displayed in Unicode chars
747 identifier - The ID of the SI
748 Url - The URL of the service
749 url_length - The length of the URL in characters
750
751 *******************************************************************************/
752 #if 0
753 void AUI_wap_push_show(USHORT *Text, USHORT text_length, SHORT identifier, char *Url, USHORT url_length)
754 {
755 T_WAP_DATA *data = AUI_wap_data();
756 T_EDITOR_DATA editor_data;
757
758 #ifdef TRACE_AUIWAP
759 TRACE_FUNCTION("AUI_wap_push_show");
760 #endif
761
762 if (!data)
763 {
764 return;
765 }
766
767 if (!data->PushData)
768 {
769 return;
770 }
771
772 strncpy(data->Buffer, Url, url_length); /* Store URL here for now */
773 data->Buffer[url_length] = 0;
774
775 data->PushData->service_indication = identifier;
776
777 AUI_wap_string_alloc(&data->Message, TEXT_MAX_LEN);
778
779 if (text_length>=TEXT_MAX_LEN)
780 {
781 text_length = TEXT_MAX_LEN-1;
782 }
783
784 data->Message.text[0] = 0x7F80;
785 ATB_uc_text_copy(&data->Message.text[1], Text, text_length);
786 ATB_uc_text_convert(&data->Message.text[1], text_length);
787
788 AUI_standard_editor(&editor_data, (char *)data->Message.text, text_length+1, READ_ONLY_MODE, (T_EDIT_CB)AUI_wap_push_show_cb); // Setup standard editor
789
790 editor_data.destroyEditor = TRUE;
791 editor_data.TextId = TxtMessage; // Prompt to display above editor
792 editor_data.LeftSoftKey = TxtGoTo;
793 editor_data.RightSoftKey = TxtExit;
794 data->edit_win = editor_start(data->parent_win,&editor_data); /* SPR#2086 */
795
796 return;
797 }
798 #endif
799
800 void AUI_wap_push_show(USHORT *Text, USHORT text_length, SHORT identifier, char *Url, USHORT url_length)
801 {
802 T_WAP_DATA *data = AUI_wap_data();
803 #ifdef NEW_EDITOR
804 T_AUI_EDITOR_DATA editor_data;
805 #else
806 T_EDITOR_DATA editor_data;
807 #endif /* NEW_EDITOR */
808
809 #ifdef TRACE_AUIWAP
810 TRACE_FUNCTION("AUI_wap_push_show");
811 #endif
812
813 if (!data)
814 {
815 return;
816 }
817
818 if (!data->PushData)
819 {
820 return;
821 }
822
823 strncpy(data->Buffer, Url, url_length); /* Store URL here for now */
824 data->Buffer[url_length] = 0;
825
826 data->PushData->service_indication = identifier;
827
828 AUI_wap_string_alloc(&data->Message, TEXT_MAX_LEN);
829
830 if (text_length>=TEXT_MAX_LEN)
831 {
832 text_length = TEXT_MAX_LEN-1;
833 }
834
835 data->Message.text[0] = 0x7F80;
836 ATB_uc_text_copy(&data->Message.text[1], Text, text_length);
837 ATB_uc_text_convert(&data->Message.text[1], text_length);
838 #if 0
839 AUI_standard_editor(&editor_data, (char *)data->Message.text, text_length+1, READ_ONLY_MODE, (T_EDIT_CB)AUI_wap_push_show_cb); // Setup standard editor
840
841 editor_data.destroyEditor = TRUE;
842 editor_data.TextId = TxtMessage; // Prompt to display above editor
843 editor_data.LeftSoftKey = TxtGoTo;
844 editor_data.RightSoftKey = TxtExit;
845 data->edit_win = editor_start(data->parent_win,&editor_data); /* SPR#2086 */
846 #endif
847
848 #ifdef NEW_EDITOR
849 // xreddymn Jan-10-2005 MMI-SPR-27618: Modified editor to read-only
850 AUI_standard_editor(&editor_data, WAP_EDIT_DOWNLOAD, ED_MODE_ALPHA | ED_MODE_READONLY, TxtPushMessages, (T_AUI_EDIT_CB)AUI_wap_push_show_cb);
851 editor_data.RightSoftKey = TxtSoftBack;
852
853 // if (unicode)
854 /* xreddymn Jan-10-2005 MMI-SPR-27618:
855 * data->Buffer holding the URL in this case is ASCII. Changed condition if(TRUE) to if(FALSE)
856 */
857 if (FALSE)
858 {
859 AUI_edit_SetBuffer(&editor_data, ATB_DCS_UNICODE, (UBYTE *)data->Buffer, strlen(data->Buffer)+1);
860 }
861 else
862 {
863 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)data->Buffer, strlen(data->Buffer)+1);
864 }
865
866 //data->edit_win = AUI_edit_Start(data->win, &editor_data);
867 data->edit_win = AUI_edit_Start(data->parent_win, &editor_data);
868 #else /* NEW_EDITOR */
869 AUI_standard_editor(&editor_data, (char *)data->Message.text, text_length+1, READ_ONLY_MODE, (T_EDIT_CB)AUI_wap_push_show_cb); // Setup standard editor
870
871 editor_data.destroyEditor = TRUE;
872 editor_data.TextId = TxtMessage; // Prompt to display above editor
873 editor_data.LeftSoftKey = TxtGoTo;
874 editor_data.RightSoftKey = TxtExit;
875 data->edit_win = editor_start(data->parent_win,&editor_data); /* SPR#2086 */
876 #endif /* NEW_EDITOR */
877 return;
878 }
879
880 /*******************************************************************************
881
882 $Function: AUI_wap_push_show_cb
883
884 $Description: Callback function for push viewing screen.
885 SPR#2086 - SH - Added
886
887 $Returns: void
888
889 $Arguments: win - the WAP data window
890 identifier - identifier
891 reason - reason for callback
892
893 *******************************************************************************/
894
895 static void AUI_wap_push_show_cb(T_MFW_HND win, USHORT identifier, USHORT reason)
896 {
897 T_WAP_DATA *data = AUI_wap_data();
898 T_WAP_VIEW *View;
899
900 #ifdef TRACE_AUIWAP
901 TRACE_FUNCTION("AUI_wap_push_show_cb");
902 #endif
903
904 if (!data)
905 {
906 return;
907 }
908
909 /* Editor is destroyed automatically */
910
911 // xreddymn Jan-10-2005 MMI-SPR-27618: Modified to add "back" function to this screen
912 // data->edit_win = NULL;
913
914 /* Free message text */
915
916 AUI_wap_string_free(&data->Message);
917
918 switch (reason)
919 {
920 case INFO_KCD_LEFT:
921
922 // xreddymn Jan-10-2005 MMI-SPR-27618: Leave editor screen when HangUp or Right Softkey is pressed
923 AUI_destroy(EDIT_WIN);
924
925 /* Check if browsing view exists. If it doesn't, start WAP for
926 * browsing and load SI on callback */
927
928 View = ATB_wap_get_view(WAP_OBJECT_ID);
929
930 if (!View)
931 {
932 AUI_wap_start(WAP_BROWSER, AUI_wap_push_start_load_SI);
933 }
934 else
935 {
936 AUI_wap_push_start_load_SI(TRUE);
937 }
938 break;
939
940 // xreddymn Jan-10-2005 MMI-SPR-27618: Leave editor screen when HangUp or Right Softkey is pressed
941 case INFO_KCD_HUP:
942 case INFO_KCD_RIGHT:
943 AUI_destroy(EDIT_WIN);
944 break;
945 }
946
947 return;
948 }
949
950 /*******************************************************************************
951
952 $Function: AUI_wap_push_load_SL
953
954 $Description: Loads SL message by launching WAP
955
956 $Returns: void
957
958 $Arguments: identifier - an integer used to identify the SL message
959 Url - URL to which the WAP browser must be launched into
960 url_length - length of the URL in characters
961
962 xreddymn Mar-16-2005 MMI-SPR-29767
963
964 *******************************************************************************/
965
966 void AUI_wap_push_load_SL(SHORT identifier, char *Url, USHORT url_length)
967 {
968 T_WAP_VIEW *View;
969 T_WAP_DATA *data = AUI_wap_data();
970
971 #ifdef TRACE_AUIWAP
972 TRACE_FUNCTION("AUI_wap_push_load_SL");
973 #endif
974
975 if (!data)
976 {
977 return;
978 }
979
980 if (!data->PushData)
981 {
982 return;
983 }
984
985 // The URL is stored in data->Buffer and accessed by
986 // AUI_wap_push_start_load_SI
987 strncpy(data->Buffer, Url, url_length);
988 data->Buffer[url_length] = 0;
989
990 data->PushData->service_indication = identifier;
991
992 // Check if browsing view exists. If it doesn't, start WAP for
993 // browsing and load SL on callback.
994
995 View = ATB_wap_get_view(WAP_OBJECT_ID);
996
997 if (!View)
998 {
999 AUI_wap_start(WAP_BROWSER, AUI_wap_push_start_load_SI);
1000 }
1001 else
1002 {
1003 AUI_wap_push_start_load_SI(TRUE);
1004 }
1005 }
1006
1007 /*******************************************************************************
1008
1009 $Function: AUI_wap_push_start_load_SI
1010
1011 $Description: Callback function for starting push and loading an SI
1012 SPR#2086 - SH - Added
1013
1014 $Returns: void
1015
1016 $Arguments: result - TRUE if WAP started successfully.
1017
1018 *******************************************************************************/
1019
1020 static void AUI_wap_push_start_load_SI(UBYTE result)
1021 {
1022 T_WAP_DATA *data = AUI_wap_data();
1023
1024 #ifdef TRACE_AUIWAP
1025 TRACE_FUNCTION("AUI_wap_push_start_load_SI");
1026 #endif
1027
1028 if (!data || !result)
1029 {
1030 return;
1031 }
1032
1033 /* Create menu */
1034
1035 if (!data->menu_win)
1036 {
1037 AUI_menu_create(TRUE);
1038 }
1039
1040 /* Configure for connection */
1041
1042 AUI_prepare_to_connect();
1043
1044 /* Copy URL into View storage */
1045
1046 strcpy(data->View->URL, data->Buffer);
1047
1048 /* Load Service Indication */
1049
1050 ATB_wap_push_load_SI(data->View, (SHORT)data->PushData->service_indication);
1051
1052 return;
1053 }
1054
1055
1056 /*******************************************************************************
1057
1058 $Function: AUI_wap_push_list
1059
1060 $Description: Lists all push messages
1061
1062 $Returns: MFW_EVENT_CONSUMED
1063
1064 $Arguments: menu - pointer to current menu
1065 item - pointer to current menu item
1066
1067 *******************************************************************************/
1068
1069 int AUI_wap_push_list(MfwMnu* menu, MfwMnuItem* item)
1070 {
1071 T_WAP_DATA *data = AUI_wap_data();
1072 USHORT entryIndex;
1073
1074 #ifdef TRACE_AUIWAP
1075 TRACE_FUNCTION("AUI_wap_push_list");
1076 #endif
1077
1078 if (!data)
1079 {
1080 return;
1081 }
1082
1083 if (!data->PushData)
1084 {
1085 TRACE_EVENT("***ERROR - Push not initialised ***");
1086 return;
1087 }
1088
1089 /* Create the push list menu */
1090
1091 if (data->PushData->List==NULL)
1092 {
1093 // xreddymn Jan-10-2005 MMI-SPR-27618: Use WAP_PUSH_TITLE_MAX_LEN instead of CARD_TITLE_MAX_LEN
1094 data->PushData->List = ATB_wap_entry_list_create(WAP_PUSH_LIST, WAP_PUSH_MAX_MESSAGES, WAP_PUSH_TITLE_MAX_LEN, FALSE);
1095 for (entryIndex=0; entryIndex<WAP_PUSH_MAX_MESSAGES; entryIndex++)
1096 {
1097 data->PushData->List->Entry[entryIndex] = (char *)AUI_wap_memory_alloc(data->PushData->List->entry_size);
1098 }
1099 }
1100
1101 data->PushData->list_created = FALSE;
1102 memset(data->PushData->list_ids, 0, WAP_PUSH_MAX_MESSAGES);
1103
1104 AUI_please_wait(data->parent_win);
1105
1106 ATB_wap_push_get_SI_info(-1, WAP_PUSH_SHOW_ALL);
1107
1108 return MFW_EVENT_CONSUMED;
1109 }
1110
1111
1112 /*******************************************************************************
1113
1114 $Function: AUI_wap_push_list_display
1115
1116 $Description: The list of pushed messages is ready; display it
1117
1118 $Returns: None
1119
1120 $Arguments: None
1121
1122 *******************************************************************************/
1123
1124 void AUI_wap_push_list_display()
1125 {
1126 T_WAP_DATA *data = AUI_wap_data();
1127
1128 #ifdef TRACE_AUIWAP
1129 TRACE_FUNCTION("AUI_wap_push_list_display");
1130 #endif
1131
1132 if (!data)
1133 {
1134 return;
1135 }
1136
1137 AUI_entry_list(data->PushData->List, (ListCbFunc) AUI_wap_push_list_cb, 0);
1138 if (!data->list_win || data->PushData->List->no_of_entries==0)
1139 {
1140 AUI_wap_push_list_destroy();
1141 }
1142 else
1143 {
1144 data->PushData->list_created = TRUE;
1145 }
1146
1147 return;
1148 }
1149
1150
1151 /*******************************************************************************
1152
1153 $Function: AUI_wap_push_list_destroy
1154
1155 $Description: Destroy the push message list
1156
1157 $Returns: None
1158
1159 $Arguments: None
1160
1161 *******************************************************************************/
1162
1163 void AUI_wap_push_list_destroy()
1164 {
1165 T_WAP_DATA *data = AUI_wap_data();
1166 USHORT entryIndex;
1167
1168 #ifdef TRACE_AUIWAP
1169 TRACE_FUNCTION("AUI_wap_push_list_destroy");
1170 #endif
1171
1172 if (!data)
1173 {
1174 return;
1175 }
1176
1177 if (!data->PushData)
1178 {
1179 return;
1180 }
1181
1182 if (!data->PushData->List)
1183 {
1184 return;
1185 }
1186
1187 /* Create the push list menu */
1188
1189 for (entryIndex=0; entryIndex<WAP_PUSH_MAX_MESSAGES; entryIndex++)
1190 {
1191 AUI_wap_memory_free((void *)data->PushData->List->Entry[entryIndex], data->PushData->List->entry_size);
1192 }
1193 ATB_wap_entry_list_destroy(data->PushData->List);
1194
1195 data->PushData->List = NULL;
1196 data->PushData->list_created = FALSE;
1197
1198 return;
1199 }
1200
1201
1202 /*******************************************************************************
1203
1204 $Function: AUI_wap_push_list_cb
1205
1206 $Description: Callback for push message list
1207
1208 $Returns: MFW_EVENT_CONSUMED
1209
1210 $Arguments: win - The current window
1211 ListMenuData - The current list data
1212
1213 *******************************************************************************/
1214
1215 static void AUI_wap_push_list_cb(T_MFW_HND win, ListMenuData *EntryListData)
1216 {
1217 T_WAP_DATA *data = AUI_wap_data();
1218
1219 TRACE_FUNCTION("AUI_wap_push_list_cb()");
1220
1221 if (!data)
1222 {
1223 return;
1224 }
1225
1226 data->PushData->service_indication = data->PushData->list_ids[EntryListData->ListPosition];
1227
1228 switch(EntryListData->Reason)
1229 {
1230 case LISTS_REASON_SEND:
1231 ATB_wap_push_get_SI_info(data->PushData->service_indication, 0);
1232 break;
1233
1234 case LISTS_REASON_SELECT:
1235 /* Destroy any previous options menu existing */
1236 if (data->options_win)
1237 {
1238 AUI_destroy(OPTIONS_WIN);
1239 }
1240 //#ifdef MMI_WAP_PUSH_ENABLED //added by ellen
1241 //data->options_win = bookMenuStart(data->parent_win, WAPPushListOptionsAttributes(), 0);
1242 data->options_win = bookMenuStart(data->parent_win, WAPPushListOptionsAttributes(), 0);
1243 //#endif
1244 SEND_EVENT(data->options_win, ADD_CALLBACK, NULL, (void *)AUI_options_cb);
1245 break;
1246
1247 case LISTS_REASON_BACK:
1248 AUI_wap_push_list_destroy();
1249 AUI_destroy(LIST_WIN);
1250 break;
1251 }
1252
1253 return;
1254 }
1255
1256
1257 /*******************************************************************************
1258
1259 $Function: AUI_wap_push_info
1260
1261 $Description: Response from WAP Browser, returning information about a push message
1262
1263 $Returns: MFW_EVENT_CONSUMED
1264
1265 $Arguments: menu - pointer to current menu
1266 item - pointer to current menu item
1267
1268 *******************************************************************************/
1269
1270 void AUI_wap_push_info(
1271 USHORT *Text,
1272 USHORT text_length,
1273 SHORT id,
1274 char *Url,
1275 USHORT url_length,
1276 UBYTE status,
1277 ULONG created,
1278 BOOL expired,
1279 UBYTE priority)
1280 {
1281 T_WAP_DATA *data = AUI_wap_data();
1282 char *newURL;
1283
1284 TRACE_FUNCTION("AUI_wap_push_info()");
1285
1286 if (!data)
1287 {
1288 return;
1289 }
1290
1291 if (!data->PushData)
1292 {
1293 return;
1294 }
1295
1296 if (!data->PushData->List)
1297 {
1298 return;
1299 }
1300
1301 /* If list is created and we're reading a single SI */
1302
1303 if (data->PushData->list_created)
1304 {
1305 AUI_please_wait_destroy();
1306 AUI_wap_push_show(Text, text_length, id, Url, url_length);
1307 return;
1308 }
1309
1310 /* If all of list has been sent, create the menu*/
1311
1312 if (id==-1)
1313 {
1314 AUI_please_wait_destroy();
1315 AUI_wap_push_list_display();
1316 }
1317
1318 else
1319 /* Otherwise, add the menu item to the list */
1320 {
1321 data->PushData->list_ids[data->PushData->List->no_of_entries] = id;
1322
1323 newURL = (char *)AUI_wap_memory_alloc(url_length+1);
1324 strncpy(newURL, Url, url_length);
1325 newURL[url_length] = 0;
1326
1327 if (url_length>data->PushData->List->entry_size)
1328 {
1329 newURL[data->PushData->List->entry_size] = 0;
1330 newURL[data->PushData->List->entry_size-1] = '.';
1331 newURL[data->PushData->List->entry_size-2] = '.';
1332 }
1333
1334 ATB_wap_entry_add(data->PushData->List, newURL);
1335
1336 AUI_wap_memory_free((void *)newURL, url_length+1);
1337 }
1338
1339 return;
1340 }
1341
1342 /*******************************************************************************
1343
1344 $Function: AUI_wap_push_message_read
1345
1346 $Description: Read a push message
1347 SPR#2086 - Added
1348
1349 $Returns: MFW_EVENT_CONSUMED
1350
1351 $Arguments: menu - pointer to current menu
1352 item - pointer to current menu item
1353
1354 *******************************************************************************/
1355
1356 int AUI_wap_push_message_read(MfwMnu* menu, MfwMnuItem* item)
1357 {
1358 T_WAP_DATA *data = AUI_wap_data();
1359
1360 TRACE_FUNCTION("AUI_wap_push_message_read()");
1361
1362 if (!data)
1363 {
1364 return;
1365 }
1366
1367 if (!data->PushData)
1368 {
1369 return;
1370 }
1371
1372 ATB_wap_push_get_SI_info(data->PushData->service_indication, 0);
1373
1374 return MFW_EVENT_CONSUMED;
1375 }
1376
1377
1378 /*******************************************************************************
1379
1380 $Function: AUI_wap_push_message_delete
1381
1382 $Description: Delete a push message
1383 SPR#2086 - Added
1384
1385 $Returns: MFW_EVENT_CONSUMED
1386
1387 $Arguments: menu - pointer to current menu
1388 item - pointer to current menu item
1389
1390 *******************************************************************************/
1391
1392 int AUI_wap_push_message_delete(MfwMnu* menu, MfwMnuItem* item)
1393 {
1394 T_WAP_DATA *data = AUI_wap_data();
1395
1396 TRACE_FUNCTION("AUI_wap_push_message_delete()");
1397
1398 if (!data)
1399 {
1400 return;
1401 }
1402
1403 /* Delete the push message */
1404 ATB_wap_push_delete_SI(data->PushData->service_indication, 0);
1405 /* Destroy the old list */
1406 AUI_destroy(LIST_WIN);
1407 /* Save the change */
1408 ATB_wap_push_save_to_flash();
1409 /* Recreate the list */
1410 AUI_list_redraw(WAP_PUSH_LIST, TxtDeleted);
1411
1412 return MFW_EVENT_CONSUMED;
1413 }
1414
1415
1416 /*******************************************************************************
1417
1418 $Function: AUI_wap_push_showmessages
1419
1420 $Description: Setting specifies whether or not to display received push images
1421 SPR#2086 - Added
1422
1423 $Returns: MFW_EVENT_CONSUMED
1424
1425 $Arguments: menu - pointer to current menu
1426 item - pointer to current menu item
1427
1428 *******************************************************************************/
1429
1430 int AUI_wap_push_showmessages(MfwMnu* menu, MfwMnuItem* item)
1431 {
1432 T_WAP_DATA *data = AUI_wap_data();
1433 UBYTE PushMessages;
1434 T_MFW_HND setting_win;
1435
1436 #ifdef TRACE_AUIWAP
1437 TRACE_FUNCTION("AUI_wap_push_showmessages");
1438 #endif
1439
1440 if (!data)
1441 {
1442 return;
1443 }
1444
1445 setting_win = bookMenuStart(data->parent_win, WAPPushMessagesAttributes(), 0);
1446 PushMessages = ATB_wap_profile_setting(WAP_STATUS_PUSHMESSAGES); // 1 or 0 depending on flag
1447 SEND_EVENT(setting_win, DEFAULT_OPTION, NULL, &PushMessages); // Add our own callback
1448
1449 return 1;
1450 }
1451
1452
1453 /*******************************************************************************
1454
1455 $Function: AUI_wap_push_showmessages_set
1456
1457 $Description: Set showing of push messages on or off
1458
1459 $Returns: MFW_EVENT_CONSUMED
1460
1461 $Arguments: menu - pointer to the current menu
1462 item - pointer to the current menu item
1463
1464 *******************************************************************************/
1465
1466 int AUI_wap_push_showmessages_set(MfwMnu* menu, MfwMnuItem* item)
1467 {
1468 T_WAP_DATA *data = AUI_wap_data();
1469
1470 #ifdef TRACE_AUIWAP
1471 TRACE_FUNCTION("AUI_wap_push_showmessages_set");
1472 #endif
1473
1474 if (!data)
1475 {
1476 return;
1477 }
1478
1479 ATB_wap_profile_setting_change(WAP_STATUS_PUSHMESSAGES, menu->lCursor[menu->level]); /* SPR#2086 */
1480
1481 ATB_wap_profile_save(data->View); // Save change to flash
1482 AUI_info_dialog(TxtChanged, NULL); /* SPR#2086 */
1483
1484 return 1;
1485 }
1486