CellBroadcast.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:177k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * CellBroadcast.C
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for MMI SMS APP.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  *------------------------------------------------------------------------------
  132.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  133.  *============================================================================
  134.  ****************************************************************************/
  135. /**
  136.  * Copyright Notice
  137.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  138.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  139.  *  (It is illegal to remove this copyright notice from this software or any
  140.  *  portion of it)
  141.  */
  142.  /**************************************************************
  143.    FILENAME : CellBroadcast.c
  144.    PURPOSE     : Cell Broadcast application 
  145.    REMARKS     : nil
  146.    AUTHOR      : Hariprasad, Magesh k
  147.    DATE     : JAN 09,03
  148. **************************************************************/
  149. #ifdef __MOD_SMSAL__
  150. /*  */
  151. #include "MMI_features.h"
  152. #include "stdC.h"
  153. #include "L4Dr1.h"
  154. #include "PixtelDataTypes.h"
  155. /* ... Add More MMI header */
  156. #include "EventsGprot.h"
  157. #include "HistoryGprot.h"
  158. #include "GlobalMenuItems.h"
  159. #include "GlobalConstants.h"
  160. #include "Globaldefs.h"
  161. #include "wgui_categories.h"
  162. #include "wgui_categories_inputs.h"
  163. #include "CustMenuRes.h"
  164. #include "CommonScreens.h"
  165. #include "Unicodexdcl.h"
  166. #include "TimerEvents.h"
  167. #include "DebugInitDef.h"
  168. #include "ProtocolEvents.h"
  169. /* ...Add MSG header */
  170. #include "customer_ps_inc.h"
  171. #include "mmi_msg_context.h"
  172. #include "MessagesL4Def.h"
  173. #include "MessagesResourceData.h"
  174. #include "MessagesMiscell.h"
  175. #include "MessagesExDcl.h"
  176. #include "SmsGuiInterfaceProt.h"
  177. #include "SMsGuiInterfaceType.h"
  178. #include "SmsPsHandler.h"
  179. #include "CellBroadcastType.h"
  180. /*  */
  181. #include "Gui_ems.h"
  182. #include "wgui_ems.h"
  183. #include "GSM7BitDefaultAlphabet.h"
  184. /*  */
  185. #include "NVRAMEnum.h"
  186. #include "NVRAMProt.h"
  187. #include "NVRAMType.h"
  188. #include "SettingProfile.h"
  189. #include "ProfileGprots.h"
  190. #include "SettingProt.h"
  191. #include "PhoneBookGprot.h"
  192. #include "GpioInc.h"
  193. #include "KeyBrd.h"
  194. #include "IdleAppDef.h"
  195. #include "CallManagementGprot.h"
  196. #ifdef MMI_ON_HARDWARE_P
  197. #include "nvram_user_defs.h"
  198. #endif 
  199. #include "SMSApi.h"
  200. #include "SMSStruct.h"  /* temp!! */
  201. /*  */
  202. #ifndef NVRAM_SMS_CB_CHNL_RECORD_SIZE
  203. #define NVRAM_SMS_CB_CHNL_RECORD_SIZE  180
  204. #endif 
  205. #ifndef NVRAM_SMS_CB_SMS_RECORD_SIZE
  206. /* MTK Joy modified for corrected NVRAM data size, 1207 */
  207. #define NVRAM_SMS_CB_SMS_RECORD_SIZE   826
  208. /* MTK end */
  209. #endif /* NVRAM_SMS_CB_SMS_RECORD_SIZE */ 
  210. //
  211. //MTK Joy added for multipage CB, 0113
  212. #define SWAP_USHORT(Var) *Var = *(unsigned short*)SwapEndian((void*)Var, sizeof(short))
  213. #ifndef NVRAM_SMS_CB_SMS_PAGE_SIZE
  214. #define NVRAM_SMS_CB_SMS_PAGE_SIZE        94
  215. #endif 
  216. #ifndef NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL
  217. #define NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL         30
  218. #endif 
  219. #ifndef NVRAM_SMS_CB_SMS_INFO_SIZE
  220. #define NVRAM_SMS_CB_SMS_INFO_SIZE        20
  221. #endif 
  222. #define SMS_CB_SMS_PAGE_SIZE_UCS2         82
  223. /* MTK end */
  224. #define MESSAGES_CB_BOOTUP_TIMEOUT_DURATION 3000        /* 3 Seconds */
  225. static msg_cb_channel_nvram_struct cbNvramStruct;
  226. static U8 IsCBMessageReadOperRequired = TRUE;
  227. static msg_cb_msg_index_struct cbMsgIndex;
  228. static msg_cb_msg_info_struct cbMsgInfo;
  229. static msg_cb_msg_content_struct cbMsgContent[MAX_CB_MSG_TOTAL_PAGE][NVRAM_SMS_CB_SMS_PAGE_SIZE];
  230. static U8 *cbMsgStart;
  231. //#ifdef __MMI_MESSAGES_TWO_CB_MODES_DISPLAY__
  232. //static U16 kplLSKStringtID;
  233. //static U16 kplLSKIconID;
  234. //static U16 kplRSKStringID; 
  235. //static U16 kplRSKIconID;
  236. //#endif
  237. static U8 dispCBMessage[NVRAM_SMS_CB_SMS_PAGE_SIZE * ENCODING_LENGTH * MAX_CB_MSG_PAGE];
  238. static U32 dispCBLength = 0;
  239. static U16 cbChnlEditorIcons[MAX_CB_CHNL_INLINE_ITEM] = 
  240. {
  241.     IMG_CB_CHNL_TITLE,
  242.     IMG_SMS_COMMON_NOIMAGE,
  243.     IMG_CB_CHNL_NUMBER,
  244.     IMG_SMS_COMMON_NOIMAGE
  245. };
  246. const U16 cbDefaultChnlNameStrId[SMS_CB_MAX_ENTRY] = 
  247. {
  248.     STR_CB_CHNL_NAME_1,
  249.     STR_CB_CHNL_NAME_2,
  250.     STR_CB_CHNL_NAME_3,
  251.     STR_CB_CHNL_NAME_4,
  252.     STR_CB_CHNL_NAME_5,
  253.     STR_CB_CHNL_NAME_6,
  254.     STR_CB_CHNL_NAME_7,
  255.     STR_CB_CHNL_NAME_8,
  256.     STR_CB_CHNL_NAME_9,
  257.     STR_CB_CHNL_NAME_10,
  258.     STR_CB_CHNL_NAME_11,
  259.     STR_CB_CHNL_NAME_12,
  260.     STR_CB_CHNL_NAME_13,
  261.     STR_CB_CHNL_NAME_14,
  262.     STR_CB_CHNL_NAME_15,
  263.     STR_CB_CHNL_NAME_16,
  264.     STR_CB_CHNL_NAME_17,
  265.     STR_CB_CHNL_NAME_18,
  266.     STR_CB_CHNL_NAME_19,
  267.     STR_CB_CHNL_NAME_20,
  268.     STR_CB_CHNL_NAME_21,
  269.     STR_CB_CHNL_NAME_22,
  270.     STR_CB_CHNL_NAME_23,
  271.     STR_CB_CHNL_NAME_24,
  272.     STR_CB_CHNL_NAME_25,
  273.     STR_CB_CHNL_NAME_26,
  274.     STR_CB_CHNL_NAME_27,
  275.     STR_CB_CHNL_NAME_28,
  276.     STR_CB_CHNL_NAME_29,
  277.     STR_CB_CHNL_NAME_30,
  278.     STR_CB_CHNL_NAME_31,
  279.     STR_CB_CHNL_NAME_32,
  280.     STR_CB_CHNL_NAME_33,
  281.     STR_CB_CHNL_NAME_34,
  282.     STR_CB_CHNL_NAME_35,
  283.     STR_CB_CHNL_NAME_36,
  284.     STR_CB_CHNL_NAME_37,
  285.     STR_CB_CHNL_NAME_38,
  286.     STR_CB_CHNL_NAME_39,
  287.     STR_CB_CHNL_NAME_40,
  288. };
  289. /*  */
  290. /**************************************************************
  291.             revised part--variable
  292. **************************************************************/
  293. static msg_cb_info_struct cb_info;
  294. static msg_cb_state_enum cb_state;
  295. static msg_cb_display_struct cb_display;
  296. extern wgui_inline_item wgui_inline_items[];
  297. /*************************************************************
  298.             Cb language
  299. *************************************************************/
  300. const U32 LangEnumAndStrID[MAX_LANG_SUPPORT][2] = 
  301. {
  302.     {MMI_CBS0_GERMAN, STR_LANG_GERMAN},
  303.     {MMI_CBS0_ENGLISH, STR_LANG_ENGLISH},
  304.     {MMI_CBS0_ITALIAN, STR_LANG_ITALIAN},
  305.     {MMI_CBS0_FRENCH, STR_LANG_FRENCH},
  306.     {MMI_CBS0_SPANISH, STR_LANG_SPANISH},
  307.     {MMI_CBS0_DUTCH, STR_LANG_DUTCH},
  308.     {MMI_CBS0_SWEDISH, STR_LANG_SWEDISH},
  309.     {MMI_CBS0_DANISH, STR_LANG_DANISH},
  310.     {MMI_CBS0_PORTUGUESE, STR_LANG_PORTUGUESE},
  311.     {MMI_CBS0_FINNISH, STR_LANG_FINNISH},
  312.     {MMI_CBS0_NORWEGIAN, STR_LANG_NORWEGIAN},
  313.     {MMI_CBS0_GREEK, STR_LANG_GREEK},
  314.     {MMI_CBS0_TURKISH, STR_LANG_TURKISH},
  315.     {MMI_CBS0_HUNGARIAN, STR_LANG_HUNGARIAN},
  316.     {MMI_CBS0_POLISH, STR_LANG_POLISH},
  317.     {MMI_CBS0_LANG_UNSPECIFIED, STR103_MITEM103_CB_LANGUAGE_UNSPECIFIED},
  318.     {MMI_CBS1_CZECH, STR_LANG_CZECH},
  319.     {MMI_CBS1_HEBREW, STR_LANG_HEBREW},
  320.     {MMI_CBS1_ARABIC, STR_LANG_ARABIC},
  321.     {MMI_CBS1_RUSSIAN, STR_LANG_RUSSIAN},
  322.     {MMI_CBS2_AA, STR_LANG_AFAR},
  323.     {MMI_CBS2_AB, STR_LANG_ABKHAZIAN},
  324.     {MMI_CBS2_AF, STR_LANG_AFRIKAANS},
  325.     {MMI_CBS2_AM, STR_LANG_AMHARIC},
  326.     {MMI_CBS2_AR, STR_LANG_ARABIC},
  327.     {MMI_CBS2_AS, STR_LANG_ASSAMESE},
  328.     {MMI_CBS2_AY, STR_LANG_AYMARA},
  329.     {MMI_CBS2_AZ, STR_LANG_AZERBAIJANI},
  330.     {MMI_CBS2_BA, STR_LANG_BASHKIR},
  331.     {MMI_CBS2_BE, STR_LANG_BYELORUSSIAN},
  332.     {MMI_CBS2_BG, STR_LANG_BULGARIAN},
  333.     {MMI_CBS2_BH, STR_LANG_BIHARI},
  334.     {MMI_CBS2_BI, STR_LANG_BISLAMA},
  335.     {MMI_CBS2_BN, STR_LANG_BENGALI},
  336.     {MMI_CBS2_BO, STR_LANG_TIBETAN},
  337.     {MMI_CBS2_BR, STR_LANG_BRETON},
  338.     {MMI_CBS2_CA, STR_LANG_CATALAN},
  339.     {MMI_CBS2_CO, STR_LANG_CORSICAN},
  340.     {MMI_CBS2_CS, STR_LANG_CZECH},
  341.     {MMI_CBS2_CY, STR_LANG_WELSH},
  342.     {MMI_CBS2_DA, STR_LANG_DANISH},
  343.     {MMI_CBS2_DE, STR_LANG_GERMAN},
  344.     {MMI_CBS2_DZ, STR_LANG_BHUTANI},
  345.     {MMI_CBS2_EL, STR_LANG_GREEK},
  346.     {MMI_CBS2_EN, STR_LANG_ENGLISH},
  347.     {MMI_CBS2_EO, STR_LANG_ESPERANTO},
  348.     {MMI_CBS2_ES, STR_LANG_SPANISH},
  349.     {MMI_CBS2_ET, STR_LANG_ESTONIAN},
  350.     {MMI_CBS2_EU, STR_LANG_BASQUE},
  351.     {MMI_CBS2_FA, STR_LANG_PERSIAN},
  352.     {MMI_CBS2_FI, STR_LANG_FINNISH},
  353.     {MMI_CBS2_FJ, STR_LANG_FIJI},
  354.     {MMI_CBS2_FO, STR_LANG_FAROESE},
  355.     {MMI_CBS2_FR, STR_LANG_FRENCH},
  356.     {MMI_CBS2_FY, STR_LANG_FRISIAN},
  357.     {MMI_CBS2_GA, STR_LANG_IRISH},
  358.     {MMI_CBS2_GD, STR_LANG_SCOTS_GAELIC},
  359.     {MMI_CBS2_GL, STR_LANG_GALICIAN},
  360.     {MMI_CBS2_GN, STR_LANG_GUARANI},
  361.     {MMI_CBS2_GU, STR_LANG_GUJARATI},
  362.     {MMI_CBS2_HA, STR_LANG_HAUSA},
  363.     {MMI_CBS2_HE, STR_LANG_HEBREW},
  364.     {MMI_CBS2_HI, STR_LANG_HINDI},
  365.     {MMI_CBS2_HR, STR_LANG_CROATIAN},
  366.     {MMI_CBS2_HU, STR_LANG_HUNGARIAN},
  367.     {MMI_CBS2_HY, STR_LANG_ARMENIAN},
  368.     {MMI_CBS2_IA, STR_LANG_INTERLINGUA},
  369.     {MMI_CBS2_ID, STR_LANG_INDONESIAN},
  370.     {MMI_CBS2_IE, STR_LANG_INTERLINGUE},
  371.     {MMI_CBS2_IK, STR_LANG_INUPIAK},
  372.     {MMI_CBS2_IS, STR_LANG_ICELANDIC},
  373.     {MMI_CBS2_IT, STR_LANG_ITALIAN},
  374.     {MMI_CBS2_IU, STR_LANG_INUKTITUT},
  375.     {MMI_CBS2_JA, STR_LANG_JAPANESE},
  376.     {MMI_CBS2_JW, STR_LANG_JAVANESE},
  377.     {MMI_CBS2_KA, STR_LANG_GEORGIAN},
  378.     {MMI_CBS2_KK, STR_LANG_KAZAKH},
  379.     {MMI_CBS2_KL, STR_LANG_GREENLANDIC},
  380.     {MMI_CBS2_KM, STR_LANG_CAMBODIAN},
  381.     {MMI_CBS2_KN, STR_LANG_KANNADA},
  382.     {MMI_CBS2_KO, STR_LANG_KOREAN},
  383.     {MMI_CBS2_KS, STR_LANG_KASHMIRI},
  384.     {MMI_CBS2_KU, STR_LANG_KURDISH},
  385.     {MMI_CBS2_KY, STR_LANG_KIRGHIZ},
  386.     {MMI_CBS2_LA, STR_LANG_LATIN},
  387.     {MMI_CBS2_LN, STR_LANG_LINGALA},
  388.     {MMI_CBS2_LO, STR_LANG_LAOTHIAN},
  389.     {MMI_CBS2_LT, STR_LANG_LITHUANIAN},
  390.     {MMI_CBS2_LV, STR_LANG_LATVIAN},
  391.     {MMI_CBS2_MG, STR_LANG_MALAGASY},
  392.     {MMI_CBS2_MI, STR_LANG_MAORI},
  393.     {MMI_CBS2_MK, STR_LANG_MACEDONIAN},
  394.     {MMI_CBS2_ML, STR_LANG_MALAYALAM},
  395.     {MMI_CBS2_MN, STR_LANG_MONGOLIAN},
  396.     {MMI_CBS2_MO, STR_LANG_MOLDAVIAN},
  397.     {MMI_CBS2_MR, STR_LANG_MARATHI},
  398.     {MMI_CBS2_MS, STR_LANG_MALAY},
  399.     {MMI_CBS2_MT, STR_LANG_MALTESE},
  400.     {MMI_CBS2_MY, STR_LANG_BURMESE},
  401.     {MMI_CBS2_NA, STR_LANG_NAURU},
  402.     {MMI_CBS2_NE, STR_LANG_NEPALI},
  403.     {MMI_CBS2_NL, STR_LANG_DUTCH},
  404.     {MMI_CBS2_NO, STR_LANG_NORWEGIAN},
  405.     {MMI_CBS2_OC, STR_LANG_OCCITAN},
  406.     {MMI_CBS2_OM, STR_LANG_OROMO},
  407.     {MMI_CBS2_OR, STR_LANG_ORIYA},
  408.     {MMI_CBS2_PA, STR_LANG_PUNJABI},
  409.     {MMI_CBS2_PL, STR_LANG_POLISH},
  410.     {MMI_CBS2_PS, STR_LANG_PASHTO},
  411.     {MMI_CBS2_PT, STR_LANG_PORTUGUESE},
  412.     {MMI_CBS2_QU, STR_LANG_QUECHUA},
  413.     {MMI_CBS2_RM, STR_LANG_RHAETO_ROMANCE},
  414.     {MMI_CBS2_RN, STR_LANG_KIRUNDI},
  415.     {MMI_CBS2_RO, STR_LANG_ROMANIAN},
  416.     {MMI_CBS2_RU, STR_LANG_RUSSIAN},
  417.     {MMI_CBS2_RW, STR_LANG_KINYARWANDA},
  418.     {MMI_CBS2_SA, STR_LANG_SANSKRIT},
  419.     {MMI_CBS2_SD, STR_LANG_SINDHI},
  420.     {MMI_CBS2_SG, STR_LANG_SANGHO},
  421.     {MMI_CBS2_SH, STR_LANG_SERBO_CROATIAN},
  422.     {MMI_CBS2_SI, STR_LANG_SINHALESE},
  423.     {MMI_CBS2_SK, STR_LANG_SLOVAK},
  424.     {MMI_CBS2_SL, STR_LANG_SLOVENIAN},
  425.     {MMI_CBS2_SM, STR_LANG_SAMOAN},
  426.     {MMI_CBS2_SN, STR_LANG_SHONA},
  427.     {MMI_CBS2_SO, STR_LANG_SOMALI},
  428.     {MMI_CBS2_SQ, STR_LANG_ALBANIAN},
  429.     {MMI_CBS2_SR, STR_LANG_SERBIAN},
  430.     {MMI_CBS2_SS, STR_LANG_SISWATI},
  431.     {MMI_CBS2_ST, STR_LANG_SESOTHO},
  432.     {MMI_CBS2_SU, STR_LANG_SUNDANESE},
  433.     {MMI_CBS2_SV, STR_LANG_SWEDISH},
  434.     {MMI_CBS2_SW, STR_LANG_SWAHILI},
  435.     {MMI_CBS2_TA, STR_LANG_TAMIL},
  436.     {MMI_CBS2_TE, STR_LANG_TELUGU},
  437.     {MMI_CBS2_TG, STR_LANG_TAJIK},
  438.     {MMI_CBS2_TH, STR_LANG_THAI},
  439.     {MMI_CBS2_TI, STR_LANG_TIGRINYA},
  440.     {MMI_CBS2_TK, STR_LANG_TURKMEN},
  441.     {MMI_CBS2_TL, STR_LANG_TAGALOG},
  442.     {MMI_CBS2_TN, STR_LANG_SETSWANA},
  443.     {MMI_CBS2_TO, STR_LANG_TONGA},
  444.     {MMI_CBS2_TR, STR_LANG_TURKISH},
  445.     {MMI_CBS2_TS, STR_LANG_TSONGA},
  446.     {MMI_CBS2_TT, STR_LANG_TATAR},
  447.     {MMI_CBS2_TW, STR_LANG_TWI},
  448.     {MMI_CBS2_UG, STR_LANG_UIGHUR},
  449.     {MMI_CBS2_UK, STR_LANG_UKRAINIAN},
  450.     {MMI_CBS2_UR, STR_LANG_URDU},
  451.     {MMI_CBS2_UZ, STR_LANG_UZBEK},
  452.     {MMI_CBS2_VI, STR_LANG_VIETNAMESE},
  453.     {MMI_CBS2_VO, STR_LANG_VOLAPUK},
  454.     {MMI_CBS2_WO, STR_LANG_WOLOF},
  455.     {MMI_CBS2_XH, STR_LANG_XHOSA},
  456.     {MMI_CBS2_YI, STR_LANG_YIDDISH},
  457.     {MMI_CBS2_YO, STR_LANG_YORUBA},
  458.     {MMI_CBS2_ZA, STR_LANG_ZHUANG},
  459.     {MMI_CBS2_ZH, STR_LANG_CHINESE},
  460.     {MMI_CBS2_ZU, STR_LANG_ZULU},
  461.     {MMI_CBS_INVALID, 0}
  462. };
  463. /*****************************************************************************
  464.  * FUNCTION
  465.  *  MMICbsDecodeLang
  466.  * DESCRIPTION
  467.  *  Decode CB language
  468.  * PARAMETERS
  469.  *  char1           [IN]            Char 1
  470.  *  char2           [IN]            Char 2
  471.  *  lang_type       [IN/OUT]        Language type
  472.  * RETURNS
  473.  *  void
  474.  *****************************************************************************/
  475. void MMICbsDecodeLang(U8 char1, U8 char2, msg_cb_lang_enum *lang_type)
  476. {
  477.     /*----------------------------------------------------------------*/
  478.     /* Local Variables                                                */
  479.     /*----------------------------------------------------------------*/
  480.     /*----------------------------------------------------------------*/
  481.     /* Code Body                                                      */
  482.     /*----------------------------------------------------------------*/
  483.     *lang_type = MMI_CBS_INVALID;
  484.     switch (char1)
  485.     {
  486.         case 'a':
  487.             switch (char2)
  488.             {
  489.                 case 'a':
  490.                     *lang_type = MMI_CBS2_AA;
  491.                     break;
  492.                 case 'b':
  493.                     *lang_type = MMI_CBS2_AB;
  494.                     break;
  495.                 case 'f':
  496.                     *lang_type = MMI_CBS2_AF;
  497.                     break;
  498.                 case 'm':
  499.                     *lang_type = MMI_CBS2_AM;
  500.                     break;
  501.                 case 'r':
  502.                     *lang_type = MMI_CBS2_AR;
  503.                     break;
  504.                 case 's':
  505.                     *lang_type = MMI_CBS2_AS;
  506.                     break;
  507.                 case 'y':
  508.                     *lang_type = MMI_CBS2_AY;
  509.                     break;
  510.                 case 'z':
  511.                     *lang_type = MMI_CBS2_AZ;
  512.                     break;
  513.             }
  514.             break;
  515.         case 'b':
  516.             switch (char2)
  517.             {
  518.                 case 'a':
  519.                     *lang_type = MMI_CBS2_BA;
  520.                     break;
  521.                 case 'e':
  522.                     *lang_type = MMI_CBS2_BE;
  523.                     break;
  524.                 case 'g':
  525.                     *lang_type = MMI_CBS2_BG;
  526.                     break;
  527.                 case 'h':
  528.                     *lang_type = MMI_CBS2_BH;
  529.                     break;
  530.                 case 'i':
  531.                     *lang_type = MMI_CBS2_BI;
  532.                     break;
  533.                 case 'n':
  534.                     *lang_type = MMI_CBS2_BN;
  535.                     break;
  536.                 case 'o':
  537.                     *lang_type = MMI_CBS2_BO;
  538.                     break;
  539.                 case 'r':
  540.                     *lang_type = MMI_CBS2_BR;
  541.                     break;
  542.             }
  543.             break;
  544.         case 'c':
  545.             switch (char2)
  546.             {
  547.                 case 'a':
  548.                     *lang_type = MMI_CBS2_CA;
  549.                     break;
  550.                 case 'o':
  551.                     *lang_type = MMI_CBS2_CO;
  552.                     break;
  553.                 case 's':
  554.                     *lang_type = MMI_CBS2_CS;
  555.                     break;
  556.                 case 'y':
  557.                     *lang_type = MMI_CBS2_CY;
  558.                     break;
  559.             }
  560.             break;
  561.         case 'd':
  562.             switch (char2)
  563.             {
  564.                 case 'a':
  565.                     *lang_type = MMI_CBS2_DA;
  566.                     break;
  567.                 case 'e':
  568.                     *lang_type = MMI_CBS2_DE;
  569.                     break;
  570.                 case 'z':
  571.                     *lang_type = MMI_CBS2_DZ;
  572.                     break;
  573.             }
  574.             break;
  575.         case 'e':
  576.             switch (char2)
  577.             {
  578.                 case 'l':
  579.                     *lang_type = MMI_CBS2_EL;
  580.                     break;
  581.                 case 'n':
  582.                     *lang_type = MMI_CBS2_EN;
  583.                     break;
  584.                 case 'o':
  585.                     *lang_type = MMI_CBS2_EO;
  586.                     break;
  587.                 case 's':
  588.                     *lang_type = MMI_CBS2_ES;
  589.                     break;
  590.                 case 't':
  591.                     *lang_type = MMI_CBS2_ET;
  592.                     break;
  593.                 case 'u':
  594.                     *lang_type = MMI_CBS2_EU;
  595.                     break;
  596.             }
  597.             break;
  598.         case 'f':
  599.             switch (char2)
  600.             {
  601.                 case 'a':
  602.                     *lang_type = MMI_CBS2_FA;
  603.                     break;
  604.                 case 'i':
  605.                     *lang_type = MMI_CBS2_FI;
  606.                     break;
  607.                 case 'j':
  608.                     *lang_type = MMI_CBS2_FJ;
  609.                     break;
  610.                 case 'o':
  611.                     *lang_type = MMI_CBS2_FO;
  612.                     break;
  613.                 case 'r':
  614.                     *lang_type = MMI_CBS2_FR;
  615.                     break;
  616.                 case 'y':
  617.                     *lang_type = MMI_CBS2_FY;
  618.                     break;
  619.             }
  620.             break;
  621.         case 'g':
  622.             switch (char2)
  623.             {
  624.                 case 'a':
  625.                     *lang_type = MMI_CBS2_GA;
  626.                     break;
  627.                 case 'd':
  628.                     *lang_type = MMI_CBS2_GD;
  629.                     break;
  630.                 case 'l':
  631.                     *lang_type = MMI_CBS2_GL;
  632.                     break;
  633.                 case 'n':
  634.                     *lang_type = MMI_CBS2_GN;
  635.                     break;
  636.                 case 'u':
  637.                     *lang_type = MMI_CBS2_GU;
  638.                     break;
  639.             }
  640.             break;
  641.         case 'h':
  642.             switch (char2)
  643.             {
  644.                 case 'a':
  645.                     *lang_type = MMI_CBS2_HA;
  646.                     break;
  647.                 case 'e':
  648.                     *lang_type = MMI_CBS2_HE;
  649.                     break;
  650.                 case 'i':
  651.                     *lang_type = MMI_CBS2_HI;
  652.                     break;
  653.                 case 'r':
  654.                     *lang_type = MMI_CBS2_HR;
  655.                     break;
  656.                 case 'u':
  657.                     *lang_type = MMI_CBS2_HU;
  658.                     break;
  659.                 case 'y':
  660.                     *lang_type = MMI_CBS2_HY;
  661.                     break;
  662.             }
  663.             break;
  664.         case 'i':
  665.             switch (char2)
  666.             {
  667.                 case 'a':
  668.                     *lang_type = MMI_CBS2_IA;
  669.                     break;
  670.                 case 'd':
  671.                     *lang_type = MMI_CBS2_ID;
  672.                     break;
  673.                 case 'e':
  674.                     *lang_type = MMI_CBS2_IE;
  675.                     break;
  676.                 case 'k':
  677.                     *lang_type = MMI_CBS2_IK;
  678.                     break;
  679.                 case 's':
  680.                     *lang_type = MMI_CBS2_IS;
  681.                     break;
  682.                 case 't':
  683.                     *lang_type = MMI_CBS2_IT;
  684.                     break;
  685.                 case 'u':
  686.                     *lang_type = MMI_CBS2_IU;
  687.                     break;
  688.             }
  689.             break;
  690.         case 'j':
  691.             switch (char2)
  692.             {
  693.                 case 'a':
  694.                     *lang_type = MMI_CBS2_JA;
  695.                     break;
  696.                 case 'w':
  697.                     *lang_type = MMI_CBS2_JW;
  698.                     break;
  699.             }
  700.             break;
  701.         case 'k':
  702.             switch (char2)
  703.             {
  704.                 case 'a':
  705.                     *lang_type = MMI_CBS2_KA;
  706.                     break;
  707.                 case 'k':
  708.                     *lang_type = MMI_CBS2_KK;
  709.                     break;
  710.                 case 'l':
  711.                     *lang_type = MMI_CBS2_KL;
  712.                     break;
  713.                 case 'm':
  714.                     *lang_type = MMI_CBS2_KM;
  715.                     break;
  716.                 case 'n':
  717.                     *lang_type = MMI_CBS2_KN;
  718.                     break;
  719.                 case 'o':
  720.                     *lang_type = MMI_CBS2_KO;
  721.                     break;
  722.                 case 's':
  723.                     *lang_type = MMI_CBS2_KS;
  724.                     break;
  725.                 case 'u':
  726.                     *lang_type = MMI_CBS2_KU;
  727.                     break;
  728.                 case 'y':
  729.                     *lang_type = MMI_CBS2_KY;
  730.                     break;
  731.             }
  732.             break;
  733.         case 'l':
  734.             switch (char2)
  735.             {
  736.                 case 'a':
  737.                     *lang_type = MMI_CBS2_LA;
  738.                     break;
  739.                 case 'n':
  740.                     *lang_type = MMI_CBS2_LN;
  741.                     break;
  742.                 case 'o':
  743.                     *lang_type = MMI_CBS2_LO;
  744.                     break;
  745.                 case 't':
  746.                     *lang_type = MMI_CBS2_LT;
  747.                     break;
  748.                 case 'v':
  749.                     *lang_type = MMI_CBS2_LV;
  750.                     break;
  751.             }
  752.             break;
  753.         case 'm':
  754.             switch (char2)
  755.             {
  756.                 case 'g':
  757.                     *lang_type = MMI_CBS2_MG;
  758.                     break;
  759.                 case 'i':
  760.                     *lang_type = MMI_CBS2_MI;
  761.                     break;
  762.                 case 'k':
  763.                     *lang_type = MMI_CBS2_MK;
  764.                     break;
  765.                 case 'l':
  766.                     *lang_type = MMI_CBS2_ML;
  767.                     break;
  768.                 case 'n':
  769.                     *lang_type = MMI_CBS2_MN;
  770.                     break;
  771.                 case 'o':
  772.                     *lang_type = MMI_CBS2_MO;
  773.                     break;
  774.                 case 'r':
  775.                     *lang_type = MMI_CBS2_MR;
  776.                     break;
  777.                 case 's':
  778.                     *lang_type = MMI_CBS2_MS;
  779.                     break;
  780.                 case 't':
  781.                     *lang_type = MMI_CBS2_MT;
  782.                     break;
  783.                 case 'y':
  784.                     *lang_type = MMI_CBS2_MY;
  785.                     break;
  786.             }
  787.             break;
  788.         case 'n':
  789.             switch (char2)
  790.             {
  791.                 case 'a':
  792.                     *lang_type = MMI_CBS2_NA;
  793.                     break;
  794.                 case 'e':
  795.                     *lang_type = MMI_CBS2_NE;
  796.                     break;
  797.                 case 'l':
  798.                     *lang_type = MMI_CBS2_NL;
  799.                     break;
  800.                 case 'o':
  801.                     *lang_type = MMI_CBS2_NO;
  802.                     break;
  803.             }
  804.             break;
  805.         case 'o':
  806.             switch (char2)
  807.             {
  808.                 case 'c':
  809.                     *lang_type = MMI_CBS2_OC;
  810.                     break;
  811.                 case 'm':
  812.                     *lang_type = MMI_CBS2_OM;
  813.                     break;
  814.                 case 'r':
  815.                     *lang_type = MMI_CBS2_OR;
  816.                     break;
  817.             }
  818.             break;
  819.         case 'p':
  820.             switch (char2)
  821.             {
  822.                 case 'a':
  823.                     *lang_type = MMI_CBS2_PA;
  824.                     break;
  825.                 case 'l':
  826.                     *lang_type = MMI_CBS2_PL;
  827.                     break;
  828.                 case 's':
  829.                     *lang_type = MMI_CBS2_PS;
  830.                     break;
  831.                 case 't':
  832.                     *lang_type = MMI_CBS2_PT;
  833.                     break;
  834.             }
  835.             break;
  836.         case 'q':
  837.             switch (char2)
  838.             {
  839.                 case 'u':
  840.                     *lang_type = MMI_CBS2_QU;
  841.                     break;
  842.             }
  843.             break;
  844.         case 'r':
  845.             switch (char2)
  846.             {
  847.                 case 'm':
  848.                     *lang_type = MMI_CBS2_RM;
  849.                     break;
  850.                 case 'n':
  851.                     *lang_type = MMI_CBS2_RN;
  852.                     break;
  853.                 case 'o':
  854.                     *lang_type = MMI_CBS2_RO;
  855.                     break;
  856.                 case 'u':
  857.                     *lang_type = MMI_CBS2_RU;
  858.                     break;
  859.                 case 'w':
  860.                     *lang_type = MMI_CBS2_RW;
  861.                     break;
  862.             }
  863.             break;
  864.         case 's':
  865.             switch (char2)
  866.             {
  867.                 case 'a':
  868.                     *lang_type = MMI_CBS2_SA;
  869.                     break;
  870.                 case 'd':
  871.                     *lang_type = MMI_CBS2_SD;
  872.                     break;
  873.                 case 'g':
  874.                     *lang_type = MMI_CBS2_SG;
  875.                     break;
  876.                 case 'h':
  877.                     *lang_type = MMI_CBS2_SH;
  878.                     break;
  879.                 case 'i':
  880.                     *lang_type = MMI_CBS2_SI;
  881.                     break;
  882.                 case 'k':
  883.                     *lang_type = MMI_CBS2_SK;
  884.                     break;
  885.                 case 'l':
  886.                     *lang_type = MMI_CBS2_SL;
  887.                     break;
  888.                 case 'm':
  889.                     *lang_type = MMI_CBS2_SM;
  890.                     break;
  891.                 case 'n':
  892.                     *lang_type = MMI_CBS2_SN;
  893.                     break;
  894.                 case 'o':
  895.                     *lang_type = MMI_CBS2_SO;
  896.                     break;
  897.                 case 'q':
  898.                     *lang_type = MMI_CBS2_SQ;
  899.                     break;
  900.                 case 'r':
  901.                     *lang_type = MMI_CBS2_SR;
  902.                     break;
  903.                 case 's':
  904.                     *lang_type = MMI_CBS2_SS;
  905.                     break;
  906.                 case 't':
  907.                     *lang_type = MMI_CBS2_ST;
  908.                     break;
  909.                 case 'u':
  910.                     *lang_type = MMI_CBS2_SU;
  911.                     break;
  912.                 case 'v':
  913.                     *lang_type = MMI_CBS2_SV;
  914.                     break;
  915.                 case 'w':
  916.                     *lang_type = MMI_CBS2_SW;
  917.                     break;
  918.             }
  919.             break;
  920.         case 't':
  921.             switch (char2)
  922.             {
  923.                 case 'a':
  924.                     *lang_type = MMI_CBS2_TA;
  925.                     break;
  926.                 case 'e':
  927.                     *lang_type = MMI_CBS2_TE;
  928.                     break;
  929.                 case 'g':
  930.                     *lang_type = MMI_CBS2_TG;
  931.                     break;
  932.                 case 'h':
  933.                     *lang_type = MMI_CBS2_TH;
  934.                     break;
  935.                 case 'i':
  936.                     *lang_type = MMI_CBS2_TI;
  937.                     break;
  938.                 case 'k':
  939.                     *lang_type = MMI_CBS2_TK;
  940.                     break;
  941.                 case 'l':
  942.                     *lang_type = MMI_CBS2_TL;
  943.                     break;
  944.                 case 'n':
  945.                     *lang_type = MMI_CBS2_TN;
  946.                     break;
  947.                 case 'o':
  948.                     *lang_type = MMI_CBS2_TO;
  949.                     break;
  950.                 case 'r':
  951.                     *lang_type = MMI_CBS2_TR;
  952.                     break;
  953.                 case 's':
  954.                     *lang_type = MMI_CBS2_TS;
  955.                     break;
  956.                 case 't':
  957.                     *lang_type = MMI_CBS2_TT;
  958.                     break;
  959.                 case 'w':
  960.                     *lang_type = MMI_CBS2_TW;
  961.                     break;
  962.             }
  963.             break;
  964.         case 'u':
  965.             switch (char2)
  966.             {
  967.                 case 'g':
  968.                     *lang_type = MMI_CBS2_UG;
  969.                     break;
  970.                 case 'k':
  971.                     *lang_type = MMI_CBS2_UK;
  972.                     break;
  973.                 case 'r':
  974.                     *lang_type = MMI_CBS2_UR;
  975.                     break;
  976.                 case 'z':
  977.                     *lang_type = MMI_CBS2_UZ;
  978.                     break;
  979.             }
  980.             break;
  981.         case 'v':
  982.             switch (char2)
  983.             {
  984.                 case 'i':
  985.                     *lang_type = MMI_CBS2_VI;
  986.                     break;
  987.                 case 'o':
  988.                     *lang_type = MMI_CBS2_VO;
  989.                     break;
  990.             }
  991.             break;
  992.         case 'w':
  993.             switch (char2)
  994.             {
  995.                 case 'o':
  996.                     *lang_type = MMI_CBS2_WO;
  997.                     break;
  998.             }
  999.             break;
  1000.         case 'x':
  1001.             switch (char2)
  1002.             {
  1003.                 case 'h':
  1004.                     *lang_type = MMI_CBS2_XH;
  1005.                     break;
  1006.             }
  1007.             break;
  1008.         case 'y':
  1009.             switch (char2)
  1010.             {
  1011.                 case 'i':
  1012.                     *lang_type = MMI_CBS2_YI;
  1013.                     break;
  1014.                 case 'o':
  1015.                     *lang_type = MMI_CBS2_YO;
  1016.                     break;
  1017.             }
  1018.             break;
  1019.         case 'z':
  1020.             switch (char2)
  1021.             {
  1022.                 case 'a':
  1023.                     *lang_type = MMI_CBS2_ZA;
  1024.                     break;
  1025.                 case 'h':
  1026.                     *lang_type = MMI_CBS2_ZH;
  1027.                     break;
  1028.                 case 'u':
  1029.                     *lang_type = MMI_CBS2_ZU;
  1030.                     break;
  1031.             }
  1032.             break;
  1033.     }
  1034. }
  1035. /*****************************************************************************
  1036.  * FUNCTION
  1037.  *  DecodeCbsDcs
  1038.  * DESCRIPTION
  1039.  *  Decode Cb DCS
  1040.  * PARAMETERS
  1041.  *  dcs                 [IN]            DCS
  1042.  *  char1               [IN]            Char 1
  1043.  *  char2               [IN]            Char 2
  1044.  *  char3               [IN]            Char 3
  1045.  *  lang_type           [IN/OUT]        Language type
  1046.  *  alphabet_type       [IN/OUT]        Alphabet type
  1047.  *  msg_class           [IN/OUT]        Message class
  1048.  *  is_compress         [IN/OUT]        Is compress
  1049.  *  is_reserved         [IN/OUT]        Is reserved
  1050.  * RETURNS
  1051.  *  skip character
  1052.  *****************************************************************************/
  1053. U8 DecodeCbsDcs(
  1054.     U8 dcs,
  1055.     U8 char1,
  1056.     U8 char2,
  1057.     U8 char3,
  1058.     msg_cb_lang_enum *lang_type,
  1059.     smsal_dcs_enum *alphabet_type,
  1060.     msg_cb_class_enum *msg_class,
  1061.     pBOOL *is_compress,
  1062.     pBOOL *is_reserved)
  1063. {
  1064.     /*----------------------------------------------------------------*/
  1065.     /* Local Variables                                                */
  1066.     /*----------------------------------------------------------------*/
  1067.     kal_uint8 coding_group = (dcs >> 4);
  1068.     kal_uint8 coding_bits = (dcs & 0x0f);
  1069.     kal_uint8 skip_char = 0;
  1070.     /*----------------------------------------------------------------*/
  1071.     /* Code Body                                                      */
  1072.     /*----------------------------------------------------------------*/
  1073.     *lang_type = MMI_CBS0_LANG_UNSPECIFIED;
  1074.     *alphabet_type = SMSAL_DEFAULT_DCS;
  1075.     *msg_class = MMI_CBS_CLASS_UNSPECIFIED;
  1076.     *is_compress = KAL_FALSE;
  1077.     *is_reserved = KAL_FALSE;
  1078.     switch (coding_group)
  1079.     {
  1080.         case 0x00:
  1081.             *lang_type = (msg_cb_lang_enum) coding_bits;
  1082.             break;
  1083.         case 0x01:
  1084.             /* 
  1085.              * GSM7: PS side already unpack 
  1086.              * UCS2: PS side didn't unpack 
  1087.              */
  1088.             if (coding_bits == 0)   /* GSM7 */
  1089.             {
  1090.                 if (char3 == 0x0d)  /* CR */
  1091.                 {
  1092.                     MMICbsDecodeLang(char1, char2, lang_type);
  1093.                     skip_char = 3;
  1094.                 }
  1095.             }
  1096.             else if (coding_bits == 1)  /* UCS2 */
  1097.             {
  1098.                 *alphabet_type = SMSAL_UCS2_DCS;
  1099.                 MMICbsDecodeLang((U8) (char1 & 0x7f), (U8) (((char2 & 0x3f) << 1) | ((char1 & 0x80) >> 7)), lang_type);
  1100.                 skip_char = 2;
  1101.             }
  1102.             /* MTK end */
  1103.             else
  1104.             {
  1105.                 *is_reserved = KAL_TRUE;
  1106.             }
  1107.             break;
  1108.         case 0x02:
  1109.             if (coding_bits < 0x04)
  1110.             {
  1111.                 *lang_type = (msg_cb_lang_enum) (16 + coding_bits);
  1112.             }
  1113.             else
  1114.             {
  1115.                 *is_reserved = KAL_TRUE;
  1116.             }
  1117.             break;
  1118.         case 0x03:
  1119.             *is_reserved = KAL_TRUE;
  1120.             break;
  1121.         case 0x04:  /* General Data Coding Scheme */
  1122.         case 0x05:
  1123.         case 0x06:
  1124.         case 0x07:
  1125.             if ((coding_group & 0x02) != 0)
  1126.             {
  1127.                 *is_compress = KAL_TRUE;
  1128.             }
  1129.             if ((coding_group & 0x01) == 0x01)
  1130.             {
  1131.                 *msg_class = (msg_cb_class_enum) (dcs & 0x03);
  1132.             }
  1133.             *alphabet_type = (smsal_dcs_enum) (dcs & 0x0C);
  1134.             break;
  1135.         case 0x08:  /* 0x08 - 0x0d: Reserved */
  1136.         case 0x09:
  1137.         case 0x0a:
  1138.         case 0x0b:
  1139.         case 0x0c:
  1140.         case 0x0d:
  1141.             *is_reserved = KAL_TRUE;
  1142.             break;
  1143.         case 0x0e:  /* defined by WAP forum */
  1144.             break;
  1145.         case 0x0f:  /* Data Coding/Message Class */
  1146.             *alphabet_type = (smsal_dcs_enum) (dcs & 0x04);
  1147.             *msg_class = (msg_cb_class_enum) (dcs & 0x03);
  1148.             break;
  1149.         default:
  1150.             break;
  1151.     }
  1152.     return skip_char;
  1153. }   /* end of DecodeCbsDcs */
  1154. /*****************************************************************************
  1155.  * FUNCTION
  1156.  *  DeleteCBMessage
  1157.  * DESCRIPTION
  1158.  *  Delete CB message
  1159.  * PARAMETERS
  1160.  *  index       [IN]        Index
  1161.  * RETURNS
  1162.  *  delete length
  1163.  *****************************************************************************/
  1164. U8 DeleteCBMessage(S32 index)
  1165. {
  1166.     /*----------------------------------------------------------------*/
  1167.     /* Local Variables                                                */
  1168.     /*----------------------------------------------------------------*/
  1169.     S32 i = 0;
  1170.     U8 deleteLen = cbMsgInfo.MsgPage[index];
  1171.     /*----------------------------------------------------------------*/
  1172.     /* Code Body                                                      */
  1173.     /*----------------------------------------------------------------*/
  1174.     /* first, clear the content */
  1175.     memset(cbMsgIndex.pCBMsgContent[index], 0, cbMsgInfo.MsgPage[index] * NVRAM_SMS_CB_SMS_PAGE_SIZE);
  1176.     /* second, reset the info */
  1177.     cbMsgInfo.MsgDCS[index] = 0;
  1178.     cbMsgInfo.MsgPage[index] = 0;
  1179.     /* MTK Joy 0222 */
  1180.     cbMsgInfo.MsgMI[index] = SMS_CB_UNUSED_CBMI;
  1181.     //MTK end
  1182.     //third, compute the new index
  1183.     cbMsgIndex.currCBTotal--;
  1184.     /* forth, move the content and update the info */
  1185.     if (index < (cbMsgIndex.currCBTotal))
  1186.     {
  1187.         for (i = index; i < (cbMsgIndex.currCBTotal); i++)
  1188.         {
  1189.             memcpy(
  1190.                 cbMsgIndex.pCBMsgContent[i],
  1191.                 cbMsgIndex.pCBMsgContent[i + 1],
  1192.                 cbMsgInfo.MsgPage[i + 1] * NVRAM_SMS_CB_SMS_PAGE_SIZE);
  1193.             cbMsgInfo.MsgDCS[i] = cbMsgInfo.MsgDCS[i + 1];
  1194.             cbMsgInfo.MsgPage[i] = cbMsgInfo.MsgPage[i + 1];
  1195.             /* MTK Joy 0222 */
  1196.             cbMsgInfo.MsgMI[i] = cbMsgInfo.MsgMI[i + 1];
  1197.             /* MTK end */
  1198.             cbMsgIndex.pCBMsgContent[i + 1] =
  1199.                 cbMsgIndex.pCBMsgContent[i] + (cbMsgInfo.MsgPage[i] * NVRAM_SMS_CB_SMS_PAGE_SIZE);
  1200.         }
  1201.     }
  1202.     /* fifth, clear the endings */
  1203.     cbMsgIndex.pCBMsgContent[cbMsgIndex.currCBTotal] = NULL;
  1204.     cbMsgInfo.MsgDCS[cbMsgIndex.currCBTotal] = 0;
  1205.     cbMsgInfo.MsgPage[cbMsgIndex.currCBTotal] = 0;
  1206.     /* MTK Joy 0222 */
  1207.     cbMsgInfo.MsgMI[cbMsgIndex.currCBTotal] = SMS_CB_UNUSED_CBMI;
  1208.     /* MTK end */
  1209.     if (cbMsgIndex.currCBTotal == 0)
  1210.     {
  1211.         cbMsgIndex.pCBMsgTail = (U8*) cbMsgContent[0];
  1212.     }
  1213.     else if (cbMsgIndex.currCBTotal < MAX_STORE_CB_MSG)
  1214.     {
  1215.         cbMsgIndex.pCBMsgTail =
  1216.             cbMsgIndex.pCBMsgContent[cbMsgIndex.currCBTotal - 1] + cbMsgInfo.MsgPage[cbMsgIndex.currCBTotal -
  1217.                                                                                      1] * NVRAM_SMS_CB_SMS_PAGE_SIZE;
  1218.     }
  1219.     else
  1220.     {
  1221.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] DeleteCBMessage: total number error ---*n"));
  1222.         cbMsgIndex.pCBMsgTail = NULL;
  1223.         return 0;
  1224.     }
  1225.     memset(cbMsgIndex.pCBMsgTail, 0, deleteLen * NVRAM_SMS_CB_SMS_PAGE_SIZE);
  1226.     return deleteLen;
  1227. }
  1228. /*****************************************************************************
  1229.  * FUNCTION
  1230.  *  AddCBMessage
  1231.  * DESCRIPTION
  1232.  *  Add CB message to storage buffer
  1233.  * PARAMETERS
  1234.  *  cbMI            [IN]        Cbmi
  1235.  *  cbDCS           [IN]        Cb DCS
  1236.  *  cbPage          [IN]        Cb page number
  1237.  *  cbMsg           [IN]        Cb message pointer
  1238.  *  totalLen        [IN]        Cb message length
  1239.  * RETURNS
  1240.  *  void
  1241.  *****************************************************************************/
  1242. void AddCBMessage(U16 cbMI, U8 cbDCS, U8 cbPage, PU8 cbMsg, U16 totalLen)
  1243. {
  1244.     /*----------------------------------------------------------------*/
  1245.     /* Local Variables                                                */
  1246.     /*----------------------------------------------------------------*/
  1247.     msg_cb_lang_enum langType;
  1248.     smsal_dcs_enum alphabetType;
  1249.     msg_cb_class_enum msgClass;
  1250.     pBOOL isCompress;
  1251.     pBOOL isReserved;
  1252.     /*----------------------------------------------------------------*/
  1253.     /* Code Body                                                      */
  1254.     /*----------------------------------------------------------------*/
  1255.     if ((cbMsgIndex.pCBMsgTail == NULL) ||
  1256.         ((cbMsgIndex.pCBMsgTail) > ((cbMsgStart) + NVRAM_SMS_CB_SMS_PAGE_SIZE * NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL)))
  1257.     {
  1258.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] AddCBMessage: tail address error ---*n"));
  1259.     }
  1260.     else
  1261.     {
  1262.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] AddCBMessage: tail address ok = %d---*n",
  1263.                              cbMsgIndex.pCBMsgTail));
  1264.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] AddCBMessage: currCBTotal = %d",
  1265.                              cbMsgIndex.currCBTotal));
  1266.         cbMsgIndex.currCBTotal++;
  1267.         cbMsgIndex.pCBMsgContent[cbMsgIndex.currCBTotal - 1] = cbMsgIndex.pCBMsgTail;
  1268.         memcpy(cbMsgIndex.pCBMsgContent[cbMsgIndex.currCBTotal - 1], cbMsg, totalLen);
  1269.         DecodeCbsDcs(
  1270.             cbDCS,
  1271.             cbMsg[0],
  1272.             cbMsg[1],
  1273.             cbMsg[2],
  1274.             &langType,
  1275.             &alphabetType,
  1276.             &msgClass,
  1277.             &isCompress,
  1278.             &isReserved);
  1279.         switch (alphabetType)
  1280.         {
  1281.             case SMSAL_DEFAULT_DCS:
  1282.             case SMSAL_RESERVED_DCS:
  1283.                 memset(
  1284.                     cbMsgIndex.pCBMsgContent[cbMsgIndex.currCBTotal - 1] + totalLen,
  1285.                     0x20,
  1286.                     cbPage * NVRAM_SMS_CB_SMS_PAGE_SIZE - totalLen);
  1287.                 break;
  1288.             case SMSAL_8BIT_DCS:
  1289.             case SMSAL_UCS2_DCS:
  1290.                 memset(
  1291.                     cbMsgIndex.pCBMsgContent[cbMsgIndex.currCBTotal - 1] + totalLen,
  1292.                     0x00,
  1293.                     cbPage * NVRAM_SMS_CB_SMS_PAGE_SIZE - totalLen);
  1294.                 break;
  1295.         }
  1296.         cbMsgInfo.MsgDCS[cbMsgIndex.currCBTotal - 1] = cbDCS;
  1297.         cbMsgInfo.MsgPage[cbMsgIndex.currCBTotal - 1] = cbPage;
  1298.         /* MTK Joy 0222 */
  1299.         cbMsgInfo.MsgMI[cbMsgIndex.currCBTotal - 1] = cbMI;
  1300.         /* MTK end */
  1301.         if (((cbMsgIndex.pCBMsgTail) + cbPage * NVRAM_SMS_CB_SMS_PAGE_SIZE) <
  1302.             ((cbMsgStart) + NVRAM_SMS_CB_SMS_PAGE_SIZE * NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL))
  1303.         {
  1304.             (cbMsgIndex.pCBMsgTail) += (cbPage * NVRAM_SMS_CB_SMS_PAGE_SIZE);
  1305.         }
  1306.         else
  1307.         {
  1308.             cbMsgIndex.pCBMsgTail = NULL;
  1309.         }
  1310.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] AddCBMessage: tail address ok = %d---*n",
  1311.                              cbMsgIndex.pCBMsgTail));
  1312.     }
  1313. }
  1314. /*****************************************************************************
  1315.  * FUNCTION
  1316.  *  ReadCbChnlInfoFromNvram
  1317.  * DESCRIPTION
  1318.  *  Read CB channel info from NVRAM, to be removed after L4 provide interface
  1319.  * PARAMETERS
  1320.  *  void
  1321.  * RETURNS
  1322.  *  void
  1323.  *****************************************************************************/
  1324. void ReadCbChnlInfoFromNvram(void)
  1325. {
  1326.     /*----------------------------------------------------------------*/
  1327.     /* Local Variables                                                */
  1328.     /*----------------------------------------------------------------*/
  1329.     S16 error = 0;
  1330.     /*----------------------------------------------------------------*/
  1331.     /* Code Body                                                      */
  1332.     /*----------------------------------------------------------------*/
  1333.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] ReadCbChnlInfoFromNvram ---*n"));
  1334.     if (ReadRecord(NVRAM_EF_SMS_CB_CHNL_LID, 1, &cbNvramStruct, NVRAM_SMS_CB_CHNL_RECORD_SIZE, &error) < 0)
  1335.     {
  1336.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] ResetCBInfoStructs-failed ---*n"));
  1337.     }
  1338. }
  1339. /*****************************************************************************
  1340.  * FUNCTION
  1341.  *  WriteCbChnlInfoToNvram
  1342.  * DESCRIPTION
  1343.  *  Write CB channel info to NVRAM
  1344.  * PARAMETERS
  1345.  *  void
  1346.  * RETURNS
  1347.  *  void
  1348.  *****************************************************************************/
  1349. void WriteCbChnlInfoToNvram(void)
  1350. {
  1351.     /*----------------------------------------------------------------*/
  1352.     /* Local Variables                                                */
  1353.     /*----------------------------------------------------------------*/
  1354.     S16 error = 0;
  1355.     /*----------------------------------------------------------------*/
  1356.     /* Code Body                                                      */
  1357.     /*----------------------------------------------------------------*/
  1358.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] WriteCbChnlInfoToNvram ---*n"));
  1359.     if (WriteRecord(NVRAM_EF_SMS_CB_CHNL_LID, 1, &cbNvramStruct, NVRAM_SMS_CB_CHNL_RECORD_SIZE, &error) !=
  1360.         NVRAM_SMS_CB_CHNL_RECORD_SIZE)
  1361.     {
  1362.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] WriteCbChnlInfoToNvram-: failed (ecode%d) ---*n",
  1363.                              (int)error));
  1364.     }
  1365. }
  1366. /*****************************************************************************
  1367.  * FUNCTION
  1368.  *  ReadCBMessageInfoFromNvram
  1369.  * DESCRIPTION
  1370.  *  Read CB Message info from NVRAM
  1371.  * PARAMETERS
  1372.  *  void
  1373.  * RETURNS
  1374.  *  void
  1375.  *****************************************************************************/
  1376. void ReadCBMessageInfoFromNvram(void)
  1377. {
  1378.     /*----------------------------------------------------------------*/
  1379.     /* Local Variables                                                */
  1380.     /*----------------------------------------------------------------*/
  1381.     S16 error = 0;
  1382.     U16 cbTotalLen = 0;
  1383.     S8 i = 0, j = 0;
  1384.     S8 readBase = 0;
  1385.     /*----------------------------------------------------------------*/
  1386.     /* Code Body                                                      */
  1387.     /*----------------------------------------------------------------*/
  1388.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] ReadCBMessageInfoFromNvram ---*n"));
  1389.     if (ReadRecord(NVRAM_EF_SMS_CB_SMS_INFO_LID, 1, &cbMsgInfo, NVRAM_SMS_CB_SMS_INFO_SIZE, &error) < 0)
  1390.     {
  1391.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] ReadCBMessageInfoFromNvram-(code=%d) ---*n",
  1392.                              (int)error));
  1393.     }
  1394.     cbMsgStart = (U8*) cbMsgContent[0];
  1395.     for (i = 0; i < MAX_STORE_CB_MSG; i++)
  1396.     {
  1397.         if (cbMsgInfo.MsgPage[i] == 0)
  1398.         {
  1399.             break;
  1400.         }
  1401.         for (j = readBase; (j < (readBase + cbMsgInfo.MsgPage[i])) && (j < NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL); j++)
  1402.         {
  1403.             U16 index = (U16) j + 1;
  1404.             if (ReadRecord(NVRAM_EF_SMS_CB_SMS_LID, index, cbMsgContent[j], NVRAM_SMS_CB_SMS_PAGE_SIZE, &error) < 0)
  1405.             {
  1406.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1407.                                      "*---[CellBroadcast.c] ReadCBMessageInfoFromNvram-(code=%d) ---*n", (int)error));
  1408.             }
  1409.         }
  1410.         cbMsgIndex.pCBMsgContent[i] = cbMsgStart + cbTotalLen;
  1411.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] ReadCBMessageInfoFromNvram-address=%d ---*n",
  1412.                              cbMsgIndex.pCBMsgContent[i]));
  1413.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] CB[%d] dcs=%d page=%d", i, cbMsgInfo.MsgDCS[i],
  1414.                              cbMsgInfo.MsgPage[i]));
  1415.         cbTotalLen += (U16) (cbMsgInfo.MsgPage[i] * NVRAM_SMS_CB_SMS_PAGE_SIZE);
  1416.         readBase = readBase + (S8) cbMsgInfo.MsgPage[i];
  1417.     }
  1418.     cbMsgIndex.currCBTotal = i;
  1419.     if (cbTotalLen == NVRAM_SMS_CB_SMS_PAGE_SIZE * NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL)
  1420.     {
  1421.         cbMsgIndex.pCBMsgTail = NULL;
  1422.     }
  1423.     else
  1424.     {
  1425.         cbMsgIndex.pCBMsgTail = cbMsgStart + cbTotalLen;
  1426.     }
  1427. }
  1428. /*****************************************************************************
  1429.  * FUNCTION
  1430.  *  WriteCBMessageInfoToNvram
  1431.  * DESCRIPTION
  1432.  *  Write CB message info to NVRAM
  1433.  * PARAMETERS
  1434.  *  void
  1435.  * RETURNS
  1436.  *  void
  1437.  *****************************************************************************/
  1438. void WriteCBMessageInfoToNvram(void)
  1439. {
  1440.     /*----------------------------------------------------------------*/
  1441.     /* Local Variables                                                */
  1442.     /*----------------------------------------------------------------*/
  1443.     S8 i = 0, j = 0;
  1444.     S8 writeBase = 0;
  1445.     S16 error = 0;
  1446.     /*----------------------------------------------------------------*/
  1447.     /* Code Body                                                      */
  1448.     /*----------------------------------------------------------------*/
  1449.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] cbmsgaddress=%d", &cbMsgInfo));
  1450.     if (WriteRecord(NVRAM_EF_SMS_CB_SMS_INFO_LID, 1, &cbMsgInfo, NVRAM_SMS_CB_SMS_INFO_SIZE, &error) !=
  1451.         NVRAM_SMS_CB_SMS_INFO_SIZE)
  1452.     {
  1453.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] WriteCBMessageInfoFromNvram-(code=%d) ---*n",
  1454.                              (int)error));
  1455.     }
  1456.     for (i = 0; i < MAX_STORE_CB_MSG; i++)
  1457.     {
  1458.         if (cbMsgInfo.MsgPage[i] == 0)
  1459.         {
  1460.             break;
  1461.         }
  1462.         for (j = writeBase; (j < (writeBase + cbMsgInfo.MsgPage[i])) && (j < NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL); j++)
  1463.         {
  1464.             U16 index = (U16) j + 1;
  1465.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] cbmsgcontent=%d", cbMsgContent[i]));
  1466.             if (WriteRecord(NVRAM_EF_SMS_CB_SMS_LID, index, cbMsgContent[j], NVRAM_SMS_CB_SMS_PAGE_SIZE, &error) !=
  1467.                 NVRAM_SMS_CB_SMS_PAGE_SIZE)
  1468.             {
  1469.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1470.                                      "*---[CellBroadcast.c] WriteCBMessageInfoFromNvram-(code=%d) ---*n", (int)error));
  1471.             }
  1472.         }
  1473.         writeBase = writeBase + (S8) cbMsgInfo.MsgPage[i];
  1474.     }
  1475. }
  1476. /*****************************************************************************
  1477.  * FUNCTION
  1478.  *  ConvertCBForDisplay
  1479.  * DESCRIPTION
  1480.  *  Convert CB message for display, according to its DCS
  1481.  * PARAMETERS
  1482.  *  data        [IN]            Message data
  1483.  *  len         [IN]            Message length
  1484.  *  format      [IN]            Message format
  1485.  *  outLen      [IN/OUT]        Message output length
  1486.  * RETURNS
  1487.  *  void
  1488.  *****************************************************************************/
  1489. void ConvertCBForDisplay(U8 *data, U16 len, U8 format, U32 *outLen)
  1490. {
  1491.     /*----------------------------------------------------------------*/
  1492.     /* Local Variables                                                */
  1493.     /*----------------------------------------------------------------*/
  1494.     U16 outLength;
  1495.     /*----------------------------------------------------------------*/
  1496.     /* Code Body                                                      */
  1497.     /*----------------------------------------------------------------*/
  1498.     if (len > 0)
  1499.     {
  1500.         switch (format)
  1501.         {
  1502.             case (MMI_DEFAULT_DCS):
  1503.             {
  1504.                 U8 *tempData;
  1505.                 tempData = OslMalloc(len);;
  1506.                 ConvertGSM7BitDefaultEncodingToAscii(tempData, data, len, &outLength);
  1507.                 AnsiiNToUnicodeString((PS8) dispCBMessage, (PS8) tempData, outLength);
  1508.                 memset((void*)&dispCBMessage[outLength * ENCODING_LENGTH], 0, ENCODING_LENGTH);
  1509.                 OslMfree(tempData);
  1510.                 if (outLen != NULL)
  1511.                 {
  1512.                     *outLen = (U32) outLength *ENCODING_LENGTH + ENCODING_LENGTH;
  1513.                 }
  1514.             }
  1515.                 break;
  1516.             case (MMI_8BIT_DCS):
  1517.                 AnsiiNToUnicodeString((PS8) dispCBMessage, (PS8) data, len);
  1518.                 memset((void*)&dispCBMessage[len * ENCODING_LENGTH], 0, ENCODING_LENGTH);
  1519.                 if (outLen != NULL)
  1520.                 {
  1521.                     *outLen = len * ENCODING_LENGTH + ENCODING_LENGTH;
  1522.                 }
  1523.                 break;
  1524.             case (MMI_UCS2_DCS):
  1525.                 memset((void*)dispCBMessage, 0, len + 1 + ENCODING_LENGTH);
  1526.                 memcpy(dispCBMessage, data, len);
  1527.                 if (outLen != NULL)
  1528.                 {
  1529.                     *outLen = len + ENCODING_LENGTH;
  1530.                 }
  1531.             #ifdef MMI_ON_HARDWARE_P
  1532.                 {
  1533.                     U16 *tempData;
  1534.                     int i;
  1535.                     tempData = (U16*) dispCBMessage;
  1536.                     for (i = 0; i < len; i += 2)
  1537.                     {
  1538.                         SWAP_USHORT(tempData);
  1539.                         tempData++;
  1540.                     }
  1541.                 }
  1542.             #endif /* MMI_ON_HARDWARE_P */ 
  1543.                 break;
  1544.         }
  1545.         return;
  1546.     }
  1547.     else
  1548.     {
  1549.         memset((void*)dispCBMessage, 0, ENCODING_LENGTH);
  1550.         if (outLen != NULL)
  1551.         {
  1552.             *outLen = ENCODING_LENGTH;
  1553.         }
  1554.         return;
  1555.     }
  1556. }
  1557. /*****************************************************************************
  1558.  * FUNCTION
  1559.  *  ReadCBMessageContent
  1560.  * DESCRIPTION
  1561.  *  Read CB message content for dislpay
  1562.  * PARAMETERS
  1563.  *  outLen          [IN/OUT]        Output length
  1564.  *  msgData         [IN]            Message data
  1565.  *  msgLength       [IN]            Message length
  1566.  *  dcs             [IN]            Message DCS
  1567.  * RETURNS
  1568.  *  void
  1569.  *****************************************************************************/
  1570. void ReadCBMessageContent(PU32 outLen, PU8 msgData, U16 msgLength, U8 dcs)
  1571. {
  1572.     /*----------------------------------------------------------------*/
  1573.     /* Local Variables                                                */
  1574.     /*----------------------------------------------------------------*/
  1575.     msg_cb_lang_enum langType;
  1576.     smsal_dcs_enum alphabetType;
  1577.     msg_cb_class_enum msgClass;
  1578.     pBOOL isCompress;
  1579.     pBOOL isReserved;
  1580.     /* MTK add Kevin */
  1581.     U8 skipChar;
  1582.     /*----------------------------------------------------------------*/
  1583.     /* Code Body                                                      */
  1584.     /*----------------------------------------------------------------*/
  1585.     /* MTK end */
  1586.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] ReadCBMessageContent ---*n"));
  1587.     /* MTK add Kevin */
  1588.     skipChar = DecodeCbsDcs(
  1589.                 dcs,
  1590.                 msgData[0],
  1591.                 msgData[1],
  1592.                 msgData[2],
  1593.                 &langType,
  1594.                 &alphabetType,
  1595.                 &msgClass,
  1596.                 &isCompress,
  1597.                 &isReserved);
  1598.     /* MTK end */
  1599.     if (isCompress == TRUE || isReserved == TRUE)
  1600.     {
  1601.         DisplayPopup(
  1602.             (PU8) GetString(STR_SMS_DOES_NOT_SUPPORT),
  1603.             IMG_GLOBAL_WARNING,
  1604.             0,
  1605.             MESSAGES_POPUP_TIME_OUT,
  1606.             (U8) WARNING_TONE);
  1607.         DeleteMessagesHistoryNodes();
  1608.     }
  1609.     else
  1610.     {
  1611.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] alphabetType=%d ---*n", alphabetType));
  1612.         switch (alphabetType)
  1613.         {
  1614.                 /* MTK add Kevin for skipping some characters containing dcs info */
  1615.             case SMSAL_DEFAULT_DCS:
  1616.             case SMSAL_RESERVED_DCS:
  1617.                 ConvertCBForDisplay(msgData + skipChar, (U16) (msgLength - skipChar), SMSAL_DEFAULT_DCS, outLen);
  1618.                 return;
  1619.             case SMSAL_8BIT_DCS:
  1620.                 ConvertCBForDisplay(msgData + skipChar, (U16) (msgLength - skipChar), SMSAL_8BIT_DCS, outLen);
  1621.                 return;
  1622.             case SMSAL_UCS2_DCS:
  1623.                 ConvertCBForDisplay(msgData + skipChar, (U16) (msgLength - skipChar), SMSAL_UCS2_DCS, outLen);
  1624.                 return;
  1625.                 /* MTK end */
  1626.             default:
  1627.                 ConvertCBForDisplay(msgData + skipChar, (U16) (msgLength - skipChar), SMSAL_DEFAULT_DCS, outLen);
  1628.                 return;
  1629.         }
  1630.     }
  1631.     return;
  1632. }
  1633. /*****************************************************************************
  1634.  * FUNCTION
  1635.  *  mmi_msg_get_cb_mode_req
  1636.  * DESCRIPTION
  1637.  *  Get CB mode
  1638.  * PARAMETERS
  1639.  *  void
  1640.  * RETURNS
  1641.  *  void
  1642.  *****************************************************************************/
  1643. void mmi_msg_get_cb_mode_req(void)
  1644. {
  1645.     /*----------------------------------------------------------------*/
  1646.     /* Local Variables                                                */
  1647.     /*----------------------------------------------------------------*/
  1648.     MYQUEUE Message;
  1649.     /*----------------------------------------------------------------*/
  1650.     /* Code Body                                                      */
  1651.     /*----------------------------------------------------------------*/
  1652.     Message.oslSrcId = MOD_MMI;
  1653.     Message.oslDestId = MOD_L4C;
  1654.     Message.oslMsgId = PRT_MSG_ID_MMI_SMS_GET_CB_MODE_REQ;
  1655.     Message.oslDataPtr = NULL;
  1656.     Message.oslPeerBuffPtr = NULL;
  1657.     OslMsgSendExtQueue(&Message);
  1658. }
  1659. /*****************************************************************************
  1660.  * FUNCTION
  1661.  *  mmi_msg_get_cb_mode_rsp_active
  1662.  * DESCRIPTION
  1663.  *  Get CB mode for current status
  1664.  * PARAMETERS
  1665.  *  inMsg       [IN]        L4 response message
  1666.  * RETURNS
  1667.  *  void
  1668.  *****************************************************************************/
  1669. void mmi_msg_get_cb_mode_rsp_active(void *inMsg)
  1670. {
  1671.     /*----------------------------------------------------------------*/
  1672.     /* Local Variables                                                */
  1673.     /*----------------------------------------------------------------*/
  1674.     MMI_FRM_CB_GET_CB_MODE_RSP_STRUCT *msgRsp = (MMI_FRM_CB_GET_CB_MODE_RSP_STRUCT*) inMsg;
  1675.     /*----------------------------------------------------------------*/
  1676.     /* Code Body                                                      */
  1677.     /*----------------------------------------------------------------*/
  1678.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] GetCBServiceModeRsp ---*n"));
  1679.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_CB_MODE_RSP);
  1680.     /* if incoming call ringing or alarm playing, do not show response result in case interrupt current screen */
  1681.     if (mmi_msg_check_interrupt() == TRUE)
  1682.     {
  1683.         return;
  1684.     }
  1685.     if (msgRsp->result == TRUE)
  1686.     {
  1687.         cb_info.mode = msgRsp->mode;
  1688.         memset(cb_display.mode, 0, ENCODING_LENGTH);
  1689.         if (cb_info.mode == TRUE)
  1690.         {
  1691.             pfnUnicodeStrcpy((S8*) cb_display.mode, (S8*) GetString((U16) STR_GLOBAL_ON));
  1692.         }
  1693.         else
  1694.         {
  1695.             pfnUnicodeStrcpy((S8*) cb_display.mode, (S8*) GetString((U16) STR_GLOBAL_OFF));
  1696.         }
  1697.         mmi_msg_entry_cb_main_menu();
  1698.     }
  1699.     else
  1700.     {
  1701.         DisplayPopup(
  1702.             (PU8) GetString(STR_CB_NOT_READY_YET),
  1703.             IMG_GLOBAL_UNFINISHED,
  1704.             1,
  1705.             MESSAGES_POPUP_TIME_OUT,
  1706.             (U8) ERROR_TONE);
  1707.     }
  1708. }
  1709. /*****************************************************************************
  1710.  * FUNCTION
  1711.  *  mmi_msg_get_cb_mode_rsp_display
  1712.  * DESCRIPTION
  1713.  *  Get CB mode to display channel list
  1714.  * PARAMETERS
  1715.  *  inMsg       [IN]        L4 reponse message
  1716.  * RETURNS
  1717.  *  void
  1718.  *****************************************************************************/
  1719. void mmi_msg_get_cb_mode_rsp_display(void *inMsg)
  1720. {
  1721.     /*----------------------------------------------------------------*/
  1722.     /* Local Variables                                                */
  1723.     /*----------------------------------------------------------------*/
  1724.     MMI_FRM_CB_GET_CB_MODE_RSP_STRUCT *msgRsp = (MMI_FRM_CB_GET_CB_MODE_RSP_STRUCT*) inMsg;
  1725.     /*----------------------------------------------------------------*/
  1726.     /* Code Body                                                      */
  1727.     /*----------------------------------------------------------------*/
  1728.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] GetCBServiceModeRsp ---*n"));
  1729.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_CB_MODE_RSP);
  1730.     /* if incoming call ringing or alarm playing, do not show response result in case interrupt current screen */
  1731.     if (mmi_msg_check_interrupt() == TRUE)
  1732.     {
  1733.         return;
  1734.     }
  1735.     if (msgRsp->result == TRUE)
  1736.     {
  1737.         U8 i = 0;
  1738.         U8 total = 0;
  1739.         U8 addindex = msgRsp->total_mid_num;
  1740.         /* delete if apply new interface */
  1741.         ReadCbChnlInfoFromNvram();
  1742.         /* end */
  1743.         for (i = 0; i < msgRsp->total_mid_num; i++)
  1744.         {
  1745.             if (msgRsp->info.mid[i] != SMSAL_CB_UNUSED_CBMI)
  1746.             {
  1747.                 U8 j = 0;
  1748.                 cb_info.cbchnlentry[total].mi = msgRsp->info.mid[i];
  1749.                 cb_info.cbchnlentry[total].mask = msgRsp->info.mid_mask[i];
  1750.                 cb_info.cbchnlentry[total].index = i;
  1751.                 /* delete if apply new interface */
  1752.                 memset(cb_info.cbchnlentry[total].name, 0, MAX_CB_CHNL_NAME_LENGTH + 1);
  1753.                 while ((cbNvramStruct.l4MidIndex[j] != i) && (j < SMS_CB_MAX_ENTRY))
  1754.                 {
  1755.                     j++;
  1756.                 }
  1757.                 if (j == SMS_CB_MAX_ENTRY)
  1758.                 {
  1759.                     memset((S8*) cb_info.cbchnlentry[total].name, 0, MAX_CB_CHNL_NAME_LENGTH);
  1760.                     cb_info.cbchnlentry[total].dcs = PHB_ASCII;
  1761.                 }
  1762.                 else
  1763.                 {
  1764.                     memcpy(
  1765.                         (S8*) cb_info.cbchnlentry[total].name,
  1766.                         (S8*) cbNvramStruct.chnlNames[j].name,
  1767.                         MAX_CB_CHNL_NAME_LENGTH);
  1768.                     cb_info.cbchnlentry[total].dcs = cbNvramStruct.chnlNames[j].name_dcs;
  1769.                 }
  1770.                 /* end */
  1771.                 total++;
  1772.             }
  1773.             else
  1774.             {
  1775.                 if (addindex == msgRsp->total_mid_num)
  1776.                 {
  1777.                     addindex = i;
  1778.                 }
  1779.             }
  1780.         }
  1781.         cb_info.totalmi = total;
  1782.         memset(&cbNvramStruct, 0xff, sizeof(msg_cb_channel_nvram_struct));
  1783.         for (i = 0; i < cb_info.totalmi; i++)
  1784.         {
  1785.             cbNvramStruct.l4MidIndex[i] = cb_info.cbchnlentry[i].index;
  1786.             cbNvramStruct.chnlNames[i].name_dcs = cb_info.cbchnlentry[i].dcs;
  1787.             memcpy(
  1788.                 (S8*) cbNvramStruct.chnlNames[i].name,
  1789.                 (S8*) cb_info.cbchnlentry[i].name,
  1790.                 MAX_CB_CHNL_NAME_LENGTH + 1);
  1791.         }
  1792.         /* delete if apply new interface */
  1793.         WriteCbChnlInfoToNvram();
  1794.         /* end */
  1795.         switch (cb_state)
  1796.         {
  1797.             case SMS_CB_CHNL_SELECT_STATE:
  1798.                 if (cb_info.totalmi == 0)
  1799.                 {
  1800.                     DisplayPopup(
  1801.                         (PU8) GetString(STR_GLOBAL_EMPTY),
  1802.                         IMG_GLOBAL_WARNING,
  1803.                         1,
  1804.                         MESSAGES_POPUP_TIME_OUT,
  1805.                         (U8) WARNING_TONE);
  1806.                 }
  1807.                 else
  1808.                 {
  1809.                     mmi_msg_entry_cb_channel_select();
  1810.                 }
  1811.                 break;
  1812.             case SMS_CB_CHNL_EDIT_STATE:
  1813.             case SMS_CB_CHNL_DELETE_STATE:
  1814.                 if (cb_info.totalmi == 0)
  1815.                 {
  1816.                     DisplayPopup(
  1817.                         (PU8) GetString(STR_GLOBAL_EMPTY),
  1818.                         IMG_GLOBAL_WARNING,
  1819.                         1,
  1820.                         MESSAGES_POPUP_TIME_OUT,
  1821.                         (U8) WARNING_TONE);
  1822.                 }
  1823.                 else
  1824.                 {
  1825.                     mmi_msg_entry_cb_channel_list();
  1826.                 }
  1827.                 break;
  1828.             case SMS_CB_CHNL_ADD_STATE:
  1829.                 if (cb_info.totalmi == msgRsp->total_mid_num)
  1830.                 {
  1831.                     DisplayPopup(
  1832.                         (PU8) GetString(STR_SMS_CB_CHNL_FULL),
  1833.                         IMG_GLOBAL_WARNING,
  1834.                         1,
  1835.                         MESSAGES_POPUP_TIME_OUT,
  1836.                         (U8) WARNING_TONE);
  1837.                 }
  1838.                 else
  1839.                 {
  1840.                     cb_display.addindex = addindex;
  1841.                     memset(cb_display.name, 0, (MAX_CB_CHNL_NAME_LENGTH + 1) * ENCODING_LENGTH);
  1842.                     memset(cb_display.mi, 0, (MAX_CB_CHNL_NUMBER_DISPLAY_LENGTH + 1) * ENCODING_LENGTH);
  1843.                     cb_display.dcs = PHB_ASCII;
  1844.                     mmi_msg_entry_cb_channel_edit();
  1845.                 }
  1846.                 break;
  1847.             case SMS_CB_READ_MESSAGE_STATE:
  1848.                 mmi_msg_entry_cb_read_message();
  1849.                 break;
  1850.             default:
  1851.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[CellBroadcast.c] cb_info is filled up-------*n"));
  1852.                 break;
  1853.         }
  1854.     }
  1855.     else
  1856.     {
  1857.         DisplayPopup(
  1858.             (PU8) GetString(STR_CB_ERROR_MESSAGE),
  1859.             IMG_GLOBAL_UNFINISHED,
  1860.             1,
  1861.             MESSAGES_POPUP_TIME_OUT,
  1862.             (U8) ERROR_TONE);
  1863.     }
  1864. }
  1865. /*****************************************************************************
  1866.  * FUNCTION
  1867.  *  mmi_msg_get_cb_mode_rsp_language
  1868.  * DESCRIPTION
  1869.  *  Get CB mode to display CB language list
  1870.  * PARAMETERS
  1871.  *  inMsg       [IN]        L4 response message
  1872.  * RETURNS
  1873.  *  void
  1874.  *****************************************************************************/
  1875. void mmi_msg_get_cb_mode_rsp_language(void *inMsg)
  1876. {
  1877.     /*----------------------------------------------------------------*/
  1878.     /* Local Variables                                                */
  1879.     /*----------------------------------------------------------------*/
  1880.     MMI_FRM_CB_GET_CB_MODE_RSP_STRUCT *msgRsp = (MMI_FRM_CB_GET_CB_MODE_RSP_STRUCT*) inMsg;
  1881.     /*----------------------------------------------------------------*/
  1882.     /* Code Body                                                      */
  1883.     /*----------------------------------------------------------------*/
  1884.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] GetCBServiceModeRsp ---*n"));
  1885.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_CB_MODE_RSP);
  1886.     /* if incoming call ringing or alarm playing, do not show response result in case interrupt current screen */
  1887.     if (mmi_msg_check_interrupt() == TRUE)
  1888.     {
  1889.         return;
  1890.     }
  1891.     if (msgRsp->result == TRUE)
  1892.     {
  1893.         U8 i = 0;
  1894.         U8 total = 0;
  1895.         U8 firstByte = 0;
  1896.         U8 secondByte = 0;
  1897.         pBOOL isCompress;
  1898.         pBOOL isReserved;
  1899.         msg_cb_lang_enum langType;
  1900.         smsal_dcs_enum alphabetType;
  1901.         msg_cb_class_enum msgClass;
  1902.         for (i = 0; i < msgRsp->total_dcs_num; i++)
  1903.         {
  1904.             if (msgRsp->info.dcs[i] != SMSAL_CB_UNUSED_DCS)
  1905.             {
  1906.                 firstByte = (msgRsp->info.dcs[i] & 0xff00) >> 8;
  1907.                 secondByte = (msgRsp->info.dcs[i] & 0x00ff);
  1908.                 if (firstByte == 0x00)
  1909.                 {
  1910.                     DecodeCbsDcs(secondByte, 0, 0, 0, &langType, &alphabetType, &msgClass, &isCompress, &isReserved);
  1911.                 }
  1912.                 else
  1913.                 {
  1914.                     MMICbsDecodeLang(firstByte, secondByte, &langType);
  1915.                 }
  1916.                 if ((langType != MMI_CBS0_LANG_UNSPECIFIED) && (langType != MMI_CBS_INVALID))
  1917.                 {
  1918.                     cb_info.cblanentry[total].dcs = langType;
  1919.                     cb_info.cblanentry[total].mask = msgRsp->info.dcs_mask[i];
  1920.                     cb_info.cblanentry[total].index = i;
  1921.                     total++;
  1922.                 }
  1923.             }
  1924.             firstByte = 0;
  1925.             secondByte = 0;
  1926.         }
  1927.         cb_info.totaldcs = total;
  1928.         cb_info.dcsall = msgRsp->info.is_all_language_on;
  1929.         mmi_msg_entry_cb_language();
  1930.     }
  1931. }
  1932. /*****************************************************************************
  1933.  * FUNCTION
  1934.  *  mmi_msg_set_cb_mode_req
  1935.  * DESCRIPTION
  1936.  *  Set CB mode request
  1937.  * PARAMETERS
  1938.  *  para        [IN]        Setting type flag
  1939.  * RETURNS
  1940.  *  void
  1941.  *****************************************************************************/
  1942. void mmi_msg_set_cb_mode_req(U8 para)
  1943. {
  1944.     /*----------------------------------------------------------------*/
  1945.     /* Local Variables                                                */
  1946.     /*----------------------------------------------------------------*/
  1947.     MYQUEUE Message;
  1948.     MMI_FRM_CB_SET_CB_MODE_REQ_STRUCT *msgReq;
  1949.     U8 i = 0;
  1950.     /*----------------------------------------------------------------*/
  1951.     /* Code Body                                                      */
  1952.     /*----------------------------------------------------------------*/
  1953.     WriteCbChnlInfoToNvram();
  1954.     Message.oslSrcId = MOD_MMI;
  1955.     Message.oslDestId = MOD_L4C;
  1956.     Message.oslMsgId = PRT_MSG_ID_MMI_SMS_SET_CB_MODE_REQ;
  1957.     msgReq = (MMI_FRM_CB_SET_CB_MODE_REQ_STRUCT*) OslConstructDataPtr(sizeof(MMI_FRM_CB_SET_CB_MODE_REQ_STRUCT));
  1958.     if ((para & SMSAL_CB_MI) == SMSAL_CB_MI)
  1959.     {
  1960.         for (i = 0; i < SMS_CB_MAX_ENTRY; i++)
  1961.         {
  1962.             msgReq->info.mid[i] = SMSAL_CB_UNUSED_CBMI;
  1963.         }
  1964.         for (i = 0; i < cb_info.totalmi; i++)
  1965.         {
  1966.             msgReq->info.mid[cb_info.cbchnlentry[i].index] = cb_info.cbchnlentry[i].mi;
  1967.         }
  1968.     }
  1969.     if (((para & SMSAL_CB_MI) == SMSAL_CB_MI) || ((para & SMSAL_CB_MI_MASK) == SMSAL_CB_MI_MASK))
  1970.     {
  1971.         for (i = 0; i < SMS_CB_MAX_ENTRY; i++)
  1972.         {
  1973.             msgReq->info.mid_mask[i] = 1;
  1974.         }
  1975.         for (i = 0; i < cb_info.totalmi; i++)
  1976.         {
  1977.             msgReq->info.mid_mask[cb_info.cbchnlentry[i].index] = cb_info.cbchnlentry[i].mask;
  1978.         }
  1979.     }
  1980.     if ((para & SMSAL_CB_DCS_MASK) == SMSAL_CB_DCS_MASK)
  1981.     {
  1982.         for (i = 0; i < SMS_CB_MAX_LANG; i++)
  1983.         {
  1984.             msgReq->info.dcs_mask[i] = 1;
  1985.         }
  1986.         for (i = 0; i < cb_info.totaldcs; i++)
  1987.         {
  1988.             msgReq->info.dcs_mask[cb_info.cblanentry[i].index] = cb_info.cblanentry[i].mask;
  1989.         }
  1990.     }
  1991.     if ((para & SMSAL_CB_ALL_LANG) == SMSAL_CB_ALL_LANG)
  1992.     {
  1993.         msgReq->info.is_all_language_on = cb_info.dcsall;
  1994.     }
  1995.     msgReq->info.para_ind = para;
  1996.     Message.oslDataPtr = (oslParaType*) msgReq;
  1997.     Message.oslPeerBuffPtr = NULL;
  1998.     OslMsgSendExtQueue(&Message);
  1999. }
  2000. /*****************************************************************************
  2001.  * FUNCTION
  2002.  *  mmi_msg_set_cb_mode_rsp
  2003.  * DESCRIPTION
  2004.  *  Set CB mode response
  2005.  * PARAMETERS
  2006.  *  inMsg       [IN]        L4 reponse message
  2007.  * RETURNS
  2008.  *  void
  2009.  *****************************************************************************/
  2010. void mmi_msg_set_cb_mode_rsp(void *inMsg)
  2011. {
  2012.     /*----------------------------------------------------------------*/
  2013.     /* Local Variables                                                */
  2014.     /*----------------------------------------------------------------*/
  2015.     MMI_FRM_CB_SET_CB_MODE_RSP_STRUCT *msgRsp = (MMI_FRM_CB_SET_CB_MODE_RSP_STRUCT*) inMsg;
  2016.     /*----------------------------------------------------------------*/
  2017.     /* Code Body                                                      */
  2018.     /*----------------------------------------------------------------*/
  2019.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_CB_MODE_RSP);
  2020.     if (msgRsp->result == TRUE)
  2021.     {
  2022.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] SetCBServiceModeRsp-ok ---*n"));
  2023.         switch (cb_state)
  2024.         {
  2025.             case SMS_CB_DEFAULT_SETTINGS_MODE_STATE:
  2026.                 if (msgRsp->result == TRUE)
  2027.                 {
  2028.                     RstRestoreDisplayPopup(TRUE);
  2029.                 }
  2030.                 else
  2031.                 {
  2032.                     RstRestoreDisplayPopup(FALSE);
  2033.                 }
  2034.                 break;
  2035.             case SMS_CB_CHNL_SELECT_STATE:
  2036.             case SMS_CB_CHNL_ADD_STATE:
  2037.             case SMS_CB_CHNL_EDIT_STATE:
  2038.                 DisplayPopup(
  2039.                     (PU8) GetString(STR_GLOBAL_SAVED),
  2040.                     IMG_GLOBAL_ACTIVATED,
  2041.                     1,
  2042.                     MESSAGES_POPUP_TIME_OUT,
  2043.                     (U8) SUCCESS_TONE);
  2044.                 DeleteMessagesHistoryNodes();
  2045.                 break;
  2046.             case SMS_CB_CHNL_DELETE_STATE:
  2047.                 if (g_msg_cntx.currHiliteIndex == cb_info.totalmi)
  2048.                 {
  2049.                     g_msg_cntx.currHiliteIndex--;
  2050.                 }
  2051.                 DisplayPopup(
  2052.                     (PU8) GetString(STR_MESSAGES_DELETED_ID),
  2053.                     IMG_GLOBAL_ACTIVATED,
  2054.                     1,
  2055.                     MESSAGES_POPUP_TIME_OUT,
  2056.                     (U8) SUCCESS_TONE);
  2057.                 if (cb_info.totalmi == 0)
  2058.                 {
  2059.                     DeleteScreenIfPresent(SCR_ID_MSG_CB_CHANNEL_LIST);
  2060.                 }
  2061.                 break;
  2062.             case SMS_CB_LANGUAGE_STATE:
  2063.                 if (msgRsp->result == TRUE)
  2064.                 {
  2065.                     DisplayPopup(
  2066.                         (PU8) GetString(STR_GLOBAL_SAVED),
  2067.                         IMG_GLOBAL_ACTIVATED,
  2068.                         1,
  2069.                         MESSAGES_POPUP_TIME_OUT,
  2070.                         (U8) SUCCESS_TONE);
  2071.                     DeleteMessagesHistoryNodes();
  2072.                 }
  2073.                 else
  2074.                 {
  2075.                     DisplayPopup(
  2076.                         (PU8) GetString(STR_MESSAGES_UNKNOWN_ERROR),
  2077.                         IMG_GLOBAL_UNFINISHED,
  2078.                         1,
  2079.                         MESSAGES_POPUP_TIME_OUT,
  2080.                         (U8) ERROR_TONE);
  2081.                     DeleteMessagesHistoryNodes();
  2082.                 }
  2083.                 break;
  2084.         }
  2085.     }
  2086.     else
  2087.     {
  2088.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] SetCBServiceModeRsp-failed ---*n"));
  2089.         if (cb_state == SMS_CB_DEFAULT_SETTINGS_MODE_STATE)
  2090.         {
  2091.             RstRestoreDisplayPopup(FALSE);
  2092.         }
  2093.         else
  2094.         {
  2095.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_CB_CHANNEL_LIST);
  2096.             DisplayPopup(
  2097.                 (PU8) GetString(STR_CB_ERROR_MESSAGE),
  2098.                 IMG_GLOBAL_UNFINISHED,
  2099.                 1,
  2100.                 MESSAGES_POPUP_TIME_OUT,
  2101.                 (U8) ERROR_TONE);
  2102.             DeleteMessagesHistoryNodes();
  2103.         }
  2104.     }
  2105. }
  2106. /*****************************************************************************
  2107.  * FUNCTION
  2108.  *  mmi_msg_subscribe_cb_req
  2109.  * DESCRIPTION
  2110.  *  Subscribe CB request
  2111.  * PARAMETERS
  2112.  *  subscribe       [IN]        Subscribe type
  2113.  * RETURNS
  2114.  *  void
  2115.  *****************************************************************************/
  2116. void mmi_msg_subscribe_cb_req(U8 subscribe)
  2117. {
  2118.     /*----------------------------------------------------------------*/
  2119.     /* Local Variables                                                */
  2120.     /*----------------------------------------------------------------*/
  2121.     MYQUEUE Message;
  2122.     MMI_FRM_CB_SUBSCRIBE_REQ_STRUCT *msgReq;
  2123.     /*----------------------------------------------------------------*/
  2124.     /* Code Body                                                      */
  2125.     /*----------------------------------------------------------------*/
  2126.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] EnableOrDiasableCBServiceReq ---*n"));
  2127.     Message.oslSrcId = MOD_MMI;
  2128.     Message.oslDestId = MOD_L4C;
  2129.     Message.oslMsgId = PRT_MSG_ID_MMI_CB_SUBSCRIBE_REQ;
  2130.     msgReq = (MMI_FRM_CB_SUBSCRIBE_REQ_STRUCT*) OslConstructDataPtr(sizeof(MMI_FRM_CB_SUBSCRIBE_REQ_STRUCT));
  2131.     msgReq->on_off = subscribe;
  2132.     Message.oslDataPtr = (oslParaType*) msgReq;
  2133.     Message.oslPeerBuffPtr = NULL;
  2134.     OslMsgSendExtQueue(&Message);
  2135. }
  2136. /*****************************************************************************
  2137.  * FUNCTION
  2138.  *  mmi_msg_subscribe_cb_rsp
  2139.  * DESCRIPTION
  2140.  *  Subscribe CB response
  2141.  * PARAMETERS
  2142.  *  inMsg       [IN]        L4 reponse message
  2143.  * RETURNS
  2144.  *  void
  2145.  *****************************************************************************/
  2146. void mmi_msg_subscribe_cb_rsp(void *inMsg)
  2147. {
  2148.     /*----------------------------------------------------------------*/
  2149.     /* Local Variables                                                */
  2150.     /*----------------------------------------------------------------*/
  2151.     MMI_FRM_CB_SUBSCRIBE_RSP_STRUCT *msgRsp = (MMI_FRM_CB_SUBSCRIBE_RSP_STRUCT*) inMsg;
  2152.     /*----------------------------------------------------------------*/
  2153.     /* Code Body                                                      */
  2154.     /*----------------------------------------------------------------*/
  2155.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_CB_SUBSCRIBE_RSP);
  2156.     if (msgRsp->result == TRUE)
  2157.     {
  2158.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] mmi_msg_subscribe_cb_rsp -OK ---*n"));
  2159.         if (cb_state == SMS_CB_DEFAULT_SETTINGS_MODE_STATE)
  2160.         {
  2161.             U8 i = 0;
  2162.             for (i = 0; i < SMS_CB_MAX_ENTRY; i++)
  2163.             {
  2164.                 cb_info.cbchnlentry[i].mask = 1;
  2165.             }
  2166.             for (i = 0; i < SMS_CB_MAX_LANG; i++)
  2167.             {
  2168.                 cb_info.cblanentry[i].mask = 1;
  2169.             }
  2170.             cb_info.dcsall = 1;
  2171.             SetProtocolEventHandler(mmi_msg_set_cb_mode_rsp, PRT_MSG_ID_MMI_SMS_SET_CB_MODE_RSP);
  2172.             mmi_msg_set_cb_mode_req(SMSAL_CB_MI_MASK | SMSAL_CB_DCS_MASK);
  2173.         }
  2174.         else
  2175.         {
  2176.             U8 subscribe = (!cb_info.mode);
  2177.             cb_info.mode = subscribe;
  2178.             memset(cb_display.mode, 0, ENCODING_LENGTH);
  2179.             if (cb_info.mode == TRUE)
  2180.             {
  2181.                 pfnUnicodeStrcpy((S8*) cb_display.mode, (S8*) GetString((U16) STR_GLOBAL_ON));
  2182.             }
  2183.             else
  2184.             {
  2185.                 pfnUnicodeStrcpy((S8*) cb_display.mode, (S8*) GetString((U16) STR_GLOBAL_OFF));
  2186.             }
  2187.             mmi_msg_refresh_cb_main_menu();
  2188.         }
  2189.     }
  2190.     else
  2191.     {
  2192.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] mmi_msg_subscribe_cb_rsp-Failed ---*n"));
  2193.         if (cb_state == SMS_CB_DEFAULT_SETTINGS_MODE_STATE)
  2194.         {
  2195.             RstRestoreDisplayPopup(FALSE);
  2196.         }
  2197.         else
  2198.         {
  2199.             DisplayPopup(
  2200.                 (PU8) GetString(STR_CB_ERROR_MESSAGE),
  2201.                 IMG_GLOBAL_UNFINISHED,
  2202.                 1,
  2203.                 MESSAGES_POPUP_TIME_OUT,
  2204.                 (U8) ERROR_TONE);
  2205.         }
  2206.     }
  2207. }
  2208. /*****************************************************************************
  2209.  * FUNCTION
  2210.  *  mmi_msg_handle_new_cb_ind
  2211.  * DESCRIPTION
  2212.  *  Handle new CB indication
  2213.  * PARAMETERS
  2214.  *  inMsg       [IN]        L4 response message
  2215.  * RETURNS
  2216.  *  void
  2217.  *****************************************************************************/
  2218. void mmi_msg_handle_new_cb_ind(void *inMsg)
  2219. {
  2220.     /*----------------------------------------------------------------*/
  2221.     /* Local Variables                                                */
  2222.     /*----------------------------------------------------------------*/
  2223.     MMI_FRM_CB_MSG_IND_STRUCT *CbsMsg = (MMI_FRM_CB_MSG_IND_STRUCT*) inMsg;
  2224.     U8 i = 0;
  2225.     U8 deleteIndex = 0;
  2226.     U16 inCBMI = SMS_CB_UNUSED_CBMI;
  2227.     U8 inCBDCS = 0;
  2228.     U8 inCBPage = 0;
  2229.     U8 currCBPageTotal = 0;
  2230.     /*----------------------------------------------------------------*/
  2231.     /* Code Body                                                      */
  2232.     /*----------------------------------------------------------------*/
  2233.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] mmi_msg_handle_new_cb_ind ---*n"));
  2234.     if (IsCBMessageReadOperRequired)
  2235.     {
  2236.         IsCBMessageReadOperRequired = FALSE;
  2237.     #ifdef MMI_ON_WIN32
  2238.         cbMsgStart = (U8*) cbMsgContent[0];
  2239.         cbMsgIndex.pCBMsgTail = (U8*) cbMsgContent[0];
  2240.     #else /* MMI_ON_WIN32 */ 
  2241.         ReadCBMessageInfoFromNvram();
  2242.     #endif /* MMI_ON_WIN32 */ 
  2243.     }
  2244.     inCBMI = CbsMsg->mi;
  2245.     inCBDCS = CbsMsg->dcs;
  2246.     inCBPage = ((CbsMsg->msg_length) / NVRAM_SMS_CB_SMS_PAGE_SIZE);
  2247.     if (((CbsMsg->msg_length) % NVRAM_SMS_CB_SMS_PAGE_SIZE) != 0)
  2248.     {
  2249.         inCBPage++;
  2250.     }
  2251.     inCBPage = (inCBPage > MAX_CB_MSG_PAGE) ? MAX_CB_MSG_PAGE : inCBPage;
  2252.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] Page= %d---*n", inCBPage));
  2253.     for (i = 0; i < cbMsgIndex.currCBTotal; i++)
  2254.     {
  2255.         currCBPageTotal += cbMsgInfo.MsgPage[i];
  2256.     }
  2257.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*---[CellBroadcast.c] CurrTotalPage= %d---*n", currCBPageTotal));
  2258.     if ((currCBPageTotal + inCBPage) < NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL)
  2259.     {
  2260.         if (cbMsgIndex.currCBTotal == MAX_STORE_CB_MSG)
  2261.         {
  2262.             if (cb_display.currindex == MAX_STORE_CB_MSG - 1)
  2263.             {
  2264.                 deleteIndex = 0;
  2265.                 cb_display.currindex--;
  2266.             }
  2267.             else
  2268.             {
  2269.                 deleteIndex = MAX_STORE_CB_MSG - 1;
  2270.             }
  2271.             DeleteCBMessage(deleteIndex);
  2272.         }
  2273.     }
  2274.     else
  2275.     {
  2276.         if (cb_display.currindex == (cbMsgIndex.currCBTotal - 1))
  2277.         {
  2278.             for (i = 0; i < cbMsgIndex.currCBTotal - 1; i++)
  2279.             {
  2280.                 currCBPageTotal -= DeleteCBMessage(0);
  2281.                 cb_display.currindex--;
  2282.                 if ((currCBPageTotal + inCBPage) <= NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL)
  2283.                 {
  2284.                     break;
  2285.                 }
  2286.             }
  2287.         }
  2288.         else
  2289.         {
  2290.             for (i = cbMsgIndex.currCBTotal - 1;; i--)
  2291.             {
  2292.                 if ((cb_display.currindex == MAX_STORE_CB_MSG) || (i > cb_display.currindex))
  2293.                 {
  2294.                     currCBPageTotal -= DeleteCBMessage(i);
  2295.                     if ((currCBPageTotal + inCBPage) <= NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL)
  2296.                     {
  2297.                         break;
  2298.                     }
  2299.                 }
  2300.                 else if (i < cb_display.currindex)
  2301.                 {
  2302.                     currCBPageTotal -= DeleteCBMessage(i);
  2303.                     cb_display.currindex--;
  2304.                     if ((currCBPageTotal + inCBPage) <= NVRAM_SMS_CB_SMS_PAGE_NUM_TOTAL)
  2305.                     {
  2306.                         break;
  2307.                     }
  2308.                 }
  2309.                 if (i == 0)
  2310.                 {
  2311.                     break;
  2312.                 }
  2313.             }
  2314.         }
  2315.     }
  2316.     AddCBMessage(inCBMI, inCBDCS, inCBPage, CbsMsg->msg_data, CbsMsg->msg_length);
  2317.     cb_display.unread[cbMsgIndex.currCBTotal - 1] = TRUE;
  2318.     /* gs code is the first two most significant bits in the first octet */
  2319.     if ((CbsMsg->sn & 0xc000) == 0)
  2320.     {
  2321.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[CellBroadcast.c] Immediate mode-------*n"));
  2322.         cb_display.immediate[cbMsgIndex.currCBTotal - 1] = TRUE;
  2323.     }
  2324.     else
  2325.     {
  2326.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[CellBroadcast.c] Normal mode-------*n"));
  2327.         cb_display.immediate[cbMsgIndex.currCBTotal - 1] = FALSE;
  2328.     }
  2329.     mmi_msg_new_cb_ind();
  2330. }
  2331. /*****************************************************************************
  2332.  * FUNCTION
  2333.  *  mmi_msg_new_cb_ind
  2334.  * DESCRIPTION
  2335.  *  New CB message indication
  2336.  * PARAMETERS
  2337.  *  void
  2338.  * RETURNS
  2339.  *  void
  2340.  *****************************************************************************/
  2341. void mmi_msg_new_cb_ind(void)
  2342. {
  2343.     /*----------------------------------------------------------------*/
  2344.     /* Local Variables                                                */
  2345.     /*----------------------------------------------------------------*/
  2346.     /*----------------------------------------------------------------*/
  2347.     /* Code Body                                                      */
  2348.     /*----------------------------------------------------------------*/
  2349.     TurnOnBacklight(1);
  2350.     if (IsMMIInIdleState() || GetMessagesCurrScrnID() == SCR_ID_MSG_CB_MESSAGE_IDLE ||
  2351.         GetMessagesCurrScrnID() == SCR_ID_MSG_CB_MESSAGE_IND)
  2352.     {
  2353.         ClearKeyEvents();   /* key flussing */
  2354.         if (IsKeyPadLockState())
  2355.         {
  2356.             EntryIdleScreen();
  2357.         }
  2358.         else
  2359.         {
  2360.         #ifdef __MMI_MESSAGES_TWO_CB_MODES_DISPLAY__
  2361.             if (cb_display.immediate[cbMsgIndex.currCBTotal - 1] == TRUE)
  2362.             {
  2363.                 cbMsgIndex.currCBIndex = cbMsgIndex.currCBTotal - 1;
  2364.             }
  2365.             else if (GetMessagesCurrScrnID() != SCR_ID_MSG_CB_MESSAGE_IDLE)
  2366.             {
  2367.                 cbMsgIndex.currCBIndex = cbMsgIndex.currCBTotal - 1;
  2368.             }
  2369.         #else /* __MMI_MESSAGES_TWO_CB_MODES_DISPLAY__ */ 
  2370.             cbMsgIndex.currCBIndex = cbMsgIndex.currCBTotal - 1;
  2371.         #endif /* __MMI_MESSAGES_TWO_CB_MODES_DISPLAY__ */ 
  2372.             mmi_msg_entry_new_cb_ind();
  2373.         }
  2374.     }