comparison src/aci2/bmi/mmiSmsBroadcast.c @ 3:93999a60b835

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