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

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