comparison src/ui/mfw/mfw_sms.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children 92abb46dc1ba
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_sms.c $|
4 | $Author:: Vo $Revision:: 1 $|
5 | CREATED: 21.12.98 $Modtime:: 24.03.00 10:25 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_SMS
10 PURPOSE : This module contains SMS management functions.
11
12 Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
13 Description:SMS alphanumeric address
14 Solution:Inorder to support alphanumeric address,MMI is setting editor mode as
15 "ED_MODE_ALPHA" in the function SmsSend_R_OPTExeSend(). Also MMI is checking whether user
16 have entered Numeric oralphanumeric address in the function sms_submit() and
17 sms_submit before calling sAT_PlusCMGS() and sAT_PlusCMGW() respectively.
18
19 Feb 28, 2007 OMAPS00109953 a0393213(R.Prabakar)
20 Description : Need to be able to store SMS in SIM/ME
21 Solution : Earlier, index alone was sufficient to identify messages. Now memory should also be taken care of.
22
23 July 27, 2006 DR: OMAPS00085347 x0021334
24 Description: The display freeze when reading a stored concatenated SMS (This concatenated
25 SMS consists of 3 SMS) from SIM.
26 Solution: Added code to free the allocated memory after concatenated SMS has been read.
27
28 May 18, 2006 DR: OMAPS00070657 x0pleela
29 Description: CPHS feature on Locosto-Lite
30 Solution: Enabling the voice mail indication if there are any voice mails
31
32 Feb 07, 2006 DR: OMAPS00059261 x0pleela
33 Description: SMS is not forwarding STATUS reports that are read from SIM storage to ACI
34 Solution: sms_decode_status(): removed the code added for handling pending status of a status report
35 rat_plusCMGR(): updating sms_str based on tp_status of a status report
36 Removed macros STAT_MIN_VALUE and STAT_MAX_VALUE added earlier
37 Replaced MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
38
39 Feb 01, 2006 DR: OMAPS00059261 x0pleela
40 Description: SMS is not forwarding STATUS reports that are read from SIM storage to ACI
41 Solution: Added two macros to check the range of status of status report
42 Used enums for the hardcoded values for MFW_MSG_DELIVER(MT), MFW_MSG_SUBMIT (MO) and MFW_MSG_STATUS_REPORT (STATUS REPORT) types while reading the messages
43 Added a check in "sms_decodeStatus" to support pending status of the status report
44 Made changes as per review comments
45
46 Jan 30, 2006 DR: OMAPS00059261 x0pleela
47 Description: SMS is not forwarding STATUS reports that are read from SIM storage to ACI
48 Solution: Added code to read MT Status report
49
50
51 Jan 20, 2006 REF: DRT OMAPS00053377 xdeepadh
52 Description: SMS Validity Period - using MMI - Failure, MS not able to set SMS validity
53 Solution: While setting the validity period, the validity period format also has been set in the
54 frst octet.
55
56 Nov 15,2005 DR : OMAPS00057280 - x0034700
57 Description: Compilation Errors in Neptune build while integrating latest MMI Changes
58 Solution: Included the compilation FLAG "NEPTUNE_BOARD" for un wanted code for Neptune build
59
60 Feb 22, 2006 REF: MMI-FIX-OMAPS00058684 x0035544(Sudha)
61 Description: Can't send a SMS with a specific SIM card
62 Solution: Check the PID(Protocol ID) value for an MO SMS and Set the PID(Protocol ID) accordingly.
63
64 Dec 15, 2005 REF: MMI-FIX-OMAPS00058684 x0035544
65 Description: OMAPS00045726 / MMI-FIX-30439 Follow-Up : ifdef for FF Home Zone forgotten.
66 Solution: Added Feature flag FF_HOMEZONE for the function sms_homezoneCBToggle(U8 Activate_CB)
67
68 Nov 8, 2005 REF: OMAPS00050772, a0876501 (Shashi)
69 Issue description: CMGD merge from tcs4.0 to g23m.
70 Solution: New parameter is added to sAT_PlusCMGD function. Migrating the MFW changes.
71
72
73 Oct 18, 2005 REF: SPR 34678 xdeepadh
74 Description: MMI Screen – shows garbled characters for Cell Information
75 Solution: The CB messages with DCS 242(class-2,default alphabet) are discarded.
76
77 May 27, 2005 MMI-FIX-29869 x0018858
78 Description: There is a limitation on the number of messages that can be downloaded from
79 server even though there is space on the sim.
80 Solution: The limitation has been removed and the number of messages that can be dowloaded
81 has been modified to the masimum number that can be stored.
82
83 Jun 14, 2005 REF: MMI-FIX-30439 x0018858
84 Description: The homezone/cityzone tags were not being displayed properly.
85 Solution: Modified to save the tags properly in caches and also made the
86 appropriate modifications to update the same properly during mobility.
87
88 July 7, 2005 REF: CRR MMI-SPR-32179 x0018858
89 Issue description: PS crashed while performing call Forwarding.
90 Solution: Since this is related to memory leaks which occur, the code has been added to
91 free certain memory based on a a checking condition and also by cleaning the buffer.
92
93 xrashmic 9 May, 2005 MMI-SPR-30159
94 Concat PUSH msg are stored and sent to wap client once all parts are received
95
96 x0018858 24 Mar, 2005 MMI-FIX-11321
97 Issue Description :- If the inbox is full and a new message is receivd, no indication is received.
98 Fix: Added support for handling indication when message box is full and
99 there is a pending message.
100
101 March 31, 2005 REF: CRR MMI-SPR-24511 x0012852
102 Bug:The phone crashes when the user selects the 'Delete All' option
103 almost the same time as there's an incoming message.
104 Fix:Check added for part message before deleting all messages.
105
106 March 2, 2005 REF: CRR 11536 x0018858
107 Description: Reply path not supported while sending a reply.
108 Solution: Added menu option for the reply path.
109
110
111 Feb 28, 2004 REF: CRR 28809 Deepa M.D
112 Bug:SRAM Optimization :Dynamic allocation of sms_mo
113 Fix:The static T_MFW_SMS_MO sms_mo variable, is made a local pointer variable.
114 It is dynamically allocated and deallocated.
115 The Optimization changes done for golite build have been incorpaorated to color build.
116 The MMI_LITE flag used for rAT_PlusCMGR has been removed.
117
118 Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
119 Issue description: BMI: using the tool nowSMS the voicemail indication via sms does not work
120 Solution: Instead of identifying voice using addr[0] and pid, we use dcs. Also, messages belonging
121 to group "1100" are deleted when voicemail icon is displayed.
122
123 Dec 23, 2004 REF: CRR MMI-SPR-27741 xkundadu
124 Issue description: BMI: crashing when using the function : sms_index_list() located in mfw
125 Solution: Changed the msg_list variable to array of T_MFW_SMS_IDX.
126
127 Aug 18, 2004 REF: CRR 24282 Deepa M.D
128 Bug:Go-lite Optimization Dynamic allocation of sms_mo
129 Fix:static T_MFW_SMS_MO sms_mo has been made a local variable.
130 It is allocated/deallocated dynamically.
131
132 Aug 16, 2004 REF: CRR 24323 Deepa M.D
133 Bug:Clenup of sprintf used for tracing
134 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX
135
136 Aug 17, 2004 REF: CRR 24281 Deepa M.D
137 Bug:Go-lite Optimization Remove the unsed variable temp_conv_buffer
138 Fix:Removed the unused variables from mfw_sms.c
139
140 Aug 26, 2004 REF: CRR 23287 Deepa M.D
141 Bug:Inconsistent events being passed in MFW sms module
142 Fix:For E_SMS_MT_RECEIVED event,sms_id_wait is passed.
143
144 Jul 07, 2004 REF: CRR 15846 Deepa M.D
145 Bug : Concatenated SMT : SMS present but not displayed !!!
146 Fix : Check has been made before freeing the memory.
147
148 SPR 2260: Merged in bugfixes 1833, 1669, 872,1830, 1828, 2031, and 2007
149 fom the 1.6.3 branch into this file.
150
151 Apr 12, 2004 REF: CRR 13370 Deepa M.D
152 Bug : The Sender name was not displayed properly in the status report.
153 Fix : The sendername had garbage values when the corresponding number was not
154 present in the Phonebook.So when the name was not present, only the number is displayed.
155
156
157
158 */
159
160 #define ENTITY_MFW
161
162 #include <string.h>
163 #include <stdio.h>
164 #include <stdlib.h>
165
166 #if defined (NEW_FRAME)
167
168 #include "typedefs.h"
169 #include "vsi.h"
170 #include "custom.h"
171 #include "gsm.h"
172
173 #else
174
175 #include "STDDEFS.H"
176 #include "custom.h"
177 #include "gsm.h"
178 #include "vsi.h"
179
180 #endif
181
182 #include "cus_aci.h"
183 #include "message.h"
184 #include "prim.h"
185 #include "aci_cmh.h"
186 #include "ksd.h"
187 #include "prim.h"
188 #ifndef PCM_2_FFS
189 #include "pcm.h"
190 #endif
191
192 #ifndef FF_2TO1_PS
193 #include "p_mnsms.val"
194 #endif
195
196 #include "psa.h"
197 #include "psa_sim.h"
198
199 #include "mfw_mfw.h"
200 #include "mfw_nm.h"
201 #include "mfw_sima.h"
202 #include "mfw_nmi.h"
203 #include "mfw_phb.h"
204 #include "mfw_cm.h"
205 #include "mfw_cmi.h"
206 #include "mfw_sim.h"
207 #include "mfw_simi.h"
208 #include "mfw_phbi.h"
209 #include "mfw_sms.h"
210 #include "mfw_smsi.h"
211 #include "mfw_win.h"
212 #include "mfw_cphs.h"
213 #include "mfw_cphsi.h"
214 #include "aci_lst.h"
215 #include "conc_sms.h"
216
217
218 #ifdef SIM_TOOLKIT
219 #include "mfw_sat.h"
220 #endif
221
222 #include <string.h>
223 #include <stdio.h>
224
225 /********* current define *******************************************/
226 /*SPR 2260 added definitions*/
227 #define FIRST_READ_OF_MEMORY_USE 1
228 #define POST_DELETE_CHECK 2
229 // Feb 22, 2006 DR:OMAPS00068268 x0035544
230 //Added the #defines for the bits 7, 6 and 5
231 #define BIT_7 0x80
232 #define BIT_6 0x40
233 #define BIT_5 0x20
234
235 //May 27, 2005 MMI-FIX-29869 x0018858 - Added the #defines
236 #ifdef FF_MMI_SMS_DYNAMIC
237 #define ALLOC_MEMORY mfwAlloc
238 #define FREE_MEMORY mfwFree
239 //May 27, 2005 MMI-FIX-29869 x0018858- Modified from staic array to dynamic memory.
240 T_MFW_SMS_MSG* msg_info = NULL; /* message table */
241
242 //May 27, 2005 MMI-FIX-29869 x0018858 - Added a Checking variable.
243 static int Counter_first = 0;
244 #else
245 static T_MFW_SMS_MSG msg_info[MAX_MESSAGES]; /* message table */
246 #endif
247
248
249 static T_MFW_SMS_MT sms_mt;
250 static T_MFW_SMS_CB sms_cb;
251 static T_MFW_SMS_ID sms_id, sms_id_wait;
252
253 static T_MFW_MEM_INFO memory;
254 static T_MFW_MEM_INFO sim_memory; /*a0393213 OMAPS00109953 - To keep track of sms memory in SIM*/
255 static T_MFW_MEM_INFO ffs_memory; /*a0393213 OMAPS00109953 - To keep track of sms memory in ME*/
256 /*a0393213 OMAPS00109953 - state machine for index retrieval - first retrieve all SIM indexes then all ME indexes*/
257 static T_MFW_SMS_INDEX_RETRIEVE_STATE index_retrieve_state;
258
259 static SHORT status_change_index;
260 /*a0393213 - To store the memory(SIM/ME) where the message, whose status is to be changed, resides*/
261 static T_MFW_SMS_MEM status_change_memory=MFW_MEM_NOTPRESENT;
262
263 static SHORT deleting_index;
264 /*a0393213 OMAPS00109953 - To store the memory where the SMS, which is to be deleted, resides*/
265 static T_MFW_SMS_MEM deleting_memory=MFW_MEM_NOTPRESENT;
266
267 static UBYTE f_update;
268 static UBYTE int_req;
269 static UBYTE smsReady;
270 static UBYTE phbReady;
271 static T_ACI_SMS_STAT sentStatus; /*a0393213 compiler warnings removal - type of sentStatus changed from UBYTE*/
272 static UBYTE sms_update = FALSE;
273
274 static UBYTE coll_sms_send; /* mt sms during send process */
275 static UBYTE coll_sms_read; /* mt sms during read process */
276 static UBYTE coll_sms_delete; /* mt sms during delete process */
277 static UBYTE coll_sms_req; /* mt sms during request process */
278
279 static UBYTE data[30];
280
281 static UBYTE initialising_flag;
282
283 UBYTE sms_type;
284 UBYTE mt_type;
285 UBYTE int_init_req;
286 CHAR *wr_addr;
287 UBYTE Delete_1_2_1_vm_icon=FALSE;
288 UBYTE Display_1_2_1_vm_icon =FALSE;
289 static UBYTE cb_mid[10]; /* cell broadcast message identifier */
290 static UBYTE fg;
291 EXTERN MfwHdr * current_mfw_elem;
292
293 static BOOL cmgr_awaiting_ok = FALSE; // Marcus: Issue 2260: 03/10/2002
294 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
295 static UBYTE sms_wap_sent_flag = FALSE; /* SPR#2086 - SH - TRUE if SMS is sent */
296 #endif
297
298 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
299 // Added this variable to identify voice mail message to be deleted
300 BOOL invalidVm = FALSE;
301
302 //x0pleela 30 Jan, 2006 DR: OMAPS00059261
303 //SMS buffer storage size
304 #define MAX_STAT_MSG_LEN 30
305
306 extern UBYTE reply_path_bit ;
307 /*********************Prototypes****************************************/
308
309 //Feb 22, 2006 DR:OMAPS00068268 x0035544
310 BOOL Sms_Check_PID(SHORT pid);
311 /*SPR2260 added prototype for new function*/
312 /*a0393213 OMAPS00109953 - memory added as new parameter*/
313 BOOL delete_sms_from_table (SHORT index, T_MFW_SMS_MEM memory);
314 //Dec 14, 2005 REF: MMI-FIX-OMAPS00058684 x0035544
315 #ifdef FF_HOMEZONE
316 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858
317 void sms_homezoneCBToggle(U8 Activate_CB);
318 #endif
319 LOCAL T_ACI_SMS_STOR sms_mem_cvt(UBYTE mem);
320 #ifdef FF_MMI_SMS_DYNAMIC
321
322 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
323 int is_alphanumeric_addr(char *dest_addr);
324
325 // May 27, 2005 MMI-FIX-29869 x0018858 - Begin
326 /*
327 +--------------------------------------------------------------------+
328 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
329 | STATE : code ROUTINE : Check_max_sms_allowed |
330 +--------------------------------------------------------------------+
331
332 PURPOSE : Check for the max number of messages that can be stored and aloocate
333 memory accordingly.
334
335 */
336 void Check_max_sms_allowed(void)
337 {
338
339 int i,num, my_count ;
340 T_MFW_SMS_MSG* cpy_msg_info = NULL; /* message table */
341 U8 *MaxTotal;
342
343 if((memory.total > 0) &&( Counter_first == 0))
344 {
345 g_max_messages = memory.total;
346
347 if( msg_info == NULL)
348 {
349 msg_info = (T_MFW_SMS_MSG*)ALLOC_MEMORY(g_max_messages*sizeof(T_MFW_SMS_MSG));
350
351 }
352 Counter_first ++;
353 }
354
355 }
356 // May 27, 2005 MMI-FIX-29869 x0018858 - End
357 #endif
358 /*
359 +--------------------------------------------------------------------+
360 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
361 | STATE : code ROUTINE : sms_init |
362 +--------------------------------------------------------------------+
363
364 PURPOSE : initialize for SMS management
365
366 */
367
368
369 void sms_init(void)
370 {
371 /*a0393213 compiler warnings removal - removed variable i*/
372
373 TRACE_FUNCTION ("sms_init()");
374
375 /* Setting the default SMS parameter */
376 sms_type = MFW_NO_MESSAGE;
377 mt_type = MFW_NO_MESSAGE;
378 status_change_index = 0;
379 deleting_index = 0;
380 /*a0393213 OMAPS00109953 - SMS memory related variables updated*/
381 status_change_memory=MFW_MEM_NOTPRESENT;
382 deleting_memory=MFW_MEM_NOTPRESENT;
383 smsReady = 0;
384 phbReady = 0;
385 sms_id.index = sms_id_wait.index = 0;
386 #if 0
387 for (i=0; i<MAX_MESSAGES; i++)
388 {
389 msg_info[i].index = -1;
390 msg_info[i].addr.number[0] = '\0';
391 msg_info[i].addr.tag[0] = '\0';
392 msg_info[i].addr.ton = MFW_TON_UNKNOWN;
393 msg_info[i].addr.npi = MFW_NPI_UNKNOWN;
394 msg_info[i].first_index = -1; /*SPR 2260*/
395 msg_info[i].concat_status = MFW_SMS_NO_CONC;
396
397 }
398 #endif
399 /* PATCH-6363 VO 30.01.01 */
400 /*a0393213 OMAPS00109953 - SMS memory related variables updated*/
401 /*This member indicates the preferred memory - the memory, which is considered first for saving the incoming messages/drafts*/
402 memory.mem=(UBYTE)MFW_MEM_NOTPRESENT;
403 memory.used=0;
404 memory.total=0;
405 ffs_memory.mem = MFW_MEM_ME;
406 ffs_memory.used = 0;
407 ffs_memory.total = 0;
408 sim_memory.mem = MFW_MEM_SIM;
409 sim_memory.used = 0;
410 sim_memory.total = 0;
411
412 index_retrieve_state=MFW_SMS_INDEX_NOT_RETRIEVED;
413 /* PATCH-6363 end */
414 }
415
416 // x0018858 24 Mar, 2005 MMI-FIX-11321
417 //begin- MMI-FIX-11321
418 /*
419 +--------------------------------------------------------------------+
420 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
421 | STATE : code ROUTINE : sms_set_cind_values |
422 +--------------------------------------------------------------------+
423
424 PURPOSE : Set the Indication parameters.
425
426 */
427
428 T_MFW sms_set_cind_values( T_ACI_MM_CIND_VAL_TYPE *cind_Settings)
429 {
430 if(0 == cind_Settings)
431 return MFW_SMS_FAIL;
432
433
434 if(sAT_PlusCIND(CMD_SRC_LCL,CIND_SIGNAL_INDICATOR_LVL0,CIND_SMSFULL_INDICATOR_MEMFULL)NEQ AT_CMPL)
435 {
436 TRACE_EVENT(" The indication couldnt not be set");
437 return MFW_SMS_FAIL;
438 }
439 return MFW_SMS_OK;
440 }
441
442 /*
443 +--------------------------------------------------------------------+
444 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
445 | STATE : code ROUTINE : sms_set_cmer_values |
446 +--------------------------------------------------------------------+
447
448 PURPOSE : Set the CMER parameters.
449
450 */
451 T_MFW sms_set_cmer_values(T_ACI_MM_CMER_VAL_TYPE *cmer_Settings)
452 {
453 if(0 == cmer_Settings)
454 return MFW_SMS_FAIL;
455
456 // ADDED BY RAVI - ACI CHANGES - 6-10-2005
457 #if (BOARD==61)
458 if(sAT_PlusCMER(CMD_SRC_LCL,CMER_MODE_2,(T_ACI_CMER_KEYP_TYPE)CMER_INDICATOR_2,
459 (T_ACI_CMER_IND_TYPE)CMER_BFR_1, (T_ACI_CMER_BFR_TYPE)0)NEQ AT_CMPL) /* typecast to remove warning Aug - 11 */
460 #else
461 if(sAT_PlusCMER(CMD_SRC_LCL,CMER_MODE_2,CMER_INDICATOR_2,CMER_BFR_1)NEQ AT_CMPL)
462 #endif
463 // END ADDITION RAVI - 6-10-2005
464 {
465 TRACE_EVENT(" The indication couldnt not be set");
466 return MFW_SMS_FAIL;
467 }
468 return MFW_SMS_OK;
469 }
470 //end. - MMI-FIX-11321
471
472 /*
473 +--------------------------------------------------------------------+
474 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
475 | STATE : code ROUTINE : sms_exit |
476 +--------------------------------------------------------------------+
477
478 PURPOSE : initialize for SMS management
479
480 */
481
482 void sms_exit(void)
483 {
484 TRACE_FUNCTION ("sms_exit()");
485 }
486
487 /*
488 +--------------------------------------------------------------------+
489 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
490 | STATE : code ROUTINE : sms_phbReady_ind |
491 +--------------------------------------------------------------------+
492
493 PURPOSE : finished initialize from the SIM card
494
495 */
496
497 void sms_phbReady_ind(void)
498 {
499 if (smsReady)
500 {
501 TRACE_FUNCTION("sms_phbReady_ind");
502
503 f_update = MFW_SMS_NEW;
504 TRACE_EVENT("all free");
505 coll_sms_send = coll_sms_read = coll_sms_delete = coll_sms_req = MFW_SMS_FREE;
506 sms_read_msg_info();
507 smsReady = 0;
508 phbReady = 0;
509 }
510 else
511 phbReady = 1;
512 }
513
514 /*
515 +--------------------------------------------------------------------+
516 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
517 | STATE : code ROUTINE : rAT_sms_ready |
518 +--------------------------------------------------------------------+
519
520 PURPOSE : finished initialize from the SIM card
521
522 */
523
524 void rAT_sms_ready(void)
525 {
526 TRACE_FUNCTION("rAT_sms_ready()");
527
528 if (phbReady)
529 {
530 f_update = MFW_SMS_NEW;
531 sms_read_msg_info();
532 smsReady = 0;
533 phbReady = 0;
534 }
535 else
536 smsReady = 1;
537 }
538
539 /*
540 +--------------------------------------------------------------------+
541 | PROJECT : GSM-F&D (8411) MODULE : MFW_CB |
542 | STATE : code ROUTINE : rAT_SignalSMS |
543 +--------------------------------------------------------------------+
544
545 PURPOSE : handles rAT_SignalSMS call back
546
547 */
548
549 GLOBAL void rAT_SignalSMS ( UBYTE state )
550 {
551 TRACE_FUNCTION("rAT_SignalSMS()");
552 switch (state)
553 {
554 #ifdef FF_2TO1_PS
555 case MNSMS_STATE_INITIALISING: initialising_flag = TRUE; break;
556 case MNSMS_STATE_READY: initialising_flag = FALSE; break;
557 #else
558 case SMS_STATE_INITIALISING: initialising_flag = TRUE; break;
559 case SMS_STATE_READY: initialising_flag = FALSE; break;
560 #endif
561 }
562 }
563
564
565 /*
566 +--------------------------------------------------------------------+
567 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
568 | STATE : code ROUTINE : sms_create |
569 +--------------------------------------------------------------------+
570
571 PURPOSE : create SMS control
572
573 */
574
575 T_MFW_HND sms_create(T_MFW_HND hWin, T_MFW_EVENT event, T_MFW_CB cbfunc)
576 {
577 T_MFW_HDR *hdr;
578 T_MFW_SMS *sms_para;
579 MfwHdr *insert_status =0;
580
581 TRACE_FUNCTION ("sms_create()");
582
583 hdr = (T_MFW_HDR *) mfwAlloc(sizeof(T_MFW_HDR));
584 sms_para = (T_MFW_SMS *) mfwAlloc(sizeof(T_MFW_SMS));
585
586 if (!hdr OR !sms_para)
587 {
588 TRACE_ERROR("ERROR: sms_create() Mem Alloc Failed.");
589
590 if(hdr)
591 mfwFree((U8*)hdr,sizeof(MfwHdr));
592
593 if(sms_para)
594 mfwFree((U8*)sms_para,sizeof(T_MFW_SMS));
595
596 return FALSE;
597 }
598 /* initialisation of the handler */
599 sms_para->emask = event;
600 sms_para->handler = cbfunc;
601
602 hdr->data = sms_para; /* store parameter in node */
603 hdr->type = MFW_TYP_SMS; /* store type of event handler */
604
605 /* installation of the handler */
606
607 insert_status = mfwInsert((T_MFW_HDR *)hWin, hdr);/*SPR 1968, inserted inadvertently deleted function call*/
608
609 if(!insert_status)
610 {
611 TRACE_ERROR("ERROR: sms_create() Failed to Install Handler. ");
612 mfwFree((U8*)hdr,sizeof(MfwHdr));
613 mfwFree((U8*)sms_para,sizeof(T_MFW_SIM));
614 return 0;
615 }
616 return insert_status;
617 }
618
619
620 /*
621 +--------------------------------------------------------------------+
622 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
623 | STATE : code ROUTINE : sms_delete |
624 +--------------------------------------------------------------------+
625
626 PURPOSE : delete SMS control
627
628 */
629
630 T_MFW_RES sms_delete(T_MFW_HND h)
631 {
632 TRACE_FUNCTION ("sms_delete()");
633
634 if (!h OR !((T_MFW_HDR *)h)->data)
635 return MFW_RES_ILL_HND;
636
637 if (!mfwRemove((T_MFW_HDR *) h))
638 return MFW_RES_ILL_HND;
639
640 mfwFree((U8 *)(((T_MFW_HDR *) h)->data),sizeof(T_MFW_SMS));
641 mfwFree((U8 *)h,sizeof(T_MFW_HDR));
642
643 return MFW_RES_OK;
644 }
645
646
647 /*
648 +--------------------------------------------------------------------+
649 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
650 | STATE : code ROUTINE : sms_signal |
651 +--------------------------------------------------------------------+
652
653 PURPOSE : send a event.
654
655 */
656
657 void sms_signal(T_MFW_EVENT event, void * para)
658 {
659 UBYTE temp = dspl_Enable(0);
660 TRACE_FUNCTION ("sms_signal()");
661 if (mfwSignallingMethod EQ 0)
662 {
663 /* focus is on a window */
664 if (mfwFocus)
665 /* send event to sim management handler if available */
666 if (sms_sign_exec (mfwFocus, event, para))
667 {
668 dspl_Enable(temp);
669 return;
670 }
671
672 /* acutal focussed window is not available or has no
673 * network management registration handler, then search
674 * all nodes from the root. */
675 if (mfwRoot)
676 sms_sign_exec (mfwRoot, event, para);
677 }
678 else
679 {
680 MfwHdr * h = 0;
681
682 /*
683 * Focus set, then start here
684 */
685 if (mfwFocus)
686 h = mfwFocus;
687 /*
688 * Focus not set, then start root
689 */
690 if (!h)
691 h = mfwRoot;
692
693 /*
694 * No elements available, return
695 */
696
697 while (h)
698
699
700 {
701 /*
702 * Signal consumed, then return
703 */
704 if (sms_sign_exec (h, event, para))
705 {
706 dspl_Enable(temp);
707 return;
708 }
709
710 /*
711 * All windows tried inclusive root
712 */
713 if (h == mfwRoot)
714 {
715 dspl_Enable(temp);
716 return;
717 }
718
719 /*
720 * get parent window
721 */
722 h = mfwParent(mfwParent(h));
723 if(h)
724 h = ((MfwWin * )(h->data))->elems;
725 }
726 sms_sign_exec (mfwRoot, event, para);
727 }
728 dspl_Enable(temp);
729 return;
730 }
731
732
733 /*
734 +--------------------------------------------------------------------+
735 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
736 | STATE : code ROUTINE : sms_sign_exec |
737 +--------------------------------------------------------------------+
738
739 PURPOSE : Send a signal if there is an SMS management handler.
740
741 */
742
743 BOOL sms_sign_exec (T_MFW_HDR * cur_elem,
744 T_MFW_EVENT event,
745 T_MFW_SMS_PARA * para)
746 {
747 /***************************Go-lite Optimization changes Start***********************/
748 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
749 TRACE_EVENT_P1("sms_sign_exec(): %d", event);
750 /***************************Go-lite Optimization changes end***********************/
751 while (cur_elem)
752 {
753 /* event handler is available */
754 if (cur_elem->type EQ MFW_TYP_SMS)
755 {
756 T_MFW_SMS * sms_data;
757 /* handler is SMS management handler */
758 sms_data = (T_MFW_SMS *)cur_elem->data;
759 if (sms_data->emask & event)
760 {
761 /* event is expected by the call back function */
762 sms_data->event = event;
763 switch (event)
764 {
765 case E_SMS_MO_AVAIL:
766 memcpy (&sms_data->para.index, para, sizeof (UBYTE));
767 break;
768 case E_SMS_CMD_AVAIL:
769 memcpy (&sms_data->para.index, para, sizeof (UBYTE));
770 break;
771 case E_SMS_SAVE_AVAIL:
772 memcpy (&sms_data->para.index, para, sizeof (UBYTE));
773 break;
774 case E_SMS_MT:
775 memcpy (&sms_data->para.sms_mt, para, sizeof (T_MFW_SMS_MT));
776 break;
777 case E_SMS_MO:
778 memcpy (&sms_data->para.sms_mo, para, sizeof (T_MFW_SMS_MO));
779 break;
780 case E_SMS_CB:
781 memcpy (&sms_data->para.sms_cb, para, sizeof (T_MFW_SMS_CB));
782 break;
783 case E_SMS_CB_RECEIVED:
784 memcpy (&sms_data->para.sms_id, para, sizeof (T_MFW_SMS_ID));
785 break;
786 case E_SMS_MT_RECEIVED:
787 memcpy (&sms_data->para.sms_id, para, sizeof (T_MFW_SMS_ID));
788 break;
789 case E_SMS_STATUS:
790 memcpy (&sms_data->para.sms_status, para, sizeof (T_MFW_SMS_STATUS));
791 break;
792 case E_SMS_MEM:
793 memcpy (&sms_data->para.sms_mem, para, sizeof (T_MFW_SMS_MEM_INFO));
794 break;
795 case E_SMS_OK:
796 /*SPR 2653, no need for conditional compilation round if, removing it*/
797 // EF we only copy if non null
798 if (para != NULL)
799 memcpy (&sms_data->para.cmd_ind, para, sizeof (UBYTE));
800 break;
801 case E_SMS_ERR:
802 memcpy (&sms_data->para.cmd_ind, para, sizeof (UBYTE));
803 break;
804 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
805 /* SPR#2086 */
806 case E_SMS_WAP_MT_RECEIVED:
807 memcpy (&sms_data->para.sms_mt, para, sizeof (T_MFW_SMS_MT));
808 break;
809 case E_SMS_WAP_MO_SENT:
810 memcpy (&sms_data->para.index, para, sizeof (UBYTE));
811 break;
812 case E_SMS_WAP_ERR:
813 memcpy (&sms_data->para.index, para, sizeof (UBYTE));
814 break;
815 #endif
816 }
817
818 /* if call back defined, call it */
819 if (sms_data->handler)
820 {
821 // PATCH LE 06.06.00
822 // store current mfw elem
823 current_mfw_elem = cur_elem;
824 // END PATCH LE 06.06.00
825 if ((*(sms_data->handler)) (sms_data->event, (void *)&sms_data->para))
826 {
827 TRACE_EVENT("send SMS event");
828 return TRUE;
829 }
830 }
831 }
832 }
833 cur_elem = cur_elem->next;
834 }
835
836 return FALSE;
837 }
838
839
840 /*
841 +-------------------------------------------------------------------+
842 | PROJECT : GSM-PS (6147) MODULE : MFW_PHB |
843 | STATE : code ROUTINE : sms_read_msg_info |
844 +-------------------------------------------------------------------+
845
846 PURPOSE : This function is used to read total information about SMS.
847 */
848
849 void sms_read_msg_info()
850 {
851 int i;
852
853 TRACE_FUNCTION("sms_read_msg_info()");
854
855 #ifdef FF_MMI_SMS_DYNAMIC
856 for (i=0; i<g_max_messages; i++)
857 #else
858 for (i=0; i<MAX_MESSAGES; i++)
859 #endif
860 {
861 msg_info[i].index = -1;
862 msg_info[i].addr.number[0] = '\0';
863 msg_info[i].addr.tag[0] = '\0';
864 msg_info[i].addr.ton = MFW_TON_UNKNOWN;
865 msg_info[i].addr.npi = MFW_NPI_UNKNOWN;
866 msg_info[i].msg_ref=0;
867 /*a0393213 OMAPS00109953*/
868 msg_info[i].mem=MFW_MEM_NOTPRESENT;
869
870 }
871
872 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGL
873 Retrieve SMS indexes in SIM first*/
874 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
875 {
876 TRACE_ERROR("sms_read_msg_info():Not able to set pref memory");
877 return;
878 }
879
880 f_update = MFW_SMS_NEW;
881 if (sAT_PlusCMGL (CMD_SRC_LCL, SMS_STAT_All,
882 #ifdef FF_2TO1_PS
883 0, (T_ACI_SMS_READ)MNSMS_READ_PREVIEW) NEQ AT_EXCT) /* typecast to remove warning Aug - 11 */
884 #else
885 0, SMS_READ_Preview) NEQ AT_EXCT)/*a0393213 warnings removal-READ_PREVIEW changed to SMS_READ_Preview*/
886 #endif
887 {
888 TRACE_EVENT("sAT_PlusCMGL error");
889 f_update = MFW_SMS_FREE;
890 }
891 else /*a0393213 OMAPS00109953 - update the state machine*/
892 {
893 index_retrieve_state=MFW_SMS_SIM_INDEX_RETRIEVING;
894 }
895 }
896
897
898 /*
899 +--------------------------------------------------------------------+
900 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
901 | STATE : code ROUTINE : rAT_PlusCMGL |
902 +--------------------------------------------------------------------+
903
904 PURPOSE : Response of read SMS list from ACI
905 */
906
907 void rAT_PlusCMGL ( T_ACI_CMGL_SM * smLst )
908 {
909 T_SMS_TYPE received_sms_type;
910 T_CONC_ASSEMBLY_RETURN concatenated_status=CONC_ERR_UNKN;
911 #ifdef TI_PS_FF_CONC_SMS
912 T_SM_DATA_EXT conc_data_ext={NULL,0};
913 #endif /*TI_PS_FF_CONC_SMS*/
914
915 TRACE_FUNCTION ("rAT_PlusCMGL()");
916 /*a0393213 OMAPS00109953 - third parameter added for SMS_getSMSType()*/
917 if(initialising_flag == TRUE)
918 {
919 received_sms_type = SMS_getSMSType( &smLst->udh, smLst->adress, MODE3);
920 }
921 else
922 {
923 received_sms_type = SMS_getSMSType( &smLst->udh, smLst->adress, MODE2);
924 }
925 TRACE_EVENT_P1("SMS Type is = %d", received_sms_type);
926 TRACE_EVENT_P1("SMS message status:%d", smLst->stat);
927
928 #ifdef TI_PS_FF_CONC_SMS
929 if (received_sms_type == CONCATE)
930 {
931 if(initialising_flag == TRUE)
932 {
933 /*a0393213 OMAPS00109953 - memory added as parameter*/
934 concatenated_status =concSMS_Collect(&conc_data_ext, smLst, FALSE, SMS_STOR_NotPresent);
935 }
936 else
937 {
938 /*a0393213 OMAPS00109953*/
939 concatenated_status =concSMS_Collect(&conc_data_ext, smLst, TRUE, sms_mem_cvt(memory.mem));
940 }
941 TRACE_EVENT_P2("conc status: %d, conc length: %d", concatenated_status, conc_data_ext.len);
942
943
944 }
945 // July 27, 2006 DR: OMAPS00085347 x0021334
946 // Free the allocated memory after concatenated SMS has been read.
947 if (concatenated_status EQ CONC_COMPLETED)
948 {
949 if (conc_data_ext.data != NULL)
950 {
951 MFREE (conc_data_ext.data);
952 }
953 }
954 #endif /*TI_PS_FF_CONC_SMS*/
955
956 /*a0393213 OMAPS00109953 - memory added as parameter*/
957 sms_store_new_msg_info(smLst->msg_ref, smLst, TRUE/*MC SPR 2260*/, concatenated_status,received_sms_type,(T_MFW_SMS_MEM)memory.mem);
958
959
960 f_update = MFW_SMS_NEW;
961 {
962 TRACE_EVENT_P4("CMGL Msg table: %d,%d,%d, %d", msg_info[0].index, msg_info[1].index,msg_info[2].index,msg_info[3].index);
963 TRACE_EVENT_P4("CMGL Msg table: %d,%d,%d, %d", msg_info[4].index, msg_info[5].index,msg_info[6].index,msg_info[7].index);
964 }
965 }
966
967
968 /*
969 +--------------------------------------------------------------------+
970 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
971 | STATE : code ROUTINE : sms_update_ready |
972 +--------------------------------------------------------------------+
973
974 PURPOSE : message list update is ready
975 */
976
977 void sms_update_ready(void)
978 {
979 TRACE_FUNCTION("sms_update_ready()");
980
981 sms_signal(E_SMS_MT_RECEIVED, &sms_id);
982 sms_id.index = 0;
983
984 if (memory.used == memory.total)
985 sms_signal(E_SMS_MEM_FULL, 0);
986 }
987
988
989 /*
990 +--------------------------------------------------------------------+
991 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
992 | STATE : code ROUTINE : sms_update_msg_info |
993 +--------------------------------------------------------------------+
994
995 PURPOSE : update the SMS information list
996 */
997
998 void sms_update_msg_info(T_MFW_SMS_STAT stat)
999 {
1000 int i;
1001
1002 TRACE_FUNCTION("sms_update_msg_info()");
1003 #ifdef FF_MMI_SMS_DYNAMIC
1004 for (i=0; i<g_max_messages; i++)
1005 #else
1006 for (i=0; i<MAX_MESSAGES; i++)
1007 #endif
1008 {
1009 if (msg_info[i].index EQ status_change_index &&
1010 msg_info[i].mem EQ status_change_memory) /*a0393213 OMAPS00109953 - memory also taken into consideration*/
1011 {
1012 msg_info[i].stat = stat;
1013 }
1014 }
1015
1016 status_change_index = 0;
1017 /*a0393213 OMAPS00109953 - invalidate the variable*/
1018 status_change_memory=MFW_MEM_NOTPRESENT;
1019 }
1020
1021
1022 /*
1023 +-------------------------------------------------------------------+
1024 | PROJECT : GSM-PS (6147) MODULE : MFW_PHB |
1025 | STATE : code ROUTINE : sms_mem_cvt |
1026 +-------------------------------------------------------------------+
1027
1028 PURPOSE : This function is used to convert the type of memory
1029 used by MFW to the type of memory used by ACI.
1030 */
1031 LOCAL T_ACI_SMS_STOR sms_mem_cvt(UBYTE mem)
1032 {
1033 switch ( mem )
1034 {
1035 case ( MFW_MEM_ME ): return SMS_STOR_Me;
1036 case ( MFW_MEM_SIM ): return SMS_STOR_Sm;
1037 default: return SMS_STOR_NotPresent;
1038 }
1039 }
1040
1041
1042 /*
1043 +--------------------------------------------------------------------+
1044 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1045 | STATE : code ROUTINE : sms_set_mt_ind |
1046 +--------------------------------------------------------------------+
1047
1048 PURPOSE : MMI selects, how the receiving of new messages
1049 from the network is indicated.
1050
1051 */
1052
1053 void sms_set_mt_ind(T_MFW_SMS_MT_IND mt_ind)
1054 {
1055 T_ACI_RETURN ret = AT_CMPL;
1056 TRACE_FUNCTION("sms_set_mt_ind()");
1057
1058 switch (mt_ind)
1059 {
1060 case MT_IND_IDX:
1061 TRACE_EVENT("MT_IND_IDX");
1062 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1063 CNMI_MT_SmsDeliverInd,
1064 CNMI_BM_NotPresent,
1065 CNMI_DS_SmsStatRpt );
1066 break;
1067
1068 case MT_IND_MSG:
1069 TRACE_EVENT("MT_IND_MSG");
1070 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1071 CNMI_MT_SmsDeliver,
1072 CNMI_BM_NotPresent,
1073 CNMI_DS_SmsStatRpt );
1074 break;
1075
1076 case MT_IND_NO_IDX:
1077 TRACE_EVENT("MT_IND_NO_IDX");
1078 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1079 CNMI_MT_NoSmsDeliverInd,
1080 CNMI_BM_NotPresent,
1081 CNMI_DS_SmsStatRpt );
1082 break;
1083
1084 case MT_CB_IDX:
1085 TRACE_EVENT("MT_CB_IDX");
1086 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1087 CNMI_MT_NotPresent,
1088 CNMI_BM_CbmInd,
1089 CNMI_DS_NotPresent );
1090 break;
1091
1092 case MT_CB_MSG:
1093 TRACE_EVENT("MT_CB_MSG");
1094 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1095 CNMI_MT_NotPresent,
1096 CNMI_BM_Cbm,
1097 CNMI_DS_NotPresent );
1098 break;
1099
1100 case MT_CB_NO_IDX:
1101 TRACE_EVENT("MT_CB_NO_IDX");
1102 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1103 CNMI_MT_NotPresent,
1104 CNMI_BM_NoCbmInd,
1105 CNMI_DS_NotPresent );
1106 break;
1107
1108 /* Marcus: Issue 1170: 07/10/2002: Start */
1109 case MT_IND_SRR_ON:
1110 TRACE_EVENT("MT_IND_SRR_ON");
1111 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1112 CNMI_MT_NotPresent, /*a0393213 compiler warnings removal - CNMI_BM_NotPresent changed to CNMI_MT_NotPresent*/
1113 CNMI_BM_NotPresent,
1114 CNMI_DS_SmsStatRpt );
1115 break;
1116
1117 case MT_IND_SRR_OFF:
1118 TRACE_EVENT("MT_IND_SRR_OFF");
1119 ret = sAT_PlusCNMI ( CMD_SRC_LCL,
1120 CNMI_MT_NotPresent, /*a0393213 compiler warnings removal - CNMI_BM_NotPresent changed to CNMI_MT_NotPresent*/
1121 CNMI_BM_NotPresent,
1122 CNMI_DS_NoSmsStatRpt );
1123 break;
1124 /* Marcus: Issue 1170: 07/10/2002: End */
1125
1126 default:
1127 TRACE_EVENT_P1("default: mt_ind = %d", mt_ind);
1128 break;
1129 }
1130
1131 if (ret != AT_CMPL)
1132 TRACE_EVENT_P1("sAT_PlusCNMI: %d", ret);
1133 }
1134
1135
1136
1137
1138 /*
1139 +-------------------------------------------------------------------------+
1140 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1141 | STATE : code ROUTINE : sms_change_read_status |
1142 +-------------------------------------------------------------------------+
1143
1144 PURPOSE : Change SMS status from MFW_SMS_UNREAD to MFW_SMS_READ
1145
1146 GW-SPR#779-Modified code to abort if status has already been updated or if no match is found
1147
1148 */
1149 /*a0393213 OMAPS00109953 - memory added as parameter*/
1150 T_MFW sms_change_read_status(SHORT index, T_MFW_SMS_MEM sms_memory)
1151 {
1152 SHORT i;
1153 //UBYTE fg;
1154 T_ACI_RETURN ret;
1155 TRACE_FUNCTION("sms_change_read_status()");
1156
1157 fg = 0;
1158 #ifdef FF_MMI_SMS_DYNAMIC
1159 for (i=0; i<g_max_messages; i++)
1160 #else
1161 for (i=0; i<MAX_MESSAGES; i++)
1162 #endif
1163 {
1164 /*a0393213 OMAPS00109953 - memory also taken into consideration*/
1165 if (msg_info[i].index == index && msg_info[i].mem == sms_memory)
1166 {
1167 if ((msg_info[i].stat == MFW_SMS_UNREAD) ||
1168 (msg_info[i].stat == MFW_SMS_STOR_UNSENT))
1169 {
1170 fg = 1;
1171 }
1172 else
1173 {
1174 /* status is not unread/unsent - no need to change it*/
1175 return (1);
1176 }
1177 /* Stop search as soon as the index matches */
1178 break;
1179 }
1180 }
1181
1182 /* This change is no completely right, because the SIM will be always updated,
1183 but it makes possible that the read message doesn't come up as new every time
1184 that the mobile is switched on.
1185 GW - Replaced code that returns if no match is found
1186 */
1187
1188 if (!fg)
1189 {
1190 TRACE_EVENT("sms_change_read_status No index match-ERROR");
1191 return 0;
1192 }
1193
1194 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGR*/
1195 if(sms_set_pref_memory(sms_memory)!=MFW_SMS_OK)
1196 {
1197 TRACE_ERROR("sms_change_read_status():Not able to set pref memory");
1198 return 0;
1199 }
1200
1201 sms_type = MFW_NO_MESSAGE;/* SPR 2260 Don't do anything scary in rAT_PlusCMGR callback func*/
1202 /*CONQUEST 5991- MC- Changed third parameter in function call*/
1203 ret = sAT_PlusCMGR(CMD_SRC_LCL, (UBYTE)index, SMS_READ_StatusChange);
1204
1205 if (ret NEQ AT_CMPL AND ret NEQ AT_EXCT)
1206 {
1207 TRACE_EVENT("sms_change_read_status ERROR");
1208 fg = 0;
1209 return 0;
1210 }
1211 /*CONQUEST 5991- MC- Added line to set current message to "read" status*/
1212 #ifdef FF_MMI_SMS_DYNAMIC /*a0393213 lint warnings removal - Possible access of out-of-bounds pointer*/
1213 if(i<g_max_messages)
1214 #else
1215 if(i<MAX_MESSAGES)
1216 #endif
1217 {
1218 if ( msg_info[i].stat == MFW_SMS_STOR_UNSENT)
1219 msg_info[i].stat = MFW_SMS_STOR_SENT;
1220 else
1221 msg_info[i].stat = MFW_SMS_READ;//MC
1222 }
1223 status_change_index = index;
1224 /*a0393213 OMAPS00109953 - set the global variable*/
1225 status_change_memory = sms_memory;
1226 return 1;
1227 }
1228
1229
1230 /*
1231 +--------------------------------------------------------------------+
1232 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1233 | STATE : code ROUTINE : sms_submit |
1234 +--------------------------------------------------------------------+
1235
1236 PURPOSE : Send a mobile originated short massage.
1237
1238 GW 09/10/01 - Modified code to always copy entire (possible) message length
1239 */
1240
1241 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1242 /* NM, 27.5.04
1243
1244 the sms_submit function with the parameters : addr_type and sca
1245 has been taken out as it does not send SMS ?!
1246
1247 */
1248 #endif
1249
1250 #ifdef NO_ASCIIZ
1251 T_MFW sms_submit(T_MFW_SMS_MO_TYPE type,
1252 CHAR *dest_addr,
1253 UBYTE *msg,
1254 USHORT msg_len,
1255 CHAR *sca)
1256 #else
1257 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1258 T_MFW sms_submit(T_MFW_SMS_MO_TYPE type,
1259 CHAR *dest_addr,
1260 T_MFW_PHB_TON addr_type,
1261 UBYTE *msg,
1262 USHORT msg_len,
1263 CHAR *sca,
1264 T_MFW_PHB_TON sc_type)
1265 #else
1266 T_MFW sms_submit(T_MFW_SMS_MO_TYPE type,
1267 CHAR *dest_addr,
1268
1269 UBYTE *msg,
1270 USHORT msg_len,
1271 CHAR *sca)
1272 // sbh - added length to the above definition, since '@' characters stored as NULL & will stop
1273 // strlen from working properly.
1274
1275 #endif
1276 #endif
1277 {
1278 #ifdef TI_PS_FF_CONC_SMS
1279 T_SM_DATA_EXT conc_data_ext;
1280 #else /*TI_PS_FF_CONC_SMS*/
1281 T_ACI_SM_DATA conc_data_ext;
1282 #endif /*TI_PS_FF_CONC_SMS*/
1283
1284 SHORT rp;
1285 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1286 T_ACI_TOA toa;
1287 T_ACI_TOA tosca;
1288 #endif
1289 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
1290 T_ACI_TOA set_toa;
1291 int addr_type;
1292 T_ACI_RETURN ACI_MFW_return;
1293
1294 TRACE_FUNCTION ("sms_submit()");
1295 //March 2, 2005 REF: CRR 11536 x0018858
1296 //Modified the condition for setting the reply path.
1297 if (reply_path_bit ==1)
1298 {
1299 rp = 1; /* reply path = 0 */
1300 }
1301 else
1302 {
1303 rp = 0; /* reply path = default */
1304 }
1305
1306 #ifdef TI_PS_FF_CONC_SMS
1307 conc_data_ext.data = msg;
1308 conc_data_ext.len = msg_len;
1309 #else /*TI_PS_FF_CONC_SMS*/
1310 conc_data_ext.len = (UBYTE)msg_len;
1311 memcpy(conc_data_ext.data, msg, conc_data_ext.len);
1312 #endif /*TI_PS_FF_CONC_SMS*/
1313
1314 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1315 //NM toa.ton = phb_ncvtTon(addr_type);
1316 //NM toa.npi = NPI_IsdnTelephony;
1317 //NM tosca.ton = phb_ncvtTon(sc_type);
1318 //NM tosca.npi = NPI_IsdnTelephony;
1319 #endif
1320
1321 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
1322 //setting type of address.
1323 addr_type = is_alphanumeric_addr(dest_addr);
1324
1325
1326 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
1327 //sending toa instead of NULL
1328 if ( addr_type == TRUE )
1329 {
1330 set_toa.ton = TON_Alphanumeric;
1331 set_toa.npi = NPI_NotPresent;
1332 ACI_MFW_return = sAT_PlusCMGS(CMD_SRC_LCL, dest_addr, &set_toa, &conc_data_ext, sca, NULL, rp);
1333
1334 }
1335 else
1336 ACI_MFW_return = sAT_PlusCMGS(CMD_SRC_LCL, dest_addr, NULL, &conc_data_ext, sca, NULL, rp);
1337
1338 if(ACI_MFW_return != AT_EXCT)
1339 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1340 //NM if (sAT_PlusCMGS(CMD_SRC_LCL, dest_addr, &toa, &conc_data_ext, sca, &tosca, rp) NEQ AT_EXCT)
1341 #endif
1342 return MFW_SMS_FAIL;
1343 return MFW_SMS_OK;
1344
1345 }
1346
1347 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1348
1349
1350 /*
1351 +--------------------------------------------------------------------+
1352 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1353 | STATE : code ROUTINE : sms_submit |
1354 +--------------------------------------------------------------------+
1355
1356 PURPOSE : Send a mobile originated short message for WAP.
1357 - Sets a flag so that success or failure of send can be reported
1358 to MMI.
1359 */
1360 T_MFW sms_submit_wap_sms(T_MFW_SMS_MO_TYPE type,
1361 CHAR *dest_addr,
1362 T_MFW_PHB_TON addr_type,
1363 UBYTE *msg,
1364 USHORT msg_len,
1365 CHAR *sca,
1366 T_MFW_PHB_TON sc_type)
1367 {
1368 TRACE_FUNCTION ("sms_submit_wap_sms()");
1369
1370 sms_wap_sent_flag = TRUE;
1371
1372 /* NM, 27.5.04
1373
1374 the sms_submit function with the parameters : addr_type and sca
1375 has been taken out as it does not send SMS ?!
1376
1377 */
1378
1379 //NM return sms_submit(type, dest_addr, addr_type, msg, msg_len, sca, sc_type);
1380 }
1381
1382 #endif /* #if defined (FF_WAP) && defined (FF_GPF_TCPIP) */
1383
1384 /*
1385 +--------------------------------------------------------------------+
1386 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1387 | STATE : code ROUTINE : sms_stored_submit |
1388 +--------------------------------------------------------------------+
1389
1390 PURPOSE : Send a stored mobile originated short massage.
1391
1392 */
1393
1394 T_MFW sms_stored_submit(CHAR *dest_addr, UBYTE index)
1395 {
1396 TRACE_FUNCTION ("sms_stored_submit()");
1397
1398 if (sAT_PlusCMSS(CMD_SRC_LCL, index, dest_addr, NULL) NEQ AT_EXCT)
1399 {
1400 return MFW_SMS_FAIL;
1401 }
1402 return MFW_SMS_OK;
1403 }
1404
1405
1406 /*
1407 +--------------------------------------------------------------------+
1408 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1409 | STATE : code ROUTINE : rAT_PlusCMSS |
1410 +--------------------------------------------------------------------+
1411
1412 PURPOSE : Response of Send a stored mobile originated
1413 short massage.
1414
1415 */
1416
1417 void rAT_PlusCMSS (UBYTE mr, UBYTE numSeg)
1418 {
1419 TRACE_FUNCTION ("rAT_PlusCMSS()");
1420
1421 sms_update_msg_info(MFW_SMS_STOR_SENT);
1422 sms_signal(E_SMS_MO_AVAIL, &mr);
1423
1424 }
1425
1426
1427 /*
1428 +--------------------------------------------------------------------+
1429 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1430 | STATE : code ROUTINE : rAT_PlusCMT |
1431 +--------------------------------------------------------------------+
1432
1433 PURPOSE : Receive a new short message.
1434
1435 */
1436
1437 void rAT_PlusCMT(T_ACI_CMGL_SM* sm)
1438 { T_SMS_TYPE received_sms_type;
1439 T_CONC_ASSEMBLY_RETURN concatenated_status;
1440 #ifdef TI_PS_FF_CONC_SMS
1441 T_SM_DATA_EXT conc_data_ext;
1442 #endif /*TI_PS_FF_CONC_SMS*/
1443 int i;
1444 TRACE_FUNCTION ("rAT_PlusCMT()");
1445
1446 TRACE_EVENT_P1("CMT, sm->data.len: %d", sm->data.len);
1447 /*a0393213 OMAPS00109953 - new parameter added for SMS_getSMSType()*/
1448 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE1);
1449
1450 #ifdef TI_PS_FF_CONC_SMS
1451 if (received_sms_type == CONCATE)
1452 {
1453 /*a0393213 OMAPS00109953 - memory added as parameter*/
1454 concatenated_status =concSMS_Collect(&conc_data_ext, sm, FALSE, SMS_STOR_NotPresent);
1455 TRACE_EVENT_P2("conc status: %d, conc length: %d", concatenated_status, conc_data_ext.len);
1456 for(i=0;i<conc_data_ext.len;i++)
1457 {
1458 TRACE_EVENT_P2("%02x, %c", conc_data_ext.data[i],conc_data_ext.data[i]);
1459 }
1460 switch (concatenated_status)
1461 {
1462 case CONC_ERR_UNKN:
1463 TRACE_EVENT("Concatenated SMS error");break;
1464 case CONC_ERR_BUF_FULL:
1465 TRACE_EVENT("Concatented SMS buffer Full Error");break;
1466 case CONC_CONTINUED: //not last SMS
1467 TRACE_EVENT("Concatenated Continued!");
1468 break;
1469 case CONC_COMPLETED:
1470 {
1471 TRACE_EVENT("COncatenation Completed!");
1472 memset(&sms_mt, 0, sizeof(sms_mt));
1473
1474 #ifdef NO_ASCIIZ
1475 memcpy(sms_mt.orig_addr.tag,
1476 sm->alpha.data,
1477 sm->alpha.len);
1478 sms_mt.orig_addr.len = sm->alpha.len;
1479 #else
1480 phb_Alpha2Gsm(sm->alpha, (UBYTE *)sms_mt.orig_addr.tag);
1481 #endif
1482 strcpy(sms_mt.orig_addr.number, sm->adress);
1483 sms_mt.orig_addr.ton =
1484 phb_cvtTon(sm->toa.ton);
1485 sms_mt.orig_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
1486 if (sm->tosca.ton == TON_International)
1487 sprintf(sms_mt.sc_addr, "+%s", sm->sca);
1488 else
1489 strcpy(sms_mt.sc_addr, sm->sca);
1490 sms_mt.prot_id = (UBYTE)sm->pid;
1491 sms_mt.dcs = (UBYTE)sm->dcs & 0xFC; /* Ignore message class */
1492
1493 sms_mt.rp = sm->fo >> 7 & 1;
1494
1495 /* SBH */
1496 if (sm->dcs & 0x10) /* Bit 5 indicates that we should get message class from bits 0 & 1 */
1497 {
1498 sms_mt.ti = sm->dcs & 3;
1499 }
1500 else /* Otherwise, set to default value */
1501 {
1502 sms_mt.ti = 1;
1503 }
1504 TRACE_EVENT_P2("dcs: %d, ti: %d", sms_mt.dcs, sms_mt.ti);
1505 /* SBH end */
1506
1507 memcpy((char *)sms_mt.sctp.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
1508 memcpy((char *)sms_mt.sctp.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
1509 memcpy((char *)sms_mt.sctp.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
1510 memcpy((char *)sms_mt.sctp.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
1511 memcpy((char *)sms_mt.sctp.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
1512 memcpy((char *)sms_mt.sctp.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
1513 sms_mt.sctp.timezone = sm->scts.timezone;
1514
1515 /* copy length of whole concat SMS*/
1516 sms_mt.msg_len = conc_data_ext.len;
1517 memset(sms_mt.sms_msg, 0, sm->data.len);
1518 /*copy all data from concat SMS*/
1519 memcpy(sms_mt.sms_msg, (char*)conc_data_ext.data, conc_data_ext.len);
1520 sms_mt.udh_len = sm->udh.len;
1521 memcpy((char *)sms_mt.udh, (char *)sm->udh.data, sm->udh.len);
1522
1523 /*SPR#1408 - DS - Now done at end of function
1524 *sms_signal(E_SMS_MT, &sms_mt);
1525 */
1526
1527 }
1528
1529 }
1530 }
1531 else
1532 #endif /*TI_PS_FF_CONC_SMS*/
1533 {
1534
1535
1536 memset(&sms_mt, 0, sizeof(sms_mt));
1537
1538 #ifdef NO_ASCIIZ
1539 memcpy(sms_mt.orig_addr.tag,
1540 sm->alpha.data,
1541 sm->alpha.len);
1542 sms_mt.orig_addr.len = sm->alpha.len;
1543 #else
1544 phb_Alpha2Gsm(sm->alpha, (UBYTE *)sms_mt.orig_addr.tag);
1545 #endif
1546 strcpy(sms_mt.orig_addr.number, sm->adress);
1547 sms_mt.orig_addr.ton =
1548 phb_cvtTon(sm->toa.ton);
1549 sms_mt.orig_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
1550 if (sm->tosca.ton == TON_International)
1551 sprintf(sms_mt.sc_addr, "+%s", sm->sca);
1552 else
1553 strcpy(sms_mt.sc_addr, sm->sca);
1554 sms_mt.prot_id = (UBYTE)sm->pid;
1555 sms_mt.dcs = (UBYTE)sm->dcs & 0xFC; /* Ignore message class */
1556 sms_mt.rp = sm->fo >> 7 & 1;
1557 /* PATCH JPS 04.10 END */
1558
1559 /* SBH */
1560 if (sm->dcs & 0x10) /* Bit 5 indicates that we should get message class from bits 0 & 1 */
1561 {
1562 sms_mt.ti = sm->dcs & 3;
1563 }
1564 else /* Otherwise, set to default value */
1565 {
1566 sms_mt.ti = 1;
1567 }
1568 TRACE_EVENT_P2("dcs: %d, ti: %d", sms_mt.dcs, sms_mt.ti);
1569 /* SBH end */
1570
1571 memcpy((char *)sms_mt.sctp.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
1572 memcpy((char *)sms_mt.sctp.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
1573 memcpy((char *)sms_mt.sctp.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
1574 memcpy((char *)sms_mt.sctp.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
1575 memcpy((char *)sms_mt.sctp.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
1576 memcpy((char *)sms_mt.sctp.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
1577 sms_mt.sctp.timezone = sm->scts.timezone;
1578
1579 sms_mt.msg_len = sm->data.len;
1580 memcpy(sms_mt.sms_msg, (char *)sm->data.data, sm->data.len);
1581 sms_mt.udh_len = sm->udh.len;
1582 memcpy((char *)sms_mt.udh, (char *)sm->udh.data, sm->udh.len);
1583
1584 /*SPR#1408 - DS - Now done at end of function
1585 *sms_signal(E_SMS_MT, &sms_mt);
1586 */
1587 }
1588
1589 /*MC SPR 1364, need to call this function to update CPHS voicemail data*/
1590 /*SPR#1408 - DS - Modified to store voicemail status in SMS structure. Port of 1669 */
1591 if (sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
1592 &sm->toa, &sm->udh) == MFW_SMS_VOICE)
1593 {
1594 sms_mt.voicemail = TRUE;
1595 TRACE_EVENT("MT SMS is a voicemail message");
1596 }
1597 else
1598 {
1599 sms_mt.voicemail = FALSE;
1600 }
1601 sms_signal(E_SMS_MT, &sms_mt);
1602
1603 }
1604
1605 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1606 #define SMS_PUSH_PDU_OFFSET 1
1607 #define PUSH_METHOD_PDU 0x06
1608
1609 static UBYTE *MMS_pdu=NULL;
1610 static UBYTE id_no,seq_no;
1611 static int pdu_len;
1612
1613 void redirectMMSNotification(T_ACI_CMGL_SM * sm)
1614 {
1615 int header_len;
1616 char buf[80];
1617 int idx;
1618
1619 TRACE_FUNCTION ("redirectMMSNotification()");
1620
1621 if(MMS_pdu)
1622 {
1623 if(id_no!=sm->udh.data[8] || sm->udh.data[10]!=2) /*had lost packet*/
1624 {
1625 TRACE_EVENT("-----MMS_pdu something------");
1626 mfwFree(MMS_pdu,MAX_SM_LEN<<1);
1627 MMS_pdu=NULL;
1628 }
1629 else
1630 {
1631 memcpy(MMS_pdu+pdu_len, sm->data.data, sm->data.len);
1632
1633 TRACE_EVENT("Second SMS been recorded");
1634 TRACE_EVENT_P3("bgein=%x,end=%x,len=%d",MMS_pdu[pdu_len],MMS_pdu[pdu_len+sm->data.len-1],sm->data.len);
1635
1636 pdu_len+=(sm->data.len);
1637
1638 /*deliver PDU to WAP*/
1639 TRACE_EVENT("Deliver PDU to WAP");
1640
1641 /* MWSmsNotification.data=MMS_pdu;
1642 MWSmsNotification.data_length=pdu_len;
1643 M_MMS_WAP_SMS_NOTIFICATION_IND(&MWSmsNotification);
1644 */
1645 //WMPush.data=MMS_pdu;
1646 //WMPush.data_length=pdu_len;
1647 //WMPush.is_sms_bearer=TRUE;
1648 //M_WAP_MMS_PUSH_IND(&WMPush);
1649
1650 //////////////////////////////////////////////////////////////////
1651 //////////////////////////////////////////////////////////////////
1652
1653 mfwFree(MMS_pdu,MAX_SM_LEN<<1);
1654 MMS_pdu=NULL;
1655 return;
1656 }
1657 }
1658
1659 id_no=sm->udh.data[8];
1660 seq_no=sm->udh.data[10];
1661
1662 if(seq_no!=1){
1663 return;
1664 }
1665
1666 /*identify pdu*/
1667 if(sm->data.data[SMS_PUSH_PDU_OFFSET]!=PUSH_METHOD_PDU){
1668 return;
1669 }
1670
1671 if(!(MMS_pdu=mfwAlloc(MAX_SM_LEN<<1)))
1672 return;
1673
1674 header_len=sm->data.data[SMS_PUSH_PDU_OFFSET+1];
1675
1676 pdu_len=sm->data.len-(header_len+1)-(SMS_PUSH_PDU_OFFSET+1);
1677 memcpy(MMS_pdu,sm->data.data+SMS_PUSH_PDU_OFFSET+2+header_len,pdu_len);
1678
1679 TRACE_EVENT("First SMS been recorded");
1680 TRACE_EVENT_P3("bgein=%x,end=%x,len=%d",MMS_pdu[0],MMS_pdu[pdu_len-1],pdu_len);
1681 }
1682
1683
1684 #endif /* #if defined (FF_WAP) && defined (FF_GPF_TCPIP) */
1685 /*
1686 +--------------------------------------------------------------------+
1687 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1688 | STATE : code ROUTINE : rAT_PlusCMTI |
1689 +--------------------------------------------------------------------+
1690
1691 PURPOSE : Receive a new short message identifier.
1692
1693 */
1694 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1695 #else
1696 void rAT_PlusCMTI(T_ACI_SMS_STOR mem, UBYTE index, T_ACI_CMGL_SM* sm)
1697 {
1698 /* MZ 2260 Handset displays Message Full on receiving an SMS. */
1699 //T_MFW_MEM_INFO memory;
1700 #ifndef MMI_LITE
1701 // T_ACI_RETURN ret; // RAVI
1702 // int i, j; // RAVI
1703 #endif
1704 T_SMS_TYPE received_sms_type;
1705 T_CONC_ASSEMBLY_RETURN concatenated_status=CONC_ERR_UNKN;
1706 #ifdef TI_PS_FF_CONC_SMS
1707 T_SM_DATA_EXT conc_data_ext={NULL,0};
1708 #endif /*TI_PS_FF_CONC_SMS*/
1709
1710 if (initialising_flag == FALSE)
1711 {
1712 /* Ignore CMTI if initialising */
1713
1714
1715 TRACE_FUNCTION ("rAT_PlusCMTI()");
1716 TRACE_EVENT_P1("f_update is = % in CMTI", f_update);
1717
1718 /*a0393213 OMAPS00109953 - new parameter added to SMS_getSMSType()*/
1719 if(initialising_flag == TRUE)
1720 {
1721 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE3);
1722 }
1723 else
1724 {
1725 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE2);
1726 }
1727 TRACE_EVENT_P1("SMS Type is = %d", received_sms_type);
1728 TRACE_EVENT_P2("msg_ref: %d, index: %d", sm->msg_ref, index);
1729
1730 #ifdef TI_PS_FF_CONC_SMS
1731 if (received_sms_type == CONCATE)
1732 {
1733 if(initialising_flag == TRUE)
1734 {
1735 /*a0393213 OMAPS00109953 - memory added as parameter*/
1736 concatenated_status =concSMS_Collect(&conc_data_ext, sm, FALSE, SMS_STOR_NotPresent);
1737 }
1738 else
1739 {
1740 /*a0393213 OMAPS00109953*/
1741 concatenated_status =concSMS_Collect(&conc_data_ext, sm, TRUE, mem);
1742 }
1743 TRACE_EVENT_P2("conc status: %d, conc length: %d", concatenated_status, conc_data_ext.len);
1744 }
1745 // July 7, 2005 REF: CRR MMI-SPR-32179 x0018858
1746 // Added a check to free the variable only when CONC_COMPLETED status is encountered.
1747 if (concatenated_status EQ CONC_COMPLETED)
1748 {
1749 if(conc_data_ext.data != NULL)
1750 {
1751 MFREE(conc_data_ext.data);
1752 }
1753 }
1754 #else /*TI_PS_FF_CONC_SMS*/
1755 concatenated_status = CONC_ERR_UNKN;
1756 #endif /*TI_PS_FF_CONC_SMS*/
1757 sms_store_new_msg_info(index,sm,TRUE, concatenated_status, received_sms_type, (T_MFW_SMS_MEM)mem);
1758
1759 if (f_update EQ MFW_SMS_UPDATE OR
1760 coll_sms_send EQ MFW_SMS_WAIT OR
1761 coll_sms_read EQ MFW_SMS_WAIT OR
1762 coll_sms_delete EQ MFW_SMS_WAIT OR
1763 coll_sms_req EQ MFW_SMS_WAIT)
1764 {
1765 if (sms_id_wait.index <= 0)
1766 {
1767 sms_id_wait.index = index;
1768 sms_id_wait.mem = (mem EQ SMS_STOR_Me)? MFW_MEM_ME: MFW_MEM_SIM;
1769 sms_id_wait.concat_status = concatenated_status;
1770 sms_id_wait.received_sms_type = received_sms_type;
1771 }
1772 else
1773 {
1774 TRACE_EVENT("Indication Overrun");
1775 }
1776 f_update = MFW_SMS_UPDATE;
1777 }
1778 else
1779 {
1780 sms_send_new_msg_ind(sm,index, mem, received_sms_type, concatenated_status);
1781 }
1782 f_update = MFW_SMS_FREE;
1783 if(memory.total == memory.used)
1784 {
1785 TRACE_EVENT_P2("memory used is = %d, of %d", memory.used, memory.total);
1786 sms_signal(E_SMS_MEM_FULL, NULL);
1787 }
1788 }
1789 if(msg_info != NULL)
1790 {
1791 TRACE_EVENT_P4("CMTI Msg table: %d,%d,%d, %d", msg_info[0].index, msg_info[1].index,msg_info[2].index,msg_info[3].index);
1792 TRACE_EVENT_P4("CMTI Msg table: %d,%d,%d, %d", msg_info[4].index, msg_info[5].index,msg_info[6].index,msg_info[7].index);
1793 }
1794 /*MC SPR 1364, need to call this function to update CPHS voicemail data*/
1795 sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
1796 &sm->toa, &sm->udh);
1797 /*SPR 2260, this is already called in sms_store_new_msg_info, BUT we need it in for initialisation*/
1798 }
1799 #endif
1800
1801
1802 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
1803 //TISHMMS Project
1804 /*
1805 use UDH data to caculate destinator port and originator port id if any
1806 If not port id, the out put id will be 0
1807 */
1808 void sms_getPortId(UBYTE* data, UBYTE length, USHORT * destinatorPort, USHORT *originatorPort)
1809 {
1810 UBYTE ucOffset = 0;
1811 USHORT usTempOffset;
1812 UBYTE i;
1813
1814 *destinatorPort = 0;
1815 *originatorPort = 0;
1816
1817 if (length == 0)
1818 {
1819 return;
1820 }
1821
1822 for (i = 0 ; i < 47; i++)//140/3=47
1823 {
1824 /*3GPP protocal 23040 clause 9.2.3.24*/
1825 //0x05 the IE is port id, length should be 4
1826 if ((data[ucOffset] == 0x05) && (data[ucOffset + 1] == 4))
1827 {
1828 *destinatorPort = data[ucOffset + 3] + data[ucOffset + 2]*0x100;
1829 *originatorPort = data[ucOffset + 5] + data[ucOffset + 4]*0x100;
1830 //do not return here because the last is the valid one
1831 }
1832 else
1833 {
1834 usTempOffset = ucOffset + data[ucOffset + 1] + 2;
1835
1836 //port information 6 bytes
1837 if (((usTempOffset + 6) > MAX_SM_LEN) ||((usTempOffset + 6) > length))
1838 {
1839 break;
1840 }
1841
1842 ucOffset = usTempOffset;
1843 }
1844 }
1845
1846 return;
1847 }
1848
1849
1850 /*
1851 Search in UDH data to see if it is a EMS SMS
1852 */
1853 BOOL sms_is_ems_type(UBYTE* UdhData, UBYTE UdhLength)
1854 {
1855 BOOL Ret = FALSE;
1856 UBYTE ucOffset = 0;
1857 USHORT usTempOffset;
1858
1859 UBYTE i;
1860
1861 if (UdhLength == 0)
1862 {
1863 return Ret;
1864 }
1865
1866 for (i = 0 ; i < 47; i++)
1867 {
1868 /*3GPP protocal 23040 clause 9.2.3.24*/
1869 if ( (UdhData[ucOffset] >= 0X0A) && (UdhData[ucOffset] <= 0X1F) )
1870 {
1871 if ( (UdhData[ucOffset] >= 0X1B) && (UdhData[ucOffset] <= 0X1F) )
1872 {
1873 //xmzhou_trace_string_value("sms_is_ems_type Reserved for future EMS features: ", UdhData[ucOffset]);
1874 }
1875
1876 Ret = TRUE;
1877 break;
1878 }
1879 else
1880 {
1881 usTempOffset = ucOffset + UdhData[ucOffset + 1] + 2;
1882
1883 if ((usTempOffset >= MAX_SM_LEN) ||(usTempOffset >= UdhLength))
1884 {
1885 break;
1886 }
1887
1888 ucOffset = usTempOffset;
1889 }
1890 }
1891
1892 return Ret;
1893 }
1894
1895 //TISHMMS Project
1896 T_MNSMS_MESSAGE_IND gTpduData;
1897 void rAT_PlusCMTPdu (T_MNSMS_MESSAGE_IND* pTpdu)
1898 {
1899 //xmzhou_trace_string("rAT_PlusCMTPdu called");
1900 memcpy(&gTpduData, pTpdu, sizeof(T_MNSMS_MESSAGE_IND));
1901 return;
1902 }
1903
1904
1905
1906 #if defined (FF_MMI_MMS) || defined (FF_MMI_EMS)
1907 EXTERN void sms_save_to_m4(U8* pSmsPud);
1908 #endif
1909
1910 BOOL sms_save_to_m4_in_Mfw( T_MNSMS_MESSAGE_IND *mnsms_message_ind )
1911 {
1912 T_sms_sdu * sms_sdu = &mnsms_message_ind->sms_sdu;
1913 U8 align_pdu[SIM_PDU_LEN];
1914 U8* pSmsPud;
1915 U8 *pAligned = align_pdu;
1916 U8 *pData = sms_sdu->buf;
1917 U8 offset;
1918 U16 i;
1919 U16 ByteLength;
1920 #if 0
1921 /* First align data on byte boundry */
1922 pData += sms_sdu->o_buf / EIGHT_BITS;
1923 offset = sms_sdu->o_buf % EIGHT_BITS;
1924
1925
1926
1927 if (offset)
1928 {
1929 for ( i=0; i < sms_sdu->l_buf; i += EIGHT_BITS)
1930 {
1931 *pAligned = *pData++ << offset;
1932 *pAligned++ |= *pData >> (EIGHT_BITS - offset);
1933 }
1934 /* Point back to the start of the data */
1935 pAligned = align_pdu;
1936 }
1937 else
1938 pAligned = pData;
1939 #endif
1940 pSmsPud = sms_sdu->buf;
1941 if ((sms_sdu->l_buf & 0x07) == 0)
1942 {
1943 ByteLength = sms_sdu->l_buf/8;
1944 }
1945 else
1946 {
1947 ByteLength = (sms_sdu->l_buf/8) + 1;
1948 }
1949
1950 //NM sms_save_tpdu_ffs(pSmsPud, ByteLength);
1951
1952 #if defined (FF_MMI_MMS) || defined (FF_MMI_EMS)
1953 sms_save_to_m4(pSmsPud);
1954 #endif
1955
1956 return TRUE;
1957 }
1958
1959
1960
1961 /*
1962 +--------------------------------------------------------------------+
1963 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
1964 | STATE : code ROUTINE : rAT_PlusCMTI |
1965 +--------------------------------------------------------------------+
1966
1967 PURPOSE : Receive a new short message identifier.
1968
1969 */
1970
1971 void rAT_PlusCMTI(T_ACI_SMS_STOR mem, UBYTE index, T_ACI_CMGL_SM* sm)
1972 {
1973 /* MZ 2007 Handset displays Message Full on receiving an SMS. */
1974 //T_MFW_MEM_INFO memory;
1975 T_ACI_RETURN ret;
1976 T_SMS_TYPE received_sms_type;
1977 T_CONC_ASSEMBLY_RETURN concatenated_status;
1978 #ifdef TI_PS_FF_CONC_SMS
1979 T_SM_DATA_EXT conc_data_ext;
1980 #endif /*TI_PS_FF_CONC_SMS*/
1981 int i, j;
1982 static int fileid=0;
1983
1984 if (initialising_flag == FALSE)
1985 {
1986 /* Ignore CMTI if initialising */
1987
1988
1989 TRACE_FUNCTION ("rAT_PlusCMTI()");
1990
1991 #if 0
1992 /////////////////////////////////////////////////////////added by ellen
1993 {
1994 char temp[120];
1995 char* temp2;
1996 int i,i_sum=0;
1997
1998 TRACE_EVENT("=== SMS Received ===");
1999 TRACE_EVENT_P2("fo %02X, msg_ref %02X",sm->fo, sm->msg_ref);
2000 sprintf(temp," %d bytes of UDH", sm->udh.len);
2001 TRACE_EVENT(temp);
2002
2003
2004 temp2 = (char*)temp;
2005 sprintf(temp2,"udh ");
2006 temp2+=4;
2007
2008 for(i=0; i<sm->udh.len; i++)
2009 {
2010 sprintf(temp2,"%02X ",sm->udh.data[i]);
2011 temp2+=3;
2012 i_sum ++;
2013 if(i_sum > 30) break;
2014
2015 }
2016 TRACE_EVENT(temp);
2017
2018 sprintf(temp," %d bytes of DATA", sm->data.len);
2019 TRACE_EVENT(temp);
2020
2021
2022 temp2 = (char*)temp;
2023 sprintf(temp2,"data ");
2024 temp2+=5;
2025
2026 for(i=0; i<sm->data.len; i++)
2027 {
2028 sprintf(temp2,"%02X ",sm->data.data[i]);
2029 temp2+=3;
2030 i_sum ++;
2031 if(i_sum > 30) break;
2032
2033 }
2034 TRACE_EVENT(temp);
2035
2036 }
2037 /////////////////////////////////////////////////////////
2038 #endif
2039
2040 /* SPR#2086 - SH - Intercept a WAP SMS *///TISHMMS Project
2041 {
2042
2043 USHORT destinatorPort;
2044 USHORT originatorPort;
2045
2046 sms_getPortId(sm->udh.data, sm->udh.len, &destinatorPort, &originatorPort);
2047
2048 //xmzhou_trace_string_value("New Msg arrived,desti port=",destinatorPort);
2049 //xmzhou_trace_string_value("New Msg arrived,orig port=",originatorPort);
2050
2051 //xmzhou_trace_string_value("CMTI new msg udh length=",sm->udh.len);
2052 //xmzhou_trace_n_bytes(sm->udh.data,sm->udh.len);
2053
2054 TRACE_EVENT_P2("+++++ In rAT_PlusCMTI ready to judge PUSH or not DestP=%d,OrgP=%d +++++",destinatorPort,originatorPort);
2055 if (destinatorPort==2948
2056 || destinatorPort==2949
2057 || destinatorPort==49999 /*OTA Provisioning*/
2058 || destinatorPort==49996 /*OTA SyncML*/
2059 || originatorPort==9200
2060 || originatorPort==9201
2061 || originatorPort==9202
2062 || originatorPort==9203)
2063
2064 {
2065 USHORT index_i;
2066
2067 //xmzhou_trace_string_value("CMTI new msg data length=",sm->data.len);
2068 //xmzhou_trace_string("WAP SMS be identified!!!!!!!");
2069 //xmzhou_trace_n_bytes(sm->data.data,sm->data.len);
2070 #if 0
2071 fileid++;
2072
2073 if(fileid==1){
2074 xmzhou_trace_string_value("CMTI new msg data1 length=",sm->data.len);
2075 if((sm->data.len)<2048) ffs_fwrite("/mms/data1", sm->data.data, sm->data.len);
2076
2077 rvf_delay(500);
2078
2079 xmzhou_trace_string_value("CMTI new msg udh1 length=",sm->udh.len);
2080 if((sm->udh.len)<2048) ffs_fwrite("/mms/udh1", sm->udh.data, sm->udh.len);
2081
2082 }
2083
2084 if(fileid==2){
2085 xmzhou_trace_string_value("CMTI new msg data2 length=",sm->data.len);
2086 if((sm->data.len)<2048) ffs_fwrite("/mms/data2", sm->data.data, sm->data.len);
2087
2088 rvf_delay(500);
2089
2090 xmzhou_trace_string_value("CMTI new msg udh2 length=",sm->udh.len);
2091 if((sm->udh.len)<2048) ffs_fwrite("/mms/udh2", sm->udh.data, sm->udh.len);
2092 }
2093
2094 rvf_delay(1000);
2095 #endif
2096 /*a0393213 OMAPS00109953 - memory added as parameter*/
2097 sms_msg_delete(index,mem);
2098 #if 0
2099 //////////////////////////////////////////////////////////////////////////////////
2100 TRACE_EVENT("MMS Notification");
2101 if(sm->udh.len > 8){
2102 redirectMMSNotification(sm);
2103 }
2104 else {
2105 /////////////////////////////////////////////////////////////////////////////////
2106 #endif
2107 memset(&sms_mt, 0, sizeof(sms_mt));
2108
2109 for (index_i=0; index_i<12; index_i++)
2110 {
2111 TRACE_EVENT_P2("Adress: %X (%c)", sm->adress[index_i], sm->adress[index_i]);
2112 }
2113
2114 memcpy(sms_mt.orig_addr.tag, sm->alpha.data, sm->alpha.len);
2115 sms_mt.orig_addr.len = sm->alpha.len;
2116 strcpy(sms_mt.orig_addr.number, sm->adress);
2117 sms_mt.orig_addr.ton = phb_cvtTon(sm->toa.ton);
2118 sms_mt.orig_addr.npi = phb_cvtNpi(sm->toa.npi);
2119 if (sm->tosca.ton == TON_International)
2120 sprintf(sms_mt.sc_addr, "+%s", sm->sca);
2121 else
2122 strcpy(sms_mt.sc_addr, sm->sca);
2123 sms_mt.prot_id = (UBYTE)sm->pid;
2124 sms_mt.dcs = (UBYTE)sm->dcs & 0xFC; /* Ignore message class */
2125 sms_mt.msg_len = sm->data.len;
2126 memset(sms_mt.sms_msg, 0, sm->data.len);
2127 memcpy(sms_mt.sms_msg, (char*)sm->data.data, sm->data.len);
2128 sms_mt.udh_len = sm->udh.len;
2129
2130 memcpy((char *)sms_mt.udh, (char *)sm->udh.data, sm->udh.len);
2131
2132 //xrashmic 9 May, 2005 MMI-SPR-30159
2133 memcpy(&sms_mt.sctp,&sm->scts,sizeof(T_ACI_VP_ABS));
2134
2135 sms_signal(E_SMS_WAP_MT_RECEIVED, &sms_mt);
2136
2137 /* Delete the message */
2138
2139 return;
2140 #if 0
2141 }/*end of else*/
2142 #endif
2143 }
2144 }
2145
2146 {
2147 //BOOL sms_is_ems_type(UBYTE* UdhData, UBYTE UdhLength)
2148 BOOL bIsEms = FALSE;
2149
2150 bIsEms = sms_is_ems_type(sm->udh.data, sm->udh.len);
2151
2152 if (bIsEms == TRUE)
2153 {
2154 //xmzhou_trace_string("EMS SMS received!!!!!!!!!!!!");//proc EMS message
2155 /*a0393213 OMAPS00109953 - memory added as parameter*/
2156 sms_msg_delete(index,mem);
2157 sms_save_to_m4_in_Mfw( &gTpduData );
2158 }
2159
2160
2161 }
2162
2163 TRACE_EVENT_P1("f_update is = % in CMTI", f_update);
2164 /*a0393213 OMAPS00109953 - new parameter added to SMS_getSMSType()*/
2165 if(initialising_flag == TRUE)
2166 {
2167 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE3);
2168 }
2169 else
2170 {
2171 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE2);
2172 }
2173 TRACE_EVENT_P1("SMS Type is = %d", received_sms_type);
2174 TRACE_EVENT_P2("msg_ref: %d, index: %d", sm->msg_ref, index);
2175
2176 #ifdef TI_PS_FF_CONC_SMS
2177
2178 if (received_sms_type == CONCATE)
2179 {
2180 if(initialising_flag == TRUE)
2181 {
2182 /*a0393213 OMAPS00109953 - memory added as parameter*/
2183 concatenated_status =concSMS_Collect(&conc_data_ext, sm, FALSE, SMS_STOR_NotPresent);
2184 }
2185 else
2186 {
2187 /*a0393213 OMAPS00109953*/
2188 concatenated_status =concSMS_Collect(&conc_data_ext, sm, TRUE, mem);
2189 }
2190 TRACE_EVENT_P2("conc status: %d, conc length: %d", concatenated_status, conc_data_ext.len);
2191 }
2192 #else /*TI_PS_FF_CONC_SMS*/
2193 concatenated_status = CONC_ERR_UNKN;
2194 #endif /*TI_PS_FF_CONC_SMS*/
2195
2196 /*a0393213 OMAPS00109953 - memory added as parameter*/
2197 sms_store_new_msg_info(index,sm,TRUE, concatenated_status, received_sms_type, mem);
2198
2199 if (f_update EQ MFW_SMS_UPDATE OR
2200 coll_sms_send EQ MFW_SMS_WAIT OR
2201 coll_sms_read EQ MFW_SMS_WAIT OR
2202 coll_sms_delete EQ MFW_SMS_WAIT OR
2203 coll_sms_req EQ MFW_SMS_WAIT)
2204 {
2205 if (sms_id_wait.index <= 0)
2206 {
2207 sms_id_wait.index = index;
2208 sms_id_wait.mem = (mem EQ SMS_STOR_Me)? MFW_MEM_ME: MFW_MEM_SIM;
2209 sms_id_wait.concat_status = concatenated_status;
2210 sms_id_wait.received_sms_type = received_sms_type;
2211 }
2212 else
2213 {
2214 TRACE_EVENT("Indication Overrun");
2215 }
2216 f_update = MFW_SMS_UPDATE;
2217 }
2218 else
2219 {
2220 sms_send_new_msg_ind(sm,index, mem, received_sms_type, concatenated_status);
2221 }
2222 f_update = MFW_SMS_FREE;
2223 if(memory.total == memory.used)
2224 {
2225 TRACE_EVENT_P2("memory used is = %d, of %d", memory.used, memory.total);
2226 sms_signal(E_SMS_MEM_FULL, NULL);
2227 }
2228 }
2229 if(msg_info != NULL)
2230 {
2231 TRACE_EVENT_P4("CMTI Msg table: %d,%d,%d, %d", msg_info[0].index, msg_info[1].index,msg_info[2].index,msg_info[3].index);
2232 TRACE_EVENT_P4("CMTI Msg table: %d,%d,%d, %d", msg_info[4].index, msg_info[5].index,msg_info[6].index,msg_info[7].index);
2233 }
2234 /*MC SPR 1366, need to call this function to update CPHS voicemail data*/
2235 sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
2236 &sm->toa, &sm->udh);
2237 /*SPR 1833, this is already called in sms_store_new_msg_info, BUT we need it in for initialisation*/
2238 }
2239
2240 #endif /* #if defined (FF_WAP) && defined (FF_GPF_TCPIP) */
2241 /*
2242 +------------------------------------------------------------------------+
2243 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2244 | STATE : code ROUTINE : find_slot_in_msg_info |
2245 +------------------------------------------------------------------------+
2246
2247 PURPOSE : Find a slot in msg_info for the index of the SMS supplied
2248
2249 */
2250 /*a0393213 OMAPS00109953 - memory added as parameter*/
2251 static int find_slot_in_msg_info(UBYTE index, UBYTE update_mem, T_MFW_SMS_MEM mem)
2252 {
2253 int ret = -1;
2254 int i;
2255
2256 TRACE_FUNCTION("find_slot_in_msg_info");
2257
2258 if (index >= 1)
2259 {
2260 /* A valid index, so look for it already being in msg_info */
2261 #ifdef FF_MMI_SMS_DYNAMIC
2262 for (i = 0; (i < g_max_messages) && (ret == -1); i++)
2263 #else
2264 for (i = 0; (i < MAX_MESSAGES) && (ret == -1); i++)
2265 #endif
2266 {
2267 /*a0393213 OMAPS00109953 - mem also taken into consideration*/
2268 if (msg_info[i].index == index && msg_info[i].mem==mem)
2269 {
2270 /* Index already in msg_info, so replace */
2271 ret = i;
2272 }
2273 }
2274
2275 if (ret == -1)
2276 {
2277 /* Index was not already in msg_info, so look for unused slot */
2278 #ifdef FF_MMI_SMS_DYNAMIC
2279 for (i = 0; (i < g_max_messages) && (ret == -1); i++)
2280 #else
2281 for (i = 0; (i < MAX_MESSAGES) && (ret == -1); i++)
2282 #endif
2283 {
2284 if (msg_info[i].index == -1)
2285 {
2286 /* First unused slot in msg_info found */
2287 ret = i;
2288 if (update_mem)
2289 memory.used++;
2290 /*a0393213 OMAPS00109953 - memory usage updated*/
2291 if(update_mem)
2292 {
2293 if(mem==MFW_MEM_SIM)
2294 sim_memory.used++;
2295 else
2296 ffs_memory.used++;
2297 }
2298 }
2299 }
2300 }
2301 }
2302
2303 TRACE_EVENT_P1("find_slot_in_msg_info returning %d", ret);
2304
2305 return ret;
2306 }
2307
2308 /*
2309 +--------------------------------------------------------------------+
2310 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2311 | STATE : code ROUTINE : sms_store_new_msg_info |
2312 +--------------------------------------------------------------------+
2313
2314 PURPOSE : Store message information
2315
2316 */
2317 /*a0393213 OMAPS00109953 - memory added as parameter*/
2318 T_MFW sms_store_new_msg_info(UBYTE index, T_ACI_CMGL_SM* sm, UBYTE update_mem, T_CONC_ASSEMBLY_RETURN conc_stat ,
2319 T_SMS_TYPE received_sms_type, T_MFW_SMS_MEM mem)
2320 {
2321 int j;
2322 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
2323 // Added this variable to store the voice mail status
2324 T_MFW status;
2325
2326 #ifndef MMI_LITE
2327 //T_CONC_ASSEMBLY_RETURN concatenated_status; // RAVI
2328 // T_SM_DATA_EXT conc_data_ext; // RAVI
2329 #endif
2330 int i;
2331
2332
2333 TRACE_EVENT("sms_store_new_msg_info");
2334
2335 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
2336 sms_type = MFW_SMS_MESSAGE;
2337 #else
2338 /*SPR 2530 removed setting of sms_type flag*/
2339 #endif
2340 /*a0393213 OMAPS00109953 - memory added as parameter*/
2341 if ((j = find_slot_in_msg_info(index, update_mem,mem)) != -1)
2342 {
2343 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
2344 //Initial value of msg_type is set to not voice
2345 msg_info[j].msg_type = MFW_SMS_NotVOICE;
2346
2347 TRACE_EVENT_P1("SMS Type is = %d", received_sms_type);
2348
2349
2350 #ifdef TI_PS_FF_CONC_SMS
2351 /*SPR 2260*/
2352 if (received_sms_type == CONCATE)
2353 {
2354 /*a0393213 OMAPS00109953 - code cleanup done*/
2355 UBYTE first_index=0;
2356 T_MFW_SMS_MEM first_mem=MFW_MEM_NOTPRESENT;
2357 T_CONC_BUF_ELEM* conc_buf_elem;
2358 conc_buf_elem=concSMS_GetFirstIndex_ext(concSMS_GetMsgRef ( sm ), sm->adress);
2359 /*a0393213 OMAPS00109953 - The memory type returned by concSMS_GetFirstIndex_ext
2360 if of psa type. It should be changed to cmh type. Clean solution would be to move this conversion to ACI */
2361 if(conc_buf_elem)
2362 {
2363 first_index=conc_buf_elem->rec_num;
2364 cmhSMS_getMemCmh(conc_buf_elem->mem,(T_ACI_SMS_STOR*)(&first_mem));
2365 }
2366 /*a0393213 OMAPS00109953 - Msg Ref (unique number to each message, don't confuse with index) is stored*/
2367 msg_info[j].msg_ref=concSMS_GetMsgRef ( sm );
2368
2369 if (conc_stat == CONC_COMPLETED)
2370 { /*replace index withat of first message*/
2371 index = first_index;
2372 /*a0393213 OMAPS00109953 - first_mem is the memory where the first segment of the cSMS resides*/
2373 mem=first_mem;
2374
2375 msg_info[j].concat_status = MFW_SMS_CONC_WHOLE;
2376 TRACE_EVENT("Setting to WHOLE");
2377 }
2378 else /*otherwise leave index as it is*/
2379 { /*check if message already complete*/
2380 #ifdef FF_MMI_SMS_DYNAMIC
2381 for (i=0; i<g_max_messages; i++)
2382 #else
2383 for (i=0; i<MAX_MESSAGES; i++)
2384 #endif
2385 { if (msg_info[i].index != -1)
2386 { if (msg_info[i].first_index == first_index
2387 && msg_info[i].first_mem == first_mem /*a0393213 OMAPS00109953*/
2388 && msg_info[i].concat_status == MFW_SMS_CONC_WHOLE)
2389 return 1;/*don't bother copying this message into the table*/ // RAVI - Changed return to return 1
2390 }
2391 }
2392
2393 msg_info[j].concat_status = MFW_SMS_CONC_PART;
2394 TRACE_EVENT("Setting to PART");
2395 }
2396
2397 TRACE_EVENT_P1("index = %d",index);
2398
2399 msg_info[j].first_index =first_index;
2400 /*a0393213 OMAPS00109953*/
2401 msg_info[j].first_mem=first_mem;
2402
2403 /*if complete SMS, delete old fragments*/
2404 if (conc_stat == CONC_COMPLETED)
2405 #ifdef FF_MMI_SMS_DYNAMIC
2406 for (i=0; i<g_max_messages; i++)
2407 #else
2408 for (i=0; i<MAX_MESSAGES; i++)
2409 #endif
2410 {
2411 if (msg_info[i].index != -1)
2412 {
2413 /*a0393213 OMAPS00109953*/
2414 if (msg_info[i].msg_ref==concSMS_GetMsgRef ( sm )
2415 &&(msg_info[i].concat_status == MFW_SMS_CONC_PART ))
2416 {
2417 TRACE_EVENT_P1("Deleting index number:%d", msg_info[i].index);
2418 delete_sms_from_table(msg_info[i].index, msg_info[i].mem);/*a0393213 OMAPS00109953*/
2419 }
2420 }
2421
2422 }
2423 }
2424 /*a0393213 OMAPS00109953 - new case added - it's the case where segments of cSMS are treated as normal SMS*/
2425 else if (received_sms_type == NORMAL_IND_CSMS)
2426 {
2427 TRACE_EVENT( "sms_store_new_msg_info Incomplete sms!!!!");
2428 msg_info[j].first_index = 0xFF;/*invalid index*/
2429 msg_info[j].first_mem=MFW_MEM_NOTPRESENT;/*a0393213 OMAPS00109953*/
2430 msg_info[j].concat_status = MFW_SMS_CONC_PART;
2431 }
2432 else
2433 #endif /*TI_PS_FF_CONC_SMS*/
2434 {
2435 msg_info[j].first_index = 0xFF;/*invalid index*/
2436 msg_info[j].first_mem=MFW_MEM_NOTPRESENT;/*a0393213 OMAPS00109953*/
2437 msg_info[j].concat_status = MFW_SMS_NO_CONC;
2438 TRACE_EVENT("Setting to NO CONC");
2439 }
2440
2441
2442 sm->index = index;
2443 msg_info[j].index = index;
2444 msg_info[j].mem=mem;/*a0393213 OMAPS00109953*/
2445
2446 //x0pleela 08 Feb, 2006 DR: OMAPS00059261
2447 //Replacing MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
2448
2449 //x0pleela 07 Feb, 2006 DR: OMAPS00059261
2450 //Update msg_info's message type for STATUS REPORT
2451 if(( 0x03 & sm->fo ) EQ MFW_MSG_STATUS_REPORT )
2452 {
2453 msg_info[j].msg_type = MFW_SMS_STATRPT;
2454 }
2455 msg_info[j].stat = sms_decodeStatus(sm->stat);
2456
2457 strcpy((char *)msg_info[j].addr.number, sm->adress);
2458 msg_info[j].addr.ton = phb_cvtTon(sm->toa.ton);
2459 msg_info[j].addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
2460
2461
2462 #ifdef NO_ASCIIZ
2463 memcpy(msg_info[j].addr.tag,
2464 sm->alpha.data,
2465 sm->alpha.len);
2466 msg_info[j].addr.len = sm->alpha.len;
2467 #else
2468 phb_Alpha2Gsm(&sm->alpha,
2469 (UBYTE *)msg_info[j].addr.tag);
2470 #endif
2471
2472 memcpy(&msg_info[j].rctp, &sm->scts, sizeof(T_MFW_SMS_SCTP));
2473
2474 // check voice mail status
2475 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
2476 // Commented the 'if' condition below.
2477 /* if (sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
2478 &sm->toa, &sm->udh) EQ MFW_SMS_VOICE)
2479 msg_info[j].msg_type = MFW_SMS_VOICE;*/
2480 status = sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
2481 &sm->toa, &sm->udh);
2482 // Check if it is a voice mail message
2483 if(status == MFW_SMS_VOICE || status == MFW_SMS_VOICEMSG_DELETE)
2484 {
2485 // If voicemail message is from group "1100"
2486 if(status == MFW_SMS_VOICEMSG_DELETE)
2487 {
2488 // Mark this message for deletion
2489 msg_info[j].stat= MFW_SMS_VOICEMSG_DELETE;
2490 }
2491 msg_info[j].msg_type = MFW_SMS_VOICE;
2492 }
2493
2494 coll_sms_read = MFW_SMS_FREE;
2495 f_update = MFW_SMS_FREE;
2496 TRACE_EVENT_P1("UDH Length is = %d", sm->udh.len);
2497 }
2498 /*SPR 2260, check if memory full*/
2499 TRACE_EVENT_P2("memory used is = %d, of %d", memory.used, memory.total);
2500 if(memory.total == memory.used)
2501 {
2502
2503 sms_signal(E_SMS_MEM_FULL, NULL);
2504 }
2505 return 1; // RAVI
2506 }
2507
2508
2509
2510 /*
2511 +--------------------------------------------------------------------+
2512 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2513 | STATE : code ROUTINE : sms_stored_submit |
2514 +--------------------------------------------------------------------+
2515
2516 PURPOSE : Send a new message indication to the MMI
2517
2518 */
2519
2520 T_MFW sms_send_new_msg_ind(T_ACI_CMGL_SM* sm,UBYTE index, UBYTE mem, UBYTE received_sms_type, UBYTE concatenated_status)
2521 {
2522 TRACE_FUNCTION("sms_send_new_msg_ind");
2523 #ifdef TI_PS_FF_CONC_SMS
2524 if (received_sms_type == CONCATE)
2525 {
2526 switch (concatenated_status)
2527 {
2528 case CONC_ERR_UNKN:
2529 TRACE_EVENT("Concatenated SMS error");break;
2530 case CONC_ERR_BUF_FULL:
2531 TRACE_EVENT("Concatented SMS buffer Full Error");break;
2532 case CONC_CONTINUED: //not last SMS
2533 TRACE_EVENT("Concatenation Continued");
2534 break;
2535 case CONC_COMPLETED:
2536 {
2537 TRACE_EVENT("Concatenation Completed");
2538 memset(&sms_mt, 0, sizeof(sms_mt));
2539 /*SPR 2260*/
2540 if (sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
2541 &sm->toa, &sm->udh) == MFW_SMS_VOICE)
2542 sms_mt.voicemail = TRUE;
2543 else
2544 sms_mt.voicemail = FALSE;
2545 if(initialising_flag == TRUE)
2546 sms_signal(E_SMS_MT, &sms_mt);
2547 else
2548 {
2549 //Aug 26, 2004 REF: CRR 23287 Deepa M.D
2550 //The second parameter is not used in case of
2551 //E_SMS_MT_RECEIVED event.sms_id_wait is the variable
2552 //used for MT SMS, which is ignored anyway.
2553 sms_signal(E_SMS_MT_RECEIVED, &sms_id_wait);
2554 }
2555 }
2556 }
2557 }
2558 else
2559 #endif /*TI_PS_FF_CONC_SMS*/
2560 {
2561 memset(&sms_mt, 0, sizeof(sms_mt));
2562
2563 if(initialising_flag == TRUE)
2564 sms_signal(E_SMS_MT, &sms_mt);
2565 else
2566 {
2567 //Aug 26, 2004 REF: CRR 23287 Deepa M.D
2568 //The second parameter is not used in case of
2569 //E_SMS_MT_RECEIVED event.sms_id_wait is the variable
2570 //used for MT SMS, which is ignored anyway.
2571 sms_signal(E_SMS_MT_RECEIVED, &sms_id_wait);
2572 }
2573 }
2574 return 1; /*a0393213 compiler warnings removal - added return statement*/
2575 }
2576
2577 /*
2578 +--------------------------------------------------------------------+
2579 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2580 | STATE : code ROUTINE : rAT_PlusCBM |
2581 +--------------------------------------------------------------------+
2582
2583 PURPOSE : Receive a new cell broadcast message.
2584
2585 */
2586 void rAT_PlusCBM(SHORT sn,
2587 SHORT mid,
2588 SHORT dcs,
2589 UBYTE page,
2590 UBYTE pages,
2591 T_ACI_CBM_DATA* data)
2592 {
2593 TRACE_FUNCTION ("rAT_PlusCBM()");
2594
2595 /* copy parameter */
2596 sms_cb.sn = sn;
2597 sms_cb.msg_id = mid;
2598 sms_cb.dcs = (UBYTE)dcs;
2599 sms_cb.page = page;
2600 sms_cb.pages = pages;
2601 sms_cb.msg_len = data->len;
2602 memcpy((char *)sms_cb.cb_msg, (char *)data->data, data->len);
2603 /* send cell broadcast message event */
2604 // Oct 18, 2005 REF: SPR 34678 xdeepadh
2605 //The CB messages with DCS 242(class-2,default alphabet) are discarded
2606 if(dcs!=0xF2)
2607 {
2608 sms_signal(E_SMS_CB, &sms_cb);
2609 }
2610 }
2611
2612
2613 /*
2614 +--------------------------------------------------------------------+
2615 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2616 | STATE : code ROUTINE : rAT_PlusCBMI |
2617 +--------------------------------------------------------------------+
2618
2619 PURPOSE : Receive a new cell broadcast message identifier.
2620
2621 */
2622
2623 void rAT_PlusCBMI(T_ACI_SMS_STOR mem, UBYTE index)
2624 {
2625 TRACE_EVENT ("rAT_PlusCBMI()");
2626
2627 switch ( mem )
2628 {
2629 case ( SMS_STOR_Me ):
2630 sms_id.mem = MFW_MEM_ME;
2631 break;
2632 case ( SMS_STOR_Sm ):
2633 sms_id.mem = MFW_MEM_SIM;
2634 break;
2635 default:
2636 break;
2637 }
2638
2639 sms_id.index = index;
2640
2641 /* send a short message identifier event */
2642 sms_signal(E_SMS_CB_RECEIVED, &sms_id);
2643 }
2644
2645
2646 /*
2647 +--------------------------------------------------------------------+
2648 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2649 | STATE : code ROUTINE : rAT_PlusCDS |
2650 +--------------------------------------------------------------------+
2651
2652 PURPOSE : Receive a status report message.
2653
2654 */
2655
2656 void rAT_PlusCDS(T_ACI_CDS_SM *st)
2657 {
2658 T_MFW_SMS_STATUS sms_status;
2659 T_MFW_PHB_ENTRY phb_entry;
2660 T_MFW_PHB_LIST phb_list;
2661 SHORT phb_index;
2662 #ifdef NO_ASCIIZ
2663 T_MFW_PHB_TEXT findText;
2664 #endif
2665
2666 TRACE_FUNCTION ("rAT_PlusCDS()");
2667
2668 memset(&phb_entry, 0, sizeof(phb_entry));
2669 memset(&phb_list, 0, sizeof(phb_list));
2670 phb_list.entry = &phb_entry;
2671
2672 sms_status.msg_id = 0x03 & (UBYTE)st->fo;
2673 sms_status.msg_ref = st->msg_ref;
2674 strcpy(sms_status.addr.number, st->addr);
2675 sms_status.addr.ton = phb_cvtTon(st->toa.ton);
2676 sms_status.addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(st->toa.npi);
2677
2678 #ifdef NO_ASCIIZ
2679 strcpy((char *)findText.data, st->addr);
2680 findText.len = (UBYTE)strlen(st->addr);
2681 if (phb_find_entries (PHB_ADN, &phb_index,
2682 MFW_PHB_NUMBER,
2683 1, &findText,
2684 &phb_list) EQ MFW_PHB_OK)
2685 {
2686 if (phb_list.num_entries)
2687 {
2688 memcpy(sms_status.addr.tag,
2689 phb_list.entry->name.data,
2690 phb_list.entry->name.len);
2691 sms_status.addr.len = phb_list.entry->name.len;
2692
2693 }
2694 // Apr 12, 2004 REF: CRR 13370 Deepa M.D
2695 else
2696 {
2697 sms_status.addr.tag[0]='\0';
2698 sms_status.addr.len = 0;
2699
2700 }
2701 }
2702 #else
2703 if (phb_find_entries (PHB_ADN, &phb_index,
2704 MFW_PHB_NUMBER,
2705 1,
2706 st->ra,
2707 &phb_list) EQ MFW_PHB_OK)
2708 {
2709
2710 if (phb_list.num_entries)
2711 {
2712 strcpy((char *)sms_status.addr.tag, (char *)phb_list.entry->name);
2713
2714 }
2715 }
2716 #endif
2717
2718 sms_status.status = st->tp_status;
2719
2720 memcpy((char *)sms_status.rctp.year, (char *)st->vpabs_scts.year, MAX_SCTP_DIGITS);
2721 memcpy((char *)sms_status.rctp.month, (char *)st->vpabs_scts.month, MAX_SCTP_DIGITS);
2722 memcpy((char *)sms_status.rctp.day, (char *)st->vpabs_scts.day, MAX_SCTP_DIGITS);
2723 memcpy((char *)sms_status.rctp.hour, (char *)st->vpabs_scts.hour, MAX_SCTP_DIGITS);
2724 memcpy((char *)sms_status.rctp.minute, (char *)st->vpabs_scts.minute, MAX_SCTP_DIGITS);
2725 memcpy((char *)sms_status.rctp.second, (char *)st->vpabs_scts.second, MAX_SCTP_DIGITS);
2726 sms_status.rctp.timezone = st->vpabs_scts.timezone;
2727
2728 /* send status report message event */
2729 sms_signal(E_SMS_STATUS, &sms_status);
2730 }
2731
2732
2733 /*
2734 +------------------------------------------------------------------+
2735 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2736 | STATE : code ROUTINE : sms_set_pref_memory|
2737 +------------------------------------------------------------------+
2738
2739 PURPOSE : Set preferred message storage.
2740
2741 */
2742
2743 T_MFW sms_set_pref_memory(UBYTE mem)
2744 {
2745 TRACE_FUNCTION ("sms_set_pref_memory()");
2746
2747 /*a0393213 OMAPS00109953 - The pref memory is already same as mem*/
2748 if(memory.mem==mem)
2749 return MFW_SMS_OK;
2750
2751 if (sAT_PlusCPMS(CMD_SRC_LCL,
2752 sms_mem_cvt(mem),
2753 sms_mem_cvt(mem),
2754 sms_mem_cvt(mem)) NEQ AT_CMPL) /*a0393213 OMAPS00109953 sAT_PlusCPMS is a synchronous call - so AT_EXCT changed to AT_CMPL*/
2755 return MFW_SMS_FAIL;
2756 return MFW_SMS_OK;
2757 }
2758
2759
2760 /*
2761 +--------------------------------------------------------------------+
2762 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2763 | STATE : code ROUTINE : sms_read |
2764 +--------------------------------------------------------------------+
2765
2766 PURPOSE : Read a SMS message.
2767
2768 */
2769 /*a0393213 OMAPS00109953 - memory added as parameter*/
2770 T_MFW sms_read(UBYTE type, UBYTE index, T_MFW_SMS_MEM sms_memory)
2771 {
2772 TRACE_EVENT_P1("sms_read():%d",index);
2773
2774 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGR*/
2775 if(sms_set_pref_memory(sms_memory)!=MFW_SMS_OK)
2776 {
2777 TRACE_ERROR("sms_read_msg_info():Not able to set pref memory");
2778 return MFW_SMS_FAIL;
2779 }
2780
2781 coll_sms_read = MFW_SMS_WAIT;
2782
2783 if (sAT_PlusCMGR(CMD_SRC_LCL, index, SMS_READ_Preview) NEQ AT_EXCT)
2784 return MFW_SMS_FAIL;
2785 /*SPR 2260, set sms type so we get event from rAT_plusCMGR*/
2786 sms_type = MFW_SMS_MESSAGE;
2787
2788 memset(&sms_mt, 0, sizeof(sms_mt));
2789 sms_mt.index = index;
2790 sms_mt.memory=sms_memory; /*a0393213 OMAPS00109953*/
2791 cmgr_awaiting_ok = FALSE; // Marcus: Issue 2260: 03/10/2002
2792
2793 return MFW_SMS_OK;
2794 }
2795
2796
2797 /*
2798 +--------------------------------------------------------------------+
2799 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
2800 | STATE : code ROUTINE : rAT_PlusCMGR |
2801 +--------------------------------------------------------------------+
2802
2803
2804 PURPOSE : Call back for read message.
2805
2806 */
2807
2808 //Feb 28, 2004 REF: CRR 28809 Deepa M.D
2809 /*The Optimization changes done for golite build have been incorpaorated to color build.
2810 The MMI_LITE flag used for rAT_PlusCMGR has been removed.*/
2811 void rAT_PlusCMGR(T_ACI_CMGL_SM * sm, T_ACI_CMGR_CBM * cbm)
2812 {
2813 T_SMS_TYPE received_sms_type;
2814 T_CONC_ASSEMBLY_RETURN concatenated_status=CONC_ERR_UNKN;
2815 #ifdef TI_PS_FF_CONC_SMS
2816 T_SM_DATA_EXT conc_data_ext;
2817 #endif /*TI_PS_FF_CONC_SMS*/
2818 //Feb 28, 2004 REF: CRR 28809 Deepa M.D
2819 //sms_mo is made a local variable.It will be allocated /deallocated dynamically.
2820 T_MFW_SMS_MO *sms_mo=NULL;
2821 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
2822 UBYTE wap_sms = FALSE;
2823 #endif
2824 TRACE_FUNCTION ("rAT_PlusCMGR()");
2825 TRACE_EVENT_P2("messagepointer:%d, Cellbroadcast pointer:%d", sm, cbm);
2826 cmgr_awaiting_ok = TRUE; // Marcus: Issue 2260: 03/10/2002
2827 #ifdef TI_PS_FF_CONC_SMS
2828 conc_data_ext.data = NULL; // Jul 07, 2004 REF: CRR 15846 Deepa M.D
2829 #endif /*TI_PS_FF_CONC_SMS*/
2830 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
2831 /* SPR#2086 - SH - Intercept a WAP SMS */
2832 {
2833 USHORT destinatorPort = sm->udh.data[3]+sm->udh.data[2]*0x100;
2834 USHORT originatorPort = sm->udh.data[5]+sm->udh.data[4]*0x100;
2835
2836 if (destinatorPort==2948
2837 || destinatorPort==2949
2838 || originatorPort==9200
2839 || originatorPort==9201
2840 || originatorPort==9202
2841 || originatorPort==9203)
2842 {
2843 wap_sms = TRUE;
2844 }
2845 }
2846 #endif
2847 switch (sms_type)
2848 {
2849 case MFW_SMS_MESSAGE:
2850 { if (sm != NULL) /*SPR2260 make sure we have a valid pointer*/
2851 { switch (0x03 & sm->fo)
2852 {
2853 case MFW_MSG_DELIVER: //x0pleela 01 Feb, 2006 DR: OMAPS00059261 /* SMS type: MT */
2854 {
2855 #ifdef TI_PS_FF_CONC_SMS
2856 USHORT conc_msg_ref;
2857 UBYTE conc_index;
2858 T_CONC_BUF_ELEM* conc_buf_elem=NULL;/*a0393213 OMAPS00109953*/
2859 int i;/*SPR2260*/
2860 BOOL continue_flag=FALSE;/*SPR2260*/
2861 #endif /*TI_PS_FF_CONC_SMS*/
2862
2863
2864 TRACE_EVENT_P1("UDH Length is = %d", sm->udh.len);
2865 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE3);/*a0393213 OMAPS00109953*/
2866 TRACE_EVENT_P1("SMS Type is = %d", received_sms_type);
2867
2868 #ifdef TI_PS_FF_CONC_SMS
2869 if (received_sms_type == CONCATE)
2870 {
2871 /*a0393213 OMAPS00109953*/
2872 concatenated_status =concSMS_Collect(&conc_data_ext, sm, FALSE, SMS_STOR_NotPresent);
2873 TRACE_EVENT_P2("conc status: %d, conc length: %d", concatenated_status, conc_data_ext.len);
2874
2875 switch (concatenated_status)
2876 {
2877
2878 case CONC_ERR_BUF_FULL:
2879 TRACE_EVENT("Concatented SMS buffer Full Error");
2880 sms_signal(E_SMS_ERR, NULL);
2881 break;
2882 case CONC_ERR_UNKN:
2883 TRACE_EVENT("Concatenated SMS error");
2884 case CONC_CONTINUED: //not last SMS
2885 TRACE_EVENT("Concatenation Continued");
2886 /*SPR 2260*/
2887 cmgr_awaiting_ok = FALSE; // Marcus: Issue 2260: 03/10/2002
2888
2889 /*if the index exists in the message table, process the message*/
2890 #ifdef FF_MMI_SMS_DYNAMIC
2891 for (i=0; i <g_max_messages;i++)
2892 #else
2893 for (i=0; i <MAX_MESSAGES;i++)
2894 #endif
2895 if (msg_info[i].index == sm->msg_ref && msg_info[i].concat_status == MFW_SMS_CONC_PART)
2896 continue_flag = TRUE;
2897 if (!continue_flag)
2898 break;
2899
2900 case CONC_COMPLETED:
2901 {
2902 TRACE_EVENT("Concatenation Completed");
2903 memset(&sms_mt, 0, sizeof(sms_mt));
2904 /*a0393213 OMAPS00109953*/
2905 conc_msg_ref=concSMS_GetMsgRef(sm);
2906 conc_buf_elem=concSMS_GetFirstIndex_ext(conc_msg_ref,sm->adress);
2907 conc_index=conc_buf_elem->rec_num;
2908 #ifdef NO_ASCIIZ
2909 memcpy(sms_mt.orig_addr.tag,
2910 sm->alpha.data,
2911 sm->alpha.len);
2912 sms_mt.orig_addr.len = sm->alpha.len;
2913 #else
2914 phb_Alpha2Gsm(sm->alpha, (UBYTE *)sms_mt.orig_addr.tag);
2915 #endif
2916 strcpy(sms_mt.orig_addr.number, sm->adress);
2917 sms_mt.orig_addr.ton =
2918 phb_cvtTon(sm->toa.ton);
2919 sms_mt.orig_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
2920 if (sm->tosca.ton == TON_International)
2921 sprintf(sms_mt.sc_addr, "+%s", sm->sca);
2922 else
2923 strcpy(sms_mt.sc_addr, sm->sca);
2924 sms_mt.prot_id = (UBYTE)sm->pid;
2925 sms_mt.dcs = (UBYTE)sm->dcs & 0xFC; /* Ignore message class */
2926
2927 /*MC SPR 2260, message index should be set to that of first index in
2928 concatenated message if this is a complete message*/
2929 if (concatenated_status == CONC_COMPLETED)
2930 sms_mt.index = conc_index;
2931 else
2932 sms_mt.index = sm->msg_ref;
2933 /*a0393213 OMAPS00109953 - the memory is of psa type. It should be converted to cmh type
2934 Clean solution would be to move this conversion to ACI*/
2935 cmhSMS_getMemCmh(conc_buf_elem->mem,(T_ACI_SMS_STOR*)(&(sms_mt.memory)));
2936 sms_mt.rp = sm->fo >> 7 & 1;
2937
2938 /* SBH */
2939 if (sm->dcs & 0x10) /* Bit 5 indicates that we should get message class from bits 0 & 1 */
2940 {
2941 sms_mt.ti = sm->dcs & 3;
2942 }
2943 else /* Otherwise, set to default value */
2944 {
2945 sms_mt.ti = 1;
2946 }
2947 /* SBH end */
2948
2949 memcpy((char *)sms_mt.sctp.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
2950 memcpy((char *)sms_mt.sctp.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
2951 memcpy((char *)sms_mt.sctp.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
2952 memcpy((char *)sms_mt.sctp.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
2953 memcpy((char *)sms_mt.sctp.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
2954 memcpy((char *)sms_mt.sctp.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
2955 sms_mt.sctp.timezone = sm->scts.timezone;
2956
2957 /* copy length of whole concat SMS*/
2958 if (conc_data_ext.len > MAX_MSG_LEN)
2959 sms_mt.msg_len = MAX_MSG_LEN;
2960 else
2961 sms_mt.msg_len = conc_data_ext.len;
2962 /*copy all data from concat SMS*/
2963 /*SPR 2260*/
2964 if (sm->stat == SMS_STAT_Invalid)
2965 memset(sms_mt.sms_msg, NULL, MAX_MSG_LEN_ARRAY);
2966 else /*SPR2260 */
2967 { if (concatenated_status == CONC_COMPLETED)
2968 { memcpy(sms_mt.sms_msg, (char*)conc_data_ext.data, sms_mt.msg_len);}
2969 else/*copy data from sm pointer if message not complete*/
2970 { memcpy(sms_mt.sms_msg, (char*)sm->data.data, sm->data.len);
2971 sms_mt.msg_len = sm->data.len;
2972 }
2973 }
2974 /* Free memory allocated by the ACI */
2975 // Jul 07, 2004 REF: CRR 15846 Deepa M.D
2976 //Free the memory only if conc_data_ext.data is not NULL.
2977 if(conc_data_ext.data != NULL)
2978 {
2979 MFREE(conc_data_ext.data);
2980 }
2981 sms_mt.udh_len = sm->udh.len;
2982 memcpy((char *)sms_mt.udh, (char *)sm->udh.data, sm->udh.len);
2983
2984 /*MC SPR 2260, need to call this function to update CPHS voicemail data*/
2985 if (sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
2986 &sm->toa, &sm->udh) == MFW_SMS_VOICE)
2987 sms_mt.voicemail = TRUE;
2988 else
2989 sms_mt.voicemail = FALSE;
2990
2991 sms_type = MFW_NO_MESSAGE;
2992
2993 coll_sms_read = MFW_SMS_FREE;
2994 /*whenever some operation is done the pref memory should be set back to SIM*/
2995 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
2996 {
2997 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
2998 }
2999 sms_signal(E_SMS_MT, &sms_mt);
3000 }
3001 }
3002 }
3003 else
3004 #endif /*TI_PS_FF_CONC_SMS*/
3005 {
3006 #ifdef NO_ASCIIZ
3007 memcpy(sms_mt.orig_addr.tag,
3008 sm->alpha.data,
3009 sm->alpha.len);
3010
3011 sms_mt.orig_addr.len = sm->alpha.len;
3012 #else
3013 phb_Alpha2Gsm(&sm->alpha, (UBYTE *)sms_mt.orig_addr.tag);
3014 #endif
3015
3016 if (sm->toa.ton == TON_International)
3017 sprintf(sms_mt.orig_addr.number, "+%s", sm->adress);
3018 else
3019 strcpy(sms_mt.orig_addr.number, sm->adress);
3020
3021 sms_mt.orig_addr.ton = phb_cvtTon(sm->toa.ton);
3022 sms_mt.orig_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
3023
3024 if (sm->tosca.ton == TON_International)
3025 sprintf(sms_mt.sc_addr, "+%s", sm->sca);
3026 else
3027 strcpy(sms_mt.sc_addr, sm->sca);
3028
3029 sms_mt.prot_id = (UBYTE)sm->pid;
3030 sms_mt.dcs = (UBYTE)sm->dcs & 0xFC; /* Ignore message class */
3031 sms_mt.rp = sm->fo >> 7 & 1;
3032
3033 // PATCH JPS 04.10 END
3034 /* SBH */
3035 if (sm->dcs & 0x10) /* Bit 5 indicates that we should get message class from bits 0 & 1 */
3036 {
3037 sms_mt.ti = sm->dcs & 3;
3038 }
3039 else /* Otherwise, set to default value */
3040 {
3041 sms_mt.ti = 1;
3042 }
3043 /* SBH end */
3044
3045 TRACE_EVENT_P2("dcs: %d, ti: %d", sms_mt.dcs, sms_mt.ti);
3046
3047 memcpy((char *)sms_mt.sctp.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
3048 memcpy((char *)sms_mt.sctp.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
3049 memcpy((char *)sms_mt.sctp.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
3050 memcpy((char *)sms_mt.sctp.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
3051 memcpy((char *)sms_mt.sctp.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
3052 memcpy((char *)sms_mt.sctp.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
3053 sms_mt.sctp.timezone = sm->scts.timezone;
3054 sms_mt.msg_len = sm->data.len;
3055 TRACE_EVENT_P2("msg_len %d, data.len %d", sms_mt.msg_len, sm->data.len);
3056 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
3057 /* SPR#2086 - SH - If we've got a WAP SMS, replace the message
3058 * with a string */
3059
3060 if (wap_sms)
3061 {
3062 char *message = "WAP SMS";
3063
3064 strcpy(sms_mt.sms_msg, message);
3065 sms_mt.msg_len = strlen(message);
3066 }
3067 else
3068 {
3069
3070 /*SPR 2260, if invalid message just set text to NULL*/
3071 #endif
3072 if (sm->stat == SMS_STAT_Invalid)
3073 memset(sms_mt.sms_msg, NULL, MAX_MSG_LEN_ARRAY);
3074 else
3075 {
3076 memcpy(sms_mt.sms_msg, (char*)sm->data.data, sm->data.len);
3077 sms_mt.msg_len = sm->data.len;
3078
3079 }
3080 /*SPR 2260 end*/
3081 sms_mt.udh_len = sm->udh.len;
3082 memcpy((char *)sms_mt.udh, (char *)sm->udh.data, sm->udh.len);
3083 sms_type = MFW_NO_MESSAGE;
3084 TRACE_EVENT("read=free1");
3085 coll_sms_read = MFW_SMS_FREE;
3086 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
3087 }
3088 #endif
3089
3090 /*MC SPR 2260, need to call this function to update CPHS voicemail data*/
3091 if (sms_check_voice_mail(sm->pid, sm->dcs, sm->adress,
3092 &sm->toa, &sm->udh) == MFW_SMS_VOICE)
3093 sms_mt.voicemail = TRUE;
3094 else
3095 sms_mt.voicemail = FALSE;
3096 /*whenever some operation is done the pref memory should be set back to SIM*/
3097 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
3098 {
3099 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
3100 }
3101 sms_signal(E_SMS_MT, &sms_mt);
3102 }
3103 }
3104 break;
3105
3106 case MFW_MSG_SUBMIT://x0pleela 01 Feb, 2006 DR: OMAPS00059261 /* SMS type: MO */
3107 {
3108 #ifdef TI_PS_FF_CONC_SMS
3109 int i;/*SPR2260*/
3110 BOOL continue_flag=FALSE;
3111 USHORT conc_msg_ref;/*SPR 2260*/
3112 UBYTE conc_index;
3113 /*a0393213 OMAPS00109953*/
3114 T_CONC_BUF_ELEM* conc_buf_elem=NULL;
3115 #endif /*TI_PS_FF_CONC_SMS*/
3116
3117 //Feb 28, 2004 REF: CRR 28809 Deepa M.D
3118 //Allocate sms_mo dynamically
3119 sms_mo = (T_MFW_SMS_MO*)mfwAlloc(sizeof(T_MFW_SMS_MO));
3120 if (sms_mo == NULL)
3121 {
3122 TRACE_EVENT("sms_mo alloc failed");
3123 return ;
3124 }
3125 received_sms_type = SMS_getSMSType( &sm->udh, sm->adress, MODE3);/*a0393213 OMAPS00109953*/
3126 TRACE_EVENT_P1("SMS Type is = %d", received_sms_type);
3127
3128 #ifdef TI_PS_FF_CONC_SMS
3129 if (received_sms_type == CONCATE)
3130 {
3131 /*a0393213 OMAPS00109953 - memory added as parameter*/
3132 concatenated_status =concSMS_Collect(&conc_data_ext, sm, FALSE, SMS_STOR_NotPresent);
3133 TRACE_EVENT_P2("conc status: %d, conc length: %d", concatenated_status, conc_data_ext.len);
3134
3135
3136 TRACE_EVENT_P1("UDH Length is = %d", sm->udh.len);
3137
3138
3139
3140 switch (concatenated_status)
3141 {
3142
3143 case CONC_ERR_BUF_FULL:
3144 TRACE_EVENT("Concatented SMS buffer Full Error");
3145 sms_signal(E_SMS_ERR, NULL);
3146 break;
3147 case CONC_ERR_UNKN:
3148 TRACE_EVENT("Concatenated SMS error");
3149 case CONC_CONTINUED: //not last SMS
3150 TRACE_EVENT("Concatenation Continued");
3151 cmgr_awaiting_ok = FALSE; // Marcus: Issue 2260: 03/10/2002
3152 /*SPR 2260,if the index exists in the message table, continue processing message*/
3153 #ifdef FF_MMI_SMS_DYNAMIC
3154 for (i=0; i <g_max_messages;i++)
3155 #else
3156 for (i=0; i <MAX_MESSAGES;i++)
3157 #endif
3158 if (msg_info[i].index == sm->msg_ref && msg_info[i].concat_status == MFW_SMS_CONC_PART)
3159 continue_flag = TRUE;
3160 if (!continue_flag)
3161 break;
3162 case CONC_COMPLETED:
3163 {
3164
3165 TRACE_EVENT("Concatenation Completed");
3166
3167 memset(sms_mo, 0, sizeof(T_MFW_SMS_MO));
3168 /*SPR 2260*/
3169 /*a0393213 OMAPS00109953*/
3170 conc_msg_ref=concSMS_GetMsgRef(sm);
3171 conc_buf_elem=concSMS_GetFirstIndex_ext(conc_msg_ref,sm->adress);
3172 conc_index=conc_buf_elem->rec_num;
3173 TRACE_EVENT_P2("msg_len: %d conc len: %d", sms_mo->msg_len, conc_data_ext.len);
3174
3175 #ifdef NO_ASCIIZ
3176 memcpy(sms_mo->dest_addr.tag,
3177 sm->alpha.data,
3178 sm->alpha.len);
3179 sms_mo->dest_addr.len = sm->alpha.len;
3180 #else
3181 phb_Alpha2Gsm(&sm->alpha, (UBYTE *)sms_mo->dest_addr.tag);
3182 #endif
3183 strcpy(sms_mo->dest_addr.number, sm->adress);
3184 sms_mo->dest_addr.ton = phb_cvtTon(sm->toa.ton);
3185 sms_mo->dest_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
3186 if (sm->tosca.ton == TON_International)
3187 sprintf(sms_mo->sc_addr, "+%s", sm->sca);
3188 else
3189 strcpy((char *)sms_mo->sc_addr, sm->sca);
3190
3191 sms_mo->prot_id = (UBYTE)sm->pid;
3192 sms_mo->dcs = sm->dcs;
3193
3194 /*MC SPR 2260, message index should be set to that of first index in
3195 concatenated message if this is a complete message*/
3196 if (concatenated_status == CONC_COMPLETED)
3197 sms_mo->msg_ref = conc_index;
3198 else
3199 sms_mo->msg_ref = sm->msg_ref;
3200 /*a0393213 OMAPS00109953 - the memory is of psa type. It should be converted to cmh type.
3201 Clean solution would be to move this ACI*/
3202 cmhSMS_getMemCmh(conc_buf_elem->mem,(T_ACI_SMS_STOR*)(&(sms_mo->memory )));
3203
3204 sms_mo->vp_mode = 0x03 & sm->fo << 2;
3205 sms_mo->vp_rel = (UBYTE)sm->vp_rel;
3206
3207 memcpy((char *)sms_mo->vp_abs.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
3208 memcpy((char *)sms_mo->vp_abs.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
3209 memcpy((char *)sms_mo->vp_abs.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
3210 memcpy((char *)sms_mo->vp_abs.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
3211 memcpy((char *)sms_mo->vp_abs.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
3212 memcpy((char *)sms_mo->vp_abs.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
3213 sms_mo->vp_abs.timezone = sm->scts.timezone;
3214
3215 /* copy length of whole concat SMS*/
3216 if (conc_data_ext.len > MAX_MSG_LEN)
3217 sms_mo->msg_len = MAX_MSG_LEN;
3218 else
3219 sms_mo->msg_len = conc_data_ext.len;
3220 /*SPR 2260 if invalid message just set text to NULL*/
3221 if (sm->stat == SMS_STAT_Invalid)
3222 memset(sms_mo->sms_msg, NULL, MAX_MSG_LEN_ARRAY);
3223 else
3224 { if (concatenated_status == CONC_COMPLETED)
3225 { memcpy(sms_mo->sms_msg, (char*)conc_data_ext.data, sms_mo->msg_len);}
3226 else
3227 { memcpy(sms_mo->sms_msg, (char*)sm->data.data, sm->data.len);
3228 sms_mo->msg_len = sm->data.len;
3229 }
3230 }
3231
3232 /* Free memory allocated by the ACI */
3233 // Jul 07, 2004 REF: CRR 15846 Deepa M.D
3234 //Free the memory only if conc_data_ext.data is not NULL.
3235 if(conc_data_ext.data != NULL)
3236 {
3237 MFREE(conc_data_ext.data);
3238 }
3239 sms_type = MFW_NO_MESSAGE;
3240 /*whenever some operation is done the pref memory should be set back to SIM*/
3241 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
3242 {
3243 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
3244 }
3245 sms_signal(E_SMS_MO, sms_mo);
3246 }
3247 }
3248 }
3249 else
3250 #endif /*TI_PS_FF_CONC_SMS*/
3251 {
3252 #ifdef NO_ASCIIZ
3253 memcpy(sms_mo->dest_addr.tag,
3254 sm->alpha.data,
3255 sm->alpha.len);
3256 sms_mo->dest_addr.len = sm->alpha.len;
3257 #else
3258 phb_Alpha2Gsm(&sm->alpha, (UBYTE *)sms_mo->dest_addr.tag);
3259 #endif
3260 strcpy(sms_mo->dest_addr.number, sm->adress);
3261 sms_mo->dest_addr.ton = phb_cvtTon(sm->toa.ton);
3262 sms_mo->dest_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
3263 if (sm->tosca.ton == TON_International)
3264 sprintf(sms_mo->sc_addr, "+%s", sm->sca);
3265 else
3266 strcpy((char *)sms_mo->sc_addr, sm->sca);
3267
3268 sms_mo->prot_id = (UBYTE)sm->pid;
3269 sms_mo->dcs = sm->dcs;
3270 sms_mo->msg_ref = sm->msg_ref;
3271 sms_mo->vp_mode = 0x03 & sm->fo << 2;
3272 sms_mo->vp_rel = (UBYTE)sm->vp_rel;
3273 /*a0393213 OMAPS00109953 - for normal sms the memory, from where the message is read,
3274 would be the preferred memory, which is set just before calling sAT_PlusCMGR*/
3275 sms_mo->memory=(T_MFW_SMS_MEM)memory.mem;
3276
3277 memcpy((char *)sms_mo->vp_abs.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
3278 memcpy((char *)sms_mo->vp_abs.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
3279 memcpy((char *)sms_mo->vp_abs.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
3280 memcpy((char *)sms_mo->vp_abs.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
3281 memcpy((char *)sms_mo->vp_abs.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
3282 memcpy((char *)sms_mo->vp_abs.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
3283 sms_mo->vp_abs.timezone = sm->scts.timezone;
3284
3285 TRACE_EVENT("Normal MO Message");
3286 sms_mo->msg_len = sm->data.len;
3287 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
3288 /* SPR#2086 - SH - If we've got a WAP SMS, replace the message
3289 * with a string */
3290 if (wap_sms)
3291 {
3292 char *message = "WAP SMS";
3293 strcpy(sms_mt.sms_msg, message);
3294 sms_mt.msg_len = strlen(message);
3295 }
3296 else
3297 {
3298 #endif
3299 /* CQ:16780 clear the buffer before reading in the retrieved SMS, prevents residual characters
3300 from previous message being displayed. 15-01-04 MZ*/
3301
3302 memset(sms_mo->sms_msg, NULL, MAX_MSG_LEN_ARRAY);
3303
3304 /*SPR 2260 if invalid message just set text to NULL*/
3305 if (sm->stat != SMS_STAT_Invalid)
3306 memcpy(sms_mo->sms_msg, (char *)sm->data.data, sm->data.len);
3307 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
3308 }
3309 #endif
3310 sms_type = MFW_NO_MESSAGE;
3311 /*whenever some operation is done the pref memory should be set back to SIM*/
3312 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
3313 {
3314 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
3315 }
3316 sms_signal(E_SMS_MO, sms_mo);
3317 }
3318 }
3319 //Feb 28, 2004 REF: CRR 28809 Deepa M.D
3320 //Deallocate the variable
3321 if(sms_mo!=NULL)
3322 {
3323 mfwFree((U8*)sms_mo, sizeof(T_MFW_SMS_MO));
3324 sms_mo=NULL;
3325 }
3326
3327 break;
3328
3329 //x0pleela 30 Jan, 2006 DR: OMAPS00059261
3330 //Store the status report message into sms_mt
3331 #ifndef NEPTUNE_BOARD
3332 case MFW_MSG_STATUS_REPORT://x0pleela 01 Feb, 2006 DR: OMAPS00059261 /* SMS type: STATUS REPORT */
3333 {
3334 char sms_str[MAX_STAT_MSG_LEN];
3335 TRACE_EVENT("Status report");
3336 #ifdef NO_ASCIIZ
3337 memcpy(sms_mt.orig_addr.tag,
3338 sm->alpha.data,
3339 sm->alpha.len);
3340 sms_mt.orig_addr.len = sm->alpha.len;
3341 #else
3342 phb_Alpha2Gsm(&sm->alpha, (UBYTE *)sms_mt.orig_addr.tag);
3343 #endif
3344 if (sm->toa.ton == TON_International)
3345 sprintf(sms_mt.orig_addr.number, "+%s", sm->adress);
3346 else
3347 strcpy(sms_mt.orig_addr.number, sm->adress);
3348
3349 sms_mt.orig_addr.ton = phb_cvtTon(sm->toa.ton);
3350 sms_mt.orig_addr.npi = (T_MFW_PHB_NPI)phb_cvtNpi(sm->toa.npi);
3351
3352 if (sm->tosca.ton == TON_International)
3353 sprintf(sms_mt.sc_addr, "+%s", sm->sca);
3354 else
3355 strcpy(sms_mt.sc_addr, sm->sca);
3356
3357 sms_mt.prot_id = (UBYTE)sm->pid;
3358 sms_mt.dcs = (UBYTE)sm->dcs & 0xFC; /* Ignore message class */
3359 sms_mt.rp = sm->fo >> 7 & 1;
3360
3361 // PATCH JPS 04.10 END
3362 /* SBH */
3363 if (sm->dcs & 0x10) /* Bit 5 indicates that we should get message class from bits 0 & 1 */
3364 {
3365 sms_mt.ti = sm->dcs & 3;
3366 }
3367 else /* Otherwise, set to default value */
3368 {
3369 sms_mt.ti = 1;
3370 }
3371 /* SBH end */
3372
3373 TRACE_EVENT_P2("dcs: %d, ti: %d", sms_mt.dcs, sms_mt.ti);
3374
3375 memcpy((char *)sms_mt.sctp.year, (char *)sm->scts.year, MAX_SCTP_DIGITS);
3376 memcpy((char *)sms_mt.sctp.month, (char *)sm->scts.month, MAX_SCTP_DIGITS);
3377 memcpy((char *)sms_mt.sctp.day, (char *)sm->scts.day, MAX_SCTP_DIGITS);
3378 memcpy((char *)sms_mt.sctp.hour, (char *)sm->scts.hour, MAX_SCTP_DIGITS);
3379 memcpy((char *)sms_mt.sctp.minute, (char *)sm->scts.minute, MAX_SCTP_DIGITS);
3380 memcpy((char *)sms_mt.sctp.second, (char *)sm->scts.second, MAX_SCTP_DIGITS);
3381 sms_mt.sctp.timezone = sm->scts.timezone;
3382 sms_mt.msg_len = sm->data.len;
3383 TRACE_EVENT_P2("msg_len %d, data.len %d", sms_mt.msg_len, sm->data.len);
3384
3385 memset(sms_str, 0, MAX_STAT_MSG_LEN);
3386 memset(sms_mt.sms_msg, NULL, MAX_MSG_LEN_ARRAY);
3387
3388 //x0pleela 01 Feb, 2006 DR: OMAPS00059261
3389 //To display the message as "Delivered" or "Pending" as per the status
3390 TRACE_EVENT_P1("sm->stat: %d", sm->tp_status);
3391 //x0pleela 06 Feb, 2006 DR: OMAPS00059261
3392 //To display the message as "Delivered" or "Pending" as per the tp_status
3393 if( !sm->tp_status )
3394 {
3395 strcpy(sms_str, "Delivered:");
3396 }
3397 else
3398 {
3399 strcpy(sms_str, "Pending:");
3400 }
3401 strcat(sms_str, sm->adress);
3402 memcpy(sms_mt.sms_msg, sms_str, strlen(sms_str));
3403 sms_mt.msg_len = strlen(sms_str);
3404 TRACE_EVENT_P2("sm->adress:%s, sms_str:%s ",sm->adress,sms_str);
3405
3406 /*SPR 2260 end*/
3407 sms_mt.udh_len = sm->udh.len;
3408 memcpy((char *)sms_mt.udh, (char *)sm->udh.data, sm->udh.len);
3409 sms_type = MFW_NO_MESSAGE;
3410 TRACE_EVENT("read=free1");
3411 coll_sms_read = MFW_SMS_FREE;
3412
3413 //x0pleela 08 Feb, 2006 DR: OMAPS00059261
3414 //Replacing MT_STATUS_RPT with MFW_SMS_STATRPT as MT_STATUS_RPT is removed
3415
3416 //x0pleela 30 Jan, 2006 DR: OMAPS00059261
3417 //Store sms message type
3418 sms_mt.sms_msg_type = MFW_SMS_STATRPT;
3419 sms_mt.voicemail = FALSE;
3420 /*whenever some operation is done the pref memory should be set back to SIM*/
3421 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
3422 {
3423 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
3424 }
3425 sms_signal(E_SMS_MT, &sms_mt);
3426 }
3427 break;
3428 #endif
3429 default:
3430 sms_signal(E_SMS_ERR, NULL);
3431 }
3432 }
3433
3434 else
3435 { TRACE_EVENT("rAT_plusCMGR: SMS pointer error");
3436
3437 }
3438 }
3439 break;
3440
3441 case MFW_CB_MESSAGE:
3442 if (cbm != NULL) /*SPR2260 make sure we have a valid pointer*/
3443 {
3444 sms_cb.sn = cbm->sn;
3445 sms_cb.msg_id = cbm->mid;
3446 sms_cb.dcs = cbm->dcs;
3447 sms_cb.page = cbm->page;
3448 sms_cb.pages = cbm->pages;
3449 sms_cb.msg_len = cbm->data.len;
3450 memcpy((char *)sms_cb.cb_msg, (char *)cbm->data.data, cbm->data.len);
3451
3452 /* send cell broadcast message event */
3453 sms_type = MFW_NO_MESSAGE;
3454 sms_signal(E_SMS_CB, &sms_cb);
3455 }
3456 else
3457 TRACE_EVENT("rAT_plusCMGR: SMS CB pointer error");
3458 break;
3459
3460 case MFW_NO_MESSAGE:
3461 TRACE_EVENT("read=free no msg");
3462 coll_sms_read = MFW_SMS_FREE;
3463 if(coll_sms_read EQ MFW_SMS_WAIT)
3464 coll_sms_read = MFW_SMS_FREE;
3465 break;
3466 }
3467
3468 sms_check_mt_update();
3469
3470 {
3471 TRACE_EVENT_P4("CMGR Msg table: %d,%d,%d, %d", msg_info[0].index, msg_info[1].index,msg_info[2].index,msg_info[3].index);
3472 TRACE_EVENT_P4("CMGR Msg table: %d,%d,%d, %d", msg_info[4].index, msg_info[5].index,msg_info[6].index,msg_info[7].index);
3473 }
3474 }
3475
3476 /*
3477 +--------------------------------------------------------------------+
3478 | PROJECT : GSM-PS (6147) MODULE : MFW_SMS |
3479 | STATE : code ROUTINE : rAT_PlusCMGD |
3480 +--------------------------------------------------------------------+
3481
3482 PURPOSE :
3483 */
3484 GLOBAL void rAT_PlusCMGD ()
3485 {
3486 TRACE_FUNCTION ("rAT_PlusCMGD");
3487 //July 7, 2005 REF: CRR MMI-SPR-32179 x0018858
3488 //Clears the incompleted message buffers.
3489 #ifndef NEPTUNE_BOARD //a0876501 - Shashi - Guarded the below function call for Neptune.
3490 concSMS_clearIncompleteMsg();
3491 #endif
3492 /*a0393213 OMAPS00109953*/
3493 sms_ok_delete();
3494 }
3495 /*a0393213 OMAPS00109953 - updates the memory details*/
3496 static void sms_update_memory()
3497 {
3498 qAT_PlusCPMS_ext( CMD_SRC_LCL, &sim_memory.total, &sim_memory.used, &ffs_memory.total, &ffs_memory.used );
3499
3500 memory.total = sim_memory.total+ffs_memory.total;
3501 memory.used = sim_memory.used+ffs_memory.used;
3502 }
3503
3504
3505 /*
3506 +--------------------------------------------------------------------+
3507 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
3508 | STATE : code ROUTINE : sms_store |
3509 +--------------------------------------------------------------------+
3510
3511 PURPOSE : Save a short message.
3512
3513 GW 09/10/01 - Modified code to always save the maximum message length
3514 */
3515 #ifdef NO_ASCIIZ
3516 T_MFW sms_store(T_MFW_SMS_MO_TYPE type,
3517 CHAR *addr,
3518 UBYTE *msg,
3519 USHORT msg_len,
3520 CHAR *sca)
3521 #else
3522 T_MFW sms_store(T_MFW_SMS_MO_TYPE type,
3523 CHAR *addr,
3524 UBYTE *msg,
3525 USHORT msg_len,
3526 CHAR *sca)
3527 // sbh - added length to the above definition, since '@' characters stored as NULL & will stop
3528 // strlen from working properly.
3529 #endif
3530 {
3531 #ifdef TI_PS_FF_CONC_SMS
3532 T_SM_DATA_EXT conc_data_ext;
3533 #else /*TI_PS_FF_CONC_SMS*/
3534 T_ACI_SM_DATA conc_data_ext;
3535 #endif /*TI_PS_FF_CONC_SMS*/
3536 SHORT rp;
3537 /*a0393213 OMAPS00109953*/
3538 T_MFW_SMS_MEM pref_mem=MFW_MEM_NOTPRESENT;
3539 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
3540 T_ACI_TOA set_toa;
3541 int addr_type;
3542 T_ACI_RETURN ACI_MFW_return;
3543
3544 TRACE_FUNCTION ("sms_store()");
3545
3546 /*a0393213 OMAPS00109953 - identify where to store the new message*/
3547 if(sim_memory.used==sim_memory.total)
3548 {
3549 if(ffs_memory.used==ffs_memory.total)
3550 {
3551 sms_signal(E_SMS_MEM_FULL, 0);
3552 return MFW_SMS_FAIL;
3553 }
3554 else
3555 {
3556 pref_mem=MFW_MEM_ME;
3557 }
3558 }
3559 else
3560 {
3561 pref_mem=MFW_MEM_SIM;
3562 }
3563
3564 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGW*/
3565 if(sms_set_pref_memory(pref_mem)!=MFW_SMS_OK)
3566 {
3567 TRACE_ERROR("sms_read_msg_info():Not able to set pref memory");
3568 return MFW_SMS_FAIL;
3569 }
3570
3571 if (type == MFW_SMS_REPLY OR
3572 type == MFW_SMS_REPLY_SENT )
3573 rp = 0; /* reply path = 0 */
3574 else
3575 rp = -1; /* reply path = default */
3576
3577 #ifdef TI_PS_FF_CONC_SMS
3578 conc_data_ext.data = msg;
3579 conc_data_ext.len = msg_len;
3580 #else /*TI_PS_FF_CONC_SMS*/
3581 conc_data_ext.len = (UBYTE)msg_len;
3582 memcpy(conc_data_ext.data, msg, conc_data_ext.len);
3583 #endif /*TI_PS_FF_CONC_SMS*/
3584
3585 if (type == MFW_SMS_REPLY_SENT OR
3586 type == MFW_SMS_SUBMIT_SENT )
3587 sentStatus = SMS_STAT_StoSent;
3588 else
3589 sentStatus = SMS_STAT_StoUnsent;
3590
3591
3592
3593 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
3594 //setting type of address.
3595 addr_type = is_alphanumeric_addr(addr);
3596
3597
3598 //Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
3599 //sending toa instead of NULL
3600
3601
3602
3603 if ( addr_type == TRUE )
3604 {
3605 set_toa.ton = TON_Alphanumeric;
3606 set_toa.npi = NPI_NotPresent;
3607 ACI_MFW_return = sAT_PlusCMGW(CMD_SRC_LCL, 0, addr, &set_toa,
3608 sentStatus, 0xFF,
3609 &conc_data_ext, sca,
3610 NULL, rp);
3611
3612 }
3613 else
3614 ACI_MFW_return = sAT_PlusCMGW(CMD_SRC_LCL, 0, addr, NULL,
3615 sentStatus, 0xFF,
3616 &conc_data_ext, sca,
3617 NULL, rp);
3618
3619 if(ACI_MFW_return != AT_EXCT)
3620 {
3621 TRACE_EVENT("sAT_PlusCMGW error");
3622 return MFW_SMS_FAIL;
3623 }
3624
3625 wr_addr = addr;
3626 sms_type = MFW_WR_NEW_MESSAGE;
3627 return MFW_SMS_OK;
3628
3629
3630 }
3631
3632
3633
3634
3635 /*
3636 +--------------------------------------------------------------------+
3637 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
3638 | STATE : code ROUTINE : sms_mt_store |
3639 +--------------------------------------------------------------------+
3640
3641 PURPOSE : Save a MT message.
3642
3643 */
3644
3645 T_MFW sms_mt_store(T_MFW_SMS_MT *mt_msg, T_MFW_SMS_STAT stat)
3646 {
3647 #ifdef TI_PS_FF_CONC_SMS
3648 T_SM_DATA_EXT conc_data_ext;
3649 #else /*TI_PS_FF_CONC_SMS*/
3650 T_ACI_SM_DATA conc_data_ext;
3651 #endif /*TI_PS_FF_CONC_SMS*/
3652 T_ACI_TOA toa;
3653 /*a0393213 OMAPS00109953*/
3654 T_MFW_SMS_MEM pref_mem=MFW_MEM_NOTPRESENT;
3655
3656
3657 TRACE_FUNCTION ("sms_mt_store()");
3658
3659 /* check whether memory is full */
3660 /*a0393213 OMAPS00109953 - identify where to store the new message*/
3661 if(sim_memory.used==sim_memory.total)
3662 {
3663 if(ffs_memory.used==ffs_memory.total)
3664 {
3665 sms_signal(E_SMS_MEM_FULL, 0);
3666 return MFW_SMS_FAIL;
3667 }
3668 else
3669 {
3670 pref_mem=MFW_MEM_ME;
3671 }
3672 }
3673 else
3674 {
3675 pref_mem=MFW_MEM_SIM;
3676 }
3677
3678 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGW*/
3679 if(sms_set_pref_memory(pref_mem)!=MFW_SMS_OK)
3680 {
3681 TRACE_ERROR("sms_read_msg_info():Not able to set pref memory");
3682 return MFW_SMS_FAIL;
3683 }
3684
3685 #ifdef TI_PS_FF_CONC_SMS
3686 conc_data_ext.len = mt_msg->msg_len;
3687 conc_data_ext.data = (UBYTE *)mt_msg->sms_msg;
3688 #else /*TI_PS_FF_CONC_SMS*/
3689 conc_data_ext.len = (UBYTE)mt_msg->msg_len;
3690 memcpy(conc_data_ext.data, (UBYTE *)mt_msg->sms_msg, conc_data_ext.len);
3691 #endif /*TI_PS_FF_CONC_SMS*/
3692
3693 toa.ton = phb_ncvtTon(mt_msg->orig_addr.ton);
3694 toa.npi = phb_ncvtNpi(mt_msg->orig_addr.npi);
3695
3696
3697 if (sAT_PlusCMGW(CMD_SRC_LCL, 0, mt_msg->orig_addr.number,
3698 &toa, sms_codeStatus(stat), 0, /* no message reference */
3699 &conc_data_ext,
3700 mt_msg->sc_addr, NULL, -1) NEQ AT_EXCT)
3701
3702 {
3703 TRACE_EVENT("sAT_PlusCMGW error");
3704 return MFW_SMS_FAIL;
3705 }
3706
3707 sms_type = MFW_WR_NEW_MESSAGE;
3708 return MFW_SMS_OK;
3709 }
3710
3711
3712 /*
3713 +--------------------------------------------------------------------+
3714 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
3715 | STATE : code ROUTINE: sms_change |
3716 +--------------------------------------------------------------------+
3717
3718
3719 PURPOSE : Save a changed short message.
3720
3721 GW 09/10/01 - Copy entire message length.
3722
3723 */
3724
3725 #ifdef NO_ASCIIZ
3726 T_MFW sms_change(CHAR *addr, UBYTE *msg,
3727 USHORT msg_len, UBYTE index
3728 #else
3729 T_MFW sms_change(CHAR *addr, USHORT *msg, USHORT msg_len, UBYTE index
3730 // sbh - added length to the above function call, since '@' characters stored as NULL & will stop
3731 // strlen from working properly.
3732 #endif
3733 , T_MFW_SMS_MEM sms_memory) /*a0393213 OMAPS00109953 - memory added as new parameter*/
3734 {
3735 #ifdef TI_PS_FF_CONC_SMS
3736 T_SM_DATA_EXT conc_data_ext;
3737 #else /*TI_PS_FF_CONC_SMS*/
3738 T_ACI_SM_DATA conc_data_ext;
3739 #endif /*TI_PS_FF_CONC_SMS*/
3740
3741
3742 TRACE_FUNCTION ("sms_change()");
3743 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGW*/
3744 if(sms_set_pref_memory(sms_memory)!=MFW_SMS_OK)
3745 {
3746 TRACE_ERROR("sms_read_msg_info():Not able to set pref memory");
3747 return MFW_SMS_FAIL;
3748 }
3749
3750
3751 #ifdef TI_PS_FF_CONC_SMS
3752 conc_data_ext.len = msg_len;
3753 conc_data_ext.data = (UBYTE *)msg;
3754 #else /*TI_PS_FF_CONC_SMS*/
3755 conc_data_ext.len = (UBYTE)msg_len;
3756 memcpy( conc_data_ext.data,(UBYTE *)msg, conc_data_ext.len);
3757 #endif /*TI_PS_FF_CONC_SMS*/
3758
3759 if (sAT_PlusCMGW(CMD_SRC_LCL, index, addr, NULL,
3760 SMS_STAT_StoUnsent, 0xFF, /* message reference */
3761 &conc_data_ext,
3762 NULL, NULL, -1) NEQ AT_EXCT)
3763 return MFW_SMS_FAIL;
3764
3765
3766
3767 sms_type = MFW_WR_CHG_MESSAGE;
3768 return MFW_SMS_OK;
3769 }
3770
3771
3772 /*
3773 +--------------------------------------------------------------------+
3774 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
3775 | STATE : code ROUTINE: rAT_PlusCMGW |
3776 +--------------------------------------------------------------------+
3777
3778
3779 PURPOSE : Call back for saving a short message.
3780
3781 */
3782
3783 void rAT_PlusCMGW(UBYTE index, UBYTE numSeg, UBYTE mem)
3784 {
3785 int i;
3786 T_MFW_PHB_ENTRY phb_entry;
3787 T_MFW_PHB_LIST phb_list;
3788 SHORT phb_index;
3789 #ifdef NO_ASCIIZ
3790 T_MFW_PHB_TEXT findText;
3791 #endif
3792
3793 TRACE_FUNCTION ("rAT_PlusCMGW()");
3794 TRACE_EVENT_P2("Index: %d, numseg: %d", index, numSeg);
3795 /*whenever some operation is done the pref memory should be set back to SIM*/
3796 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
3797 {
3798 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
3799 }
3800 memset(&phb_entry, 0, sizeof(phb_entry));
3801 memset(&phb_list, 0, sizeof(phb_list));
3802 phb_list.entry = &phb_entry;
3803
3804 if (sms_type == MFW_WR_NEW_MESSAGE)
3805 {
3806 #ifdef FF_MMI_SMS_DYNAMIC
3807 for (i=0; i<g_max_messages; i++)
3808 #else
3809 for (i=0; i<MAX_MESSAGES; i++)
3810 #endif
3811 {
3812 if (msg_info[i].index == -1)
3813 break;
3814 }
3815 #ifdef FF_MMI_SMS_DYNAMIC
3816 if (i < g_max_messages)
3817 #else
3818 if (i < MAX_MESSAGES)
3819 #endif
3820 {
3821 msg_info[i].index = index;
3822 /*a0393213 OMAPS00109953*/
3823 /*The memory type returned is of psa type. It should be converted to cmh type.
3824 clean solution would be to move this to ACI*/
3825 cmhSMS_getMemCmh(mem,(T_ACI_SMS_STOR*)&(msg_info[i].mem));
3826 strncpy (msg_info[i].addr.number, wr_addr, MFW_NUM_LEN-1);
3827 msg_info[i].addr.number[MFW_NUM_LEN-1] = 0;
3828 /* search the name in phonebook */
3829 #ifdef NO_ASCIIZ
3830 strcpy((char *)findText.data, wr_addr);
3831 findText.len = strlen(wr_addr);
3832 if (phb_find_entries (PHB_ADN, &phb_index,
3833 MFW_PHB_NUMBER,
3834 1, &findText,
3835 &phb_list) EQ MFW_PHB_OK)
3836 {
3837 if (phb_list.num_entries == 1)
3838 {
3839 memcpy((char *)msg_info[i].addr.tag,
3840 (char *)phb_list.entry->name.data,
3841 phb_list.entry->name.len);
3842 msg_info[i].addr.len = phb_list.entry->name.len;
3843 }
3844 }
3845 #else
3846 if (phb_find_entries (PHB_ADN, &phb_index,
3847 MFW_PHB_NUMBER,
3848 1, (CHAR *)wr_addr,
3849 &phb_list) EQ MFW_PHB_OK)
3850 {
3851 if (phb_list.num_entries == 1)
3852 {
3853 strcpy((char *)msg_info[i].addr.tag, (char *)phb_list.entry->name);
3854 }
3855 }
3856 #endif
3857
3858 if (sentStatus EQ SMS_STAT_StoUnsent)
3859 msg_info[i].stat = MFW_SMS_STOR_UNSENT;
3860 else
3861 msg_info[i].stat = MFW_SMS_STOR_SENT;
3862 /*SPR 2260, we're making the assumption that only complete concat SMSs or single SMSs
3863 can be saved successfully*/
3864 if (numSeg == 1)
3865 msg_info[i].concat_status = MFW_SMS_NO_CONC;
3866 #ifdef TI_PS_FF_CONC_SMS
3867 else
3868 msg_info[i].concat_status = MFW_SMS_CONC_WHOLE;
3869 #endif /*TI_PS_FF_CONC_SMS*/
3870
3871 msg_info[i].first_index = index;/*SPR 2260*/
3872 /*a0393213 OMAPS00109953*/
3873 /*The memory type returned is of psa type. It should be converted to cmh type.
3874 clean solution would be to move this to ACI*/
3875 cmhSMS_getMemCmh(mem,(T_ACI_SMS_STOR*)&(msg_info[i].first_mem));
3876 msg_info[i].msg_type = MFW_SMS_NotVOICE; // ???
3877 memory.used +=numSeg;/*SPR2260*/
3878 }
3879 }
3880 /*SPR 2260*/
3881 /*a0393213 OMAPS00109953*/
3882 sms_update_memory();
3883 TRACE_EVENT_P2("memory used is = %d, of %d", memory.used, memory.total);
3884 if(memory.total == memory.used)
3885 {
3886
3887 sms_signal(E_SMS_MEM_FULL, NULL);
3888 }
3889 sms_type = MFW_NO_MESSAGE;
3890
3891 sms_check_mt_update();
3892
3893 sms_signal(E_SMS_SAVE_AVAIL, &index);
3894 }
3895
3896
3897 /*
3898 +--------------------------------------------------------------------+
3899 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
3900 | STATE : code ROUTINE: sms_msg_delete |
3901 +--------------------------------------------------------------------+
3902
3903
3904 PURPOSE : Delete a short message.
3905
3906 */
3907 /*a0393213 OMAPS00109953 - memory added as parameter*/
3908 T_MFW sms_msg_delete(UBYTE index, T_MFW_SMS_MEM sms_memory)
3909 {
3910 TRACE_FUNCTION ("sms_msg_delete()");
3911
3912 /*a0393213 OMAPS00109953 - set preferred memory before calling sAT_PlusCMGD*/
3913 if(sms_set_pref_memory(sms_memory)!=MFW_SMS_OK)
3914 {
3915 TRACE_ERROR("sms_read_msg_info():Not able to set pref memory");
3916 return MFW_SMS_FAIL;
3917 }
3918 coll_sms_delete = MFW_SMS_WAIT;
3919
3920 #ifdef FF_2TO1_PS
3921 if (sAT_PlusCMGD(CMD_SRC_LCL, index, MNSMS_CMGD_DEL_INDEX) NEQ AT_EXCT)
3922 #else
3923 /* a0876501 (Shashi), 08-Nov-2005, OMAPS00050772.
3924 Added new parameter to be passed (3rd Parameter is set to 0). */
3925 if (sAT_PlusCMGD(CMD_SRC_LCL, index,0) NEQ AT_EXCT)
3926 #endif
3927 return MFW_SMS_FAIL;
3928 /*MC*/
3929 deleting_index = index;
3930 deleting_memory= sms_memory;
3931 return MFW_SMS_OK;
3932 }
3933
3934 /*
3935 +--------------------------------------------------------------------+
3936 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
3937 | STATE : code ROUTINE: sms_ok_change |
3938 +--------------------------------------------------------------------+
3939
3940 PURPOSE : Call back for the status change of a short message.form
3941 UNREAD to READ
3942
3943 */
3944
3945 void sms_ok_change()
3946 {
3947
3948
3949
3950 // Dec 23, 2004 REF: CRR MMI-SPR-27741 xkundadu
3951 // Issue description: BMI: crashing when using the function : sms_index_list() located in mfw
3952 // Solution: Changed the msg_list variable to array of T_MFW_SMS_IDX.
3953
3954 // May 27, 2005 MMI-FIX-29869 x0018858 - Modified from static to dynamic variable
3955 #ifdef FF_MMI_SMS_DYNAMIC
3956 T_MFW_SMS_IDX* msg_list;
3957 #else
3958 T_MFW_SMS_IDX msg_list[MAX_MESSAGES];
3959 #endif
3960 int noOfVMSMS = 0; // stores number of VM sms
3961 int i;
3962 // May 27, 2005 MMI-FIX-29869 x0018858 - Modified from static to dynamic variable
3963 #ifdef FF_MMI_SMS_DYNAMIC
3964 msg_list = (T_MFW_SMS_IDX*)ALLOC_MEMORY(g_max_messages*sizeof(T_MFW_SMS_IDX));
3965 #endif
3966
3967 TRACE_FUNCTION ("sms_ok_change()");
3968
3969 /* Marcus: Issue 2260: 03/10/2002: Start */
3970 if (cmgr_awaiting_ok == TRUE)
3971 {
3972 cmgr_awaiting_ok = FALSE;
3973 /* Marcus: Issue 2260: 03/10/2002: End */
3974
3975 if (fg)
3976 {
3977 fg = 0;
3978 sms_update_msg_info(MFW_SMS_READ);
3979 sms_signal(E_SMS_OK, 0);
3980 }
3981
3982 sms_check_mt_update();
3983
3984
3985 // Dec 23, 2004 REF: CRR MMI-SPR-27741 xkundadu
3986 // Issue description: BMI: crashing when using the function : sms_index_list() located in mfw
3987 // Solution: Changed the msg_list variable to array of T_MFW_SMS_IDX.
3988 #ifdef FF_MMI_SMS_DYNAMIC
3989 noOfVMSMS = sms_index_list(MFW_SMS_VOICE, msg_list, g_max_messages) ;
3990 #else
3991 noOfVMSMS = sms_index_list(MFW_SMS_VOICE, msg_list, MAX_MESSAGES) ;
3992 #endif
3993 TRACE_EVENT_P1("No of VM sms:%d", noOfVMSMS);
3994 // Checking the number of VM sms.
3995 if( noOfVMSMS > 0)
3996 {
3997 //Delete the vm sms which is read.
3998 for(i=0;i<noOfVMSMS;i++)
3999 {
4000 //Find out the VM sms which is already read and delete it.
4001 if(msg_list[i].stat == MFW_SMS_READ)
4002 {
4003 /*a0393213 OMAPS00109953 - memory type passed as parameter*/
4004 sms_msg_delete(msg_list[i].index,msg_list[i].memory);
4005 break;
4006 }
4007 }
4008 }
4009
4010 /* Marcus: Issue 2260: 03/10/2002: Start */
4011 }
4012 else
4013 {
4014 TRACE_EVENT("Ignoring unexpected OK");
4015 }
4016 #ifdef FF_MMI_SMS_DYNAMIC
4017 // May 27, 2005 MMI-FIX-29869 x0018858 - Freeing the memory.
4018 FREE_MEMORY((U8*)msg_list, g_max_messages*sizeof(T_MFW_SMS_IDX));
4019 #endif
4020 /* Marcus: Issue 2260: 03/10/2002: End */
4021 }
4022
4023 /*
4024 +--------------------------------------------------------------------+
4025 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4026 | STATE : code ROUTINE: sms_ok_delete |
4027 +--------------------------------------------------------------------+
4028
4029
4030 PURPOSE : Call back for deleting a short message.
4031
4032 */
4033
4034 void sms_ok_delete()
4035 {
4036
4037 TRACE_FUNCTION ("sms_ok_delete()");
4038 /*SPR2530, moved flag claering code here from delete_sms_from_table*/
4039
4040 if(coll_sms_delete EQ MFW_SMS_WAIT)
4041 coll_sms_delete = MFW_SMS_FREE;
4042 /*whenever some operation is done the pref memory should be set back to SIM*/
4043 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
4044 {
4045 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
4046 }
4047 /*SPR 1833, replaces section of code with function call*/
4048 /*a0393213 OMAPS00109953 - memory type passed as parameter*/
4049 if (delete_sms_from_table (deleting_index, deleting_memory))
4050 {
4051 deleting_index = -1; /*Hope this fixes multiple deletions*/
4052 /*a0393213 OMAPS00109953*/
4053 deleting_memory = MFW_MEM_NOTPRESENT;
4054 /*SPR 2260, we have to request the SMS storage status to update memory.used*/
4055 /*as we have no idea how many segments the deleted SMS had*/
4056 int_req = POST_DELETE_CHECK;/*update memory variable, don't send an event to MMI*/
4057
4058 /* cq16875 If the SIM Entity is busy then don't send an E_SmS_OK event to the MMI
4059 12-02-04 MZ.*/
4060 if(AT_BUSY != qAT_PlusCPMS(CMD_SRC_LCL))
4061 sms_signal(E_SMS_OK, 0);
4062
4063 sms_signal(E_SMS_MEM_FREE, 0);
4064
4065 sms_check_mt_update();
4066 }
4067 {
4068 TRACE_EVENT_P4("CMGD Msg table: %d,%d,%d, %d", msg_info[0].index, msg_info[1].index,msg_info[2].index,msg_info[3].index);
4069 TRACE_EVENT_P4("CMGD Msg table: %d,%d,%d, %d", msg_info[4].index, msg_info[5].index,msg_info[6].index,msg_info[7].index);
4070 }
4071 }
4072 /*
4073 +--------------------------------------------------------------------+
4074 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4075 | STATE : code ROUTINE: delete_sms_from_table |
4076 +--------------------------------------------------------------------+
4077
4078
4079 PURPOSE : deletes a message from the MFW message table
4080 created for SPR2260
4081
4082 */
4083 /*a0393213 OMAPS00109953 - memory type added as a parameter*/
4084 BOOL delete_sms_from_table (SHORT index, T_MFW_SMS_MEM memory)
4085 {
4086 int i;
4087
4088 TRACE_FUNCTION ("delete_sms_from_table()");
4089
4090 /*SPR2530, removed flag clearing code*/
4091 #ifdef FF_MMI_SMS_DYNAMIC
4092 for (i=0; i<g_max_messages; i++)
4093 #else
4094 for (i=0; i<MAX_MESSAGES; i++)
4095 #endif
4096 {
4097 /*a0393213 OMAPS00109953 - memory is also taken into consideration*/
4098 if (msg_info[i].index == index&& msg_info[i].mem == memory)
4099 {
4100 msg_info[i].index = -1;
4101 /*a0393213 OMAPS00109953*/
4102 msg_info[i].mem = MFW_MEM_NOTPRESENT;
4103 msg_info[i].stat = MFW_SMS_UNKNOWN;
4104 msg_info[i].msg_type = MFW_SMS_UNKNOWN;
4105 msg_info[i].addr.number[0] = '\0';
4106 msg_info[i].addr.tag[0] = '\0';
4107 msg_info[i].addr.ton = MFW_TON_UNKNOWN;
4108 msg_info[i].addr.npi = MFW_NPI_UNKNOWN;
4109 /*SPR 2260, reset new elements*/
4110 msg_info[i].first_index = -1;
4111 /*a0393213 OMAPS00109953*/
4112 msg_info[i].first_mem=MFW_MEM_NOTPRESENT;
4113 msg_info[i].concat_status = MFW_SMS_NO_CONC;
4114 return TRUE;
4115 }
4116 }
4117
4118 return FALSE;
4119 }
4120 /*
4121 +--------------------------------------------------------------------+
4122 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4123 | STATE : code ROUTINE: sms_command |
4124 +--------------------------------------------------------------------+
4125
4126
4127 PURPOSE : Send a mobile originated short massage command.
4128
4129 */
4130
4131 T_MFW sms_command(CHAR *dest_addr, UBYTE command, UBYTE msg_ref)
4132 {
4133 TRACE_FUNCTION ("sms_command()");
4134
4135 switch (command)
4136 {
4137 case SMS_ENQ_PREV_SMS:
4138 if (sAT_PlusCMGC(CMD_SRC_LCL,
4139 0x22, // SMS command with Status Report Request
4140 0x00, // Command Type
4141 0x00, // Protocol Identifier
4142 msg_ref, // message reference of previous SMS
4143 dest_addr, // destination address
4144 NULL, // type of destination address
4145 NULL) // command data
4146 NEQ AT_EXCT)
4147 return MFW_SMS_FAIL;
4148 break;
4149
4150 case SMS_CAN_STAT_REQ:
4151 if (sAT_PlusCMGC(CMD_SRC_LCL,
4152 0x02, // SMS command without Status Report Request
4153 0x01, // Command Type
4154 0x00, // Protocol Identifier
4155 msg_ref, // message reference of previous SMS
4156 dest_addr, // destination address
4157 NULL, // type of destination address
4158 NULL) // command data
4159 NEQ AT_EXCT)
4160 return MFW_SMS_FAIL;
4161 break;
4162
4163 case SMS_DEL_PREV_SMS:
4164 if (sAT_PlusCMGC(CMD_SRC_LCL,
4165 0x02, // SMS command without Status Report Request
4166 0x02, // Command Type
4167 0x00, // Protocol Identifier
4168 msg_ref, // message reference of previous SMS
4169 dest_addr, // destination address
4170 NULL, // type of destination address
4171 NULL) // command data
4172 NEQ AT_EXCT)
4173 return MFW_SMS_FAIL;
4174 break;
4175
4176 case SMS_REQ_STAT_REP:
4177 if (sAT_PlusCMGC(CMD_SRC_LCL,
4178 0x02, // SMS command without Status Report Request
4179 0x03, // Command Type
4180 0x00, // Protocol Identifier
4181 msg_ref, // message reference of previous SMS
4182 dest_addr, // destination address
4183 NULL, // type of destination address
4184 NULL) // command data
4185 NEQ AT_EXCT)
4186 return MFW_SMS_FAIL;
4187 break;
4188 default:
4189 /*
4190 * non-supported command type
4191 */
4192 return MFW_SMS_FAIL;
4193 }
4194 return MFW_SMS_OK;
4195 }
4196
4197 /*
4198 +-------------------------------------------------------------------------------+
4199 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4200 | STATE : code ROUTINE: sms_set_SrvCntr_number |
4201 +-------------------------------------------------------------------------------+
4202
4203 PURPOSE : MMI sets the Service Center Number on the SIM
4204
4205 */
4206
4207 T_MFW sms_set_SrvCntr_number(T_MFW_SMS_INFO *sms_info)
4208 {
4209 T_ACI_RETURN res;
4210
4211 TRACE_FUNCTION ("sms_set_SrvCntr_Nmbr_parameter()");
4212
4213
4214 if(sms_info == 0)
4215 return MFW_SMS_FAIL;
4216
4217 if (sAT_PlusCSCA(CMD_SRC_LCL, (char *)sms_info->sc_addr, 0) NEQ AT_CMPL)
4218 return MFW_SMS_FAIL;
4219 /* Send text mode parameters to ACI */
4220
4221
4222 if (sAT_PlusCSMP(CMD_SRC_LCL, ACI_NumParmNotPresent, ACI_NumParmNotPresent,
4223 NULL, NULL, ACI_NumParmNotPresent,
4224 ACI_NumParmNotPresent) NEQ AT_CMPL)
4225 return MFW_SMS_FAIL;
4226
4227 res = sAT_PlusCSAS(CMD_SRC_LCL, (SHORT) 1);
4228 switch (res)
4229 {
4230 case AT_FAIL:
4231 return MFW_SMS_FAIL;
4232 case AT_CMPL:
4233 sms_signal(E_SMS_OK, 0);
4234 return MFW_SMS_OK;
4235 case AT_EXCT:
4236 return MFW_SMS_OK;
4237 default:
4238 return MFW_SMS_FAIL;
4239 }
4240
4241 /*a0393213 compiler warnings removal - return statement removed*/
4242 }
4243
4244 /*
4245 +-------------------------------------------------------------------------------+
4246 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4247 | STATE : code ROUTINE: sms_set_dcs_number |
4248 +-------------------------------------------------------------------------------+
4249
4250 PURPOSE : MMI sends the dcs data to the sim (control 7bit ascii (compressed),
4251 8bit or 16bit (unicode) uncompressed data
4252
4253
4254 */
4255 T_MFW sms_set_dcs_number(T_MFW_SMS_INFO *sms_info)
4256 {
4257
4258 TRACE_FUNCTION ("sms_set_dcs_parameter()");
4259
4260
4261 if(sms_info == 0)
4262 return MFW_SMS_FAIL;
4263
4264
4265 if (sAT_PlusCSMP(CMD_SRC_LCL, ACI_NumParmNotPresent, ACI_NumParmNotPresent,
4266 NULL, NULL, ACI_NumParmNotPresent,
4267 sms_info->dcs ) NEQ AT_CMPL)
4268 return MFW_SMS_FAIL;
4269
4270 return MFW_SMS_OK;
4271 }
4272
4273
4274 /*
4275 +-------------------------------------------------------------------------------+
4276 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4277 | STATE : code ROUTINE: sms_set_val_period |
4278 +-------------------------------------------------------------------------------+
4279
4280 PURPOSE : MMI sends the Validity Period to the ACI
4281
4282
4283 */
4284 T_MFW sms_set_val_period(T_MFW_SMS_INFO *sms_info)
4285 {
4286
4287 TRACE_FUNCTION ("sms_set_val_period()");
4288
4289 if(sms_info == 0)
4290 return MFW_SMS_FAIL;
4291
4292 /*Jan 20, 2006 REF: DRT OMAPS00053377 xdeepadh
4293 MMI supports only the relative validity period format.
4294 Hence, set the validity period format to relative for all the cases*/
4295 if ((sms_info->vp_mode EQ SMS_VPF_NUMERICAL) ||(sms_info->vp_mode EQ SMS_VPF_STRING) ||(sms_info->vp_mode EQ SMS_VPF_NOTPRESENT))
4296 {
4297
4298 TRACE_EVENT_P1("sms_info->vp_mode %d",sms_info->vp_mode);
4299 TRACE_EVENT("MMI supports only the relative validity period format ");
4300
4301 /*Set the TP-Validity-Period-Format (TP-VPF) bits to relative format */
4302 sms_info->first_oct = sms_info->first_oct | 0x10 ;
4303
4304 }
4305
4306 TRACE_EVENT_P1("first_oct is %d",sms_info->first_oct);
4307
4308 //Send text mode parameters to ACI
4309 if (sAT_PlusCSMP(CMD_SRC_LCL, sms_info->first_oct, sms_info->vp_rel,
4310 NULL, NULL, ACI_NumParmNotPresent,
4311 ACI_NumParmNotPresent) NEQ AT_CMPL)
4312 return MFW_SMS_FAIL;
4313
4314 return MFW_SMS_OK;
4315 }
4316
4317 //Feb 22, 2006 DR:OMAPS00068268 x0035544
4318 BOOL Sms_Check_PID(SHORT pid)
4319 {
4320 TRACE_FUNCTION("Sms_Check_PID()");
4321
4322 if(pid & BIT_7)
4323 {
4324 if(!(pid & BIT_6)) // Bit 7 = 1 and Bit 6 = 0
4325 return TRUE;
4326 }
4327 else
4328 {
4329 if(pid & BIT_6) // Bit 7 = 0 and Bit 6 = 1, Bits 5...0 some values are reserved
4330 {
4331 if(((pid >= 0x48) AND (pid <= 0x5E)) OR
4332 ((pid >= 0x60) AND (pid <= 0x7B)))
4333 return TRUE;
4334 }
4335 else
4336 {
4337 if(pid & BIT_5) // Bit 7 = 0, Bit 6 = 0 and Bit 5 = 1, Bits 4...0 some values are reserved
4338 {
4339 if((pid EQ 0x2E) OR (pid EQ 0x2F) OR
4340 ((pid >= 0x33) AND (pid <= 0x37)))
4341 return TRUE;
4342 }
4343 }
4344 }
4345
4346 return FALSE;
4347 }
4348
4349
4350 /*
4351 +--------------------------------------------------------------------+
4352 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4353 | STATE : code ROUTINE: sms_parameter |
4354 +--------------------------------------------------------------------+
4355
4356
4357 PURPOSE : MMI sets SMS parameters.
4358
4359 */
4360
4361
4362 T_MFW sms_parameter(T_MFW_SMS_INFO *sms_info, BOOL fGet)
4363 {
4364 T_ACI_TOA sc_typ;
4365
4366 CHAR sca[MAX_LEN];
4367 SHORT first_oct=0x0000;
4368
4369 SHORT vprel;
4370 T_ACI_VP_ABS vpabs;
4371 SHORT pid;
4372 SHORT dcs;
4373 T_ACI_RETURN res;
4374 //x0035544 Feb 22, 2006 DR:OMAPS00068268
4375 BOOL PIDReserved;
4376
4377 TRACE_FUNCTION ("sms_parameter()");
4378
4379 if(sms_info == 0)
4380 return MFW_SMS_FAIL;
4381
4382 if(fGet) {
4383
4384 memset(sms_info, 0, sizeof(T_MFW_SMS_INFO));
4385
4386 if (qAT_PlusCSCA(CMD_SRC_LCL,
4387 sca,
4388 &sc_typ) EQ AT_FAIL
4389 OR qAT_PlusCSMP(CMD_SRC_LCL,
4390 &first_oct,
4391 &vprel,
4392 &vpabs,
4393 NULL,
4394 &pid,
4395 &dcs ) EQ AT_FAIL)
4396 {
4397
4398 return MFW_SMS_FAIL;
4399 }
4400
4401 if (sc_typ.ton == TON_International)
4402 sprintf(sms_info->sc_addr, "+%s", sca);
4403 else
4404 strcpy((char *)sms_info->sc_addr, (char *)sca);
4405 //x0035544 Feb 22, 2006 DR:OMAPS00068268
4406 PIDReserved = Sms_Check_PID(pid);
4407 /* If pid value falls in to any of Reserved category then set it to 0 */
4408 if(PIDReserved)
4409 pid = 0;
4410 sms_info->prot_id = pid;
4411 sms_info->dcs = dcs;
4412 sms_info->vp_rel = (UBYTE)vprel;
4413 memcpy(&sms_info->vp_abs, &vpabs, sizeof(T_MFW_SMS_SCTP));
4414
4415 if ((first_oct & 0x18) EQ 0x10)
4416 sms_info->vp_mode = SMS_VPF_NUMERICAL;
4417 if ((first_oct & 0x18) EQ 0x18)
4418 sms_info->vp_mode = SMS_VPF_STRING;
4419 if ((first_oct & 0x18) EQ 0x00)
4420 sms_info->vp_mode = SMS_VPF_NOTPRESENT;
4421
4422 sms_info->rd = first_oct >> 2 & 1;
4423 sms_info->rp = first_oct >> 7 & 1;
4424 sms_info->srr = first_oct >> 5 & 1;
4425 /*Jan 20, 2006 REF: DRT OMAPS00053377 xdeepadh
4426 Store the first octet details in the structure.*/
4427 sms_info->first_oct = first_oct;
4428
4429 } else {
4430
4431 if (sAT_PlusCSCA(CMD_SRC_LCL, (char *)sms_info->sc_addr, 0) NEQ AT_CMPL)
4432 {
4433 return MFW_SMS_FAIL;
4434 }
4435 /* Send text mode parameters to ACI */
4436 if (sms_info->vp_mode EQ SMS_VPF_NUMERICAL)
4437 first_oct = 0x11;
4438 if (sms_info->vp_mode EQ SMS_VPF_STRING)
4439 first_oct = 0x19;
4440 if (sms_info->vp_mode EQ SMS_VPF_NOTPRESENT)
4441 first_oct = 0x01;
4442
4443 first_oct |= sms_info->rd << 2;
4444 first_oct |= sms_info->rp << 7;
4445 first_oct |= sms_info->srr << 5;
4446
4447 if (sAT_PlusCSMP(CMD_SRC_LCL, first_oct, sms_info->vp_rel,
4448 (T_ACI_VP_ABS *)&sms_info->vp_abs, NULL, sms_info->prot_id,
4449 sms_info->dcs) NEQ AT_CMPL)
4450 {
4451 return MFW_SMS_FAIL;
4452 }
4453 res = sAT_PlusCSAS(CMD_SRC_LCL, (SHORT) 1);
4454 switch (res)
4455 {
4456 case AT_FAIL:
4457 return MFW_SMS_FAIL;
4458 case AT_CMPL:
4459 sms_signal(E_SMS_OK, 0);
4460 return MFW_SMS_OK;
4461 case AT_EXCT:
4462 return MFW_SMS_OK;
4463 default:
4464 return MFW_SMS_FAIL;
4465 }
4466 }
4467
4468 return MFW_SMS_OK;
4469 }
4470
4471
4472 /*
4473 +--------------------------------------------------------------------+
4474 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4475 | STATE : code ROUTINE: sms_busy_ind |
4476 +--------------------------------------------------------------------+
4477
4478
4479 PURPOSE : SMS busy indication to MMI.
4480
4481 */
4482
4483 void sms_busy_ind(void) // bugfix for SIM refresh
4484 {
4485 int_req = 0;
4486 sms_signal(E_SMS_BUSY, 0);
4487 }
4488
4489
4490 /*
4491 +----------------------------------------------------------------------------+
4492 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4493 | STATE : code ROUTINE: sms_set_cell_broadcast_info |
4494 +----------------------------------------------------------------------------+
4495
4496
4497 PURPOSE : MMI sets SMS cell broadcast parameters.
4498
4499 */
4500
4501 T_MFW sms_set_cell_broadcast_info(UBYTE mode, T_MFW_SMS_CB_INFO *sms_cb_info)
4502 {
4503 T_ACI_RETURN res;
4504
4505 TRACE_FUNCTION ("sms_set_cell_broadcast_info()");
4506 /*SPR 2470, if the Channel ID list is empty, the mode logic is inverted due to the warped logic of
4507 AT commands*/
4508
4509 /*if we are disabling cell broadcast*/
4510 if (mode == 1)
4511 { /* and the channel ID list is empty*/
4512 if (sms_cb_info->msg_id[0] == 0xFFFF)
4513 mode =0;
4514 }
4515 /*if we are enabling cell broadcast*/
4516 else
4517 { /* and the channel ID list is empty*/
4518 if (sms_cb_info->msg_id[0] == 0xFFFF)
4519 mode =1;
4520 }
4521
4522 if (sAT_PlusCSCB(CMD_SRC_LCL, (T_ACI_CSCB_MOD)mode, sms_cb_info->msg_id, sms_cb_info->dcs) NEQ AT_CMPL) /*a0393213 compiler warnings removal - explicit typecasting done*/
4523 return MFW_SMS_FAIL;
4524
4525 res = sAT_PlusCSAS(CMD_SRC_LCL, (SHORT) 1);
4526 switch (res)
4527 {
4528 case AT_FAIL:
4529 return MFW_SMS_FAIL;
4530 case AT_CMPL:
4531 sms_signal(E_SMS_OK, 0);
4532 return MFW_SMS_OK;
4533 case AT_EXCT:
4534 return MFW_SMS_OK;
4535 default:
4536 return MFW_SMS_FAIL;
4537 }
4538
4539 /*a0393213 compiler warnings removal - return statement removed*/
4540 }
4541
4542 /*
4543 +----------------------------------------------------------------------------+
4544 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4545 | STATE : code ROUTINE: sms_get_cell_broadcast_info |
4546 +----------------------------------------------------------------------------+
4547
4548
4549 PURPOSE : MMI gets SMS cell broadcast parameters.
4550
4551 */
4552 #ifdef FF_2TO1_PS
4553 T_MFW sms_get_cell_broadcast_info(T_MFW_SMS_CB_INFO *sms_cb_info)
4554 {
4555 T_ACI_CSCB_MOD mode;
4556 USHORT mids[CBM_MAX_RANGE_NUMBER];
4557 UBYTE dcss[CBM_MAX_RANGE_NUMBER];
4558 UBYTE c_mids, c_dcss;
4559 TRACE_FUNCTION ("sms_get_cell_broadcast_info()");
4560
4561 memset(dcss,0xFF,CBM_MAX_RANGE_NUMBER);
4562 memset(mids,0xFFFF,CBM_MAX_RANGE_NUMBER);
4563
4564 if (qAT_PlusCSCB(CMD_SRC_LCL, &mode, &c_mids, mids, &c_dcss, dcss) EQ AT_CMPL)
4565 {
4566
4567 sms_cb_info->mode = mode;
4568 memcpy((char *)sms_cb_info->dcs, (char *)dcss, CBM_MAX_RANGE_NUMBER);
4569
4570 memcpy((char *)sms_cb_info->msg_id, (char *)mids, sizeof(mids));
4571
4572 return MFW_SMS_OK;
4573 }
4574 else
4575 return MFW_SMS_FAIL;
4576 }
4577 #else
4578 T_MFW sms_get_cell_broadcast_info(T_MFW_SMS_CB_INFO *sms_cb_info)
4579 {
4580 T_ACI_CSCB_MOD mode;
4581 USHORT mids[MAX_IDENTS];
4582 UBYTE dcss[MAX_IDENTS];
4583
4584 TRACE_FUNCTION ("sms_get_cell_broadcast_info()");
4585
4586 memset(dcss,0xFF,MAX_IDENTS);
4587 memset(mids,0xFFFF,MAX_IDENTS);
4588
4589 if (qAT_PlusCSCB(CMD_SRC_LCL, &mode, mids, dcss) EQ AT_CMPL)
4590 {
4591
4592 sms_cb_info->mode = mode;
4593 memcpy((char *)sms_cb_info->dcs, (char *)dcss, MAX_IDENTS);
4594
4595 memcpy((char *)sms_cb_info->msg_id, (char *)mids, sizeof(mids));
4596
4597 return MFW_SMS_OK;
4598 }
4599 else
4600 return MFW_SMS_FAIL;
4601 }
4602
4603
4604 #endif
4605
4606 /*
4607 +--------------------------------------------------------------------+
4608 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4609 | STATE : code ROUTINE: rAT_PlusCMGS |
4610 +--------------------------------------------------------------------+
4611
4612
4613 PURPOSE : Call back to inform about the successful sending of
4614 a mobile originated short massage.
4615
4616 */
4617
4618 void rAT_PlusCMGS(UBYTE mr, UBYTE numSeg)
4619 {
4620 TRACE_FUNCTION ("rAT_PlusCMGS()");
4621
4622 if(coll_sms_send EQ MFW_SMS_WAIT)
4623 coll_sms_send = MFW_SMS_FREE;
4624
4625 sms_check_mt_update();
4626 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
4627
4628 /* SPR#2086 - SH - Check if it's a WAP SMS */
4629 if (sms_wap_sent_flag)
4630 {
4631 sms_wap_sent_flag = FALSE;
4632 sms_signal(E_SMS_WAP_MO_SENT, &mr);
4633 }
4634 else
4635 {
4636 sms_signal(E_SMS_MO_AVAIL, &mr);
4637 }
4638 #else
4639 sms_signal(E_SMS_MO_AVAIL, &mr);
4640 #endif
4641 }
4642
4643
4644 /*
4645 +--------------------------------------------------------------------+
4646 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4647 | STATE : code ROUTINE: rAT_PlusCMGC |
4648 +--------------------------------------------------------------------+
4649
4650
4651 PURPOSE : Call back to inform about the successful sending of a
4652 mobile originated short massage command.
4653
4654 */
4655
4656 void rAT_PlusCMGC(UBYTE mr)
4657 {
4658 TRACE_FUNCTION ("rAT_PlusCMGC()");
4659
4660 sms_check_mt_update();
4661
4662 sms_signal(E_SMS_CMD_AVAIL, &mr);
4663 }
4664
4665
4666 /*
4667 +--------------------------------------------------------------------+
4668 | PROJECT: MMI-Framework (8417) MODULE: MFW_SMS |
4669 | STATE : code ROUTINE: rAT_PlusCMS |
4670 +--------------------------------------------------------------------+
4671
4672
4673 PURPOSE : Report the error result on failures of the last
4674 executed functions
4675
4676 */
4677
4678 void rAT_PlusCMS (T_ACI_AT_CMD cmdId, T_ACI_CMS_ERR err, T_EXT_CMS_ERROR *ce)
4679 {
4680 T_MFW_SMS_CMD_IND cmd_ind;
4681
4682 TRACE_FUNCTION ("rAT_PlusCMS()");
4683 TRACE_EVENT_P1("Error: %d",cmdId);
4684
4685 switch (cmdId)
4686 {
4687 case AT_CMD_CMGS:
4688 case AT_CMD_CMSS:
4689 cmd_ind = CMD_SMS_SUBMIT;
4690 coll_sms_send = MFW_SMS_FREE;
4691
4692 #if defined (FF_WAP) && defined (FF_GPF_TCPIP)
4693
4694 /* SPR#2086 - SH - Check if it's a WAP SMS */
4695 if (sms_wap_sent_flag)
4696 {
4697 sms_wap_sent_flag = FALSE;
4698 sms_signal(E_SMS_WAP_ERR, &cmd_ind);
4699 }
4700 else
4701 {
4702 sms_signal(E_SMS_ERR, &cmd_ind);
4703 }
4704 #else
4705 sms_signal(E_SMS_ERR, &cmd_ind);
4706 #endif
4707 break;
4708
4709 case AT_CMD_CMGC:
4710 cmd_ind = CMD_SMS_COMMAND;
4711 coll_sms_req = MFW_SMS_FREE;
4712 sms_signal(E_SMS_ERR, &cmd_ind);
4713 break;
4714
4715 case AT_CMD_CPMS:
4716 cmd_ind = CMD_SMS_MEMORY;
4717 sms_signal(E_SMS_ERR, &cmd_ind);
4718 break;
4719
4720 case AT_CMD_CMGR:
4721 cmd_ind = CMD_SMS_READ;
4722 coll_sms_read = MFW_SMS_FREE;
4723 sms_signal(E_SMS_ERR, &cmd_ind);
4724 break;
4725
4726 case AT_CMD_CMGL:
4727 cmd_ind = CMD_SMS_READ;
4728 coll_sms_read = MFW_SMS_FREE;
4729 sms_signal(E_SMS_ERR, &cmd_ind);
4730 sms_ok_CMGL(); /*JVJ SPR1118 This case has been added to handle the Error of CMGL
4731 when the SIM Card has no messages. Even without SMS in the SIM card,
4732 the call to qAT_PlusCPMS to query the memory status is still needed */
4733 break;
4734
4735 case AT_CMD_CMGW:
4736 sms_type = MFW_NO_MESSAGE;
4737 cmd_ind = CMD_SMS_STORE;
4738 coll_sms_send = MFW_SMS_FREE;
4739 sms_signal(E_SMS_ERR, &cmd_ind);
4740 break;
4741
4742 case AT_CMD_CMGD:
4743 cmd_ind = CMD_SMS_SET_PARA;
4744 coll_sms_delete = MFW_SMS_FREE;
4745 sms_signal(E_SMS_ERR, &cmd_ind);
4746 break;
4747
4748 case AT_CMD_CSAS:
4749 cmd_ind = CMD_SMS_DELETE;
4750 sms_signal(E_SMS_ERR, &cmd_ind);
4751 break;
4752 }
4753
4754 sms_check_mt_update();
4755 }
4756
4757
4758 /*
4759 +--------------------------------------------------------------------+
4760 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
4761 | STATE : code ROUTINE : sms_get_memset |
4762 +--------------------------------------------------------------------+
4763
4764 PURPOSE : This function is used to request the preferred SMS memory
4765 */
4766 T_MFW sms_get_memset(void)
4767 {
4768 TRACE_FUNCTION ("sms_get_memset()");
4769
4770 coll_sms_req = MFW_SMS_WAIT;
4771
4772 if (qAT_PlusCPMS(CMD_SRC_LCL) EQ AT_EXCT)
4773 return MFW_SMS_OK;
4774 return MFW_SMS_FAIL;
4775 }
4776
4777
4778 /*
4779 +---------------------------------------------------------------------------+
4780 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
4781 | STATE : code ROUTINE : rAT_PlusCPMS |
4782 +---------------------------------------------------------------------------+
4783
4784 PURPOSE : Call back for request of preferred SMS memory.
4785 */
4786
4787 GLOBAL void rAT_PlusCPMS (T_ACI_SMS_STOR_OCC * mem1,
4788 T_ACI_SMS_STOR_OCC * mem2,
4789 T_ACI_SMS_STOR_OCC * mem3)
4790 {
4791 T_MFW_SMS_MEM_INFO sms_mem;
4792
4793 TRACE_FUNCTION ("rAT_PlusCPMS");
4794 /*a0393213 OMAPS00109953*/
4795 /*update memory info*/
4796 switch(mem1->mem)
4797 {
4798 case SMS_STOR_Sm:
4799 sim_memory.total=mem1->total;
4800 sim_memory.used=mem1->used;
4801 break;
4802 case SMS_STOR_Me:
4803 ffs_memory.total=mem1->total;
4804 ffs_memory.used=mem1->used;
4805 break;
4806 default:
4807 TRACE_ERROR("rAT_PlusCPMS():Unknown memory");
4808 }
4809
4810 memory.mem=sms_mem.mem=mem1->mem;
4811 memory.total=sms_mem.total=sim_memory.total+ffs_memory.total;
4812 memory.used=sms_mem.used=sim_memory.used+ffs_memory.used;
4813 /* HLE temp for testing iface and for WIN32 simulation */
4814
4815 #if defined (WIN32)
4816 mem1->total = 10;
4817 #endif
4818
4819 if(coll_sms_req EQ MFW_SMS_WAIT)
4820 coll_sms_req = MFW_SMS_FREE;
4821
4822 if (int_req || int_init_req)
4823 { TRACE_EVENT_P2("memory.used:%d,memory.total:%d",mem1->used, mem1->total);
4824
4825 if (int_req ==FIRST_READ_OF_MEMORY_USE)
4826 sms_signal(E_SMS_READY, 0);
4827 int_req = 0;
4828 int_init_req = 0;
4829 /*a0393213 OMAPS00109953*/
4830 if(memory.used==memory.total)
4831 sms_signal(E_SMS_MEM_FULL, 0);
4832
4833 #ifdef SIM_TOOLKIT
4834 if (sms_update)
4835 {
4836 sms_update = FALSE;
4837 sms_sat_update_cnf();
4838 }
4839 #endif
4840 return;
4841 }
4842 else
4843 sms_signal(E_SMS_MEM, &sms_mem);
4844
4845 sms_check_mt_update();
4846 }
4847
4848
4849 /*
4850 +---------------------------------------------------------------------------+
4851 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
4852 | STATE : code ROUTINE : sms_message_count |
4853 +---------------------------------------------------------------------------+
4854
4855 PURPOSE : Request number of SMS message
4856
4857 */
4858
4859 SHORT sms_message_count (T_MFW_SMS_STAT stat)
4860 {
4861 SHORT count;
4862 int i;
4863 TRACE_FUNCTION("sms_message_count");
4864
4865 count = 0;
4866 if ((stat == MFW_SMS_UNREAD)
4867 OR (stat == MFW_SMS_READ)
4868 OR (stat == MFW_SMS_STOR_UNSENT)
4869 OR (stat == MFW_SMS_STOR_SENT))
4870 {
4871 #ifdef FF_MMI_SMS_DYNAMIC
4872 for (i=0; i<g_max_messages; i++)
4873 #else
4874 for (i=0; i<MAX_MESSAGES; i++)
4875 #endif
4876 {
4877 // PATCH JPS 20.09 - Don't look at SMS with index -1 because it means it is deleted
4878 if (msg_info[i].index != -1)
4879 {
4880
4881 if (msg_info[i].stat == stat)
4882 count++;
4883 }
4884 // PATCH JPS 20.09 END - Don't look at SMS with index -1 because it means it is deleted
4885 }
4886 return count;
4887 }
4888
4889 if (stat == MFW_SMS_ALL)
4890 {
4891 #ifdef FF_MMI_SMS_DYNAMIC
4892 for (i=0; i<g_max_messages; i++)
4893 #else
4894 for (i=0; i<MAX_MESSAGES; i++)
4895 #endif
4896 {
4897 if (msg_info[i].index != -1)
4898 count++;
4899 }
4900 return count;
4901 }
4902
4903 if (stat == MFW_SMS_MO)
4904 {
4905 #ifdef FF_MMI_SMS_DYNAMIC
4906 for (i=0; i<g_max_messages; i++)
4907 #else
4908 for (i=0; i<MAX_MESSAGES; i++)
4909 #endif
4910 {
4911 // PATCH JPS 20.09 - Don't look at SMS with index -1 because it means it is deleted
4912 if (msg_info[i].index != -1)
4913 {
4914 if ((msg_info[i].stat == MFW_SMS_STOR_UNSENT)
4915 OR (msg_info[i].stat == MFW_SMS_STOR_SENT))
4916 count++;
4917 }
4918 // PATCH JPS 20.09 END - Don't look at SMS with index -1 because it means it is deleted
4919 }
4920 return count;
4921 }
4922 if (stat == MFW_SMS_MT)
4923 {
4924 #ifdef FF_MMI_SMS_DYNAMIC
4925 for (i=0; i<g_max_messages; i++)
4926 #else
4927 for (i=0; i<MAX_MESSAGES; i++)
4928 #endif
4929 {
4930 // PATCH JPS 20.09 - Don't look at SMS with index -1 because it means it is deleted
4931 if (msg_info[i].index != -1)
4932 {
4933 if ((msg_info[i].stat == MFW_SMS_UNREAD)
4934 OR (msg_info[i].stat == MFW_SMS_READ))
4935 count++;
4936 }
4937 // PATCH JPS 20.09 END - Don't look at SMS with index -1 because it means it is deleted
4938 }
4939 return count;
4940 }
4941 if (stat == MFW_SMS_VOICE)
4942 {
4943 #ifdef FF_MMI_SMS_DYNAMIC
4944 for (i=0; i<g_max_messages; i++)
4945 #else
4946 for (i=0; i<MAX_MESSAGES; i++)
4947 #endif
4948 {
4949 // PATCH JPS 20.09 - Don't look at SMS with index -1 because it means it is deleted
4950 if (msg_info[i].index != -1)
4951 {
4952 if (msg_info[i].msg_type == stat)
4953 count++;
4954 }
4955 // PATCH JPS 20.09 END - Don't look at SMS with index -1 because it means it is deleted
4956 }
4957 return count;
4958 }
4959 return 0;
4960 }
4961
4962
4963 /*
4964 +---------------------------------------------------------------------------+
4965 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
4966 | STATE : code ROUTINE : sms_message_list |
4967 +---------------------------------------------------------------------------+
4968
4969 PURPOSE : Request a stored message list
4970
4971 Note: msg_type is not used in this implementation
4972 */
4973
4974 SHORT sms_message_list(T_MFW_SMS_STAT stat,
4975 T_MFW_SMS_MSG * msg_list,
4976 int max_entries)
4977 {
4978 SHORT count;
4979 int i;
4980
4981 TRACE_FUNCTION("sms_message_list()");
4982
4983 count = 0;
4984 switch (stat)
4985 {
4986 case MFW_SMS_ALL:
4987 #ifdef FF_MMI_SMS_DYNAMIC
4988 for (i=0; i<g_max_messages; i++)
4989 #else
4990 for (i=0; i<MAX_MESSAGES; i++)
4991 #endif
4992 {
4993 if (count >= max_entries)
4994 return count;
4995
4996 if (msg_info[i].index != -1)
4997 {
4998 sms_copy_msg_list(i, &msg_list[count]);
4999 count++;
5000 }
5001 }
5002 return count;
5003
5004 case MFW_SMS_MO:
5005 #ifdef FF_MMI_SMS_DYNAMIC
5006 for (i=0; i<g_max_messages; i++)
5007
5008 #else
5009 for (i=0; i<MAX_MESSAGES; i++)
5010 #endif
5011 {
5012 if (count >= max_entries)
5013 return count;
5014
5015 if ((msg_info[i].index != -1)
5016 AND ((msg_info[i].stat == MFW_SMS_STOR_UNSENT)
5017 OR (msg_info[i].stat == MFW_SMS_STOR_SENT)))
5018 {
5019 sms_copy_msg_list(i, &msg_list[count]);
5020 count++;
5021 }
5022 }
5023 return count;
5024
5025 case MFW_SMS_STOR_UNSENT:
5026 #ifdef FF_MMI_SMS_DYNAMIC
5027 for (i=0; i<g_max_messages; i++)
5028 #else
5029 for (i=0; i<MAX_MESSAGES; i++)
5030 #endif
5031 {
5032 if (count >= max_entries)
5033 return count;
5034
5035 if ((msg_info[i].index != -1)
5036 AND (msg_info[i].stat == MFW_SMS_STOR_UNSENT))
5037 {
5038 sms_copy_msg_list(i, &msg_list[count]);
5039 count++;
5040 }
5041 }
5042 return count;
5043
5044 case MFW_SMS_STOR_SENT:
5045 #ifdef FF_MMI_SMS_DYNAMIC
5046 for (i=0; i<g_max_messages; i++)
5047 #else
5048 for (i=0; i<MAX_MESSAGES; i++)
5049 #endif
5050 {
5051 if (count >= max_entries)
5052 return count;
5053
5054 if ((msg_info[i].index != -1)
5055 AND (msg_info[i].stat == MFW_SMS_STOR_SENT))
5056 {
5057 sms_copy_msg_list(i, &msg_list[count]);
5058 count++;
5059 }
5060 }
5061 return count;
5062
5063 case MFW_SMS_MT:
5064 #ifdef FF_MMI_SMS_DYNAMIC
5065 for (i=0; i<g_max_messages; i++)
5066 #else
5067 for (i=0; i<MAX_MESSAGES; i++)
5068 #endif
5069 {
5070 if (count >= max_entries)
5071 return count;
5072
5073 if ((msg_info[i].index != -1)
5074 AND ((msg_info[i].stat == MFW_SMS_UNREAD)
5075 OR (msg_info[i].stat == MFW_SMS_READ)))
5076 {
5077 sms_copy_msg_list(i, &msg_list[count]);
5078 count++;
5079 }
5080 }
5081 return count;
5082
5083 case MFW_SMS_UNREAD:
5084 #ifdef FF_MMI_SMS_DYNAMIC
5085 for (i=0; i<g_max_messages; i++)
5086 #else
5087 for (i=0; i<MAX_MESSAGES; i++)
5088 #endif
5089 {
5090 if (count >= max_entries)
5091 return count;
5092
5093 if ((msg_info[i].index != -1)
5094 AND (msg_info[i].stat == MFW_SMS_UNREAD))
5095 {
5096 sms_copy_msg_list(i, &msg_list[count]);
5097 count++;
5098 }
5099 }
5100 return count;
5101
5102 case MFW_SMS_READ:
5103 #ifdef FF_MMI_SMS_DYNAMIC
5104 for (i=0; i<g_max_messages; i++)
5105 #else
5106 for (i=0; i<MAX_MESSAGES; i++)
5107 #endif
5108 {
5109 if (count >= max_entries)
5110 return count;
5111
5112 if ((msg_info[i].index != -1)
5113 AND (msg_info[i].stat == MFW_SMS_READ))
5114 {
5115 sms_copy_msg_list(i, &msg_list[count]);
5116 count++;
5117 }
5118 }
5119 return count;
5120
5121 case MFW_SMS_VOICE:
5122 #ifdef FF_MMI_SMS_DYNAMIC
5123 for (i=0; i<g_max_messages; i++)
5124 #else
5125 for (i=0; i<MAX_MESSAGES; i++)
5126 #endif
5127 {
5128 if (count >= max_entries)
5129 return count;
5130
5131 if ((msg_info[i].index != -1)
5132 AND (msg_info[i].msg_type == MFW_SMS_VOICE))
5133 {
5134 sms_copy_msg_list(i, &msg_list[count]);
5135 count++;
5136 }
5137 }
5138 return count;
5139
5140 default:
5141 return count;
5142 }
5143 }
5144
5145
5146 /*
5147 +---------------------------------------------------------------------------+
5148 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5149 | STATE : code ROUTINE : sms_copy_msg_list |
5150 +---------------------------------------------------------------------------+
5151
5152 PURPOSE : copy a stored message list
5153
5154 */
5155
5156 void sms_copy_msg_list(int num, T_MFW_SMS_MSG *msg_list)
5157 {
5158 TRACE_FUNCTION("sms_copy_msg_list()");
5159
5160 msg_list->index = msg_info[num].index;
5161 msg_list->mem=msg_info[num].mem; /*a0393213 OMAPS00109953*/
5162 /*
5163 * forward message reference to MMI
5164 */
5165 msg_list->msg_ref = msg_info[num].msg_ref;
5166 msg_list->stat = msg_info[num].stat;
5167 msg_list->msg_type = msg_info[num].msg_type;
5168 strcpy(msg_list->addr.number, msg_info[num].addr.number);
5169 msg_list->addr.ton = msg_info[num].addr.ton;
5170 msg_list->addr.npi = msg_info[num].addr.npi;
5171 // March 31, 2005 REF: CRR MMI-SPR-24511 x0012852
5172 // first_index, concat_status are also added to use it later on.
5173 msg_list->concat_status = msg_info[num].concat_status;
5174 msg_list->first_index = msg_info[num].first_index;
5175 /*a0393213 OMAPS00109953*/
5176 msg_list->first_mem=msg_info[num].first_mem;
5177 #ifdef NO_ASCIIZ
5178 memcpy(msg_list->addr.tag,
5179 msg_info[num].addr.tag,
5180 msg_info[num].addr.len);
5181 msg_list->addr.len = msg_info[num].addr.len;
5182 #else
5183 strcpy(msg_list->addr.tag, msg_info[num].addr.tag);
5184 #endif
5185 memcpy(&msg_list->rctp, &msg_info[num].rctp, sizeof(T_MFW_SMS_SCTP));
5186 }
5187
5188 /*
5189 +---------------------------------------------------------------------------+
5190 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5191 | STATE : code ROUTINE : sms_ok_csas |
5192 +---------------------------------------------------------------------------+
5193
5194 PURPOSE : Setting of SMS parameter/cell broadcast parameter
5195 is successful.
5196
5197 */
5198
5199 void sms_ok_csas(void)
5200 {
5201 TRACE_FUNCTION("sms_ok_csas() ");
5202 sms_signal(E_SMS_OK, 0);
5203
5204 sms_check_mt_update();
5205 }
5206
5207 /*
5208 +---------------------------------------------------------------------------+
5209 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5210 | STATE : code ROUTINE : sms_error_csas |
5211 +---------------------------------------------------------------------------+
5212
5213 PURPOSE : Setting of SMS parameter/cell broadcast parameter
5214 is failed.
5215
5216 */
5217
5218 void sms_error_csas(void)
5219 {
5220 sms_signal(E_SMS_ERR, 0);
5221 }
5222
5223 /*
5224 +--------------------------------------------------------------------+
5225 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5226 | STATE : code ROUTINE : sms_codeStatus |
5227 +--------------------------------------------------------------------+
5228
5229 PURPOSE : This function is used to convert the status
5230 used by MFW to the status used by ACI.
5231 */
5232
5233 T_ACI_SMS_STAT sms_codeStatus(T_MFW_SMS_STAT stat)
5234 {
5235 switch (stat)
5236 {
5237 case MFW_SMS_UNREAD: return SMS_STAT_RecUnread;
5238 case MFW_SMS_READ: return SMS_STAT_RecRead;
5239 case MFW_SMS_STOR_UNSENT: return SMS_STAT_StoUnsent;
5240 case MFW_SMS_STOR_SENT: return SMS_STAT_StoSent;
5241 case MFW_SMS_ALL: return SMS_STAT_All;
5242 default: return SMS_STAT_NotPresent;
5243 }
5244 }
5245
5246
5247 /*
5248 +--------------------------------------------------------------------+
5249 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5250 | STATE : code ROUTINE : sms_decodeStatus |
5251 +--------------------------------------------------------------------+
5252
5253 PURPOSE : This function is used to convert the status
5254 used by ACI to the status used by MFW.
5255 */
5256
5257 T_MFW_SMS_STAT sms_decodeStatus(T_ACI_SMS_STAT stat)
5258 {
5259 switch (stat)
5260 { case SMS_STAT_Invalid: return MFW_SMS_INVALID;/*SPR 2260*/
5261 case SMS_STAT_RecUnread: return MFW_SMS_UNREAD;
5262 case SMS_STAT_RecRead: return MFW_SMS_READ;
5263 case SMS_STAT_StoUnsent: return MFW_SMS_STOR_UNSENT;
5264 case SMS_STAT_StoSent: return MFW_SMS_STOR_SENT;
5265 case SMS_STAT_All: return MFW_SMS_ALL;
5266 default:
5267 return MFW_SMS_UNKNOWN;
5268 }
5269 }
5270
5271
5272 /*
5273 +--------------------------------------------------------------------+
5274 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
5275 | STATE : code ROUTINE : sms_get_cbm_id |
5276 +--------------------------------------------------------------------+
5277
5278 PURPOSE : get cell broadcast message identifier
5279 cbmid: array for cell broadcast message identifier
5280 len: size of array
5281
5282 */
5283
5284 void sms_get_cbm_id (USHORT *cbmid, UBYTE len)
5285 {
5286 UBYTE max;
5287 int i;
5288 int p;
5289
5290 if (len > 6) /* maximal 5 cell broadcast message identifiers + '\0' */
5291 max = 6;
5292 else
5293 max = len;
5294
5295 p = 0;
5296 // from 0-4
5297 for (i=0; i<(max-1); i++)
5298 {
5299 if (cb_mid[p] == 0xFF AND cb_mid[p+1] == 0xFF)
5300 break;
5301 cbmid[i] = ( ( SHORT )cb_mid[p] << 8 ) + cb_mid[p+1];
5302 p += 2;
5303 }
5304 cbmid[i] = '\0';
5305 }
5306
5307
5308 /*
5309 +--------------------------------------------------------------------+
5310 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
5311 | STATE : code ROUTINE : sms_save_cbm_id |
5312 +--------------------------------------------------------------------+
5313
5314 PURPOSE : save cell broadcast message identifier
5315
5316 */
5317
5318 void sms_save_cbm_id (USHORT *cbmid, UBYTE len)
5319 {
5320 int i;
5321 UBYTE p;
5322 UBYTE max;
5323
5324 memset(cb_mid, 0xFF, sizeof(cb_mid));
5325
5326 if (len > 5)
5327 max = 5;
5328 else
5329 max = len;
5330
5331 p = 0;
5332 for (i=0; i<max; i++)
5333 {
5334 if (!cbmid[i])
5335 break;
5336
5337 cb_mid[p++] = (UBYTE)(cbmid[i] >> 8);
5338 cb_mid[p++] = (UBYTE)cbmid[i];
5339 }
5340
5341 memset(data, 0xFF, sizeof(data));
5342
5343 memcpy(data, cb_mid, 10);
5344
5345 sim_write_sim(SIM_CBMI, data, 10);
5346 }
5347
5348
5349 /*
5350 +--------------------------------------------------------------------+
5351 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
5352 | STATE : code ROUTINE : sms_check_mt_update|
5353 +--------------------------------------------------------------------+
5354
5355 PURPOSE : save cell broadcast message identifier
5356
5357 */
5358
5359 void sms_check_mt_update()
5360 {
5361 TRACE_EVENT("sms_check_mt_update() ");
5362
5363 if (sms_id.index > 0)
5364 {
5365 sms_send_new_msg_ind(NULL,sms_id.index, sms_id.mem, sms_id.received_sms_type, sms_id.concat_status);
5366
5367 sms_id.index = 0;
5368 }
5369 if (sms_id_wait.index > 0)
5370 {
5371 sms_send_new_msg_ind(NULL,sms_id_wait.index, sms_id_wait.mem, sms_id_wait.received_sms_type, sms_id_wait.concat_status);
5372
5373 sms_id_wait.index = 0;
5374
5375 }
5376
5377
5378 }
5379
5380 /*
5381 +--------------------------------------------------------------------+
5382 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
5383 | STATE : code ROUTINE : sms_check_voice_mail|
5384 +--------------------------------------------------------------------+
5385
5386 PURPOSE : Check voice mail.
5387
5388 */
5389
5390 T_MFW sms_check_voice_mail(UBYTE pid, UBYTE dcs, char *addr,
5391 T_ACI_TOA *toa, T_ACI_UDH_DATA *udh)
5392 { T_MFW status =MFW_SMS_UNKNOWN;//MC
5393 //x0pleela 24 Mar, 2006 ER OMAPS00070657
5394 //Flag for Voice mail waiting indication icon to display or not
5395 #ifdef FF_CPHS
5396 BOOL udh_flag=FALSE;
5397 #endif
5398 TRACE_FUNCTION("sms_check_voice_mail()");
5399
5400 if (dcs == 0xC0 /* check data coding scheme */
5401 OR dcs == 0xC8
5402 OR dcs == 0xD0
5403 OR dcs == 0xD8
5404 OR dcs == 0xE0
5405 OR dcs == 0xE8)
5406 {
5407
5408 status = MFW_SMS_VOICE;
5409 }
5410
5411 else if (udh->len > 0 AND udh->data[0] == 0x01
5412 AND (udh->data[2] == 0x80 OR udh->data[2] == 0x00)) /* check user data header */
5413 {
5414 status = MFW_SMS_VOICE;
5415 //x0pleela 24 Mar, 2006 ER OMAPS00070657
5416 /*If message count is zero, so delete icon */
5417 #ifdef FF_CPHS
5418 if( udh->data[3] == 0x00 )
5419 {
5420 TRACE_EVENT("message count is zero" );
5421 udh_flag = TRUE;
5422 }
5423 #endif
5424 }
5425
5426 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
5427 // Voice mail identification is already done using dcs. Identification should not be done using pid. Check commented
5428 // else if (pid == 0x5F OR pid ==0x42 /*On power-up check pid to determine SMS VM */) /* check message identifier */
5429 /* { status = MFW_SMS_VOICE;
5430
5431 } */
5432 else if (toa->ton == TON_Alphanumeric
5433 // 0x30 special case for one-2-one when voice mail has been deleted.
5434 AND (addr[0] == 0x10 OR addr[0] == 0x11 OR addr[0]==0x31 OR addr[0]==0x30)) /* check CPHS */
5435 {
5436 // Fix for one-2-one VM icon control. 26/6/01 MZ
5437 if(addr[0]==0x30)
5438 {
5439 Delete_1_2_1_vm_icon = TRUE;
5440 Display_1_2_1_vm_icon = FALSE;
5441 }
5442 else if(addr[0]==0x31 && Delete_1_2_1_vm_icon == FALSE)
5443 Display_1_2_1_vm_icon = TRUE;
5444
5445 status = MFW_SMS_VOICE;
5446
5447 }
5448 TRACE_EVENT_P2("Addr[0]:%x, Addr[1]:%x", addr[0], addr[1]);
5449 TRACE_EVENT_P2("Addr[2]:%x, Addr[3]:%x", addr[2], addr[3]);
5450 /*MC1364, improved this to check if voicemail indicator to be set or cleared*/
5451
5452 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
5453 // Instead of identifying voice mail ON (indication)/OFF(deletion) using addr[0], we use dcs.
5454 // (addr[0]&0x01) condition replaced with (dcs & 0x08)
5455
5456 //x0pleela 24 Mar, 2006 ER OMAPS00070657
5457 #ifdef FF_CPHS
5458 if ((status == MFW_SMS_VOICE) && (dcs & 0x08)&& (!udh_flag)) //if a voicemail indication
5459 #else
5460 if ((status == MFW_SMS_VOICE) && (dcs & 0x08))
5461 #endif
5462 {
5463 Delete_1_2_1_vm_icon = FALSE;/*SPR2260*/
5464 Display_1_2_1_vm_icon = TRUE;
5465
5466 //x0pleela 09 June, 2006 DR: OMAPS00079692
5467 //following code is commented as MMI need not set the VMWI flag
5468 #if 0
5469
5470 /*MC, if MSB set, bit 0 of second char in 7-bit encoding)*/
5471 if (addr[1] & 0x08) /*SPR 2260 experimentally, bit set by orange*/
5472 cphs_set_mailbox_status(0,MFW_CFLAG_SET , 0, 0);/*set line2*/
5473 else
5474 cphs_set_mailbox_status(MFW_CFLAG_SET, 0, 0, 0);/*set line1*/
5475 #endif
5476 }
5477 //x0pleela 24 Mar, 2006 ER OMAPS00070657
5478 #ifdef FF_CPHS
5479 if ( ((status == MFW_SMS_VOICE) && !(dcs & 0x08)) OR(udh_flag)) //if a voicemail deletion
5480 #else
5481 if ((status == MFW_SMS_VOICE) && !(dcs & 0x08))
5482 #endif
5483 {
5484 Delete_1_2_1_vm_icon = TRUE;/*SPR2260*/
5485 Display_1_2_1_vm_icon = FALSE;
5486
5487 //x0pleela 09 June, 2006 DR: OMAPS00079692
5488 //following code is commented as MMI need not set the VMWI flag
5489 #if 0
5490 /*MC, if MSB set, bit 0 of second char in 7-bit encoding)*/
5491 if (addr[1] & 0x08) /*SPR 2260 experimentally, bit set by orange*/
5492 cphs_set_mailbox_status(0,MFW_CFLAG_NOTSet , 0, 0);/*clear line2*/
5493 else
5494 cphs_set_mailbox_status(MFW_CFLAG_NOTSet, 0, 0, 0);/*clear line1*/
5495 #endif
5496 }
5497 // Feb 16, 2005 REF: CRR MMI-SPR-27900 xnkulkar
5498 // If voicemail message is from group "1100", update status as MFW_SMS_VOICEMSG_DELETE
5499 if ((status == MFW_SMS_VOICE) && ((dcs & 0xF0) == 0xC0))
5500 {
5501 status = MFW_SMS_VOICEMSG_DELETE;
5502 invalidVm = TRUE; // set this flag to TRUE to indicate that this voice mail sms is to be deleted
5503 }
5504
5505 return status;
5506 }
5507
5508 #ifdef SIM_TOOLKIT
5509 /*
5510 +---------------------------------------------------------------------+
5511 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5512 | STATE : code ROUTINE : sms_sat_file_update |
5513 +---------------------------------------------------------------------+
5514
5515 PURPOSE : SIM file change indication
5516
5517 */
5518
5519 void sms_sat_file_update(USHORT dataId)
5520 {
5521 TRACE_FUNCTION("sms_sat_file_update()");
5522
5523 sms_update = TRUE;
5524 switch (dataId)
5525 {
5526 case SIM_SMS:
5527 sms_read_msg_info();
5528 break;
5529 default:
5530 break;
5531 }
5532 }
5533 #endif
5534
5535 #ifdef SIM_TOOLKIT
5536 /*
5537 +---------------------------------------------------------------------+
5538 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5539 | STATE : code ROUTINE : sms_sat_update_cnf |
5540 +---------------------------------------------------------------------+
5541
5542 PURPOSE : SIM file change indication
5543
5544 */
5545
5546 void sms_sat_update_cnf (void)
5547 {
5548 TRACE_FUNCTION("sms_sat_update_cnf()");
5549 satUpdateFiles ( TRUE, SIM_SMS );
5550 }
5551 #endif
5552
5553 /* PATCH JPS 29.09: like sms_message_list but returns only index and status */
5554
5555 /*
5556 +---------------------------------------------------------------------------+
5557 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5558 | STATE : code ROUTINE : sms_index_list |
5559 +---------------------------------------------------------------------------+
5560
5561 PURPOSE : Request a stored message index and status
5562 */
5563
5564 SHORT sms_index_list(T_MFW_SMS_STAT stat,
5565 T_MFW_SMS_IDX * msg_list,
5566 int max_entries)
5567 {
5568 SHORT count;
5569 int i;
5570
5571 TRACE_FUNCTION("sms_index_list()");
5572
5573 count = 0;
5574 switch (stat)
5575 {
5576 case MFW_SMS_ALL:
5577 #ifdef FF_MMI_SMS_DYNAMIC
5578 for (i=0; i<g_max_messages; i++)
5579 #else
5580 for (i=0; i<MAX_MESSAGES; i++)
5581 #endif
5582 {
5583 if (count >= max_entries)
5584 return count;
5585
5586 if (msg_info[i].index != -1)
5587 {
5588 sms_copy_idx_list(i, &msg_list[count]);
5589 count++;
5590 }
5591 }
5592 return count;
5593
5594 case MFW_SMS_MO:
5595 #ifdef FF_MMI_SMS_DYNAMIC
5596 for (i=0; i<g_max_messages; i++)
5597 #else
5598 for (i=0; i<MAX_MESSAGES; i++)
5599 #endif
5600 {
5601 if (count >= max_entries)
5602 return count;
5603
5604 if ((msg_info[i].index != -1)
5605 AND ((msg_info[i].stat == MFW_SMS_STOR_UNSENT)
5606 OR (msg_info[i].stat == MFW_SMS_STOR_SENT)))
5607 {
5608 sms_copy_idx_list(i, &msg_list[count]);
5609 count++;
5610 }
5611 }
5612 return count;
5613
5614 case MFW_SMS_STOR_UNSENT:
5615 #ifdef FF_MMI_SMS_DYNAMIC
5616 for (i=0; i<g_max_messages; i++)
5617 #else
5618 for (i=0; i<MAX_MESSAGES; i++)
5619 #endif
5620 {
5621 if (count >= max_entries)
5622 return count;
5623
5624 if ((msg_info[i].index != -1)
5625 AND (msg_info[i].stat == MFW_SMS_STOR_UNSENT))
5626 {
5627 sms_copy_idx_list(i, &msg_list[count]);
5628 count++;
5629 }
5630 }
5631 return count;
5632
5633 case MFW_SMS_STOR_SENT:
5634 #ifdef FF_MMI_SMS_DYNAMIC
5635 for (i=0; i<g_max_messages; i++)
5636 #else
5637 for (i=0; i<MAX_MESSAGES; i++)
5638 #endif
5639 {
5640 if (count >= max_entries)
5641 return count;
5642
5643 if ((msg_info[i].index != -1)
5644 AND (msg_info[i].stat == MFW_SMS_STOR_SENT))
5645 {
5646 sms_copy_idx_list(i, &msg_list[count]);
5647 count++;
5648 }
5649 }
5650 return count;
5651
5652 case MFW_SMS_MT:
5653 #ifdef FF_MMI_SMS_DYNAMIC
5654 for (i=0; i<g_max_messages; i++)
5655 #else
5656 for (i=0; i<MAX_MESSAGES; i++)
5657 #endif
5658 {
5659 if (count >= max_entries)
5660 return count;
5661
5662 if ((msg_info[i].index != -1)
5663 AND ((msg_info[i].stat == MFW_SMS_UNREAD)
5664 OR (msg_info[i].stat == MFW_SMS_READ)))
5665 {
5666 sms_copy_idx_list(i, &msg_list[count]);
5667 count++;
5668 }
5669 }
5670 return count;
5671
5672 case MFW_SMS_UNREAD:
5673 #ifdef FF_MMI_SMS_DYNAMIC
5674 for (i=0; i<g_max_messages; i++)
5675 #else
5676 for (i=0; i<MAX_MESSAGES; i++)
5677 #endif
5678 {
5679 if (count >= max_entries)
5680 return count;
5681
5682 if ((msg_info[i].index != -1)
5683 AND (msg_info[i].stat == MFW_SMS_UNREAD))
5684 {
5685 sms_copy_idx_list(i, &msg_list[count]);
5686 count++;
5687 }
5688 }
5689 return count;
5690
5691 case MFW_SMS_READ:
5692 #ifdef FF_MMI_SMS_DYNAMIC
5693 for (i=0; i<g_max_messages; i++)
5694 #else
5695 for (i=0; i<MAX_MESSAGES; i++)
5696 #endif
5697 {
5698 if (count >= max_entries)
5699 return count;
5700
5701 if ((msg_info[i].index != -1)
5702 AND (msg_info[i].stat == MFW_SMS_READ))
5703 {
5704 sms_copy_idx_list(i, &msg_list[count]);
5705 count++;
5706 }
5707 }
5708 return count;
5709
5710 case MFW_SMS_VOICE:
5711 #ifdef FF_MMI_SMS_DYNAMIC
5712 for (i=0; i<g_max_messages; i++)
5713 #else
5714 for (i=0; i<MAX_MESSAGES; i++)
5715 #endif
5716 {
5717 if (count >= max_entries)
5718 return count;
5719
5720 if ((msg_info[i].index != -1)
5721 AND (msg_info[i].msg_type == MFW_SMS_VOICE))
5722 {
5723 sms_copy_idx_list(i, &msg_list[count]);
5724 count++;
5725 }
5726 }
5727 return count;
5728
5729 default:
5730 return count;
5731 }
5732 }
5733
5734
5735 /*
5736 +---------------------------------------------------------------------------+
5737 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5738 | STATE : code ROUTINE : sms_copy_idx_list |
5739 +---------------------------------------------------------------------------+
5740
5741 PURPOSE : copy the index and status of a short message
5742
5743 */
5744
5745 void sms_copy_idx_list(int num, T_MFW_SMS_IDX *msg_list)
5746 {
5747 TRACE_FUNCTION("sms_copy_idx_list()");
5748
5749 msg_list->index = msg_info[num].index;
5750 /*
5751 * forward message reference to MMI
5752 */
5753 msg_list->stat = msg_info[num].stat;
5754 msg_list->msg_type = msg_info[num].msg_type;
5755 /*a0393213 OMAPS00109953*/
5756 msg_list->memory=msg_info[num].mem;
5757
5758 }
5759 /*a0393213 OMAPS00109953 - memory type added as a parameter*/
5760 void sms_copy_idx(UBYTE index, T_MFW_SMS_IDX *msg_list, T_MFW_SMS_MEM sms_memory)
5761 {int i;
5762 TRACE_FUNCTION("sms_copy_idx()");
5763
5764 #ifdef FF_MMI_SMS_DYNAMIC
5765 for (i=0; i<g_max_messages; i++)
5766 #else
5767 for (i=0;i<MAX_MESSAGES; i++)
5768 #endif
5769 {
5770 /*a0393213 OMAPS00109953 - memory is also taken into consideration*/
5771 if (index==msg_info[i].index && sms_memory==msg_info[i].mem)
5772 /*
5773 * forward message reference to MMI
5774 */
5775 {
5776 msg_list->concat_status = msg_info[i].concat_status;/*SPR 2260*/
5777 msg_list->stat = msg_info[i].stat;
5778 msg_list->msg_type = msg_info[i].msg_type;
5779 break;
5780 }
5781 }
5782 }
5783
5784 //GW-SPR#780 - Removed procedure - status is already updated by 'sms_change_read_status'
5785 /* PATCH JPS 29.09 END */
5786 /*
5787 +---------------------------------------------------------------------------+
5788 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5789 | STATE : code ROUTINE : sms_ok_CMGL |
5790 +---------------------------------------------------------------------------+
5791
5792 PURPOSE : End of the rAT_PlusCMGL()
5793
5794 */
5795 void sms_ok_CMGL (void)
5796 {
5797 TRACE_FUNCTION("sms_ok_CMGL: rAT_PlusCMGL cmpl");
5798 /*a0393213 OMAPS00109953*/
5799 if(index_retrieve_state==MFW_SMS_SIM_INDEX_RETRIEVING)
5800 {
5801 /*all the indexes of SMes residing in SIM has been got - now get indexes from ME*/
5802 if(sms_set_pref_memory(MFW_MEM_ME)!=MFW_SMS_OK)
5803 {
5804 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
5805 }
5806 else
5807 {
5808 f_update=MFW_SMS_NEW;
5809 if (sAT_PlusCMGL (CMD_SRC_LCL, SMS_STAT_All,
5810 #ifdef FF_2TO1_PS
5811 0, (T_ACI_SMS_READ)MNSMS_READ_PREVIEW) NEQ AT_EXCT) /* typecast to remove warning Aug - 11 */
5812 #else
5813 0, SMS_READ_Preview) NEQ AT_EXCT)/*a0393213 warnings removal-READ_PREVIEW changed to SMS_READ_Preview*/
5814 #endif
5815 {
5816 TRACE_EVENT("sAT_PlusCMGL error");
5817 }
5818 else
5819 {
5820 index_retrieve_state=MFW_SMS_FFS_INDEX_RETRIEVING;
5821 return;
5822 }
5823 }
5824 }
5825 else if(index_retrieve_state==MFW_SMS_FFS_INDEX_RETRIEVING)
5826 {
5827 /*all the indexes of SMes residing in FFS has been got - so all the indexes has been got*/
5828 index_retrieve_state=MFW_SMS_INDEX_RETRIEVED;
5829 /*setting the pref memory back to SIM*/
5830 if(sms_set_pref_memory(MFW_MEM_SIM)!=MFW_SMS_OK)
5831 {
5832 TRACE_ERROR("sms_ok_CMGL():Not able to set pref memory");
5833 }
5834 }
5835 else
5836 {
5837 TRACE_ERROR("sms_ok_CMGL() : Improper index retrieving state");
5838 }
5839 /* request default memory */
5840 f_update = MFW_SMS_FREE;
5841 int_req = FIRST_READ_OF_MEMORY_USE;/*SPR2260*/
5842
5843 qAT_PlusCPMS(CMD_SRC_LCL);
5844
5845 }
5846
5847
5848
5849 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858
5850 //begin 30439
5851 /*
5852 +---------------------------------------------------------------------------+
5853 | PROJECT : MMI-Framework (8417) MODULE : MFW_SMS |
5854 | STATE : code ROUTINE : sms_homezoneCBToggle |
5855 +---------------------------------------------------------------------------+
5856
5857 PURPOSE :
5858
5859 */
5860 #ifndef NEPTUNE_BOARD
5861
5862 //Dec 14, 2005 REF: MMI-FIX-OMAPS00058684 x0035544
5863 #ifdef FF_HOMEZONE
5864 void sms_homezoneCBToggle(U8 Activate_CB)
5865 {
5866 T_ACI_RETURN ret;
5867 T_ACI_CBHZ_MOD mode;
5868 T_ACI_CS dcs;
5869 UBYTE timeout;
5870 int def_timeout = 60;
5871
5872 TRACE_FUNCTION("sms_homezoneCBToggle()");
5873
5874 ret = qAT_PercentCBHZ(CMD_SRC_LCL , &mode, &dcs, &timeout);
5875
5876 if (ret EQ AT_FAIL)
5877 {
5878 //Aug 16, 2005 REF: MMI-FIX-30439 x0018858
5879 //Incase the querying fails, we still wil have to activate/ de-activate with default
5880 //values for dcs and timeout
5881 if(1 == Activate_CB )
5882 {
5883 TRACE_FUNCTION("ACTIVATING HOMEZONE");
5884 /*a0393213 warnings removal-CS_GsmDef used instead of 0*/
5885 ret = sAT_PercentCBHZ(CMD_SRC_LCL , CBHZ_MOD_Active,CS_GsmDef,def_timeout);
5886 }
5887 else
5888 {
5889 TRACE_FUNCTION("DE-ACTIVATING HOMEZONE");
5890 /*a0393213 warnings removal-CS_GsmDef used instead of 0*/
5891 ret = sAT_PercentCBHZ(CMD_SRC_LCL , CBHZ_MOD_NotActive,CS_GsmDef,def_timeout);
5892 }
5893 return;
5894 }
5895
5896
5897 if(1 == Activate_CB )
5898 {
5899 TRACE_FUNCTION("ACTIVATING HOMEZONE");
5900 ret = sAT_PercentCBHZ(CMD_SRC_LCL , CBHZ_MOD_Active,dcs,timeout);
5901 }
5902 else
5903 {
5904 TRACE_FUNCTION("DE-ACTIVATING HOMEZONE");
5905 ret = sAT_PercentCBHZ(CMD_SRC_LCL , CBHZ_MOD_NotActive,dcs,timeout);
5906 }
5907 return;
5908
5909 }
5910 //end 30439
5911 #endif
5912 #endif
5913
5914 ////Mar 22 2007 ER:OMAPS00113882 x0061088 (Prachi)
5915 /*******************************************************************************
5916
5917 $Function: is_alphanumeric_addr
5918
5919 $Description: check whether the address entered by user is alphanumeric or numeric.
5920
5921 $Returns: None
5922
5923 $Arguments: win
5924
5925 *******************************************************************************/
5926
5927 int is_alphanumeric_addr(char *dest_addr)
5928 {
5929 int addr_length,index=0;
5930 addr_length= strlen(dest_addr);
5931 while( index < addr_length )
5932 {
5933 if ( ((*dest_addr) >= '0') && ( (*dest_addr) <= '9'))
5934 {
5935 dest_addr++;
5936 index++; /* address is numeric */
5937 }
5938 else
5939 return TRUE; /*alphanumeric address*/
5940
5941 }
5942 return FALSE;
5943 }
5944