comparison g23m/condat/ms/src/bmi/mmiSmsIdle.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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: MmiSmsIdle.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description: Implementation for MMI smsidle unsolicited event handling
24
25
26
27 ********************************************************************************
28
29 $History: MmiSmsIdle.c
30
31 25/10/00 Original Condat(UK) BMI version.
32
33 Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
34 Description: Mp3 Ringer Implementation
35 Solution: The Midi Ringer application has been enhanced to support mp3 as ringer.
36 The interface function names have been modified.
37
38 May 27, 2005 MMI-FIX-29869 x0018858
39 Description: There is a limitation on the number of messages that can be downloaded from
40 server even though there is space on the sim.
41 Solution: The limitation has been removed and the number of messages that can be dowloaded
42 has been modified to the maximum number that can be stored.
43
44 Jun 14, 2005 REF: MMI-FIX-30439 x0018858
45 Description: The homezone/cityzone tags were not being displayed properly.
46 Solution: Modified to save the tags properly in caches and also made the
47 appropriate modifications to update the same properly during mobility.
48
49 Apr 05, 2005 REF: ENH 29994 xdeepadh
50 Description: Implementation of Generic Midi Ringer and Modification of existing Midi Test Application
51 Solution: Generic Midi Ringer and Midi Test Application were implemented.
52
53 x0018858 24 Mar, 2005 MMI-FIX-11321
54 Issue Description :- If the inbox is full and a new message is receivd, no indication is received.
55 Fix: Added support for handling indication when message box is full and
56 there is a pending message.
57
58 Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
59 Issue description: BMI: using the tool nowSMS the voicemail indication via sms does not work
60 Solution: Instead of identifying voice using addr[0] and pid, we use dcs. Also, messages belonging
61 to group "1100" are deleted when voicemail icon is displayed.
62
63 Apr 27, 2004 REF: CRR 21336 Deepa M.D
64 Bug:SMSMT UCS2 Class0 message content not displayed.
65 Fix:The alphabet bits(UCS2) of DCS were not decoded properly.
66
67 $End
68
69 *******************************************************************************/
70
71 #define ENTITY_MFW
72
73 /* includes */
74 #include <string.h>
75 #include <stdio.h>
76 #include <stdlib.h>
77
78 #if defined (NEW_FRAME)
79
80 #include "typedefs.h"
81 #include "vsi.h"
82 #include "pei.h"
83 #include "custom.h"
84 #include "gsm.h"
85
86 #else
87
88 #include "STDDEFS.H"
89 #include "custom.h"
90 #include "gsm.h"
91 #include "vsi.h"
92
93 #endif
94 #include "prim.h"
95
96
97 #include "mfw_sys.h"
98
99 #include "mfw_mfw.h"
100 #include "mfw_win.h"
101 #include "mfw_kbd.h"
102 /* SPR#1428 - SH - New Editor changes */
103 #ifndef NEW_EDITOR
104 #include "mfw_edt.h"
105 #endif
106 #include "mfw_lng.h"
107 #include "mfw_icn.h"
108 #include "mfw_phb.h"
109 #include "mfw_sim.h"
110 #include "mfw_nm.h"
111
112 #include "ksd.h"
113 #include "psa.h"
114 #include "mfw_sms.h"
115 #include "mfw_smsi.h"
116 #include "mfw_mnu.h"
117 #include "mfw_sat.h"
118 #include "mfw_tim.h"
119 #include "mfw_mme.h"
120
121 #include "dspl.h"
122
123 #include "MmiMmi.h"
124 #include "MmiDummy.h"
125 #include "MmiDialogs.h"
126 #include "MmiLists.h"
127
128 #include "MmiMain.h"
129 #include "MmiStart.h"
130 #include "MmiPins.h"
131 #include "MmiMenu.h"
132 #include "MmiSoftKeys.h"
133 #include "MmiSounds.h"
134 #include "mmiCall.h"
135
136 #include "MmiBookController.h"
137
138
139 #include "MmiIdle.h"
140 #include "Mmiicons.h"
141 #include "mmiSmsIdle.h"
142 #include "mmiSmsBroadcast.h"
143
144 /* SPR759 - SH */
145 #ifdef MMI_HOMEZONE_ENABLED
146 #include "MmiHomezone.h"
147 #endif
148 #include "mmiSmsRead.h" /*SPR 2512*/
149 #include "cus_aci.h"
150
151 #include "prim.h"
152 #ifndef PCM_2_FFS
153 #include "pcm.h"
154 #endif
155
156 #include "gdi.h"
157 #include "audio.h"
158
159 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
160 extern BOOL invalidVm;
161 //Apr 05, 2005 REF: ENH 29994 xdeepadh
162 #ifdef FF_MIDI_RINGER
163 #include "mfw_midi.h"
164 #endif
165
166 /*********************************************************************
167 **********************************************************************
168
169 STATIC MENU WINDOW. DECLARATION
170
171 *********************************************************************
172 **********************************************************************/
173
174 typedef struct
175 {
176 /* administrative data */
177
178 T_MMI_CONTROL mmi_control;
179 T_MFW_HND win;
180 SHORT id;
181 T_MFW_HND parent;
182
183 /* associated handlers */
184
185 T_MFW_HND sms;
186
187 /* internal data */
188
189 BOOL sms_initialised;
190 BOOL sms_store_free;
191 } T_smsidle;
192 //Apr 05, 2005 REF: ENH 29994 xdeepadh
193 #ifdef FF_MIDI_RINGER
194 extern T_call call_data;
195 #endif
196 /*********************************************************************
197
198 External Function Prototypes
199
200 **********************************************************************/
201 extern UBYTE getcurrentSMSTone(void);
202 extern UBYTE getcurrentVoiceTone(void);
203 extern UBYTE Delete_1_2_1_vm_icon;
204 extern UBYTE Display_1_2_1_vm_icon;
205 /* cq15633 Access function returning incoming call alert window status. 23-03-04. MZ */
206 extern BOOL call_IsAlertScreenActive( void );
207 // May 27, 2005 MMI-FIX-29869 x0018858 - Extern function
208 #ifdef FF_MMI_SMS_DYNAMIC
209 extern Check_max_sms_allowed(void);
210 #endif
211 /*********************************************************************
212
213 Function Prototypes
214
215 **********************************************************************/
216 // ADDED BY RAVI - 28-11-2005
217 EXTERN UBYTE getCurrentRingerSettings(void);
218 extern UBYTE sms_check_message_pending(void);
219 // END RAVI - 28-11-2005
220
221 static SHORT smsidle_get_new_cb_messages_count(void);
222 static T_smsidle smsidle_data;
223 static int smsidle_sr_status_to_text_id(UBYTE status); /* Marcus: Issue 1170: 07/10/2002 */
224
225
226 // Used to count the number of deleted messages in delete all
227 SHORT g_ListLength2;
228 static char status_report[160]; /* Marcus: Issue 1170: 07/10/2002 */
229
230 static T_MFW_HND smsidle_create (T_MFW_HND parent);
231 static void smsidle_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
232 int smsidle_sms_cb (MfwEvt e, MfwWin *w);
233
234 /*******************************************************************************
235
236 $Function: smsidle_start
237
238 $Description: This function will be call once.It is create a static sms handle
239
240 $Returns: mfw window handler
241
242 $Arguments: parent_window - Parent window handler
243 param - optional data
244
245 *******************************************************************************/
246
247 T_MFW_HND smsidle_start(T_MFW_HND parent_window, void *param)
248 {
249 T_MFW_HND win;
250
251 TRACE_FUNCTION ("smsidle_start()");
252
253 win = smsidle_create (parent_window);
254
255 if (win NEQ NULL)
256 {
257 SEND_EVENT (win, E_INIT, 0, NULL);
258 }
259 return win;
260 }
261
262 /*******************************************************************************
263
264 $Function: smsidle_create
265
266 $Description: Create sms Idle window
267
268 $Returns: mfw window handler
269
270 $Arguments: parent_window - Parent window handler
271
272 *******************************************************************************/
273 static T_MFW_HND smsidle_create(MfwHnd parent_window)
274 {
275 T_smsidle * data = &smsidle_data;
276 T_MFW_WIN * win;
277
278 TRACE_FUNCTION ("smsidle_create()");
279
280 /*
281 * Create window handler
282 */
283
284 if (data->win EQ NULL)
285 {
286 data->win =
287 win_create (parent_window, 0, 0, NULL);
288 if (data->win EQ NULL)
289 {
290 return NULL;
291 }
292 }
293 else
294 {
295 TRACE_EVENT ("smsidle_create() called twice");
296 return NULL;
297 }
298
299 /*
300 * connect the dialog data to the MFW-window
301 */
302
303 data->mmi_control.dialog = (T_DIALOG_FUNC)smsidle_exec_cb;
304 data->mmi_control.data = data;
305 win = (T_MFW_WIN *)((T_MFW_HDR *)data->win)->data;
306 win->user = (void *)data;
307 data->parent = parent_window;
308
309 /*
310 * return window handle
311 */
312
313 win_show(data->win);
314 return data->win;
315 }
316
317 /*******************************************************************************
318
319 $Function: smsidle_destroy
320
321 $Description: Destroy the sms Idle window.
322
323 $Returns: none
324
325 $Arguments: none
326
327 *******************************************************************************/
328 void smsidle_destroy(void)
329 {
330 T_MFW_WIN * win_data;
331 MfwHnd own_window;
332 T_smsidle * data;
333
334 own_window = smsidle_data.win;
335
336 TRACE_FUNCTION ("smsidle_destroy()");
337
338 if (own_window)
339 {
340 win_data = (T_MFW_WIN *)((T_MFW_HDR *)own_window)->data;
341 data = (T_smsidle *)win_data->user;
342
343 if (data)
344 {
345 /*
346 * Delete WIN handler
347 */
348 win_delete (data->win);
349
350 /*
351 * Free Memory
352 */
353 /* Memory is static! */
354 }
355 else
356 {
357 TRACE_EVENT ("smsidle_destroy() called twice");
358 return;
359 }
360 }
361 }
362
363
364
365 /*******************************************************************************
366
367 $Function: smsidle_exec_cb
368
369 $Description: Call back function for the sms Idle window.
370
371 $Returns: none
372
373 $Arguments: win - current window
374 event - window event
375 value - unique id
376 parameter - pointer to optional data.
377
378 *******************************************************************************/
379
380 void smsidle_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
381 /* callback handler for events sent to to trigger execution */
382 {
383 T_MFW_WIN * win_data = (T_MFW_WIN *)((T_MFW_HDR *) win)->data;
384 T_smsidle * data = (T_smsidle *)win_data->user;
385 T_MFW_EVENT smsEvents;
386
387 TRACE_FUNCTION ("smsidle_exec_cb()");
388
389 switch (event)
390 {
391 case E_INIT:
392 /* initialization of administrative data */
393 data->id = value;
394
395 /* initialization of the dialog data */
396
397 sms_init(); /* startup sms in MFW */
398
399 smsEvents =
400 E_SMS_MO_AVAIL | E_SMS_CMD_AVAIL | E_SMS_SAVE_AVAIL
401 | E_SMS_MT | E_SMS_MO | E_SMS_MT_RECEIVED | E_SMS_STATUS
402 | E_SMS_MEM | E_SMS_OK | E_SMS_ERR | E_SMS_BUSY
403 | E_SMS_MEM_FULL | E_SMS_MEM_FREE | E_SMS_RECEIVED | E_SMS_CB
404 | E_SMS_READY | E_SMS_CB_RECEIVED;
405
406
407 data->sms = sms_create(win, smsEvents, (T_MFW_CB) smsidle_sms_cb);
408
409 /* "sms_initialised" indicates that the SMS is ready or not */
410 /*api - 10-05-02 - Set To True so the SMS can be recieved (Event not Generated) */
411 data->sms_initialised = FALSE; /* SMS not ready yet */
412
413 /* "sms_store_free" indicates that the SMS Memory is full or not */
414 /* Set default to True !*/
415 data->sms_store_free = TRUE; // ???
416
417 break;
418 case E_BACK:
419 case E_ABORT:
420 case E_EXIT:
421 smsidle_destroy(); /* there's no default reaction */
422 sms_delete(data->sms);
423 sms_exit(); /* ??? implementation of routine is actually empty */
424 break;
425 default:
426 TRACE_EVENT("unhandled event in smsidle_exec_cb()");
427 return;
428 }
429 }
430 /*******************************************************************************
431
432 $Function: smsidle_message_to_text
433
434 $Description: function to format message information into a text string. SPR2363
435
436 $Returns: none
437
438 $Arguments: message data structure, text buffer(should be at least MAX_EDITOR_LEN
439 chars long)
440
441 *******************************************************************************/
442
443 void smsidle_message_to_text(T_MFW_SMS_MT* SmsMt, char* text_buffer)
444 {
445 T_MFW_PHB_ENTRY pb_entry;
446 // UBYTE input_type, output_type; // RAVI
447 char sms_text_buffer[STANDARD_EDITOR_SIZE];
448 UBYTE index=0;
449 // UBYTE msg_len; // RAVI
450 T_ATB_TEXT main_text, temp_text;
451
452
453
454 /*clear buffers*/
455 memset(sms_text_buffer, 0, STANDARD_EDITOR_SIZE);
456 memset(text_buffer, 0, MAX_EDITOR_LEN);
457
458
459
460
461
462 /*, if new editor use nice string-handling functions*/
463
464 main_text.data = (UBYTE*)text_buffer;
465 /*set up text data stucture for main display string*/
466 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
467 main_text.dcs = ATB_DCS_UNICODE;
468 else
469 main_text.dcs = ATB_DCS_ASCII;
470 ATB_string_Length(&main_text);
471
472
473 /*SPR 2539, if new editor use nice string-handling functions*/
474 /*see if the sender is in the phonebook*/
475 if (bookFindNameInPhonebook((const char*)SmsMt->orig_addr.number, &pb_entry) !=0)
476 { char temp_string[PHB_MAX_LEN];
477
478 memset(temp_string, 0, PHB_MAX_LEN);
479 /*copy name into a text data structure*/
480 if ((pb_entry.name.dcs&0xC0) == MFW_DCS_UCS2 ||pb_entry.name.data[0] == 0x80 )
481 temp_text.dcs = ATB_DCS_UNICODE;
482 else
483 temp_text.dcs = ATB_DCS_ASCII;
484 if (temp_text.dcs != ATB_DCS_UNICODE)
485 {
486 temp_text.data = (UBYTE*)pb_entry.name.data;
487 }
488
489 else
490 { pb_entry.name.len-=2;
491 memcpy(temp_string, &pb_entry.name.data[2], pb_entry.name.len);
492 temp_text.data = (UBYTE*)temp_string;
493 }
494 ATB_string_Length(&temp_text);
495 /*add name text into main display string*/
496 ATB_string_Concat(&main_text, &temp_text);
497 }
498
499
500
501 sms_text_buffer[index++]='\n';
502
503 sms_text_buffer[index++]='0'+SmsMt->sctp.day[0];
504 sms_text_buffer[index++]='0'+SmsMt->sctp.day[1];
505 sms_text_buffer[index++]='/';
506 sms_text_buffer[index++]='0'+SmsMt->sctp.month[0];
507 sms_text_buffer[index++]='0'+SmsMt->sctp.month[1];
508 sms_text_buffer[index++]='/';
509 sms_text_buffer[index++]='0'+SmsMt->sctp.year[0];
510 sms_text_buffer[index++]='0'+SmsMt->sctp.year[1];
511 sms_text_buffer[index++]=',';
512 sms_text_buffer[index++]='\n';
513
514 sms_text_buffer[index++] ='0'+SmsMt->sctp.hour[0];
515 sms_text_buffer[index++]='0'+SmsMt->sctp.hour[1];
516 sms_text_buffer[index++]=':';
517 sms_text_buffer[index++]='0'+SmsMt->sctp.minute[0];
518 sms_text_buffer[index++]='0'+SmsMt->sctp.minute[1];
519 sms_text_buffer[index++]='\n';
520
521 /* if new editor use nice string-handling functions*/
522
523 temp_text.dcs = ATB_DCS_ASCII;
524 temp_text.data = (UBYTE*)sms_text_buffer;
525 ATB_string_Length(&temp_text);
526 ATB_string_Concat(&main_text, &temp_text);
527 // Apr 27, 2004 REF: CRR 21336 Deepa M.D
528 //Check for the Alphabet bits(2nd and 3rd bits) in the DCS.(GSM 03.38 version 5.6.1,Section 4)
529 //Bit 3 and 2 are equal to 1 &0 indicates UCS2 coding
530 if ((SmsMt->dcs&0x0C) == MFW_DCS_UCS2)
531 temp_text.dcs = ATB_DCS_UNICODE;
532 else
533 temp_text.dcs = ATB_DCS_ASCII;
534 temp_text.data = (UBYTE*)SmsMt->sms_msg;
535 ATB_string_Length(&temp_text);
536 /*Add date and time to main display string*/
537 ATB_string_Concat(&main_text, &temp_text);
538
539
540
541 }
542
543
544 /*******************************************************************************
545
546 $Function: smsidle_sms_cb
547
548 $Description: Call back function for the sms Idle window.
549
550 $Returns: none
551
552 $Arguments: event - window event
553 w - current window
554 *******************************************************************************/
555 int smsidle_sms_cb (MfwEvt event, MfwWin *w)
556 /* smsidle's sms event handler */
557 {
558 T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
559 T_MFW_WIN * win_data = (T_MFW_WIN *)((T_MFW_HDR *)win)->data;
560 T_smsidle * data = (T_smsidle *)win_data->user;
561 UBYTE currentSMSTone;
562 UBYTE currentVoiceTone; /*CQ 10586 - API - 19/06/03 */
563
564 /*cq 15633 get current ringer settings */
565 UBYTE currentRinger = getCurrentRingerSettings();
566
567 /*JVJ SPR1298 Converted to dynamic variable */
568 //May 27, 2005 MMI-FIX-29869 x0018858
569 #ifdef FF_MMI_SMS_DYNAMIC
570 T_MFW_SMS_IDX* msg_list;
571 T_MFW_SMS_IDX* urd_msg_list;
572 #else
573 T_MFW_SMS_IDX* msg_list= (T_MFW_SMS_IDX*)ALLOC_MEMORY(MAX_MESSAGES*sizeof(T_MFW_SMS_IDX));
574 T_MFW_SMS_IDX* urd_msg_list= (T_MFW_SMS_IDX*)ALLOC_MEMORY(MAX_MESSAGES*sizeof(T_MFW_SMS_IDX));
575 #endif
576 SHORT urd_count;
577 // UBYTE alphabet; // RAVI
578 /*JVJ SPR1298 Converted to dynamic variable */
579 char* temp_buffer = NULL;
580 int result = MFW_EVENT_CONSUMED;
581
582 //May 27, 2005 MMI-FIX-29869 x0018858
583 #ifdef FF_MMI_SMS_DYNAMIC
584 Check_max_sms_allowed();
585
586 msg_list = (T_MFW_SMS_IDX*)ALLOC_MEMORY(g_max_messages*sizeof(T_MFW_SMS_IDX));
587 urd_msg_list = (T_MFW_SMS_IDX*)ALLOC_MEMORY(g_max_messages*sizeof(T_MFW_SMS_IDX));
588 #endif
589
590 TRACE_EVENT ("smsidle_sms_cb()");
591
592 switch (event)
593 {
594 case E_SMS_READY:
595 TRACE_EVENT ("E_SMS_READY");
596 /* now sms is now ready for using */
597 data->sms_initialised = TRUE;
598 sms_set_mt_ind(MT_IND_IDX); /* MMI-FIX-17223. Needed for class 0 messages not to be stored in SIM */
599 sms_cb_init(); /*SPR 2470 initialise cell broadcast now SMS has initialised*/
600 smscb_getCBsettings(); /* Get CB info from SIM or phone */
601 #ifdef MMI_HOMEZONE_ENABLED
602 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858
603 //Commented the function call,
604 //homezoneActivateCB(); /* SPR759 - SH - Activate Cell Broadcast channel for homezone */
605 #endif
606
607 break;
608 case E_SMS_MT_RECEIVED: /* new SMS received, automatically saved */
609 case E_SMS_MT: /* new SMS received, NOT automatically saved */
610 {
611
612 /*SPR#1408 - DS - Take the SMS data from MFW. Port of 1669 */
613 T_MFW_SMS_MT *Message = (T_MFW_SMS_MT *) w;
614
615 // check for SMS indicating voice mail.
616 //May 27, 2005 MMI-FIX-29869 x0018858
617 #ifdef FF_MMI_SMS_DYNAMIC
618 urd_count = sms_index_list(MFW_SMS_UNREAD,urd_msg_list,g_max_messages);
619
620 sms_index_list(MFW_SMS_VOICE,msg_list,g_max_messages);
621 #else
622 urd_count=sms_index_list(MFW_SMS_UNREAD,urd_msg_list,MAX_MESSAGES);
623
624 sms_index_list(MFW_SMS_VOICE,msg_list,MAX_MESSAGES);
625 #endif
626 TRACE_EVENT_P4("urd_count %d urd_msg_list-> index %d stat %d msg_type %d",
627 urd_count,urd_msg_list[0].index,urd_msg_list[0].stat,urd_msg_list[0].msg_type);
628
629 TRACE_EVENT_P2("msg_type: %d, Message->voicemail: %d", msg_list[0].msg_type, Message->voicemail);
630
631 //Check SMS indicating voice mail is the received SMS, by checking index is the same.
632 /*SPR#1408 - DS - Added check for voicemail flag.
633 *For E_SMS_MT_RECEIVED messages the MFW flags the message as a voicemail by setting the
634 *msg_type to MFW_SMS_VOICE. For E_SMS_MT messages the MFW flags as a voicemail by
635 *setting a boolean in the SMS MT structure. Port of 1669 (then modified).
636 */
637 if ( ( (event == E_SMS_MT_RECEIVED) && (msg_list[0].msg_type == MFW_SMS_VOICE) ) ||
638 ( (event == E_SMS_MT) && (Message->voicemail == TRUE) ) )
639 {
640 if(iconsGetState(iconIdVoice) == ICON_VISIBLE || (Delete_1_2_1_vm_icon == TRUE))
641 {
642 if (iconsGetState(iconIdVoice) == ICON_VISIBLE && Display_1_2_1_vm_icon == TRUE)
643 {
644 // one-2-one only functionality, do nothing as icon is already being displayed.
645 break;
646 }
647 else
648 {
649 Delete_1_2_1_vm_icon = FALSE;
650 Display_1_2_1_vm_icon = FALSE;
651 iconsDeleteState(iconIdVoice);
652 }
653 }
654 else
655 {
656 iconsSetState(iconIdVoice); /* display voice mail icon.*/
657 //Apr 05, 2005 REF: ENH 29994 xdeepadh
658 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
659 //Play the SMS tone alert
660 #ifdef FF_MIDI_RINGER
661 mfw_ringer_start(AS_RINGER_MODE_SMS,false,sounds_midi_ringer_start_cb);
662 #else
663 /*CQ 10586 - API - 19/06/03 - Play Adio buzzer when new voice mail received*/
664 currentVoiceTone = getcurrentVoiceTone();
665 #ifdef FF_MMI_RINGTONE /* MSL SMS Tone Play */
666 audio_PlaySoundID( AUDIO_BUZZER, SMSTONE_SELECT, 200, AUDIO_PLAY_ONCE );
667 #else
668 /* RAVI - 20-1-2006 */
669 #ifdef NEPTUNE_BOARD
670 audio_PlaySoundID( AUDIO_BUZZER, currentVoiceTone, 200,
671 AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
672 #else
673 audio_PlaySoundID( AUDIO_BUZZER, currentVoiceTone, 200, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
674 #endif
675
676 #endif
677 #endif
678 mme_backlightEvent(BL_INCOMING_SMS);
679 }
680 idleEvent(IdleUpdate); /* update the idle screen.*/
681
682 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
683 // Check if this voice mail sms is marked for deletion (belonging to group "1100")
684 if(msg_list[0].stat == MFW_SMS_VOICEMSG_DELETE)
685 {
686 //Delete this voice mail sms and set 'invalidVm' flag to FALSE
687 sms_msg_delete(msg_list[0].index);
688 invalidVm = FALSE;
689 }
690 }
691 else if(urd_count > 0 && urd_msg_list[0].stat == MFW_SMS_UNREAD && (event != E_SMS_MT))
692 {
693 /* set the status: The sms icon and the string*/
694 /* "message(s) received" will be displayed */
695 iconsSetState(iconIdSMS); /* Indicate SMS delivery to MS-User. */
696 idleEvent(IdleNewSmsMessage);
697 //Apr 05, 2005 REF: ENH 29994 xdeepadh
698 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
699 //Play the SMS tone alert
700 //If SMS is recieved , while in call screen,dont play the tone.
701 #ifdef FF_MIDI_RINGER
702
703 if((!(call_data.calls.numCalls)))
704 {
705 mfw_ringer_start(AS_RINGER_MODE_SMS,false,sounds_midi_ringer_start_cb);
706 }
707 #else
708 currentSMSTone = getcurrentSMSTone();
709 #ifdef FF_MMI_RINGTONE /* MSL SMS Tone Play */
710 audio_PlaySoundID( AUDIO_BUZZER, SMSTONE_SELECT, 200, AUDIO_PLAY_ONCE );
711 #else
712 /* RAVI - 20-1-2006 */
713 #ifdef NEPTUNE_BOARD
714 audio_PlaySoundID( AUDIO_BUZZER, currentSMSTone,
715 getCurrentVoulmeSettings(), AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
716 #else
717 audio_PlaySoundID( AUDIO_BUZZER, currentSMSTone, 200, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
718 #endif
719
720 #endif
721 #endif
722 /* cq15633 If the Incoming call alert screen is active continue with the incoming call ringer after playing the
723 the SMS received tone. 23-03-04 MZ. */
724 //Apr 05, 2005 REF: ENH 29994 xdeepadh
725 #ifndef FF_MIDI_RINGER
726 if(TRUE == call_IsAlertScreenActive())
727 {
728 #ifdef FF_MMI_RINGTONE /* MSL SMS Tone Play */
729 audio_PlaySoundID(AUDIO_BUZZER, SMSTONE_SELECT, 0 , AUDIO_PLAY_INFINITE);
730 #else
731 /* RAVI - 20-1-2006 */
732 /* Silent Implementation */
733 #ifdef NEPTUNE_BOARD
734 audio_PlaySoundID(AUDIO_BUZZER, currentRinger,
735 getCurrentVoulmeSettings(), AUDIO_PLAY_INFINITE);
736 #else
737 audio_PlaySoundID(AUDIO_BUZZER, currentRinger, 0 , AUDIO_PLAY_INFINITE);
738 #endif
739 /* END RAVI */
740
741 #endif
742 }
743 #endif
744
745 mme_backlightEvent(BL_INCOMING_SMS);
746 }
747 /*NM p029*/
748 /* API - Implemented NM changes from 3.3.3 mainline to show class 0 SMS on idle screen */
749 else if(event == E_SMS_MT) /* this sms identifier "E_SMS_MT" is not saved on the SIM */
750 {
751 /* take the SMS data from MFW */
752 T_MFW_SMS_MT *Message = (T_MFW_SMS_MT *) w;
753 char* temp_buffer_sms = (char*)ALLOC_MEMORY(MAX_EDITOR_LEN);
754 /* Marcus: Issue 1650: 28/01/2003: Start */
755 TRACE_EVENT ("E_SMS_MT");
756 /* check for the class 0 message */
757 TRACE_EVENT_P1("dcs: 0x%02X", Message->dcs);
758 /*if memory allocation successful*/
759
760 if (temp_buffer_sms != NULL)
761 {
762 if ((Message->dcs & TEXT_CLASS_GIVEN) &&
763 ((Message->dcs & TEXT_CLASS_MASK) == TEXT_CLASS_0))
764 {
765 TRACE_EVENT ("Class 0 message");
766
767 /*
768 ** SPR#1745 NDH Text from ACI may be compressed. if so
769 ** the text will need to be converted to ASCII before it can
770 ** be displayed properly
771 */
772 if (Message->dcs & TEXT_COMPRESSED)
773 {
774
775 TRACE_EVENT ("text_compressed");
776
777 /*
778 ACI already (in case of 7bit-dcs!) extract the 7 bit to 8 bit,
779 so this is what we get and we have just only to decode from
780 7Bit-Default to ASCII
781 */
782
783 /*SPR 2512, convert message into a text string and then send to idle for display*/
784 smsidle_message_to_text(Message, temp_buffer_sms);
785 addCBCH(temp_buffer_sms, IdleNewSmsMessage);
786
787
788
789
790 }
791 else
792 {
793 TRACE_EVENT ("text_uncompressed");
794
795
796 /*SPR 2512, convert message into a text string and then send to idle for display*/
797 smsidle_message_to_text(Message, temp_buffer_sms);
798 addCBCH(temp_buffer_sms, IdleNewSmsMessage);
799
800
801 }
802 /*
803 ** SPR#1745 - End
804 */
805 /*CQ10826 - API - 27/06/03 - Add audio indication for class 0 SMS*/
806 //Apr 05, 2005 REF: ENH 29994 xdeepadh
807 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
808 #ifdef FF_MIDI_RINGER
809 mfw_ringer_start(AS_RINGER_MODE_SMS,false,sounds_midi_ringer_start_cb);
810 #else
811 currentSMSTone = getcurrentSMSTone();
812 #ifdef FF_MMI_RINGTONE /* MSL SMS Tone Play */
813 audio_PlaySoundID( AUDIO_BUZZER, SMSTONE_SELECT, 200, AUDIO_PLAY_ONCE );
814 #else
815 /* RAVI - 20-1-2006 */
816 #ifdef NEPTUNE_BOARD
817 audio_PlaySoundID( AUDIO_BUZZER, currentSMSTone,
818 getCurrentVoulmeSettings(), AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
819 #else
820 audio_PlaySoundID( AUDIO_BUZZER, currentSMSTone, 200, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
821 #endif
822 /* END RAVI */
823
824 #endif
825 #endif
826 mme_backlightEvent(BL_INCOMING_SMS);
827 /*CQ10826 - END*/
828
829 }
830
831
832 /*temp_buffer_sms will be freed in editor callback*/
833
834 }
835 }
836 /*NM p029 end*/
837 }
838 break;
839 case E_SMS_CB: /* new CBCH received */
840 {
841 // USHORT i; // RAVI
842 SHORT geograhical_scope = (SHORT)0xC000;
843
844 T_MFW_SMS_CB *Message = (T_MFW_SMS_CB *)w;
845
846 TRACE_EVENT ("E_SMS_CB");
847
848 temp_buffer = (char*)ALLOC_MEMORY(MAX_CBMSG_LEN);
849 memset(temp_buffer, '\0', MAX_CBMSG_LEN);
850
851 //check: does the incoming CB indicates a immediate scope
852 if (! (Message->sn & geograhical_scope) )
853 {
854 //Immediate scope
855 // API - 859 - German characters were not visable in the CB message
856 TRACE_EVENT("Immediate Scope");
857
858 // API - 859 - Convert the the incoming GSM Text to ASCII
859 /*SPR2175, use new function for conversion*/
860 ATB_convert_String(Message->cb_msg, MFW_DCS_8bits, Message->msg_len,
861 temp_buffer, MFW_ASCII, MAX_CBMSG_LEN, FALSE);
862
863 /* SPR 2429, removed search for terminating character*/
864
865 #ifdef MMI_HOMEZONE_ENABLED // SH 11/12/01
866 /* SPR759 - SH - Homezone: check to see if CB gives us the coordinates of the centre of the current cell */
867
868 if (Message->msg_id==HZ_IDENTIFIER)
869 {
870 homezoneCBData(Message->cb_msg);
871 }
872 else
873 {
874 #endif // HOMEZONE
875
876 //display now on the idle screen
877
878 addCBCH(temp_buffer, IdleNewCBImmediateMessage);
879 statusCBCH(TRUE);
880 #ifdef MMI_HOMEZONE_ENABLED
881 } /* SPR759 - SH */
882 #endif
883 }
884 else //Normal scope
885 {
886 TRACE_EVENT("Normal Scope");
887 //only for single- and the last page of mulitpages
888 //other pages have not the termination "0x00D"
889
890 // API - 859 - Convert the the incoming GSM Text to ASCII
891 /*SPR2175, use new function for conversion*/
892 ATB_convert_String(Message->cb_msg, MFW_DCS_8bits, Message->msg_len,
893 temp_buffer, MFW_ASCII, MAX_MSG_LEN, FALSE);
894
895 memcpy(Message->cb_msg, temp_buffer, MAX_CBMSG_LEN);
896
897 /* SPR 2429, removed search for terminating character*/
898 {
899 Message->cb_msg[MAX_CBMSG_LEN - 1 ]='\0'; // RAVI - Changed as MAX_CBMSG_LEN - 1.
900 }
901
902 //indicate on the idle screen the new incoming cb
903 addCBCH( NULL, IdleNewCBNormalMessage );
904 statusCBCH(TRUE);
905
906 //save the incoming cb messages in the fifo
907 sms_new_incoming_cb (Message);
908
909 }
910 FREE_MEMORY((void*)temp_buffer,MAX_CBMSG_LEN);
911 }
912 break;
913
914 case E_SMS_MEM_FULL:
915 /* the memory of SMS is FULL !!*/
916 data->sms_store_free = FALSE;
917
918 /* sendevent IDLE_UPDATE; */
919 SEND_EVENT(idle_get_window(),IDLE_UPDATE,0,0);
920 break;
921 case E_SMS_MEM_FREE:
922 /* the memory of SMS is FREE */
923 data->sms_store_free = TRUE;
924
925 /* sendevent IDLE_UPDATE; */
926 SEND_EVENT(idle_get_window(),IDLE_UPDATE,0,0);
927 /* ??? */
928
929 break;
930 case E_SMS_STATUS: /* status report from service center */
931 /* Marcus: Issue 1170: 07/10/2002: Start */
932 {
933 T_MFW_SMS_STATUS *sms_status = (T_MFW_SMS_STATUS *)w;
934 TRACE_EVENT("E_SMS_STATUS");
935 //Apr 05, 2005 REF: ENH 29994 xdeepadh
936 //Nov 02, 2005 REF:ER OMAPS00039044 xdeepadh
937 //Play the SMS tone alert for status report indication
938 #ifdef FF_MIDI_RINGER
939 mfw_ringer_start(AS_RINGER_MODE_SMS,false,sounds_midi_ringer_start_cb);
940 #else
941 currentSMSTone = getcurrentSMSTone();
942 #ifdef FF_MMI_RINGTONE /* MSL SMS Tone Play */
943 audio_PlaySoundID( AUDIO_BUZZER, SMSTONE_SELECT, 200, AUDIO_PLAY_ONCE );
944 #else
945 /* RAVI - 20-1-2006 */
946 #ifdef NEPTUNE_BOARD
947 audio_PlaySoundID( AUDIO_BUZZER, currentSMSTone,
948 getCurrentVoulmeSettings(), AUDIO_PLAY_ONCE );
949 #else
950 audio_PlaySoundID( AUDIO_BUZZER, currentSMSTone, 200, AUDIO_PLAY_ONCE );
951 #endif
952 /* END RAVI */
953
954 #endif
955 #endif
956
957 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
958 {
959 /*
960 * There is no support for Chinese in the addCBCH function,
961 * so will be problems with class 0 SMS messages and with cell
962 * broadcast messages that need to be addressed anyway.
963 * A new issue will be raised to handle this problem.
964 */
965 }
966 else
967 {
968 memset(status_report, '\0', sizeof(status_report));
969 strcpy(status_report, MmiRsrcGetText(TxtSRR));
970 strcat(status_report, ": ");
971 strcat(status_report, MmiRsrcGetText(TxtStatus));
972 strcat(status_report, ": ");
973 strcat(status_report, MmiRsrcGetText(smsidle_sr_status_to_text_id(sms_status->status)));
974 sprintf(&status_report[strlen(status_report)], " (%u): ", sms_status->status);
975 #ifdef NO_ASCIIZ
976 if (sms_status->addr.len)
977 {
978 memcpy(&status_report[strlen(status_report)], sms_status->addr.tag, sms_status->addr.len);
979 strcat(status_report, " ");
980 }
981 #else
982 if (strlen(sms_status->addr.tag))
983 {
984 strcat(status_report, sms_status->addr.tag);
985 strcat(status_report, " ");
986 }
987 #endif
988 if (sms_status->addr.ton == MFW_TON_INTERNATIONAL)
989 strcat(status_report, "+");
990
991 strcat(status_report, sms_status->addr.number);
992 sprintf(&status_report[strlen(status_report)],
993 ": %0u%0u/%0u%0u/%0u%0u %0u%0u:%0u%0u:%0u%0u (%s %u)",
994 sms_status->rctp.day[0],
995 sms_status->rctp.day[1],
996 sms_status->rctp.month[0],
997 sms_status->rctp.month[1],
998 sms_status->rctp.year[0],
999 sms_status->rctp.year[1],
1000 sms_status->rctp.hour[0],
1001 sms_status->rctp.hour[1],
1002 sms_status->rctp.minute[0],
1003 sms_status->rctp.minute[1],
1004 sms_status->rctp.second[0],
1005 sms_status->rctp.second[1],
1006 MmiRsrcGetText(TxtMessage),
1007 sms_status->msg_ref);
1008
1009 addCBCH(status_report, IdleNewSmsMessage);
1010
1011 //display now on the idle screen
1012 statusCBCH(TRUE);
1013 }
1014 }
1015 /* Marcus: Issue 1170: 07/10/2002: End */
1016
1017 break;
1018 case E_SMS_MEM: /* indicates status of memory */
1019 /* not used */
1020 break;
1021 case E_SMS_MO: /* SMS sending has started */
1022 /* not used */
1023 case E_SMS_OK:
1024 /* Only happens when an SMS message is deleted. */
1025
1026 break;
1027 case E_SMS_BUSY:
1028 TRACE_EVENT ("E_SMS_BUSY");
1029 break;
1030 case E_SMS_SAVE_AVAIL:
1031 break;
1032 case E_SMS_CMD_AVAIL:
1033 break;
1034 case E_SMS_ERR:
1035 TRACE_EVENT ("E_SMS_ERR");
1036 break;
1037 default:
1038 TRACE_EVENT("unhandled event in smsidle_sms_cb()");
1039 result = MFW_EVENT_PASSED;
1040 break;
1041 }
1042 //May 27, 2005 MMI-FIX-29869 x0018858
1043 #ifdef FF_MMI_SMS_DYNAMIC
1044 FREE_MEMORY((void*)msg_list,g_max_messages*sizeof(T_MFW_SMS_IDX));
1045 FREE_MEMORY((void*)urd_msg_list,g_max_messages*sizeof(T_MFW_SMS_IDX));
1046 #else
1047 FREE_MEMORY((void*)msg_list,MAX_MESSAGES*sizeof(T_MFW_SMS_IDX));
1048 FREE_MEMORY((void*)urd_msg_list,MAX_MESSAGES*sizeof(T_MFW_SMS_IDX));
1049 #endif
1050
1051 return result;
1052 }
1053
1054 /*******************************************************************************
1055
1056 $Function: smsidle_get_memory_full
1057
1058 $Description: Call back function for the sms Idle window.
1059
1060 $Returns: sms memory status.
1061
1062 $Arguments: none
1063
1064 *******************************************************************************/
1065
1066 BOOL smsidle_get_memory_full(void)
1067 {
1068 return (!smsidle_data.sms_store_free);
1069 }
1070
1071 /*******************************************************************************
1072
1073 $Function: smsidle_get_new_cb_messages_count
1074
1075 $Description: Call back function for the sms Idle window.
1076
1077 $Returns: sms count.
1078
1079 $Arguments: none
1080 *******************************************************************************/
1081
1082 SHORT smsidle_get_new_cb_messages_count(void)
1083 {
1084 if (smsidle_get_ready_state())
1085 {
1086 return smscb_get_new_cb_messages_count();
1087 }
1088 else
1089 {
1090 return 0;
1091 }
1092 }
1093
1094
1095 /*******************************************************************************
1096
1097 $Function: smsidle_get_ready_state
1098
1099 $Description: This function can be call from anywhere to get the information
1100 about the "sms_initialised"
1101
1102 $Returns: sms status
1103
1104 $Arguments: none
1105
1106 *******************************************************************************/
1107 BOOL smsidle_get_ready_state(void)
1108 {
1109 return (smsidle_data.sms_initialised);
1110 }
1111
1112 //GW SPR#1035 - Added SAT changes
1113 /*******************************************************************************
1114
1115 $Function: smsidle_unset_ready_state
1116
1117 $Description: this unset the flat "sms_initialised"
1118
1119 $Returns: sms status
1120
1121 $Arguments: none
1122
1123 *******************************************************************************/
1124 void smsidle_unset_ready_state(void)
1125 {
1126 smsidle_data.sms_initialised = FALSE;
1127 }
1128
1129 /*******************************************************************************
1130
1131 $Function: smsidle_get_unread_sms_available
1132
1133 $Description: This function allows an external process to determine the
1134 received and unread SMS PP message status.
1135
1136 $Returns: sms status.
1137
1138 $Arguments: none
1139
1140 *******************************************************************************/
1141 BOOL smsidle_get_unread_sms_available(void)
1142 { SHORT unread_sms_count;
1143
1144 //May 27, 2005 MMI-FIX-29869 x0018858
1145 #ifdef FF_MMI_SMS_DYNAMIC
1146 //begin
1147 qAT_PlusCPMS(CMD_SRC_LCL);
1148 Check_max_sms_allowed();
1149 //End
1150 #endif
1151 TRACE_FUNCTION("smsidle_get_unread_sms_available() ");
1152 if (smsidle_get_ready_state())
1153 {
1154 //API - 14-01-03 - 1403 - Remove the call to iconsSetState(iconIdSMS) to indicate new SMS incall
1155 unread_sms_count = sms_message_count(MFW_SMS_UNREAD);
1156
1157 return (unread_sms_count > 0 && (unread_sms_count > sms_message_count(MFW_SMS_VOICE)));
1158 }
1159 else
1160 {
1161
1162 iconsDeleteState(iconIdSMS);
1163 return FALSE;
1164 }
1165 }
1166
1167 /*******************************************************************************
1168
1169 $Function: smsidle_display_sms_status
1170
1171 $Description: Interogates the SMS unread message count and displays
1172 the result using the SMS icon and an information text.
1173
1174 $Returns: id of text string to be displayed
1175
1176 $Arguments: noOfMsgs - returns number of unread messages (or 0 if there are no
1177 messages or the memory is full).
1178
1179 GW 02/10/01 - Modified code to work with chinese unicode text.
1180 *******************************************************************************/
1181 int smsidle_display_sms_status(int* noOfMsgs)
1182 {
1183 SHORT SmsMsgCount;
1184 SHORT SmsVmailCount;
1185 int txtMsg;
1186
1187 TRACE_FUNCTION("smsidle_display_sms_status() ");
1188 *noOfMsgs = 0;
1189 txtMsg = TxtNull;
1190
1191 if (smsidle_get_ready_state())
1192 {
1193 SmsVmailCount = sms_message_count(MFW_SMS_VOICE);
1194
1195
1196 SmsMsgCount = sms_message_count (MFW_SMS_UNREAD);
1197
1198 /* Envelope icon and text only appear if a non-Voicemail SMS exists. */
1199
1200 if (smsidle_get_memory_full())
1201 {
1202 /* x0018858 24 Mar, 2005 MMI-FIX-11321
1203 Added a condition to check for any pending message.
1204 */
1205 //begin -x0018858 24 Mar, 2005 MMI-FIX-11321
1206 if( TRUE == sms_check_message_pending())
1207 {
1208 txtMsg = TxtSmsWaiting;
1209 }//end. x0018858 24 Mar, 2005 MMI-FIX-11321
1210 else
1211 {
1212 txtMsg = TxtSmsListFull;
1213 }
1214 }
1215 else if ((SmsMsgCount > 0) && (SmsMsgCount > SmsVmailCount))
1216 {
1217 txtMsg = TxtNewMessage;
1218 *noOfMsgs = SmsMsgCount;
1219
1220 }
1221 else
1222 {
1223 iconsDeleteState(iconIdSMS); /* Turn off SMS icon. */
1224 txtMsg = TxtNull;
1225 }
1226
1227 iconsShow();
1228 }
1229 return (txtMsg);
1230 }
1231
1232 /*******************************************************************************
1233
1234 $Function: smsidle_get_unread_smscb_available
1235
1236 $Description: This function allows an external process to determine the
1237 received SMS CB message status.
1238
1239 $Returns: execution status
1240
1241 $Arguments: none
1242
1243 *******************************************************************************/
1244 BOOL smsidle_get_unread_smscb_available(void)
1245 {
1246 if (smsidle_get_ready_state())
1247 return (smsidle_get_new_cb_messages_count() > 0);
1248 else
1249 return FALSE;
1250 }
1251
1252 /*******************************************************************************
1253
1254 $Function: smsidle_display_smscb_status
1255
1256 $Description: Interogates the SMS CB message received status and
1257 returns the resulting string to the caller.
1258
1259 $Returns: none
1260
1261 $Arguments: TextString - Text String
1262 *******************************************************************************/
1263 void smsidle_display_smscb_status(char *TextString)
1264 {
1265 SHORT count;
1266
1267 /* count the unread cb messagesc */
1268 count = smsidle_get_new_cb_messages_count();
1269
1270
1271 /* the unread CB should have a high priority than */
1272 /* the class 0 CB */
1273 if (count > 0)
1274 {
1275 sprintf(TextString, "%d %s\0",count, GET_TEXT(TxtNewCbMessage));
1276 iconsSetState(iconIdSMS); /* Indicate SMS delivery to MS-User. */
1277
1278 }
1279 }
1280 /* Marcus: Issue 1170: 07/10/2002: Start */
1281 /*******************************************************************************
1282
1283 $Function: smsidle_sr_status_to_text_id
1284
1285 $Description: Returns the text ID for the given status report status
1286
1287 $Returns: int : text ID
1288
1289 $Arguments: UBYTE: SMS-STATUS-REPORT status
1290 *******************************************************************************/
1291 static int smsidle_sr_status_to_text_id(UBYTE status)
1292 {
1293 int ret = TxtError;
1294 UBYTE group = ((status & 0x60) >> 5);
1295 UBYTE value = (status & 0x1F);
1296 switch (group)
1297 {
1298 case 0: // Short message transaction completed
1299 if ((value >= 3) && (value <= 0x0F))
1300 ret = TxtError;
1301 else
1302 ret = TxtDelivered;
1303 break;
1304
1305 case 1: // Temporary error, SC still trying to transfer SM
1306 if ((value >= 6) && (value <= 0x0F))
1307 ret = TxtError;
1308 else
1309 ret = TxtTempError;
1310 break;
1311
1312 case 2: // Permanent error, SC is not making any more transfer attempts
1313 case 3: // Temporary error, SC is not making any more transfer attempts
1314 ret = TxtError;
1315 break;
1316 }
1317 return ret;
1318 }
1319 /* Marcus: Issue 1170: 07/10/2002: End */
1320
1321
1322
1323
1324
1325