comparison src/aci2/mfw/mfw_nm.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_nm.c $|
4 | $Author:: Es $Revision:: 1 $|
5 | CREATED: 07.10.98 $Modtime:: 2.03.00 16:28 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_NM
10
11 PURPOSE : This modul contains the functions for network management.
12
13
14 $History:: mfw_nm.c
15
16 Feb 15, 2006 ER: OMAPS00065203 x0pleela
17 Description: Cingular Operator Name Prioritization implementation required
18 Solution: Incorporated review comments
19 - Changed from NEQ NM_CPHS to EQ NM_ROM as we know %CNIV will
20 be called only if source id is ROM or CPHS and not roaming in nm_get_opername()
21 - set_opn_sel_done(): sets opn_sel_done flag to TRUE or FALSE.
22 - get_opn_sel_done(): returns the current value of flag opn_sel_done.
23
24 Feb 09, 2006 ER: OMAPS00065203 x0pleela
25 Description: Cingular Operator Name Prioritization implementation required
26 Solution: Handling E_NM_OPN for operator name display
27 Query for COPN in rAT_PlusCREG and update plmn data
28 Defined following new functions:
29 nm_decodeSourceId:to convert the source id used by ACI to the source id used by MFW
30 nm_update_plmn_data: update plmn data after querying COPN
31 nm_get_COPN: query COPN
32 nm_get_opername: updates operator name based on cingular's prioritization requirement.
33 Priority would be in order ONS->NITZ->ROM
34 nm_get_network_data: gets operator name from network
35
36 Nov 24, 2005 DR: OMAPS00045909 - Shashi Shekar B.S.
37 Description: Improve IMEI control mechanism
38 Solution : When MMI calls sAT_PLUSCFUN, if an IMEI invalid error is returned,
39 we will block on that screen & will not allow the user to browse menus further,
40 since the PS will not be booted at all!!!
41
42 July 14, 2005 REF: CRR 31916 x0021334
43 Description: rCI_PercentCOPS() and rAT_PercentCOPS() is not implemented
44 Solution: rAT_PercentCOPS() is implemented.
45
46 Mar 01, 2005 REF: ENH 29327 xdeepadh
47 Bug:Locosto MMI Optimization
48 Fix:The changes done for the Golite optimization have been utilised for color build.
49 This is done by removing the functions under #ifndef MMI_LITE.
50 The static vaiable T_MFW_PLMN_LIST plmn_list has been made local variable.
51 It has been dynamically allocated and deallocated.
52
53 Aug 16, 2004 REF: CRR 24293 Deepa M.D
54 Bug:Go-lite optimisation dynamic allocation of variable 'plmn_list'
55 Fix:The static vaiable T_MFW_PLMN_LIST plmn_list has been made local variable.
56 It has been dynamically allocated and deallocated.
57
58
59 Aug 16, 2004 REF: CRR 24323 Deepa M.D
60 Bug:Clenup of sprintf used for tracing
61 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX $
62
63 Sep 23, 2004 REF: CRR 24562 xvilliva
64 Bug: Enable/disable the manual network selection option depending
65 on ENS.
66 Fix: If the manual network selection is disabled we check if an
67 error is returned and set the global g_ensErr.
68
69
70 *
71 * ***************** Version 39 *****************
72 * User: Es Date: 2.03.00 Time: 16:31
73 * Updated in $/GSM/Condat/MS/SRC/MFW
74 * use 'aci_delete()' to clear the primitive routing for mfw_nm.
75 *
76 * ***************** Version 38 *****************
77 * User: Vo Date: 16.02.00 Time: 14:22
78 * Updated in $/GSM/Condat/MS/SRC/MFW
79 *
80 * ***************** Version 37 *****************
81 * User: Vo Date: 11.02.00 Time: 12:57
82 * Updated in $/GSM/Condat/MS/SRC/MFW
83 * Bug fix: limited service
84 *
85 * ***************** Version 36 *****************
86 * User: Vo Date: 11.02.00 Time: 11:01
87 * Updated in $/GSM/Condat/MS/SRC/MFW
88 * add limited service indication
89 *
90 * ***************** Version 35 *****************
91 * User: Vo Date: 28.01.00 Time: 12:48
92 * Updated in $/GSM/Condat/MS/SRC/MFW
93 * Limited service
94 *
95 * ***************** Version 34 *****************
96 * User: Vo Date: 20.01.00 Time: 13:17
97 * Updated in $/GSM/Condat/MS/SRC/MFW
98 * Add new methodes to save preferred PLMN entry (change interface
99 * function nm_change_pref_plmn())
100 *
101 * ***************** Version 33 *****************
102 * User: Vo Date: 22.12.99 Time: 15:59
103 * Updated in $/GSM/Condat/MS/SRC/MFW
104 * New: Request of preferred PLMN memory of SIM card
105 *
106 * ***************** Version 32 *****************
107 * User: Vo Date: 3.12.99 Time: 12:16
108 * Updated in $/GSM/Condat/MS/SRC/MFW
109 * remove the request of maximum/used preferred PLMN list
110 *
111 * ***************** Version 31 *****************
112 * User: Vo Date: 2.12.99 Time: 13:28
113 * Updated in $/GSM/Condat/MS/SRC/MFW
114 *
115 * ***************** Version 30 *****************
116 * User: Vo Date: 2.12.99 Time: 13:25
117 * Updated in $/GSM/Condat/MS/SRC/MFW
118 * New: request of max/used perferred PLMN list
119 *
120 * ***************** Version 29 *****************
121 * User: Vo Date: 21.10.99 Time: 13:24
122 * Updated in $/GSM/Condat/MS/SRC/MFW
123 * changed of read/change perferred PLMN list
124 * add event for successful de-registration
125 |
126 | ***************** Version 28 *****************
127 | User: Le Date: 8.10.99 Time: 13:38
128 | Updated in $/GSM/Condat/MS/SRC/MFW
129 *
130 * ***************** Version 27 *****************
131 * User: Es Date: 16.09.99 Time: 16:56
132 * Updated in $/GSM/DEV/MS/SRC/MFW
133 * reordered include statements due to addons in mfw_phb.h
134 *
135 * ***************** Version 26 *****************
136 * User: Vo Date: 13.09.99 Time: 11:39
137 * Updated in $/GSM/DEV/MS/SRC/MFW
138 * Bug fix: registration with numeric network format
139 *
140 * ***************** Version 25 *****************
141 * User: Vo Date: 30.08.99 Time: 14:03
142 * Updated in $/GSM/DEV/MS/SRC/MFW
143 * bug fix
144 * new function
145 *
146 * ***************** Version 24 *****************
147 * User: Vo Date: 2.07.99 Time: 18:16
148 * Updated in $/GSM/DEV/MS/SRC/MFW
149 *
150 * ***************** Version 23 *****************
151 * User: Vo Date: 20.05.99 Time: 17:39
152 * Updated in $/GSM/DEV/MS/SRC/MFW
153 *
154 * ***************** Version 22 *****************
155 * User: Vo Date: 28.04.99 Time: 16:11
156 * Updated in $/GSM/DEV/MS/SRC/MFW
157 *
158 * ***************** Version 21 *****************
159 * User: Vo Date: 31.03.99 Time: 14:09
160 * Updated in $/GSM/DEV/MS/SRC/MFW
161 *
162 * ***************** Version 20 *****************
163 * User: Es Date: 15.03.99 Time: 18:21
164 * Updated in $/GSM/DEV/MS/SRC/MFW
165 * recode
166 *
167 * ***************** Version 19 *****************
168 * User: Vo Date: 17.02.99 Time: 19:03
169 * Updated in $/GSM/DEV/MS/SRC/MFW
170 *
171 * ***************** Version 18 *****************
172 * User: Vo Date: 12.02.99 Time: 18:59
173 * Updated in $/GSM/DEV/MS/SRC/MFW
174 *
175 * ***************** Version 17 *****************
176 * User: Vo Date: 9.02.99 Time: 14:54
177 * Updated in $/GSM/DEV/MS/SRC/MFW
178 *
179 * ***************** Version 16 *****************
180 * User: Vo Date: 12.01.99 Time: 14:55
181 * Updated in $/GSM/DEV/MS/SRC/MFW
182 *
183 * ***************** Version 15 *****************
184 * User: Es Date: 23.12.98 Time: 15:47
185 * Updated in $/GSM/DEV/MS/SRC/MFW
186 *
187 * ***************** Version 14 *****************
188 * User: Es Date: 18.12.98 Time: 13:04
189 * Updated in $/GSM/DEV/MS/SRC/MFW
190 *
191 * ***************** Version 13 *****************
192 * User: Es Date: 8.12.98 Time: 16:53
193 * Updated in $/GSM/DEV/MS/SRC/MFW
194 *
195 * ***************** Version 11 *****************
196 * User: Vo Date: 1.12.98 Time: 15:43
197 * Updated in $/GSM/DEV/MS/SRC/MFW
198 *
199 * ***************** Version 10 *****************
200 * User: Vo Date: 30.11.98 Time: 17:49
201 * Updated in $/GSM/DEV/MS/SRC/MFW
202 *
203 * ***************** Version 9 *****************
204 * User: Vo Date: 24.11.98 Time: 21:40
205 * Updated in $/GSM/DEV/MS/SRC/MFW
206 * first successful compilation of MFW
207 *
208 * ***************** Version 8 *****************
209 * User: Vo Date: 13.11.98 Time: 16:21
210 * Updated in $/GSM/DEV/MS/SRC/MFW
211 *
212 * ***************** Version 7 *****************
213 * User: Es Date: 12.11.98 Time: 13:50
214 * Updated in $/GSM/DEV/MS/SRC/MFW
215 |
216 | ***************** Version 6 *****************
217 | User: Le Date: 11.11.98 Time: 13:35
218 | Updated in $/GSM/DEV/MS/SRC/MFW
219 |
220 | ***************** Version 5 *****************
221 | User: Le Date: 10.11.98 Time: 16:07
222 | Updated in $/GSM/DEV/MS/SRC/MFW
223 |
224 | ***************** Version 4 *****************
225 | User: Le Date: 10.11.98 Time: 11:08
226 | Updated in $/GSM/DEV/MS/SRC/MFW
227 |
228 | ***************** Version 3 *****************
229 | User: Le Date: 27.10.98 Time: 15:59
230 | Updated in $/GSM/DEV/MS/SRC/MFW
231 |
232 | ***************** Version 2 *****************
233 | User: Le Date: 21.10.98 Time: 16:20
234 | Updated in $/GSM/DEV/MS/SRC/MFW
235 |
236 | ***************** Version 1 *****************
237 | User: Le Date: 21.10.98 Time: 10:33
238 | Created in $/GSM/DEV/MS/SRC/MFW
239 */
240
241 #define ENTITY_MFW
242
243 #include <string.h>
244 #include <stdio.h>
245 #include <stdlib.h>
246
247 #if defined (NEW_FRAME)
248
249 #include "typedefs.h"
250 #include "vsi.h"
251 #include "pei.h"
252 #include "custom.h"
253 #include "gsm.h"
254
255 #else
256
257 #include "STDDEFS.H"
258 #include "custom.h"
259 #include "gsm.h"
260 #include "vsi.h"
261
262 #endif
263
264 #include "prim.h"
265
266 #include "mfw_mfw.h"
267 #include "mfw_nm.h"
268 #include "mfw_sim.h"
269 #include "mfw_sima.h"
270 #include "mfw_nmi.h"
271 #include "mfw_simi.h"
272 #include "mfw_nma.h"
273 #include "mfw_acie.h"
274 #include "mfw_phb.h"
275 #include "mfw_cm.h"
276 #include "mfw_sms.h"
277 #include "mfw_win.h"
278
279 #include "ksd.h"
280 #include "psa.h"
281
282 #include "mfw_ss.h"
283 #include "mfw_ssi.h"
284
285 #if defined (FAX_AND_DATA)
286 #include "aci_fd.h"
287 #endif
288
289 #include "mfw_ffs.h"
290
291 #include "message.h"
292 #include "prim.h"
293 #include "aci_cmh.h" //GW 22-11-01 - Added
294
295 #ifdef SIM_TOOLKIT
296 #include "mfw_sat.h"
297 #endif
298
299 #ifndef NEPTUNE_BOARD
300 extern const T_OPER_NTRY_FIXED operListFixed[]; /* Side access into cus_aci.h */
301 #else
302 extern const T_OPER_NTRY operList[];
303 #endif
304 EXTERN MfwHdr * current_mfw_elem;
305
306 U8 mfw_IMSI [LONG_NAME]; /* expanded IMSI (ASCIIZ) */
307
308 static U8 last_selected_mode = NOT_PRESENT_8BIT;
309 static U8 reg_stat;
310 static U8 reg_flag;
311 #ifdef NO_ASCIIZ
312 static T_MFW_SP_NAME service_provider_name;
313 #else
314 static U8 service_provider_name [LONG_NAME];
315 #endif
316 static U8 display_condition;
317 static T_MFW_PREF_PLMN_LIST pplmn_list;
318 static T_MFW_NET_IND net_ind;
319 static T_MFW_TIME_IND tim_ind;
320 static UBYTE mfwPplmnReq;
321 static BOOL sat_update = FALSE;
322 // Sep 23, 2004 REF: CRR 24562 xvilliva
323 int g_ensErr = 0;
324
325 //x0pleela 08 Feb, 2006 ER: OMAPS00065203
326 GLOBAL UBYTE gEons_alloc_active; /* EONS allocation and activation */
327 static UBYTE opn_sel_done; /* flag to inform priority is done*/
328
329 /*SPR#2122 - DS - Commented out. Now operator list is dynamically allocated in nm_avail_plmn_list()
330 *static T_ACI_COPS_OPDESC oper_list [MAX_OPER];
331 */
332
333 static int nmCommand (U32 cmd, void *h); /* handle window commands */
334 static void nm_search_reg_status(void);
335
336 U8 pplmnCnt;
337 U8 pplmnCmd;
338
339 static int pSlot; /* primitive handler slot */
340
341
342
343
344 /*
345 +--------------------------------------------------------------------+
346 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
347 | STATE : code ROUTINE : nm_init |
348 +--------------------------------------------------------------------+
349
350 PURPOSE : Initialize network manager
351
352 */
353
354 int nm_init (void)
355 {
356
357 TRACE_FUNCTION("nm_init()");
358
359 if (last_selected_mode == NOT_PRESENT_8BIT)
360 {
361 last_selected_mode = FFS_flashData.PLMN_selection_mode;
362 }
363 /* install prim handler */
364 pSlot = aci_create(nma_response_cb,NULL);
365
366 reg_flag = 0;
367 mfwPplmnReq = 0;
368 reg_stat = NOT_PRESENT_8BIT;
369 sat_update = FALSE;
370 mfwCommand[MfwTypNm] = (MfwCb) nmCommand;
371
372 return last_selected_mode;
373 }
374
375
376 /*
377 +--------------------------------------------------------------------+
378 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
379 | STATE : code ROUTINE : nm_exit |
380 +--------------------------------------------------------------------+
381
382 PURPOSE : Finalize network manager
383
384 */
385
386 void nm_exit (void)
387 {
388 /* remove prim handler */
389 aci_delete(pSlot);
390 last_selected_mode = NOT_PRESENT_8BIT;
391 reg_stat = NOT_PRESENT_8BIT;
392 }
393
394
395 /*
396 +--------------------------------------------------------------------+
397 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
398 | STATE : code ROUTINE : nm_create |
399 +--------------------------------------------------------------------+
400
401 PURPOSE : Create network manager
402
403 */
404
405 MfwHnd nm_create (MfwHnd hWin, MfwEvt event, MfwCb cbfunc)
406 {
407 MfwHdr *hdr;
408 T_MFW_NM *nm_para;
409 MfwHdr *insert_status =0;
410
411 TRACE_FUNCTION("nm_create()");
412
413 hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
414 nm_para = (T_MFW_NM *) mfwAlloc(sizeof(T_MFW_NM));
415
416 if (!hdr || !nm_para)
417 {
418 TRACE_ERROR("ERROR: nm_create() Mem Alloc Failed.");
419
420 if(hdr)
421 mfwFree((U8*)hdr,sizeof(MfwHdr));
422 if(nm_para)
423 mfwFree((U8*)nm_para,sizeof(T_MFW_NM));
424
425 return FALSE;
426 }
427
428 nm_para->emask = event;
429 nm_para->handler = cbfunc;
430
431 hdr->data = nm_para; /* store parameter in node */
432 hdr->type = MfwTypNm; /* type of event handler */
433
434 insert_status = mfwInsert((MfwHdr *) hWin,hdr);
435 if(!insert_status)
436 {
437 TRACE_ERROR("ERROR: nm_create() Failed to Install Handler. ");
438 mfwFree((U8*)hdr,sizeof(MfwHdr));
439 mfwFree((U8*)nm_para ,sizeof(T_MFW_NM));
440 return 0;
441 }
442 return insert_status;
443 }
444
445
446 /*
447 +--------------------------------------------------------------------+
448 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
449 | STATE : code ROUTINE : nm_delete |
450 +--------------------------------------------------------------------+
451
452 PURPOSE : delete network manager
453
454 */
455
456 MfwRes nm_delete (MfwHnd h)
457 {
458 TRACE_FUNCTION("nm_delete()");
459
460 if (!h || !((MfwHdr *) h)->data)
461 return MfwResIllHnd;
462
463 if (!mfwRemove((MfwHdr *) h))
464 return MfwResIllHnd;
465
466 mfwFree(((MfwHdr *) h)->data,sizeof(T_MFW_NM));
467 mfwFree(h,sizeof(MfwHdr));
468
469 return MfwResOk;
470 }
471
472
473 /*
474 +--------------------------------------------------------------------+
475 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
476 | STATE : code ROUTINE : nm_sign_exec |
477 +--------------------------------------------------------------------+
478
479 PURPOSE : dispatch network management signal
480
481 */
482
483 static int nm_sign_exec (MfwHdr *cur_elem, MfwEvt event,
484 T_MFW_NM_PARA * para)
485 {
486 TRACE_FUNCTION("nm_sign_exec()");
487
488 while (cur_elem)
489 {
490 if (cur_elem->type == MfwTypNm)
491 {
492 T_MFW_NM *nm_data;
493
494 nm_data = (T_MFW_NM *) cur_elem->data;
495 if (nm_data->emask & event)
496 {
497 nm_data->event = event;
498 switch (event)
499 {
500 case E_NM_FULL_SERVICE:
501 //x0pleela 9 Feb, 2006 ER:OMAPS00065203
502 //Handling E_NM_OPN for operator name display
503 case E_NM_OPN:
504 memcpy(&nm_data->para.ident,para,
505 sizeof(T_MFW_NETWORK_STRUCT));
506 break;
507 case E_NM_PLMN_LIST:
508 memcpy(&nm_data->para.plmns,para,
509 sizeof(T_MFW_PLMN_LIST));
510 break;
511 case E_NM_PREF_PLMN_LIST:
512 memcpy(&nm_data->para.pplmns,para,
513 sizeof(T_MFW_PREF_PLMN_LIST));
514 break;
515 case E_NM_PPLMN_MEM:
516 memcpy(&nm_data->para.pplmn_mem,para,
517 sizeof(T_MFW_PPLMN_MEM));
518 break;
519 case E_NM_CELL_SELECT:
520 memcpy(&nm_data->para.cell_info,para,
521 sizeof(T_MFW_CELL_STRUCT));
522 break;
523 case E_MFW_NET_IND:
524 memcpy(&nm_data->para.net_info,para,
525 sizeof(T_MFW_NET_IND));
526 break;
527 case E_MFW_TIME_IND:
528 memcpy(&nm_data->para.tim_info,para,
529 sizeof(T_MFW_TIME_IND));
530 break;
531 }
532 if (nm_data->handler)
533 {
534 // PATCH LE 06.06.00
535 // store current mfw elem
536 current_mfw_elem = cur_elem;
537 // END PATCH LE 06.06.00
538 if ((*(nm_data->handler)) (nm_data->event,
539 (void *) &nm_data->para))
540 return TRUE;
541 }
542 }
543 }
544 cur_elem = cur_elem->next;
545 }
546
547 return FALSE;
548 }
549
550
551 /*
552 +--------------------------------------------------------------------+
553 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
554 | STATE : code ROUTINE : nm_signal |
555 +--------------------------------------------------------------------+
556
557 PURPOSE : Send a signal
558
559 */
560
561 static void nm_signal (MfwEvt event, void *para)
562 {
563 UBYTE temp;
564 TRACE_FUNCTION("nm_signal()");
565
566 temp = dspl_Enable(0);
567 if (mfwSignallingMethod EQ 0)
568 {
569 if (mfwFocus)
570 if (nm_sign_exec(mfwFocus,event,para))
571 {
572 dspl_Enable(temp);
573 return;
574 }
575 if (mfwRoot)
576 nm_sign_exec(mfwRoot,event,para);
577 }
578 else
579 {
580 MfwHdr * h = 0;
581
582 /*
583 * Focus set, then start here
584 */
585 if (mfwFocus)
586 h = mfwFocus;
587 /*
588 * Focus not set, then start root
589 */
590 if (!h)
591 h = mfwRoot;
592
593 /*
594 * No elements available, return
595 */
596
597 while (h)
598
599
600 {
601 /*
602 * Signal consumed, then return
603 */
604 if (nm_sign_exec (h, event, para))
605 {
606 dspl_Enable(temp);
607 return;
608 }
609
610 /*
611 * All windows tried inclusive root
612 */
613 if (h == mfwRoot)
614 {
615 dspl_Enable(temp);
616 return;
617 }
618
619 /*
620 * get parent window
621 */
622 h = mfwParent(mfwParent(h));
623 if(h)
624 h = ((MfwWin * )(h->data))->elems;
625 }
626 nm_sign_exec (mfwRoot, event, para);
627 }
628 dspl_Enable(temp);
629 }
630
631
632
633 /*
634 +--------------------------------------------------------------------+
635 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
636 | STATE : code ROUTINE : nm_set_mode |
637 +--------------------------------------------------------------------+
638
639 PURPOSE : Change registration mode
640
641 */
642
643 void nm_set_mode (U8 mode)
644 {
645
646 TRACE_FUNCTION("nm_set_mode()");
647
648 if (mode != NM_AUTOMATIC && mode != NM_MANUAL)
649 return;
650
651 if (mode != last_selected_mode)
652 {
653 last_selected_mode = mode;
654 {
655 FFS_flashData.PLMN_selection_mode = mode;
656 flash_write();
657 }
658 }
659 }
660
661
662 /*
663 +--------------------------------------------------------------------+
664 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
665 | STATE : code ROUTINE : nm_get_mode |
666 +--------------------------------------------------------------------+
667
668 PURPOSE : Get registration mode
669
670 */
671
672 T_MFW nm_get_mode ()
673 {
674 return last_selected_mode;
675 }
676
677
678 /*
679 +--------------------------------------------------------------------+
680 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
681 | STATE : code ROUTINE : nm_activate |
682 +--------------------------------------------------------------------+
683
684 PURPOSE : Notify about SIM card activation
685
686 */
687
688 void nm_activate (U8 result)
689 {
690 //TRACE_FUNCTION("nm_activate()");
691
692 }
693
694
695 /*
696 +--------------------------------------------------------------------+
697 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
698 | STATE : code ROUTINE : nm_reg_flag_req |
699 +--------------------------------------------------------------------+
700
701 PURPOSE : Notify about SIM card activation
702
703 */
704
705 T_MFW nm_reg_flag_req()
706 {
707 return reg_flag;
708 }
709
710
711 /*
712 +--------------------------------------------------------------------+
713 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
714 | STATE : code ROUTINE : nm_mmi_parameters |
715 +--------------------------------------------------------------------+
716
717 PURPOSE : Notify about relevant parameters
718
719 */
720
721 #ifdef FF_2TO1_PS
722 void nm_mmi_parameters (T_SIM_imsi_field *imsi, T_SIM_pref_plmn *plmn)
723 {
724 void simDecodeIMSI (U8 *ci, U8 li, U8 *di);
725
726 TRACE_FUNCTION("nm_mmi_parameters()");
727
728 simDecodeIMSI(imsi->field,imsi->c_field,mfw_IMSI);
729 }
730 #else
731 void nm_mmi_parameters (T_imsi_field *imsi, T_pref_plmn *plmn)
732 {
733 void simDecodeIMSI (U8 *ci, U8 li, U8 *di);
734
735 TRACE_FUNCTION("nm_mmi_parameters()");
736
737 simDecodeIMSI(imsi->field,imsi->c_field,mfw_IMSI);
738 }
739 #endif
740
741
742 /*
743 +--------------------------------------------------------------------+
744 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
745 | STATE : code ROUTINE : nm_pref_plmn_list |
746 +--------------------------------------------------------------------+
747
748 PURPOSE : Request preferred PLMN list
749
750 */
751
752 void nm_pref_plmn_list(T_MFW_NETWORK_STRUCT *pplmn, UBYTE count, SHORT start)
753 {
754 SHORT lastIdx;
755 T_ACI_CPOL_OPDESC operLst[MAX_OPER];
756 T_ACI_RETURN res;
757 UBYTE i, j;
758
759 TRACE_FUNCTION("nm_pref_plmn_list()");
760
761 pplmn_list.count = 0;
762 pplmn_list.plmn = pplmn;
763 pplmnCnt = count;
764
765 j = 0;
766 while (1)
767 {
768 res = qAT_PlusCPOL(CMD_SRC_LCL,
769 start,
770 &lastIdx,
771 operLst,
772 CPOL_MOD_CompactList);
773 if (res == AT_EXCT)
774 return;
775
776 if (res == AT_CMPL)
777 {
778 for (i=0; i<MAX_OPER; i++)
779 {
780 if (operLst[i].index == -1 OR pplmn_list.count >= pplmnCnt)
781 break;
782
783 pplmn_list.plmn[j].index = operLst[i].index;
784 #ifdef NO_ASCIIZ
785 sAT_PlusCOPSE((UBYTE *)operLst[i].oper,
786 (UBYTE)operLst[i].format,
787 &pplmn_list.plmn[j].network_long,
788 &pplmn_list.plmn[j].network_short,
789 pplmn_list.plmn[j].network_numeric);
790 #else
791 sAT_PlusCOPSE((UBYTE *)operLst[i].oper,
792 (UBYTE)operLst[i].format,
793 pplmn_list.plmn[j].network_long,
794 pplmn_list.plmn[j].network_short,
795 pplmn_list.plmn[j].network_numeric);
796 #endif
797 pplmn_list.count++;
798 j++;
799 }
800 if (i < MAX_OPER OR (j EQ pplmnCnt))
801 {
802 nm_signal(E_NM_PREF_PLMN_LIST, &pplmn_list);
803 return;
804 }
805 start = lastIdx + 1;
806 }
807 else
808 {
809 nm_signal(E_NM_PREF_PLMN_LIST, &pplmn_list);
810 return;
811 }
812 }
813 }
814
815
816 /*
817 +--------------------------------------------------------------------+
818 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
819 | STATE : code ROUTINE : rAT_PlusCPOL |
820 +--------------------------------------------------------------------+
821
822 PURPOSE : callback of preferred PLMN list
823
824 */
825
826 void rAT_PlusCPOL(SHORT startIdx, SHORT lastIdx,
827 T_ACI_CPOL_OPDESC *operLst,
828 SHORT usdNtry)
829 {
830 UBYTE i, j;
831 SHORT endIdx;
832 T_MFW_PPLMN_MEM pplmn_mem;
833
834 TRACE_FUNCTION("nm_pref_plmn_list()");
835
836 if (mfwPplmnReq)
837 {
838 mfwPplmnReq = 0;
839 pplmn_mem.maxRcd = (UBYTE)lastIdx;
840 pplmn_mem.usedRcd = (UBYTE)usdNtry;
841 nm_signal(E_NM_PPLMN_MEM, &pplmn_mem);
842 return;
843 }
844
845 endIdx = lastIdx;
846 j = 0;
847 while (1)
848 {
849 for (i=0; i<MAX_OPER; i++)
850 {
851 if (operLst[i].index == -1 OR pplmn_list.count >= pplmnCnt)
852 break;
853
854 pplmn_list.plmn[j].index = operLst[i].index;
855 #ifdef NO_ASCIIZ
856 sAT_PlusCOPSE((UBYTE *)operLst[i].oper,
857 (UBYTE)operLst[i].format,
858 &pplmn_list.plmn[j].network_long,
859 &pplmn_list.plmn[j].network_short,
860 pplmn_list.plmn[j].network_numeric);
861 #else
862 sAT_PlusCOPSE((UBYTE *)operLst[i].oper,
863 (UBYTE)operLst[i].format,
864 pplmn_list.plmn[j].network_long,
865 pplmn_list.plmn[j].network_short,
866 pplmn_list.plmn[j].network_numeric);
867 #endif
868 pplmn_list.count++;
869 j++;
870 }
871 if ((i<MAX_OPER) OR (j EQ pplmnCnt))
872 {
873 nm_signal(E_NM_PREF_PLMN_LIST, &pplmn_list);
874 return;
875 }
876 startIdx = endIdx + 1;
877 if (qAT_PlusCPOL(CMD_SRC_LCL, startIdx, &endIdx,
878 operLst, CPOL_MOD_CompactList) != AT_CMPL)
879 {
880 nm_signal(E_NM_PREF_PLMN_LIST, &pplmn_list);
881 return;
882 }
883 }
884 }
885
886
887 /*
888 +----------------------------------------------------------------------+
889 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
890 | STATE : code ROUTINE : nm_change_pref_plmn |
891 +----------------------------------------------------------------------+
892
893 PURPOSE : Save/Change/Delete a preferred PLMN
894
895 */
896
897 T_MFW_NM_RETURN nm_change_pref_plmn(T_MFW_PPLMN_MODE mode,
898 SHORT index, SHORT index2,
899 UBYTE *network_numeric)
900 {
901 SHORT idx;
902 T_ACI_CPOL_FRMT format;
903 CHAR * oper;
904 SHORT idx2;
905 T_ACI_CPOL_MOD md;
906
907 TRACE_FUNCTION("nm_change_pref_plmn()");
908
909 switch (mode)
910 {
911 case NEW_PREF_PLMN:
912 idx = -1;
913 idx2 = -1;
914 format = CPOL_FRMT_Numeric;
915 oper = (CHAR *)network_numeric;
916 md = CPOL_MOD_CompactList;
917 break;
918 case REPLACE_PREF_PLMN:
919 idx = index;
920 idx2 = -1;
921 format = CPOL_FRMT_Numeric;
922 oper = (CHAR *)network_numeric;
923 md = CPOL_MOD_CompactList;
924 break;
925 case DELETE_PREF_PLMN:
926 idx = index;
927 idx2 = -1;
928 format = CPOL_FRMT_NotPresent;
929 oper = NULL;
930 md = CPOL_MOD_CompactList;
931 break;
932 case INSERT_PREF_PLMN:
933 idx = index;
934 idx2 = -1;
935 format = CPOL_FRMT_Numeric;
936 oper = (CHAR *)network_numeric;
937 md = CPOL_MOD_Insert;
938 break;
939 case CHANGE_PREF_PLMN:
940 idx = index;
941 idx2 = index2;
942 format = CPOL_FRMT_Numeric;
943 oper = (CHAR *)network_numeric;
944 md = CPOL_MOD_CompactList;
945 break;
946 default:
947 return NM_ERR;
948 }
949
950 if (sAT_PlusCPOL(CMD_SRC_LCL, idx, format,
951 oper, idx2, md) != AT_EXCT)
952 return NM_ERR;
953 pplmnCmd = CHANGE_PREF_PLMN;
954 return NM_OK;
955 }
956
957
958 /*
959 +----------------------------------------------------------------------+
960 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
961 | STATE : code ROUTINE : nm_change_pref_plmn_longname |
962 +----------------------------------------------------------------------+
963
964 PURPOSE : Change a preferred PLMN using longname. added for SPR 2635.
965
966 */
967
968 T_MFW_NM_RETURN nm_change_pref_plmn_longname(T_MFW_PPLMN_MODE mode,
969 SHORT index, SHORT index2,
970 char *network_long)
971 {
972 SHORT idx;
973 T_ACI_CPOL_FRMT format;
974 CHAR * oper;
975 SHORT idx2;
976 T_ACI_CPOL_MOD md;
977
978 TRACE_FUNCTION("nm_change_pref_plmn()");
979
980 switch (mode)
981 {
982
983 case REPLACE_PREF_PLMN:
984 idx = index;
985 idx2 = -1;
986 format = CPOL_FRMT_Long;
987 oper = (CHAR *)network_long;
988 md = CPOL_MOD_CompactList;
989 break;
990
991 default:
992 return NM_ERR;
993 }
994
995 if (sAT_PlusCPOL(CMD_SRC_LCL, idx, format,
996 oper, idx2, md) != AT_EXCT)
997 return NM_ERR;
998 pplmnCmd = CHANGE_PREF_PLMN;
999 return NM_OK;
1000 }
1001
1002 /*
1003 +--------------------------------------------------------------------+
1004 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1005 | STATE : code ROUTINE : nm_ok_pref_plmn |
1006 +--------------------------------------------------------------------+
1007
1008
1009 PURPOSE : The change of preferred PLMN is successful.
1010
1011 */
1012
1013 void nm_ok_pref_plmn(void)
1014 {
1015 TRACE_FUNCTION("nm_ok_pref_plmn()");
1016
1017 if (pplmnCmd == CHANGE_PREF_PLMN)
1018 {
1019 pplmnCmd = CMD_NOT_PRESENT;
1020 nm_signal(E_NM_CHANGE_PPLMN_OK, 0);
1021 }
1022 }
1023
1024
1025 /*
1026 +--------------------------------------------------------------------+
1027 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1028 | STATE : code ROUTINE : nm_error_pref_plmn |
1029 +--------------------------------------------------------------------+
1030
1031
1032 PURPOSE : The change of preferred PLMN is failed.
1033
1034 */
1035
1036 void nm_error_pref_plmn(void)
1037 {
1038 TRACE_FUNCTION("nm_error_pref_plmn()");
1039
1040 if (pplmnCmd == CHANGE_PREF_PLMN)
1041 {
1042 pplmnCmd = CMD_NOT_PRESENT;
1043 nm_signal(E_NM_CHANGE_PPLMN_ERR, 0);
1044 return;
1045 }
1046 if (mfwPplmnReq)
1047 mfwPplmnReq = 0;
1048 pplmn_list.count = 0;
1049 nm_signal(E_NM_PREF_PLMN_LIST, &pplmn_list);
1050 }
1051
1052
1053 /*
1054 +--------------------------------------------------------------------+
1055 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1056 | STATE : code ROUTINE : nm_copy_plmn_list |
1057 +--------------------------------------------------------------------+
1058
1059
1060 PURPOSE : Write the PLMN information in PLMN list
1061
1062 */
1063
1064 void nm_copy_plmn_list (T_MFW_NETWORK_STRUCT *plmn, T_ACI_COPS_OPDESC *operLst)
1065 {
1066 U8 *forbidden_id;
1067 U8 *fieldstrength;
1068
1069 TRACE_FUNCTION("nm_copy_plmn_list()");
1070 #ifdef NO_ASCIIZ
1071 plmn->network_long.len = 0;
1072 plmn->network_short.len = 0;
1073 memset(plmn->network_numeric, 0, NUMERIC_LENGTH);
1074
1075 if (operLst->longOper)
1076 {
1077 plmn->network_long.len = MINIMUM(LONG_NAME-1, strlen((char *)operLst->longOper));
1078 memcpy (plmn->network_long.data, operLst->longOper, plmn->network_long.len);
1079 plmn->network_long.data[plmn->network_long.len] = '\0';
1080 plmn->network_long.dcs = MFW_ASCII;
1081 }
1082
1083 if (operLst->shortOper)
1084 {
1085 plmn->network_short.len = MINIMUM(SHORT_NAME-1, strlen((char *)operLst->shortOper));
1086 memcpy (plmn->network_short.data, operLst->shortOper, plmn->network_short.len);
1087 plmn->network_short.data[plmn->network_short.len] = '\0';
1088 plmn->network_short.dcs = MFW_ASCII;
1089 }
1090 #else
1091 memset(plmn->network_long, 0, LONG_NAME);
1092 memset(plmn->network_short, 0, SHORT_NAME);
1093 memset(plmn->network_numeric, 0, NUMERIC_LENGTH);
1094
1095 if (operLst->longOper)
1096 strncpy((char *)plmn->network_long, (char *)operLst->longOper, LONG_NAME-1);
1097
1098 if (operLst->shortOper)
1099 strncpy((char *)plmn->network_short, (char *)operLst->shortOper, SHORT_NAME-1);
1100 #endif
1101 if (operLst->numOper)
1102 strncpy((char *)plmn->network_numeric, (char *)operLst->numOper, NUMERIC_LENGTH-1);
1103
1104 if (operLst->status == COPS_STAT_Available
1105 || operLst->status == COPS_STAT_Current)
1106 plmn->forbidden_indicator = MFW_PLMN_AVAILABLE;
1107 else
1108 plmn->forbidden_indicator = MFW_PLMN_FORBIDDEN;
1109
1110 if (!strncmp((char *) mfw_IMSI,(char *) plmn->network_numeric,5))
1111 plmn->roaming_indicator = 0;
1112 else
1113 plmn->roaming_indicator = 1;
1114
1115 sAT_PlusCOPSF(&forbidden_id,&fieldstrength);
1116 plmn->fieldstrength = fieldstrength;
1117 }
1118
1119
1120 /*
1121 +---------------------------------------------------------------------+
1122 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1123 | STATE : code ROUTINE : nm_pplmn_mem_req |
1124 +---------------------------------------------------------------------+
1125
1126 PURPOSE : Request the maximum number of preferred PLMN records
1127 in SIM card
1128
1129 */
1130
1131 T_MFW_NM_RETURN nm_pplmn_mem_req(void)
1132 {
1133 T_ACI_RETURN res;
1134 SHORT maxRcd, usedRcd;
1135 T_MFW_PPLMN_MEM pplmn_mem;
1136
1137 TRACE_FUNCTION("nm_pplmn_mem_req()");
1138
1139 res = tAT_PlusCPOL(CMD_SRC_LCL, &maxRcd, &usedRcd);
1140 if (res == AT_EXCT)
1141 {
1142 mfwPplmnReq = 1;
1143 return NM_OK;
1144 }
1145 if (res == AT_CMPL)
1146 {
1147 pplmn_mem.maxRcd = (UBYTE)maxRcd;
1148 pplmn_mem.usedRcd = (UBYTE)usedRcd;
1149 nm_signal(E_NM_PPLMN_MEM, &pplmn_mem);
1150 return NM_OK;
1151 }
1152
1153 return NM_ERR;
1154 }
1155
1156
1157 /*
1158 +--------------------------------------------------------------------+
1159 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1160 | STATE : code ROUTINE : nm_registration |
1161 +--------------------------------------------------------------------+
1162
1163 PURPOSE : Start registration
1164
1165 */
1166
1167 T_MFW nm_registration (U8 mode, U8 freq_bands, U8 limited)
1168 {
1169 U8 sim_stat;
1170
1171 TRACE_FUNCTION("nm_registration()");
1172
1173 sAT_Abort(CMD_SRC_LCL, AT_CMD_NRG);
1174
1175 sim_stat = sim_status_check();
1176 reg_flag = 1;
1177
1178 if (limited)
1179 {
1180 if (sAT_PercentNRG(CMD_SRC_LCL,
1181 NRG_RGMD_Auto,
1182 NRG_SVMD_Limited,
1183 NRG_FRMT_Numeric,
1184 NULL) != AT_EXCT)
1185 TRACE_EVENT("Limited Service error: SAT_PercentNRG");
1186 return sim_stat;
1187 }
1188
1189 // Nov 24, 2005, a0876501, DR: OMAPS00045909
1190 if (!limited && sim_stat == IMEI_NOT_VALID)
1191 return IMEI_NOT_VALID;
1192
1193 if (!limited && sim_stat != SIM_ACTIVE)
1194 return SIM_NOT_ACTIVE;
1195
1196
1197 if (mode == NM_MANUAL)
1198 {
1199 /*
1200 Apr 13, 2004 REF: CRR 16303 JuanVi Jativa-Villoldo
1201 sim_spn_req(); Moved to the function rAT_PlusCFUNP
1202 */
1203 nm_avail_plmn_list();
1204 }
1205 else
1206 {
1207 if (sAT_PercentNRG(CMD_SRC_LCL,
1208 NRG_RGMD_Auto,
1209 NRG_SVMD_Full,
1210 NRG_FRMT_Numeric,
1211 NULL) != AT_EXCT)
1212 {
1213 TRACE_ERROR("sAT_PercentNRG error");
1214 }
1215 /*
1216 Apr 13, 2004 REF: CRR 16303 JuanVi Jativa-Villoldo
1217 sim_spn_req(); Moved to the function rAT_PlusCFUNP
1218 */ }
1219 return SIM_ACTIVE;
1220 }
1221
1222
1223 /*
1224 +--------------------------------------------------------------------+
1225 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1226 | STATE : code ROUTINE : nm_avail_plmn_list |
1227 +--------------------------------------------------------------------+
1228
1229 PURPOSE : Request the available PLMN list
1230
1231 SPR#2122 - DS - Restructured to make oper_list dynamically allocated
1232 */
1233
1234
1235
1236 void nm_avail_plmn_list ()
1237 {
1238 T_ACI_RETURN result;
1239 int i;
1240 SHORT last_ind = 0;
1241 T_ACI_COPS_OPDESC* oper_list = NULL;
1242 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1243 //Dynamically allocate the plmn_list.
1244 T_MFW_PLMN_LIST* plmn_list;
1245 plmn_list = (T_MFW_PLMN_LIST*)mfwAlloc(sizeof(T_MFW_PLMN_LIST));
1246 if(plmn_list == NULL)
1247 {
1248 TRACE_EVENT("plmn_list malloc failed");
1249 return ;
1250 }
1251
1252 TRACE_FUNCTION("nm_avail_plmn_list()");
1253
1254 /* Dynamically allocate operator list buffer */
1255 oper_list = (T_ACI_COPS_OPDESC*)mfwAlloc(sizeof(T_ACI_COPS_OPDESC)*MAX_OPER);
1256
1257 if (oper_list == NULL)
1258 {
1259 TRACE_ERROR("ERROR: Failed to allocate oper list buffer");
1260 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1261 //Deallocate the plmn_list
1262 if(plmn_list !=NULL)
1263 {
1264 mfwFree((U8*)plmn_list,sizeof(T_MFW_PLMN_LIST));
1265 plmn_list=NULL;
1266 }
1267 return;
1268 }
1269
1270
1271 // PATCH JVU - PLMN selection during registration
1272 sAT_Abort(CMD_SRC_LCL, AT_CMD_NRG);
1273 // END PATCH JVU - PLMN selection during registration
1274
1275 plmn_list->count = 0;
1276 result = tAT_PlusCOPS(CMD_SRC_LCL,0,&last_ind,oper_list);
1277 if (result == AT_FAIL || result == AT_BUSY)
1278 {
1279 TRACE_ERROR("ERROR: tAT_PlusCOPS error");
1280 //Sep 23, 2004 REF: CRR 24562 xvilliva
1281 //If AT_FAIL is returned, we query for the exact error
1282 //and set a variable accordingly.
1283 if(result == AT_FAIL)
1284 {
1285 ULONG err;
1286
1287 err = qAT_ErrDesc();
1288 switch (ACI_ERR_DESC_CLASS( err ))
1289 {
1290 case ACI_ERR_CLASS_Cme:
1291 if (ACI_ERR_DESC_NR( err ) == CME_ERR_OpNotAllow)
1292 {
1293 g_ensErr = 1;
1294 }
1295 break;
1296 }
1297 }
1298
1299 /* Deallocate operator list buffer */
1300 if (oper_list != NULL)
1301 {
1302 mfwFree((U8*)oper_list, sizeof(T_ACI_COPS_OPDESC)*MAX_OPER);
1303 oper_list = NULL;
1304 }
1305
1306 nm_signal(E_NM_PLMN_LIST,plmn_list);
1307 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1308 //Deallocate the plmn_list
1309 if(plmn_list !=NULL)
1310 {
1311 mfwFree((U8*)plmn_list,sizeof(T_MFW_PLMN_LIST));
1312 plmn_list=NULL;
1313 }
1314 return;
1315 }
1316 if (result == AT_EXCT)
1317 {
1318 /* Deallocate operator list buffer */
1319 if (oper_list != NULL)
1320 {
1321 mfwFree((U8*)oper_list, sizeof(T_ACI_COPS_OPDESC)*MAX_OPER);
1322 oper_list = NULL;
1323 }
1324 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1325 //Deallocate the plmn_list
1326 if(plmn_list !=NULL)
1327 {
1328 mfwFree((U8*)plmn_list,sizeof(T_MFW_PLMN_LIST));
1329 plmn_list=NULL;
1330 }
1331 return; /* wait for rAT_PlusCOPS() */
1332 }
1333
1334 if (last_ind > MAX_OPER)
1335 last_ind = MAX_OPER;
1336
1337 for (i = 0; i <= last_ind; i++)
1338 nm_copy_plmn_list(&plmn_list->plmn[i], &oper_list[i]);
1339
1340 /* Deallocate operator list buffer */
1341 if (oper_list != NULL)
1342 {
1343 mfwFree((U8*)oper_list, sizeof(T_ACI_COPS_OPDESC)*MAX_OPER);
1344 oper_list = NULL;
1345 }
1346
1347 plmn_list->count = i;
1348 nm_signal(E_NM_PLMN_LIST,plmn_list);
1349 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1350 //Deallocate the plmn_list
1351 if(plmn_list !=NULL)
1352 {
1353 mfwFree((U8*)plmn_list,sizeof(T_MFW_PLMN_LIST));
1354 plmn_list=NULL;
1355 }
1356 }
1357
1358
1359 /*
1360 +--------------------------------------------------------------------+
1361 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1362 | STATE : code ROUTINE : nm_home_plmn |
1363 +--------------------------------------------------------------------+
1364
1365 PURPOSE : Get the home PLMN name
1366
1367 */
1368
1369 void nm_home_plmn (T_MFW_NETWORK_STRUCT *hplmn)
1370 {
1371 U8 oper[6];
1372
1373 /* get network operator */
1374 strncpy((char *)oper, (char *)mfw_IMSI, 5);
1375 oper[5] = 0;
1376
1377 #ifdef NO_ASCIIZ
1378 sAT_PlusCOPSE(oper,
1379 COPS_FRMT_Numeric,
1380 &hplmn->network_long,
1381 &hplmn->network_short,
1382 hplmn->network_numeric);
1383
1384 #else
1385 sAT_PlusCOPSE(oper,
1386 COPS_FRMT_Numeric,
1387 hplmn->network_long,
1388 hplmn->network_short,
1389 hplmn->network_numeric);
1390 #endif
1391 }
1392
1393
1394 /*
1395 +--------------------------------------------------------------------+
1396 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1397 | STATE : code ROUTINE : nm_plmn_list |
1398 +--------------------------------------------------------------------+
1399
1400 PURPOSE : Request existing network list
1401
1402 */
1403 #ifndef NEPTUNE_BOARD
1404 int nm_plnm_list(T_MFW_NETWORK_STRUCT *plmn_list, int start, int count)
1405 {
1406 int i;
1407 int sum;
1408
1409 TRACE_FUNCTION("nm_plnm_list()");
1410 sum = 0;
1411 while (operListFixed[sum].longName != NULL)
1412 sum++;
1413
1414 if (start >= sum)
1415 return 0;
1416 for (i=0; i<count; i++)
1417 {
1418 if (operListFixed[start].longName != NULL)
1419 {
1420 plmn_list[i].index = start+1;
1421 #ifdef NO_ASCIIZ
1422 sAT_PlusCOPSE((UBYTE *)operListFixed[start].longName,
1423 COPS_FRMT_Long,
1424 &plmn_list[i].network_long,
1425 &plmn_list[i].network_short,
1426 plmn_list[i].network_numeric);
1427 #else
1428 sAT_PlusCOPSE((UBYTE *)operListFixed[start].longName,
1429 COPS_FRMT_Long,
1430 plmn_list[i].network_long,
1431 plmn_list[i].network_short,
1432 plmn_list[i].network_numeric);
1433 #endif
1434 start++;
1435 }
1436 else
1437 {
1438 #ifdef NO_ASCIIZ
1439 plmn_list[i].network_long.len = 0;
1440 plmn_list[i].network_short.len = 0;
1441 plmn_list[i].network_numeric[0] = 0;
1442 #else
1443 plmn_list[i].network_long[0] = 0;
1444 plmn_list[i].network_short[0] = 0;
1445 plmn_list[i].network_numeric[0] = 0;
1446 #endif
1447 break;
1448 }
1449 }
1450 return sum;
1451 }
1452 #else
1453 int nm_plnm_list(T_MFW_NETWORK_STRUCT *plmn_list, int start, int count)
1454 {
1455 int i;
1456 int sum;
1457
1458 TRACE_FUNCTION("nm_plnm_list()");
1459 sum = 0;
1460 while (operList[sum].longName != NULL)
1461 sum++;
1462
1463 if (start >= sum)
1464 return 0;
1465
1466 for (i=0; i<count; i++)
1467 {
1468 if (operList[start].longName != NULL)
1469 {
1470 plmn_list[i].index = start+1;
1471 #ifdef NO_ASCIIZ
1472 sAT_PlusCOPSE((UBYTE *)operList[start].longName,
1473 COPS_FRMT_Long,
1474 &plmn_list[i].network_long,
1475 &plmn_list[i].network_short,
1476 plmn_list[i].network_numeric);
1477 #else
1478 sAT_PlusCOPSE((UBYTE *)operList[start].longName,
1479 COPS_FRMT_Long,
1480 plmn_list[i].network_long,
1481 plmn_list[i].network_short,
1482 plmn_list[i].network_numeric);
1483 #endif
1484 start++;
1485 }
1486 else
1487 {
1488 #ifdef NO_ASCIIZ
1489 plmn_list[i].network_long.len = 0;
1490 plmn_list[i].network_short.len = 0;
1491 plmn_list[i].network_numeric[0] = 0;
1492 #else
1493 plmn_list[i].network_long[0] = 0;
1494 plmn_list[i].network_short[0] = 0;
1495 plmn_list[i].network_numeric[0] = 0;
1496 #endif
1497 break;
1498 }
1499 }
1500 return sum;
1501 }
1502 #endif
1503 /*
1504 +--------------------------------------------------------------------+
1505 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1506 | STATE : code ROUTINE : nm_plmn_list_longnames |
1507 +--------------------------------------------------------------------+
1508
1509 PURPOSE : Request existing network list longnames. added for SPR 2635.
1510
1511 */
1512
1513 #ifndef NEPTUNE_BOARD
1514 int nm_plnm_list_longnames(char**plmn_ln_list, int start, int count)
1515 {
1516 int i;
1517 int sum;
1518
1519 TRACE_FUNCTION("nm_plnm_list_longnames()");
1520
1521 sum = 0;
1522
1523 /*count the number of longnames*/
1524 while (operListFixed[sum].longName != NULL)
1525 sum++;
1526 /*if we attempt read past the end of the list*/
1527 if (start >= sum)
1528 return 0;
1529
1530 /*for each pointer in the list*/
1531 for (i=0; i<count; i++)
1532 {
1533 if (operListFixed[start].longName != NULL)
1534 {
1535 /*just set pointer to point at longname in ROM in ACI*/
1536 plmn_ln_list[i] = (char*)operListFixed[start].longName;
1537
1538 start++;
1539 }
1540 else
1541 {
1542 plmn_ln_list[i] = NULL;
1543 break;
1544 }
1545 }
1546 return sum;
1547 }
1548 #else
1549 int nm_plnm_list_longnames(char**plmn_ln_list, int start, int count)
1550 {
1551 int i;
1552 int sum;
1553
1554 TRACE_FUNCTION("nm_plnm_list_longnames()");
1555
1556 sum = 0;
1557
1558 /*count the number of longnames*/
1559 while (operList[sum].longName != NULL)
1560 sum++;
1561 /*if we attempt read past the end of the list*/
1562 if (start >= sum)
1563 return 0;
1564
1565 /*for each pointer in the list*/
1566 for (i=0; i<count; i++)
1567 {
1568 if (operList[start].longName != NULL)
1569 {
1570 /*just set pointer to point at longname in ROM in ACI*/
1571 plmn_ln_list[i] = (char*)operList[start].longName;
1572
1573 start++;
1574 }
1575 else
1576 {
1577 plmn_ln_list[i] = NULL;
1578 break;
1579 }
1580 }
1581 return sum;
1582 }
1583 #endif
1584
1585 /*
1586 +--------------------------------------------------------------------+
1587 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1588 | STATE : code ROUTINE : nm_select_plmn |
1589 +--------------------------------------------------------------------+
1590
1591 PURPOSE : Select PLMN for registration
1592
1593 */
1594
1595 void nm_select_plmn (U8 *network)
1596 {
1597 T_ACI_RETURN result;
1598 TRACE_FUNCTION("nm_select_plmn()");
1599
1600 result = sAT_PercentNRG(CMD_SRC_LCL,
1601 NRG_RGMD_Manual,
1602 NRG_SVMD_Full,
1603 NRG_FRMT_Numeric,
1604 (char *) network);
1605 result = AT_FAIL;
1606 if (result != AT_EXCT)
1607 {
1608 TRACE_ERROR("sAT_PercentNRG error");
1609 //Sep 23, 2004 REF: CRR 24562 xvilliva
1610 //If AT_FAIL is returned, we query for the exact error
1611 //and set a variable accordingly.
1612 if(result == AT_FAIL)
1613 {
1614 ULONG err;
1615
1616 err = qAT_ErrDesc();
1617 switch (ACI_ERR_DESC_CLASS( err ))
1618 {
1619 case ACI_ERR_CLASS_Cme:
1620 if (ACI_ERR_DESC_NR( err ) == CME_ERR_OpNotAllow)
1621 {
1622 g_ensErr = 1;
1623 }
1624 break;
1625 }
1626 }
1627 }
1628 }
1629
1630
1631 /*
1632 +--------------------------------------------------------------------+
1633 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1634 | STATE : code ROUTINE : nm_spn_cnf |
1635 +--------------------------------------------------------------------+
1636
1637 PURPOSE : Notify about service provider name
1638
1639 */
1640
1641 void nm_spn_cnf (SHORT error, T_EF_SPN *efspn)
1642 {
1643 U8 i;
1644
1645 SHORT simErr;
1646 TRACE_FUNCTION("nm_spn_cnf()");
1647
1648
1649 #ifdef FF_2TO1_PS
1650 simErr = CAUSE_SIM_NO_ERROR;
1651 #else
1652 simErr = SIM_NO_ERROR;
1653 #endif
1654
1655 #ifdef NO_ASCIIZ
1656 memset (service_provider_name.data, 0, sizeof(service_provider_name.data));
1657 service_provider_name.len = 0;
1658
1659 if (error EQ simErr)
1660 {
1661 for (i=0; (efspn->service_provider[i] != 0xFF) && (i < SP_NAME); i++)
1662 service_provider_name.data[i] = efspn->service_provider[i];
1663
1664 service_provider_name.len = i;
1665 }
1666 #else
1667 memset (service_provider_name, 0, sizeof(service_provider_name));
1668
1669 if (error EQ simErr)
1670 {
1671 for (i=0; (efspn->service_provider[i] != 0xFF) && (i < SP_NAME-1); i++)
1672 service_provider_name[i] = efspn->service_provider[i];
1673 }
1674 #endif
1675 display_condition = efspn->display_condition & 0x01;
1676
1677 #ifdef SIM_TOOLKIT
1678 if (sat_update)
1679 {
1680 sat_update = FALSE;
1681 satUpdateFiles ( TRUE, SIM_SPN );
1682 }
1683 #endif
1684 }
1685
1686 #ifdef SIM_TOOLKIT
1687 /*
1688 +---------------------------------------------------------------------+
1689 | PROJECT : MMI-Framework (8417) MODULE : MFW_SIM |
1690 | STATE : code ROUTINE : nm_sat_file_update |
1691 +---------------------------------------------------------------------+
1692
1693 PURPOSE : SIM file change indication
1694
1695 */
1696
1697 void nm_sat_file_update(USHORT dataId)
1698 {
1699 UBYTE serv_stat;
1700
1701 TRACE_FUNCTION("nm_sat_file_update()");
1702
1703 switch (dataId)
1704 {
1705 case SIM_SPN:
1706 if ((serv_stat = sim_serv_table_check(17)) NEQ NO_ALLOCATED)
1707 {
1708 sat_update = TRUE;
1709 sim_read_sim(SIM_SPN, NOT_PRESENT_8BIT, 17);
1710 }
1711 else
1712 satUpdateFiles ( TRUE, SIM_SPN );
1713 break;
1714 default:
1715 break;
1716 }
1717 }
1718 #endif
1719
1720
1721 /*
1722 +--------------------------------------------------------------------+
1723 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1724 | STATE : code ROUTINE : nm_deregistration |
1725 +--------------------------------------------------------------------+
1726
1727 PURPOSE : Delete registration
1728
1729 */
1730
1731 void nm_deregistration (void)
1732 {
1733 TRACE_FUNCTION ("nm_deregistration()");
1734
1735 if (sAT_PlusCFUN(CMD_SRC_LCL,CFUN_FUN_Minimum,CFUN_RST_NotPresent)
1736 != AT_EXCT)
1737 {
1738 TRACE_ERROR("sAT_PlusCFUN error");
1739 }
1740 }
1741
1742
1743 /*
1744 +-----------------------------------------------------------------------+
1745 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1746 | STATE : code ROUTINE : nm_ok_deregistration |
1747 +-----------------------------------------------------------------------+
1748
1749 PURPOSE : de-registration successful
1750
1751 */
1752
1753 void nm_ok_deregistration (void)
1754 {
1755 TRACE_FUNCTION ("nm_ok_deregistration()");
1756 nm_signal(E_NM_DEREGISTRATION, 0);
1757 }
1758
1759
1760 /*
1761 +--------------------------------------------------------------------+
1762 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1763 | STATE : code ROUTINE : nm_ok_cops |
1764 +--------------------------------------------------------------------+
1765
1766 PURPOSE : Successful end of operator selection
1767
1768 */
1769
1770 void nm_ok_cops (void)
1771 {
1772 TRACE_FUNCTION("nm_ok_cops()");
1773
1774 nm_search_reg_status();
1775 reg_flag = 0;
1776 }
1777
1778
1779 /*
1780 +--------------------------------------------------------------------+
1781 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1782 | STATE : code ROUTINE : nm_ok_cops |
1783 +--------------------------------------------------------------------+
1784
1785 PURPOSE : Successful selection of band
1786 SPR919 - SH - added this function.
1787 */
1788
1789 void nm_ok_band (void)
1790 {
1791 TRACE_FUNCTION("nm_ok_band()");
1792
1793 nm_signal(E_NM_BAND, 0);
1794 }
1795
1796
1797
1798 /*
1799 +--------------------------------------------------------------------+
1800 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1801 | STATE : code ROUTINE : nm_error_cops |
1802 +--------------------------------------------------------------------+
1803
1804 PURPOSE : error end of operator selection
1805
1806 */
1807
1808 void nm_error_cops (void)
1809 {
1810 TRACE_FUNCTION("nm_error_cops()");
1811
1812 nm_search_reg_status();
1813 reg_flag = 0;
1814 }
1815
1816
1817 /*
1818 +--------------------------------------------------------------------+
1819 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1820 | STATE : code ROUTINE : nm_reg_status |
1821 +--------------------------------------------------------------------+
1822
1823 PURPOSE : Check the registration status
1824
1825 */
1826
1827 T_MFW nm_reg_status (void)
1828 {
1829 TRACE_FUNCTION("nm_reg_status()");
1830
1831 return reg_stat;
1832 }
1833
1834
1835 /*
1836 +--------------------------------------------------------------------+
1837 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1838 | STATE : code ROUTINE : rAT_PlusCOPS |
1839 +--------------------------------------------------------------------+
1840
1841 PURPOSE : Notify about available PLMN list
1842 NOTE : oper_list defines as char *
1843 Every operator (PLMN) uses 3 bytes
1844
1845 // July 14, 2005 REF: CRR 31916 x0021334
1846 // The functionality in rAT_PlusCOPS has been moved to new function 'nm_Plus_Percent_COPS()'
1847 which is common for rAT_PercentCOPS as well.
1848
1849 //SPR#0777 - DS - Added check to make sure last_ind is valid. If invalid set to 0.
1850 // - Changed check to make last_ind equal to MAX_OPER-1 if last_ind is greater than MAX_OPER.
1851 // - Changed <= to < in nm_copy_plmn_list for loop.
1852
1853 */
1854
1855 void rAT_PlusCOPS (S16 last_ind, T_ACI_COPS_OPDESC *operLst)
1856 {
1857 TRACE_FUNCTION ("rAT_PlusCOPS()");
1858
1859 nm_Plus_Percent_COPS(last_ind, operLst);
1860 }
1861
1862
1863 /*
1864 +--------------------------------------------------------------------+
1865 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1866 | STATE : code ROUTINE : rAT_PercentCOPS |
1867 +--------------------------------------------------------------------+
1868
1869 PURPOSE : Notify about available PLMN list. Call is made to nm_Plus_Percent_COPS().
1870
1871 // July 14, 2005 REF: CRR 31916 x0021334
1872 // New function 'rAT_PercentCOPS()' implemented.
1873
1874 */
1875
1876 void rAT_PercentCOPS (S16 last_ind, T_ACI_COPS_OPDESC *operLst)
1877 {
1878 TRACE_FUNCTION ("rAT_PercentCOPS()");
1879
1880 nm_Plus_Percent_COPS(last_ind, operLst);
1881 }
1882
1883
1884 /*
1885 +--------------------------------------------------------------------+
1886 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1887 | STATE : code ROUTINE : nm_Plus_Percent_COPS |
1888 +--------------------------------------------------------------------+
1889
1890 PURPOSE : Notify about available PLMN list. Common function called from rAT_PlusCOPS
1891 and rAT_PercentCOPS
1892
1893 // July 14, 2005 REF: CRR 31916 x0021334
1894 // New function 'nm_Plus_Percent_COPS()' implemented.
1895
1896 */
1897
1898 void nm_Plus_Percent_COPS (S16 last_ind, T_ACI_COPS_OPDESC *operLst)
1899 {
1900 int i;
1901 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1902 //Dynamically allocate the plmn_list
1903 T_MFW_PLMN_LIST *plmn_list;
1904 plmn_list=(T_MFW_PLMN_LIST*)mfwAlloc(sizeof(T_MFW_PLMN_LIST));
1905 if(plmn_list==NULL)
1906 {
1907 TRACE_EVENT("plmn_list malloc failed");
1908 return;
1909 }
1910 TRACE_FUNCTION ("nm_Plus_Percent_COPS()");
1911
1912 memset(plmn_list, 0, sizeof(T_MFW_PLMN_LIST));
1913
1914 if (operLst[0].status == COPS_STAT_Unknown)
1915 {
1916 nm_signal(E_NM_PLMN_LIST,plmn_list);
1917 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1918 //Deallocate the plmn_list
1919 if(plmn_list !=NULL)
1920 {
1921 mfwFree((U8*)plmn_list,sizeof(T_MFW_PLMN_LIST));
1922 plmn_list = NULL;
1923 }
1924 return;
1925 }
1926 /***************************Go-lite Optimization changes Start***********************/
1927 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1928 TRACE_EVENT_P1("rAT_PlusCOPS: last_ind: %d",last_ind);
1929 /***************************Go-lite Optimization changes END***********************/
1930 if (last_ind > 128) //Invalid index passed in.
1931 {
1932 last_ind = -1;
1933 }
1934 else
1935 {
1936 if (last_ind >= MAX_OPER) //Index is larger than max number of operators.
1937 {
1938 last_ind = MAX_OPER-1;
1939 }
1940 }
1941
1942
1943 //DS 27/5/2002 - changed <= to <
1944 for (i = 0; i <= last_ind; i++) /* operLst == oper_list !! */
1945 {
1946 nm_copy_plmn_list(&plmn_list->plmn[i], &operLst[i]);
1947 }
1948 /***************************Go-lite Optimization changes Start***********************/
1949 // Aug 16, 2004 REF: CRR 24323 Deepa M.D
1950 TRACE_EVENT_P1("rAT_PlusCOPS: Loop i val is %d",i);
1951 /***************************Go-lite Optimization changes END***********************/
1952 plmn_list->count = i;
1953
1954 nm_signal(E_NM_PLMN_LIST,plmn_list);
1955 //Mar 01, 2005 REF: ENH 29327 xdeepadh
1956 //Deallocate the plmn_list
1957 if(plmn_list !=NULL)
1958 {
1959 mfwFree((U8*)plmn_list,sizeof(T_MFW_PLMN_LIST));
1960 plmn_list =NULL;
1961 }
1962 }
1963
1964
1965
1966
1967 /*
1968 +----------------------------------------------------------------------+
1969 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
1970 | STATE : code ROUTINE : nm_search_reg_status |
1971 +----------------------------------------------------------------------+
1972
1973 PURPOSE : Change registration status
1974
1975 */
1976
1977 void nm_search_reg_status(void)
1978 {
1979 T_ACI_NRG_RGMD regMode;
1980 T_ACI_NRG_SVMD srvMode;
1981 T_ACI_NRG_FRMT oprFrmt;
1982 T_ACI_NRG_SVMD srvStat;
1983 U8 oper[LONG_NAME];
1984
1985 qAT_PercentNRG(CMD_SRC_LCL,
1986 &regMode,
1987 &srvMode,
1988 &oprFrmt,
1989 &srvStat,
1990 (char *)oper);
1991
1992 if (srvStat == NRG_SVMD_Limited)
1993 {
1994 reg_stat = MFW_LIMITED_SERVICE;
1995 nm_signal(E_NM_LIMITED_SERVICE,NULL);
1996 }
1997 if (srvStat == NRG_SVMD_NoSrv)
1998 {
1999 reg_stat = MFW_NO_SERVICE;
2000 nm_signal(E_NM_NO_SERVICE,NULL);
2001 }
2002 }
2003
2004
2005 /*
2006 +--------------------------------------------------------------------+
2007 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2008 | STATE : code ROUTINE : rAT_PlusCREG |
2009 +--------------------------------------------------------------------+
2010
2011 PURPOSE : Change registration status
2012
2013 */
2014
2015 void rAT_PlusCREG (T_ACI_CREG_STAT stat,
2016 USHORT lac,
2017 USHORT cid)
2018 {
2019 T_MFW_NETWORK_STRUCT plmn_ident;
2020 T_MFW_CELL_STRUCT cell;
2021 T_ACI_NRG_RGMD regMode;
2022 T_ACI_NRG_SVMD srvMode;
2023 T_ACI_NRG_FRMT oprFrmt;
2024 T_ACI_NRG_SVMD srvStat;
2025 U8 oper[LONG_NAME];
2026
2027 TRACE_FUNCTION("rAT_PlusCREG()");
2028
2029 switch (stat)
2030 {
2031 case CREG_STAT_Reg:
2032 case CREG_STAT_Roam:
2033 reg_stat = MFW_FULL_SERVICE;
2034 qAT_PercentNRG(CMD_SRC_LCL,
2035 &regMode,
2036 &srvMode,
2037 &oprFrmt,
2038 &srvStat,
2039 (char *)oper);
2040 #ifdef NO_ASCIIZ
2041 sAT_PlusCOPSE(oper,(U8) oprFrmt,&plmn_ident.network_long,
2042 &plmn_ident.network_short,
2043 plmn_ident.network_numeric);
2044 memcpy(plmn_ident.service_provider.data,
2045 service_provider_name.data,
2046 service_provider_name.len);
2047 plmn_ident.service_provider.len = service_provider_name.len;
2048 #else
2049 sAT_PlusCOPSE(oper,(U8) oprFrmt,plmn_ident.network_long,
2050 plmn_ident.network_short,
2051 plmn_ident.network_numeric);
2052 strcpy((char *) plmn_ident.service_provider,
2053 (char *) service_provider_name);
2054 #endif
2055 plmn_ident.display_condition = display_condition & 0x01;
2056 if (stat == CREG_STAT_Reg)
2057 plmn_ident.roaming_indicator = 0;
2058 if (stat == CREG_STAT_Roam)
2059 plmn_ident.roaming_indicator = 1;
2060
2061 //x0pleela 08 Feb, 2006 ER: OMAPS00065203
2062 nm_get_COPN( &plmn_ident );
2063
2064 nm_signal(E_NM_FULL_SERVICE,&plmn_ident);
2065
2066 /* Cell ReSelection Code */
2067 cell.ci = cid;
2068 cell.lid = lac;
2069 nm_signal(E_NM_CELL_SELECT,&cell);
2070 break;
2071
2072 case CREG_STAT_NoSearch:
2073 case CREG_STAT_Denied:
2074 case CREG_STAT_NotPresent:
2075 if (!reg_flag)
2076 nm_search_reg_status();
2077 break;
2078 case CREG_STAT_Search:
2079 if (reg_flag)
2080 {
2081 reg_stat = MFW_SEARCH_NETWORK;
2082 nm_signal(E_NM_SEARCH_NETWORK,NULL);
2083 }
2084 else
2085 nm_search_reg_status();
2086 break;
2087 default:
2088 nm_search_reg_status();
2089 break;
2090 }
2091 }
2092
2093
2094 /*
2095 +--------------------------------------------------------------------+
2096 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2097 | STATE : code ROUTINE : nm_abort_avail_plmn|
2098 +--------------------------------------------------------------------+
2099
2100 PURPOSE : Change registration status
2101
2102 */
2103
2104 void nm_abort_avail_plmn(void)
2105 {
2106 sAT_Abort(CMD_SRC_LCL, AT_CMD_COPS);
2107 }
2108
2109 /*
2110 +--------------------------------------------------------------------+
2111 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2112 | STATE : code ROUTINE : nm_nitz_info_ind |
2113 +--------------------------------------------------------------------+
2114
2115 PURPOSE : NITZ information indication
2116
2117 */
2118
2119 #ifdef FF_2TO1_PS
2120 void nm_nitz_info_ind(T_MMREG_INFO_IND * mmr_info_ind)
2121
2122
2123 {
2124 UBYTE flag;
2125
2126 TRACE_FUNCTION("nm_nitz_info_ind()");
2127
2128 flag = 0;
2129
2130 /* BEGIN ADD: SUMIT: REQ : aligning to 5.x SAP definitions */
2131 #ifdef NEPTUNE_BOARD
2132 /* copy country code and network code */
2133 memset (net_ind.mcc, 0, PS_SIZE_MCC);
2134 memset (net_ind.mnc, 0, PS_SIZE_MNC_MAX);
2135 if (mmr_info_ind->v_plmn_id EQ TRUE)
2136 {
2137 flag = 1;
2138 memcpy (net_ind.mcc, mmr_info_ind->plmn_id.mcc, PS_SIZE_MCC);
2139 memcpy (net_ind.mnc, mmr_info_ind->plmn_id.mnc, PS_SIZE_MNC_MAX);
2140 }
2141
2142 /* copy long name */
2143 memset(&net_ind.long_name, 0, sizeof(T_MFW_NET_NAME));
2144
2145 if (mmr_info_ind->v_full_net_name EQ TRUE)
2146 {
2147 flag = 1;
2148 net_ind.long_name.dcs = mmr_info_ind->full_net_name.cs;
2149 net_ind.long_name.add_ci = mmr_info_ind->full_net_name.add_ci;
2150 net_ind.long_name.num_spare = mmr_info_ind->full_net_name.num_spare;
2151 net_ind.long_name.len = MINIMUM (MMREG_MAX_TEXT_LEN, mmr_info_ind->full_net_name.c_text);
2152 memcpy (net_ind.long_name.data,
2153 mmr_info_ind->full_net_name.text,
2154 net_ind.long_name.len);
2155 }
2156
2157 /* copy short name */
2158 memset(&net_ind.short_name, 0, sizeof(T_MFW_NET_NAME));
2159 if (mmr_info_ind->v_short_net_name EQ TRUE)
2160 {
2161 flag = 1;
2162 net_ind.short_name.dcs = mmr_info_ind->short_net_name.cs;
2163 net_ind.short_name.add_ci = mmr_info_ind->short_net_name.add_ci;
2164 net_ind.short_name.num_spare = mmr_info_ind->short_net_name.num_spare;
2165 net_ind.short_name.len = MINIMUM (MMREG_MAX_TEXT_LEN, mmr_info_ind->short_net_name.c_text);
2166 memcpy (net_ind.short_name.data,
2167 mmr_info_ind->short_net_name.text,
2168 net_ind.short_name.len);
2169 }
2170
2171 if (flag)
2172 nm_signal(E_MFW_NET_IND, &net_ind);
2173
2174 flag = 0;
2175 memset(&tim_ind, 0, sizeof(T_MFW_TIME_IND));
2176 /* copy time */
2177 if (mmr_info_ind->v_universal_time EQ TRUE AND
2178 mmr_info_ind->v_local_time_zone EQ TRUE )
2179 {
2180 flag = 1;
2181 tim_ind.timezone = mmr_info_ind->local_time_zone.time_zone;
2182 tim_ind.year = (mmr_info_ind->universal_time.year);
2183 tim_ind.month = (mmr_info_ind->universal_time.month);
2184 tim_ind.day = (mmr_info_ind->universal_time.day);
2185 tim_ind.hour = (mmr_info_ind->universal_time.hour);
2186 tim_ind.minute =(mmr_info_ind->universal_time.minute);
2187 tim_ind.second = (mmr_info_ind->universal_time.second );
2188 }
2189 else if (mmr_info_ind->v_local_time_zone EQ TRUE AND
2190 mmr_info_ind->v_universal_time NEQ TRUE )
2191 {
2192 flag = 1;
2193 tim_ind.timezone = mmr_info_ind->local_time_zone.time_zone;
2194 }
2195
2196 #else
2197 /* END ADD: Sumit */
2198 /* copy country code and network code */
2199 memset (net_ind.mcc, 0, PS_SIZE_MCC);
2200 memset (net_ind.mnc, 0, PS_SIZE_MNC_MAX);
2201 if (mmr_info_ind->plmn.plmn_presence EQ TRUE)
2202 {
2203 flag = 1;
2204 memcpy (net_ind.mcc, mmr_info_ind->plmn.plmn_id.mcc, PS_SIZE_MCC);
2205 memcpy (net_ind.mnc, mmr_info_ind->plmn.plmn_id.mnc, PS_SIZE_MNC_MAX);
2206 }
2207
2208 /* copy long name */
2209 memset(&net_ind.long_name, 0, sizeof(T_MFW_NET_NAME));
2210 if (mmr_info_ind->full_net_name.v_name EQ TRUE)
2211 {
2212 flag = 1;
2213 net_ind.long_name.dcs = mmr_info_ind->full_net_name.cs;
2214 net_ind.long_name.add_ci = mmr_info_ind->full_net_name.add_ci;
2215 net_ind.long_name.num_spare = mmr_info_ind->full_net_name.num_spare;
2216 net_ind.long_name.len = MINIMUM (MMREG_MAX_TEXT_LEN, mmr_info_ind->full_net_name.c_text);
2217 memcpy (net_ind.long_name.data,
2218 mmr_info_ind->full_net_name.text,
2219 net_ind.long_name.len);
2220 }
2221
2222 /* copy short name */
2223 memset(&net_ind.short_name, 0, sizeof(T_MFW_NET_NAME));
2224 if (mmr_info_ind->short_net_name.v_name EQ TRUE)
2225 {
2226 flag = 1;
2227 net_ind.short_name.dcs = mmr_info_ind->short_net_name.cs;
2228 net_ind.short_name.add_ci = mmr_info_ind->short_net_name.add_ci;
2229 net_ind.short_name.num_spare = mmr_info_ind->short_net_name.num_spare;
2230 net_ind.short_name.len = MINIMUM (MMREG_MAX_TEXT_LEN, mmr_info_ind->short_net_name.c_text);
2231 memcpy (net_ind.short_name.data,
2232 mmr_info_ind->short_net_name.text,
2233 net_ind.short_name.len);
2234 }
2235
2236 if (flag)
2237 nm_signal(E_MFW_NET_IND, &net_ind);
2238
2239 flag = 0;
2240 memset(&tim_ind, 0, sizeof(T_MFW_TIME_IND));
2241 /* copy time */
2242 if (mmr_info_ind->net_time_zone.v_time_zone EQ TRUE AND
2243 mmr_info_ind->net_time.v_time EQ TRUE )
2244 {
2245 flag = 1;
2246 tim_ind.timezone = mmr_info_ind->net_time_zone.time_zone;
2247 tim_ind.year = ((mmr_info_ind->net_time.year[0]-'0') * 10 + (mmr_info_ind->net_time.year[1]-'0') );
2248 tim_ind.month = ((mmr_info_ind->net_time.month[0]-'0') * 10 + (mmr_info_ind->net_time.month[1]-'0') );
2249 tim_ind.day = ((mmr_info_ind->net_time.day[0]-'0') * 10 + (mmr_info_ind->net_time.day[1]-'0') );
2250 tim_ind.hour = ((mmr_info_ind->net_time.hour[0]-'0') * 10 + (mmr_info_ind->net_time.hour[1]-'0') );
2251 tim_ind.minute = ((mmr_info_ind->net_time.minute[0]-'0') * 10 + (mmr_info_ind->net_time.minute[1]-'0') );
2252 tim_ind.second = ((mmr_info_ind->net_time.second[0]-'0') * 10 + (mmr_info_ind->net_time.second[1]-'0') );
2253 }
2254 else if (mmr_info_ind->net_time_zone.v_time_zone EQ TRUE AND
2255 mmr_info_ind->net_time.v_time NEQ TRUE )
2256 {
2257 flag = 1;
2258 tim_ind.timezone = mmr_info_ind->net_time_zone.time_zone;
2259 }
2260 /*BEGIN ADD: Neptune */
2261 #endif
2262 /*END ADD: Neptune */
2263 if (flag)
2264 nm_signal(E_MFW_TIME_IND, &tim_ind);
2265 }
2266 #else
2267 void nm_nitz_info_ind(T_MMR_INFO_IND * mmr_info_ind)
2268 {
2269 UBYTE flag;
2270
2271 TRACE_FUNCTION("nm_nitz_info_ind()");
2272
2273 flag = 0;
2274 /* copy country code and network code */
2275 memset (net_ind.mcc, 0, SIZE_MCC);
2276 memset (net_ind.mnc, 0, SIZE_MNC);
2277 if (mmr_info_ind->plmn.v_plmn EQ TRUE)
2278 {
2279 flag = 1;
2280 memcpy (net_ind.mcc, mmr_info_ind->plmn.mcc, SIZE_MCC);
2281 memcpy (net_ind.mnc, mmr_info_ind->plmn.mnc, SIZE_MNC);
2282 }
2283
2284 /* copy long name */
2285 memset(&net_ind.long_name, 0, sizeof(T_MFW_NET_NAME));
2286 if (mmr_info_ind->full_name.v_name EQ TRUE)
2287 {
2288 flag = 1;
2289 net_ind.long_name.dcs = mmr_info_ind->full_name.dcs;
2290 net_ind.long_name.add_ci = mmr_info_ind->full_name.add_ci;
2291 net_ind.long_name.num_spare = mmr_info_ind->full_name.num_spare;
2292 net_ind.long_name.len = MINIMUM (MMR_MAX_TEXT_LEN, mmr_info_ind->full_name.c_text);
2293 memcpy (net_ind.long_name.data,
2294 mmr_info_ind->full_name.text,
2295 net_ind.long_name.len);
2296 }
2297
2298 /* copy short name */
2299 memset(&net_ind.short_name, 0, sizeof(T_MFW_NET_NAME));
2300 if (mmr_info_ind->short_name.v_name EQ TRUE)
2301 {
2302 flag = 1;
2303 net_ind.short_name.dcs = mmr_info_ind->short_name.dcs;
2304 net_ind.short_name.add_ci = mmr_info_ind->short_name.add_ci;
2305 net_ind.short_name.num_spare = mmr_info_ind->short_name.num_spare;
2306 net_ind.short_name.len = MINIMUM (MMR_MAX_TEXT_LEN, mmr_info_ind->short_name.c_text);
2307 memcpy (net_ind.short_name.data,
2308 mmr_info_ind->short_name.text,
2309 net_ind.short_name.len);
2310 }
2311
2312 if (flag)
2313 nm_signal(E_MFW_NET_IND, &net_ind);
2314
2315 flag = 0;
2316 memset(&tim_ind, 0, sizeof(T_MFW_TIME_IND));
2317 /* copy time */
2318 if (mmr_info_ind->ntz.v_tz EQ TRUE AND
2319 mmr_info_ind->time.v_time EQ TRUE )
2320 {
2321 flag = 1;
2322 tim_ind.timezone = mmr_info_ind->ntz.tz;
2323 tim_ind.year = mmr_info_ind->time.year;
2324 tim_ind.month = mmr_info_ind->time.month;
2325 tim_ind.day = mmr_info_ind->time.day;
2326 tim_ind.hour = mmr_info_ind->time.hour;
2327 tim_ind.minute = mmr_info_ind->time.minute;
2328 tim_ind.second = mmr_info_ind->time.second;
2329 }
2330 else if (mmr_info_ind->ntz.v_tz EQ TRUE AND
2331 mmr_info_ind->time.v_time NEQ TRUE )
2332 {
2333 flag = 1;
2334 tim_ind.timezone = mmr_info_ind->ntz.tz;
2335 }
2336
2337 if (flag)
2338 nm_signal(E_MFW_TIME_IND, &tim_ind);
2339 }
2340 #endif
2341
2342 /*
2343 +--------------------------------------------------------------------+
2344 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2345 | STATE : code ROUTINE : nmCommand |
2346 +--------------------------------------------------------------------+
2347
2348 PURPOSE : handle mfw windows command
2349
2350 */
2351
2352 static int nmCommand (U32 cmd, void *h)
2353 {
2354 switch (cmd)
2355 {
2356 case MfwCmdDelete: /* delete me */
2357 if (!h)
2358 return 0;
2359 nm_delete(h);
2360 return 1;
2361 default:
2362 break;
2363 }
2364
2365 return 0;
2366 }
2367
2368 /*
2369 +--------------------------------------------------------------------+
2370 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2371 | STATE : code ROUTINE : nm_restrict_bands |
2372 +--------------------------------------------------------------------+
2373
2374 PURPOSE : restrict the band usage
2375 0: default
2376 1: only GSM 900
2377 2: only DCS 1800
2378
2379 */
2380
2381 T_MFW nm_restrict_bands (U8 mode)
2382 {
2383 EXTERN void pl_pei_config (char *, char *);
2384
2385 char dummy [40];
2386
2387 switch (mode)
2388 {
2389 case 0:
2390 pl_pei_config ( "CONFIG SET_BAND=0", dummy );
2391 break;
2392 case 1:
2393 pl_pei_config ( "CONFIG SET_BAND=1", dummy );
2394 break;
2395 case 2:
2396 pl_pei_config ( "CONFIG SET_BAND=2", dummy );
2397 break;
2398 }
2399
2400 return 0;
2401 }
2402
2403 #ifdef NO_ASCIIZ
2404 /*
2405 +--------------------------------------------------------------------+
2406 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2407 | STATE : code ROUTINE : nm_get_spn |
2408 +--------------------------------------------------------------------+
2409
2410 PURPOSE : Function to give access to the service provider string
2411
2412 Parameters : None
2413
2414 Return: Service provider string
2415
2416 */
2417
2418 void nm_get_spn (T_MFW_SP_NAME *name)
2419 {
2420 if (name NEQ NULL)
2421 memcpy(name, &service_provider_name, sizeof(T_MFW_SP_NAME));
2422 }
2423
2424 #else
2425 /* PATCH PMC 000804 */
2426 /*
2427 +--------------------------------------------------------------------+
2428 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2429 | STATE : code ROUTINE : nm_get_spn |
2430 +--------------------------------------------------------------------+
2431
2432 PURPOSE : Function to give access to the service provider string
2433
2434 Parameters : None
2435
2436 Return: Service provider string
2437
2438 */
2439
2440 void nm_get_spn (char *name)
2441 {
2442 if (name NEQ NULL)
2443 strncpy (name, service_provider_name, LONG_NAME);
2444 }
2445 /* END PATCH PMC */
2446 #endif
2447
2448 /*
2449 +---------------------------------------------------------------------+
2450 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2451 | STATE : code ROUTINE : nm_abort_registraion|
2452 +---------------------------------------------------------------------+
2453
2454 PURPOSE : abort current registration
2455
2456 Parameters : None
2457
2458 */
2459 void nm_abort_registraion(void)
2460 {
2461 sAT_Abort(CMD_SRC_LCL, AT_CMD_NRG);
2462 }
2463
2464 /*
2465 +--------------------------------------------------------------------+
2466 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2467 | STATE : code ROUTINE : nm_decodeSourceId |
2468 +--------------------------------------------------------------------+
2469
2470 PURPOSE : This function is used to convert the source id
2471 used by ACI to the source id used by MFW.
2472 */
2473
2474 //x0pleela 09 Feb, 2006 ER: OMAPS00065203
2475 int nm_decodeSourceId( UBYTE sourceId)
2476 {
2477 TRACE_FUNCTION("nm_decodeSourceId()");
2478 #ifndef NEPTUNE_BOARD
2479 switch (sourceId)
2480 {
2481 case Read_ROM_TABLE: return NM_ROM;
2482 case Read_EONS: return NM_EONS;
2483 case Read_CPHS: return NM_CPHS;
2484 case Read_INVALID: return NM_NITZ;
2485 default: return NM_NONE;
2486 }
2487 #endif
2488 }
2489
2490 /*
2491 +--------------------------------------------------------------------+
2492 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2493 | STATE : code ROUTINE : nm_update_plmn_data |
2494 +--------------------------------------------------------------------+
2495
2496 PURPOSE : This function is used to update plmn data after querying COPN
2497 */
2498 //x0pleela 09 Feb, 2006 ER: OMAPS00065203
2499 void nm_update_plmn_data( T_MFW_NETWORK_STRUCT *plmn_ident,
2500 T_ACI_OPER_NTRY oper_ntry)
2501 {
2502 TRACE_FUNCTION("nm_update_plmn_data()");
2503
2504 #ifndef NEPTUNE_BOARD
2505 plmn_ident->opn_read_from = nm_decodeSourceId(oper_ntry.source);
2506 #endif
2507
2508 TRACE_EVENT_P1("plmn_ident->opn_read_from:%d",plmn_ident->opn_read_from);
2509 TRACE_EVENT_P1("gEons_alloc_active:%d",gEons_alloc_active);
2510
2511 if( plmn_ident->opn_read_from EQ NM_EONS )
2512 {
2513 TRACE_EVENT("EONS TRUE");
2514 //update plmn_ident with EONS
2515 #ifdef NO_ASCIIZ
2516 memset(plmn_ident->network_long.data, 0, LONG_NAME);
2517 memset(plmn_ident->network_long.data, 0, SHORT_NAME);
2518 memcpy( plmn_ident->network_long.data,
2519 oper_ntry.longName,
2520 strlen(oper_ntry.longName) );
2521
2522 memcpy( plmn_ident->network_short.data,
2523 oper_ntry.shrtName,
2524 strlen(oper_ntry.shrtName));
2525
2526 #else
2527 memset(plmn_ident->network_long, 0, LONG_NAME);
2528 memset(plmn_ident->network_long, 0, SHORT_NAME);
2529 strcpy( plmn_ident->network_long,
2530 oper_ntry.longName);
2531 strcpy( plmn_ident->network_short,
2532 oper_ntry.shrtName);
2533 #endif
2534 {
2535 char oper_mcc_mnc[NUMERIC_LENGTH];
2536 memset( oper_mcc_mnc, 0, NUMERIC_LENGTH);
2537 sprintf(oper_mcc_mnc, "%d%d", oper_ntry.mcc, oper_ntry.mnc);
2538 memcpy( plmn_ident->network_numeric,
2539 (char*)oper_mcc_mnc,
2540 strlen(oper_mcc_mnc) );
2541 }
2542 set_opn_sel_done(TRUE);
2543 }
2544 }
2545
2546 /*
2547 +--------------------------------------------------------------------+
2548 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2549 | STATE : code ROUTINE : nm_get_COPN |
2550 +--------------------------------------------------------------------+
2551
2552 PURPOSE : This function is used to query for COPS and COPN which will indicate from
2553 where the operator name was read
2554 */
2555 //x0pleela 09 Feb, 2006 ER: OMAPS00065203
2556 void nm_get_COPN( T_MFW_NETWORK_STRUCT *plmn_ident )
2557 {
2558 T_ACI_COPS_MOD mode;
2559 T_ACI_COPS_FRMT format;
2560 T_ACI_OPER_NTRY oper_ntry;
2561 char opername[LONG_NAME];
2562
2563 TRACE_FUNCTION("nm_get_COPN()");
2564
2565 memset (&oper_ntry, 0, sizeof( T_ACI_OPER_NTRY ));
2566 //Check where MS is registered
2567 if( qAT_PlusCOPS ( CMD_SRC_LCL, &mode,
2568 &format, (char *)opername ) EQ AT_CMPL )
2569 {
2570 //Request info about operator name
2571 if(qAT_PercentCOPN(CMD_SRC_LCL,
2572 format,
2573 (char *)opername,
2574 &oper_ntry) EQ AT_CMPL )
2575 {
2576 nm_update_plmn_data(plmn_ident, oper_ntry);
2577 }
2578 }
2579 }
2580
2581 /*
2582 +--------------------------------------------------------------------+
2583 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2584 | STATE : code ROUTINE : nm_get_opername |
2585 +--------------------------------------------------------------------+
2586
2587 PURPOSE : This function updates operator name based on cingular's prioritization requirement.
2588 Priority would be in order ONS->NITZ->ROM
2589
2590 */
2591 //x0pleela 09 Feb, 2006 ER: OMAPS00065203
2592 void nm_get_opername(T_MFW_NETWORK_STRUCT * plmn_ident)
2593 {
2594 TRACE_FUNCTION("nm_get_opername()");
2595
2596 if( ( ( plmn_ident->opn_read_from EQ NM_CPHS ) AND ( plmn_ident->roaming_indicator) )
2597 OR (plmn_ident->opn_read_from EQ NM_ROM) ) //x0pleela 15 Feb, 2006 ER:OMAPS00065203
2598 //changed from NEQ NM_CPHS to EQ NM_ROM
2599 //as we know %CNIV will be called only
2600 //if source id is ROM or CPHS and not roaming
2601 {
2602 sAT_PercentCNIV(CMD_SRC_LCL, CNIV_MODE_ON);
2603 }
2604 else
2605 {
2606 set_opn_sel_done(TRUE);
2607 //send E_NM_OPN event
2608 nm_signal(E_NM_OPN, plmn_ident);
2609 }
2610 return;
2611 }
2612
2613 /*
2614 +--------------------------------------------------------------------+
2615 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2616 | STATE : code ROUTINE : nm_get_opername |
2617 +--------------------------------------------------------------------+
2618
2619 PURPOSE : This function gets operator name from network.
2620 */
2621 //x0pleela 09 Feb, 2006 ER: OMAPS00065203
2622
2623 void nm_get_network_data(T_MFW_NETWORK_STRUCT *plmn_netw_data)
2624 {
2625 TRACE_FUNCTION("nm_get_network_data()");
2626
2627 //send E_NM_OPN event
2628 nm_signal(E_NM_OPN, plmn_netw_data);
2629 }
2630
2631 /*
2632 +--------------------------------------------------------------------+
2633 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2634 | STATE : code ROUTINE : set_opn_sel_done |
2635 +--------------------------------------------------------------------+
2636
2637 PURPOSE : This function sets opn_sel_done flag to TRUE or FALSE.
2638 */
2639 //x0pleela 15 Feb, 2006 ER: OMAPS00065203
2640 void set_opn_sel_done( UBYTE opn_selected )
2641 {
2642 TRACE_FUNCTION(" set_opn_sel_done()");
2643 opn_sel_done = opn_selected;
2644 }
2645
2646 /*
2647 +--------------------------------------------------------------------+
2648 | PROJECT : MMI-Framework (8417) MODULE : MFW_NM |
2649 | STATE : code ROUTINE : set_opn_sel_done |
2650 +--------------------------------------------------------------------+
2651
2652 PURPOSE : This function returns the current value of flag opn_sel_done.
2653 */
2654 //x0pleela 15 Feb, 2006 ER: OMAPS00065203
2655 UBYTE get_opn_sel_done( void )
2656 {
2657 TRACE_FUNCTION("get_opn_sel_done()");
2658 return opn_sel_done;
2659
2660 }