comparison src/ui3/bmi/mmiSmsBroadcast.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1
2 /*******************************************************************************
3
4 CONDAT (UK)
5
6 ********************************************************************************
7
8 This software product is the property of Condat (UK) Ltd and may not be
9 disclosed to any third party without the express permission of the owner.
10
11 ********************************************************************************
12
13 $Project name: Basic MMI
14 $Project code: BMI (6349)
15 $Module: SMS Cell Broadcast
16 $File: MmiSmsBroadcast.c
17 $Revision: 1.0
18
19 $Author: Condat(UK)
20 $Date: 22/02/01
21
22 ********************************************************************************
23
24 Description:
25
26 Implementation of MMI SMS Cell Broadcast dynamic menu handling
27
28 ********************************************************************************
29
30 $History: MmiSmsBroadcast.c
31 Feb 16, 2007 REF: OMAPS00116175 x0pleela
32 Description: [MMI] Not possible to store CB settings CBSC with +CSAS and +CRES
33 Solution: In function smscb_getCBsettings(), changed the incremental value from 2 to 1 as the
34 successive CB parameters ( message id) was getting skipped while reading back from
35 cell broadcast parameters
36
37 Nov 14, 2006 REF: OMAPS00099394 x0039928
38 Description: TC2.1.51(BMI/MFW) - SMS - Read Broadcast message fails
39 Solution: On press of back key in the message editor, it is directly taken out to the menu
40 instead of recreating the list.
41
42 Dec 22, 2004 REF: CRR MFW-SPR-27847 xnkulkar
43 Description: MFW memory size variable changed from U16 -> U32
44 Solution: In function 'smscb_setCBsettings' variable 'd' is checked for limit and
45 duplication is removed. This was the reason for crash.
46
47 Aug 16, 2004 REF: CRR 24323 Deepa M.D
48 Bug:Clenup of sprintf used for tracing
49 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX
50
51 25/10/00 Original Condat(UK) BMI version.
52 Issue Number : SPR#12722 on 29/03/04 by Deepa M.D
53 Apr 29, 2004 REF: CRR 11630 Deepa M.D
54 Fix:When a new entry channelId is added ,the whole list of channelIds are refreshed,
55 and the corresponding names are displayed in the list.
56
57 $End
58 *******************************************************************************/
59
60
61 /*******************************************************************************
62
63 Include Files
64
65 *******************************************************************************/
66
67 #define ENTITY_MFW
68
69 /* includes */
70 #include <string.h>
71 #include <stdio.h>
72 #include <stdlib.h>
73
74 #include "typedefs.h"
75 #include "vsi.h"
76 #include "pei.h"
77 #include "custom.h"
78 #include "gsm.h"
79
80 #include "custom.h"
81 #include "gsm.h"
82 #include "vsi.h"
83 #include "prim.h"
84 #include "mfw_sys.h"
85 #include "mfw_mfw.h"
86 #include "mfw_win.h"
87 #include "mfw_kbd.h"
88 /* SPR#1428 - SH - New Editor changes */
89 #ifndef NEW_EDITOR
90 #include "mfw_edt.h"
91 #endif
92 #include "mfw_lng.h"
93 #include "mfw_icn.h"
94 #include "mfw_phb.h"
95 #include "mfw_sim.h"
96 #include "mfw_nm.h"
97 #include "ksd.h"
98 #include "psa.h"
99 #include "mfw_sms.h"
100 #include "mfw_mnu.h"
101 #include "mfw_sat.h"
102 #include "mfw_tim.h"
103
104 #include "MmiMmi.h"
105 #include "MmiDummy.h"
106 #include "MmiDialogs.h"
107 #include "MmiLists.h"
108
109 #include "MmiMain.h"
110 #include "MmiStart.h"
111 #include "MmiPins.h"
112 #include "MmiMenu.h"
113 #include "MmiSoftKeys.h"
114
115 #include "MmiBookController.h"
116
117 #include "mmiSmsBroadcast.h"
118 #include "mmiSmsIdle.h"
119 /* SPR#1428 - SH - New Editor changes */
120 #ifdef NEW_EDITOR
121 #include "ATBCommon.h"
122 #include "ATBDisplay.h"
123 #include "ATBEditor.h"
124 #include "AUIEditor.h"
125 #else
126 #include "MmiEditor.h"
127 #endif
128 #include "MmiIdle.h"
129
130 #include "cus_aci.h"
131
132 #include "mmiColours.h"
133
134 /* BEGIN ADD: Sumit : Req ID: : 31-Mar-2005*/
135 #ifndef NEPTUNE_BOARD
136 /* END ADD: Sumit : Req ID: : 31-Mar-2005*/
137 #include "ffs/ffs.h" /*SPR 1920*/
138 /* BEGIN ADD: Sumit : Req ID: : 31-Mar-2005*/
139 #else
140 #include "ffs.h"
141 #endif
142 /* END ADD: Sumit : Req ID: : 31-Mar-2005*/
143
144 #ifdef DEBUG_SMS_CB
145 #include "MmiHomezone.h"
146 #endif
147 #include "MmiSettings.h"
148
149
150
151 #define MENU_TEXT_LENGTH 16 /* count of chars to be displayed in one list entry */
152
153 /* SH - moved to .h file */
154
155 /*MC SPR 1920,FFS CB Topic name data structure*/
156 typedef struct
157 {
158 uint8 name[CB_TAG_LENGTH];
159
160 } T_SMSCB_TOPIC_TAG;
161
162 /* storage for Cell Broadcast lists */
163 typedef struct
164 {
165 T_SMSCB_ATT cb_attributes[MAX_MIDS]; /* list of attributes of messages stored in fifo */
166 /*SPR 1920, replaced cb_buffer with an array of dynically allocated strings */
167 char* messages[MAX_STORED_PAGES];
168 ListMenuData *cb_list_attributes; //atttributes for the menu list
169
170 T_SMSCB_STATUS current_status; /*read status for all messages */
171
172 UBYTE found_mid; //indicate the already existing cb in the fifo
173 UBYTE clear_mid; //indicate the deleting process
174 UBYTE result_used; //to update the used-pointer, after deleting the cb message
175 UBYTE total_number; //this include the total number of messages in the fifo; need for Menu-list
176
177 UBYTE multipage_number; //this include the total page of a particular multipage; need for showing msg.
178 UBYTE *multipage; //pointer to the first page of multipage
179 UBYTE start_used; //indicate the start point of the multipage, used for the searching
180 UBYTE end_used; //indicate the end point of the multipage, used for the searching
181
182 UBYTE used_pointer; //start point of the free space link list
183 UBYTE free_pointer; //start point of the data link list
184
185
186 } T_SMSCB_DATA;
187
188
189
190 T_SMSCB_DATASTORE g_smscb_data; /* storage for Cell Broadcast Info lists */
191 T_SMSCB_DATA smscb_data; /* storage for Cell Broadcast Message lists */
192
193
194
195 //Attributes of the list menu
196 static const MfwMnuAttr sms_cb_menuAttrib =
197 {
198 &smscb_M_CBArea,
199 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
200 /* x0045876, 14-Aug-2006 (WR - integer conversion resulted in a change of sign) */
201 (U8) -1, /* use default font */
202 NULL, /* with these items */
203 0, /* number of items */
204 COLOUR_LIST_SMS, TxtNull, NULL, MNUATTRSPARE
205
206 };
207
208
209 #define OFFSET(index) (index*CB_PAGE_LENGTH)
210
211 //this shows traces of some variable
212 //#define DEBUG_SMS_CB
213
214 #ifdef DEBUG_SMS_CB
215 UBYTE DEBUG;
216 #endif
217
218 char* ffs_cb_tag_name(int channel_num, char* name);/*SPR1920, new function header*/
219 //these prototypes belongs to saving cb_messages in the fifo
220 UBYTE sms_cb_count_messages ( void );
221 UBYTE sms_cb_count_unread_messages ( void );
222 UBYTE sms_cb_delete_message (USHORT mid);
223 UBYTE sms_cb_find_termination (UBYTE *used);
224 UBYTE sms_cb_update_free_pointer (UBYTE temp);
225 UBYTE sms_cb_search_mid (USHORT mid, SHORT sn);
226 UBYTE sms_cb_store_message (T_MFW_SMS_CB *Message);
227 UBYTE sms_cb_find_endpoint (USHORT mid, UBYTE end_used);
228 UBYTE sms_cb_find_startpoint (USHORT mid, UBYTE end_used);
229 UBYTE sms_cb_give_position_of_msg (UBYTE used, UBYTE positon);
230 UBYTE sms_cb_overwrite_old_message (T_MFW_SMS_CB *Message);
231
232
233 void sms_cb_show_cb_message(UBYTE link_list_position);
234 static ListMenuData * sms_cb_create_list (UBYTE number);
235 /*SPR 1920, removed header for function sms_cb_select_read*/
236 static void sms_cb_list_cb(T_MFW_HND win, ListMenuData * ListData);
237 void sms_cb_store_attributes (UBYTE position, T_MFW_SMS_CB *Message);
238 static void sms_cb_editor_cb (T_MFW_HND win, USHORT Identifier, SHORT reason);
239
240 /* SPR#1428 - SH - New Editor changes */
241 #ifdef NEW_EDITOR
242 void sms_cb_loadEditDefault (T_AUI_EDITOR_DATA *editor_data);
243 #else /* NEW_EDITOR */
244 void sms_cb_loadEditDefault (T_EDITOR_DATA *editor_data);
245 #endif /* NEW_EDITOR */
246
247 /*********************************************************************
248 **********************************************************************
249
250 cell broadcast declaration
251
252 *********************************************************************
253 **********************************************************************/
254
255 typedef struct
256 {
257 int index; /* index of selected item in list */
258 } T_CB_index_param;
259
260 typedef struct
261 {
262 int index; /* index of selected item in list */
263 char name[CB_TAG_LENGTH]; /* buffer for name to be associated with topic */
264 char number[CB_MID_LENGTH]; /* buffer for channel number of topic */
265 } T_CB_EDT_MIDEDT_param;
266
267 typedef struct
268 {
269 int index; /* index of selected item in list */
270 char text[CB_TAG_LENGTH]; /* buffer for name to be associated with topic ??? size is dummy */
271 char number[CB_MID_LENGTH]; /* buffer for channel number of topic ??? size is dummy */
272 } T_S_param; /* ??? T_S_param not to be defined here, but in "mmiSmsSend.h"! */
273
274
275 /* IDs used for identification of sources of events */
276 enum {
277 smscb_M_CB_ID,
278 smscb_M_CB_ACT_ID,
279 smscb_M_CB_TOP_ID,
280 smscb_M_CB_TOP_CONS_ID,
281 smscb_M_CB_TOP_CONS_SEL_ID,
282 smscb_CB_ID,
283 smscb_CB_TEXTEDT_ID,
284 smscb_CB_OPT_ID,
285 smscb_CB_OPT_DEL_NOACK_ID,
286 smscb_CB_EDT_TEXTEDT_ID,
287 smscb_CB_EDT_MIDEDT_ID
288 } smscb_ID;
289
290
291
292 void msgsExtractPhoneNumber(UBYTE *InputString, UBYTE *Buffer);
293 /* forward declaration of local start routines */
294 /*SPR 1920 removed header for smscb_M_CB_ACT_start()*/
295 static T_MFW_HND smscb_M_CB_TOP_start(T_MFW_HND parent_window, void *dummy);
296 static T_MFW_HND smscb_M_CB_TOP_CONS_start(T_MFW_HND parent_window, void *dummy);
297 static T_MFW_HND smscb_M_CB_TOP_CONS_SEL_start(T_MFW_HND parent_window, T_CB_index_param * parameter);
298 static T_MFW_HND smscb_CB_start(T_MFW_HND parent_window, void *dummy);
299 static T_MFW_HND smscb_CB_TEXTEDT_start(T_MFW_HND parent_window, T_CB_index_param * parameter);
300 static T_MFW_HND smscb_CB_OPT_start(T_MFW_HND parent_window, T_CB_index_param * parameter);
301 static T_MFW_HND smscb_CB_OPT_DEL_NOACK_start(T_MFW_HND parent_window, T_CB_index_param * parameter);
302 static T_MFW_HND smscb_CB_EDT_TEXTEDT_start(T_MFW_HND parent_window, T_CB_index_param * parameter);
303 static T_MFW_HND smscb_CB_EDT_MIDEDT_start(T_MFW_HND parent_window, T_CB_EDT_MIDEDT_param * parameter);
304
305
306 void info_screen (T_MFW_HND win, USHORT TextId, USHORT TextId2, T_VOID_FUNC Callback)
307 /* present info <TextId> for 3 seconds in a simple infoscreen */
308 {
309
310 T_DISPLAY_DATA display_info;
311
312 TRACE_FUNCTION ("info_screen()");
313
314 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TextId, TextId2 , COLOUR_STATUS);
315 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)Callback, THREE_SECS, 0 );
316 display_info.Identifier = 0;
317
318 info_dialog (win, &display_info);
319 }
320
321 /*********************************************************************
322 **********************************************************************
323
324 cell broadcast routines DECLARATION
325
326 *********************************************************************
327 **********************************************************************/
328 static T_MFW smscb_delete_topic(UBYTE MidOffset);
329 /*SPR 1920, removed function temp_smscb_M_CB_ExeRead()*/
330 /* SH moved prototype to header file */
331
332 #if(0) /* x0039928 - Lint warning removal */
333 static void listCreate(MfwHnd Parent, MfwMnuAttr *a , MfwEvt e, ListCbFunc cbFunc)
334 {
335
336 ListMenuData list_menu_data;
337
338 /* initialization of the dialog data */
339 list_menu_data.Attr = a;
340 list_menu_data.List = a->items;
341 list_menu_data.ListLength = a->nItems;/* Number of entries in list menu. */
342 list_menu_data.ListPosition = 1;/* True cursor position in list menu. */
343 list_menu_data.CursorPosition = 1;/* Cursor position in list snapshot. */
344 list_menu_data.SnapshotSize = 4;/* Number of list entries to view. */
345 list_menu_data.Font = 0;
346 list_menu_data.LeftSoftKey = TxtSoftSelect;
347 list_menu_data.RightSoftKey = TxtSoftBack;
348 /* SPR1428 - SH - Accept menu select key */
349 list_menu_data.KeyEvents = KEY_CLEAR | KEY_RIGHT | KEY_LEFT | KEY_MNUUP | KEY_MNUDOWN | KEY_MNUSELECT;
350 list_menu_data.Reason = 0;
351 list_menu_data.Strings = FALSE;
352 list_menu_data.autoDestroy = TRUE;
353
354 listDisplayListMenu(Parent, &list_menu_data, cbFunc,0);
355
356 }
357 #endif
358 // end c020 rsa
359 /*SPR1920, removed declarations and functions for menu-handling*/
360
361
362
363
364 /*********************************************************************
365 **********************************************************************
366
367 M_CB_ACT DYNAMIC MENU WINDOW. CONTENTS BEHAVIOUR
368
369 *********************************************************************
370 **********************************************************************/
371 /*******************************************************************************
372
373 $Function: smscb_M_CB_ACT_ExeNo
374
375 $Description:
376
377 $Returns: none.
378
379 $Arguments:
380
381 *******************************************************************************/
382 int smscb_M_CB_ACT_ExeNo(MfwMnu* m, MfwMnuItem* i)
383 {
384 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
385 /*SPR 1920, removed unneccessary variables*/
386 /*GW SPR#2470 Call 'smscb_setCBsettings' so that sAT_PlusCSCB is also called.*/
387
388 settingsSetStatus(SettingsCBDisable, SET_SETTING );/*Remember settings in FFS*/
389 // sms_set_mt_ind(MT_CB_NO_IDX);
390 smscb_setCBsettings(SMSCB_SWITCH_OFF);
391
392 info_screen(win, TxtDeActivated,TxtNull, NULL);
393
394
395 statusCBCH(FALSE);
396
397 /* SPR 1920, removed window destruction code*/
398 return MFW_EVENT_CONSUMED;
399 }
400
401 #ifdef DEBUG_SMS_CB
402 T_MFW_HND timer;
403
404 int test_tim_cb(MfwEvt event, MfwTim *timer_info)
405 {
406 int i;
407
408 test_function_to_send_cb ();
409 tim_delete(timer);
410 /***************************Go-lite Optimization changes Start***********************/
411 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
412 for (i=0; i<MAX_STORED_PAGES ; i++)
413 {
414 TRACE_EVENT_P2("free_index: %d, i:%d", smscb_data.cb_attributes[i].next_link,i);
415 }
416 /***************************Go-lite Optimization changes end***********************/
417 TRACE_EVENT_P1("count of messages:%d", sms_cb_count_messages ());
418
419 for (i=0; i<MAX_STORED_PAGES ; i++)
420 {
421
422 TRACE_EVENT_P2("start_page: %d, i:%d", smscb_data.cb_attributes[i].start_page,i);
423 }
424
425
426 TRACE_EVENT_P1("smscb_data.used_pointer%d", smscb_data.used_pointer);
427 TRACE_EVENT_P1("smscb_data.free_pointer%d", smscb_data.free_pointer);
428
429 return MFW_EVENT_CONSUMED;
430 }
431
432 #endif
433 /*******************************************************************************
434
435 $Function: smscb_M_CB_ACT_ExeYes
436
437 $Description:
438
439 $Returns: none.
440
441 $Arguments:
442
443 *******************************************************************************/
444 int smscb_M_CB_ACT_ExeYes(MfwMnu* m, MfwMnuItem* i)
445 {
446 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
447 /*SPR 1920, removed unneccessary variables*/
448 /*GW SPR#2470 Call 'smscb_setCBsettings' so that sAT_PlusCSCB is also called.*/
449
450 settingsSetStatus(SettingsCBDisable, CLEAR_SETTING );/*Remember settings in FFS*/
451 //sms_set_mt_ind(MT_CB_MSG);
452 smscb_setCBsettings(SMSCB_SWITCH_ON);
453
454 info_screen(win, TxtActivated,TxtNull, NULL);
455
456
457 /*SPR1959, removed declarations and functions for menu-handling*/
458 #ifdef DEBUG_SMS_CB
459 timer = tim_create(NULL, 5000, (MfwCb)test_tim_cb);
460 tim_start(timer);
461
462
463
464
465
466 #endif //DEBUG_SMS_CB
467 return MFW_EVENT_CONSUMED;
468 }
469
470
471
472
473
474 /*********************************************************************
475 **********************************************************************
476
477 M_CB_TOP DYNAMIC MENU WINDOW. CONTENTS BEHAVIOUR
478
479 *********************************************************************
480 **********************************************************************/
481 /*******************************************************************************
482
483 $Function: smscb_M_CB_TOP_ExeConsult
484
485 $Description:
486
487 $Returns: none.
488
489 $Arguments:
490
491 *******************************************************************************/
492 int smscb_M_CB_TOP_ExeConsult(MfwMnu* m, MfwMnuItem* i)
493 {
494 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
495 /*SPR 1920, removed unneccessary variables*/
496
497
498 #ifdef DEBUG_SMS_CB
499 UBYTE ii;
500 for (ii = 0; ii < MAX_MIDS; ii++)
501 {
502 /***************************Go-lite Optimization changes Start***********************/
503 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
504 TRACE_EVENT_P2 ("g_smscb_data.CBTopics.entry[0].msg_id:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
505 /***************************Go-lite Optimization changes end***********************/
506 }
507 #endif
508
509
510 if (!smsidle_get_ready_state())
511 {
512 info_screen(0, TxtSimNot, TxtReady, NULL);
513 TRACE_EVENT ("SIM is not ready !!");
514 return MFW_EVENT_CONSUMED; /* x0039928 - Lint warning fix */
515 }
516
517 if (g_smscb_data.CBTopics.length EQ 0)
518 {
519 info_screen(0, TxtEmptyList,TxtNull, NULL);
520
521 TRACE_EVENT ("CellBroadcast Topic-list is empty !!");
522 return MFW_EVENT_CONSUMED; /* x0039928 - Lint warning fix */
523 }
524
525 // selection "Consult": menucreate M_CB_TOP_CONS
526 return (int)smscb_M_CB_TOP_CONS_start (win, NULL);
527 }
528 T_CB_index_param CB_index_param;/*MC SPR1920 added global variable*/
529 /*******************************************************************************
530
531 $Function: smscb_M_CB_TOP_ExeAddNew
532
533 $Description:
534
535 $Returns:
536
537 $Arguments:
538
539 *******************************************************************************/
540 int smscb_M_CB_TOP_ExeAddNew(MfwMnu* m, MfwMnuItem* i)
541 {
542 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
543 /*SPR 1920, removed unneccessary variables*/
544 int index;
545
546 // selection "Add": call sms_cb_edit_topic(List=CBTopics, Index=ADD)
547 index = g_smscb_data.CBTopics.length;/* get the index of the next free entry in list CBTopics */
548
549 if (index > MAX_MIDS)
550 {
551 /* all entries are already used */
552 info_screen (win, TxtFull /* ??? */,TxtNull, NULL);
553 return MFW_EVENT_CONSUMED;
554 }
555 else
556 {
557
558
559 CB_index_param.index = index;
560 return (int)smscb_CB_EDT_TEXTEDT_start(win, &CB_index_param);
561 }
562 }
563
564
565 /*********************************************************************
566 **********************************************************************
567
568 M_CB_TOP_CONS DYNAMIC MENU WINDOW. DECLARATION
569
570 *********************************************************************
571 **********************************************************************/
572 typedef struct
573 {
574 /* administrative data */
575
576 T_MMI_CONTROL mmi_control;
577 T_MFW_HND win;
578 SHORT id;
579 T_MFW_HND parent;
580
581 /* associated handlers */
582
583 /* internal data */
584 T_CB_index_param CB_index_param; /* parameter for called submenus (index in list) */
585 MfwMnuItem menuItems[MAX_MIDS]; /* List=CBTopics */
586 ListMenuData list_menu_data;
587 } T_M_CB_TOP_CONS;
588
589 static T_MFW_HND smscb_M_CB_TOP_CONS_create (T_MFW_HND parent);
590 static void smscb_M_CB_TOP_CONS_destroy (T_MFW_HND window);
591 static void smscb_M_CB_TOP_CONS_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * dummy);
592 static void smscb_M_CB_TOP_CONS_listmnu_cb (T_MFW_HND * win, ListMenuData * ListData);
593
594 /* x0045876, 14-Aug-2006 (WR - function declared implicitly) */
595 static int smscb_M_CB_TOP_CONS_SEL_ExeDelete(T_MFW_HND * win);
596
597 static const MfwMnuAttr smscb_M_CB_TOP_CONSAttrib =
598 {
599 &smscb_M_CB_TOP_CONSArea,
600 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
601
602 /* x0045876, 14-Aug-2006 (WR - integer conversion resulted in a change of sign) */
603 (U8) -1, /* use default font */
604
605 NULL, /* with these items */
606 0, /* number of items */
607 COLOUR_LIST_SMS, TxtNull, NULL, MNUATTRSPARE
608
609 };
610
611 /*********************************************************************
612 **********************************************************************
613
614 M_CB_TOP_CONS DYNAMIC MENU WINDOW. IMPLEMENTATION
615
616 *********************************************************************
617 **********************************************************************/
618
619 /*******************************************************************************
620
621 $Function: smscb_M_CB_TOP_CONS_start
622
623 $Description:
624
625 $Returns:
626
627 $Arguments:
628
629 *******************************************************************************/
630 T_MFW_HND smscb_M_CB_TOP_CONS_start(T_MFW_HND parent_window, void *dummy)
631 {
632 T_MFW_HND win;
633
634 TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_start()");
635
636 win = smscb_M_CB_TOP_CONS_create (parent_window);
637
638 if (win NEQ NULL)
639 {
640 SEND_EVENT (win, E_INIT, smscb_M_CB_TOP_CONS_ID, NULL);
641 }
642 return win;
643 }
644
645
646 /*******************************************************************************
647
648 $Function: smscb_M_CB_TOP_CONS_create
649
650 $Description:
651
652 $Returns:
653
654 $Arguments:
655
656 *******************************************************************************/
657 static T_MFW_HND smscb_M_CB_TOP_CONS_create(MfwHnd parent_window)
658 {
659 T_M_CB_TOP_CONS * data = (T_M_CB_TOP_CONS *)ALLOC_MEMORY (sizeof (T_M_CB_TOP_CONS));
660 T_MFW_WIN * win;
661
662 TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_create()");
663
664 /*
665 * Create window handler
666 */
667
668 data->win =
669 win_create (parent_window, 0, 0, NULL);
670 if (data->win EQ NULL)
671 {
672 return NULL;
673 }
674
675 /*
676 * connect the dialog data to the MFW-window
677 */
678
679 data->mmi_control.dialog = (T_DIALOG_FUNC)smscb_M_CB_TOP_CONS_exec_cb;
680 data->mmi_control.data = data;
681 win = ((T_MFW_HDR *)data->win)->data;
682 win->user = (void *)data;
683 data->parent = parent_window;
684
685 /*
686 * return window handle
687 */
688
689 winShow(data->win);
690 return data->win;
691 }
692
693 static void smscb_M_CB_TOP_CONS_destroy(MfwHnd own_window)
694 {
695 T_MFW_WIN * win_data;
696 T_M_CB_TOP_CONS * data;
697
698 TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_destroy()");
699
700 if (own_window)
701 {
702 win_data = ((T_MFW_HDR *)own_window)->data;
703 data = (T_M_CB_TOP_CONS *)win_data->user;
704
705 if (data)
706 {
707 /*
708 * Delete WIN handler
709 */
710 win_delete (data->win);
711
712 /*
713 * Free Memory
714 */
715 FREE_MEMORY ((void *)data->list_menu_data.List, MAX_MIDS * sizeof (MfwMnuItem)); // c017 rsa
716 FREE_MEMORY ((void *)data, sizeof (T_M_CB_TOP_CONS));
717 }
718 else
719 {
720 TRACE_EVENT ("smscb_M_CB_TOP_CONS_destroy() called twice");
721 }
722 }
723 }
724
725 /*******************************************************************************
726
727 $Function: smscb_M_CB_TOP_CONS_recreate
728
729 $Description:
730
731 $Returns:
732
733 $Arguments:
734
735 *******************************************************************************/
736 static void smscb_M_CB_TOP_CONS_recreate(T_M_CB_TOP_CONS *data)
737 {
738 int i;
739 // int len; // RAVI
740
741 #ifdef DEBUG_SMS_CB
742 UBYTE ii;
743 TRACE_EVENT ("before create a list !");
744 for (ii = 0; ii < MAX_MIDS; ii++)
745 {
746 TRACE_EVENT_P2 (" 01 midlist:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
747 }
748 /***************************Go-lite Optimization changes Start***********************/
749 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
750 TRACE_EVENT_P2 (" 01 midlist:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
751 /***************************Go-lite Optimization changes end***********************/
752 #endif
753
754 //on RECREATE|INIT: menucreate dynamiclist (List=CBTopics, SoftLeft=SELECT, SoftRight=BACK) /* show: 1. Name 2. MID */
755
756 // c017 rsa
757 /* allocate sufficient memory to hold the maximum list of menu items */
758 data->list_menu_data.List = (MfwMnuItem *)ALLOC_MEMORY (MAX_MIDS * sizeof (MfwMnuItem));
759 // end c017 rsa
760
761 for (i=0; i < g_smscb_data.CBTopics.length; i++) /* Fill Menu List */
762 {
763 mnuInitDataItem(&data->list_menu_data.List[i]);
764
765
766 /* get the correct entry in list of CBTopics */
767 data->list_menu_data.List[i].str = g_smscb_data.CBTopics.entry[i].name;
768 data->list_menu_data.List[i].flagFunc = item_flag_none;
769
770
771 }
772
773 //actual number of entries in list menu
774 data->list_menu_data.ListLength = g_smscb_data.CBTopics.length;
775
776 data->list_menu_data.autoDestroy = TRUE;
777
778 listDisplayListMenu(data->win, &data->list_menu_data, (ListCbFunc)smscb_M_CB_TOP_CONS_listmnu_cb,0);
779 }
780
781 /*******************************************************************************
782
783 $Function: smscb_M_CB_TOP_CONS_exec_cb
784
785 $Description:
786
787 $Returns:
788
789 $Arguments:
790
791 *******************************************************************************/
792 void smscb_M_CB_TOP_CONS_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * dummy)
793 /* callback handler for events sent to to trigger execution */
794 {
795
796 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
797 T_M_CB_TOP_CONS * data = (T_M_CB_TOP_CONS *)win_data->user;
798 T_MFW_HND * l_parent;
799 SHORT l_id;
800 // UBYTE i; // RAVI.
801
802 TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_exec_cb()");
803
804 switch (event)
805 {
806 case E_INIT:
807 /* initialization of administrative data */
808 data->id = value;
809
810 /* initialization of the dialog data */
811 data->list_menu_data.ListPosition = 1;/* True cursor position in list menu. */
812 data->list_menu_data.CursorPosition = 1;/* Cursor position in list snapshot. */
813 data->list_menu_data.SnapshotSize = 4;/* Number of list entries to view. */
814 data->list_menu_data.Font = 0;
815 data->list_menu_data.LeftSoftKey = TxtDelete;
816 data->list_menu_data.RightSoftKey = TxtSoftBack;
817 data->list_menu_data.KeyEvents = KEY_CLEAR | KEY_RIGHT | KEY_LEFT | KEY_MNUUP | KEY_MNUDOWN;
818 data->list_menu_data.Reason = 0;
819 data->list_menu_data.Strings = TRUE; // c020 rsa
820 data->list_menu_data.Attr = (MfwMnuAttr*)&smscb_M_CB_TOP_CONSAttrib;
821 data->list_menu_data.autoDestroy = TRUE;
822
823 /* NOBREAK */
824 case E_RETURN:
825 case E_EXIT: /* terminate EXIT from CB_EDT_MIDEDT|M_CB_TOP_CONS_SEL here */
826 /* (re)create the dialog handler */
827 TRACE_FUNCTION ("EXIT in M_CB_TOP_CONS_exec_cb");
828
829 //the special case : if the user deleted the last CB item
830 //check if there is any more CB in the list when not
831 //give a infoscreen and go back to the CB menu
832 if (g_smscb_data.CBTopics.length EQ 0)
833 {
834 info_screen(0, TxtEmptyList,TxtNull, NULL);
835 l_parent = data->parent;
836 l_id = data->id;
837 smscb_M_CB_TOP_CONS_destroy(data->win);
838 SEND_EVENT (l_parent, event, l_id, NULL); /* forward event to parent */
839
840 }
841 else
842 {
843 smscb_M_CB_TOP_CONS_recreate(data);
844
845 /* put the (new) dialog window on top of the window stack */
846 /* winUpdate(data->win); c021 rsa */
847 }
848 break;
849 case E_ABORT: /* defaultreaction */
850 TRACE_EVENT ("ABORT in M_CB_TOP_CONS_exec_cb");
851
852 l_parent = data->parent;
853 l_id = data->id;
854 smscb_M_CB_TOP_CONS_destroy(data->win);
855 SEND_EVENT (l_parent, event, l_id, NULL); /* forward event to parent */
856 break;
857 default:
858 return;
859 }
860 }
861
862 /*******************************************************************************
863
864 $Function: smscb_M_CB_TOP_CONS_listmnu_cb
865
866 $Description:
867
868 $Returns:
869
870 $Arguments:
871
872 *******************************************************************************/
873 static void smscb_M_CB_TOP_CONS_listmnu_cb (T_MFW_HND * win, ListMenuData * ListData)
874 /* smscb_M_CB_TOP_CONS menu event handler */
875 {
876 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
877 T_M_CB_TOP_CONS * data = (T_M_CB_TOP_CONS *)win_data->user;
878 int index;
879
880 TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_listmnu_cb()");
881
882 switch (ListData->Reason)
883 {
884 case LISTS_REASON_SELECT:
885 //on SELECT: menucreate M_CB_TOP_CONS_SEL(Index=selection)
886 index = ListData->ListPosition;
887 data->CB_index_param.index = index;
888
889 smscb_M_CB_TOP_CONS_SEL_ExeDelete(win);
890
891 break;
892 case LISTS_REASON_BACK: /* back to previous menu */
893 smscb_M_CB_TOP_CONS_destroy(data->win);
894 SEND_EVENT (data->parent, E_RETURN, data->id, NULL); // c007 rsa
895 break;
896 default:
897 return;
898 }
899 return;
900 }
901
902
903 void ExeDelete_infoscreen_cb (T_MFW_HND win, USHORT identifier, UBYTE reason);
904
905 /*********************************************************************
906 **********************************************************************
907
908 M_CB_TOP_CONS_SEL DYNAMIC MENU WINDOW. CONTENTS BEHAVIOUR
909
910 *********************************************************************
911 **********************************************************************/
912
913
914 /*******************************************************************************
915
916 $Function: smscb_M_CB_TOP_CONS_SEL_ExeDelete
917
918 $Description:
919
920 $Returns:
921
922 $Arguments:
923
924 *******************************************************************************/
925 static int smscb_M_CB_TOP_CONS_SEL_ExeDelete(T_MFW_HND * win)
926 {
927 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
928 T_M_CB_TOP_CONS * data = (T_M_CB_TOP_CONS *)win_data->user;
929 // T_MFW_HND * l_parent; // RAVI
930 // SHORT l_id; // RAVI
931 int index;
932
933 //index is the selected MID
934 index = data->CB_index_param.index;
935
936 //delete now the user selected Topic MID
937 smscb_delete_topic((UBYTE) index);
938
939 //show infoscreen ("Deleted");
940 info_screen(win, TxtDeleted, TxtNull, (T_VOID_FUNC) ExeDelete_infoscreen_cb);
941
942
943 //save the updated Topic list on the SIM
944 smscb_setCBsettings(SMSCB_SWITCH_ON);
945
946 //selfdestroy; sendevent EXIT
947
948
949 return MFW_EVENT_CONSUMED;
950 }
951
952 void ExeDelete_infoscreen_cb (T_MFW_HND win , USHORT identifier, UBYTE reason)
953 {
954 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
955 T_M_CB_TOP_CONS * data = (T_M_CB_TOP_CONS *)win_data->user;
956 SHORT l_id;
957
958 l_id = data->id;
959
960 //nm go back and recreate the CB list
961 SEND_EVENT (win, E_EXIT, l_id, NULL);
962
963 }
964
965 /*********************************************************************
966 **********************************************************************
967
968 CB_EDT_TEXTEDT DYNAMIC MENU WINDOW. DECLARATION
969
970 *********************************************************************
971 **********************************************************************/
972
973 typedef struct
974 {
975 /* administrative data */
976
977 T_MMI_CONTROL mmi_control;
978 T_MFW_HND win;
979 SHORT id;
980 T_MFW_HND parent;
981
982 /* associated handlers */
983
984 T_MFW_HND editor;
985
986 /* internal data */
987 T_CB_index_param * param; /* pointer to parameter space in parent (index in list) */
988 #ifdef NEW_EDITOR
989 T_AUI_EDITOR_DATA editor_info; /* SPR#1428 - SH - New Editor data */
990 #else
991 T_EDITOR_DATA editor_info; /* storage for editor attributes */
992 #endif
993 T_CB_EDT_MIDEDT_param CB_EDT_MIDEDT_param; /* parameter space for buffer for editing */
994 } T_CB_EDT_TEXTEDT;
995
996 static T_MFW_HND smscb_CB_EDT_TEXTEDT_create (T_MFW_HND parent);
997 static void smscb_CB_EDT_TEXTEDT_destroy (T_MFW_HND window);
998 static void smscb_CB_EDT_TEXTEDT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
999 static void smscb_CB_EDT_TEXTEDT_editor_cb (T_MFW_HND win, USHORT Identifier, USHORT event);
1000
1001 /*********************************************************************
1002 **********************************************************************
1003
1004 CB_EDT_TEXTEDT DYNAMIC MENU WINDOW. IMPLEMENTATION
1005
1006 *********************************************************************
1007 **********************************************************************/
1008
1009 T_MFW_HND smscb_CB_EDT_TEXTEDT_start(T_MFW_HND parent_window, T_CB_index_param * parameter)
1010 {
1011 T_MFW_HND win;
1012
1013 TRACE_FUNCTION ("smscb_CB_EDT_TEXTEDT_start()");
1014
1015 win = smscb_CB_EDT_TEXTEDT_create (parent_window);
1016
1017 if (win NEQ NULL)
1018 {
1019 SEND_EVENT (win, E_INIT, smscb_CB_EDT_TEXTEDT_ID, (void *)parameter);
1020 }
1021 return win;
1022 }
1023
1024
1025 /*******************************************************************************
1026
1027 $Function: smscb_CB_EDT_TEXTEDT_create
1028
1029 $Description:
1030
1031 $Returns:
1032
1033 $Arguments:
1034
1035 *******************************************************************************/
1036 static T_MFW_HND smscb_CB_EDT_TEXTEDT_create(MfwHnd parent_window)
1037 {
1038 T_CB_EDT_TEXTEDT * data = (T_CB_EDT_TEXTEDT *)ALLOC_MEMORY (sizeof (T_CB_EDT_TEXTEDT));
1039 T_MFW_WIN * win;
1040
1041 TRACE_FUNCTION ("smscb_CB_EDT_TEXTEDT_create()");
1042
1043 /*
1044 * Create window handler
1045 */
1046
1047 data->win =
1048 win_create (parent_window, 0, 0, NULL);
1049 if (data->win EQ NULL)
1050 {
1051 return NULL;
1052 }
1053
1054 /*
1055 * connect the dialog data to the MFW-window
1056 */
1057
1058 data->mmi_control.dialog = (T_DIALOG_FUNC)smscb_CB_EDT_TEXTEDT_exec_cb;
1059 data->mmi_control.data = data;
1060 win = ((T_MFW_HDR *)data->win)->data;
1061 win->user = (void *)data;
1062 data->parent = parent_window;
1063
1064 /*
1065 * return window handle
1066 */
1067
1068 winShow(data->win);
1069 return data->win;
1070 }
1071
1072
1073 /*******************************************************************************
1074
1075 $Function: smscb_CB_EDT_TEXTEDT_destroy
1076
1077 $Description:
1078
1079 $Returns:
1080
1081 $Arguments:
1082
1083 *******************************************************************************/
1084 static void smscb_CB_EDT_TEXTEDT_destroy(MfwHnd own_window)
1085 {
1086 T_MFW_WIN * win_data;
1087 T_CB_EDT_TEXTEDT * data;
1088
1089 TRACE_FUNCTION ("smscb_CB_EDT_TEXTEDT_destroy()");
1090
1091 if (own_window)
1092 {
1093 win_data = ((T_MFW_HDR *)own_window)->data;
1094 data = (T_CB_EDT_TEXTEDT *)win_data->user;
1095
1096 if (data)
1097 {
1098 /*
1099 * Delete WIN handler
1100 */
1101 win_delete (data->win);
1102
1103 /*
1104 * Free Memory
1105 */
1106 FREE_MEMORY ((void *)data, sizeof (T_CB_EDT_TEXTEDT));
1107 }
1108 else
1109 {
1110 TRACE_EVENT ("smscb_CB_EDT_TEXTEDT_destroy() called twice");
1111 }
1112 }
1113 }
1114
1115 /*******************************************************************************
1116
1117 $Function: smscb_CB_EDT_TEXTEDT_exec_cb
1118
1119 $Description:
1120
1121 $Returns:
1122
1123 $Arguments:
1124
1125 *******************************************************************************/
1126 void smscb_CB_EDT_TEXTEDT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
1127 /* callback handler for events sent to to trigger execution */
1128 {
1129
1130
1131 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1132 T_CB_EDT_TEXTEDT * data = (T_CB_EDT_TEXTEDT *)win_data->user;
1133 int
1134 index;
1135
1136 TRACE_FUNCTION ("smscb_CB_EDT_TEXTEDT_exec_cb()");
1137
1138 switch (event)
1139 {
1140 case E_INIT:
1141 /* initialization of administrative data */
1142 data->id = value;
1143 data->param = (T_CB_index_param *)parameter; /* store the pointer to the parameter for later use */
1144
1145
1146 #ifdef DEBUG_SMS_CB
1147 /***************************Go-lite Optimization changes Start***********************/
1148 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1149 TRACE_EVENT_P1( "the index is %d", data->param->index);
1150 /***************************Go-lite Optimization changes end***********************/
1151 #endif
1152
1153 /* initialization of the dialog data */
1154 index = data->param->index;
1155 data->CB_EDT_MIDEDT_param.index = index; /* copy the index to parameter space of next menu */
1156
1157 data->CB_EDT_MIDEDT_param.name[0] = '\0'; /* provide empty entry */
1158
1159 //on INIT: exec "copy params to dynamic memory <data>"; RECREATE
1160 /* NOBREAK */
1161 case E_RETURN: //on RETURN: RECREATE // recreate editor if back from options
1162
1163 /* SPR#1428 - SH - New Editor changes */
1164
1165 #ifdef NEW_EDITOR
1166 AUI_edit_SetDefault(&data->editor_info);
1167 AUI_edit_SetDisplay(&data->editor_info, ZONE_FULL_SK_TITLE, COLOUR_EDITOR_XX, EDITOR_FONT);
1168 AUI_edit_SetEvents(&data->editor_info, value, TRUE, TEN_SECS, (T_AUI_EDIT_CB)smscb_CB_EDT_TEXTEDT_editor_cb);
1169 AUI_edit_SetTextStr(&data->editor_info, TxtSoftOK, TxtDelete, TxtEnterName, NULL);
1170 // Change by Sasken ( Deepa M.d) on March 29th 2004
1171 // Issue Number : MMI-SPR-12722
1172 // Subject: Right softkey should be "Back" when the editor is empty
1173 // Bug : Right softkey should be "Back" when the editor is empty
1174 // Solution : Added alternative string for the right softkey tobe displayed when the editor is empty
1175
1176 AUI_edit_SetAltTextStr(&data->editor_info, 0, NULL, TRUE, TxtSoftBack);
1177 AUI_edit_SetBuffer(&data->editor_info, ATB_DCS_ASCII, (UBYTE *)data->CB_EDT_MIDEDT_param.name, CB_TAG_LENGTH);
1178 AUI_edit_SetMode(&data->editor_info, ED_MODE_ALPHA, ED_CURSOR_BAR);
1179
1180 data->editor = AUI_edit_Start(data->win,&data->editor_info); /* start the editor */
1181 #else /* NEW_EDITOR */
1182 /*MC SPR 1488, got rid of hardcoded editor dimensions*/
1183 data->editor_info.editor_attr.win.px = 0;
1184 data->editor_info.editor_attr.win.py = Mmi_layout_line(2);
1185 data->editor_info.editor_attr.win.sx =SCREEN_SIZE_X;
1186 data->editor_info.editor_attr.win.sy = 2*Mmi_layout_line_height();
1187 data->editor_info.editor_attr.edtCol = COLOUR_EDITOR_XX;
1188 data->editor_info.editor_attr.font = 0;
1189 data->editor_info.editor_attr.mode = edtCurBar1;
1190 data->editor_info.editor_attr.controls = 0;
1191 data->editor_info.editor_attr.text = data->CB_EDT_MIDEDT_param.name; /* buffer to be edited */
1192 data->editor_info.editor_attr.size = CB_TAG_LENGTH;
1193 data->editor_info.LeftSoftKey = TxtSoftOK;
1194 data->editor_info.RightSoftKey = TxtDelete;
1195 data->editor_info.TextId = TxtEnterName;
1196 data->editor_info.Identifier = value; /* optional */
1197 data->editor_info.mode = ALPHA_MODE;
1198 data->editor_info.Callback = (T_EDIT_CB)smscb_CB_EDT_TEXTEDT_editor_cb;
1199 data->editor_info.destroyEditor = TRUE;
1200 data->editor_info.hide = FALSE;
1201 // Change by Sasken ( Deepa M.d) on March 29th 2004
1202 // Issue Number : MMI-SPR-12722
1203 // Subject: Right softkey should be "Back" when the editor is empty
1204 // Bug : Right softkey should be "Back" when the editor is empty
1205 // Solution : Added alternative string for the right softkey tobe displayed when the editor is empty
1206 data->editor_info.AlternateLeftSoftKey = TxtSoftBack;
1207 data->editor_info.TextString = NULL;
1208 data->editor_info.min_enter = 0;
1209 data->editor_info.timeout = TEN_SECS;
1210
1211 /* create the dialog handler */
1212 data->editor = editor_start(data->win,&data->editor_info); /* start the editor */
1213 #endif /* NEW_EDITOR */
1214
1215 break;
1216 case E_ABORT:
1217 case E_EXIT: /* defaultreaction */
1218 smscb_CB_EDT_TEXTEDT_destroy(data->win);
1219 /*SPR 1920, removed sending of exit event to parent, no longer needed*/
1220 break;
1221 default:
1222 return;
1223 }
1224 }
1225
1226 /*******************************************************************************
1227
1228 $Function: smscb_CB_EDT_TEXTEDT_editor_cb
1229
1230 $Description:
1231
1232 $Returns:
1233
1234 $Arguments:
1235
1236 *******************************************************************************/
1237 static void smscb_CB_EDT_TEXTEDT_editor_cb (T_MFW_HND win, USHORT Identifier, USHORT event)
1238 /* smscb_CB_EDT_TEXTEDT editor event handler */
1239 {
1240 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1241 T_CB_EDT_TEXTEDT * data = (T_CB_EDT_TEXTEDT *)win_data->user;
1242 T_MFW_HND * l_parent;
1243 SHORT l_id;
1244
1245 TRACE_FUNCTION ("smscb_CB_EDT_TEXTEDT_editor_cb()");
1246
1247 switch(event)
1248 {
1249 case INFO_KCD_LEFT:
1250 //on OK: menucreate CB_EDT_MIDEDT(data)
1251 smscb_CB_EDT_MIDEDT_start (win, &data->CB_EDT_MIDEDT_param);
1252 break;
1253 case INFO_KCD_RIGHT:
1254 case INFO_KCD_HUP: /* defaultreaction */
1255 l_parent = data->parent;
1256 l_id = data->id;
1257 smscb_CB_EDT_TEXTEDT_destroy(data->win);
1258 SEND_EVENT (l_parent, E_RETURN, l_id, NULL); // c007 rsa
1259 break;
1260 default:
1261 break;
1262 }
1263 return;
1264 }
1265 /*********************************************************************
1266 **********************************************************************
1267
1268 CB_EDT_MIDEDT DYNAMIC MENU WINDOW. DECLARATION
1269
1270 *********************************************************************
1271 **********************************************************************/
1272
1273 typedef struct
1274 {
1275 /* administrative data */
1276
1277 T_MMI_CONTROL mmi_control;
1278 T_MFW_HND win;
1279 SHORT id;
1280 T_MFW_HND parent;
1281
1282 /* associated handlers */
1283
1284 T_MFW_HND editor;
1285
1286 /* internal data */
1287 T_CB_EDT_MIDEDT_param * param; /* pointer to parameter space in parent (buffer for editing) */
1288 #ifdef NEW_EDITOR
1289 T_AUI_EDITOR_DATA editor_info; /* SPR#1428 - SH - New Editor data */
1290 #else
1291 T_EDITOR_DATA editor_info; /* storage for editor attributes */
1292 #endif
1293 } T_CB_EDT_MIDEDT;
1294
1295 static T_MFW_HND smscb_CB_EDT_MIDEDT_create (T_MFW_HND parent);
1296 static void smscb_CB_EDT_MIDEDT_destroy (T_MFW_HND window);
1297 static void smscb_CB_EDT_MIDEDT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
1298 static void smscb_CB_EDT_MIDEDT_editor_cb (T_MFW_HND win, USHORT Identifier, USHORT event);
1299
1300 /*********************************************************************
1301 **********************************************************************
1302
1303 CB_EDT_MIDEDT DYNAMIC MENU WINDOW. IMPLEMENTATION
1304
1305 *********************************************************************
1306 **********************************************************************/
1307
1308 T_MFW_HND smscb_CB_EDT_MIDEDT_start(T_MFW_HND parent_window, T_CB_EDT_MIDEDT_param * parameter)
1309 {
1310 T_MFW_HND win;
1311
1312 TRACE_FUNCTION ("smscb_CB_EDT_MIDEDT_start()");
1313
1314 win = smscb_CB_EDT_MIDEDT_create (parent_window);
1315
1316 if (win NEQ NULL)
1317 {
1318 SEND_EVENT (win, E_INIT, smscb_CB_EDT_MIDEDT_ID, (void *)parameter);
1319 }
1320 return win;
1321 }
1322
1323 /*******************************************************************************
1324
1325 $Function: smscb_CB_EDT_MIDEDT_create
1326
1327 $Description:
1328
1329 $Returns:
1330
1331 $Arguments:
1332
1333 *******************************************************************************/
1334 static T_MFW_HND smscb_CB_EDT_MIDEDT_create(MfwHnd parent_window)
1335 {
1336 T_CB_EDT_MIDEDT * data = (T_CB_EDT_MIDEDT *)ALLOC_MEMORY (sizeof (T_CB_EDT_MIDEDT));
1337 T_MFW_WIN * win;
1338
1339 TRACE_FUNCTION ("smscb_CB_EDT_MIDEDT_create()");
1340
1341 /*
1342 * Create window handler
1343 */
1344
1345 data->win = win_create (parent_window, 0, 0, NULL);
1346
1347 if (data->win EQ NULL)
1348 {
1349 return NULL;
1350 }
1351
1352 /*
1353 * connect the dialog data to the MFW-window
1354 */
1355
1356 data->mmi_control.dialog = (T_DIALOG_FUNC)smscb_CB_EDT_MIDEDT_exec_cb;
1357 data->mmi_control.data = data;
1358 win = ((T_MFW_HDR *)data->win)->data;
1359 win->user = (void *)data;
1360 data->parent = parent_window;
1361
1362 /*
1363 * return window handle
1364 */
1365
1366 winShow(data->win);
1367 return data->win;
1368 }
1369
1370
1371 /*******************************************************************************
1372
1373 $Function: smscb_CB_EDT_MIDEDT_destroy
1374
1375 $Description:
1376
1377 $Returns:
1378
1379 $Arguments:
1380
1381 *******************************************************************************/
1382 static void smscb_CB_EDT_MIDEDT_destroy(MfwHnd own_window)
1383 {
1384 T_MFW_WIN * win_data;
1385 T_CB_EDT_MIDEDT * data;
1386
1387
1388 TRACE_FUNCTION ("smscb_CB_EDT_MIDEDT_destroy()");
1389
1390 if (own_window)
1391 {
1392 win_data = ((T_MFW_HDR *)own_window)->data;
1393 data = (T_CB_EDT_MIDEDT *)win_data->user;
1394
1395 if (data)
1396 {
1397 /*
1398 * Delete WIN handler
1399 */
1400 win_delete (data->win);
1401
1402 /*
1403 * Free Memory
1404 */
1405 FREE_MEMORY ((void *)data, sizeof (T_CB_EDT_MIDEDT));
1406 }
1407 else
1408 {
1409 TRACE_EVENT ("smscb_CB_EDT_MIDEDT_destroy() called twice");
1410 }
1411 }
1412 }
1413
1414
1415 /*******************************************************************************
1416
1417 $Function: smscb_CB_EDT_MIDEDT_exec_cb
1418
1419 $Description:
1420
1421 $Returns:
1422
1423 $Arguments:
1424
1425 *******************************************************************************/
1426 void smscb_CB_EDT_MIDEDT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
1427 /* callback handler for events sent to to trigger execution */
1428 {
1429
1430 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1431 T_CB_EDT_MIDEDT * data = (T_CB_EDT_MIDEDT *)win_data->user;
1432 T_MFW_HND * l_parent;
1433 SHORT l_id;
1434 int index;
1435
1436 TRACE_FUNCTION ("smscb_CB_EDT_MIDEDT_exec_cb()");
1437
1438 switch (event)
1439 {
1440 case E_INIT:
1441 /* initialization of administrative data */
1442 data->id = value;
1443 data->param = (T_CB_EDT_MIDEDT_param *)parameter; /* store the pointer to the parameter for later use */
1444
1445 /* initialization of the dialog data */
1446 index = data->param->index;
1447 if (g_smscb_data.CBTopics.entry[index].msg_id NEQ NO_MID)
1448 {
1449 data->param->number[0] = '\0'; /* provide empty entry */
1450
1451 }
1452 else
1453 {
1454 data->param->number[0] = '\0'; /* provide empty entry */
1455 }
1456 //on INIT: call editor (Type=numeric, Length=3, Prompt="Enter MID Number",
1457 // Number=data->List.Number[data->ListIndex], SoftLeft=OK, SoftRight=BACK)
1458
1459 /* SPR#1428 - SH - New Editor changes */
1460 #ifdef NEW_EDITOR
1461 AUI_edit_SetDefault(&data->editor_info);
1462 AUI_edit_SetDisplay(&data->editor_info, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT);
1463 AUI_edit_SetEvents(&data->editor_info, value, TRUE, TEN_SECS, (T_AUI_EDIT_CB)smscb_CB_EDT_MIDEDT_editor_cb);
1464 AUI_edit_SetTextStr(&data->editor_info, TxtSoftOK, TxtDelete, TxtEnterMid, NULL);
1465 AUI_edit_SetAltTextStr(&data->editor_info, 1, TxtNull, TRUE, TxtSoftBack);
1466 AUI_edit_SetBuffer(&data->editor_info, ATB_DCS_ASCII, (UBYTE *)data->param->number, CB_MID_LENGTH);
1467 AUI_edit_SetMode(&data->editor_info, 0, ED_CURSOR_BAR);
1468
1469 data->editor = AUI_edit_Start(data->win,&data->editor_info); /* start the editor */
1470 #else /* NEW_EDITOR */
1471 editor_attr_init(&data->editor_info.editor_attr, ZONE_SMALL_EDITOR, edtCurBar1, 0, data->param->number, CB_MID_LENGTH, COLOUR_EDITOR );
1472 editor_data_init(&data->editor_info,(T_EDIT_CB)smscb_CB_EDT_MIDEDT_editor_cb,TxtSoftOK,TxtDelete,TxtEnterMid,1 ,DIGITS_MODE, TEN_SECS);
1473 data->editor_info.destroyEditor = TRUE;
1474 data->editor_info.Identifier = value;
1475 data->editor_info.hide = FALSE;
1476 data->editor_info.TextString = NULL;
1477
1478 /* create the dialog handler */
1479 data->editor = editor_start(data->win,&data->editor_info); /* start the editor */
1480 #endif /* NEW_EDITOR */
1481 break;
1482 case E_ABORT:
1483 case E_EXIT: /* defaultreaction */
1484 l_parent = data->parent;
1485 l_id = data->id;
1486 smscb_CB_EDT_MIDEDT_destroy(data->win);
1487 SEND_EVENT (l_parent, event, l_id, NULL); /* forward event to parent */
1488 break;
1489 default:
1490 return;
1491 }
1492 }
1493
1494
1495 /*******************************************************************************
1496
1497 $Function: smscb_CB_EDT_MIDEDT_editor_cb
1498
1499 $Description:
1500
1501 $Returns:
1502
1503 $Arguments:
1504
1505 *******************************************************************************/
1506 static void smscb_CB_EDT_MIDEDT_editor_cb (T_MFW_HND win, USHORT Identifier, USHORT event)
1507 /* smscb_CB_EDT_MIDEDT editor event handler */
1508 {
1509 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1510 T_CB_EDT_MIDEDT * data = (T_CB_EDT_MIDEDT *)win_data->user;
1511 T_MFW_HND * l_parent;
1512 SHORT l_id;
1513 int index;
1514 UBYTE ll;
1515 T_SMSCB_TOPIC_TAG ffs_tag;/*SPR1920*/
1516 char file_name[20];
1517 int val;
1518 #ifdef DEBUG_SMS_CB
1519 UBYTE ii;
1520 #endif
1521
1522 TRACE_FUNCTION ("smscb_CB_EDT_MIDEDT_editor_cb()");
1523
1524 l_parent = data->parent;
1525 l_id = data->id;
1526
1527 switch(event)
1528 {
1529 case INFO_KCD_LEFT:
1530 index = data->param->index;
1531
1532 //nm "-1"the zero is counted as well
1533 if (index < MAX_MIDS -1 )
1534 {
1535 /* add a new entry */
1536
1537
1538 memcpy (g_smscb_data.CBTopics.entry[index].name, data->param->name, CB_TAG_LENGTH);
1539 g_smscb_data.CBTopics.entry[index].msg_id = atoi(data->param->number);
1540 /*SPR1959, save name to FFS*/
1541 memcpy(ffs_tag.name, data->param->name, CB_TAG_LENGTH);
1542 { val = ffs_fwrite((const char*)ffs_cb_tag_name(g_smscb_data.CBTopics.entry[index].msg_id, file_name), (void*)&ffs_tag, sizeof(T_SMSCB_TOPIC_TAG));
1543
1544 TRACE_EVENT_P1("CB tag name write status:%d", val);
1545 }
1546
1547 #ifdef DEBUG_SMS_CB
1548 /***************************Go-lite Optimization changes Start***********************/
1549 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1550 TRACE_EVENT_P1 ( "the index is %d", index);
1551 /***************************Go-lite Optimization changes end***********************/
1552 #endif
1553
1554 /* add a new entry */
1555 index += 1;
1556 g_smscb_data.CBTopics.length = index;
1557
1558 smscb_setCBsettings(SMSCB_SWITCH_ON); /* save in SIM */
1559
1560 info_screen(win, TxtSaved ,TxtNull, NULL);
1561
1562 }
1563 else
1564 {
1565 info_screen (win, TxtFull, TxtNull, NULL);
1566 }
1567
1568 // Apr 29, 2004 REF: CRR 11630 Deepa M.D
1569 // Refresh the list,so that if a name exists for a channelId in FFS, it is displayed.
1570 for(ll = 0; ll < g_smscb_data.CBTopics.length; ll++)
1571 {
1572 if (g_smscb_data.CBTopics.entry[ll].msg_id EQ NO_MID)
1573 {
1574 break;
1575 }
1576
1577 /* Set default tag string, until we get the saved name from PCM */
1578 g_smscb_data.CBTopics.entry[ll].name[0] = '\0';
1579 /*attempt to read channel name from FFS file*/
1580 val = ffs_fread(ffs_cb_tag_name(g_smscb_data.CBTopics.entry[ll].msg_id, file_name), &ffs_tag, sizeof(T_SMSCB_TOPIC_TAG));
1581 /*if reading successful, copy name to data structure*/
1582
1583 if (val == sizeof(ffs_tag))
1584 {
1585 memcpy(g_smscb_data.CBTopics.entry[ll].name, ffs_tag.name, CB_TAG_LENGTH);
1586 }
1587 /* update here g_smscb_data.CBTopics.entry[i].name from PCM */
1588 if (g_smscb_data.CBTopics.entry[ll].name[0] EQ '\0')
1589 {
1590 /* but if it's empty substitute it by the channel number */
1591 sprintf (g_smscb_data.CBTopics.entry[ll].name,"Ch%d,ID:%d",ll,g_smscb_data.CBTopics.entry[ll].msg_id);
1592 }
1593
1594 }
1595
1596
1597 #ifdef DEBUG_SMS_CB
1598 /***************************Go-lite Optimization changes Start***********************/
1599 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1600 TRACE_EVENT ("after add a new one !");
1601 for (ii = 0; ii < MAX_MIDS; ii++)
1602 {
1603
1604 TRACE_EVENT_P2 (" 04 midlist:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
1605 }
1606
1607 TRACE_EVENT_P1 ("04 midlist:%d", g_smscb_data.CBTopics.length);
1608
1609 /***************************Go-lite Optimization changes end***********************/
1610 #endif
1611
1612
1613
1614
1615 smscb_CB_EDT_MIDEDT_destroy(data->win);
1616 SEND_EVENT (l_parent, E_EXIT, l_id, NULL);
1617 break;
1618 case INFO_KCD_RIGHT:
1619 case INFO_KCD_HUP: /* defaultreaction */
1620 smscb_CB_EDT_MIDEDT_destroy(data->win);
1621 SEND_EVENT (l_parent, E_RETURN, l_id, NULL); // c007 rsa
1622 break;
1623 default:
1624 break;
1625 }
1626 return;
1627 }
1628
1629 /*********************************************************************
1630 **********************************************************************
1631
1632
1633 cell broadcast routines IMPLEMENTATION
1634
1635 *********************************************************************
1636 **********************************************************************/
1637
1638
1639 /*******************************************************************************
1640
1641 $Function: smscb_InitData
1642
1643 $Description: Initialises CB message storage
1644
1645 $Returns: none.
1646
1647 $Arguments:
1648
1649 *******************************************************************************/
1650 void smscb_InitData (void)
1651 {
1652 UBYTE i;
1653
1654 g_smscb_data.CBTopics.length = 0;
1655 for (i = 0; i < MAX_MIDS; i++)
1656 {
1657 g_smscb_data.CBTopics.entry[i].msg_id = NO_MID; /* Set MID list default values. */
1658 g_smscb_data.CBTopics.entry[i].name[0] = '\0';
1659 g_smscb_data.CBTopics.entry[i].dcs = 0;
1660 }
1661
1662 }
1663
1664 /*******************************************************************************
1665
1666 $Function: smscb_delete_topic
1667
1668
1669
1670 $Description: : This function is used to delete an MID from the
1671 current list <g_smscb_data.CBTopics>.
1672
1673
1674 $Returns:
1675
1676 $Arguments:
1677
1678 *******************************************************************************/
1679 static T_MFW smscb_delete_topic(UBYTE MidOffset)
1680 {
1681 SHORT Mid;
1682 UBYTE MidCount;
1683 UBYTE i;
1684
1685 #ifdef DEBUG_SMS_CB
1686 UBYTE ii;
1687 #endif
1688
1689 Mid = g_smscb_data.CBTopics.entry[MidOffset].msg_id;
1690
1691 /* Find out how many messages are stored.
1692 * set MidCount to first entry which contains NO_MID or
1693 * set MidCount to MAX_MIDS if list is full
1694 */
1695 //
1696 MidCount = g_smscb_data.CBTopics.length + 1;
1697
1698 /* Move the MID data up one. */
1699 while (MidOffset < (MidCount)) //c005 rsa avoid copying from behind the array
1700 {
1701 g_smscb_data.CBTopics.entry[MidOffset] = g_smscb_data.CBTopics.entry[MidOffset + 1];
1702 MidOffset++;
1703 }
1704 //c005 rsa but assign NO_MID behind the last entry
1705 if (MidCount > 0)
1706 g_smscb_data.CBTopics.entry[MidCount].msg_id = NO_MID;
1707 else
1708 g_smscb_data.CBTopics.entry[0].msg_id = NO_MID;
1709 //end c005 rsa
1710
1711 g_smscb_data.CBTopics.length--;
1712
1713 /* Delete any message in FIFO bearing the MID. */
1714 /*MC SPR 1920, I have a suspicion this does nothing, but have replaced references
1715 to removed structure members with references to data stored for topics list*/
1716 i = 0;
1717 while ((i < MAX_MIDS) && (g_smscb_data.CBTopics.entry[i].msg_id != Mid))
1718 i++;
1719
1720
1721 #ifdef DEBUG_SMS_CB
1722 /***************************Go-lite Optimization changes Start***********************/
1723 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1724 TRACE_EVENT_P1 ("i is %d", i);
1725 /***************************Go-lite Optimization changes end***********************/
1726 #endif
1727
1728
1729 #ifdef DEBUG_SMS_CB
1730 /***************************Go-lite Optimization changes Start***********************/
1731 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1732 TRACE_EVENT ("after deleting !");
1733 for (ii = 0; ii < MAX_MIDS; ii++)
1734 {
1735
1736 TRACE_EVENT_P2 (" 03 midlist:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
1737 }
1738
1739 TRACE_EVENT_P1 ("03 midlist:%d", g_smscb_data.CBTopics.length);
1740 /***************************Go-lite Optimization changes end***********************/
1741 #endif
1742
1743
1744
1745 return 1;
1746 }
1747
1748 /*******************************************************************************
1749
1750 $Function: ffs_cb_tag_name
1751
1752 $Description: generates a filename string for the pathname of an FFS CB Topic tag file
1753 i.e./MMI/cbtagXX where XX is the channel number.
1754 Added for issue1920
1755
1756 $Returns: filename string
1757
1758 $Arguments: channel number, pointer to allocated string
1759
1760 *******************************************************************************/
1761 char* ffs_cb_tag_name(int channel_num, char* name)
1762 {
1763 sprintf(name,"/mmi/cbtag%d",channel_num);
1764 return name;
1765 }
1766
1767 /*******************************************************************************
1768
1769 $Function: smscb_getCBsettings
1770
1771 $Description: This function allows the MS-User to examine the
1772 current list of MIDs being used to filter CB messages.
1773
1774
1775 $Returns:
1776
1777 $Arguments:
1778
1779 *******************************************************************************/
1780 T_MFW smscb_getCBsettings(void)
1781 {
1782 T_MFW status;
1783 UBYTE i,d=0;
1784 /*MC SPR 1920, need to allocate this as large data structure*/
1785 T_MFW_SMS_CB_INFO* SmsCbInfo = (T_MFW_SMS_CB_INFO*)ALLOC_MEMORY(sizeof(T_MFW_SMS_CB_INFO));
1786 T_SMSCB_TOPIC_TAG ffs_tag;/*SPR1920*/
1787 char file_name[20];/*SPR1920*/
1788 int val;/*SPR1920*/
1789
1790 #ifdef FF_2TO1_PS
1791 return MFW_SMS_FAIL;
1792 #endif
1793
1794 #ifdef DEBUG_SMS_CB
1795 TRACE_EVENT (" get the list from sim");
1796 #endif
1797
1798 //clear the Topic list
1799 smscb_InitData();
1800
1801 //get the Topic list from the SIM
1802 status = sms_get_cell_broadcast_info(SmsCbInfo);
1803
1804 //set to default
1805 g_smscb_data.CBTopics.length = 0xFF;
1806
1807
1808 #ifdef DEBUG_SMS_CB
1809 /***************************Go-lite Optimization changes Start***********************/
1810 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1811 for (i = 0; i <= 19; i++)
1812 {
1813 TRACE_EVENT_P2("DATA from mfw %d i:%d", SmsCbInfo->msg_id[i],i);
1814 }
1815 /***************************Go-lite Optimization changes end***********************/
1816 #endif
1817
1818
1819 for (i = 0; i < MAX_MIDS; i++)
1820 {
1821 /* Update MID list from SIM data. */
1822 g_smscb_data.CBTopics.entry[i].msg_id = SmsCbInfo->msg_id[d];
1823
1824 g_smscb_data.CBTopics.entry[i].dcs = SmsCbInfo->dcs[d];
1825
1826 if (g_smscb_data.CBTopics.entry[i].msg_id EQ NO_MID)
1827 {
1828 break;
1829 }
1830 else
1831 {
1832 g_smscb_data.CBTopics.length = i;
1833 }
1834
1835 /* Set default tag string, until we get the saved name form PCM */
1836 g_smscb_data.CBTopics.entry[i].name[0] = '\0';
1837 /*SPR1920*/
1838 /*attempt to read channel name from FFS file*/
1839 val = ffs_fread(ffs_cb_tag_name(g_smscb_data.CBTopics.entry[i].msg_id, file_name), &ffs_tag, sizeof(T_SMSCB_TOPIC_TAG));
1840 /*if reading successful, copy name to data structure*/
1841 if (val == sizeof(ffs_tag))
1842 {
1843 memcpy(g_smscb_data.CBTopics.entry[i].name, ffs_tag.name, CB_TAG_LENGTH);
1844 }
1845 /*SPR1920, end*/
1846 /* ??? update here g_smscb_data.CBTopics.entry[i].name from PCM */
1847 if (g_smscb_data.CBTopics.entry[i].name[0] EQ '\0')
1848 {
1849 /* but if it's empty substitute it by the channel number */
1850 sprintf (g_smscb_data.CBTopics.entry[i].name,"Ch%d,ID:%d",i,g_smscb_data.CBTopics.entry[i].msg_id);
1851 }
1852 //x0pleela 16 Feb, 2007 DR: OMAPS00116175
1853 //Changed the incremental value from 2 to 1 as the successive CB parameters ( message id) was getting skipped while reading back
1854 //from cell broadcast parameters
1855 d++;
1856
1857 #ifdef DEBUG_SMS_CB
1858 /***************************Go-lite Optimization changes Start***********************/
1859 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1860 TRACE_EVENT_P2 ( "02 midlist:%d, i:%d", g_smscb_data.CBTopics.entry[i].msg_id,i);
1861 /***************************Go-lite Optimization changes end***********************/
1862 #endif
1863
1864 }
1865
1866
1867 if (g_smscb_data.CBTopics.length EQ 0xFF)
1868 {
1869 //list is empty
1870 g_smscb_data.CBTopics.length = 0;
1871 }
1872 else
1873 {
1874 //+1 because the "0" was counted as well
1875 g_smscb_data.CBTopics.length +=1;
1876 }
1877
1878
1879
1880 /*SPR 1920, end of function, deallocate memory*/
1881 FREE_MEMORY((void*)SmsCbInfo,sizeof(T_MFW_SMS_CB_INFO));
1882 return status;
1883 }
1884
1885 /*******************************************************************************
1886
1887 $Function: smscb_setCBsettings
1888
1889 $Description: This function is used to activated/de-activate the CB
1890 feature and to submit MIDs for filter list control.
1891
1892 When the CB feature is switched ON, the stored message
1893 index MIDs are set to invalid, i.e ready for incoming CB
1894 messages and the MID list is initialised. On switch OFF,
1895 the MID list parameters are refreshed before the switch
1896 OFF command is issued, to ensure that the most recent
1897 MID list is used. It is not necessary to handle the
1898 stored message index MIDs as they will be dealt with
1899 next time the feature is activated.
1900 usage:
1901 Status = smscb_setCBsettings(SMSCB_SWITCH_OFF);
1902 Status = smscb_setCBsettings(SMSCB_SWITCH_ON);
1903
1904
1905 $Returns: none.
1906
1907 $Arguments:
1908
1909 *******************************************************************************/
1910 T_MFW smscb_setCBsettings(UBYTE State)
1911 {
1912 /* SPR759 - SH - removed 'static' so function can be called by Homezone */
1913
1914 UBYTE i,d=0;
1915 T_MFW Status;
1916 /*MC SPR 1920, need to allocate this as large data structure*/
1917 T_MFW_SMS_CB_INFO* SmsCbInfo = (T_MFW_SMS_CB_INFO*)ALLOC_MEMORY(sizeof(T_MFW_SMS_CB_INFO));
1918
1919 #ifndef NEPTUNE_BOARD
1920 /* June 23, 2006 Ref: OMAPS00079445 */
1921 #ifdef FF_2TO1_PS
1922 return MFW_SMS_FAIL;
1923 #endif
1924 #endif
1925
1926 /* SH - moved up here otherwise does not execute*/
1927 //nm
1928 if (State EQ SMSCB_SWITCH_ON )
1929 sms_set_mt_ind(MT_CB_MSG);
1930 else
1931 sms_set_mt_ind(MT_CB_NO_IDX);
1932
1933
1934 /* copy local list to SIM */
1935 SmsCbInfo->mode = State;
1936
1937
1938 for (i = 0; i < MAX_MIDS; i++)
1939 {
1940 SmsCbInfo->msg_id[i] = NO_MID; /* Set MID list default values. */
1941 SmsCbInfo->dcs[i] = 0xFF;
1942 }
1943
1944 // Dec 22, 2004 REF: CRR MFW-SPR-27847 xnkulkar
1945 // Description: MFW memory size variable changed from U16 -> U32
1946 // Solution: 'd' is checked against 'MAX_IDENTS' to restrict increment beyond limit
1947 for (i = 0; (i < g_smscb_data.CBTopics.length) && (d < MAX_IDENTS); i++)
1948 {
1949
1950 SmsCbInfo->msg_id[d] = g_smscb_data.CBTopics.entry[i].msg_id;
1951 /* ??? update here PCM with g_smscb_data.CBTopics.entry[i].name */
1952 SmsCbInfo->dcs[d] = (char)g_smscb_data.CBTopics.entry[i].dcs;
1953
1954 d++;
1955
1956 // Dec 22, 2004 REF: CRR MFW-SPR-27847 xnkulkar
1957 // Description: MFW memory size variable changed from U16 -> U32
1958 // Solution: Duplication removed
1959
1960 // SmsCbInfo->msg_id[d] = g_smscb_data.CBTopics.entry[i].msg_id;
1961 // /* ??? update here PCM with g_smscb_data.CBTopics.entry[i].name */
1962 // SmsCbInfo->dcs[d] = (char)g_smscb_data.CBTopics.entry[i].dcs;
1963
1964 // d++;
1965
1966
1967 }
1968
1969
1970 #ifdef DEBUG_SMS_CB
1971 /***************************Go-lite Optimization changes Start***********************/
1972 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1973 for (i = 0; i <= 25; i++)
1974 {
1975 TRACE_EVENT_P2 ("SAVING..SmsCbInfo.msg_id[i] %d i:%d", SmsCbInfo->msg_id[i],i);
1976 }
1977 /***************************Go-lite Optimization changes end***********************/
1978 #endif
1979
1980 Status = sms_set_cell_broadcast_info(State, SmsCbInfo);
1981
1982 #ifdef DEBUG_SMS_CB
1983 /***************************Go-lite Optimization changes Start***********************/
1984 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1985 TRACE_EVENT_P1 ("SAVING.Status is %d", Status);
1986 /***************************Go-lite Optimization changes end***********************/
1987 #endif
1988 /*SPR 1920, end of function, deallocate memory*/
1989 FREE_MEMORY((void*)SmsCbInfo,sizeof(T_MFW_SMS_CB_INFO));
1990 return Status;
1991 }
1992
1993
1994 /*******************************************************************************
1995
1996 $Function: smscb_get_new_cb_messages_count
1997
1998 $Description: Calls from the MainMenu
1999
2000 $Returns: none.
2001
2002 $Arguments:
2003
2004 *******************************************************************************/
2005 SHORT smscb_get_new_cb_messages_count(void)
2006 {
2007 int j;
2008 int count;
2009
2010 count = 0;
2011 /*SPR 1920, use cb_attributes list as smsCBList removed*/
2012 for (j=0; j<MAX_MIDS; j++)
2013 {
2014 if (smscb_data.cb_attributes[j].status== UNREAD_MESSAGE)
2015 {
2016 count++; /* found an unread message */
2017 }
2018 }
2019 return count;
2020 }
2021
2022 /*******************************************************************************
2023
2024 $Function: msgsExtractPhoneNumber
2025
2026 $Description: This function extracts a phone number within quotes, which
2027 is embedded in a text message.
2028
2029 $Returns:
2030 $Arguments:
2031
2032 *******************************************************************************/
2033 void msgsExtractPhoneNumber(UBYTE *InputString, UBYTE *Buffer)
2034 {
2035 UBYTE i;
2036 CHAR * FirstQuote;
2037 CHAR * SecondQuote;
2038
2039 FirstQuote = strchr((const char *)InputString, (int)"\"");
2040
2041 if (FirstQuote != NULL) /* x0039928 - Lint warning removal */
2042 {
2043 SecondQuote = strchr((const char *)FirstQuote++, (int)"\"");
2044
2045 if (SecondQuote != NULL) /* x0039928 - Lint warning removal */
2046 {
2047 for (i = 0; FirstQuote != SecondQuote; i++)
2048 Buffer[i] = FirstQuote[i];
2049 }
2050
2051 if (ss_check_ss_string((UBYTE *)Buffer) != MFW_SS_DIAL)
2052 Buffer[0] = '\0';
2053 }
2054 }
2055 #ifdef DEBUG_SMS_CB
2056 void handle_dummy_message(T_MFW_SMS_CB* Message)
2057 {
2058 USHORT i;
2059 SHORT geograhical_scope = (SHORT)0xC000;
2060 char temp_buffer[MAX_CBMSG_LEN];
2061
2062 TRACE_EVENT ("E_SMS_CB");
2063
2064 memset(temp_buffer, '\0', MAX_CBMSG_LEN);
2065
2066 //check: does the incoming CB indicates a immediate scope
2067 if (! (Message->sn & geograhical_scope) )
2068 {
2069 //Immediate scope
2070 // API - 859 - German characters were not visable in the CB message
2071 TRACE_EVENT("Immediate Scope");
2072
2073
2074
2075 for(i=0;i <= Message->msg_len;i++)
2076 {
2077 //check now for the termination "0x00D"
2078 //the message is NOT terminated with '\0'
2079 if (Message->cb_msg[i] EQ 0x0d)
2080 {
2081 Message->cb_msg[i]='\0';
2082 }
2083 }
2084 // API - 859 - Convert the the incoming GSM Text to ASCII
2085 ATB_convert_String(Message->cb_msg, MFW_DCS_8bits, Message->msg_len,
2086 temp_buffer, MFW_ASCII, MAX_CBMSG_LEN, FALSE);
2087 #ifdef MMI_HOMEZONE_ENABLED // SH 11/12/01
2088 /* SPR759 - SH - Homezone: check to see if CB gives us the coordinates of the centre of the current cell */
2089
2090 if (Message->msg_id==HZ_IDENTIFIER)
2091 {
2092 homezoneCBData(Message->cb_msg);
2093 }
2094 else
2095 {
2096 #endif // HOMEZONE
2097
2098 //display now on the idle screen
2099
2100 addCBCH(temp_buffer, IdleNewCBImmediateMessage);
2101 statusCBCH(TRUE);
2102 #ifdef MMI_HOMEZONE_ENABLED
2103 } /* SPR759 - SH */
2104 #endif
2105 }
2106
2107 else //Normal scope
2108
2109 {
2110 TRACE_EVENT("Normal Scope");
2111 //only for single- and the last page of mulitpages
2112 //other pages have not the termination "0x00D"
2113
2114 // API - 859 - Convert the the incoming GSM Text to ASCII
2115
2116 {
2117 Message->cb_msg[MAX_CBMSG_LEN-1]='\0';
2118 }
2119 ATB_convert_String(Message->cb_msg, MFW_DCS_8bits, Message->msg_len,
2120 temp_buffer, MFW_ASCII, /*MAX_MSG_LEN*/MAX_CBMSG_LEN, FALSE);
2121 memcpy(Message->cb_msg, temp_buffer, MAX_CBMSG_LEN);
2122 //indicate on the idle screen the new incoming cb
2123 addCBCH( NULL, IdleNewCBNormalMessage );
2124 statusCBCH(TRUE);
2125 //save the incoming cb messages in the fifo
2126 sms_new_incoming_cb (Message);
2127
2128 }
2129
2130 }
2131 /*******************************************************************************
2132
2133 $Function: test_function_to_send_cb
2134
2135 $Description: This function is only for simulation of incoming cb messages
2136
2137 $Returns:
2138 $Arguments:
2139
2140 *******************************************************************************/
2141
2142
2143 void test_function_to_send_cb (void)
2144 {
2145 T_MFW_SMS_CB Message;
2146 UBYTE i;
2147
2148
2149 DEBUG = FALSE;
2150
2151 // for testing only
2152 //#if 0
2153 TRACE_EVENT("Testcase");
2154 Message.sn = 60;
2155 Message.msg_id = 60;
2156 Message.page = 1;
2157 Message.pages = 1;
2158 strcpy (Message.cb_msg, "60 Toronto Blue Jays to a 4-0 victory Tuesday ");
2159 Message.msg_len= strlen(Message.cb_msg);
2160 handle_dummy_message (&Message);
2161
2162
2163
2164 Message.sn = 61;
2165 Message.msg_id = 61;
2166 Message.page = 1;
2167 Message.pages = 1;
2168 strcpy (Message.cb_msg, "61 Toronto Blue Jays to a 4-0 victory Tuesday");
2169 Message.msg_len= strlen(Message.cb_msg);
2170 handle_dummy_message (&Message);
2171
2172
2173
2174 Message.sn = 62;
2175 Message.msg_id = 61;
2176 Message.page = 1;
2177 Message.pages = 1;
2178 strcpy (Message.cb_msg, "61/2 Toronto Blue Jays to a 4-0 victory Tuesday");
2179 Message.msg_len= strlen(Message.cb_msg);
2180 handle_dummy_message (&Message);
2181
2182 Message.sn = 55;
2183 Message.msg_id = 55;
2184 Message.page = 1;
2185 Message.pages = 1;
2186 strcpy (Message.cb_msg, " 55 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ");
2187 Message.msg_len= strlen(Message.cb_msg);
2188 Message.dcs = MFW_DCS_8bits;
2189 handle_dummy_message (&Message);
2190
2191
2192
2193 Message.sn = /*56*/0xC038;
2194 Message.msg_id = 55;
2195 Message.page = 1;
2196 Message.pages = 2;
2197 strcpy (Message.cb_msg, "55/2 1/2 Toronto Blue Jays to a 4-0 victory Tuesday Multipage");
2198 Message.msg_len= strlen(Message.cb_msg);
2199 handle_dummy_message (&Message);
2200
2201
2202
2203 Message.sn = /*56*/0xC038;
2204 Message.msg_id = 56;
2205 Message.page = 2;
2206 Message.pages = 2;
2207 strcpy (Message.cb_msg, "56 2/2 Toronto Blue Jays to a 4-0 victory Tuesday Multipage");
2208 Message.msg_len= strlen(Message.cb_msg);
2209 handle_dummy_message (&Message);
2210
2211 Message.sn = 58;
2212 Message.msg_id = 58;
2213 Message.page = 1;
2214 Message.pages = 1;
2215 strcpy (Message.cb_msg, "58 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ");
2216 Message.msg_len= strlen(Message.cb_msg);
2217 handle_dummy_message (&Message);
2218
2219 Message.sn = /*56*/0xC038;
2220 Message.msg_id = 56;
2221 Message.page = 2;
2222 Message.pages = 2;
2223 strcpy (Message.cb_msg, "56 2/2 Toronto Blue Jays to a 4-0 victory Tuesday Multipage");
2224 Message.msg_len= strlen(Message.cb_msg);
2225 handle_dummy_message (&Message);
2226
2227 Message.sn = 45;
2228 Message.msg_id = 45;
2229 Message.page = 1;
2230 Message.pages = 1;
2231 strcpy (Message.cb_msg, "45 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ");
2232 Message.msg_len= strlen(Message.cb_msg);
2233 handle_dummy_message (&Message);
2234
2235 //#if 0
2236
2237 Message.sn = 16384;
2238 Message.msg_id = 59;
2239 Message.page = 1;
2240 Message.pages = 15;
2241 strcpy (Message.cb_msg, "58 1/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage***");
2242 Message.msg_len= strlen(Message.cb_msg);
2243 handle_dummy_message (&Message);
2244
2245
2246
2247 Message.sn = 16384;
2248 Message.msg_id = 59;
2249 Message.page = 2;
2250 Message.pages = 15;
2251 strcpy (Message.cb_msg, "59 2/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2252 Message.msg_len= strlen(Message.cb_msg);
2253 handle_dummy_message (&Message);
2254
2255 Message.sn = 16384;
2256 Message.msg_id = 59;
2257 Message.page = 3;
2258 Message.pages = 15;
2259 strcpy (Message.cb_msg, "59 3/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage***");
2260 Message.msg_len= strlen(Message.cb_msg);
2261 handle_dummy_message (&Message);
2262 Message.sn = 16384;
2263 Message.msg_id = 59;
2264 Message.page = 4;
2265 Message.pages = 15;
2266 strcpy (Message.cb_msg, "59 4/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage***");
2267 Message.msg_len= strlen(Message.cb_msg);
2268 handle_dummy_message (&Message);
2269
2270
2271
2272 Message.sn = 16384;
2273 Message.msg_id = 59;
2274 Message.page = 5;
2275 Message.pages = 15;
2276 strcpy (Message.cb_msg, "59 5/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2277 Message.msg_len= strlen(Message.cb_msg);
2278 handle_dummy_message (&Message);
2279
2280 Message.sn = 16384;
2281 Message.msg_id = 59;
2282 Message.page = 6;
2283 Message.pages = 15;
2284 strcpy (Message.cb_msg, "59 6/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2285 Message.msg_len= strlen(Message.cb_msg);
2286 handle_dummy_message (&Message);
2287 Message.sn = 16384;
2288 Message.msg_id = 59;
2289 Message.page = 7;
2290 Message.pages = 15;
2291 strcpy (Message.cb_msg, "59 7/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage***");
2292 Message.msg_len= strlen(Message.cb_msg);
2293 handle_dummy_message (&Message);
2294
2295
2296
2297 Message.sn = 16384;
2298 Message.msg_id = 59;
2299 Message.page = 8;
2300 Message.pages = 15;
2301 strcpy (Message.cb_msg, "59 8/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2302 Message.msg_len= strlen(Message.cb_msg);
2303 handle_dummy_message (&Message);
2304
2305 Message.sn = 16384;
2306 Message.msg_id = 59;
2307 Message.page = 9;
2308 Message.pages = 15;
2309 strcpy (Message.cb_msg, "59 9/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2310 Message.msg_len= strlen(Message.cb_msg);
2311 handle_dummy_message (&Message);
2312 Message.sn = 16384;
2313 Message.msg_id = 59;
2314 Message.page = 10;
2315 Message.pages = 15;
2316 strcpy (Message.cb_msg, "59 10/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2317 Message.msg_len= strlen(Message.cb_msg);
2318 handle_dummy_message (&Message);
2319
2320
2321
2322 Message.sn = 16384;
2323 Message.msg_id = 59;
2324 Message.page = 11;
2325 Message.pages = 15;
2326 strcpy (Message.cb_msg, "59 11/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2327 Message.msg_len= strlen(Message.cb_msg);
2328 handle_dummy_message (&Message);
2329
2330 Message.sn = 16384;
2331 Message.msg_id = 59;
2332 Message.page = 12;
2333 Message.pages = 15;
2334 strcpy (Message.cb_msg, "59 12/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2335 Message.msg_len= strlen(Message.cb_msg);
2336 handle_dummy_message (&Message);
2337 Message.sn = 16384;
2338 Message.msg_id = 59;
2339 Message.page = 13;
2340 Message.pages = 15;
2341 strcpy (Message.cb_msg, "59 13/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2342 Message.msg_len= strlen(Message.cb_msg);
2343 handle_dummy_message (&Message);
2344
2345
2346
2347 Message.sn = 16384;
2348 Message.msg_id = 59;
2349 Message.page = 14;
2350 Message.pages = 15;
2351 strcpy (Message.cb_msg, "59 14/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage***");
2352 Message.msg_len= strlen(Message.cb_msg);
2353 handle_dummy_message (&Message);
2354
2355 Message.sn = 16384;
2356 Message.msg_id = 59;
2357 Message.page = 15;
2358 Message.pages = 15;
2359 strcpy (Message.cb_msg, "59 15/15 Toronto Blue Jays to a 4-0 victory Tuesday Multipage ***");
2360 Message.msg_len= strlen(Message.cb_msg);
2361 handle_dummy_message (&Message);
2362 //#endif
2363
2364 #if 0
2365
2366
2367
2368
2369 Message.sn = 63;
2370 Message.msg_id = 63;
2371 Message.page = 1;
2372 Message.pages = 1;
2373 strcpy (Message.cb_msg, "63 Toronto Blue Jays to a 4-0 victory Tuesday");
2374 Message.msg_len= strlen(Message.cb_msg);
2375 handle_dummy_message (&Message);
2376
2377
2378 Message.sn = 64;
2379 Message.msg_id = 64;
2380 Message.page = 1;
2381 Message.pages = 1;
2382 strcpy (Message.cb_msg, "64 Toronto Blue Jays to a 4-0 victory Tuesday");
2383 Message.msg_len= strlen(Message.cb_msg);
2384 handle_dummy_message (&Message);
2385
2386 Message.sn = 65;
2387 Message.msg_id = 65;
2388 Message.page = 1;
2389 Message.pages = 3;
2390 strcpy (Message.cb_msg, "65 1/3 Toronto Blue Jays to a 4-0 victory Tuesday");
2391 Message.msg_len= strlen(Message.cb_msg);
2392 handle_dummy_message (&Message);
2393
2394
2395 Message.sn = 65;
2396 Message.msg_id = 65;
2397 Message.page = 2;
2398 Message.pages = 3;
2399 strcpy (Message.cb_msg, "65 2/3 Toronto Blue Jays to a 4-0 victory Tuesday 65");
2400 Message.msg_len= strlen(Message.cb_msg);
2401 handle_dummy_message (&Message);
2402
2403
2404 Message.sn = 65;
2405 Message.msg_id = 65;
2406 Message.page = 3;
2407 Message.pages = 3;
2408 strcpy (Message.cb_msg, "65 3/3 Toronto Blue Jays to a 4-0 victory Tuesday 65");
2409 Message.msg_len= strlen(Message.cb_msg);
2410 handle_dummy_message (&Message);
2411
2412
2413 Message.sn = 66;
2414 Message.msg_id = 66;
2415 Message.page = 1;
2416 Message.pages = 1;
2417 strcpy (Message.cb_msg, "66 Toronto Blue Jays to a 4-0 victory Tuesday");
2418 Message.msg_len= strlen(Message.cb_msg);
2419 handle_dummy_message (&Message);
2420
2421 Message.sn = 67;
2422 Message.msg_id = 67;
2423 Message.page = 1;
2424 Message.pages = 1;
2425 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 67");
2426 Message.msg_len= strlen(Message.cb_msg);
2427 handle_dummy_message (&Message);
2428
2429 Message.sn = 68;
2430 Message.msg_id = 68;
2431 Message.page = 1;
2432 Message.pages = 1;
2433 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 68 ");
2434 Message.msg_len= strlen(Message.cb_msg);
2435 handle_dummy_message (&Message);
2436
2437
2438 Message.sn = 72;
2439 Message.msg_id = 72;
2440 Message.page = 1;
2441 Message.pages = 4;
2442 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 72:1 ");
2443 Message.msg_len= strlen(Message.cb_msg);
2444 handle_dummy_message (&Message);
2445
2446 Message.sn = 72;
2447 Message.msg_id = 72;
2448 Message.page = 2;
2449 Message.pages = 4;
2450 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 72:2 ");
2451 Message.msg_len= strlen(Message.cb_msg);
2452 handle_dummy_message (&Message);
2453
2454 Message.sn = 72;
2455 Message.msg_id = 72;
2456 Message.page = 3;
2457 Message.pages = 4;
2458 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 72:3 ");
2459 Message.msg_len= strlen(Message.cb_msg);
2460 handle_dummy_message (&Message);
2461
2462 Message.sn = 72;
2463 Message.msg_id = 72;
2464 Message.page =4;
2465 Message.pages = 4;
2466 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 72:4 ");
2467 Message.msg_len= strlen(Message.cb_msg);
2468 handle_dummy_message (&Message);
2469
2470 Message.sn = 73;
2471 Message.msg_id = 73;
2472 Message.page = 1;
2473 Message.pages = 1;
2474 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 73 ");
2475 Message.msg_len= strlen(Message.cb_msg);
2476 handle_dummy_message (&Message);
2477
2478
2479 Message.sn = 74;
2480 Message.msg_id = 74;
2481 Message.page = 1;
2482 Message.pages = 1;
2483 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 74");
2484 Message.msg_len= strlen(Message.cb_msg);
2485 handle_dummy_message (&Message);
2486
2487 Message.sn = 75;
2488 Message.msg_id = 75;
2489 Message.page = 1;
2490 Message.pages = 1;
2491 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 75 ");
2492 Message.msg_len= strlen(Message.cb_msg);
2493 handle_dummy_message (&Message);
2494
2495 Message.sn = 77;
2496 Message.msg_id = 77;
2497 Message.page = 1;
2498 Message.pages = 2;
2499 strcpy (Message.cb_msg, "1/2 Toronto Blue Jays to a 4-0 victory Tuesday 77:1");
2500 Message.msg_len= strlen(Message.cb_msg);
2501 handle_dummy_message (&Message);
2502
2503 Message.sn = 77;
2504 Message.msg_id = 77;
2505 Message.page = 2;
2506 Message.pages = 2;
2507 strcpy (Message.cb_msg, "2/2 Toronto Blue Jays to a 4-0 victory Tuesday 77:2 ");
2508 Message.msg_len= strlen(Message.cb_msg);
2509 handle_dummy_message (&Message);
2510 //
2511 Message.sn = 78;
2512 Message.msg_id = 78;
2513 Message.page = 1;
2514 Message.pages = 1;
2515 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 78");
2516 Message.msg_len= strlen(Message.cb_msg);
2517 handle_dummy_message (&Message);
2518
2519 Message.sn = 16386;
2520 Message.msg_id = 79;
2521 Message.page = 1;
2522 Message.pages = 1;
2523 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 79 ");
2524 Message.msg_len= strlen(Message.cb_msg);
2525 handle_dummy_message (&Message);
2526
2527 Message.sn = 80;
2528 Message.msg_id = 80;
2529 Message.page = 1;
2530 Message.pages = 3;
2531 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 80:1");
2532 Message.msg_len= strlen(Message.cb_msg);
2533 handle_dummy_message (&Message);
2534
2535
2536 Message.sn = 80;
2537 Message.msg_id = 80;
2538 Message.page = 3;
2539 Message.pages = 3;
2540 strcpy (Message.cb_msg, "80 2/3 Yoronto Blue Jays to a 4-0 Tuesday:3");
2541 Message.msg_len= strlen(Message.cb_msg);
2542 handle_dummy_message (&Message);
2543
2544 Message.sn = 80;
2545 Message.msg_id = 80;
2546 Message.page = 2;
2547 Message.pages = 3;
2548 strcpy (Message.cb_msg, "80 1/3 Toronto Blue Jays to Tuesday:2");
2549 Message.msg_len= strlen(Message.cb_msg);
2550 handle_dummy_message (&Message);
2551
2552 DEBUG = TRUE;
2553
2554 Message.sn = 83;
2555 Message.msg_id = 83;
2556 Message.page = 1;
2557 Message.pages = 1;
2558 strcpy (Message.cb_msg, " Toronto Blue Jays to a 4-0 victory Tuesday 83");
2559 Message.msg_len= strlen(Message.cb_msg);
2560 handle_dummy_message (&Message);
2561 #endif
2562 }
2563
2564 #endif
2565
2566
2567 /*******************************************************************************
2568
2569 $Function: sms_cb_init
2570
2571 $Description: This is initialize the CB fifo and the attributes after switch on the mobile
2572
2573 $Returns:
2574 $Arguments:
2575
2576 *******************************************************************************/
2577 void sms_cb_init (void)
2578 {
2579
2580 //for tracing
2581 #ifdef DEBUG_SMS_CB
2582 char buf [100];
2583 #endif
2584
2585
2586 UBYTE i;
2587
2588
2589 //set to the default, "FF" -> no CB messages stored
2590 smscb_data.used_pointer = 0xFF;
2591
2592 //set to the default, "0" -> free spaces on the first index in fifo
2593 smscb_data.free_pointer = 0;
2594
2595
2596 //set the fifo to the default
2597 for (i=0; i<MAX_STORED_PAGES -1 ; i++)
2598 {
2599 smscb_data.cb_attributes[i].next_link = i + 1;
2600 }
2601
2602 for (i=0; i<MAX_STORED_PAGES ; i++)
2603 {
2604 smscb_data.cb_attributes[i].start_page = 0;
2605 smscb_data.cb_attributes[i].header = NULL;/* SPR 1920,ensure unalloacted pointers set to NULL*/
2606 }
2607
2608
2609
2610 //"FF" on the last entry means end of the free spaces list
2611 smscb_data.cb_attributes[MAX_STORED_PAGES-1].next_link = 0xFF;
2612 smscb_getCBsettings();
2613
2614 if (settingsGetStatus(SettingsCBDisable))
2615 smscb_setCBsettings(SMSCB_SWITCH_OFF);
2616 else
2617 smscb_setCBsettings(SMSCB_SWITCH_ON);
2618 //for tracing
2619
2620
2621
2622
2623
2624 }
2625
2626 /*******************************************************************************
2627
2628 $Function: sms_cb_exit
2629
2630 $Description: This deallocates any memory. MC added for SPR 1920
2631
2632 $Returns:
2633 $Arguments:
2634
2635 *******************************************************************************/
2636 void sms_cb_exit (void)
2637 {
2638 int i;
2639 /*for each storage space*/
2640 for (i=0;i<MAX_STORED_PAGES;i++)
2641 { /*if memory allocated, deallocate it*/
2642 if(smscb_data.messages[i] != NULL)
2643 { mfwFree((U8*)smscb_data.messages[i], CB_PAGE_LENGTH);
2644 smscb_data.messages[i] = NULL;
2645 }
2646 }
2647 for(i=0; i<MAX_MIDS;i++)
2648 { if (smscb_data.cb_attributes[i].header != NULL)
2649 { FREE_MEMORY((void*)smscb_data.cb_attributes[i].header,sizeof(char)*25);
2650 smscb_data.cb_attributes[i].header = NULL;
2651 }
2652 }
2653 }
2654
2655 /*******************************************************************************
2656
2657 $Function: sms_new_incoming_cb
2658
2659 $Description: This function will be call after each NEW incoming cb messages.
2660 It checks for free spaces and organize to save the cb messages
2661 in the right order.
2662 $Returns:
2663
2664 $Arguments:
2665
2666 *******************************************************************************/
2667 void sms_new_incoming_cb (T_MFW_SMS_CB *Message)
2668 {
2669
2670 //only for tracing
2671 #ifdef DEBUG_SMS_CB
2672 UBYTE i, test;
2673 #endif
2674
2675
2676 //set to default
2677 UBYTE result =0;
2678 smscb_data.found_mid = FALSE;
2679 smscb_data.clear_mid = FALSE;
2680
2681
2682 //only for tracing
2683 #ifdef DEBUG_SMS_CB
2684 TRACE_EVENT("--------------start------------");
2685 #endif //DEBUG_SMS_CB
2686
2687
2688 //search the new MID with the MID's in the fifo.
2689 //used_pointer EQ 0xFF means there is no message in the fifo
2690 if (smscb_data.used_pointer NEQ 0xFF)
2691 {
2692 result = sms_cb_search_mid (Message->msg_id, Message->sn);
2693 }
2694
2695
2696 //error: in searching mid
2697 if (result EQ 0xAA)
2698 {
2699 TRACE_EVENT("sms cb ERROR, in searching mid");
2700 return;
2701 }
2702
2703
2704 // does the message with the same MID already exist in the fifo ?
2705 if(smscb_data.found_mid)
2706 {
2707 TRACE_EVENT("MID already exist");
2708
2709 sms_cb_delete_message (Message->msg_id);
2710
2711
2712 smscb_data.clear_mid = TRUE;
2713 }
2714
2715
2716 // does we have free space ?
2717 if (smscb_data.free_pointer EQ 0xFF)
2718 {
2719 //no free spaces -> means overwrite the oldest message
2720 sms_cb_overwrite_old_message (Message);
2721
2722 }
2723 else // does we have free space ?
2724 {
2725 //still free spaces
2726 sms_cb_store_message (Message);
2727
2728 }
2729
2730
2731
2732 //only for tracing
2733 #ifdef DEBUG_SMS_CB
2734 /***************************Go-lite Optimization changes Start***********************/
2735 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
2736 TRACE_EVENT_P1("5 smscb_data.used_pointer %d ", smscb_data.used_pointer);
2737
2738 TRACE_EVENT_P1("5 smscb_data.free_pointer %d ", smscb_data.free_pointer);
2739 /***************************Go-lite Optimization changes end***********************/
2740 TRACE_EVENT("--------------finish------------");
2741
2742
2743 #endif //DEBUG_SMS_CB
2744
2745 }
2746
2747
2748
2749 /*******************************************************************************
2750
2751 $Function: sms_cb_store_message
2752
2753 $Description: This function will be call when we have still free space for saving
2754 new incoming cb messages.
2755 $Returns:
2756
2757 $Arguments:
2758
2759 *******************************************************************************/
2760 UBYTE sms_cb_store_message (T_MFW_SMS_CB *Message)
2761 {
2762
2763 TRACE_FUNCTION("sms_cb_store_message");
2764
2765
2766 //it is only for the first time
2767 if (smscb_data.used_pointer EQ 0xFF)
2768 {
2769 // request for a free space
2770 smscb_data.used_pointer = smscb_data.free_pointer;
2771 }
2772
2773
2774 //save the new message in the fifo
2775 /*MC SPR 1920 if memory not alloacted for message, allocate some*/
2776 TRACE_EVENT_P1("Allocating memory to slot %d for CB message", smscb_data.free_pointer);
2777
2778 if (smscb_data.messages[smscb_data.free_pointer] == NULL)
2779 if ((smscb_data.messages[smscb_data.free_pointer] = (char*) mfwAlloc(sizeof(char)*CB_PAGE_LENGTH)) != NULL)
2780 memcpy(smscb_data.messages[smscb_data.free_pointer], Message->cb_msg,CB_PAGE_LENGTH);
2781
2782 /*MC end*/
2783 //save the attributes of the new cb
2784 sms_cb_store_attributes (smscb_data.free_pointer, Message);
2785
2786 //set the status of the message
2787 smscb_data.cb_attributes[smscb_data.free_pointer].status = UNREAD_MESSAGE;
2788
2789 //was it the last free space ?
2790 if (smscb_data.cb_attributes[smscb_data.free_pointer].next_link EQ 0xFF)
2791 {
2792 //no more free space available
2793
2794 UBYTE temp, result;
2795
2796
2797 //keep the link-value for later
2798 temp = smscb_data.used_pointer;
2799
2800 //find the termination in the link list
2801 result = sms_cb_find_termination (&smscb_data.used_pointer);
2802
2803 //error: couldnt find the termination ?!
2804 if (result EQ 0xAA)
2805 {
2806 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
2807 return 0; // RAVI
2808 }
2809
2810
2811 //update the link-list
2812 smscb_data.cb_attributes[smscb_data.used_pointer].next_link = smscb_data.free_pointer;
2813
2814 //no more free space
2815 smscb_data.free_pointer = 0xFF;
2816
2817 //update the used pointer
2818 smscb_data.used_pointer = temp;
2819
2820 //did it clear before ?
2821 if (smscb_data.clear_mid)
2822 {
2823 smscb_data.used_pointer = smscb_data.result_used;
2824 }
2825
2826
2827 }
2828 else //was it the last free space ?
2829 {
2830 //no, still free space available
2831
2832 UBYTE temp, temp_2, result;
2833
2834 //keep the usedpointer-value for later
2835 temp_2 = smscb_data.used_pointer;
2836
2837
2838 //keep the link-value for later
2839 temp = smscb_data.cb_attributes[smscb_data.free_pointer].next_link;
2840
2841
2842 //terminate the used list
2843 smscb_data.cb_attributes[smscb_data.free_pointer].next_link = 0xFF;
2844
2845
2846 //find the termination in the link list
2847 result = sms_cb_find_termination (&smscb_data.used_pointer);
2848
2849 //error: couldnt find the termination ?!
2850 if (result EQ 0xAA)
2851 {
2852 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
2853 return 0;
2854 }
2855
2856
2857 //update the use pointer
2858 if (smscb_data.used_pointer NEQ smscb_data.free_pointer)
2859 {
2860 smscb_data.cb_attributes[smscb_data.used_pointer].next_link = smscb_data.free_pointer;
2861 }
2862
2863
2864 // update the free pointer as well
2865 smscb_data.free_pointer = temp;
2866
2867
2868 //did it clear before ?
2869 if (smscb_data.clear_mid)
2870 {
2871 smscb_data.used_pointer = smscb_data.result_used;
2872 }
2873 else
2874 {
2875 //update the used pointer
2876 smscb_data.used_pointer = temp_2 ;
2877 }
2878
2879
2880 }
2881 //ADDED BY RAVI- 28-11-2005
2882 return 1;
2883 //END RAVI - 28-11-2005
2884 }
2885
2886 /*******************************************************************************
2887
2888 $Function: sms_cb_overwrite_old_message
2889
2890 $Description: This function will be call when we don't have free space for saving
2891 new incoming cb messages. The new cb just overwrite the
2892 oldest cb in the fifo.
2893
2894 $Returns:
2895
2896 $Arguments:
2897
2898 *******************************************************************************/
2899 UBYTE sms_cb_overwrite_old_message (T_MFW_SMS_CB *Message)
2900 {
2901 // UBYTE temp, temp_2, result; // RAVI
2902
2903 //only tracing
2904 #ifdef DEBUG_SMS_CB
2905 /***************************Go-lite Optimization changes Start***********************/
2906 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
2907 TRACE_EVENT_P1("used_pointer= %d ", smscb_data.used_pointer);
2908 TRACE_EVENT_P1("pages = %d, ", smscb_data.cb_attributes[smscb_data.used_pointer].pages);
2909 TRACE_EVENT_P1("page = %d ", smscb_data.cb_attributes[smscb_data.used_pointer].page);
2910 TRACE_EVENT_P1( "mid = %d ", smscb_data.cb_attributes[smscb_data.used_pointer].mid);
2911 /***************************Go-lite Optimization changes end***********************/
2912 #endif //DEBUG_SMS_CB
2913
2914
2915 TRACE_EVENT("sms_cb_overwrite_old_message");
2916
2917 //keep the value for later
2918 // temp = smscb_data.used_pointer;
2919
2920
2921 //find the page in the fifo with the same MID number & delete them
2922 sms_cb_delete_message (smscb_data.cb_attributes[smscb_data.used_pointer].mid);
2923
2924
2925 //now we have free space to store the new incoming cb message
2926 sms_cb_store_message (Message);
2927
2928 return 1; // ADDED BY RAVI - 28-11-2005
2929
2930 }
2931
2932 /*******************************************************************************
2933
2934 $Function: sms_cb_store_attributes
2935
2936 $Description: Store the attributes of the new incoming cb
2937
2938 Attributes are stored seperatly from the message text
2939 $Returns:
2940
2941 $Arguments:
2942
2943 *******************************************************************************/
2944
2945 void sms_cb_store_attributes (UBYTE position, T_MFW_SMS_CB *Message)
2946 {
2947 smscb_data.cb_attributes[position].sn = Message->sn;
2948 smscb_data.cb_attributes[position].mid = Message->msg_id;
2949 smscb_data.cb_attributes[position].dcs = Message->dcs;
2950 smscb_data.cb_attributes[position].page = Message->page;
2951 smscb_data.cb_attributes[position].pages = Message->pages;
2952 smscb_data.cb_attributes[position].msg_len = Message->msg_len;
2953
2954 }
2955
2956
2957 /*******************************************************************************
2958
2959 $Function: sms_cb_search_mid
2960
2961 $Description: This function searchs the new incoming message in the
2962 fifo for the already existing stored messages.
2963 If true, the stored messages in the fifo will be removed
2964
2965 $Returns:
2966
2967 $Arguments:
2968
2969 *******************************************************************************/
2970 UBYTE sms_cb_search_mid (USHORT mid ,SHORT sn)
2971 {
2972 UBYTE temp, i=0;
2973 SHORT update_number_mask = 0x0F;
2974
2975 temp = smscb_data.used_pointer;
2976
2977
2978 if (smscb_data.cb_attributes[temp].mid EQ mid)
2979 {
2980 //found the mid in the fifo
2981 TRACE_EVENT("Matching MID");
2982 if ((smscb_data.cb_attributes[temp].sn & update_number_mask) NEQ
2983 (sn & update_number_mask) )
2984 {
2985 //the new cb is the update of the existing one
2986 smscb_data.found_mid = TRUE;
2987 TRACE_EVENT("found = True, return");
2988 return temp;
2989 }
2990 /*SPR 2429, return this index as otherwise there will be two
2991 copies of the same message*/
2992 TRACE_EVENT("Serial numbers match");
2993 return temp;
2994 }
2995
2996
2997 while (smscb_data.cb_attributes[temp].next_link NEQ 0xFF)
2998 {
2999
3000 // going through the link list
3001 temp = smscb_data.cb_attributes[temp].next_link;
3002
3003
3004 if (smscb_data.cb_attributes[temp].mid EQ mid)
3005 {
3006 //found the mid in the fifo
3007 TRACE_EVENT_P1("Matching MID at location:%d", temp);
3008 if ((smscb_data.cb_attributes[temp].sn & update_number_mask) NEQ
3009 (sn & update_number_mask) )
3010 {
3011
3012 //the new cb is the update of the existing one in the fifo
3013 smscb_data.found_mid = TRUE;
3014 return temp;
3015
3016
3017 }
3018 /*SPR 2429, return this index as otherwise there will be two
3019 copies of the same message*/
3020 TRACE_EVENT("Serial numbers match");
3021 return temp;/*SHould just replace old one with new one anyway*/
3022 }
3023
3024
3025 // only to be sure there is a ever ending loop
3026 i++;
3027 if (i > MAX_STORED_PAGES)
3028 return 0xAA;
3029 }
3030
3031 return temp;
3032 }
3033
3034
3035
3036 /*******************************************************************************
3037
3038 $Function: sms_cb_delete_message
3039
3040 $Description: This function delete the messages in the fifo, even for multipages
3041
3042 $Returns:
3043
3044 $Arguments:
3045
3046 *******************************************************************************/
3047 UBYTE sms_cb_delete_message (USHORT mid)
3048 {
3049
3050 //only tracing
3051 #ifdef DEBUG_SMS_CB
3052 char buf[100];
3053 #endif
3054
3055 UBYTE temp, temp_2, result; // , i=0; // RAVI
3056
3057 TRACE_EVENT("sms_cb_delete_message");
3058
3059
3060 //keep the value for later
3061 temp_2 = smscb_data.used_pointer;
3062
3063
3064 // keep the value for later
3065 smscb_data.start_used = smscb_data.used_pointer;
3066
3067 //search for the first page of the multipages
3068 smscb_data.start_used = sms_cb_find_startpoint (mid, smscb_data.used_pointer);
3069
3070 //error: couldnt find the termination ?!
3071 if (smscb_data.start_used EQ 0xAA)
3072 {
3073 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3074 return 0; // RAVI
3075 }
3076
3077
3078 //found immediately ?
3079 if (smscb_data.start_used EQ smscb_data.used_pointer)
3080 {
3081 //is in the OLDEST position in the fifo
3082
3083 TRACE_EVENT("message in oldest position in FIFO");
3084
3085 //keep the value for later
3086 temp = smscb_data.used_pointer;
3087
3088 //search for the last page
3089 smscb_data.end_used = sms_cb_find_endpoint (mid, smscb_data.used_pointer);
3090
3091
3092 //error: couldnt find the termination ?!
3093 if (smscb_data.end_used EQ 0xAA)
3094 {
3095 TRACE_EVENT("sms cb ERROR");
3096 return 0; // RAVI
3097 }
3098
3099
3100
3101 if ( (smscb_data.cb_attributes[smscb_data.used_pointer].next_link EQ 0xFF) &&
3102 (smscb_data.cb_attributes[smscb_data.used_pointer].mid EQ mid) )
3103 {
3104 //it is the oldest cb and also the only one in the fifo
3105 TRACE_EVENT("oldest position and the only one in the list");
3106
3107
3108 //deleted messages -> now more space availabe -> update the free pointer
3109 result = sms_cb_update_free_pointer (temp);
3110
3111 //terminate the free pointer list
3112 //smscb_data.cb_attributes[smscb_data.end_used].next_link = 0xFF;
3113
3114 //error: couldnt find the termination ?!
3115 if (result EQ 0xAA)
3116 {
3117 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3118 return 0;
3119 }
3120
3121 //no anymore cb message in the fifo
3122 //terminate the use list
3123 smscb_data.used_pointer = 0xFF;
3124
3125 smscb_data.result_used = result;
3126
3127 }
3128 else
3129 {
3130 //deleted messages -> now more space availabe -> update the free pointer
3131 result = sms_cb_update_free_pointer (temp);
3132
3133 //terminate the free pointer list
3134 smscb_data.cb_attributes[smscb_data.end_used].next_link = 0xFF;
3135
3136
3137 //error: couldnt find the termination ?!
3138 if (result EQ 0xAA)
3139 {
3140 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3141 return 0;
3142 }
3143
3144 }
3145
3146
3147 }
3148 else //found immediately ?
3149 {
3150
3151 //keep the value for later
3152 temp = smscb_data.used_pointer;
3153
3154 //search for the last page of the multipages
3155 smscb_data.end_used = sms_cb_find_endpoint (mid, smscb_data.used_pointer);
3156
3157 if (smscb_data.start_used EQ 0xAA)
3158 {
3159 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3160 return 0;
3161 }
3162
3163
3164 if (smscb_data.cb_attributes[smscb_data.used_pointer].next_link EQ 0xFF &&
3165 smscb_data.cb_attributes[smscb_data.used_pointer].mid EQ mid)
3166 {
3167 //is in the the latest position in the fifo
3168
3169 TRACE_EVENT("multipage is in the latest position");
3170
3171 //terminate the position where the multipage began
3172 smscb_data.cb_attributes[smscb_data.start_used].next_link= 0xFF;
3173
3174
3175 //deleted messages -> now more space availabe -> update the free pointer
3176 result = sms_cb_update_free_pointer (temp);
3177
3178 //terminate the free pointer list
3179 smscb_data.cb_attributes[smscb_data.used_pointer].next_link = 0xFF;
3180
3181
3182 //error: couldnt find the termination ?!
3183 if (result EQ 0xAA)
3184 {
3185 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3186 return 0;
3187 }
3188
3189 smscb_data.result_used = temp_2;
3190 smscb_data.used_pointer = temp_2;
3191
3192
3193 }
3194 else
3195 {
3196 //is in the middle position in the fifo
3197
3198 TRACE_EVENT("multipage is in the middle position");
3199
3200 //update the link list
3201 smscb_data.cb_attributes[smscb_data.start_used].next_link = smscb_data.used_pointer;
3202
3203 //deleted messages -> now more space availabe -> update the free pointer
3204 result = sms_cb_update_free_pointer (temp);
3205
3206 //terminate the free pointer list
3207 smscb_data.cb_attributes[smscb_data.end_used].next_link = 0xFF;
3208
3209
3210
3211
3212
3213
3214 //error: couldnt find the termination ?!
3215 if (result EQ 0xAA)
3216 {
3217 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3218 return 0;
3219 }
3220
3221
3222 smscb_data.result_used = temp_2;
3223
3224 }
3225
3226
3227 }
3228 return 1; // ADDED BY RAVI - 28-11-2005
3229
3230 }
3231
3232 /*******************************************************************************
3233
3234 $Function: sms_cb_find_startpoint
3235
3236 $Description: find the startpoint of the multipage. It is also used for singlepage.
3237
3238
3239 $Returns:
3240
3241 $Arguments:
3242
3243 *******************************************************************************/
3244 UBYTE sms_cb_find_startpoint (USHORT mid, UBYTE start_used)
3245 {
3246 UBYTE i = 0;
3247
3248 //only tracing
3249 #ifdef DEBUG_SMS_CB
3250 // char buf[100];
3251
3252 TRACE_EVENT("in sms_cb_find_startpoint ");
3253 #endif //DEBUG_SMS_CB
3254
3255
3256 //search for the first page of the multipages
3257 while (smscb_data.cb_attributes[smscb_data.used_pointer].mid NEQ mid)
3258 {
3259
3260 start_used = smscb_data.used_pointer;
3261
3262 // going through the link list
3263 smscb_data.used_pointer = smscb_data.cb_attributes[smscb_data.used_pointer].next_link;
3264
3265 // only to be sure there is a ever ending loop
3266 i++;
3267 if (i > MAX_STORED_PAGES)
3268 return 0xAA;
3269 }
3270
3271 //only tracing
3272 TRACE_EVENT_P1("start_used: %d", start_used);
3273
3274 return start_used;
3275 }
3276
3277 /*******************************************************************************
3278
3279 $Function: sms_cb_find_startpoint
3280
3281 $Description: find the lastpage of the multipage.
3282 It is also used for the singlepage but in this case the
3283 end_used will be equal to used_pointer
3284
3285 $Returns:
3286
3287 $Arguments:
3288
3289 *******************************************************************************/
3290 UBYTE sms_cb_find_endpoint (USHORT mid, UBYTE end_used)
3291 {
3292 UBYTE i = 0;
3293
3294
3295
3296 //search for the last page of the multipages
3297 while (smscb_data.cb_attributes[smscb_data.used_pointer].mid EQ mid &&
3298 smscb_data.cb_attributes[smscb_data.used_pointer].next_link NEQ 0xFF )
3299 {
3300
3301 end_used = smscb_data.used_pointer;
3302
3303 // going through the link list
3304 smscb_data.used_pointer = smscb_data.cb_attributes[smscb_data.used_pointer].next_link;
3305
3306 // only to be sure there is a ever ending loop
3307 i++;
3308 if (i > MAX_STORED_PAGES)
3309 return 0xAA;
3310 }
3311
3312
3313 TRACE_EVENT_P1("end_used: %d", end_used);
3314
3315 return end_used;
3316 }
3317
3318 /*******************************************************************************
3319
3320 $Function: sms_cb_update_free_pointer
3321
3322 $Description: This function is updating the free pointer after deleting
3323 cb messages in the fifo (space available !)
3324
3325
3326 $Returns:
3327
3328 $Arguments:
3329
3330 *******************************************************************************/
3331 UBYTE sms_cb_update_free_pointer (UBYTE temp)
3332 {
3333 UBYTE update=0, i=0;
3334
3335
3336 TRACE_EVENT("sms_cb_update_free_pointer");
3337
3338
3339 TRACE_EVENT_P1("temp index:%d", temp);
3340 if (smscb_data.free_pointer EQ 0xFF)
3341 {TRACE_EVENT("free pointer = 0xff");
3342 //take the old used_pointer (before of deleting the messages)
3343 smscb_data.free_pointer = temp;
3344 /*MC SPR 1920, free the message slot*/
3345 mfwFree( (U8*)smscb_data.messages[temp], sizeof(char)*CB_PAGE_LENGTH);
3346 smscb_data.messages[temp] = NULL;
3347 }
3348 else
3349 {
3350 /*MC SPR 2429 free the message slot here too*/
3351 mfwFree( (U8*)smscb_data.messages[temp], sizeof(char)*CB_PAGE_LENGTH);
3352 smscb_data.messages[temp] = NULL;
3353
3354 //
3355 update = smscb_data.free_pointer;
3356 TRACE_EVENT_P1("free pointer:%d",smscb_data.free_pointer) ;
3357 //
3358 while (smscb_data.cb_attributes[smscb_data.free_pointer].next_link NEQ 0xFF)
3359 {
3360
3361 // going through the link list
3362 smscb_data.free_pointer = smscb_data.cb_attributes[smscb_data.free_pointer].next_link;
3363 TRACE_EVENT_P1("free pointer:%d",smscb_data.free_pointer) ;
3364
3365 // only to be sure there is a ever ending loop
3366 i++;
3367 if (i > MAX_STORED_PAGES)
3368 return 0xAA;
3369 }
3370
3371
3372 //continue the free pointer link list to the new deleted multipage
3373 smscb_data.cb_attributes[smscb_data.free_pointer].next_link = temp;
3374
3375
3376 //show on the first deleted multipage
3377 smscb_data.free_pointer = update;
3378
3379
3380 }
3381
3382
3383 //indicate that we deleted cb messages
3384 smscb_data.clear_mid = TRUE;
3385
3386
3387 //need for later
3388 smscb_data.result_used = smscb_data.used_pointer;
3389
3390 TRACE_EVENT_P1("used pointer: %d", smscb_data.used_pointer);
3391 //only for tracing
3392
3393
3394 return update;
3395
3396
3397 }
3398
3399
3400 /*******************************************************************************
3401
3402 $Function: sms_cb_find_termination
3403
3404 $Description: This function search for the termination in the link list.
3405 It jumps from one link to the another link until he founds
3406 the termination "0xFF"
3407
3408 $Returns:
3409
3410 $Arguments:
3411
3412 *******************************************************************************/
3413 UBYTE sms_cb_find_termination (UBYTE *used)
3414 {
3415 UBYTE i=0;
3416
3417 while (smscb_data.cb_attributes[*used].next_link NEQ 0xFF)
3418 {
3419 // going through the link list
3420 *used = smscb_data.cb_attributes[*used].next_link;
3421
3422 // only to be sure there is a ever ending loop
3423 i++;
3424 if (i > MAX_STORED_PAGES)
3425 return 0xAA;
3426
3427 }
3428
3429 return *used;
3430 }
3431
3432
3433 /*******************************************************************************
3434
3435 $Function: sms_cb_count_messages
3436
3437 $Description: This function counts messages in the fifo.
3438 ! Multipage are counted as one page !
3439
3440 $Returns:
3441
3442 $Arguments:
3443
3444 *******************************************************************************/
3445 UBYTE sms_cb_count_messages ( void )
3446 {
3447 UBYTE i=0, count=0, used, page, pages, mid, start_flag = 1; //, temp_used;
3448
3449
3450 for (i=0; i<MAX_STORED_PAGES ; i++)
3451 {
3452 smscb_data.cb_attributes[i].start_page = 0;
3453 }
3454 i=0;
3455
3456
3457 if (smscb_data.used_pointer EQ 0xFF)
3458 {
3459 //there are no cb messages in the fifo
3460 return count;
3461 }
3462
3463 used = smscb_data.used_pointer;
3464
3465 while ( i < MAX_STORED_PAGES)
3466 {
3467
3468 //single or multipage ?
3469 if(smscb_data.cb_attributes[used].pages EQ 0x01)
3470 {
3471 //Singlepage
3472
3473 start_flag = 1;
3474 /***************************Go-lite Optimization changes Start***********************/
3475 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3476 TRACE_EVENT_P2("11 : used%d, count%d", used,count);
3477
3478 /***************************Go-lite Optimization changes end***********************/
3479 //indicate the first page, even for singlepage
3480 smscb_data.cb_attributes[used].start_page = 0x55;
3481
3482 TRACE_EVENT_P1("1 set Flag at %d", used);
3483
3484 //check, is it the last message in the link list
3485 //if yes, not necessary to go through the link list
3486 if (smscb_data.cb_attributes[used].next_link NEQ 0xFF)
3487 {
3488 count ++;
3489
3490 // going through the link list
3491 used = smscb_data.cb_attributes[used].next_link;
3492 }
3493
3494 //is it the last message in the fifo ?
3495 if (smscb_data.cb_attributes[used].next_link EQ 0xFF)
3496 {
3497 /***************************Go-lite Optimization changes Start***********************/
3498 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3499 TRACE_EVENT_P2("1 : used%d,count%d", used,count);
3500 /***************************Go-lite Optimization changes end***********************/
3501
3502 //indicate the first page, even for singlepage
3503 smscb_data.cb_attributes[used].start_page = 0x55;
3504
3505
3506 TRACE_EVENT_P1("2 set Flag at %d", used);
3507
3508 count ++;
3509 return count;
3510 }
3511
3512
3513 }
3514 else //single or multipage ?
3515 {
3516
3517 //Multipage
3518 if (start_flag)
3519 {
3520
3521 //indicate the first page, even for singlepage
3522 smscb_data.cb_attributes[used].start_page = 0x55;
3523 /***************************Go-lite Optimization changes Start***********************/
3524 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3525 TRACE_EVENT_P1("3 set Flag at %d", used);
3526 /***************************Go-lite Optimization changes end***********************/
3527 }
3528
3529
3530 page = smscb_data.cb_attributes[used].page;
3531 pages = smscb_data.cb_attributes[used].pages;
3532 mid = smscb_data.cb_attributes[used].mid;
3533
3534 //check, is it the last message in the link list
3535 //if yes, not necessary to go through the link list
3536 if (smscb_data.cb_attributes[used].next_link NEQ 0xFF)
3537 {
3538 // going through the link list
3539 used = smscb_data.cb_attributes[used].next_link;
3540 }
3541
3542
3543 //is it the last message in the fifo ?
3544 if (smscb_data.cb_attributes[used].next_link EQ 0xFF)
3545 {
3546
3547 //The last page, does it still continue or does it complete
3548 //the multipage ?
3549 if( smscb_data.cb_attributes[used].pages EQ pages &&
3550 smscb_data.cb_attributes[used].page EQ (page+1) &&
3551 smscb_data.cb_attributes[used].page EQ smscb_data.cb_attributes[used].pages)
3552 {
3553 //this one was the last page of the multipage and
3554 //the last one in the fifo
3555 /***************************Go-lite Optimization changes Start***********************/
3556 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3557 TRACE_EVENT_P2("5 : used%d,count%d", used,count);
3558 /***************************Go-lite Optimization changes end***********************/
3559 start_flag = 0;
3560
3561 count ++;
3562 return count;
3563 }
3564 else
3565 {
3566 //the multipage is not complete yet
3567
3568 if (smscb_data.cb_attributes[used].mid EQ mid)
3569 {
3570
3571 start_flag = 0;
3572 /***************************Go-lite Optimization changes Start***********************/
3573 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3574 TRACE_EVENT_P2("6 : used%d,count%d", used,count);
3575 /***************************Go-lite Optimization changes end***********************/
3576 count ++;
3577
3578 return count;
3579 }
3580 else
3581 {
3582
3583 //this is a different page , it means the multipage before
3584 //is uncomplete !
3585
3586 start_flag = 0;
3587
3588
3589 //indicate the first page, even for singlepage
3590 smscb_data.cb_attributes[used].start_page = 0x55;
3591 /***************************Go-lite Optimization changes Start***********************/
3592 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3593 TRACE_EVENT_P1("4 set Flag at %d", used);
3594 /***************************Go-lite Optimization changes end***********************/
3595
3596 //the page before is a uncomplete multipage
3597 //and the last message is a single page
3598 // ->count twice
3599 count+=2;
3600 /***************************Go-lite Optimization changes Start***********************/
3601 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3602 TRACE_EVENT_P2("7 : used%d,count%d", used,count);
3603 /***************************Go-lite Optimization changes end***********************/
3604 return count;
3605
3606 }
3607 }
3608
3609 }
3610 else
3611 {
3612 if( smscb_data.cb_attributes[used].pages EQ pages &&
3613 smscb_data.cb_attributes[used].page EQ (page+1))
3614 {
3615 //still continue
3616 /***************************Go-lite Optimization changes Start***********************/
3617 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3618
3619 TRACE_EVENT_P2("3 : used%d,count%d", used,count);
3620 /***************************Go-lite Optimization changes end***********************/
3621 start_flag = 0;
3622
3623 }
3624 else
3625 {
3626 //there is a new page starting
3627
3628
3629 start_flag = 1;
3630
3631 count ++;
3632 /***************************Go-lite Optimization changes Start***********************/
3633 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3634
3635 TRACE_EVENT_P2("4 : used%d,count%d", used,count);
3636 /***************************Go-lite Optimization changes end***********************/
3637 }
3638 }
3639
3640 }
3641
3642
3643 // only to be sure there is a ever ending loop
3644 i++;
3645 }
3646
3647 /* x0045876, 14-Aug-2006 (WR - missing return statement at end of non-void function "sms_cb_count_messages") */
3648 return count;
3649 }
3650
3651 /*******************************************************************************
3652
3653 $Function: sms_cb_count_unread_messages
3654
3655 $Description: This function counts the unread messages in the fifo
3656
3657 $Returns:
3658
3659 $Arguments:
3660
3661 *******************************************************************************/
3662 UBYTE sms_cb_count_unread_messages (void)
3663 {
3664 UBYTE i=0, m=0, used;
3665
3666 used = smscb_data.used_pointer;
3667
3668 while (smscb_data.cb_attributes[used].next_link NEQ 0xFF)
3669 {
3670 // count only the unread messages
3671 if (smscb_data.cb_attributes[used].status EQ UNREAD_MESSAGE)
3672 m ++;
3673
3674 // going through the link list
3675 used = smscb_data.cb_attributes[used].next_link;
3676
3677 // only to be sure there is a ever ending loop
3678 i++;
3679 if (i > MAX_STORED_PAGES)
3680 return 0xAA;
3681
3682 }
3683
3684
3685 // have a check of the last one
3686 if (smscb_data.cb_attributes[used].status EQ UNREAD_MESSAGE)
3687 m ++;
3688
3689
3690 #ifdef DEBUG_SMS_CB
3691 /***************************Go-lite Optimization changes Start***********************/
3692 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3693 TRACE_EVENT_P1("count unread %d ", m);
3694 /***************************Go-lite Optimization changes end***********************/
3695 #endif
3696
3697 return m;
3698 }
3699
3700
3701 /*******************************************************************************
3702
3703 $Function: sms_cb_give_position_of_msg
3704
3705 $Description: You give the position (order of the msg from oldest to the latest)
3706 and he gives you the real positon of the link list
3707
3708 $Returns:
3709
3710 $Arguments: used : current used_pointer
3711
3712 *******************************************************************************/
3713 UBYTE sms_cb_give_position_of_msg (UBYTE used, UBYTE positon)
3714 {
3715 UBYTE i=0, m=0;
3716
3717 while ( (smscb_data.cb_attributes[used].next_link NEQ 0xFF) &&
3718 (i NEQ positon) )
3719 {
3720
3721 // going through the link list
3722 used= smscb_data.cb_attributes[used].next_link;
3723
3724 // only to be sure there is a ever ending loop
3725 if (smscb_data.cb_attributes[used].start_page EQ 0x55)
3726 {
3727 i++;
3728 }
3729
3730
3731
3732 if (m > MAX_STORED_PAGES)
3733 return 0xAA;
3734
3735 m++;
3736
3737 }
3738
3739 //return the positon in the link list
3740 return used;
3741 }
3742
3743 /*******************************************************************************
3744
3745 $Function: sms_cb_select_read
3746
3747 $Description: called by pressing the read item in SMS-Broadcast
3748
3749 $Returns:
3750
3751 $Arguments:
3752
3753
3754 *******************************************************************************/
3755 int sms_cb_select_read (MfwMnu* m, MfwMnuItem* i)
3756 {
3757
3758 sms_cb_read_msg (ALL_MESSAGE);
3759 return 1;
3760 }
3761
3762 /*******************************************************************************
3763
3764 $Function: sms_cb_read_msg
3765
3766 $Description: This function prepare to read the cb messages
3767 It could be call from everywhere.
3768
3769 $Returns:
3770
3771 $Arguments:
3772
3773
3774 *******************************************************************************/
3775 int sms_cb_read_msg (T_SMSCB_STATUS status)
3776 {
3777 UBYTE result; //, i; // RAVI
3778
3779
3780 T_MFW_HND win = mfwParent(mfw_header());
3781
3782 TRACE_FUNCTION("sms_cb_read_msg");
3783
3784
3785
3786 //count the number of the stored messages in the fifo
3787
3788 result = sms_cb_count_messages ();
3789
3790 if (result EQ 0x00)
3791 {
3792 TRACE_EVENT("sms cb ERROR, there are 0 cb messages");
3793 }
3794
3795
3796 if((smscb_data.used_pointer EQ 0xFF) || (result EQ 0x00))
3797 {
3798 TRACE_EVENT("There is no cb message stored");
3799
3800 info_screen(0, TxtEmptyList ,TxtNull, NULL);
3801 }
3802 else
3803 {
3804 /***************************Go-lite Optimization changes Start***********************/
3805 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
3806 TRACE_EVENT_P1("Total msg%d ", result);
3807 /***************************Go-lite Optimization changes end***********************/
3808 if (result EQ 0xAA)
3809 {
3810 TRACE_EVENT("sms cb ERROR, couldnt find the termination");
3811 return 0; // RAVI
3812 }
3813
3814
3815 //keep this value for the callback function from menu-list
3816 smscb_data.total_number = result;
3817
3818 //set the reason of reading
3819 //read "all_message" , "unread_message", ..........
3820 smscb_data.current_status = status;
3821
3822 //fill up the menu list attributes
3823 smscb_data.cb_list_attributes = sms_cb_create_list (smscb_data.total_number);
3824
3825
3826 //show the menu list on the screen now
3827 listDisplayListMenu (win, smscb_data.cb_list_attributes ,(ListCbFunc)sms_cb_list_cb,0);
3828
3829 }
3830
3831 return 1;
3832 }
3833
3834
3835 /*******************************************************************************
3836
3837 $Function: sms_cb_create_list
3838
3839 $Description: Prepare the items for the menu list
3840
3841 $Returns:
3842
3843 $Arguments:
3844
3845 *******************************************************************************/
3846 static ListMenuData * sms_cb_create_list (UBYTE number)
3847 {
3848 UBYTE i = 0, used, next_used, number_multipg =1; // RAVI - Removed - page, pages, variable. , control_bit=0;
3849
3850
3851 ListMenuData *list_menu_data = (ListMenuData *)ALLOC_MEMORY (sizeof(ListMenuData));
3852
3853 if (list_menu_data EQ 0)
3854 {
3855 TRACE_EVENT ("failed to create the list for cb");
3856 return NULL;
3857 }
3858
3859
3860 list_menu_data->List = (T_MFW_MNU_ITEM *) ALLOC_MEMORY (number * sizeof (T_MFW_MNU_ITEM));
3861
3862
3863 if (list_menu_data->List EQ 0)
3864 {
3865 TRACE_EVENT ("failed to create the list for cb");
3866 return NULL;
3867 }
3868
3869 TRACE_EVENT ("sms_cb_create_list ()");
3870
3871
3872 //take the current position in the fifo
3873 used = smscb_data.used_pointer;
3874
3875
3876 /*
3877 * Fill Menu List
3878 */
3879
3880
3881 //until to reach the end of the fifo
3882 while ( smscb_data.cb_attributes[used].next_link NEQ 0xFF )
3883 {
3884
3885 if (smscb_data.cb_attributes[used].start_page EQ 0x55)
3886 {
3887 mnuInitDataItem(&list_menu_data->List[i]);
3888
3889 next_used = used;
3890
3891 // going through the link list
3892 next_used = smscb_data.cb_attributes[next_used].next_link;
3893
3894
3895
3896 //before we put the item for a multipage, we have to
3897 //know how long it is.
3898 //This is counting the number of pages belongs to a multipage
3899 //Every multipage &singlepage starts with the indication 0x55
3900 while(smscb_data.cb_attributes[next_used].start_page NEQ 0x55)
3901 {
3902 //sprintf(buf, "number_multipg %d in while", number_multipg);
3903 //TRACE_EVENT(buf);
3904
3905 number_multipg++;
3906
3907 //go out when we reach the end of the link list
3908 if (smscb_data.cb_attributes[next_used].next_link EQ 0xFF)
3909 break;
3910
3911 // going through the link list & take the next cb message
3912 next_used = smscb_data.cb_attributes[next_used].next_link;
3913 }
3914
3915
3916
3917 //fill up the header
3918 //"MID" + "available Page" + "Total page"
3919 //the user release the uncomplete page about the available page.
3920 /*SPR1920, allocate memory for header string*/
3921 if (smscb_data.cb_attributes[used].header == NULL)
3922 smscb_data.cb_attributes[used].header = (char*)ALLOC_MEMORY(sizeof(char)*25);
3923 sprintf(smscb_data.cb_attributes[used].header,"MID%d,%d/%d", smscb_data.cb_attributes[used].mid,
3924 number_multipg, smscb_data.cb_attributes[used].pages);
3925
3926 list_menu_data->List[i].str =(char *) smscb_data.cb_attributes[used].header;
3927
3928 //set item to visible
3929 if (smscb_data.current_status EQ ALL_MESSAGE)
3930 {
3931 //show all the cb messages
3932 list_menu_data->List[i].flagFunc = item_flag_none;
3933 }
3934 else if (smscb_data.current_status EQ UNREAD_MESSAGE)
3935 {
3936 if (smscb_data.cb_attributes[used].status EQ smscb_data.current_status)
3937 list_menu_data->List[i].flagFunc = item_flag_none;
3938 else
3939 list_menu_data->List[i].flagFunc = item_flag_hide;
3940 }
3941
3942 i++;
3943 number_multipg = 1;
3944
3945
3946 }
3947
3948 // going through the link list & take the next cb message
3949 used = smscb_data.cb_attributes[used].next_link;
3950
3951 // only to be sure there is a ever ending loop
3952 if (i > MAX_STORED_PAGES)
3953 return NULL;
3954 }
3955
3956
3957 number_multipg = 1;
3958
3959 //fill up the last message of the fifo !!
3960 if (smscb_data.cb_attributes[used].start_page EQ 0x55)
3961 {
3962 mnuInitDataItem(&list_menu_data->List[i]);
3963
3964 //fill up the header
3965 //"MID" + "available Page" + "Total page"
3966 //the user release the uncomplete page about the available page.
3967 /*SPR1920, allocate memory for header string*/
3968 if (smscb_data.cb_attributes[used].header == NULL)
3969 smscb_data.cb_attributes[used].header = (char*)ALLOC_MEMORY(sizeof(char)*25);
3970 sprintf(smscb_data.cb_attributes[used].header,"MID%d,%d/%d", smscb_data.cb_attributes[used].mid,
3971 number_multipg, smscb_data.cb_attributes[used].pages);
3972
3973
3974 list_menu_data->List[i].str =(char *) smscb_data.cb_attributes[used].header;
3975
3976 //set item to visible
3977 if (smscb_data.current_status EQ ALL_MESSAGE)
3978 {
3979 //show all the cb messages
3980 list_menu_data->List[i].flagFunc = item_flag_none;
3981 }
3982 else if (smscb_data.current_status EQ UNREAD_MESSAGE)
3983 {
3984 if (smscb_data.cb_attributes[used].status EQ smscb_data.current_status)
3985 list_menu_data->List[i].flagFunc = item_flag_none;
3986 else
3987 list_menu_data->List[i].flagFunc = item_flag_hide;
3988 }
3989 }
3990
3991
3992
3993
3994
3995 /*
3996 * Fill common parameter for list handling
3997 */
3998
3999
4000 list_menu_data->ListLength = number;
4001 list_menu_data->ListPosition = 1;
4002 list_menu_data->CursorPosition = 1;
4003 list_menu_data->SnapshotSize = number;
4004 list_menu_data->Font = 0;
4005 list_menu_data->LeftSoftKey = TxtSoftSelect;
4006 list_menu_data->RightSoftKey = TxtSoftBack;
4007 /* SPR#1428 - SH - Add select key to list */
4008 list_menu_data->KeyEvents = KEY_CLEAR | KEY_RIGHT | KEY_LEFT | KEY_MNUUP | KEY_MNUDOWN | KEY_MNUSELECT;
4009 list_menu_data->Reason = 0;
4010 list_menu_data->Strings = TRUE;
4011 list_menu_data->Attr = (MfwMnuAttr*)&sms_cb_menuAttrib;
4012 list_menu_data->autoDestroy = TRUE;
4013
4014 return list_menu_data;
4015 }
4016
4017 /*******************************************************************************
4018
4019 $Function: sms_cb_list_cb
4020
4021 $Description: callback function of the menu list
4022
4023 $Returns:
4024
4025 $Arguments:
4026
4027 *******************************************************************************/
4028
4029 static void sms_cb_list_cb(T_MFW_HND win, ListMenuData * ListData)
4030 {
4031 UBYTE number, selected_postion;
4032 int i;/*SPR 1920*/
4033
4034
4035 TRACE_FUNCTION ("sms_cb_list_cb()");
4036
4037 switch (ListData->Reason)
4038 {
4039 case LISTS_REASON_SELECT: /* */
4040
4041
4042 //
4043 selected_postion = sms_cb_give_position_of_msg (smscb_data.used_pointer, ListData->ListPosition);
4044
4045
4046 //display the selected message on the scree
4047 sms_cb_show_cb_message (selected_postion);
4048
4049
4050 //destroy the list menu
4051 listsDestroy(ListData->win);
4052
4053 //counted the total number of cb msg before created the menu list
4054 number = smscb_data.total_number;
4055
4056
4057 FREE_MEMORY ((UBYTE *)smscb_data.cb_list_attributes->List, number * sizeof (T_MFW_MNU_ITEM));
4058 FREE_MEMORY ((UBYTE *)smscb_data.cb_list_attributes, sizeof (ListMenuData));
4059 /* SPR 1920 if any memory alloacted for list headers, deallocate it*/
4060 for(i=0; i<MAX_MIDS;i++)
4061 { if (smscb_data.cb_attributes[i].header != NULL)
4062 { FREE_MEMORY((void*)smscb_data.cb_attributes[i].header,sizeof(char)*25);
4063 smscb_data.cb_attributes[i].header = NULL;
4064 }
4065 }
4066 break;
4067
4068 case LISTS_REASON_BACK: /* back to previous menu */
4069
4070 TRACE_EVENT("pressed Back-key");
4071
4072 //destroy the list menu
4073 listsDestroy(ListData->win);
4074
4075 //counted the total number of cb msg before created the menu list
4076 number = smscb_data.total_number;
4077
4078 FREE_MEMORY ((UBYTE *)smscb_data.cb_list_attributes->List, number * sizeof (T_MFW_MNU_ITEM));
4079 FREE_MEMORY ((UBYTE *)smscb_data.cb_list_attributes, sizeof (ListMenuData));
4080 /* SPR 1920 if any memory alloacted for list headers, deallocate it*/
4081 for(i=0; i<MAX_MIDS;i++)
4082 { if (smscb_data.cb_attributes[i].header != NULL)
4083 { FREE_MEMORY((void*)smscb_data.cb_attributes[i].header,sizeof(char)*25);
4084 smscb_data.cb_attributes[i].header = NULL;
4085 }
4086 }
4087 break;
4088 default:
4089 return;
4090 }
4091
4092
4093
4094 }
4095
4096
4097 /*******************************************************************************
4098
4099 $Function: sms_cb_list_cb
4100
4101 $Description: open a editor to show the cb message
4102
4103 $Returns:
4104
4105 $Arguments:
4106
4107 *******************************************************************************/
4108 void sms_cb_show_cb_message(UBYTE link_list_position)
4109 {
4110
4111 T_MFW_HND win = mfwParent(mfw_header());
4112
4113 #ifdef NEW_EDITOR
4114 T_AUI_EDITOR_DATA editor_data; /* SPR#1428 - SH - New Editor data */
4115 #else
4116 T_EDITOR_DATA editor_data;
4117 #endif
4118
4119 UBYTE number_multipg =1, temp, next_used;
4120
4121 //char buf[60];
4122
4123 next_used = link_list_position;
4124
4125 //check : is it the end of the link list
4126 //if yes, not necassary to go through the link list
4127 if (smscb_data.cb_attributes[next_used].next_link NEQ 0xFF)
4128 {
4129 // going through the link list
4130 next_used = smscb_data.cb_attributes[next_used].next_link;
4131 }
4132
4133 //if the multipage contain more than one page, find out
4134 //how many pages !
4135 //This is counting the number of pages belongs to a multipage
4136 //Every multipage & singlepge starts with the indication 0x55
4137 while(smscb_data.cb_attributes[next_used].start_page NEQ 0x55)
4138 {
4139 //sprintf(buf, "number_multipg %d", number_multipg);
4140 //TRACE_EVENT(buf);
4141
4142 number_multipg++;
4143
4144 if (smscb_data.cb_attributes[next_used].next_link EQ 0xFF)
4145 break;
4146
4147 // going through the link list & take the next cb message
4148 next_used = smscb_data.cb_attributes[next_used].next_link;
4149 }
4150
4151 //sprintf(buf, "number_multipg %d after..", number_multipg);
4152 //TRACE_EVENT(buf);
4153
4154 //keep the value for later
4155 smscb_data.multipage_number = number_multipg;
4156
4157 sms_cb_loadEditDefault(&editor_data);
4158
4159 //buffer for the multipage
4160 smscb_data.multipage = (UBYTE *) ALLOC_MEMORY (OFFSET(smscb_data.multipage_number) * sizeof (UBYTE));
4161
4162 next_used = link_list_position;
4163
4164 //fill up the new buffer with the first page
4165 /*MC SPR 1920, refer to new message array*/
4166 strcat((char *)smscb_data.multipage, smscb_data.messages[next_used]);
4167 /*MC end*/
4168 //check : is it the end of the link list
4169 //if yes, not necassary to go through the link list
4170 if (smscb_data.cb_attributes[next_used].next_link NEQ 0xFF)
4171 {
4172 // going through the link list
4173 next_used = smscb_data.cb_attributes[next_used].next_link;
4174 }
4175
4176 temp = smscb_data.multipage_number;
4177
4178 //if the multipage contain more than one page, fill up the data
4179 //to the new buffer
4180 while(temp > 1)
4181 {
4182
4183 /*MC SPR 1920, refer to new message array*/
4184 strcat((char *)smscb_data.multipage, smscb_data.messages[next_used]);
4185 /*MC end*/
4186
4187 // going through the link list & take the next cb message
4188 next_used = smscb_data.cb_attributes[next_used].next_link;
4189
4190 temp --;
4191 }
4192
4193 //set the mark
4194 smscb_data.cb_attributes[link_list_position].status = READ_MESSAGE;
4195
4196 /* SPR#1428 - SH - New Editor changes */
4197 #ifdef NEW_EDITOR
4198 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, smscb_data.multipage, OFFSET(smscb_data.multipage_number));
4199 AUI_edit_SetEvents(&editor_data, link_list_position, TRUE, FOREVER, (T_AUI_EDIT_CB)sms_cb_editor_cb);
4200 AUI_edit_SetTextStr(&editor_data, TxtDelete, TxtSoftBack, 0, NULL);
4201 AUI_edit_SetAltTextStr(&editor_data, 0, TxtSoftOptions, FALSE, TxtNull);
4202 AUI_edit_SetMode(&editor_data, ED_MODE_READONLY, ED_CURSOR_NONE);
4203 AUI_edit_Start(win, &editor_data);
4204 #else /* NEW_EDITOR */
4205 editor_data.editor_attr.text =(char *) smscb_data.multipage;
4206
4207 editor_data.Identifier = link_list_position ; //keep the value (selected cb message)
4208 editor_data.editor_attr.size = OFFSET(smscb_data.multipage_number);
4209 editor_data.min_enter = 0;
4210 editor_data.LeftSoftKey = TxtDelete;
4211 editor_data.AlternateLeftSoftKey = TxtSoftOptions;
4212 editor_data.RightSoftKey = TxtSoftBack;
4213 editor_data.Callback = (T_EDIT_CB)sms_cb_editor_cb;
4214 editor_data.mode = READ_ONLY_MODE;
4215
4216 editor_start(win, &editor_data); /* start the editor */
4217 #endif /* NEW_EDITOR */
4218 }
4219
4220 /*******************************************************************************
4221
4222 $Function: sms_cb_loadEditDefault
4223
4224 $Description: Configure T_EDITOR_DATA structure with default editor settings.
4225
4226 $Returns: none
4227
4228 $Arguments: editor_data - editor data.
4229
4230 *******************************************************************************/
4231 /* SPR#1428 - SH - New Editor changes */
4232 #ifdef NEW_EDITOR
4233 void sms_cb_loadEditDefault (T_AUI_EDITOR_DATA *editor_data)
4234 {
4235 TRACE_FUNCTION ("sms_cb_loadEditDefault()");
4236
4237 AUI_edit_SetDefault(editor_data);
4238 AUI_edit_SetMode(editor_data, ED_MODE_ALPHA, ED_CURSOR_NONE);
4239 AUI_edit_SetTextStr(editor_data, TxtSoftSelect, TxtSoftBack, 0, NULL);
4240 AUI_edit_SetDisplay(editor_data, 0, COLOUR_EDITOR, EDITOR_FONT);
4241
4242 return;
4243 }
4244 #else /* NEW_EDITOR */
4245
4246 void sms_cb_loadEditDefault (T_EDITOR_DATA *editor_data)
4247 {
4248 TRACE_FUNCTION ("sms_cb_loadEditDefault()");
4249
4250 editor_attr_init(&editor_data->editor_attr, NULL, edtCurNone, 0, 0, 0, COLOUR_EDITOR);
4251 editor_data_init(editor_data, NULL, TxtSoftSelect, TxtSoftBack, 0, 1, ALPHA_MODE, FOREVER);
4252 editor_data->hide = FALSE;
4253 editor_data->AlternateLeftSoftKey = TxtNull;
4254 editor_data->Identifier = 0;
4255 editor_data->TextString = NULL;
4256 editor_data->destroyEditor = TRUE ;
4257 }
4258 #endif /* NEW_EDITOR */
4259
4260
4261 /*******************************************************************************
4262
4263 $Function: sms_cb_editor_cb
4264
4265 $Description: callback function of the editor
4266
4267 $Returns: none
4268
4269 $Arguments:
4270
4271 *******************************************************************************/
4272 static void sms_cb_editor_cb (T_MFW_HND win, USHORT Identifier, SHORT reason)
4273 {
4274
4275 //only for tracing
4276 #ifdef DEBUG_SMS_CB
4277 UBYTE w;
4278
4279 /* x0045876, 14-Aug-2006 (WR - "test" & "i" was declared but never referenced) */
4280 UBYTE test, i;
4281
4282 #endif
4283
4284 TRACE_FUNCTION ("sms_cb_editor_cb()");
4285
4286 FREE_MEMORY ((UBYTE *)smscb_data.multipage, OFFSET(smscb_data.multipage_number) * sizeof (UBYTE));
4287
4288 switch (reason)
4289 {
4290 case INFO_KCD_LEFT:
4291
4292
4293 //user selected to delete the message
4294 sms_cb_delete_message (smscb_data.cb_attributes[Identifier].mid);
4295
4296 //update the use_pointer after deleting
4297 smscb_data.used_pointer = smscb_data.result_used;
4298
4299 if (smscb_data.used_pointer EQ smscb_data.free_pointer)
4300 {
4301 //no anymore messages stored
4302 smscb_data.used_pointer = 0xFF;
4303 }
4304
4305
4306 if (smscb_data.current_status EQ ALL_MESSAGE)
4307 {
4308 //go back to the cb list
4309 sms_cb_read_msg (smscb_data.current_status);
4310 }
4311 else if (smscb_data.current_status EQ UNREAD_MESSAGE)
4312 {
4313 // if (sms_cb_count_unread_messages ())
4314 // sms_cb_read_msg (smscb_data.current_status);
4315
4316 }
4317
4318
4319
4320 break;
4321
4322 case INFO_KCD_RIGHT:
4323 case INFO_KCD_HUP:
4324
4325
4326 //only for tracing
4327 #ifdef DEBUG_SMS_CB
4328 /***************************Go-lite Optimization changes Start***********************/
4329 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
4330 TRACE_EVENT_P1( ".. used_pointer %d ", smscb_data.used_pointer);
4331 TRACE_EVENT_P1("..free_pointer %d ", smscb_data.free_pointer);
4332 for (i=0; i<MAX_STORED_PAGES ; i++)
4333 {
4334 TRACE_EVENT_P2("link_index: %d, i:%d", smscb_data.cb_attributes[i].next_link,i);
4335 }
4336 test = smscb_data.used_pointer;
4337 while (smscb_data.cb_attributes[test].next_link NEQ 0xFF)
4338 {
4339 //sprintf(buf, "Buffer on %s", &smscb_data.cb_buffer[OFFSET(test)]);
4340 /*MC*/
4341 TRACE_EVENT_P1("Buffer on %s", smscb_data.messages[test]);
4342 test = smscb_data.cb_attributes[test].next_link;
4343 }
4344 //sprintf(buf, "Buffer on %s,i:%d ", &smscb_data.cb_buffer[OFFSET(test)], i);
4345 /*MC*/
4346 TRACE_EVENT_P2("Buffer on %s,i:%d ", smscb_data.messages[test], i);
4347 /***************************Go-lite Optimization changes end***********************/
4348 #endif //DEBUG_SMS_CB
4349
4350
4351
4352 if (smscb_data.current_status EQ ALL_MESSAGE)
4353 {
4354 //go back to the cb list
4355 /* Nov 14, 2006 REF: OMAPS00099394 x0039928
4356 Fix: List recreation is commented.
4357 sms_cb_read_msg (smscb_data.current_status);
4358 */
4359 }
4360 else if (smscb_data.current_status EQ UNREAD_MESSAGE)
4361 {
4362
4363 }
4364 break;
4365
4366 default:
4367 TRACE_EVENT("Err: Default");
4368 break;
4369 }
4370 }
4371
4372
4373