comparison src/aci2/bmi/mmiSmsRead.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 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: Basic MMI
13 $Project code: BMI
14 $Module: SMS
15 $File: MmiSmsRead.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:
24
25 Shared definitions of data elements are made in here
26 and accessed via the primitive operations supplied
27
28 ********************************************************************************
29
30 $History: MmiSmsRead.c
31
32 Feb 07, 2006 DR: OMAPS00059261 x0pleela
33 Description: SMS is not forwarding STATUS reports that are read from SIM storage to ACI
34 Solution: smsread_r_exec_cb(): avoiding display of sender's address in header for status reports during listing
35 smsread_getstatustext():renamed txtreport to txtreport
36 Replaced MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
37
38 Feb 01, 2006 DR: OMAPS00059261 x0pleela
39 Description: SMS is not forwarding STATUS reports that are read from SIM storage to ACI
40 Solution: Added a check for Status report to display a text "Report:Pending" during listing of this message
41 Made changes as per review comments
42
43 Jan 30, 2006 DR: OMAPS00059261 x0pleela
44 Description: SMS is not forwarding STATUS reports that are read from SIM storage to ACI
45 Solution: Added code to read and display MT Status report
46
47 Mar 28, 2006 MMI-FIX-47813 x0035544
48 Description: Not Available transient screen is displayed when Extract number option is selected
49 in messages option screen.
50 Solution: The necessary functionality is provided to extract the numbers in a message and display
51 them appropriately.
52
53 May 27, 2005 MMI-FIX-29869 x0018858
54 Description: There is a limitation on the number of messages that can be downloaded from
55 server even though there is space on the sim.
56 Solution: The limitation has been removed and the number of messages that can be dowloaded
57 has been modified to the masimum number that can be stored.
58
59 March 2, 2005 REF: CRR 11536 x0018858
60 Description: Reply path not supported while sending a reply.
61 Solution: Added menu option for the reply path.
62
63 Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
64 Issue description: BMI: using the tool nowSMS the voicemail indication via sms does not work
65 Solution: Instead of identifying voice using addr[0] and pid, we use dcs. Also, messages belonging
66 to group "1100" are deleted when voicemail icon is displayed.
67
68 Feb 16, 2005 REF: CRR 28966 x0012851
69 Description: Editing or forwarding of large MT messages (>160 characters)
70 shouldn't be allowed when Concatenation is set to 'OFF'
71 Solution: If the 'ConcatenateStatus' flag is FALSE, the 'if' check condition
72 which allows the message to be edited or forwarded has been
73 modified for the same.
74
75 Dec 15,2004 REF: CRR 24396 xkundadu
76 Description: Phone crashes when a message is received while the
77 'List Empty' dialog is displayed.
78 Solution: NULL check is added for the list_win handle before calling
79 listsDestroy() when an MT sms is receieved.
80
81 Dec 01, 2004 REF: CRR 24225 xnkulkar
82 Description: Reset when forwarding SMS
83 Solution: The message content is sent excluding the date/time info from the
84 original message, which was causing the reset as the max limit (161) was crossed.
85
86 Sep 08, 2004 REF: CRR 24393 Deepa M. D
87 Bug:Phone crashes when user tries to reply to a saved message in the Inbox
88 Fix:The reply and Callnumber Option has been removed for the saved message.
89 25/10/00 Original Condat(UK) BMI version.
90 14/10/00 SPR 1257 - merged in issue 888 from b-sample line (extract
91 number from SMS improvements) and made changes to accommodate
92 Unicode SMSs containing numbers.
93 May 03, 2004 REF: CRR 13845 Deepa M
94 The Forward menuitem added.
95 $End
96
97 *******************************************************************************/
98
99 #define MMI_SMSREAD_C
100
101 #define ENTITY_MFW
102
103 /* includes */
104 #include <string.h>
105 #include <stdio.h>
106 #include <stdlib.h>
107
108 #if defined (NEW_FRAME)
109
110 #include "typedefs.h"
111 #include "vsi.h"
112 #include "pei.h"
113 #include "custom.h"
114 #include "gsm.h"
115
116 #else
117
118 #include "STDDEFS.H"
119 #include "custom.h"
120 #include "gsm.h"
121 #include "vsi.h"
122
123 #endif
124 #include "prim.h"
125
126
127 #include "mfw_mfw.h"
128 #include "mfw_win.h"
129 #include "mfw_kbd.h"
130 /* SPR#1428 - SH - New Editor changes */
131 #ifndef NEW_EDITOR
132 #include "mfw_edt.h"
133 #endif
134 #include "mfw_tim.h"
135 #include "mfw_phb.h"
136 #include "ksd.h"
137 #include "psa.h"
138 #include "mfw_sms.h"
139 #include "mfw_smsi.h"
140 #include "mfw_icn.h"
141 #include "mfw_mnu.h"
142 #include "mfw_lng.h"
143 #include "mfw_sat.h"
144 #include "mfw_kbd.h"
145 #include "mfw_nm.h"
146 #include "mfw_mme.h"
147
148 #include "psa_util.h"
149
150 #include "dspl.h"
151
152 #include "MmiMain.h"
153 #include "MmiDummy.h"
154 #include "MmiMmi.h"
155 #include "mmiCall.h"//GW 29/11/01 for 'callNumber'
156
157 #include "MmiDialogs.h"
158 #include "MmiLists.h"
159 #include "MmiMenu.h"
160 #include "MmiSoftKeys.h"
161 /* SPR#1428 - SH - New Editor changes */
162 #ifdef NEW_EDITOR
163 #include "ATBCommon.h"
164 #include "ATBDisplay.h"
165 #include "ATBEditor.h"
166 #include "AUIEditor.h"
167 #else
168 #include "MmiEditor.h"
169 #endif
170 #include "MmiBookShared.h" // MZ
171 #include "mmiSmsMenu.h"
172 #include "mmismssend.h"
173 #include "mmiSmsRead.h"
174 #include "mmiSmsIdle.h"
175 #include "MmiResources.h"/*MC*/
176 #include "mfw_ffs.h"
177
178 #include "cus_aci.h"
179
180 #include "prim.h"
181 #ifndef PCM_2_FFS
182 #include "pcm.h"
183 #endif
184
185
186 #include "message.h"
187 #include "prim.h"
188 #include "aci_cmh.h" //GW 29/11/01 added for types in aci_fd.h
189 #include "aci_fd.h" //GW 29/11/01 added for types in 'cmh.h'
190 #include "cmh.h" //GW 29/11/01 added for types in 'cmh_phb.h'
191 #include "cmh_phb.h" //GW 29/11/01 added for cmhPHB_getAdrStr
192
193 #include "mmiColours.h"
194 #include "audio.h"
195 //GW 29/11/01 - added header file - removed extern void callNumber(UBYTE* number);
196 MfwWin* getWinData( MfwHnd win);
197
198 /*SPR 1453*/
199 #ifdef LSCREEN
200 #define UCS2_MENU_TEXT_LEN ((MFW_TAG_LEN +10)*2 +4)/*SPR 2686 only need name+status text*/
201 #else
202 #define UCS2_MENU_TEXT_LEN 36 /*mc SPR 1242, no of bytes in latin unicode string which fills one whole line*/
203 #endif
204
205 #define MAX_EDITOR_HEADER_LENGTH 25
206
207 // Dec 01, 2004 REF: CRR 24225 xnkulkar
208 // Description: Reset when forwarding SMS
209 // Added to exclude the original date/time info from forwarded message
210 #define ORIGINAL_DATE_TIME_INFO 17
211 //Mar 28, 2006 DR:OMAPS00047813 x0035544
212 #define MAX_NUMBER_SIZE 10 //Max Size of the number array to hold the extracted numbers
213 #define MIN_NUM_LENGTH 3 //minimum length of the number to be extracted.
214
215 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
216 extern BOOL invalidVm;
217
218 extern UBYTE reply_path_bit;
219 /*********************************************************************
220
221 DYNAMIC MENU WINDOW. DECLARATION
222
223 **********************************************************************/
224
225 typedef enum
226 {
227 E_DELETE,
228 E_REPLY,
229 E_CALL_SENDER,
230 E_SAVE_NUMBER,
231 E_DATE_TIME,
232 E_FORWARD
233 };
234
235 // Those information are passed to the sms editor
236 typedef struct
237 {
238 SHORT sms_index;
239 T_MMI_SMS_STAT sms_type;
240 T_MFW_SMS_PARA *sms_info;
241 char *assoc_name;
242 }T_SMS_EDITOR_DATA;
243
244
245 /* This variable is used to know in which state we are when MFW callback function is called */
246 typedef struct
247 {
248 SHORT nb_sms_stored;
249 /*SPR 2530, need more info than just indexes*/
250
251 // May 27, 2005 MMI-FIX-29869 x0018858
252 // Description: There is a limitation on the number of messages that can be downloaded from
253 // server even though there is space on the sim.
254 // Solution: The limitation has been removed and the number of messages that can be dowloaded
255 // has been modified to the maximum number that can be stored.
256 #ifdef FF_MMI_SMS_DYNAMIC
257 T_MFW_SMS_MSG* sms_messages; /* store info about the SMS: index... */
258
259 // May 27, 2005 MMI-FIX-29869 x0018858
260 // Changed from static to dynamic
261 wstring_t** sms_header; /* header displayed in the dynamic menu */
262 #else
263 T_MFW_SMS_MSG sms_messages[MAX_MESSAGES]; /* store info about the SMS: index... */
264 wstring_t* sms_header[MAX_MESSAGES]; /* header displayed in the dynamic menu */
265 #endif
266 }T_SMS_LIST_DATA;
267
268 typedef struct
269 {
270 /* administrative data */
271
272 T_MMI_CONTROL mmi_control;
273 T_MFW_HND win;
274 SHORT id;
275 T_MFW_HND parent;
276
277 /* associated handlers */
278
279 T_MFW_HND sms_handle; /* MFW sms handler */
280
281 /* internal data */
282 T_SMS_LIST_DATA sms_list_data;
283 T_SMS_EDITOR_DATA sms_editor_data;
284 ListMenuData *menu_list_data;
285 /*SPR 2686, removed unused data field*/
286
287 } T_SMSREAD_R;
288 T_SMSREAD_R* getUserData_T_SMSREAD_R( T_MFW_WIN *win)
289 {
290 if (win == NULL)
291 return (NULL);
292 return((T_SMSREAD_R *)win->user);
293 }
294
295
296 typedef struct
297 {
298 /* administrative data */
299
300 T_MMI_CONTROL mmi_control;
301 T_MFW_HND win;
302 SHORT id;
303 T_MFW_HND parent;
304 T_MFW_HND editor_win;
305
306 /* associated handlers */
307
308
309 /* internal data */
310 T_SMS_EDITOR_DATA *sms_editor_data;
311 /*SPR 2686, removed unused data field*/
312 } T_SMSREAD_R_TEXTEDT2;
313
314 T_SMSREAD_R_TEXTEDT2* getUserData_T_SMSREAD_R_TEXTEDT2( T_MFW_WIN *win)
315 {
316 if (win == NULL)
317 return (NULL);
318 return((T_SMSREAD_R_TEXTEDT2 *)win->user);
319 }
320
321
322
323 typedef struct
324 {
325 /* administrative data */
326
327 T_MMI_CONTROL mmi_control;
328 T_MFW_HND win;
329 SHORT id;
330 T_MFW_HND parent;
331
332 /* associated handlers */
333
334 /* !!! **************************************** modify here **************************************** !!!*/
335 T_MFW_HND kbd;
336 T_MFW_HND kbd_long;
337 T_MFW_HND menu;
338 /* !!! **************************************** end modify here **************************************** !!! */
339
340 /* internal data */
341
342 /* !!! **************************************** modify here **************************************** !!!*/
343 /*SPR 2686, removed unused data field*/
344 T_MFW_HND sms;
345 T_MFW_HND dialog_win;
346
347 /* !!! **************************************** end modify here **************************************** !!! */
348 T_SMS_EDITOR_DATA *sms_editor_data; //NM 25.8
349 } T_SMSREAD_R_OPT;
350 T_SMSREAD_R_OPT* getUserData_T_SMSREAD_R_OPT( T_MFW_WIN *win)
351 {
352 if (win == NULL)
353 return (NULL);
354 return((T_SMSREAD_R_OPT *)win->user);
355 }
356
357
358
359
360
361 static enum
362 {
363 READ_SMS_LIST,
364 READ_SELECTED_SMS
365 } g_sms_state;
366
367 //MZ 7/02/01 tmp enums.
368 static enum
369 {
370 MFW_MB_LINE1,
371 MFW_MB_DATA
372 }mfw_mailBox_type;
373
374 /*MC SPR2175, removed alphabet conversion tables which are now in ATBCommon.c*/
375
376 static const MfwMnuAttr readSMS_menuAttrib =
377 {
378 &readSMS_menuArea,
379 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
380 -1, /* use default font */
381 NULL, /* with these items */
382 0, /* number of items */
383 COLOUR_LIST_SMS,
384 TxtMessages,
385 NULL,
386 MNUATTRSPARE
387
388 };
389
390 //Mar 28, 2006 DR:OMAPS00047813 x0035544
391 /*default static menu*/
392 static const MfwMnuAttr menuSearchNumListAttr =
393 {
394 &menuArea,
395 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
396 -1, /* use default font */
397 NULL, /* with these items (filled in later) */
398 0, /* number of items (filled in leter)
399
400 */
401 COLOUR_LIST_XX, /* Colour */
402 TxtExtractNumber, /* Hdr Id */
403 NULL, /* Background */
404 MNUATTRSPARE /* unused */
405 };
406
407
408
409 static SHORT g_sms_list_counter;
410
411 static SHORT g_nb_line_sms;
412 static int search_index; /* SPR888 - SH - keeps track of position within SMS for extract number */
413
414 static T_MFW_HND info_win=0;
415 static T_MFW_HND deleting_win = 0;
416 static T_MFW_HND list_win=0;
417 static T_MFW_HND sms_read_win = 0;/*MC 1991 main SMS read window*/
418 static T_MFW_HND message_win = 0; /*MC 2132, individual message display win*/
419 static T_MFW_HND option_mnu_win = 0;/*MC 2132, options menu window*/
420
421 static char sms_text_ascii[MAX_EDITOR_LEN];
422
423 /* we need this variable "read_status" to know which sms message we are going
424 to edit (user pressed in the sms menu-> EDIT)
425 because SMS_MT & SMS_MO have different size of character
426 (current length saved in "current_sms_len") !!
427 SMS_MT includes additional TIME, DATE and NUMBER and we dont want
428 to show it when we are editing.
429 */
430 static UBYTE read_status;
431 static USHORT current_sms_len= 0;
432
433 // Dec 15,2004 REF: CRR 24396 xkundadu
434 // Description: Phone crashes when a message is received while the
435 // 'List Empty' dialog is displayed.
436 // Solution: NULL check is added for the list_win handle before calling
437 // listsDestroy() function when an MT sms is receieved.
438
439 // This checks whether the 'List Empty' dialog is present or not.
440 static BOOL SmsListEmptyDlgPresent = 0;
441
442 static T_SmsUserData SmsData;
443 int SmsRead_GetStatusText( char* op_text_str, int status); // RAVI
444 static T_MFW_HND smsRead_NumberName_info_screen(T_MFW_HND parent_window, T_SmsUserData *UserData,char* name);
445 UBYTE check_assoc_name(char *name, T_MFW_SMS_ADDR sms_addr);
446
447
448 static T_MFW_HND SmsRead_R_OPT_create (T_MFW_HND parent);
449 static void SmsRead_R_OPT_destroy (T_MFW_HND window);
450 static void SmsRead_R_OPT_StandardDialog(T_MFW_HND win, char *text, ULONG duration);
451 static void SmsRead_R_OPT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
452 static int SmsRead_R_OPT_win_cb (MfwEvt e, MfwWin *w);
453 static int SmsRead_R_OPT_mfw_cb (MfwEvt event, void *parameter);
454 static int SmsRead_R_OPT_dialog_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
455 static int SmsRead_R_OPT_kbd_cb (MfwEvt e, MfwKbd *k);
456 static int SmsRead_R_OPT_mnu_cb (MfwEvt e, MfwMnu *m);
457 static int SmsRead_R_OPTExeDelete(MfwMnu* m, MfwMnuItem* i);
458 static int SmsRead_R_OPTExeReply(MfwMnu* m, MfwMnuItem* i);
459 static int SmsRead_R_OPTExeStoreNumber(MfwMnu* m, MfwMnuItem* i);
460 void SmsRead_StoreNumber(void);
461 static int SmsRead_R_OPTExeEdit(MfwMnu* m, MfwMnuItem* i);
462
463 /*SPR 2530,, old code which displays the contents of the SMS messages in the SMS list
464 has been compiled out using the macro ORIGINAL_SMS_LIST.
465 If ORGINAL_SMS_LIST is defined, then the old list is shown, otherwise the new kind of SMS
466 list is shown*/
467
468
469 /*SPR 2530,compiled out unused global vars*/
470 #ifdef ORIGINAL_SMS_LIST
471 static SHORT g_sms_list_counter;
472
473 static SHORT g_nb_line_sms;
474 #endif
475 T_MFW_HND retry_handle;/*handle for the timer to retry reading an SMS. */
476 int retry_index=0;/*index of message we're trying to read again.*/
477 void retry_sms_read(int index);
478 int retry_sms_read_tim_cb(MfwEvt event, MfwTim *timer_info);
479
480 /* R is the identifier used for the function of the Read menu window */
481 static T_MFW_HND SmsRead_R_create (T_MFW_HND parent);
482 static void SmsRead_R_destroy (T_MFW_HND window);
483 static void SmsRead_R_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
484 static int SmsRead_R_win_cb (MfwEvt e, MfwWin *w);
485 static int SmsRead_R_mfw_cb(MfwEvt event, void *parameter);
486 static int SmsRead_R_dialog_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
487 static void SmsRead_R_smslist_cb(T_MFW_HND * Parent, ListMenuData * ListData);
488 static void SmsRead_R_BuildList(T_MFW_HND win,int inUnicode);
489
490 // Fill an unicode structure for display
491 void string_CopyW2W(wstring_t *strDestination, charw_t *strSource, USHORT count );
492
493
494 static T_MFW_HND SmsRead_R_TEXTEDT2_create (T_MFW_HND parent);
495 static void SmsRead_R_TEXTEDT2_destroy (T_MFW_HND window);
496 static void SmsRead_R_TEXTEDT2_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
497 static int SmsRead_R_TEXTEDT2_win_cb (MfwEvt e, MfwWin *w);
498 static void SmsRead_R_TEXTEDT2_editor_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
499 static void SmsRead_R_TEXTEDT2_smslist_cb(T_MFW_HND * Parent, ListMenuData * ListData);
500
501
502
503 static BOOL Search_forNextNumber(T_SmsUserData *UserData);
504 //Mar 27, 2006 DR:OMAPS00047813 x0035544
505 static void SmsRead_numlist_destroy(MfwHnd own_window);
506 static void SmsRead_numlist_cb(T_MFW_HND Parent, ListMenuData * ListData);
507 void smsread_numlist_exec_cb (T_MFW_HND win, USHORT event);
508 static T_MFW_HND SmsRead_BuildNumList_Menu(T_MFW_HND win);
509 static int smsread_numlist_win_cb (MfwEvt e, MfwWin *w);
510 void Search_forNumberInSMS(T_SmsUserData *UserData);
511
512
513 //Mar 24, 2006 REF: SPR 47813 x0035544
514 static int smsread_num_ctr;
515 static char **num_buffer=NULL;
516
517 static const MfwMnuItem SmsRead_R_OPTItems [] =
518 {
519 {0,0,0,(char *)TxtDelete,0,(MenuFunc)SmsRead_R_OPTExeDelete,item_flag_none},
520 {0,0,0,(char *)TxtReply,0,(MenuFunc)SmsRead_R_OPTExeReply,item_flag_none},
521 {0,0,0,(char *)TxtEdit,0,(MenuFunc)SmsRead_R_OPTExeEdit,item_flag_none},
522 {0,0,0,(char *)TxtForward,0,(MenuFunc)SmsRead_R_OPTExeEdit,item_flag_none},//May 03, 2004 REF: CRR 13845 Deepa M -Menu item to forward SMS
523 {0,0,0,(char *)TxtExtractNumber,0,(MenuFunc)SmsRead_R_OPTExeStoreNumber,item_flag_none},
524 {0,0,0,(char *)TxtCallNumber,0,(MenuFunc)SmsRead_StoreNumber,item_flag_none}
525 };
526
527 static const MfwMnuAttr SmsRead_R_OPTAttrib =
528 {
529 &SmsRead_R_OPTArea,
530 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
531 -1, /* use default font */
532 (MfwMnuItem*) SmsRead_R_OPTItems, /* with these items */
533 sizeof(SmsRead_R_OPTItems)/sizeof(MfwMnuItem) /* number of items */
534 };
535
536 //Sep 08, 2004 REF: CRR 24393 Deepa M. D
537 //New menu item for the saved/unsent messages.
538 static const MfwMnuItem SmsRead_R_Unsent_OPTItems [] =
539 {
540 {0,0,0,(char *)TxtDelete,0,(MenuFunc)SmsRead_R_OPTExeDelete,item_flag_none},
541 {0,0,0,(char *)TxtEdit,0,(MenuFunc)SmsRead_R_OPTExeEdit,item_flag_none},
542 {0,0,0,(char *)TxtForward,0,(MenuFunc)SmsRead_R_OPTExeEdit,item_flag_none},
543 {0,0,0,(char *)TxtExtractNumber,0,(MenuFunc)SmsRead_R_OPTExeStoreNumber,item_flag_none},
544
545 };
546
547 //Sep 08, 2004 REF: CRR 24393 Deepa M. D
548 //Menu attributes for the saved/unsent messages.
549 static const MfwMnuAttr SmsRead_R_Unsent_OPTAttrib =
550 {
551 &SmsRead_R_OPTArea,
552 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
553 -1, /* use default font */
554 (MfwMnuItem*) SmsRead_R_Unsent_OPTItems, /* with these items */
555 sizeof(SmsRead_R_Unsent_OPTItems)/sizeof(MfwMnuItem) /* number of items */
556 };
557
558
559
560 /*******************************************************************************
561
562 $Function: charPtrToUBYTEPtr
563
564 $Description: Converts a char ptr to a UBYTE ptr. The procedures can be replaced by macro
565 once all conversions are confirmed as valid.
566
567 $Returns: data set to new type
568
569 $Arguments: data -data item of input type.
570
571 *******************************************************************************/
572 #ifndef MMI_USE_MACROS
573 UBYTE charToUBYTE ( char chr ) { return((UBYTE)chr); }
574 UBYTE* charPtrToUBYTEPtr ( char *ptr ) { return((UBYTE*)ptr); }
575 UBYTE SHORTToUBYTE ( SHORT data ) { return((UBYTE)data); }
576
577 char UBYTEToChar ( UBYTE data) { return((char)data); }
578 char* UBYTEPtrToCharPtr ( UBYTE* data) { return((char*)data); }
579 char* USHORTPtrToCharPtr ( USHORT* data) { return((char*)data); }
580
581 USHORT charToUSHORT ( char chr ) { return((USHORT)chr); }
582 USHORT UBYTEToUSHORT ( UBYTE data) { return((USHORT)data); }
583 USHORT* charPtrToUSHORTPtr (char* data) { return((USHORT*)data); }
584
585 #else
586 #define charToUBYTE (UBYTE)
587 #define charPtrToUBYTEPtr (UBYTE*)
588 #define SHORTToUBYTE (UBYTE)
589
590 #define UBYTEPtrToCharPtr (char*)
591 #define UBYTEToChar (char)
592 #define USHORTPtrToCharPtr (char*)
593
594 #define charToUSHORT (USHORT)
595 #define UBYTEToUSHORT (USHORT)
596 #define charPtrToUSHORTPtr (USHORT*)
597 #endif
598 /*MC SPR2175, removed GSM<->ASCII<->UCS2 conversion functions, moved to ATBCommon*/
599
600 /**/
601
602 /*******************************************************************************
603
604 $Function: SmsRead_R_start
605
606 $Description: Start the creation of the main window for SMS reading
607
608 $Returns: mfw window handler
609
610 $Arguments: parent_window - Parent window handler
611 menuAttr - Menu attributes.
612
613 *******************************************************************************/
614 T_MFW_HND SmsRead_R_start(T_MFW_HND parent_window, MfwMnuAttr *menuAttr)
615 {
616 TRACE_EVENT_P1("sms_read_win:%d", sms_read_win);
617 /*SPR2132, if the list window already exists, destroy it before creating a new one*/
618 if (sms_read_win != NULL)
619 SmsRead_R_destroy(sms_read_win);
620
621 TRACE_FUNCTION ("SmsRead_R_start()");
622 /*SPR 1991 use ssms_read_win rather than a local var*/
623 sms_read_win = SmsRead_R_create (parent_window);
624
625 if (sms_read_win NEQ NULL)
626 {
627 /* We transmit to the SMS editor the address of the data buffer */
628 SEND_EVENT (sms_read_win, E_INIT, SmsRead_R_ID, (void *)menuAttr);
629 }
630 return sms_read_win;
631 }
632
633 /*******************************************************************************
634
635 $Function: SmsRead_R_create
636
637 $Description: create the SMS read window (dynamic list of all the SMS)
638
639 $Returns: mfw window handler
640
641 $Arguments: parent_window - Parent window handler
642
643 *******************************************************************************/
644 static T_MFW_HND SmsRead_R_create(MfwHnd parent_window)
645 {
646 T_SMSREAD_R * data = (T_SMSREAD_R *)ALLOC_MEMORY (sizeof (T_SMSREAD_R));
647 T_MFW_WIN * win;
648
649 TRACE_FUNCTION ("SmsRead_R_create()");
650
651 /*
652 * Create window handler
653 */
654
655 data->win =
656 win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)SmsRead_R_win_cb);
657 if (data->win EQ NULL)
658 {
659 return NULL;
660 }
661 /*
662 * connect the dialog data to the MFW-window
663 */
664
665 data->mmi_control.dialog = (T_DIALOG_FUNC)SmsRead_R_exec_cb;
666 data->mmi_control.data = data;
667 win = getWinData(data->win);
668 win->user = (void *)data;
669 data->parent = parent_window;
670 winShow(data->win);
671
672 /*
673 * return window handle
674 */
675
676 return data->win;
677 }
678
679 /*******************************************************************************
680
681 $Function: SmsRead_R_destroy
682
683 $Description: Destroy the SMS read window (dynamic list of all the SMS)
684
685 $Returns: none
686
687 $Arguments: own_window - window handler
688
689 *******************************************************************************/
690
691 static void SmsRead_R_destroy(MfwHnd own_window)
692 {
693 T_MFW_WIN * win_data;
694 T_SMSREAD_R * data;
695 USHORT i;
696
697
698 TRACE_FUNCTION ("SmsRead_R_destroy()");
699
700 if (own_window)
701 {
702 win_data = getWinData(own_window); //((T_MFW_HDR *))->data;
703 data = getUserData_T_SMSREAD_R(win_data);
704 if (data)
705 {
706 /*
707 * Delete WIN handler
708 */
709 sms_delete(data->sms_handle);
710
711
712 /*SPR 2132, if the message options menu or the messaeg display screen exist,
713 destroy them */
714 if (option_mnu_win)
715 {
716 SmsRead_R_OPT_destroy(option_mnu_win);
717
718 }
719 if (message_win)
720 {
721 SmsRead_R_TEXTEDT2_destroy(message_win);
722 message_win = 0;
723 }
724 /*SPR 2132 end*/
725
726 if (info_win)
727 {
728 SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
729 info_win = 0;
730 }
731 if (list_win){
732
733 SEND_EVENT(list_win/*SPR1991*/,E_LIST_DESTROY/*SPR 2132*/,0,0 );
734 list_win = 0;
735 }
736 win_delete (data->win);
737 {
738
739 }
740
741 /*
742 * Free Memory
743 */
744
745 /* Free the data allocated for the name associated to the phone number */
746 if (data->sms_editor_data.assoc_name != NULL)
747 FREE_MEMORY( (void *)data->sms_editor_data.assoc_name, strlen(data->sms_editor_data.assoc_name) + 1);
748
749 /* Free the data allocated for the dynamic list */
750 if (data->menu_list_data != NULL)
751 {
752 for (i = 0; i < ((data->sms_list_data).nb_sms_stored); i++)
753 {
754 FREE_MEMORY( (void *)data->sms_list_data.sms_header[i], UCS2_MENU_TEXT_LEN+ 1/*SPR1242*/);
755 }
756 /*SPR 2686, only de-allocate memory for the number of messages displayed*/
757 FREE_MEMORY ((void *)data->menu_list_data->List,((data->sms_list_data).nb_sms_stored) * sizeof(T_MFW_MNU_ITEM));
758 FREE_MEMORY ((UBYTE *)data->menu_list_data, sizeof(ListMenuData));
759 }
760 #ifdef FF_MMI_SMS_DYNAMIC
761 FREE_MEMORY((void*)data->sms_list_data.sms_messages,g_max_messages * sizeof(T_MFW_SMS_MSG) );
762 FREE_MEMORY((void*)data->sms_list_data.sms_header, g_max_messages * sizeof(wstring_t));
763 #endif
764 FREE_MEMORY ((void *)data, sizeof (T_SMSREAD_R));
765 sms_read_win = 0;
766 }
767 else
768 {
769 TRACE_EVENT ("SmsRead_R_destroy() called twice");
770 }
771 }
772 }
773
774 /*******************************************************************************
775
776 $Function: SmsRead_R_exec_cb
777
778 $Description: Exec callback function of the SMS read window (dynamic list of
779 all the SMS)
780
781 $Returns: none
782
783 $Arguments: win - window handler
784 event - mfw event
785 parameter - optional data.
786
787 *******************************************************************************/
788 void SmsRead_R_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
789 /* callback handler for events sent to to trigger execution */
790 {
791 T_MFW_WIN * win_data;
792 T_SMSREAD_R * data;
793 T_SMS_LIST_DATA * list_data;
794 T_MFW_EVENT MfwEvents;
795
796 T_MFW_SMS_STAT sms_list_type = *(T_MFW_SMS_STAT *)parameter;
797
798 T_MFW_HND l_parent;
799 T_DISPLAY_DATA DisplayInfo;
800 // Status of SMS reading
801 T_MFW status;
802 int i;
803
804 win_data = getWinData(win); //((T_MFW_HDR *))->data;
805 data = getUserData_T_SMSREAD_R(win_data);
806 list_data = &data->sms_list_data;
807
808 TRACE_FUNCTION ("SmsRead_R_exec_cb()");
809
810 switch (event)
811 {
812 case E_INIT:
813 // May 27, 2005 MMI-FIX-29869 x0018858
814 #ifdef FF_MMI_SMS_DYNAMIC
815 // Memory allocation done here
816 if(list_data->sms_messages == NULL)
817 list_data->sms_messages = (T_MFW_SMS_MSG*)ALLOC_MEMORY (g_max_messages * sizeof(T_MFW_SMS_MSG) );
818 #endif
819 /* initialization of administrative data */
820 info_win=0;
821 data->id = value;
822 data->menu_list_data = NULL;
823
824
825 //NM 24.8
826 /* Verify that SMS handling has been correctly initialised */
827 if (!smsidle_get_ready_state())
828 {
829 SmsMenu_loadDialogDefault(&DisplayInfo);
830
831 DisplayInfo.TextId = TxtPleaseWait;
832 //DisplayInfo.TextId2 = TxtReady;
833 // Generic function for info messages
834 DisplayInfo.Callback = (T_VOID_FUNC)SmsRead_R_dialog_cb;
835
836 info_dialog(win, &DisplayInfo);
837
838 break;
839 }
840 /* We have to handle E_SMS_MO and E_SMS_MT MFW events, in order to retrieve the SMS */
841 MfwEvents = E_SMS_MT | E_SMS_MO | E_SMS_MT_RECEIVED | E_SMS_MO_AVAIL|
842 E_SMS_ERR | E_SMS_OK | E_SMS_MEM_FREE | E_SMS_MEM_FULL;
843
844 data->sms_handle = sms_create(win,MfwEvents,(MfwCb)SmsRead_R_mfw_cb);
845
846
847 /* Get info on the stored messages
848 According to sms_list_type filter some specific type (new, read...) */
849 /*MC SPR 2530, change sms_index_list to sms_message_list, we need additional info*/
850 #ifdef FF_MMI_SMS_DYNAMIC
851 list_data->nb_sms_stored = sms_message_list(sms_list_type, list_data->sms_messages, g_max_messages);
852 #else
853 list_data->nb_sms_stored = sms_message_list(sms_list_type, list_data->sms_messages, MAX_MESSAGES);
854 #endif
855 /* we want to get the whole SMS list */
856 if (list_data->nb_sms_stored > 0)
857 {
858 #ifdef ORIGINAL_SMS_LIST
859 if (!info_win)
860 info_win = mmi_dialog_information_screen_forever(win,TxtPleaseWait, NULL, COLOUR_STATUS_WAIT);
861
862 // We want to read all the SMS
863 g_sms_state = READ_SMS_LIST;
864 /* global counter to decrement each time a message is read */
865 g_sms_list_counter = list_data->nb_sms_stored - 1;
866
867 /* Initialise counter for number of entries in sms list. used to call the correct
868 no of FreeAllocs MZ 8/03/01 */
869 g_nb_line_sms =0;
870
871 status = sms_read(MFW_SMS_MESSAGE, (unsigned char)(list_data->sms_messages[g_sms_list_counter]).index);
872 #else
873 /*SPR 2530, instead of starting to raed the SMS list in a chain , just copy SMS status info
874 and sender names to list*/
875 int i, txt_len;
876 /*we're assuming the default language is a latin one*/
877 T_MFW_PHB_ENTRY phonebook_entry;
878 BOOL unicode_flag= FALSE;
879 UBYTE output_alphabet= MFW_ASCII;
880 char* name_pointer = NULL;
881
882 // May 27, 2005 MMI-FIX-29869 x0018858
883 #ifdef FF_MMI_SMS_DYNAMIC
884 // Memory allocation done here
885 list_data->sms_header = (wstring_t **) ALLOC_MEMORY (g_max_messages * sizeof(wstring_t) );
886 #endif
887
888 /*for each entry in the message list*/
889 for (i=0;i<list_data->nb_sms_stored; i++)
890 { /*allocate memory in the list*/
891
892 if(list_data->sms_header[i] == NULL)
893 list_data->sms_header[i] = (wstring_t *) ALLOC_MEMORY (UCS2_MENU_TEXT_LEN + 1);
894 /*SPR2530 clear buffer*/
895 memset(sms_text_ascii, 0, MAX_EDITOR_LEN);
896 memset(list_data->sms_header[i], 0, UCS2_MENU_TEXT_LEN + 1);
897
898 //Use common procedure to display status info.]
899 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
900 //check for Status report type and send MFW_SMS_STATRPT as status
901 if( list_data->sms_messages[i].msg_type EQ MFW_SMS_STATRPT)
902 {
903 strcpy(sms_text_ascii, MmiRsrcGetText(TxtReport));
904 txt_len = strlen( sms_text_ascii);
905 }
906 else
907 txt_len = SmsRead_GetStatusText( sms_text_ascii, list_data->sms_messages[i].stat);
908
909 /*if we're in chinese, then all string handling is in Unicode*/
910 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
911 { unicode_flag = TRUE;
912 output_alphabet= MFW_DCS_UCS2;
913 }
914 /*if incoming SMS, copy name or number to list*/
915 if (list_data->sms_messages[i].stat == MFW_SMS_UNREAD || list_data->sms_messages[i].stat == MFW_SMS_READ)
916 { /*if phonebook entry found*/
917 if (bookFindNameInPhonebook( list_data->sms_messages[i].addr.number, &phonebook_entry ))
918 {
919 /*if name isn't blank*/
920 if (phonebook_entry.name.len >0)
921 { /*if unicode tag we have to make some adjustments*/
922 if (phonebook_entry.name.data[0] == 0x80)
923 { name_pointer = (char*)&phonebook_entry.name.data[2];
924 phonebook_entry.name.dcs = MFW_DCS_UCS2;
925 phonebook_entry.name.len-=2;
926 /*SPR2530 moved conversion here*/
927 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
928 //Donot display sender's address for status report
929 if( list_data->sms_messages[i].msg_type NEQ MFW_SMS_STATRPT)
930 ATB_convert_String(name_pointer, phonebook_entry.name.dcs&0x0c, phonebook_entry.name.len,
931 &sms_text_ascii[txt_len],output_alphabet , UCS2_MENU_TEXT_LEN-txt_len, TRUE);
932 }
933 else
934 { name_pointer = (char*)phonebook_entry.name.data;
935 /*copy (and convert) name to buffer*/
936 /*SPR2530 explicitly convert from ASCII to current alphabet*/
937 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
938 //Donot display sender's address for status report
939 if( list_data->sms_messages[i].msg_type NEQ MFW_SMS_STATRPT)
940 ATB_convert_String(name_pointer, MFW_ASCII, phonebook_entry.name.len,
941 &sms_text_ascii[txt_len],output_alphabet , UCS2_MENU_TEXT_LEN-txt_len, TRUE);
942
943 }
944 }
945 }
946 else
947 {
948 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
949 //Donot display sender's address for status report
950 if( list_data->sms_messages[i].msg_type NEQ MFW_SMS_STATRPT)
951 /*copy (and convert) number to buffer*/
952 ATB_convert_String(list_data->sms_messages[i].addr.number, MFW_ASCII, MFW_NUM_LEN,
953 &sms_text_ascii[txt_len],output_alphabet ,UCS2_MENU_TEXT_LEN-txt_len, TRUE);
954 }
955
956 }
957 /* use truncation function to copy message header to list*/
958 resources_truncate_to_screen_width((char*)sms_text_ascii,0,(char*) list_data->sms_header[i], UCS2_MENU_TEXT_LEN, SCREEN_SIZE_X, unicode_flag);
959 }
960 //*All the messages have been retrieved --> display the list of SMS*/
961 if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
962 SmsRead_R_BuildList(win,0);
963 else
964 SmsRead_R_BuildList(win,1);
965 #endif
966 }
967 else
968 SmsRead_DisplayStandardDialog(win, TxtNoMessages, THREE_SECS);
969 break;
970
971 case E_RETURN:
972 /* Call the recreate function that will create and display a dynamic list from the list of SMS */
973 listDisplayListMenu(win, data->menu_list_data, (ListCbFunc_t)SmsRead_R_smslist_cb,0);
974 break;
975
976 case E_BACK:
977 /* Received an E_BACK event from the dynamic list --> suicide and E_RETURN to parent */
978 l_parent = data->parent;
979 SmsRead_R_destroy(win);
980 SEND_EVENT(l_parent, E_RETURN, data->id, NULL);
981
982 case E_EXIT: // Terminate exit from sms send...
983 // May 27, 2005 MMI-FIX-29869 x0018858
984 #ifdef FF_MMI_SMS_DYNAMIC
985 for (i=0;i<list_data->nb_sms_stored; i++)
986 {
987 FREE_MEMORY((U8*)list_data->sms_header[i], UCS2_MENU_TEXT_LEN + 1 );
988 }
989 FREE_MEMORY((U8*)list_data->sms_header, g_max_messages * sizeof(wstring_t) );
990 FREE_MEMORY((U8*)list_data->sms_messages, g_max_messages * sizeof(T_MFW_SMS_MSG));
991 #endif
992 listDisplayListMenu(win, data->menu_list_data, (ListCbFunc_t)SmsRead_R_smslist_cb,0);
993 // FREE_MEMORY((U8*)list_data->sms_messages, g_max_messages * sizeof(T_MFW_SMS_MSG));
994
995 break;
996 default:
997 break;
998 }
999 }
1000
1001 /*******************************************************************************
1002
1003 $Function: SmsRead_R_win_cb
1004
1005 $Description: Window callback function of the SMS read window (dynamic list of
1006 all the SMS)
1007
1008 $Returns: none
1009
1010 $Arguments: w - mfw window handler
1011 e - mfw event
1012
1013 *******************************************************************************/
1014
1015 static int SmsRead_R_win_cb (MfwEvt e, MfwWin *w) /* yyy window event handler */
1016 {
1017 TRACE_FUNCTION ("SmsRead_R_win_cb()");
1018 switch (e)
1019 {
1020 case MfwWinVisible: /* window is visible */
1021 break;
1022 case MfwWinFocussed: /* input focus / selected */
1023 case MfwWinDelete: /* window will be deleted */
1024 default:
1025 return MFW_EVENT_REJECTED;
1026 }
1027 return MFW_EVENT_CONSUMED;
1028 }
1029
1030 /*******************************************************************************
1031
1032 $Function: SmsRead_GetStatusText
1033
1034 $Description: Function to copy status string into array provided.
1035
1036 $Returns: number of characters used in the output array.
1037
1038 $Arguments: op_text_str - pointer to array to store the string
1039 status - read status of text message.
1040
1041 $History
1042 SPR#780-GW-Created to allow consistent display of status in text message list
1043 *******************************************************************************/
1044 int SmsRead_GetStatusText( char* op_text_str, int status)
1045 {
1046 int txt_len, txtId;
1047
1048 TRACE_FUNCTION("SmsRead_GetStatusText()");
1049
1050 if (status == MFW_SMS_READ)
1051 txtId = TxtOld;
1052 else if(status == MFW_SMS_UNREAD)
1053 txtId = TxtNew;
1054 else if(status == MFW_SMS_STOR_UNSENT)
1055 txtId = TxtSaved;
1056 else if(status == MFW_SMS_STOR_SENT)
1057 txtId = TxtSend;
1058 else if(status == MFW_SMS_INVALID)/*SPR 2530*/
1059 txtId = TxtInvalidMessage;
1060 else //assume if it is not marked as new/old/sent/unsent
1061 txtId = TxtNull;
1062
1063 // Check for the READ/UNREAD status of the MT message.
1064 if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
1065 {
1066 strcpy(op_text_str,MmiRsrcGetText(txtId));
1067 /* Only add colon if a non-empty string and valid message*/
1068 /*SPR2530 only out in a colon if the message is MT*/
1069 if (txtId == TxtOld || txtId == TxtNew)
1070 strcat(op_text_str,":");
1071 txt_len = strlen(op_text_str);
1072 }
1073 else //language = Chinese, copy unicode string
1074 {
1075 USHORT* unicodeStr;
1076 USHORT* txtStr;
1077 int uIndex;
1078
1079 unicodeStr = charPtrToUSHORTPtr(op_text_str);
1080
1081 txtStr = charPtrToUSHORTPtr(MmiRsrcGetText(txtId));
1082
1083 uIndex = 0;
1084 txt_len = 0;
1085 while ((*txtStr!= 0) && (uIndex*2 <MENU_TEXT_LENGTH))
1086 {
1087 unicodeStr[uIndex] = *txtStr;
1088 txtStr++;
1089 uIndex++;
1090 txt_len = txt_len+2; // 2bytes per chinese char
1091 }
1092 /*SPR2530 only out in a colon if the message is MT*/
1093 if ((uIndex*2 <MENU_TEXT_LENGTH) &&(txtId == TxtOld || txtId == TxtNew))
1094 {
1095 unicodeStr[uIndex] = ((charToUSHORT)(':'))<<8;
1096 uIndex++;
1097 txt_len = txt_len+2; // 2bytes per chinese char
1098 }
1099 }
1100 /* Return number of characters copied into the array */
1101 return (txt_len);
1102 }
1103
1104 /*******************************************************************************
1105
1106 $Function: SmsRead_R_mfw_cb
1107
1108 $Description: MFW callback function of the SMS read window (dynamic list of all the SMS).
1109 Only interesting events for reading are handled here
1110
1111 $Returns: event status
1112
1113 $Arguments: parameter - optional data
1114 event - mfw event
1115
1116 *******************************************************************************/
1117 int SmsRead_R_mfw_cb(MfwEvt event, void *parameter)
1118 {
1119 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
1120 T_MFW_WIN * win_data;
1121 T_SMSREAD_R * data;
1122 T_SMS_LIST_DATA * list_data;
1123 T_MFW_SMS_MO * MoMessage;
1124 T_MFW_SMS_MT * MtMessage;
1125
1126 T_MFW_SMS_IDX msg_info;
1127
1128 UBYTE input_type;/*SPR1242, UCS2 or GSM string*/
1129
1130 T_DISPLAY_DATA DisplayInfo;
1131 int input_length = 0; /*MC, SPR 1453*/
1132 BOOL unicode = FALSE;/*MC, SPR 1442*/
1133 USHORT sms_len;
1134 char *sms_text;
1135 // int i; // RAVI
1136 int txt_len;
1137
1138 win_data = getWinData(win);
1139 data = getUserData_T_SMSREAD_R(win_data);
1140 list_data = &(data->sms_list_data);
1141
1142 TRACE_FUNCTION("SmsRead_R_mfw_cb");
1143
1144 switch(event)
1145 {
1146 case E_SMS_OK:
1147 TRACE_EVENT("SmsRead_R_mfw_cb case:E_SMS_OK ");
1148 if(deleting_win)
1149 {
1150 T_MFW_SMS_STAT sms_list_type = MFW_SMS_ALL;
1151
1152 listsDestroy(list_win);
1153 list_win=0;
1154 SmsRead_R_destroy(data->win);
1155 SmsRead_R_start(NULL, (MfwMnuAttr*)&sms_list_type);
1156 SEND_EVENT(deleting_win,DIALOG_DESTROY,0,0 );
1157
1158 //API - Added line to show if the message was deleted!
1159 dlg_initDisplayData_TextId( &DisplayInfo, TxtNull, TxtNull, TxtDeleted, TxtNull, COLOUR_STATUS_WAIT);
1160 dlg_initDisplayData_events( &DisplayInfo, NULL, TWO_SECS, KEY_HUP );
1161 info_dialog (0, &DisplayInfo);
1162
1163 deleting_win = 0;
1164 }
1165
1166 break;
1167 case E_SMS_MO:
1168 TRACE_EVENT("SmsRead_R_mfw_cb case:E_SMS_MO ");
1169 MoMessage = (T_MFW_SMS_MO *)parameter;
1170 /*SPR 2530, don't need to craete SMS list here anymore*/
1171 #ifdef ORIGINAL_SMS_LIST
1172 // We are reading all the SMS on the SIM
1173 if (g_sms_state EQ READ_SMS_LIST)
1174 {
1175 // If no message text, display the address: TBD international format and phonebook
1176 if (MoMessage->msg_len == 0)
1177 {
1178 // If there is an associated name, it is displayed (but not stored here, we will have to retrieve it again if detailed view)
1179 sms_text = (MoMessage->dest_addr).number;
1180 sms_len = strlen(sms_text);
1181 }
1182 else
1183 {
1184 sms_text = MoMessage->sms_msg;
1185 sms_len = MoMessage->msg_len;
1186 }
1187
1188 memset((char*)sms_text_ascii,'\0',UCS2_MENU_TEXT_LEN + 1);
1189
1190 TRACE_EVENT_P1("MO Message Status = %d", msg_info.stat);
1191 sms_copy_idx(MoMessage->msg_ref, &msg_info);
1192
1193 //GW-SPR#780-Use common procedure to display status info.
1194 txt_len = SmsRead_GetStatusText( sms_text_ascii, msg_info.stat);
1195
1196 /*MC, SPR1242 don't trust the DCS, check for Unicode tag*/
1197 if (MoMessage->sms_msg[0] == 0x80 ||MoMessage->dcs == MFW_DCS_UCS2 )
1198 { input_type = MFW_DCS_UCS2;
1199 input_length = MoMessage->msg_len-1;/*MC,SPR 1453, prevent @ symbol on end of string*/
1200 }
1201 else
1202 { input_type = MFW_DCS_8bits;
1203 input_length = MoMessage->msg_len;/*MC, SPR 1453*/
1204 }
1205
1206 /*mc end*/
1207
1208 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
1209 { unicode = TRUE;/*MC, SPR 1442, we'll be displaying messages as unicode*/
1210 /*SPR2175, use new function for conversion*/
1211 ATB_convert_String( MoMessage->sms_msg, input_type /*MC SPR1242*/, MoMessage->msg_len,
1212 &sms_text_ascii[txt_len], MFW_DCS_UCS2, UCS2_MENU_TEXT_LEN-(txt_len+1), TRUE);
1213
1214 }
1215 else
1216 { unicode = FALSE;/*MC, SPR 1442, we'll be displaying messages as ASCII*/
1217 /*SPR2175, use new function for conversion*/
1218 ATB_convert_String( MoMessage->sms_msg, input_type /*MC SPR1242*/, input_length/*SPR 1453*/,
1219 &sms_text_ascii[txt_len] , MFW_ASCII, MENU_TEXT_LENGTH-(txt_len+1), TRUE);
1220
1221 }
1222
1223
1224 /* just in case */
1225 if (g_sms_list_counter >= 0)
1226 {
1227 list_data->sms_header[g_sms_list_counter] = (wstring_t *) ALLOC_MEMORY (UCS2_MENU_TEXT_LEN + 1/*MC SPR1242*/);
1228 /*MC, SPR 1442, use truncation function to copy message header to list*/
1229 resources_truncate_to_screen_width(sms_text_ascii,0,(char*) list_data->sms_header[g_sms_list_counter], UCS2_MENU_TEXT_LEN, SCREEN_SIZE_X, unicode);
1230 }
1231 TRACE_EVENT_P1("g_sms_list_counter = %d", g_sms_list_counter);
1232
1233 g_sms_list_counter--;
1234
1235 if (g_sms_list_counter >= 0)
1236 {
1237 // There are still messages to read.
1238 /*SPR2260, if reading SMS fails, retry*/
1239 if (sms_read(MFW_SMS_MESSAGE, SHORTToUBYTE(list_data->sms_messages[g_sms_list_counter].index))== MFW_SMS_FAIL)
1240 {
1241 retry_sms_read(SHORTToUBYTE(list_data->sms_messages[g_sms_list_counter].index));
1242 }
1243 else
1244 g_nb_line_sms++;
1245 }
1246 else
1247 {
1248 // All the messages have been retrieved --> display the list of SMS
1249 if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
1250 SmsRead_R_BuildList(win,0);
1251 else
1252 SmsRead_R_BuildList(win,1);
1253 }
1254 }
1255 // A particular SMS has been selected. We need to get all the info: full text, time stamp...
1256 else
1257 #endif
1258 if (g_sms_state EQ READ_SELECTED_SMS)
1259
1260 {
1261 data->sms_editor_data.sms_info = (T_MFW_SMS_PARA *)ALLOC_MEMORY (sizeof (T_MFW_SMS_PARA));
1262 data->sms_editor_data.sms_type = MMI_SMS_MO;
1263
1264 memcpy(data->sms_editor_data.sms_info, (T_MFW_SMS_PARA *)MoMessage, sizeof(T_MFW_SMS_PARA));
1265 SmsRead_R_TEXTEDT2_start(win, (MfwMnuAttr *)&(data->sms_editor_data));
1266 }
1267
1268 break;
1269 case E_SMS_MT:
1270
1271 MtMessage = (T_MFW_SMS_MT *)parameter;
1272
1273 /*SPR 2530, don't need to craete SMS list here anymore*/
1274 #ifdef ORIGINAL_SMS_LIST
1275
1276 if (g_sms_state EQ READ_SMS_LIST)
1277 {
1278 /*SPR 2176, if message is the last one requested from MFW*/
1279 if (list_data->sms_messages[g_sms_list_counter].index == MtMessage->index)
1280 {
1281
1282 // If no message text, display the address: TBD international format and phonebook
1283 if (MtMessage->msg_len == 0)
1284 {
1285 // If there is an associated name, it is displayed (but not stored here, we will have to retrieve it again if detailed view)
1286 // MZ check for assoc_name !!! 14/2/01
1287 sms_text = (MtMessage->orig_addr).number;
1288 sms_len = strlen(sms_text);
1289 }
1290 else
1291 {
1292
1293 sms_text = MtMessage->sms_msg;
1294 sms_len = MtMessage->msg_len;
1295 }
1296
1297 //MZ 24/05/01 clear the temp sms text buffer.
1298 memset((char*)sms_text_ascii,'\0',UCS2_MENU_TEXT_LEN + 1);
1299
1300 sms_copy_idx(MtMessage->index, &msg_info);
1301 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
1302 //Display "Report" for status report
1303 //GW-SPR#780-Use common procedure to display status info.
1304 TRACE_EVENT_P1("Status of message = %d", msg_info.stat);
1305 if( list_data->sms_messages[i].msg_type EQ MFW_SMS_STATRPT)
1306 {
1307 strcpy(sms_text_ascii, MmiRsrcGetText(TxtReport));
1308 txt_len = strlen( sms_text_ascii);
1309 }
1310 else
1311 txt_len = SmsRead_GetStatusText( sms_text_ascii, msg_info.stat);
1312
1313 /*MCSPR1242 don't trust the DCS, check for Unicode tag*/
1314 if (MtMessage->sms_msg[0] == 0x80||MtMessage->dcs == MFW_DCS_UCS2 )
1315 { input_type = MFW_DCS_UCS2;/*MC*/
1316 input_length = MtMessage->msg_len-1;/*1498, use MT length*/
1317 }
1318 else
1319 { input_type = MFW_DCS_8bits;/*MC*/
1320 input_length = MtMessage->msg_len;/*1498, use MT length*/
1321 }
1322
1323 /*mc end*/
1324 if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
1325 { unicode = FALSE; /*MC, SPR 1442, we'll be displaying messages as ASCII*/
1326 /*SPR2175, use new function for conversion*/
1327 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
1328 //Donot display sender's address for status report
1329 if( list_data->sms_messages[i].msg_type NEQ MFW_SMS_STATRPT)
1330 ATB_convert_String( MtMessage->sms_msg, input_type/*MC SPR1242*/, input_length/*SPR 1453*/,
1331 &sms_text_ascii[txt_len], MFW_ASCII /*MC SPR1242*/, MENU_TEXT_LENGTH-(txt_len+1)/*MC SPR1242*/, TRUE);
1332 }
1333 else //language = Chinese
1334 { unicode = TRUE;/*MC, SPR 1442, we'll be displaying messages as unicode*/
1335 /*SPR2175, use new function for conversion*/
1336 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
1337 //Donot display sender's address for status report
1338 if( list_data->sms_messages[i].msg_type NEQ MFW_SMS_STATRPT)
1339 ATB_convert_String( MtMessage->sms_msg, input_type /*SH*/, MtMessage->msg_len,
1340 &sms_text_ascii[txt_len], MFW_DCS_UCS2, UCS2_MENU_TEXT_LEN-txt_len/*MC SPR1242*/, TRUE);
1341 }
1342 list_data->sms_header[g_sms_list_counter] = (wstring_t *) ALLOC_MEMORY (UCS2_MENU_TEXT_LEN + 1/*MC SPR1242*/);
1343
1344 //Check for allocation fail before using memory
1345 if(list_data->sms_header[g_sms_list_counter] != NULL)
1346 { /*MC, SPR 1442, use truncation function to copy message header to list*/
1347 resources_truncate_to_screen_width(sms_text_ascii,0,(char*) list_data->sms_header[g_sms_list_counter], UCS2_MENU_TEXT_LEN, SCREEN_SIZE_X, unicode);
1348
1349 }
1350 else
1351 TRACE_EVENT(" Memory allocation failed ");
1352
1353 g_sms_list_counter--;
1354
1355 if (g_sms_list_counter >= 0)
1356 {
1357 // There are still messages to read.
1358 /*SPR2260, if reading SMS fails, retry*/
1359 if (sms_read(MFW_SMS_MESSAGE, (UBYTE)list_data->sms_messages[g_sms_list_counter].index) == MFW_SMS_FAIL)
1360 {
1361 retry_sms_read(SHORTToUBYTE(list_data->sms_messages[g_sms_list_counter].index));
1362 }
1363 g_nb_line_sms++;
1364 }
1365 else
1366 {
1367 // All the messages have been retrieved --> display the list of SMS
1368 if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
1369 SmsRead_R_BuildList(win,0);
1370 else
1371 SmsRead_R_BuildList(win,1);
1372 }
1373 }
1374 else
1375 { /*if index is not the one expected, pass event on to SmsIdle module*/
1376 return MFW_EVENT_PASSED;
1377 }
1378
1379 }
1380 else
1381 #endif
1382 if (g_sms_state EQ READ_SELECTED_SMS)
1383 {
1384 TRACE_EVENT_P1("MtMessage len: %d", MtMessage->msg_len);
1385 /*SPR 2176, if this was the message we requested*/
1386 if (MtMessage->index == data->sms_editor_data.sms_index)
1387 {
1388 data->sms_editor_data.sms_info = (T_MFW_SMS_PARA *)ALLOC_MEMORY (sizeof (T_MFW_SMS_PARA));
1389
1390 data->sms_editor_data.sms_type = MMI_SMS_MT;
1391 memcpy(data->sms_editor_data.sms_info, (T_MFW_SMS_PARA *)MtMessage, sizeof(T_MFW_SMS_PARA));
1392 sms_copy_idx(MtMessage->index, &msg_info);
1393
1394
1395 SmsRead_R_TEXTEDT2_start(win, (MfwMnuAttr *)&(data->sms_editor_data));
1396 }
1397 else
1398 { /*if index is not the one expected, pass event on to SmsIdle module*/
1399 return MFW_EVENT_PASSED;
1400 }
1401 }
1402 break;
1403 case E_SMS_ERR:
1404 TRACE_EVENT("SMS Error");
1405 if (info_win){
1406 SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
1407 info_win = 0;
1408 }
1409 #ifndef ORIGINAL_SMS_LIST
1410 /*SPR 2530 Delete and recreate SMS list window to show updates*/
1411 { T_MFW_SMS_STAT sms_list_type = MFW_SMS_ALL;
1412
1413 listsDestroy(list_win);
1414 list_win=0;
1415 SmsRead_R_destroy(sms_read_win);
1416 SmsRead_R_start(NULL, (MfwMnuAttr*)&sms_list_type);
1417 }
1418 #endif
1419 break;
1420 /*SPR 2530 handle new message event*/
1421 case E_SMS_MT_RECEIVED:
1422 /*if we are not currently displaying a message*/
1423 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
1424 // Added condition ' invalidVm == FALSE' before updating sms list
1425 // to ensure that no blank voice mail sms entry is shown.
1426 if (message_win == NULL && invalidVm == FALSE)
1427 /*SPR 2530 Delete and recreate SMS list window to show updates*/
1428 { T_MFW_SMS_STAT sms_list_type = MFW_SMS_ALL;
1429
1430 // Dec 15,2004 REF: CRR 24396 xkundadu
1431 // Description: Phone crashes when a message is received while the
1432 // 'List Empty' dialog is displayed.
1433 // Solution: NULL check is added for the list_win handle before calling
1434 // listsDestroy() function when an MT sms is receieved.
1435
1436 // Check whether the sms list window is already destroyed or not.
1437 TRACE_EVENT(" MT SMS RECEIVED ");
1438 if(list_win != NULL)
1439 {
1440 listsDestroy(list_win);
1441 list_win=0;
1442 }
1443
1444 // If the 'List empty' dialog is being displayed,
1445 // wait for 3 seconds and continue.
1446 if(SmsListEmptyDlgPresent)
1447 {
1448 vsi_t_sleep (VSI_CALLER 3000);
1449 }
1450 SmsRead_R_destroy(sms_read_win);
1451 SmsRead_R_start(NULL, (MfwMnuAttr*)&sms_list_type);
1452 }
1453 /*pass event to next handler*/
1454 return MFW_EVENT_REJECTED;
1455 // break; // RAVI
1456 /*SPR 2530 end*/
1457 default:
1458 TRACE_EVENT(" SmsRead_R_mfw_cb case: Default");
1459 return MFW_EVENT_REJECTED;
1460 }
1461 return MFW_EVENT_CONSUMED;
1462 }
1463
1464 /*******************************************************************************
1465
1466 $Function: retry_sms_read. Added for SPR2260
1467
1468 $Description: set up a timer to re-read sms at passed index in 100ms
1469
1470 $Returns: none
1471
1472 $Arguments: index of sms to be re-read
1473
1474 *******************************************************************************/
1475 void retry_sms_read(int index)
1476 { TRACE_EVENT("retry_sms_read()");
1477 retry_handle = tim_create(NULL, 1000, (MfwCb)retry_sms_read_tim_cb);
1478 tim_start(retry_handle);
1479 retry_index = index;
1480
1481 }
1482 /*******************************************************************************
1483
1484 $Function: retry_sms_read_tim_cb. Added for SPR2260
1485
1486 $Description: Callback function for retry SMS read timer
1487
1488 $Returns: status int
1489
1490 $Arguments: event, timer data structure
1491
1492 *******************************************************************************/
1493 int retry_sms_read_tim_cb(MfwEvt event, MfwTim *timer_info)
1494 { TRACE_EVENT("retry_sms_read_tim_cb()");
1495 if (sms_read(MFW_SMS_MESSAGE, retry_index) == MFW_SMS_FAIL)
1496 { tim_start(retry_handle);}
1497 else
1498 { tim_delete(retry_handle);
1499 retry_handle = NULL;
1500 }
1501 return MFW_EVENT_CONSUMED;
1502
1503 }
1504 /*******************************************************************************
1505
1506 $Function: SmsRead_R_smslist_cb
1507
1508 $Description: Callback function for the dynamic list of the SMS read window.
1509
1510 $Returns: none
1511
1512 $Arguments: Parent - window handler
1513 ListData - Menu list data.
1514
1515 *******************************************************************************/
1516
1517 void SmsRead_R_smslist_cb(T_MFW_HND * Parent, ListMenuData * ListData)
1518 {
1519
1520
1521
1522 T_MFW_WIN * win_data;
1523 T_SMSREAD_R * data;
1524
1525 // T_MFW_HND * l_parent; // RAVI
1526 // SHORT l_id; // RAVI
1527
1528
1529 TRACE_FUNCTION("SmsRead_R_smslist_cb ");
1530
1531 win_data = getWinData(Parent);
1532 data = getUserData_T_SMSREAD_R(win_data);
1533
1534 // In all the case, we need the index of the selected message
1535 data->sms_editor_data.sms_index = data->sms_list_data.sms_messages[ListData->ListPosition].index;
1536
1537 if (ListData->Reason EQ LISTS_REASON_SELECT/* && ListData->KeyReason EQ KCD_LEFT*/)
1538 {
1539 TRACE_EVENT(">>> Reason:LISTS_REASON_SELECT ");
1540 // We want only to retrieve the selected SMS
1541 g_sms_state = READ_SELECTED_SMS;
1542
1543 if (!info_win)
1544 info_win = mmi_dialog_information_screen_forever(Parent,TxtPleaseWait, NULL, COLOUR_STATUS_WAIT);
1545
1546 /*NM p030 just in case not to using the '0' index for reading */
1547 if (data->sms_editor_data.sms_index NEQ 0)
1548 { /*SPR 2530, if read fails, retry later*/
1549
1550 if (sms_read(MFW_SMS_MESSAGE, SHORTToUBYTE(data->sms_editor_data.sms_index ))== MFW_SMS_FAIL)
1551 {
1552 retry_sms_read(SHORTToUBYTE(data->sms_editor_data.sms_index ));
1553 }
1554 }
1555 }
1556
1557 /*NM p032 check if the TEST SIM is inserted.
1558 During testing FTA 34.2.3 we would like to delete
1559 the sms from the list without changing the sms-status
1560 from unread to read
1561 */
1562 if (test_sim EQ TRUE)
1563 {
1564
1565 if (ListData->Reason EQ LISTS_REASON_HANGUP)
1566 {
1567 TRACE_EVENT(">>> Reason: LISTS_REASON_HANGUP ");
1568 listsDestroy(ListData->win);
1569 list_win=0;
1570 SmsRead_R_destroy(data->win);
1571 }
1572 /*
1573 the right-soft-key deletes
1574 the selected sms in the list-menu without changing
1575 the read-status of the sms.
1576
1577 go-back key is now on the "Hang_up"
1578 */
1579 if ((ListData->Reason EQ LISTS_REASON_BACK )
1580 || (ListData->Reason EQ LISTS_REASON_CLEAR ))
1581 {
1582 T_DISPLAY_DATA DisplayInfo;
1583
1584 TRACE_EVENT(">>> Reason: LISTS_REASON_BACK/CLEAR ");
1585
1586 /* show for a short period "Message deleted" and go
1587 back to the previous menu-screen
1588 */
1589 if((sms_msg_delete((UBYTE)data->sms_editor_data.sms_index) EQ MFW_SMS_OK)
1590 && (data->sms_editor_data.sms_index NEQ 0))
1591 {
1592
1593 DisplayInfo.TextString = '\0';
1594 DisplayInfo.TextString2 = '\0';
1595 DisplayInfo.LeftSoftKey = 0;
1596 DisplayInfo.RightSoftKey = 0;
1597 DisplayInfo.Time = THREE_SECS;
1598 DisplayInfo.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT;;
1599 DisplayInfo.TextId = TxtMessage;
1600 DisplayInfo.TextId2 = TxtDeleted;
1601 DisplayInfo.Identifier = NULL;
1602 DisplayInfo.Callback = NULL;
1603
1604 info_dialog(data->win, &DisplayInfo);
1605
1606 }
1607
1608 /* destroy the read-sms-menu and go back to
1609 the previous screen
1610 */
1611 listsDestroy(ListData->win);
1612 list_win=0;
1613 SmsRead_R_destroy(data->win);
1614
1615 }
1616
1617 }
1618 else
1619 {
1620 if ((ListData->Reason EQ LISTS_REASON_BACK /*&& ListData->KeyReason EQ KCD_RIGHT*/)
1621 || (ListData->Reason EQ LISTS_REASON_CLEAR /*&& ListData->KeyReason EQ KCD_HUP */)
1622 || (ListData->Reason EQ LISTS_REASON_HANGUP)) // sbh - added hangup key
1623 {
1624 TRACE_EVENT(">>> Reason: LISTS_REASON_BACK/CLEAR ");
1625 listsDestroy(ListData->win);
1626 list_win=0;
1627 SmsRead_R_destroy(data->win);
1628 }
1629
1630
1631 }
1632 /*NM p032 end*/
1633
1634 }
1635
1636 /*******************************************************************************
1637
1638 $Function: SmsRead_R_dialog_cb
1639
1640 $Description: Dialog callback function of the SMS read window (dynamic list of all the SMS)
1641 Case where SMS has not been initialized yet
1642
1643 $Returns: status
1644
1645 $Arguments: win - current window handler
1646 Identifier - window id
1647 Reason - Event cause.
1648
1649 *******************************************************************************/
1650
1651 int SmsRead_R_dialog_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
1652 {
1653 T_MFW_WIN * win_data;
1654 T_SMSREAD_R * data;
1655 T_MFW_HND *lparent;
1656
1657 win_data = getWinData(win);
1658 data = getUserData_T_SMSREAD_R(win_data);
1659 lparent = data->parent;
1660
1661 TRACE_FUNCTION ("SmsRead_dialog_cb()");
1662
1663 switch (Reason)
1664 {
1665 case INFO_TIMEOUT:
1666 case INFO_KCD_HUP:
1667 // Commit suicide
1668 SmsRead_R_destroy(win);
1669 // Send E_RETURN event to parent window
1670 SEND_EVENT(lparent, E_RETURN, data->id, NULL);
1671
1672 // Dec 15,2004 REF: CRR 24396 xkundadu
1673 // Description: Phone crashes when a message is received while the
1674 // 'List Empty' dialog is displayed.
1675
1676 // set the variable to FALSE, since 'List empty' dialog has been destroyed .
1677 SmsListEmptyDlgPresent = FALSE;
1678 return MFW_EVENT_CONSUMED;
1679
1680 default:
1681 return MFW_EVENT_REJECTED;
1682 }
1683 }
1684
1685 /*******************************************************************************
1686
1687 $Function: SmsRead_R_BuildList
1688
1689 $Description: Build the list of SMS for the dynamic list.
1690
1691 $Returns: status
1692
1693 $Arguments: win - current window handler
1694
1695 *******************************************************************************/
1696
1697 void SmsRead_R_BuildList(T_MFW_HND win, int inUnicode)
1698 {
1699
1700 T_MFW_WIN * win_data;
1701 T_SMSREAD_R * data;
1702
1703 /* List is complete so present menu. */
1704 USHORT i;
1705
1706 TRACE_FUNCTION("SmsRead_R_BuildList");
1707
1708 win_data = getWinData(win);
1709 data = getUserData_T_SMSREAD_R(win_data);
1710
1711 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData));
1712
1713 if(data->menu_list_data == 0)
1714 {
1715 TRACE_EVENT("Failed memory alloc 1 ");
1716 return;
1717 }
1718 /*SPR 2686, only allocate memory for the number of messages displayed*/
1719 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( ((data->sms_list_data).nb_sms_stored) * sizeof(T_MFW_MNU_ITEM) );//JVJE
1720
1721 if(data->menu_list_data->List == 0)
1722 {
1723 TRACE_EVENT("Failed memory alloc 2");
1724 return;
1725 }
1726
1727
1728 for (i = 0; i < ((data->sms_list_data).nb_sms_stored); i++)
1729 {
1730 mnuInitDataItem(&data->menu_list_data->List[i]);
1731 data->menu_list_data->List[i].str = (char *)(data->sms_list_data).sms_header[i];
1732 data->menu_list_data->List[i].flagFunc = item_flag_none;
1733 }
1734
1735 data->menu_list_data->ListLength =(data->sms_list_data).nb_sms_stored;
1736 data->menu_list_data->ListPosition = 1;
1737 data->menu_list_data->CursorPosition = 1;
1738 data->menu_list_data->SnapshotSize =(data->sms_list_data).nb_sms_stored;
1739 data->menu_list_data->Font = 0;
1740 data->menu_list_data->LeftSoftKey = TxtSoftSelect;
1741 /*NM p032*/
1742 if(test_sim EQ TRUE)
1743 data->menu_list_data->RightSoftKey = TxtDelete;
1744 else
1745 data->menu_list_data->RightSoftKey = TxtSoftBack;
1746
1747 data->menu_list_data->KeyEvents = KEY_ALL;
1748 data->menu_list_data->Reason = 0;
1749 data->menu_list_data->Strings = TRUE;
1750 data->menu_list_data->Attr = (MfwMnuAttr*)&readSMS_menuAttrib;
1751 data->menu_list_data->autoDestroy = FALSE;
1752
1753 /* Create the dynamic menu window */
1754 listDisplayListMenu(win, data->menu_list_data, (ListCbFunc_t)SmsRead_R_smslist_cb,inUnicode);
1755 list_win = data->menu_list_data->win;
1756 if (info_win){
1757 SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
1758 info_win = 0;
1759 }
1760 }
1761
1762
1763
1764 /*******************************************************************************
1765
1766 $Function: SmsRead_R_OPTExeDelete
1767
1768 $Description: Called when the user press Delete in the Option menu
1769
1770 $Returns: event status.
1771
1772 $Arguments: m - pointer to menu.
1773 i - index if selected menu item.
1774 *******************************************************************************/
1775
1776 static int SmsRead_R_OPTExeDelete(MfwMnu* m, MfwMnuItem* item)
1777 {
1778 T_MFW_HND win = mfwParent(mfw_header());
1779 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1780 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
1781
1782 /* access to data from parent */
1783 T_MFW_HDR * parent = data->parent;
1784 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
1785
1786 T_SMSREAD_R_TEXTEDT2 * parent_data = (T_SMSREAD_R_TEXTEDT2 *)win_data2->user;
1787 // May 27, 2005 MMI-FIX-29869 x0018858
1788 #ifdef FF_MMI_SMS_DYNAMIC
1789 // Changed from static to dynamic
1790 T_MFW_SMS_IDX* temp_message_list;/*SPR2530*/
1791 #else
1792 T_MFW_SMS_IDX temp_message_list[MAX_MESSAGES];/*SPR2530*/
1793 #endif
1794 int no_of_messages, i;/*SPR2530*/
1795 BOOL message_currently_in_list = FALSE;/*SPR2530*/
1796 UBYTE deleting_index = parent_data->sms_editor_data->sms_index;/*SPR2686*/
1797 #ifdef FF_MMI_SMS_DYNAMIC
1798 temp_message_list = (T_MFW_SMS_IDX*)ALLOC_MEMORY(g_max_messages*sizeof(T_MFW_SMS_IDX));
1799 #endif
1800 TRACE_FUNCTION("SmsRead_R_OPTExeDelete");
1801 #ifdef MMI_LITE
1802 /*SPR 2686 destroy option window to reduce memory usage*/
1803 if (mfwCheckMemoryLeft() < 400)
1804 SmsRead_R_OPT_destroy(option_mnu_win);
1805 #endif
1806 /*SPR2530, check if message index in current list of messages*/
1807 #ifdef FF_MMI_SMS_DYNAMIC
1808 no_of_messages = sms_index_list(MFW_SMS_ALL, temp_message_list, g_max_messages);
1809 #else
1810 no_of_messages = sms_index_list(MFW_SMS_ALL, temp_message_list, MAX_MESSAGES);
1811 #endif
1812 for (i= 0; i< no_of_messages;i++)
1813 {
1814 if (temp_message_list[i].index == deleting_index)
1815 message_currently_in_list = TRUE;
1816 }
1817
1818 if (message_currently_in_list == TRUE)
1819 {
1820
1821 if(sms_msg_delete((UBYTE)deleting_index/*SPR 2686*/)== MFW_SMS_OK)
1822 {
1823 /* set the status that the user selected the delete item */
1824 if(deleting_win == 0)
1825 deleting_win= mmi_dialog_information_screen_forever(0,TxtPleaseWait, NULL, COLOUR_STATUS_WAIT);
1826
1827 {
1828 // Destroy the text editor and free memory.
1829 SmsRead_R_TEXTEDT2_destroy(parent_data->win);
1830 /*SPR 2686, only destroy option menu window if it hasn't already been destroyed*/
1831 if (option_mnu_win)
1832 SmsRead_R_OPT_destroy(option_mnu_win);
1833
1834 }
1835
1836 }
1837 else
1838 {
1839
1840 /*SPR2530, don't delete option and display windows, just show failure*/
1841 mmi_dialog_information_screen(0,TxtFailed, NULL, NULL, COLOUR_STATUS_WAIT);
1842 }
1843 }
1844 else
1845 {
1846 /*SPR2530, don't delete option and display windows, just show failure*/
1847 mmi_dialog_information_screen(0,TxtFailed, NULL, NULL, COLOUR_STATUS_WAIT);
1848 }
1849
1850 // May 27, 2005 MMI-FIX-29869 x0018858
1851 #ifdef FF_MMI_SMS_DYNAMIC
1852 // Free the allocated memory
1853 FREE_MEMORY((U8*)temp_message_list, g_max_messages*sizeof(T_MFW_SMS_IDX));
1854 #endif
1855 return 1; // ADDED BY RAVI - 28-11-2005
1856 }
1857
1858 /*******************************************************************************
1859
1860 $Function: SmsRead_R_OPTExeReply
1861
1862 $Description: Called when the user press Reply in the Option menu
1863
1864 $Returns: event status.
1865
1866 $Arguments: m - pointer to menu.
1867 i - index if selected menu item.
1868 *******************************************************************************/
1869
1870 static int SmsRead_R_OPTExeReply(MfwMnu* m, MfwMnuItem* i)
1871 {
1872
1873 T_MFW_HND win = mfwParent(mfw_header());
1874 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1875 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
1876
1877 T_MFW_HDR * parent = data->parent;
1878 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
1879
1880 T_SMSREAD_R_TEXTEDT2 * parent_data = (T_SMSREAD_R_TEXTEDT2 *)win_data2->user;
1881 // March 2, 2005 REF: CRR 11536 x0018858
1882 // T_MFW_SMS_INFO sms_parameter;//Added for retreiving the Reply path. // RAVI
1883
1884
1885 TRACE_FUNCTION("SmsRead_R_OPTExeReply");
1886
1887 /* Copy the number and name information to the SMS buffer
1888 */
1889 /*MC SPR 1257, clear whole buffer in case of Unicode entry*/
1890 memset(SmsData.TextBuffer, '\0', MAX_MSG_LEN_ARRAY);
1891 //Copy the calling number for pasting into the number buffer;
1892 /* Marcus: Issue 1804: 12/03/2003: Start */
1893 if(parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.ton == MFW_TON_INTERNATIONAL)
1894 {
1895 if(parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number[0] == '+')
1896 {
1897 strcpy((char *)SmsData.NumberBuffer,(char *)parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number);
1898 }
1899 else
1900 {
1901 strcpy((char *)SmsData.NumberBuffer,"+");
1902 strncat((char *)SmsData.NumberBuffer,(char *)parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number,sizeof(SmsData.NumberBuffer)-2);
1903 }
1904 }
1905 else
1906 strcpy((char *)SmsData.NumberBuffer,(char *)parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number);
1907 /* Marcus: Issue 1804: 12/03/2003: End */
1908
1909 // March 2, 2005 REF: CRR 11536 x0018858
1910 // Retreive and check the reply bit from the structure.
1911 // see if we should use our own service centre number
1912 if ( reply_path_bit && parent_data->sms_editor_data->sms_info->sms_mt.rp &&
1913 strlen(parent_data->sms_editor_data->sms_info->sms_mt.sc_addr) != 0 )
1914 {
1915 TRACE_EVENT_P1("The receivers SCA is %s",parent_data->sms_editor_data->sms_info->sms_mt.sc_addr);
1916 SmsData.called_from_reply_item = TRUE;
1917 /* copy the service center number as well */
1918 strcpy((char *)SmsData.CentreBuffer, (char *)parent_data->sms_editor_data->sms_info->sms_mt.sc_addr);
1919 }
1920 else
1921 {
1922 TRACE_EVENT_P1("The senders SCA is %s",SmsData.NumberBuffer);
1923 /* use the own Service Center Number if the caller doesnt send one*/
1924 SmsData.called_from_reply_item = FALSE;
1925 }
1926
1927 /* p304 SH save window pointer */
1928 win = parent_data->win;
1929 // Destroy the text editor, free memory
1930 SmsRead_R_TEXTEDT2_destroy(parent_data->win);
1931 /* Destroy the Options Menu and text editor.before starting the Send Editor.*/
1932 SmsRead_R_OPT_destroy(data->win);
1933
1934 /*SPR 2686 destroy the SMS read window to free memory*/
1935 /*destroy the built list window*/
1936 listsDestroy(list_win);
1937 list_win=0;
1938 /*destroy the main control window*/
1939 if (sms_read_win)/*SPR 2132, check window exists before destroying it*/
1940 {
1941 SmsRead_R_destroy(sms_read_win);
1942 sms_read_win = NULL;
1943 }
1944 /* NM, FTA 34.2.8 */
1945
1946 /* p304 SH - call this after destroying editor & windows. parent_data is lost,
1947 so use pointer saved from above */
1948 SmsSend_SEND_start(win, (void *) &SmsData);
1949
1950
1951
1952
1953 return 1;
1954 }
1955
1956 /*******************************************************************************
1957
1958 $Function: SmsRead_R_OPTExeStoreNumber
1959
1960 $Description: Called when the user press Store Number in the Option menu
1961
1962 $Returns: event status.
1963
1964 $Arguments: m - pointer to menu.
1965 i - index if selected menu item.
1966 *******************************************************************************/
1967
1968 static int SmsRead_R_OPTExeStoreNumber(MfwMnu* m, MfwMnuItem* i)
1969 {
1970 T_MFW_HND win = mfwParent(mfw_header());
1971 T_MFW_HND win2; //Mar 27, 2006 DR:OMAPS00047813 x0035544
1972 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1973 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
1974
1975 T_MFW_HDR * parent = data->parent;
1976 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
1977 T_SMSREAD_R_TEXTEDT2 * parent_data = (T_SMSREAD_R_TEXTEDT2 *)win_data2->user;
1978 T_MFW_PHB_ENTRY pb_data;
1979 // UBYTE found_name; /*SPR888 -SH*/ // RAVI
1980 //Mar 27, 2006 DR:OMAPS00047813 x0035544
1981 CHAR number[MFW_NUM_LEN];
1982 T_MFW_PHB_TON ton;
1983
1984 TRACE_FUNCTION("SmsRead_R_OPTExeStoreNumber");
1985
1986 /* Copy the number and name information to the SMS buffer
1987 */
1988 //Mar 27, 2006 DR:OMAPS00047813 x0035544
1989 ton = parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.ton;
1990 strcpy(number, parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number);
1991
1992 /*SPR 2686 destroy windows before attempting to extract numbers.*/
1993 // Destroy the text editor, rel memory.
1994 SmsRead_R_TEXTEDT2_destroy(parent_data->win);
1995 /* Destroy the Options Menu and text editor. */
1996 SmsRead_R_OPT_destroy(data->win);
1997
1998 //Mar 27, 2006 DR:OMAPS00047813 x0035544
1999 if(ton == MFW_TON_INTERNATIONAL &&
2000 number[0]!='+' && strlen((char *)number)>0 )
2001 /* SPR888 - SH - do not add + if already there */
2002 {
2003 strcpy((char *)SmsData.NumberBuffer,"+");
2004 strcat((char *)SmsData.NumberBuffer,(char *)number);
2005 }
2006 else
2007 {
2008 strcpy((char *)SmsData.NumberBuffer,(char *)number);
2009 }
2010
2011 if (read_status EQ MMI_SMS_MT)
2012 {
2013 /* MT -SMS has the additional information (Date, Time & Number)
2014 we dont want to show these when we are editing */
2015 memcpy(SmsData.TextBuffer,&sms_text_ascii[current_sms_len],MAX_MSG_LEN_ARRAY);
2016 }
2017 else
2018 {
2019 //when we were reading the saved-SMS with the length of MAX_MSG_LEN
2020 memcpy(SmsData.TextBuffer,sms_text_ascii,MAX_MSG_LEN_ARRAY);/* assumption: sms_text_ascii is still filled from reading the SMS*/
2021 }
2022
2023 /* SPR888 - SH - Start looking for numbers from beginning of SMS text */
2024 #if 0 //Mar 24, 2006 DR:OMAPS00047813 x0035544
2025 search_index = 0;
2026 if (strlen((char *)SmsData.NumberBuffer)==0)
2027 {
2028 Search_forNextNumber(&SmsData);
2029 }
2030
2031 if (strlen((char *)SmsData.NumberBuffer)==0)
2032 {
2033 mmi_dialog_information_screen(0, TxtNotAvailable, NULL, NULL, NULL);
2034 }
2035 else
2036 {
2037 //Search the phonebook for the sender number entry and display the tag and number.
2038 if (bookFindNameInPhonebook((const char*)&SmsData.NumberBuffer[0], &pb_data) !=0)
2039 {
2040 #ifdef NO_ASCIIZ
2041 //Display the tag and number dialog.
2042 /* SPR888 - SH - parent_data->parent changed to parent_data->win */
2043 smsRead_NumberName_info_screen(0,(void *)&SmsData, (char*)pb_data.name.data);
2044 #else
2045 //Display the tag and number dialog.
2046 /* SPR888 - SH - parent_data->parent changed to parent_data->win */
2047 smsRead_NumberName_info_screen(0,(void *)&SmsData, (char*)pb_data.name);
2048 #endif
2049
2050 }
2051 else
2052 {
2053 /* SPR888 - SH - parent_data->parent changed to parent_data->win */
2054 smsRead_NumberName_info_screen(0,(void *)&SmsData,NULL);
2055 }
2056 }
2057 #endif //Mar 24, 2006 DR:OMAPS00047813 x0035544
2058
2059 //Mar 24, 2006 DR:OMAPS00047813 x0035544
2060 Search_forNumberInSMS(&SmsData);
2061 win2 = SmsRead_BuildNumList_Menu( win);
2062 if (win2 NEQ NULL)
2063 {
2064 SEND_EVENT (win2, E_INIT, 0, 0);
2065 }
2066
2067
2068 return 1;
2069 }
2070
2071 /*******************************************************************************
2072
2073 $Function: SmsRead_R_OPTExeEdit
2074
2075 $Description: Called when the user press Forward in the Option menu
2076
2077 $Returns: event status.
2078
2079 $Arguments: m - pointer to menu.
2080 i - index if selected menu item.
2081 *******************************************************************************/
2082
2083 static int SmsRead_R_OPTExeEdit(MfwMnu* m, MfwMnuItem* i)
2084 {
2085 T_MFW_HND win = mfwParent(mfw_header());
2086 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2087 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
2088
2089 T_MFW_HDR * parent = data->parent;
2090 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
2091 T_SMSREAD_R_TEXTEDT2 * parent_data = (T_SMSREAD_R_TEXTEDT2 *)win_data2->user;
2092 T_DISPLAY_DATA Dialog;
2093
2094 TRACE_FUNCTION("SmsRead_R_OPTExeEdit");
2095 if (FFS_flashData.ConcatenateStatus == TRUE )
2096 {
2097 /* Copy the number and name information to the SMS buffer
2098 */
2099 SmsData.NumberBuffer[0] = '\0';
2100 if (read_status EQ MMI_SMS_MT)
2101 {
2102 /* MT -SMS has the additional information (Date, Time & Number)
2103 we dont want to show these when we are editing */
2104
2105 // Dec 01, 2004 REF: CRR 24225 xnkulkar
2106 // Description: Reset when forwarding SMS
2107 // Solution: The message content is sent excluding the date/time info from the
2108 // original message, which was causing the reset as the max limit was crossed.
2109 memcpy(SmsData.TextBuffer,&sms_text_ascii[current_sms_len + ORIGINAL_DATE_TIME_INFO],MAX_MSG_LEN_ARRAY);
2110 }
2111 else
2112 {
2113 //when we were reading the saved-SMS with the length of MAX_MSG_LEN
2114 memcpy(SmsData.TextBuffer,sms_text_ascii,MAX_MSG_LEN_ARRAY);/* assumption: sms_text_ascii is still filled from reading the SMS*/
2115 }
2116 SmsData.called_from_reply_item = FALSE;
2117
2118 /* p304 SH save window pointer */
2119 win = parent_data->win;
2120 // Destroy the text editor, free memory
2121 SmsRead_R_TEXTEDT2_destroy(parent_data->win);
2122 /* Destroy the Options Menu and text editor.before starting the Send Editor.*/
2123 SmsRead_R_OPT_destroy(data->win);
2124 /*SPR 1991 destroy the SMS read window to free memory*/
2125 /*destroy the built list window*/
2126 listsDestroy(list_win);
2127 list_win=0;
2128 /*destroy the main control window*/
2129 if (sms_read_win)/*SPR 2132, check window exists before destroying it*/
2130 {
2131 SmsRead_R_destroy(sms_read_win);
2132 sms_read_win = NULL;
2133 }
2134
2135 /*SPR 1991 end*/
2136 /* NM, FTA 34.2.8 */
2137
2138 /* p304 SH - call this after destroying editor & windows. parent_data is lost,
2139 so use pointer saved from above */
2140 SmsSend_SEND_start(win, (void *) &SmsData);
2141 }
2142 /* API - 28-01-03 - 1628 - Allow the editing of a single SMS if ConcatenateStatus is FALSE */
2143 /* API - 19-03-03 - 1825 - Allow the editing of a single saved SMS if ConcatenateStatus is FLASE*/
2144
2145 // Feb 16, 2005 REF: CRR 28966 x0012851
2146 // Description: Editing or forwarding of large MT messages (>160 characters)
2147 // shouldn't be allowed when Concatenation is set to 'OFF'
2148 // Solution: If the 'ConcatenateStatus' flag is FALSE, the 'if' check condition
2149 // which allows the message to be edited or forwarded has been
2150 // modified for the same.
2151 else if (FALSE==FFS_flashData.ConcatenateStatus)
2152 {
2153 if (((read_status EQ MMI_SMS_MT) && (parent_data->sms_editor_data->sms_info->sms_mt.msg_len <= BASIC_MAX_MSG_LEN))
2154 ||((read_status EQ MMI_SMS_MO) && (parent_data->sms_editor_data->sms_info->sms_mo.msg_len <= BASIC_MAX_MSG_LEN)))
2155 {
2156 TRACE_EVENT_P1("msg_len in edit is = %d", parent_data->sms_editor_data->sms_info->sms_mt.msg_len);
2157 /* Copy the number and name information to the SMS buffer
2158 */
2159 SmsData.NumberBuffer[0] = '\0';
2160 if (read_status EQ MMI_SMS_MT)
2161 {
2162 /* MT -SMS has the additional information (Date, Time & Number)
2163 we dont want to show these when we are editing */
2164 // Dec 01, 2004 REF: CRR 24225 xnkulkar
2165 // Description: Reset when forwarding SMS
2166 // Solution: The message content is sent excluding the date/time info from the
2167 // original message, which was causing the reset as the max limit was crossed.
2168 memcpy(SmsData.TextBuffer,&sms_text_ascii[current_sms_len + ORIGINAL_DATE_TIME_INFO],MAX_MSG_LEN_SGL);
2169 }
2170 else
2171 {
2172 //when we were reading the saved-SMS with the length of MAX_MSG_LEN
2173 memcpy(SmsData.TextBuffer,sms_text_ascii,MAX_MSG_LEN_SGL);/* assumption: sms_text_ascii is still filled from reading the SMS*/
2174 }
2175 SmsData.called_from_reply_item = FALSE;
2176
2177 win = parent_data->win;
2178 // Destroy the text editor, free memory
2179 SmsRead_R_TEXTEDT2_destroy(parent_data->win);
2180 /* Destroy the Options Menu and text editor.before starting the Send Editor.*/
2181 SmsRead_R_OPT_destroy(data->win);
2182 /*SPR 1991 destroy the SMS read window to free memory*/
2183 /*destroy the built list window*/
2184 listsDestroy(list_win);
2185 list_win=0;
2186 /*destroy the main control window*/
2187 if (sms_read_win)/*SPR 2132, check window exists before destroying it*/
2188 {
2189 SmsRead_R_destroy(sms_read_win);
2190 sms_read_win = NULL;
2191 }
2192 /*SPR 1991 end*/
2193 SmsSend_SEND_start(win, (void *) &SmsData);
2194 }
2195 /* API - 28-01-03 - 1628 - END */
2196 else
2197 {
2198 /* Initialise the dialog control block with default information
2199 */
2200 dlg_initDisplayData_TextId( &Dialog, TxtNull, TxtNull, TxtNotAllowed, TxtNull , COLOUR_STATUS_WAIT);
2201 dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)NULL, 3000, KEY_CLEAR );
2202
2203 /* Show the dialog
2204 */
2205 info_dialog( win, &Dialog );
2206
2207 }
2208 }
2209 return 1;
2210 }
2211
2212 /*******************************************************************************
2213
2214 $Function: SmsRead_R_READSMS_OPT_start
2215
2216 $Description: Start the creation of the Option Window from the Read SMS
2217 Text window.
2218
2219 $Returns: mfw window handler
2220
2221 $Arguments: parent_window- pointer to menu.
2222 menuAttr - menu attributes.
2223 *******************************************************************************/
2224
2225 T_MFW_HND SmsRead_R_READSMS_OPT_start(T_MFW_HND parent_window, MfwMnuAttr *menuAttr)
2226 {
2227 /*SPR 2132, setting global var to keep track of options window*/
2228
2229 TRACE_FUNCTION ("SmsRead_R_OPT_start()");
2230
2231 option_mnu_win = SmsRead_R_OPT_create (parent_window);
2232
2233 if (option_mnu_win NEQ NULL)
2234 {
2235 SEND_EVENT (option_mnu_win , E_INIT, SmsRead_R_READSMS_OPT_ID, (void *)menuAttr);
2236 }
2237 return option_mnu_win;
2238 }
2239
2240 /*SPR 2132, removed obsolete function*/
2241 /*******************************************************************************
2242
2243 $Function: SmsRead_R_OPT_create
2244
2245 $Description: Create the Options window
2246
2247 $Returns: window handler
2248
2249 $Arguments: parent_window- pointer to parent window
2250 *******************************************************************************/
2251
2252 static T_MFW_HND SmsRead_R_OPT_create(MfwHnd parent_window)
2253 {
2254 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)ALLOC_MEMORY (sizeof (T_SMSREAD_R_OPT));
2255 T_MFW_WIN * win;
2256
2257 TRACE_FUNCTION ("SmsRead_R_OPT_create()");
2258
2259 /*
2260 * Create window handler
2261 */
2262
2263 data->win =
2264 win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)SmsRead_R_OPT_win_cb);
2265 if (data->win EQ NULL)
2266 {
2267 return NULL;
2268 }
2269 /*
2270 * connect the dialog data to the MFW-window
2271 */
2272
2273 data->mmi_control.dialog = (T_DIALOG_FUNC)SmsRead_R_OPT_exec_cb;
2274 data->mmi_control.data = data;
2275 win = ((T_MFW_HDR *)data->win)->data;
2276 win->user = (void *)data;
2277 data->parent = parent_window;
2278
2279 /*
2280 * return window handle
2281 */
2282
2283 return data->win;
2284 }
2285
2286 /*******************************************************************************
2287
2288 $Function: SmsRead_R_OPT_destroy
2289
2290 $Description: Destroy the Option window
2291
2292 $Returns: none
2293
2294 $Arguments: own_window- current window
2295 *******************************************************************************/
2296
2297 static void SmsRead_R_OPT_destroy(MfwHnd own_window)
2298 {
2299 T_MFW_WIN * win_data;
2300 T_SMSREAD_R_OPT * data;
2301
2302 TRACE_FUNCTION ("SmsRead_R_OPT_destroy()");
2303
2304 if (own_window)
2305 {
2306 win_data = ((T_MFW_HDR *)own_window)->data;
2307 data = (T_SMSREAD_R_OPT *)win_data->user;
2308
2309 if (data)
2310 {
2311 /*
2312 * Delete WIN handler
2313 */
2314 win_delete (data->win);
2315
2316 /*
2317 * Free Memory
2318 */
2319 FREE_MEMORY ((void *)data, sizeof (T_SMSREAD_R_OPT));
2320 option_mnu_win =0;/*SPR2132, make sure window pointer is reset*/
2321 }
2322 else
2323 {
2324 TRACE_EVENT ("SmsRead_R_OPT_destroy() called twice");
2325 }
2326 }
2327 }
2328
2329 /*******************************************************************************
2330
2331 $Function: SmsRead_R_OPT_exec_cb
2332
2333 $Description: Exec callback function for the Option window
2334
2335 $Returns: none
2336
2337 $Arguments: win- current window
2338 event - window event Id
2339 value - unique Id
2340 parameter- optional data.
2341 *******************************************************************************/
2342
2343 void SmsRead_R_OPT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
2344 /* callback handler for events sent to to trigger execution */
2345 {
2346 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
2347 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
2348 T_MFW_HND * l_parent = NULL; // RAVI
2349 SHORT l_id = 0; // RAVI
2350
2351 T_MFW_EVENT MfwEvents;
2352
2353 TRACE_FUNCTION ("SmsRead_R_OPT_exec_cb()");
2354
2355
2356 switch (event)
2357 {
2358 case E_INIT:
2359 TRACE_EVENT(">> SmsRead_R_OPT_exec_cb(), E_INIT ");
2360 /* initialization of administrative data */
2361 data->id = value;
2362
2363 if(value == SmsRead_R_READSMS_OPT_ID)
2364 {
2365 data->kbd = kbdCreate(data->win,KEY_ALL, (MfwCb)SmsRead_R_OPT_kbd_cb);
2366 data->kbd_long = kbdCreate(data->win,KEY_ALL|KEY_LONG,(MfwCb)SmsRead_R_OPT_kbd_cb);
2367 //Sep 08, 2004 REF: CRR 24393 Deepa M. D
2368 //If the message is a saved/unsent message, then provide a different menu with the Reply option removed.
2369 if(read_status EQ MMI_SMS_MO)
2370 {
2371 data->menu = mnuCreate(data->win,(MfwMnuAttr *)&SmsRead_R_Unsent_OPTAttrib, E_MNU_ESCAPE, (MfwCb)SmsRead_R_OPT_mnu_cb);
2372 }
2373 else
2374 {
2375 data->menu = mnuCreate(data->win,(MfwMnuAttr *)&SmsRead_R_OPTAttrib, E_MNU_ESCAPE, (MfwCb)SmsRead_R_OPT_mnu_cb);
2376 }
2377 mnuLang(data->menu,mainMmiLng);
2378
2379 /* put the (new) dialog window on top of the window stack */
2380 mnuUnhide(data->menu);
2381 winShow(win);
2382 break;
2383 }
2384 else
2385 {
2386 // Catch the events concerning delete
2387 MfwEvents = E_SMS_ERR | E_SMS_OK;
2388
2389 data->sms = sms_create(data->win,MfwEvents,(MfwCb)SmsRead_R_OPT_mfw_cb);
2390 data->sms_editor_data = (T_SMS_EDITOR_DATA *)parameter;
2391 }
2392 case E_RETURN:
2393 /* create the dialog handler */
2394 data->kbd = kbdCreate(data->win,KEY_ALL, (MfwCb)SmsRead_R_OPT_kbd_cb);
2395 data->kbd_long = kbdCreate(data->win,KEY_ALL|KEY_LONG,(MfwCb)SmsRead_R_OPT_kbd_cb);
2396 //Sep 08, 2004 REF: CRR 24393 Deepa M. D
2397 //If the message is a saved/unsent message, then provide a different menu with the Reply option removed.
2398 if(read_status EQ MMI_SMS_MO)
2399 {
2400 data->menu = mnuCreate(data->win,(MfwMnuAttr *)&SmsRead_R_Unsent_OPTAttrib, E_MNU_ESCAPE, (MfwCb)SmsRead_R_OPT_mnu_cb);
2401 }
2402 else
2403 {
2404 data->menu = mnuCreate(data->win,(MfwMnuAttr *)&SmsRead_R_OPTAttrib, E_MNU_ESCAPE, (MfwCb)SmsRead_R_OPT_mnu_cb);
2405 }
2406 mnuLang(data->menu,mainMmiLng);
2407
2408 /* put the (new) dialog window on top of the window stack */
2409 mnuUnhide(data->menu);
2410 winShow(win);
2411 break;
2412
2413 case E_BACK:
2414 l_parent = data->parent;
2415 l_id = data->id;
2416 SmsRead_R_OPT_destroy(data->win);
2417 SEND_EVENT (l_parent, E_RETURN, l_id, NULL); /* forward event to parent */
2418
2419 case E_ABORT:
2420 case E_EXIT:
2421 SmsRead_R_OPT_destroy(data->win);
2422 SEND_EVENT (l_parent, event, l_id, NULL); /* forward event to parent */
2423 break;
2424 default:
2425 return;
2426 }
2427 }
2428
2429 /*******************************************************************************
2430
2431 $Function: SmsRead_R_OPT_mfw_cb
2432
2433 $Description: Exec callback function for the DEL_ALL_ACK window
2434
2435 $Returns: status
2436
2437 $Arguments: event - window event Id
2438 parameter- optional data.
2439 *******************************************************************************/
2440
2441 int SmsRead_R_OPT_mfw_cb (MfwEvt event, void *parameter)
2442 {
2443 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
2444 T_MFW_WIN * win_data = (T_MFW_WIN *)((T_MFW_HDR *)win)->data;
2445 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
2446 // T_MFW_EVENT MfwEvents; // RAVI
2447
2448
2449 TRACE_FUNCTION ("SmsRead_R_OPT_mfw_cb()");
2450
2451 switch (event)
2452 {
2453
2454 case E_SMS_ERR:
2455
2456 winDelete(data->dialog_win);
2457
2458 /* Display "All SMS deleted" and after timeout go back to parent */
2459 SmsRead_R_OPT_StandardDialog(win, "SMS not deleted", THREE_SECS); // TBD remplacer par ID
2460
2461 break;
2462
2463 case E_SMS_OK:
2464
2465 /* go now back to the parent */
2466
2467 /* destroy the dialog at first */
2468 winDelete(data->dialog_win);
2469
2470 /* Display "All SMS deleted" and after timeout go back to parent */
2471 SmsRead_R_OPT_StandardDialog(win, "SMS deleted", THREE_SECS); // TBD remplacer par ID
2472 break;
2473 }
2474 return 1; // ADDED BY RAVI - 28-11-2005
2475 }
2476
2477 /*******************************************************************************
2478
2479 $Function: SmsRead_R_OPT_mnu_cb
2480
2481 $Description: Menu callback function for the Option window
2482
2483 $Returns: status
2484
2485 $Arguments: e - mfw event Id
2486 m - menu handle
2487 *******************************************************************************/
2488
2489 static int SmsRead_R_OPT_mnu_cb (MfwEvt e, MfwMnu *m)
2490 /* SmsRead_R_OPT menu event handler */
2491 {
2492 T_MFW_HND win = mfwParent(mfw_header());
2493 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2494 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
2495 T_MFW_HND * l_parent;
2496 SHORT l_id;
2497
2498 TRACE_FUNCTION ("SmsRead_R_OPT_mnu_cb()");
2499
2500 switch (e)
2501 {
2502 case E_MNU_ESCAPE: /* back to previous menu */
2503 l_parent = data->parent;
2504 l_id = data->id;
2505 SmsRead_R_OPT_destroy(data->win);
2506 SEND_EVENT (l_parent, E_RETURN, data->id, NULL);
2507 break;
2508 default: /* in mnuCreate() only E_MNU_ESCAPE has been enabled! */
2509 return MFW_EVENT_REJECTED;
2510 }
2511 return MFW_EVENT_CONSUMED;
2512 }
2513
2514 /*******************************************************************************
2515
2516 $Function: SmsRead_R_OPT_win_cb
2517
2518 $Description: Window callback function for the Option window
2519
2520 $Returns: status
2521
2522 $Arguments: e - mfw event Id
2523 w - window handler
2524 *******************************************************************************/
2525
2526 static int SmsRead_R_OPT_win_cb (MfwEvt e, MfwWin *w)
2527 /* SmsRead_R_OPT window event handler */
2528 {
2529 TRACE_FUNCTION ("SmsRead_R_OPT_win_cb()");
2530
2531 switch (e)
2532 {
2533 case MfwWinVisible: /* window is visible */
2534 displaySoftKeys(TxtSoftSelect,TxtSoftBack);
2535 break;
2536 case MfwWinFocussed: /* input focus / selected */
2537 case MfwWinDelete: /* window will be deleted */
2538 default:
2539 return MFW_EVENT_REJECTED;
2540 }
2541 return MFW_EVENT_CONSUMED;
2542 }
2543
2544 /*******************************************************************************
2545
2546 $Function: SmsRead_R_OPT_kbd_cb
2547
2548 $Description: Exec callback function for the Option window
2549
2550 $Returns: status
2551
2552 $Arguments: e - keyboard event Id
2553 k - keyboard data
2554 *******************************************************************************/
2555
2556 static int SmsRead_R_OPT_kbd_cb (MfwEvt e, MfwKbd *k)
2557 /* SmsRead_R_OPT keyboard event handler */
2558 {
2559 T_MFW_HND win = mfwParent(mfw_header());
2560 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2561 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
2562
2563 TRACE_FUNCTION ("SmsRead_R_OPT_kbd_cb()");
2564
2565 if (e & KEY_LONG)
2566 {
2567 switch (k->code)
2568 {
2569 case KCD_HUP: /* back to previous menu */
2570 mnuEscape(data->menu);
2571 break;
2572 case KCD_RIGHT: /* Power Down */
2573 return MFW_EVENT_REJECTED; /* handled by idle */
2574 default: /* no response to all other keys */
2575 return MFW_EVENT_CONSUMED;
2576 }
2577 }
2578 else
2579 {
2580 switch (k->code)
2581 {
2582 case KCD_MNUUP: /* highlight previous entry */
2583 mnuUp(data->menu);
2584 break;
2585 case KCD_MNUDOWN: /* highlight next entry */
2586 mnuDown(data->menu);
2587 break;
2588 case KCD_MNUSELECT:
2589 case KCD_LEFT: /* activate this entry */
2590 mnuSelect(data->menu);
2591 break;
2592 case KCD_HUP: /* back to previous menu */
2593 case KCD_RIGHT: /* back to previous menu */
2594 mnuEscape(data->menu);
2595 break;
2596 default: /* no response to all other keys */
2597 return MFW_EVENT_CONSUMED;
2598 }
2599 }
2600 return MFW_EVENT_CONSUMED;
2601 }
2602
2603 /*******************************************************************************
2604
2605 $Function: SmsRead_R_OPT_dialog_cb
2606
2607 $Description: Dialog callback function of the SMS read window (dynamic list
2608 of all the SMS). Case where SMS has not been initialized yet.
2609
2610 $Returns: status
2611
2612 $Arguments: win - window handler.
2613 Identifier - unique identifier.
2614 Reason - cause of event.
2615 *******************************************************************************/
2616
2617 int SmsRead_R_OPT_dialog_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
2618 {
2619 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
2620 T_SMSREAD_R_OPT *data = (T_SMSREAD_R_OPT *)win_data->user;
2621 T_MFW_HND *lparent = data->parent;
2622
2623 TRACE_FUNCTION ("SmsRead_dialog_cb()");
2624
2625 switch (Reason)
2626 {
2627 case INFO_TIMEOUT:
2628 case INFO_KCD_HUP:
2629 // Commit suicide
2630 SmsRead_R_OPT_destroy(win);
2631 // Send E_RETURN event to parent window
2632 SEND_EVENT(lparent, E_RETURN, data->id, NULL);
2633 return MFW_EVENT_CONSUMED;
2634
2635 default:
2636 return MFW_EVENT_REJECTED;
2637 }
2638 }
2639
2640 /*******************************************************************************
2641
2642 $Function: SmsRead_DisplayStandardDialog
2643
2644 $Description: Display a standard dialog with no soft key and 3 seconds of display
2645
2646 $Returns: none
2647
2648 $Arguments: win - window handler.
2649 text - text string.
2650 duration - seconds
2651 *******************************************************************************/
2652
2653 void SmsRead_DisplayStandardDialog(T_MFW_HND win, int TextId, ULONG duration)
2654 {
2655 T_DISPLAY_DATA DisplayInfo;
2656
2657 SmsMenu_loadDialogDefault(&DisplayInfo);
2658
2659 DisplayInfo.TextId = TextId;
2660 DisplayInfo.Time = duration;
2661 DisplayInfo.Callback = (T_VOID_FUNC)SmsRead_R_dialog_cb;
2662
2663 // Dec 15,2004 REF: CRR 24396 xkundadu
2664 // Description: Phone crashes when a message is received while the
2665 // 'List Empty' dialog is displayed.
2666
2667 // set the variable to TRUE since 'List empty' dialog is going to display.
2668 SmsListEmptyDlgPresent = TRUE;
2669 info_dialog(win, &DisplayInfo);
2670 }
2671
2672 /*******************************************************************************
2673
2674 $Function: SmsRead_R_OPT_StandardDialog
2675
2676 $Description: Display a standard dialog with no soft key and 3 seconds of display
2677
2678 $Returns: none
2679
2680 $Arguments: win - window handler.
2681 text - text string.
2682 duration - seconds
2683 *******************************************************************************/
2684
2685 void SmsRead_R_OPT_StandardDialog(T_MFW_HND win, char *text, ULONG duration)
2686 {
2687 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
2688 T_SMSREAD_R_OPT *data = (T_SMSREAD_R_OPT *)win_data->user;
2689
2690 T_DISPLAY_DATA DisplayInfo;
2691
2692 SmsMenu_loadDialogDefault(&DisplayInfo);
2693
2694 DisplayInfo.TextId = 0;
2695 DisplayInfo.Time = duration;
2696 DisplayInfo.TextString = text;
2697 DisplayInfo.Callback = (T_VOID_FUNC)SmsRead_R_OPT_dialog_cb; //TBD
2698
2699 data->dialog_win = info_dialog(win, &DisplayInfo);
2700 }
2701
2702
2703 /*SPR2175, removed unused function*/
2704
2705
2706 /*******************************************************************************
2707
2708 $Function: string_CopyW2W
2709
2710 $Description:
2711
2712 $Returns: none
2713
2714 $Arguments: strDestination - destination string
2715 strSource - source string
2716 count -number of character.
2717 *******************************************************************************/
2718
2719 void string_CopyW2W(wstring_t *strDestination, charw_t *strSource, USHORT count )
2720 // Copy characters of an ascii string to a wide counted string
2721 {
2722 charw_t *pout = strDestination;
2723 while(count!=0)
2724 {
2725 *pout++ = *strSource++;
2726 count--;
2727 }
2728 }
2729
2730 /*******************************************************************************
2731
2732 $Function: SmsRead_R_TEXTEDT2_start
2733
2734 $Description: Start the creation of the SMS editor window (display of the text
2735 of one SMS)
2736
2737 $Returns: win - window handler.
2738
2739 $Arguments: parent_window - current window handler
2740 data - Menu attributes.
2741
2742 *******************************************************************************/
2743
2744 T_MFW_HND SmsRead_R_TEXTEDT2_start(T_MFW_HND parent_window, MfwMnuAttr *data)
2745 {
2746 /*SPR 2132, use global var*/
2747 TRACE_FUNCTION ("SmsRead_R_TEXTEDT2_start()");
2748
2749 message_win = SmsRead_R_TEXTEDT2_create (parent_window);
2750
2751 if (message_win NEQ NULL)
2752 {
2753 SEND_EVENT (message_win, E_INIT, SmsRead_R_TEXTEDT2_ID, (void *)data);
2754 }
2755 return message_win;
2756 }
2757
2758 /*******************************************************************************
2759
2760 $Function: SmsRead_R_TEXTEDT2_create
2761
2762 $Description: Create the SMS editor window (display of the text of one SMS)
2763
2764 $Returns: window handler.
2765
2766 $Arguments: parent_window - current window handler
2767
2768 *******************************************************************************/
2769
2770 static T_MFW_HND SmsRead_R_TEXTEDT2_create(MfwHnd parent_window)
2771 {
2772 T_SMSREAD_R_TEXTEDT2 * data = (T_SMSREAD_R_TEXTEDT2 *)ALLOC_MEMORY (sizeof (T_SMSREAD_R_TEXTEDT2));
2773 T_MFW_WIN * win;
2774
2775 TRACE_FUNCTION ("SmsRead_R_TEXTEDT2_create()");
2776
2777 /*
2778 * Create window handler
2779 */
2780
2781 data->win =
2782 win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)SmsRead_R_TEXTEDT2_win_cb);
2783 if (data->win EQ NULL)
2784 {
2785 return NULL;
2786 }
2787 /*
2788 * connect the dialog data to the MFW-window
2789 */
2790
2791 data->mmi_control.dialog = (T_DIALOG_FUNC)SmsRead_R_TEXTEDT2_exec_cb;
2792 data->mmi_control.data = data;
2793 win = ((T_MFW_HDR *)data->win)->data;
2794 win->user = (void *)data;
2795 data->parent = parent_window;
2796
2797 /*
2798 * return window handle
2799 */
2800 winShow(data->win);
2801 return data->win;
2802 }
2803
2804 /*******************************************************************************
2805
2806 $Function: SmsRead_R_TEXTEDT2_destroy
2807
2808 $Description: Destroy the SMS editor window (display of the text of one SMS)
2809
2810 $Returns: none
2811
2812 $Arguments: own_window - current window handler
2813
2814 *******************************************************************************/
2815
2816 static void SmsRead_R_TEXTEDT2_destroy(MfwHnd own_window)
2817 {
2818 T_MFW_WIN * win_data;
2819 T_SMSREAD_R_TEXTEDT2 * data;
2820
2821 // USHORT i; // RAVI
2822
2823 TRACE_FUNCTION ("SmsRead_R_TEXTEDT2_destroy()");
2824
2825 if (own_window)
2826 {
2827 win_data = ((T_MFW_HDR *)own_window)->data;
2828 data = (T_SMSREAD_R_TEXTEDT2 *)win_data->user;
2829
2830 if (data)
2831 {
2832 /*
2833 * Delete WIN handler
2834 */
2835
2836 /* SPR#1428 - SH - New Editor changes */
2837 #ifdef NEW_EDITOR
2838 AUI_edit_Destroy(data->editor_win);
2839 #else /* NEW_EDITOR */
2840 editor_destroy(data->editor_win);
2841 #endif /* NEW_EDITOR */
2842
2843 win_delete (data->win);
2844
2845
2846
2847 FREE_MEMORY ((void *)data->sms_editor_data->sms_info, sizeof (T_MFW_SMS_PARA));
2848
2849 FREE_MEMORY ((void *)data, sizeof (T_SMSREAD_R_TEXTEDT2));
2850
2851 message_win = 0; /*SPR2132, make sure window pointer is reset*/
2852 }
2853 else
2854 {
2855 TRACE_EVENT ("SmsRead_R_TEXTEDT2_destroy() called twice");
2856 }
2857 }
2858 }
2859
2860 /*******************************************************************************
2861
2862 $Function: SmsRead_R_TEXT_editor_cb
2863
2864 $Description: Callback function for the text editor
2865
2866 $Returns: none
2867
2868 $Arguments: win - current window handler
2869 Identifier -Unique identifier.
2870 reason - event
2871 *******************************************************************************/
2872
2873 static void SmsRead_R_TEXT_editor_cb (T_MFW_HND win, USHORT Identifier, SHORT reason)
2874 {
2875 T_MFW_PHB_ENTRY pb_data;
2876
2877 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
2878 T_SMSREAD_R_TEXTEDT2 * data = (T_SMSREAD_R_TEXTEDT2 *)win_data->user;
2879
2880 T_MFW_HDR * parent = data->parent;
2881 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
2882 // T_SMSREAD_R_TEXTEDT2 * parent_data = (T_SMSREAD_R_TEXTEDT2 *)win_data2->user; // RAVI
2883
2884 // T_MFW_SMS_STAT sms_list_type = MFW_SMS_ALL; // RAVI
2885
2886
2887 TRACE_FUNCTION ("SmsRead_R_TEXT_editor_cb()");
2888
2889 switch (reason)
2890 {
2891 case INFO_KCD_LEFT:
2892 //x0pleela 08 Feb, 2006 DR: OMAPS00059261
2893 //Replacing MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
2894 //x0pleela 30 Jan, 2006 DR: OMAPS00059261
2895 //Displaying different options screen for normal MT text message.
2896 //whereas, for staus report message, the message is deleted, since the option is "Delete" in LSK
2897 if( data->sms_editor_data->sms_info->sms_mt.sms_msg_type EQ MFW_SMS_STATRPT)
2898 {
2899 if(sms_msg_delete((UBYTE)data->sms_editor_data->sms_info->sms_mt.index/*SPR 2686*/)== MFW_SMS_OK)
2900 {
2901 /* set the status that the user selected the delete item */
2902 if(deleting_win == 0)
2903 deleting_win= mmi_dialog_information_screen_forever(0,TxtPleaseWait, NULL, COLOUR_STATUS_WAIT);
2904
2905 SmsRead_R_TEXTEDT2_destroy(data->win);
2906 /*SPR 2530, Delete and recreate SMS list window to show updates*/
2907 { T_MFW_SMS_STAT sms_list_type = MFW_SMS_ALL;
2908
2909 listsDestroy(list_win);
2910 list_win=0;
2911 SmsRead_R_destroy(sms_read_win);
2912 SmsRead_R_start(NULL, (MfwMnuAttr*)&sms_list_type);
2913 }
2914
2915 }
2916 else
2917 {
2918
2919 /*SPR2530, don't delete option and display windows, just show failure*/
2920 mmi_dialog_information_screen(0,TxtFailed, NULL, NULL, COLOUR_STATUS_WAIT);
2921 }
2922 }
2923 //x0pleela 01 Feb, 2006 DR: OMAPS00059261
2924 //Made changes as per review comments
2925 else //MT_TEXT
2926 {
2927 // Present the user with an Options menu from the Read SMS text screen.:16/2/01
2928 SmsRead_R_READSMS_OPT_start(win, (MfwMnuAttr*)&data->sms_editor_data);
2929 }
2930
2931 break;
2932
2933 case INFO_KCD_RIGHT:
2934 case INFO_KCD_HUP:
2935 SmsRead_R_TEXTEDT2_destroy(data->win);
2936 /*SPR 2530, Delete and recreate SMS list window to show updates*/
2937 { T_MFW_SMS_STAT sms_list_type = MFW_SMS_ALL;
2938
2939 listsDestroy(list_win);
2940 list_win=0;
2941 SmsRead_R_destroy(sms_read_win);
2942 SmsRead_R_start(NULL, (MfwMnuAttr*)&sms_list_type);
2943 }
2944 break;
2945 case INFO_KCD_DOWN:
2946 break;
2947 case INFO_KCD_CALL:
2948 /* Marcus: Issue 1041: 05/09/2002: Start */
2949 strcpy((char *)pb_data.number, (char *)SmsData.NumberBuffer);
2950 /* Marcus: Issue 1041: 05/09/2002: End */
2951 TRACE_EVENT_P1("Number is = %d",(int)pb_data.number);
2952 callNumber(pb_data.number);
2953 break;
2954
2955
2956 default:
2957 TRACE_EVENT("Err: Default No match found");
2958 break;
2959 }
2960 }
2961
2962 /*******************************************************************************
2963
2964 $Function: SmsRead_R_TEXTEDT2_exec_cb
2965
2966 $Description: Exec callback function of the SMS editor window (display of the
2967 text of one SMS)
2968
2969 $Returns: none
2970
2971 $Arguments: win - current window handler
2972 event - event id
2973 value - unique id
2974 parameter - optional data.
2975 *******************************************************************************/
2976
2977 void SmsRead_R_TEXTEDT2_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
2978 /* callback handler for events sent to to trigger execution */
2979 {
2980 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
2981 T_SMSREAD_R_TEXTEDT2 * data = (T_SMSREAD_R_TEXTEDT2 *)win_data->user;
2982 T_MFW_HND * l_parent;
2983 SHORT l_id;
2984 T_MFW_SMS_MO *SmsMo;
2985 T_MFW_SMS_MT *SmsMt;
2986 T_MFW_SMS_CB *SmsCb;
2987
2988 /* SPR#1428 - SH - New Editor changes */
2989 #ifdef NEW_EDITOR
2990 T_AUI_EDITOR_DATA sms_editor_info;
2991 USHORT size;
2992 /*SPR 2530*/
2993 T_ATB_TEXT main_text;
2994 T_ATB_TEXT temp_text;
2995 // T_ATB_DCS atb_dcs; // RAVI
2996 #else /* NEW_EDITOR */
2997 T_EDITOR_DATA sms_editor_info;
2998 #endif /* NEW_EDITOR */
2999
3000 // USHORT i, line_ret, line_nb; // RAVI
3001 USHORT msg_len;
3002 // div_t result; // RAVI
3003 /* JVJ SPR 1298 - Memory optimization. Converted to dynamic and size decreased*/
3004 char* sms_text_buffer = (char*)ALLOC_MEMORY(MAX_EDITOR_HEADER_LENGTH);
3005 T_MFW_PHB_ENTRY pb_entry;
3006 USHORT index=0;
3007 T_MFW_SMS_IDX msg_info;/*SPR 2530*/
3008
3009 TRACE_FUNCTION ("SmsRead_R_TEXTEDT2_exec_cb()");
3010
3011 switch (event)
3012 {
3013 case E_INIT:
3014 { UBYTE input_type;/*MC SPR1242*/
3015 /* initialization of administrative data */
3016 data->id = value;
3017
3018 data->sms_editor_data = (T_SMS_EDITOR_DATA *)parameter;
3019
3020 switch (data->sms_editor_data->sms_type)
3021 {
3022 case MMI_SMS_MO:
3023
3024 /* where does we need that:
3025 For editor when the user wants to editing the sms-message
3026 */
3027 read_status = MMI_SMS_MO;
3028
3029 SmsMo = (T_MFW_SMS_MO *)data->sms_editor_data->sms_info;
3030
3031 sms_copy_idx(SmsMo->msg_ref, &msg_info);/*SPR 1830*/
3032 // API Clear the buffers before showing the MO message.
3033 memset (sms_text_ascii, '\0', MAX_EDITOR_LEN);
3034 memset (sms_text_buffer, '\0', MAX_EDITOR_HEADER_LENGTH);
3035 /*SPR 2530, if new ediotr use nice string-handling functions*/
3036 #ifdef NEW_EDITOR
3037 main_text.data = (UBYTE*)sms_text_ascii;
3038 /*if we are in chinese, then we need to display in Unicode, otherwise ASCII*/
3039 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3040 main_text.dcs = ATB_DCS_UNICODE;
3041 else
3042 main_text.dcs = ATB_DCS_ASCII;
3043 ATB_string_Length(&main_text);
3044 /*if this isn't an invalid message*/
3045 if (msg_info.stat != MFW_SMS_INVALID)
3046 { /*set text string dcs, according to alphabet used for message*/
3047 if ( (SmsMo->dcs & 0x0c) == MFW_DCS_UCS2 || SmsMo->sms_msg[0] == 0x80)
3048 {
3049 temp_text.dcs = ATB_DCS_UNICODE;
3050 /* CQ 16780 15-01-04 MZ */
3051 /*copy message text to string*/
3052 temp_text.data = (UBYTE*)SmsMo->sms_msg;
3053 }
3054 else
3055 {
3056 temp_text.dcs = ATB_DCS_ASCII;
3057 /* CQ: 16780 Convert to Ascii format 15-01-04 MZ */
3058 ATB_convert_String( SmsMo->sms_msg, MFW_DCS_8bits , SmsMo->msg_len,
3059 sms_text_ascii, MFW_ASCII, MAX_MSG_LEN, TRUE);
3060 /*copy message text to string*/
3061 temp_text.data = (UBYTE*)sms_text_ascii;
3062 }
3063
3064 ATB_string_Length(&temp_text);
3065 /*concat message text into display string*/
3066 ATB_string_Concat(&main_text, &temp_text);
3067 /*if this is an incomplete concat message, add "Incomplete Message" to end of display text*/
3068 if (msg_info.concat_status == MFW_SMS_CONC_PART)
3069 {
3070 ATB_string_SetChar(&main_text, ATB_string_Length(&main_text),(USHORT)":");
3071 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3072 temp_text.dcs = ATB_DCS_UNICODE;
3073 else
3074 temp_text.dcs = ATB_DCS_ASCII;
3075 temp_text.data = (UBYTE*)MmiRsrcGetText(TxtIncompleteMessage);
3076 ATB_string_Length(&temp_text);
3077 ATB_string_Concat(&main_text, &temp_text);
3078 }
3079
3080 }
3081 else
3082 {/*set display text to "Invalid Message"*/
3083 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3084 temp_text.dcs = ATB_DCS_UNICODE;
3085 else
3086 temp_text.dcs = ATB_DCS_ASCII;
3087 temp_text.data = (UBYTE*)MmiRsrcGetText(TxtInvalidMessage);
3088 ATB_string_Length(&temp_text);
3089 ATB_string_Concat(&main_text, &temp_text);
3090 }
3091 #else
3092
3093 /* SH - convert from original dcs once more */
3094
3095 /*MC,SPR1242 don't trust the DCS, check for Unicode tag*/
3096 if (SmsMo->sms_msg[0] == 0x80||SmsMo->dcs == MFW_DCS_UCS2)
3097 { input_type = MFW_DCS_UCS2;}
3098 else
3099 { input_type = MFW_DCS_8bits;}
3100
3101 /*mc end*/
3102 if (input_type == MFW_DCS_UCS2/*MC SPR1242*/)
3103 {/*SPR2175, use new function for conversion*/
3104
3105 ATB_convert_String( SmsMo->sms_msg, /*SmsMo->dcs*/input_type/*MC SPR1242*/, SmsMo->msg_len,
3106 &sms_text_ascii[2], MFW_DCS_UCS2, MAX_MSG_LEN-2, TRUE);
3107 sms_text_ascii[0] = 0x80;
3108 sms_text_ascii[1] = 0x7F;
3109 }
3110 else
3111 {/*SPR2175, use new function for conversion*/
3112
3113 ATB_convert_String( SmsMo->sms_msg, /*SmsMo->dcs*/input_type/*MC SPR1242*/ , SmsMo->msg_len,
3114 sms_text_ascii, MFW_ASCII, MAX_MSG_LEN, TRUE);
3115
3116 }
3117
3118 #endif
3119 break;
3120
3121 case MMI_SMS_MT:
3122 /* where does we need that:
3123 For editor when the user wants to editing the sms-message
3124 */
3125 read_status = MMI_SMS_MT;
3126
3127 SmsMt = (T_MFW_SMS_MT *)data->sms_editor_data->sms_info;
3128 sms_copy_idx(SmsMt->index, &msg_info);/*SPR 2530*/
3129 memset (sms_text_ascii, '\0', MAX_EDITOR_LEN);
3130 memset (sms_text_buffer, '\0',MAX_EDITOR_HEADER_LENGTH);
3131 /*SPR 2530, if new editor use nice string-handling functions*/
3132 #ifdef NEW_EDITOR
3133 main_text.data = (UBYTE*)sms_text_ascii;
3134 /*set up text data stucture for main display string*/
3135 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3136 main_text.dcs = ATB_DCS_UNICODE;
3137 else
3138 main_text.dcs = ATB_DCS_ASCII;
3139 ATB_string_Length(&main_text);
3140 #endif
3141 if (msg_info.stat != MFW_SMS_INVALID)/*SPR 1830*/
3142 {
3143
3144 /* Marcus: Issue 1041: 05/09/2002: Start */
3145 // API - Copy number into buffer so when Call key is pressed in editor call is generated
3146 strcpy((char *)SmsData.NumberBuffer,(char *)SmsMt->orig_addr.number);
3147 /* Marcus: Issue 1041: 05/09/2002: End */
3148
3149 /* Marcus: Issue 1489: 13/12/2002: Start */
3150 /*API - 1053 - 09-09-02 Copy the number into this buffer so that when
3151 a call is generated from the editor it is connected.
3152 */
3153 if(SmsMt->orig_addr.ton == MFW_TON_INTERNATIONAL)
3154 {
3155 if(SmsMt->orig_addr.number[0] == '+')
3156 {
3157 strcpy((char *)SmsData.NumberBuffer,(char *)SmsMt->orig_addr.number);
3158 }
3159 else
3160 {
3161 strcpy((char *)SmsData.NumberBuffer, "+");
3162 strncat((char *)SmsData.NumberBuffer,(char *)SmsMt->orig_addr.number,sizeof(SmsData.NumberBuffer)-2);
3163 }
3164 }
3165 #ifndef NEW_EDITOR
3166 /* add the number or the name if he can find it in the phonebook*/
3167 if (bookFindNameInPhonebook((const char*)SmsMt->orig_addr.number, &pb_entry) !=0)
3168 {
3169 #ifdef NO_ASCIIZ
3170 /*mc SPR 1257, unicode support*/
3171 memcpy(sms_text_ascii, (char*)pb_entry.name.data,pb_entry.name.len );
3172 #else
3173 strcpy(sms_text_ascii, (char*)pb_entry.name);
3174 #endif
3175 }
3176 else
3177 {
3178
3179 strcpy(sms_text_ascii, (char *)SmsData.NumberBuffer);
3180 /* Marcus: Issue 1489: 13/12/2002: End */
3181 }
3182 #else
3183 /*SPR 2530, if new editor use nice string-handling functions*/
3184 /*see if the sender is in the phonebook*/
3185 if (bookFindNameInPhonebook((const char*)SmsMt->orig_addr.number, &pb_entry) !=0)
3186 { char temp_string[PHB_MAX_LEN];
3187
3188 memset(temp_string, '\0', PHB_MAX_LEN);
3189 /*copy name into a text data structure*/
3190
3191 /* CQ: 16780 Check the phonebook string format by testing the dcs. NOT the dcs values are Enum types and not the true dcs
3192 values of the ADN store. 15-01-04 MZ */
3193 if (pb_entry.name.dcs == MFW_DCS_UCS2 ||pb_entry.name.data[0] == 0x80 )
3194 temp_text.dcs = ATB_DCS_UNICODE;
3195 else
3196 temp_text.dcs = ATB_DCS_ASCII;
3197
3198 if (temp_text.dcs != ATB_DCS_UNICODE)
3199 {
3200 temp_text.data = (UBYTE*)pb_entry.name.data;
3201 }
3202
3203 else
3204 {
3205 /* CQ:16780 Check for unicode string type 15-01-04 MZ*/
3206 if(pb_entry.name.data[0] == 0x80)
3207 {
3208 pb_entry.name.len-=2;
3209 memcpy(temp_string, &pb_entry.name.data[2], pb_entry.name.len);
3210 }
3211 else
3212 {
3213 memcpy(temp_string, &pb_entry.name.data[0], pb_entry.name.len);
3214 }
3215
3216 temp_text.data = (UBYTE*)temp_string;
3217
3218
3219 }
3220 ATB_string_Length(&temp_text);
3221 /*add name text into main display string*/
3222 ATB_string_Concat(&main_text, &temp_text);
3223
3224 }
3225 ATB_string_Length(&main_text);
3226
3227 #endif
3228 #ifndef NEW_EDITOR
3229 /* SH - convert from original dcs once more */
3230 /*MC,SPR1242 don't trust the DCS, check for Unicode tag*/
3231 if (SmsMt->sms_msg[0] == 0x80||SmsMt->dcs == MFW_DCS_UCS2)
3232 { input_type = MFW_DCS_UCS2;}
3233 else
3234 { input_type = MFW_DCS_8bits;}
3235
3236 /*mc end*/
3237 if (/*SmsMt->dcs*/input_type == MFW_DCS_UCS2)
3238 { /*SPR2175, use new function for conversion*/
3239 ATB_convert_String( SmsMt->sms_msg, input_type /*MC SPR1242*/, SmsMt->msg_len,
3240 &sms_text_ascii[2], MFW_DCS_UCS2, MAX_MSG_LEN-2, TRUE);
3241 sms_text_ascii[0] = 0x80;
3242 sms_text_ascii[1] = 0x7F;
3243 }
3244 else
3245 {
3246
3247 #endif
3248 if(strlen(sms_text_ascii) != 14 ) // number of character that can be displayed on one line.
3249 sms_text_buffer[index++]='\n';
3250
3251 sms_text_buffer[index++]='0'+SmsMt->sctp.day[0];
3252 sms_text_buffer[index++]='0'+SmsMt->sctp.day[1];
3253 sms_text_buffer[index++]='/';
3254 sms_text_buffer[index++]='0'+SmsMt->sctp.month[0];
3255 sms_text_buffer[index++]='0'+SmsMt->sctp.month[1];
3256 sms_text_buffer[index++]='/';
3257 sms_text_buffer[index++]='0'+SmsMt->sctp.year[0];
3258 sms_text_buffer[index++]='0'+SmsMt->sctp.year[1];
3259 sms_text_buffer[index++]=',';
3260 sms_text_buffer[index++]='\n';
3261
3262 sms_text_buffer[index++] ='0'+SmsMt->sctp.hour[0];
3263 sms_text_buffer[index++]='0'+SmsMt->sctp.hour[1];
3264 sms_text_buffer[index++]=':';
3265 sms_text_buffer[index++]='0'+SmsMt->sctp.minute[0];
3266 sms_text_buffer[index++]='0'+SmsMt->sctp.minute[1];
3267 sms_text_buffer[index++]='\n';
3268 #ifndef NEW_EDITOR
3269 strcat(sms_text_ascii, sms_text_buffer);
3270 msg_len = strlen(sms_text_ascii);
3271
3272 /*
3273 keep the length of the additional information (Date,Time & Number);
3274 need it later for editing the sms messages (user pressed-> EDIT)
3275 */
3276 current_sms_len = msg_len;
3277
3278 /* SH - convert from original dcs once more */
3279 /*SPR2175, use new function for conversion*/
3280 ATB_convert_String( SmsMt->sms_msg, /*SmsMt->dcs*/input_type /*MC SPR1242*/, SmsMt->msg_len,
3281 &sms_text_ascii[msg_len], MFW_ASCII /*SH*/, MAX_EDITOR_LEN-(msg_len+1), TRUE);
3282
3283 }
3284
3285 #else
3286 /*SPR 2530, if new editor use nice string-handling functions*/
3287 /*Add date and time to main display string*/
3288 temp_text.dcs = ATB_DCS_ASCII;
3289 temp_text.data = (UBYTE*)sms_text_buffer;
3290 ATB_string_Length(&temp_text);
3291 ATB_string_Concat(&main_text, &temp_text);
3292
3293
3294 if ((SmsMt->dcs&0x0c) == MFW_DCS_UCS2)
3295 {
3296 temp_text.dcs = ATB_DCS_UNICODE;
3297 temp_text.data = (UBYTE*)SmsMt->sms_msg;
3298 }
3299 else
3300 {
3301 temp_text.dcs = ATB_DCS_ASCII;
3302
3303 /* CQ 16780 Convert incoming SMS text to ASCIII 15-01-04 MZ */
3304
3305 ATB_convert_String( SmsMt->sms_msg, MFW_DCS_8bits , SmsMt->msg_len,
3306 (char*)temp_text.data, MFW_ASCII, MAX_MSG_LEN, TRUE);
3307 }
3308
3309 ATB_string_Length(&temp_text);
3310 ATB_string_Concat(&main_text, &temp_text);
3311 /*if the message is a fragment of a concat message*/
3312 if (msg_info.concat_status == MFW_SMS_CONC_PART)
3313 { ATB_string_SetChar(&main_text, ATB_string_Length(&main_text),(USHORT)":");
3314 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3315 temp_text.dcs = ATB_DCS_UNICODE;
3316 else
3317 temp_text.dcs = ATB_DCS_ASCII;
3318 /*append "Incomplete Message" onto display string*/
3319 temp_text.data = (UBYTE*)MmiRsrcGetText(TxtIncompleteMessage);
3320 ATB_string_Length(&temp_text);
3321 ATB_string_Concat(&main_text, &temp_text);
3322 }
3323 #endif
3324 }
3325 else
3326 #ifdef NEW_EDITOR
3327 /*SPR 2530, if new editor use nice string-handling functions*/
3328 { /*if invalid message just copy "Invalid message" into main display string*/
3329 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3330 temp_text.dcs = ATB_DCS_UNICODE;
3331 else
3332 temp_text.dcs = ATB_DCS_ASCII;
3333 temp_text.data = (UBYTE*)MmiRsrcGetText(TxtInvalidMessage);
3334 ATB_string_Length(&temp_text);
3335 ATB_string_Concat(&main_text, &temp_text);
3336 }
3337 #endif
3338 sms_change_read_status(SmsMt->index);
3339 break;
3340
3341 case MMI_SMS_CB:
3342
3343 SmsCb = (T_MFW_SMS_CB *)data->sms_editor_data->sms_info;
3344
3345 break;
3346
3347 }
3348
3349 /*
3350 Actually we have 2 different size of messages:
3351 1) SMS_MT with MAX_EDITOR_LEN because of the DATE,TIME,NUMBER
3352 2) SMS_MO with MAX_MSG_LEN, just the message itself
3353 */
3354
3355 /* SPR#1428 - SH - New Editor changes */
3356 #ifdef NEW_EDITOR
3357 AUI_edit_SetDefault(&sms_editor_info);
3358
3359 /* Include title for colour display */
3360 #ifdef COLOURDISPLAY
3361 AUI_edit_SetDisplay(&sms_editor_info, ZONE_FULL_SK_TITLE_SCROLL, COLOUR_EDITOR, EDITOR_FONT);
3362 #else /* COLOURDISPLAY */
3363 AUI_edit_SetDisplay(&sms_editor_info, ZONE_FULL_SK_SCROLL, COLOUR_EDITOR, EDITOR_FONT);
3364 #endif /* COLOURDISPLAY */
3365 AUI_edit_SetMode(&sms_editor_info, ED_MODE_ALPHA | ED_MODE_READONLY, ED_CURSOR_NONE);
3366 AUI_edit_SetEvents(&sms_editor_info, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)SmsRead_R_TEXT_editor_cb);
3367
3368 //x0pleela 08 Feb, 2006 DR: OMAPS00059261
3369 //Replacing MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
3370
3371 //x0pleela 01 Feb, 2006 DR: OMAPS00059261
3372 //Made changes as per review comments
3373
3374 //x0pleela 30 Jan, 2006 DR: OMAPS00059261
3375 //Displaying the LSK as "Delete" for MT Staus report and "Options" for normal MT Text message
3376 if (SmsMt->sms_msg_type EQ MFW_SMS_STATRPT)
3377 AUI_edit_SetTextStr(&sms_editor_info, TxtDelete, TxtSoftBack, TxtMessage, NULL);
3378 else
3379 AUI_edit_SetTextStr(&sms_editor_info, TxtSoftOptions, TxtSoftBack, TxtMessage, NULL);
3380
3381 /* Check if concatenated sms is activated */
3382
3383 if (read_status EQ MMI_SMS_MO)
3384 size = MAX_MSG_LEN;
3385 else
3386 size = MAX_EDITOR_LEN;
3387 /*SPR 2530, copy display screen to editor, alphabet depends on current lanaguage*/
3388 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
3389 {
3390 /* Unicode SMS message */
3391 AUI_edit_SetBuffer(&sms_editor_info, ATB_DCS_UNICODE, (UBYTE *)&sms_text_ascii[0],size/2);
3392 }
3393 else
3394 {
3395 /* ASCII SMS message */
3396 AUI_edit_SetBuffer(&sms_editor_info, ATB_DCS_ASCII, (UBYTE *)&sms_text_ascii[0],size);
3397 }
3398
3399 data->editor_win = AUI_edit_Start(win,&sms_editor_info); /* start the editor */
3400
3401 #else /* NEW_EDITOR */
3402
3403 SmsSend_loadEditDefault(&sms_editor_info);
3404 sms_editor_info.editor_attr.text = (char *)sms_text_ascii;
3405
3406 if (read_status EQ MMI_SMS_MO)
3407 sms_editor_info.editor_attr.size = MAX_MSG_LEN;
3408 else
3409 sms_editor_info.editor_attr.size = MAX_EDITOR_LEN;
3410 sms_editor_info.min_enter = 0;
3411
3412 //x0pleela 08 Feb, 2006 DR: OMAPS00059261
3413 //Replacing MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
3414
3415 //x0pleela 30 Jan, 2006 DR: OMAPS00059261
3416 //Displaying the LSK as "Delete" for MT Staus report and "Options" for normal MT Text message
3417 if (SmsMt->sms_msg_type EQ MFW_SMS_STATRPT )
3418 {
3419 sms_editor_info.LeftSoftKey = TxtDelete;
3420 sms_editor_info.AlternateLeftSoftKey = TxtDelete;
3421 }
3422 //x0pleela 01 Feb, 2006 DR: OMAPS00059261
3423 //Made changes as per review comments
3424 else //if( SmsMt->sms_msg_type EQ MT_TEXT )
3425 {
3426 sms_editor_info.LeftSoftKey = TxtSoftOptions;
3427 sms_editor_info.AlternateLeftSoftKey = TxtSoftOptions;
3428 }
3429 sms_editor_info.RightSoftKey = TxtSoftBack;
3430 sms_editor_info.Identifier = 0 ;
3431 sms_editor_info.destroyEditor = FALSE ;
3432 sms_editor_info.Callback = (T_EDIT_CB)SmsRead_R_TEXT_editor_cb;
3433 sms_editor_info.mode = READ_ONLY_MODE;
3434
3435 data->editor_win = editor_start(win,&sms_editor_info); /* start the editor */
3436 #endif /* NEW_EDITOR */
3437
3438
3439 if (info_win){
3440 SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
3441 info_win = 0;
3442 }
3443
3444
3445 break;
3446 }
3447 case E_BACK:
3448 l_parent = data->parent;
3449 l_id = data->id;
3450 /* The editor has sent an E_BACK event, we return to the previous window (E_RETURN) */
3451 SEND_EVENT (l_parent, E_RETURN, l_id, NULL);
3452 SmsRead_R_TEXTEDT2_destroy(data->win);
3453 break;
3454
3455 case E_ABORT:
3456 case E_EXIT:
3457 l_parent = data->parent;
3458 l_id = data->id;
3459 SEND_EVENT (l_parent, event, l_id, NULL); /* forward event to parent */
3460 SmsRead_R_TEXTEDT2_destroy(data->win);
3461 break;
3462
3463 default:
3464 break;
3465 }
3466
3467 FREE_MEMORY((void*)sms_text_buffer,MAX_EDITOR_HEADER_LENGTH);
3468 return;
3469 }
3470
3471 /*******************************************************************************
3472
3473 $Function: SmsRead_R_TEXTEDT2_win_cb
3474
3475 $Description: Window callback function of the SMS editor window (display of
3476 the text of one SMS).
3477
3478 $Returns: execution status
3479
3480 $Arguments: w - mfw window handle
3481 e - event id
3482 value - unique id
3483 parameter - optional data.
3484 *******************************************************************************/
3485
3486 static int SmsRead_R_TEXTEDT2_win_cb (MfwEvt e, MfwWin *w)
3487 /* window event handler */
3488 {
3489 TRACE_FUNCTION ("SmsRead_R_TEXTEDT2_win_cb()");
3490
3491 switch (e)
3492 {
3493 case MfwWinVisible: /* window is visible */
3494 //JVJE displaySoftKeys(TxtSoftSelect,TxtSoftBack);
3495 break;
3496 case MfwWinFocussed: /* input focus / selected */
3497 case MfwWinDelete: /* window will be deleted */
3498 default:
3499 return MFW_EVENT_REJECTED;
3500 }
3501 return MFW_EVENT_CONSUMED;
3502 }
3503
3504 /*******************************************************************************
3505
3506 $Function: SmsRead_R_TEXTEDT2_smslist_cb
3507
3508 $Description: Callback function of the SMS editor window (editor itself).
3509
3510 $Returns: none
3511
3512 $Arguments: Parent - parent window.
3513 ListData - Menu item list
3514 *******************************************************************************/
3515
3516 void SmsRead_R_TEXTEDT2_smslist_cb(T_MFW_HND * Parent, ListMenuData * ListData)
3517 {
3518 T_MFW_WIN * win_data = ((T_MFW_HDR *)Parent)->data;
3519 T_SMSREAD_R * data = (T_SMSREAD_R *)win_data->user;
3520
3521 T_MFW_HND * l_parent;
3522 SHORT l_id;
3523
3524 if ((ListData->Reason EQ LISTS_REASON_BACK) || (ListData->Reason EQ LISTS_REASON_CLEAR)
3525 || (ListData->Reason EQ LISTS_REASON_HANGUP))
3526 {
3527 l_parent = data->parent;
3528 l_id = data->id;
3529 SmsRead_R_destroy(data->win);
3530 //The editor has sent an back event, we return to the previous window (E_RETURN)
3531 SEND_EVENT (l_parent, E_RETURN, l_id, NULL);
3532 }
3533 }
3534
3535 /*******************************************************************************
3536
3537 $Function: check_assoc_name
3538
3539 $Description: This function search if a phone number corresponds to any name in phonebook
3540 or to the voice mailbox or to the SMS center
3541 BE CAREFUL it allocates memory for the name, that has to be freed by the caller
3542 It returns the length of the associated name if found, else length is 0 and name is NULL
3543
3544 $Returns: string length
3545
3546 $Arguments: name - string
3547 sms_addr - phonenumber string.
3548 *******************************************************************************/
3549
3550 UBYTE check_assoc_name(char *name, T_MFW_SMS_ADDR sms_addr)
3551 {
3552 // MZ T_MFW_SMS_STAT pb_entry;
3553 T_MFW_SMS_ADDR pb_entry;
3554 USHORT i;
3555
3556
3557
3558 // TBD: add international numbers management
3559
3560 // Voice, fax... mailboxes data
3561
3562 // USHORT max_rcd; // RAVI
3563 char mail_number[PHB_MAX_LEN + 1];
3564 char mail_alpha[10]; // size hard coded in pcm.h
3565 UBYTE nlen;
3566
3567 name = NULL;
3568
3569 // First: look in phonebook
3570
3571 if (bookFindNameInPhonebook((const char*)&sms_addr.number[0], (T_MFW_PHB_ENTRY*)&pb_entry))
3572 {
3573 // A name has been found
3574 if ((name = (char*)ALLOC_MEMORY(strlen(pb_entry.tag) + 1)) != NULL)
3575 {
3576 /*Mc , unicode support*/
3577 #ifdef NO_ASCIIZ
3578 memcpy(name, pb_entry.tag, pb_entry.len);
3579 return pb_entry.len;
3580 #else
3581 strcpy(name, pb_entry.tag);
3582 return strlen(name);
3583 #endif
3584 }
3585 }
3586
3587 // Then the different mailboxes (voice, fax, data...)
3588 for (i = MFW_MB_LINE1; i <= MFW_MB_DATA; i++)
3589 {
3590
3591 {
3592 cmhPHB_getAdrStr(mail_number, PHB_MAX_LEN - 1, FFS_flashData.mbn_Num, FFS_flashData.mbn_len);
3593
3594 if (strcmp(sms_addr.number, mail_number) EQ 0)
3595 {
3596 // If the same number then we get the alpha identifier
3597 cmhPHB_getMfwTagNt ( FFS_flashData.mbn_AlphId, 10, (UBYTE*)mail_alpha, &nlen );
3598 mail_alpha[nlen] = '\0';
3599
3600 if ((name = (char*)ALLOC_MEMORY(strlen(mail_alpha) + 1)) != NULL)
3601 {
3602 /*MC, yet more unicode support*/
3603 #ifdef NO_ASCIIZ
3604 memcpy(name, mail_alpha, nlen);
3605 return nlen;
3606 #else
3607 strcpy(name, mail_alpha);
3608 return strlen(name);
3609 #endif
3610 }
3611 }
3612 }
3613 }
3614 return 1; // RAVI
3615 }
3616
3617 /*******************************************************************************
3618
3619 $Function: SmsRead_R_TEXTEDT2_editor_cb
3620
3621 $Description: Callback function for the text editor.
3622
3623 $Returns: void
3624
3625 $Arguments: win - current window.
3626 Identifier - unique id
3627 Reason - event id
3628 *******************************************************************************/
3629
3630 void SmsRead_R_TEXTEDT2_editor_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
3631 {
3632
3633 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
3634 T_SMSREAD_R_TEXTEDT2 * data = (T_SMSREAD_R_TEXTEDT2 *)win_data->user;
3635
3636 TRACE_FUNCTION("SmsRead_R_TEXTEDT2_editor_cb");
3637 switch (Reason)
3638 {
3639 case INFO_KCD_LEFT:
3640 case INFO_KCD_RIGHT:
3641 case INFO_KCD_HUP:
3642 SEND_EVENT (data->parent, E_RETURN, Identifier, NULL); /* forward event to parent */
3643 break;
3644 default:
3645 break;
3646 }
3647 }
3648
3649 /*******************************************************************************
3650
3651 $Function: SmsRead_FindNextNumber_cb
3652
3653 $Description: Exec callback function for searching the SMS text message.
3654
3655 $Returns: none
3656
3657 $Arguments: win - window handler
3658 event - mfw event
3659 value -optional id
3660 parameter - optional data.
3661
3662 *******************************************************************************/
3663 void SmsRead_FindNextNumber_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
3664 {
3665
3666 T_MFW_PHB_ENTRY pb_data;
3667
3668 switch (Reason)
3669 {
3670 case INFO_KCD_RIGHT:
3671 case INFO_KCD_CLEAR:
3672
3673 break;
3674 case INFO_KCD_LEFT:
3675
3676 // Check for numbers in SMS text, check for '+' .
3677
3678 if(Search_forNextNumber(&SmsData))
3679 {
3680
3681 if (bookFindNameInPhonebook((const char*)&SmsData.NumberBuffer[0], &pb_data) )
3682 {
3683 //Display the tag and number dialog.
3684 #ifdef NO_ASCIIZ
3685 /* SPR888 - SH - parent_data->parent changed to win */
3686 smsRead_NumberName_info_screen(win,(void *)&SmsData, (char*)pb_data.name.data);
3687 #else
3688 /* SPR888 - SH - parent_data->parent changed to win */
3689 smsRead_NumberName_info_screen(win,(void *)&SmsData, (char*)pb_data.name);
3690 #endif
3691 }
3692 else
3693 {
3694 /* SPR888 - SH - parent_data->parent changed to win */
3695 smsRead_NumberName_info_screen(win,(void *)&SmsData,NULL);
3696 }
3697 }
3698 break;
3699 case INFO_KCD_OFFHOOK:
3700 callNumber(SmsData.NumberBuffer);
3701 break;
3702
3703 default:
3704 TRACE_EVENT(" >>> INFO Default ");
3705 //return MFW_EVENT_REJECTED;
3706 break;
3707 }
3708
3709 }
3710
3711 /*******************************************************************************
3712
3713 $Function: smsRead_NumberName_info_screen
3714
3715 $Description: Display the number and name of numbers found in the received SMS text.
3716
3717 $Returns: window handle
3718
3719 $Arguments: win - current window.
3720 UserData - Sms data info
3721 *******************************************************************************/
3722
3723 static MfwHnd smsRead_NumberName_info_screen(MfwHnd win,T_SmsUserData *UserData, char* nameTag)
3724 {
3725
3726 T_DISPLAY_DATA DisplayInfo;
3727 TRACE_FUNCTION("smsRead_NumberName_info_screen() ");
3728
3729 dlg_initDisplayData_TextStr( &DisplayInfo, TxtSoftNext, TxtSoftBack, nameTag, (char*)UserData->NumberBuffer, COLOUR_STATUS);
3730 dlg_initDisplayData_events( &DisplayInfo, (T_VOID_FUNC)SmsRead_FindNextNumber_cb, FOREVER, KEY_ALL );
3731
3732 TRACE_EVENT(">>>>> Display Information Screen ");
3733 return info_dialog(win, &DisplayInfo);
3734
3735 }
3736
3737 /*******************************************************************************
3738
3739 $Function: Search_forNextNumber
3740
3741 $Description: Search through the SMS text and find a telephone number, the number
3742 may start with the '+' prefix.
3743
3744 $Returns: Boolean
3745
3746 $Arguments: UserData - SMS data info
3747 *******************************************************************************/
3748 static BOOL Search_forNextNumber(T_SmsUserData *UserData)
3749 {
3750 /* SPR888 - SH - Rewritten, old function below */
3751 /* Use search_index so we can start looking where we left off last time.
3752 Set to 0 in SMSRead_R_OPTExeStoreNumber */
3753
3754 int sms_length;
3755 int number_index;
3756 char number_buffer[NUMBER_LENGTH*2+4];
3757 char *sms_buffer;
3758 char character;
3759 UBYTE found_status;
3760
3761 TRACE_FUNCTION("Search_forNextNumber()");
3762 sms_buffer = (char*)UserData->TextBuffer;
3763 #ifdef NO_ASCIIZ
3764 if (sms_buffer[0] == 0x80)
3765 {
3766 #ifdef NEW_EDITOR /* SPR#1428 - SH - New Editor changes - new function to calculate length of unicode string */
3767 sms_length = ATB_string_UCLength((U16*)sms_buffer)*sizeof(USHORT);
3768 #else /* NEW_EDITOR */
3769 sms_length = strlenUnicode((U16*)sms_buffer);
3770 #endif /* NEW_EDITOR */
3771 }
3772 else
3773 {
3774 sms_length = strlen(sms_buffer);
3775 }
3776 #else /* NO_ASCIIZ */
3777 sms_length = strlen(sms_buffer);
3778 #endif /* NO_ASCIIZ */
3779
3780 number_index = 0;
3781 found_status = 0;
3782
3783 memset (number_buffer, '\0', NUMBER_LENGTH*2+4);
3784
3785
3786 while (search_index<sms_length && found_status<2 && number_index<NUMBER_LENGTH*2+4)
3787 {
3788 character = sms_buffer[search_index];
3789
3790 search_index++;
3791 #ifdef NO_ASCIIZ
3792 if (character=='+' || ( character>='0' && character<='9' ) || (character==0))
3793 #else
3794 if (character=='+' || ( character>='0' && character<='9' ) )
3795 #endif
3796 { if (character != 0) /*MC, only copy non-Null chars*/
3797 number_buffer[number_index++] = character;
3798 if (found_status==0)
3799 {
3800 found_status = 1; /* Found start of number */
3801 }
3802 }
3803 else
3804 {
3805 if (found_status==1)
3806 found_status = 2; /* Have reached end of number */
3807 }
3808 TRACE_EVENT_P1("Extract number string:%s", number_buffer);
3809 }
3810
3811 if(strlen(number_buffer) > 10)
3812
3813 {
3814
3815 memcpy((char*)UserData->NumberBuffer, number_buffer, sizeof(UserData->NumberBuffer));
3816 return TRUE;
3817 }
3818
3819 return FALSE;
3820 }
3821
3822
3823 /* api Store number for calling when reading SMS - 04/03/2002
3824 */
3825
3826 /*******************************************************************************
3827
3828 $Function: Search_forNextNumber
3829
3830 $Description: Search through the SMS text and find a telephone number, the number
3831 may start with the '+' prefix.
3832
3833 $Returns: Boolean
3834
3835 $Arguments: UserData - SMS data info
3836 *******************************************************************************/
3837 void SmsRead_StoreNumber(void)
3838 {
3839 T_MFW_HND win = mfwParent(mfw_header());
3840 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
3841 T_SMSREAD_R_OPT * data = (T_SMSREAD_R_OPT *)win_data->user;
3842
3843 T_MFW_HDR * parent = data->parent;
3844 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
3845 T_SMSREAD_R_TEXTEDT2 * parent_data = (T_SMSREAD_R_TEXTEDT2 *)win_data2->user;
3846 T_MFW_PHB_ENTRY pb_data;
3847
3848 TRACE_FUNCTION("SmsRead_StoreNumber");
3849
3850 TRACE_EVENT_P1("TON = %d",parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.ton);
3851 /* Marcus: Issue 1489: 13/12/2002: Start */
3852 if(parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.ton == MFW_TON_INTERNATIONAL)
3853 {
3854 if(parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number[0] == '+')
3855 {
3856 strcpy((char *)SmsData.NumberBuffer,(char *)parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number);
3857 }
3858 else
3859 {
3860 strcpy((char *)SmsData.NumberBuffer,"+");
3861 strncat((char *)SmsData.NumberBuffer,(char *)parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number,sizeof(SmsData.NumberBuffer)-2);
3862 }
3863 }
3864 else
3865 {
3866
3867 TRACE_EVENT_P1("Number = %s",parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number);
3868 strcpy((char *)SmsData.NumberBuffer,(char *)parent_data->sms_editor_data->sms_info->sms_mt.orig_addr.number);
3869 }
3870 /* Marcus: Issue 1489: 13/12/2002: End */
3871 /*MC, unicode support*/
3872 memcpy((char*)pb_data.number, (char*)SmsData.NumberBuffer, sizeof(pb_data.number));
3873
3874
3875 SmsRead_R_TEXTEDT2_destroy(message_win);
3876 /* Destroy the Options Menu and text editor.before starting the Send Editor.*/
3877 SmsRead_R_OPT_destroy(option_mnu_win);
3878
3879 /*SPR 2686 destroy the SMS read window to free memory*/
3880 /*destroy the built list window*/
3881 listsDestroy(list_win);
3882 list_win=0;
3883 /*destroy the main control window*/
3884 if (sms_read_win)/*check window exists before destroying it*/
3885 {
3886 SmsRead_R_destroy(sms_read_win);
3887 sms_read_win = NULL;
3888 }
3889
3890 callNumber(pb_data.number);
3891
3892 }
3893
3894 //x0035544 Mar 23, 2006 DR:OMAPS00047813
3895 /*******************************************************************************
3896
3897 $Function: Search_forNumberInSMS
3898
3899 $Description: Search through the SMS text and find the numbers
3900
3901 $Returns: void
3902
3903 $Arguments: UserData - SMS data info
3904 *******************************************************************************/
3905 void Search_forNumberInSMS(T_SmsUserData *UserData)
3906 {
3907 int num_row, num_col, i;
3908 int len, sms_length = 0;
3909 char character;
3910 char *sms_buffer, *sender_num;
3911 BOOL mesg_end=FALSE;
3912
3913 TRACE_FUNCTION("Search_forNumberInSMS()");
3914
3915 sms_buffer = (char*)UserData->TextBuffer;
3916 sender_num = (char*)UserData->NumberBuffer;
3917
3918 #ifdef NO_ASCIIZ
3919 if (sms_buffer[0] == 0x80)
3920 {
3921 #ifdef NEW_EDITOR /* SPR#1428 - SH - New Editor changes - new function to calculate length of unicode string */
3922 sms_length = ATB_string_UCLength((U16*)sms_buffer)*sizeof(USHORT);
3923 #else /* NEW_EDITOR */
3924 sms_length = strlenUnicode((U16*)sms_buffer);
3925 #endif /* NEW_EDITOR */
3926 }
3927 else
3928 {
3929 sms_length = strlen(sms_buffer);
3930 }
3931 #else /* NO_ASCIIZ */
3932 sms_length = strlen(sms_buffer);
3933 #endif /* NO_ASCIIZ */
3934 sms_length--;
3935 len= num_row=num_col=0;
3936 smsread_num_ctr =0;
3937 num_buffer = (char**)ALLOC_MEMORY(sizeof(char*)*MAX_NUMBER_SIZE);
3938 if (num_buffer == NULL)
3939 {
3940 TRACE_EVENT("sms number list alloc failed");
3941 return;
3942 }
3943
3944 for(i=0; i<MAX_NUMBER_SIZE; i++)
3945 num_buffer[i] = (char*)ALLOC_MEMORY(sizeof(char)*NUMBER_LENGTH);
3946 if (num_buffer[i] == NULL)
3947 {
3948 TRACE_EVENT(" sms number string alloc failed");
3949 return;
3950 }
3951
3952
3953 while (len <= sms_length)
3954 {
3955 character = sms_buffer[len];
3956
3957 if(len == sms_length)
3958 {
3959 mesg_end = TRUE;
3960 }
3961
3962 #ifdef NO_ASCIIZ
3963 if (character=='+' || ( character>='0' && character<='9' ) || (character==0))
3964 #else
3965 if (character=='+' || ( character>='0' && character<='9' ) )
3966 #endif
3967 {
3968 if (character != 0) /*MC, only copy non-Null chars*/
3969 {
3970 if(num_col <= NUMBER_LENGTH)
3971 {
3972 num_buffer[num_row][num_col] = character;
3973 num_col++;
3974 }
3975 if(mesg_end && (strlen(num_buffer[num_row]) >= MIN_NUM_LENGTH))//copy if number is at end of the message
3976 {
3977 smsread_num_ctr++;
3978 num_row++;
3979 }
3980 }
3981 }
3982 else
3983 {
3984 if(num_col != 0 )
3985 {
3986 num_buffer[num_row][num_col] = '\0';
3987 if(strlen(num_buffer[num_row]) < MIN_NUM_LENGTH )
3988 {
3989 num_col=0;
3990 }
3991 else
3992 {
3993 smsread_num_ctr++;
3994 num_row++;
3995 if( num_row >= MAX_NUMBER_SIZE)
3996 break;
3997 num_col = 0;
3998 }
3999 }
4000 }
4001 len++;
4002 }
4003
4004 if( num_row < 10 )//copy the sender number
4005 {
4006 memcpy((char*)num_buffer[num_row], (char*)sender_num, NUMBER_LENGTH);
4007 smsread_num_ctr++;
4008 }
4009
4010 return ;
4011 }
4012
4013 //Mar 23, 2006 DR:OMAPS00047813 x0035544
4014 /*******************************************************************************
4015
4016 $Function: smsread_numlist_win_cb
4017
4018 $Description: Window event handler
4019
4020 $Returns: MFW_EVENT_REJECTED:
4021 MFW_EVENT_CONSUMED:
4022
4023 $Arguments:
4024
4025 *******************************************************************************/
4026 static int smsread_numlist_win_cb (MfwEvt e, MfwWin *w)
4027 {
4028 TRACE_FUNCTION ("smsread_numlist_win_cb()");
4029 switch (e)
4030 {
4031 case MfwWinVisible: /* window is visible */
4032 break;
4033 case MfwWinFocussed: /* input focus / selected */
4034 case MfwWinDelete: /* window will be deleted */
4035
4036 default:
4037 return MFW_EVENT_REJECTED;
4038 }
4039 return MFW_EVENT_CONSUMED;
4040 }
4041
4042 //Mar 23, 2006 DR:OMAPS00047813 x0035544
4043 /*******************************************************************************
4044
4045 $Function: SmsRead_BuildNumList_Menu
4046
4047 $Description: creates dynamic menu
4048
4049 $Returns:
4050
4051 $Arguments:
4052
4053 *******************************************************************************/
4054 static T_MFW_HND SmsRead_BuildNumList_Menu(T_MFW_HND parent_window)
4055 {
4056 T_SMSREAD_R * data = (T_SMSREAD_R *)mfwAlloc(sizeof (T_SMSREAD_R));
4057 T_MFW_WIN * win;
4058
4059 TRACE_FUNCTION ("SmsRead_BuildNumList_Menu");
4060
4061 /*
4062 * Create window handler
4063 */
4064
4065 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)smsread_numlist_win_cb);
4066 if (data->win EQ NULL)
4067 {
4068 FREE_MEMORY( (void *)data, sizeof( T_SMSREAD_R ) );
4069 return NULL;
4070 }
4071
4072 TRACE_EVENT("list holder window created: " );
4073 /*
4074 * connect the dialog data to the MFW-window
4075 */
4076
4077 data->mmi_control.dialog = (T_DIALOG_FUNC)smsread_numlist_exec_cb;
4078 data->mmi_control.data = data;
4079 win = ((T_MFW_HDR *)data->win)->data;
4080 win->user = (void *)data;
4081 data->parent = parent_window;
4082 winShow(data->win);
4083 /*
4084 * return window handle
4085 */
4086
4087 return data->win;
4088 }
4089
4090 //Mar 23, 2006 DR:OMAPS00047813 x0035544
4091 /*******************************************************************************
4092
4093 $Function: smsread_numlist_exec_cb
4094
4095 $Description: callback function
4096
4097 $Returns:
4098
4099 $Arguments:
4100
4101 *******************************************************************************/
4102 void smsread_numlist_exec_cb (T_MFW_HND win, USHORT event)
4103 {
4104 T_MFW_WIN * win_data;
4105 T_SMSREAD_R * data;
4106
4107 /* List is complete so present menu. */
4108 USHORT i;
4109
4110 TRACE_FUNCTION("smsread_numlist_exec_cb");
4111
4112
4113 win_data = ((T_MFW_HDR *) win)->data;
4114 data = (T_SMSREAD_R *)win_data->user;
4115
4116 switch (event)
4117 {
4118 case E_INIT:
4119 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData));
4120
4121 if(data->menu_list_data == 0)
4122 {
4123 TRACE_EVENT("Failed memory alloc 1 ");
4124 return;
4125 }
4126 /*SPR 2686, only allocate memory for the number of messages displayed*/
4127 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( smsread_num_ctr * sizeof(T_MFW_MNU_ITEM) );//JVJE
4128
4129 if(data->menu_list_data->List == 0)
4130 {
4131 TRACE_EVENT("Failed memory alloc 2");
4132 return;
4133 }
4134
4135 for (i = 0; i < smsread_num_ctr; i++)
4136 {
4137 mnuInitDataItem(&data->menu_list_data->List[i]);
4138 data->menu_list_data->List[i].str = (char *)num_buffer[i];
4139 TRACE_EVENT_P1("Menu Tags:%s", data->menu_list_data->List[i].str);
4140 data->menu_list_data->List[i].flagFunc = item_flag_none;
4141 }
4142
4143 data->menu_list_data->ListLength =smsread_num_ctr;
4144 data->menu_list_data->ListPosition = 1;
4145 data->menu_list_data->CursorPosition = 1;
4146 data->menu_list_data->SnapshotSize =smsread_num_ctr;
4147 data->menu_list_data->Font = 0;
4148 data->menu_list_data->LeftSoftKey = TxtSoftSelect;
4149 /*NM p032*/
4150 if(test_sim EQ TRUE)
4151 data->menu_list_data->RightSoftKey = TxtNull;
4152 else
4153 data->menu_list_data->RightSoftKey = TxtSoftBack;
4154
4155 data->menu_list_data->KeyEvents = KEY_ALL;
4156 data->menu_list_data->Reason = 0;
4157 data->menu_list_data->Strings = TRUE;
4158 data->menu_list_data->Attr = (MfwMnuAttr*)&menuSearchNumListAttr;
4159 data->menu_list_data->autoDestroy = FALSE;
4160
4161 /* Create the dynamic menu window */
4162 listDisplayListMenu(win, data->menu_list_data, (ListCbFunc_t)SmsRead_numlist_cb ,0);
4163 break;
4164 default:
4165 break;
4166 }
4167
4168 }
4169
4170 //Mar 23, 2006 DR:OMAPS00047813 x0035544
4171 /*******************************************************************************
4172
4173 $Function: SmsRead_numlist_cb
4174
4175 $Description: destroy lists and menu in case of back softkey or menu exit
4176
4177 $Returns:
4178
4179 $Arguments:
4180
4181 *******************************************************************************/
4182 static void SmsRead_numlist_cb(T_MFW_HND Parent, ListMenuData * ListData)
4183 {
4184 T_MFW_WIN *win_data = ((T_MFW_HDR *)Parent)->data;
4185 T_SMSREAD_R *data = (T_SMSREAD_R *)win_data->user;
4186 char *pb_number;
4187 int i;
4188
4189 TRACE_FUNCTION ("SmsRead_numlist_cb()");
4190
4191
4192 if ((ListData->Reason EQ LISTS_REASON_BACK) ||
4193 (ListData->Reason EQ LISTS_REASON_CLEAR) ||
4194 (ListData->Reason EQ LISTS_REASON_HANGUP))
4195 {
4196 /*
4197 ** Destroy the window --- Not sure if this is required! ... leave it out for now
4198 */
4199 listsDestroy(ListData->win);
4200
4201 /*
4202 ** Free the memory set aside for ALL the devices to be listed.
4203 */
4204 for(i=0; i<MAX_NUMBER_SIZE;i++)
4205 {
4206 FREE_MEMORY((U8*)num_buffer[i], sizeof(char)*NUMBER_LENGTH);
4207 num_buffer[i] = NULL;
4208 }
4209
4210 /*deallocate memory for the array of pointer to numbers*/
4211 FREE_MEMORY((U8*)num_buffer, sizeof(char*)*MAX_NUMBER_SIZE);
4212
4213 if (data->menu_list_data->List != NULL)
4214 {
4215 FREE_MEMORY ((void *)data->menu_list_data->List, (U16)((data->menu_list_data->ListLength) *
4216 sizeof(T_MFW_MNU_ITEM)));
4217 }
4218 if (data->menu_list_data != NULL)
4219 {
4220 FREE_MEMORY ((void *)data->menu_list_data, sizeof (ListMenuData));
4221 }
4222
4223 SmsRead_numlist_destroy(data->win);
4224
4225
4226
4227 }
4228
4229 else if(ListData->Reason EQ LISTS_REASON_SELECT)
4230 {
4231 pb_number = ListData->List[ListData->ListPosition].str;
4232 callNumber((UBYTE*)pb_number);
4233
4234 }
4235
4236 return;
4237 }
4238
4239 //Mar 23, 2006 DR:OMAPS00047813 x0035544
4240 /*******************************************************************************
4241
4242 $Function: SmsRead_numlist_destroy
4243
4244 $Description: Destroy the Extr Number window.
4245
4246 $Returns: none
4247
4248 $Arguments: own_window - window handler
4249
4250 *******************************************************************************/
4251
4252 static void SmsRead_numlist_destroy(MfwHnd own_window)
4253 {
4254 T_MFW_WIN * win_data = ((T_MFW_HDR *)own_window)->data;
4255 T_SMSREAD_R * data = (T_SMSREAD_R *)win_data->user;
4256
4257 TRACE_FUNCTION ("SmsRead_numlist_destroy");
4258
4259 if (own_window == NULL)
4260 {
4261 return;
4262 }
4263
4264 if (data)
4265 {
4266 win_delete(data->win);
4267
4268 /*
4269 ** Free Memory
4270 */
4271 mfwFree((void *)data, sizeof (T_SMSREAD_R));
4272 }
4273 }
4274 #undef MMI_SMSREAD_C