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

MTK

开发平台:

C/C++

  1. {
  2.     /*----------------------------------------------------------------*/
  3.     /* Local Variables                                                */
  4.     /*----------------------------------------------------------------*/
  5.     /*----------------------------------------------------------------*/
  6.     /* Code Body                                                      */
  7.     /*----------------------------------------------------------------*/
  8.     mmi_msg_highlight_generic(
  9.         STR_GLOBAL_OK,
  10.         IMG_GLOBAL_OK,
  11.         STR_GLOBAL_BACK,
  12.         IMG_GLOBAL_BACK,
  13.         mmi_msg_club_pre_entry_send_msg,
  14.         GoBackHistory);
  15.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  16.     msg_club_level_3_index = MSG_CLUB_SERVICE_CANCEL;
  17. }
  18. /*****************************************************************************
  19.  * FUNCTION
  20.  *  mmi_msg_club_set_menu_highlight_handler
  21.  * DESCRIPTION
  22.  *  
  23.  * PARAMETERS
  24.  *  void
  25.  * RETURNS
  26.  *  void
  27.  *****************************************************************************/
  28. void mmi_msg_club_set_menu_highlight_handler(void)
  29. {
  30.     /*----------------------------------------------------------------*/
  31.     /* Local Variables                                                */
  32.     /*----------------------------------------------------------------*/
  33.     /*----------------------------------------------------------------*/
  34.     /* Code Body                                                      */
  35.     /*----------------------------------------------------------------*/
  36.     SetHiliteHandler(MENU_MSG_CLUB_SUBSCRIBE, mmi_msg_club_highlight_subscribe);
  37.     SetHiliteHandler(MENU_MSG_CLUB_ORDER, mmi_msg_club_highlight_order);
  38.     SetHiliteHandler(MENU_MSG_CLUB_EXPLAIN, mmi_msg_club_highlight_explain);
  39.     SetHiliteHandler(MENU_MSG_CLUB_QUIT, mmi_msg_club_highlight_quit);
  40. }
  41. /*****************************************************************************
  42.  * FUNCTION
  43.  *  mmi_msg_club_go_back_menu
  44.  * DESCRIPTION
  45.  *  
  46.  * PARAMETERS
  47.  *  void
  48.  * RETURNS
  49.  *  void
  50.  *****************************************************************************/
  51. void mmi_msg_club_go_back_menu(void)
  52. {
  53.     /*----------------------------------------------------------------*/
  54.     /* Local Variables                                                */
  55.     /*----------------------------------------------------------------*/
  56.     /*----------------------------------------------------------------*/
  57.     /* Code Body                                                      */
  58.     /*----------------------------------------------------------------*/
  59.     memset((S8*) & MSGClubScreen[MSGClubCount], 0, sizeof(msg_club_entry_menu_struct));
  60.     MSGClubCount--;
  61.     GoBackHistory();
  62. }
  63. /*****************************************************************************
  64.  * FUNCTION
  65.  *  mmi_msg_club_level_3_get_index
  66.  * DESCRIPTION
  67.  *  
  68.  * PARAMETERS
  69.  *  nIndex      [IN]        
  70.  * RETURNS
  71.  *  void
  72.  *****************************************************************************/
  73. void mmi_msg_club_level_3_get_index(S32 nIndex)
  74. {
  75.     /*----------------------------------------------------------------*/
  76.     /* Local Variables                                                */
  77.     /*----------------------------------------------------------------*/
  78.     /*----------------------------------------------------------------*/
  79.     /* Code Body                                                      */
  80.     /*----------------------------------------------------------------*/
  81.     msg_club_level_3_index = (U8) nIndex;
  82. }
  83. /*****************************************************************************
  84.  * FUNCTION
  85.  *  mmi_msg_club_level_2_get_index
  86.  * DESCRIPTION
  87.  *  
  88.  * PARAMETERS
  89.  *  nIndex      [IN]        
  90.  * RETURNS
  91.  *  void
  92.  *****************************************************************************/
  93. void mmi_msg_club_level_2_get_index(S32 nIndex)
  94. {
  95.     /*----------------------------------------------------------------*/
  96.     /* Local Variables                                                */
  97.     /*----------------------------------------------------------------*/
  98.     /*----------------------------------------------------------------*/
  99.     /* Code Body                                                      */
  100.     /*----------------------------------------------------------------*/
  101.     msg_club_level_2_index = (U8) nIndex;
  102. }
  103. /*****************************************************************************
  104.  * FUNCTION
  105.  *  mmi_msg_club_entry_voice_submenu
  106.  * DESCRIPTION
  107.  *  
  108.  * PARAMETERS
  109.  *  void
  110.  * RETURNS
  111.  *  void
  112.  *****************************************************************************/
  113. void mmi_msg_club_entry_voice_submenu(void)
  114. {
  115.     /*----------------------------------------------------------------*/
  116.     /* Local Variables                                                */
  117.     /*----------------------------------------------------------------*/
  118.     U8 *guiBuffer = NULL;
  119.     U8 *itemList[MSG_CLUB_MENUITEM_NUM];
  120.     U8 itemNum = MSGClubScreen[MSGClubCount].childNum;
  121.     U8 i;
  122.     U8 *caption;
  123.     msg_club_entry_voice_struct *itemInfo = (msg_club_entry_voice_struct*) MSGClubScreen[MSGClubCount].childEntry;
  124.     /*----------------------------------------------------------------*/
  125.     /* Code Body                                                      */
  126.     /*----------------------------------------------------------------*/
  127.     if (MSGClubScreen[MSGClubCount].childNum == 0)
  128.     {
  129.         msg_club_level_2_index = 0;
  130.         mmi_msg_club_entry_make_call();
  131.         memset((S8*) & MSGClubScreen[MSGClubCount], 0, sizeof(msg_club_entry_menu_struct));
  132.         MSGClubCount--;
  133.         return;
  134.     }
  135.     EntryNewScreen(SCR_ID_MSG_CLUB_VOICE_SUBMENU, NULL, mmi_msg_club_entry_voice_submenu, NULL);
  136.     guiBuffer = GetCurrGuiBuffer(SCR_ID_MSG_CLUB_VOICE_SUBMENU);
  137.     for (i = 0; i < MSGClubScreen[MSGClubCount].childNum; i++)
  138. #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  139.         itemList[i] = (U8*) get_string_lang(itemInfo[i].stringID, SSC_ENGLISH);
  140. #else 
  141.         itemList[i] = (U8*) GetString(itemInfo[i].stringID);
  142. #endif 
  143.     RegisterHighlightHandler(mmi_msg_club_level_2_get_index);
  144. #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  145.     caption = (U8*) get_string_lang(MSGClubScreen[MSGClubCount].stringID, SSC_ENGLISH);
  146. #else 
  147.     caption = (U8*) GetString(MSGClubScreen[MSGClubCount].stringID);
  148. #endif 
  149.     ShowCategory353Screen(
  150.         caption,
  151.         IMG_MESSAGE_CLUB_ID,
  152.         STR_GLOBAL_OK,
  153.         IMG_GLOBAL_OK,
  154.         STR_GLOBAL_BACK,
  155.         IMG_GLOBAL_BACK,
  156.         itemNum,
  157.         itemList,
  158.         (U16*) gIndexIconsImageList,
  159.         NULL,
  160.         0,
  161.         0,
  162.         guiBuffer);
  163.     SetLeftSoftkeyFunction(mmi_msg_club_entry_make_call, KEY_EVENT_UP);
  164.     SetKeyHandler(mmi_msg_club_entry_make_call, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  165.     SetRightSoftkeyFunction(mmi_msg_club_go_back_menu, KEY_EVENT_UP);
  166.     SetKeyHandler(mmi_msg_club_go_back_menu, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  167. }
  168. /*****************************************************************************
  169.  * FUNCTION
  170.  *  mmi_msg_club_entry_level_3
  171.  * DESCRIPTION
  172.  *  
  173.  * PARAMETERS
  174.  *  void
  175.  * RETURNS
  176.  *  void
  177.  *****************************************************************************/
  178. void mmi_msg_club_entry_level_3(void)
  179. {
  180.     /*----------------------------------------------------------------*/
  181.     /* Local Variables                                                */
  182.     /*----------------------------------------------------------------*/
  183.     U8 *guiBuffer;
  184.     U16 nStrItemList[MAX_SUB_MENUS];
  185.     U8 *itemList[MSG_CLUB_MENUITEM_NUM];
  186.     U16 numItems;
  187.     U32 menuItemId = -1;
  188.     U32 menuItemId1 = -1;
  189.     U32 maskingByte = -1;
  190.     U8 i = 0;
  191.     U8 *captionStr;
  192.     /*----------------------------------------------------------------*/
  193.     /* Code Body                                                      */
  194.     /*----------------------------------------------------------------*/
  195.     EntryNewScreen(SCR_ID_MSG_CLUB_LEVEL_3, NULL, mmi_msg_club_entry_level_3, NULL);
  196.     guiBuffer = GetCurrGuiBuffer(SCR_ID_MSG_CLUB_LEVEL_3);
  197.     SetParentHandler(MENU_MSG_CLUB_OPTION);
  198.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  199.     numItems = GetNumOfChild(MENU_MSG_CLUB_OPTION);
  200.     GetSequenceStringIds(MENU_MSG_CLUB_OPTION, nStrItemList);
  201.     mmi_msg_club_set_menu_highlight_handler();
  202.     menuItemId = GetChildMenuIDIndexByParentMenuID(MENU_MSG_CLUB_OPTION, MENU_MSG_CLUB_SUBSCRIBE);
  203.     if (menuItemId != -1)
  204.     {
  205.         if (strcmp((S8*) MSGClubSMSItem.codeDY.codeNum, "") == 0)
  206.         {
  207.             ResetBit(maskingByte, menuItemId /* 1 */ );
  208.         }
  209.         else
  210.         {
  211.         #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  212.             itemList[i] = (U8*) get_string_lang(STR_MSG_CLUB_SUBSCRIBE, SSC_ENGLISH);
  213.         #else 
  214.             itemList[i] = (U8*) GetString(STR_MSG_CLUB_SUBSCRIBE);
  215.         #endif 
  216.             i++;
  217.         }
  218.     }
  219.     menuItemId = GetChildMenuIDIndexByParentMenuID(MENU_MSG_CLUB_OPTION, MENU_MSG_CLUB_ORDER);
  220.     if (menuItemId != -1)
  221.     {
  222.         if (strcmp((S8*) MSGClubSMSItem.codeDB.codeNum, "") == 0)
  223.         {
  224.             ResetBit(maskingByte, menuItemId /* 2 */ );
  225.         }
  226.         else
  227.         {
  228.         #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  229.             itemList[i] = (U8*) get_string_lang(STR_MSG_CLUB_ORDER, SSC_ENGLISH);
  230.         #else 
  231.             itemList[i] = (U8*) GetString(STR_MSG_CLUB_ORDER);
  232.         #endif 
  233.             i++;
  234.         }
  235.     }
  236.     menuItemId = GetChildMenuIDIndexByParentMenuID(MENU_MSG_CLUB_OPTION, MENU_MSG_CLUB_EXPLAIN);
  237.     if (menuItemId != -1)
  238.     {
  239.         if (strcmp((S8*) MSGClubSMSItem.codeZF.codeNum, "") == 0)
  240.         {
  241.             ResetBit(maskingByte, menuItemId /* 3 */ );
  242.         }
  243.         else
  244.         {
  245.         #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  246.             itemList[i] = (U8*) get_string_lang(STR_MSG_CLUB_INQUIRE, SSC_ENGLISH);
  247.         #else 
  248.             itemList[i] = (U8*) GetString(STR_MSG_CLUB_INQUIRE);
  249.         #endif 
  250.             i++;
  251.         }
  252.     }
  253.     menuItemId = GetChildMenuIDIndexByParentMenuID(MENU_MSG_CLUB_OPTION, MENU_MSG_CLUB_QUIT);
  254.     if (menuItemId != -1)
  255.     {
  256.         if (strcmp((S8*) MSGClubSMSItem.codeTD.codeNum, "") == 0)
  257.         {
  258.             ResetBit(maskingByte, menuItemId /* 4 */ );
  259.         }
  260.         else
  261.         {
  262.         #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  263.             itemList[i] = (U8*) get_string_lang(STR_MSG_CLUB_QUIT, SSC_ENGLISH);
  264.         #else 
  265.             itemList[i] = (U8*) GetString(STR_MSG_CLUB_QUIT);
  266.         #endif 
  267.             i++;
  268.         }
  269.     }
  270.     MaskHiliteItems(MENU_MSG_CLUB_OPTION, maskingByte);
  271.     numItems = MaskItems(nStrItemList, (U8) numItems, maskingByte);
  272. #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  273.     captionStr = (U8*) get_string_lang(MSGClubSMSItem.stringID, SSC_ENGLISH);
  274. #else 
  275.     captionStr = (U8*) GetString(MSGClubSMSItem.stringID);
  276. #endif 
  277.     ShowCategory353Screen(
  278.         captionStr,
  279.         IMG_MESSAGE_CLUB_ID,
  280.         STR_GLOBAL_OK,
  281.         IMG_GLOBAL_OK,
  282.         STR_GLOBAL_BACK,
  283.         IMG_GLOBAL_BACK,
  284.         numItems,
  285.         itemList,
  286.         (U16*) gIndexIconsImageList,
  287.         NULL,
  288.         0,
  289.         0,
  290.         guiBuffer);
  291.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);   /* MTK Jo */
  292.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  293. }
  294. /*****************************************************************************
  295.  * FUNCTION
  296.  *  mmi_msg_club_pre_entry_level_3
  297.  * DESCRIPTION
  298.  *  
  299.  * PARAMETERS
  300.  *  void
  301.  * RETURNS
  302.  *  void
  303.  *****************************************************************************/
  304. void mmi_msg_club_pre_entry_level_3(void)
  305. {
  306.     /*----------------------------------------------------------------*/
  307.     /* Local Variables                                                */
  308.     /*----------------------------------------------------------------*/
  309.     msg_club_entry_dy_db_zf_struct *itemInfo =
  310.         (msg_club_entry_dy_db_zf_struct*) MSGClubScreen[MSGClubCount].childEntry;
  311.     /*----------------------------------------------------------------*/
  312.     /* Code Body                                                      */
  313.     /*----------------------------------------------------------------*/
  314.     memcpy((S8*) & MSGClubSMSItem, (S8*) & itemInfo[msg_club_level_2_index], sizeof(msg_club_entry_dy_db_zf_struct));
  315.     if ((strcmp((S8*) MSGClubSMSItem.codeDY.codeNum, "") != 0)
  316.         || (strcmp((S8*) MSGClubSMSItem.codeDB.codeNum, "") != 0))
  317.     {
  318.         mmi_msg_club_entry_level_3();
  319.     }
  320.     else
  321.     {
  322.         if (strcmp((S8*) MSGClubSMSItem.codeZF.codeNum, "") != 0)
  323.         {
  324.             msg_club_level_3_index = MSG_CLUB_SERVICE_EXPLAIN;
  325.         }
  326.         else
  327.         {
  328.             msg_club_level_3_index = MSG_CLUB_SERVICE_CANCEL;
  329.         }
  330.         mmi_msg_club_pre_entry_send_msg();
  331.     }
  332. }
  333. /*****************************************************************************
  334.  * FUNCTION
  335.  *  mmi_msg_club_entry_level_2
  336.  * DESCRIPTION
  337.  *  
  338.  * PARAMETERS
  339.  *  void
  340.  * RETURNS
  341.  *  void
  342.  *****************************************************************************/
  343. void mmi_msg_club_entry_level_2(void)
  344. {
  345.     /*----------------------------------------------------------------*/
  346.     /* Local Variables                                                */
  347.     /*----------------------------------------------------------------*/
  348.     U8 *guiBuffer = NULL;
  349.     S32 hiliteitem = 0;
  350.     U8 *itemList[MSG_CLUB_MENUITEM_NUM];
  351.     U8 itemNum = MSGClubScreen[MSGClubCount].childNum;
  352.     U8 i;
  353.     U8 *captionStr;
  354.     msg_club_entry_dy_db_zf_struct *itemInfo =
  355.         (msg_club_entry_dy_db_zf_struct*) MSGClubScreen[MSGClubCount].childEntry;
  356.     /*----------------------------------------------------------------*/
  357.     /* Code Body                                                      */
  358.     /*----------------------------------------------------------------*/
  359.     EntryNewScreen(SCR_ID_MSG_CLUB_LEVEL_2, NULL, mmi_msg_club_entry_level_2, NULL);
  360.     guiBuffer = GetCurrGuiBuffer(SCR_ID_MSG_CLUB_LEVEL_2);
  361.     for (i = 0; i < MSGClubScreen[MSGClubCount].childNum; i++)
  362.     {
  363.     #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  364.         itemList[i] = (U8*) get_string_lang(itemInfo[i].stringID, SSC_ENGLISH);
  365.     #else 
  366.         itemList[i] = (U8*) GetString(itemInfo[i].stringID);
  367.     #endif 
  368.     }
  369.     RegisterHighlightHandler(mmi_msg_club_level_2_get_index);
  370. #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  371.     captionStr = (U8*) get_string_lang(MSGClubMenuItem[msg_club_level_1_index].stringID, SSC_ENGLISH);
  372. #else 
  373.     captionStr = (U8*) GetString(MSGClubMenuItem[msg_club_level_1_index].stringID);
  374. #endif 
  375.     ShowCategory353Screen(
  376.         captionStr,
  377.         IMG_MESSAGE_CLUB_ID,
  378.         STR_GLOBAL_OK,
  379.         IMG_GLOBAL_OK,
  380.         STR_GLOBAL_BACK,
  381.         IMG_GLOBAL_BACK,
  382.         itemNum,
  383.         itemList,
  384.         (U16*) gIndexIconsImageList,
  385.         NULL,
  386.         0,
  387.         0,
  388.         guiBuffer);
  389.     SetLeftSoftkeyFunction(mmi_msg_club_pre_entry_level_3, KEY_EVENT_UP);
  390.     SetKeyHandler(mmi_msg_club_pre_entry_level_3, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  391.     SetRightSoftkeyFunction(mmi_msg_club_go_back_menu, KEY_EVENT_UP);
  392.     SetKeyHandler(mmi_msg_club_go_back_menu, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  393. }
  394. /*****************************************************************************
  395.  * FUNCTION
  396.  *  mmi_msg_club_level_1_get_index
  397.  * DESCRIPTION
  398.  *  
  399.  * PARAMETERS
  400.  *  nIndex      [IN]        
  401.  * RETURNS
  402.  *  void
  403.  *****************************************************************************/
  404. void mmi_msg_club_level_1_get_index(S32 nIndex)
  405. {
  406.     /*----------------------------------------------------------------*/
  407.     /* Local Variables                                                */
  408.     /*----------------------------------------------------------------*/
  409.     /*----------------------------------------------------------------*/
  410.     /* Code Body                                                      */
  411.     /*----------------------------------------------------------------*/
  412.     msg_club_level_1_index = (U8) nIndex;
  413. }
  414. /*****************************************************************************
  415.  * FUNCTION
  416.  *  mmi_msg_club_pre_entry_menu
  417.  * DESCRIPTION
  418.  *  
  419.  * PARAMETERS
  420.  *  void
  421.  * RETURNS
  422.  *  void
  423.  *****************************************************************************/
  424. void mmi_msg_club_pre_entry_menu(void)
  425. {
  426.     /*----------------------------------------------------------------*/
  427.     /* Local Variables                                                */
  428.     /*----------------------------------------------------------------*/
  429.     /*----------------------------------------------------------------*/
  430.     /* Code Body                                                      */
  431.     /*----------------------------------------------------------------*/
  432.     MSGClubCount++;
  433.     memcpy(
  434.         (S8*) & MSGClubScreen[MSGClubCount],
  435.         (S8*) & MSGClubMenuItem[msg_club_level_1_index],
  436.         sizeof(msg_club_entry_menu_struct));
  437.     if ((MSGClubScreen[MSGClubCount].childType & MSG_CLUB_MENU) == MSG_CLUB_MENU)
  438.     {
  439.         mmi_msg_club_entry_level_1();
  440.     }
  441.     else if ((MSGClubScreen[MSGClubCount].childType & MSG_CLUB_VOICE_MENU) == MSG_CLUB_VOICE_MENU)
  442.     {
  443.         mmi_msg_club_entry_voice_submenu();
  444.     }
  445.     else if (MSGClubScreen[MSGClubCount].childNum > 0)
  446.     {
  447.         mmi_msg_club_entry_level_2();
  448.     }
  449.     else
  450.     {
  451.         msg_club_entry_dy_db_zf_struct *itemInfo =
  452.             (msg_club_entry_dy_db_zf_struct*) MSGClubScreen[MSGClubCount].childEntry;
  453.         memcpy((S8*) & MSGClubSMSItem, (S8*) & itemInfo[0], sizeof(msg_club_entry_dy_db_zf_struct));
  454.         memset((S8*) & MSGClubScreen[MSGClubCount], 0, sizeof(msg_club_entry_menu_struct));
  455.         MSGClubCount--;
  456.         if ((strcmp((S8*) MSGClubSMSItem.codeDY.codeNum, "") != 0)
  457.             || (strcmp((S8*) MSGClubSMSItem.codeDB.codeNum, "") != 0))
  458.         {
  459.             mmi_msg_club_entry_level_3();
  460.         }
  461.         else
  462.         {
  463.             if (strcmp((S8*) MSGClubSMSItem.codeZF.codeNum, "") != 0)
  464.             {
  465.                 msg_club_level_3_index = MSG_CLUB_SERVICE_EXPLAIN;
  466.             }
  467.             else
  468.             {
  469.                 msg_club_level_3_index = MSG_CLUB_SERVICE_CANCEL;
  470.             }
  471.             mmi_msg_club_pre_entry_send_msg();
  472.         }
  473.     }
  474. }
  475. /*****************************************************************************
  476.  * FUNCTION
  477.  *  mmi_msg_club_entry_level_1
  478.  * DESCRIPTION
  479.  *  
  480.  * PARAMETERS
  481.  *  void
  482.  * RETURNS
  483.  *  void
  484.  *****************************************************************************/
  485. void mmi_msg_club_entry_level_1(void)
  486. {
  487.     /*----------------------------------------------------------------*/
  488.     /* Local Variables                                                */
  489.     /*----------------------------------------------------------------*/
  490.     U8 *guiBuffer = NULL;
  491.     U8 *itemList[MSG_CLUB_MENUITEM_NUM];
  492.     U8 itemNum = 0;
  493.     U8 i, j = 0;
  494.     U8 *captionStr;
  495.     msg_club_entry_menu_struct *itemInfo = (msg_club_entry_menu_struct*) MSGClubScreen[MSGClubCount].childEntry;
  496.     U16 scrIndex = SCR_ID_MSG_CLUB_LEVEL_1 + (U16) MSGClubCount;
  497.     /*----------------------------------------------------------------*/
  498.     /* Code Body                                                      */
  499.     /*----------------------------------------------------------------*/
  500.     EntryNewScreen(scrIndex, NULL, mmi_msg_club_entry_level_1, NULL);
  501.     guiBuffer = GetCurrGuiBuffer(scrIndex);
  502.     for (i = 0; i < MSGClubScreen[MSGClubCount].childNum; i++)
  503.     {
  504.         if (((itemInfo[i].childType & MSG_CLUB_CT_ONLY) == MSG_CLUB_CT_ONLY) && (MSGClubNetwork != MSG_CLUB_CT))
  505.         {
  506.             continue;
  507.         }
  508.     #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  509.         itemList[j] = (U8*) get_string_lang(itemInfo[i].stringID, SSC_ENGLISH);
  510.     #else 
  511.         itemList[j] = (U8*) GetString(itemInfo[i].stringID);
  512.     #endif 
  513.         memcpy((S8*) & MSGClubMenuItem[j], (S8*) & itemInfo[i], sizeof(msg_club_entry_menu_struct));
  514.         j++;
  515.     }
  516.     itemNum = j;
  517.     RegisterHighlightHandler(mmi_msg_club_level_1_get_index);
  518. #ifdef __MMI_MESSAGES_CLUB_SIM_CHINESE__
  519.     captionStr = (U8*) get_string_lang(MSGClubScreen[MSGClubCount].stringID, SSC_ENGLISH);
  520. #else 
  521.     captionStr = (U8*) GetString(MSGClubScreen[MSGClubCount].stringID);
  522. #endif 
  523.     ShowCategory353Screen(
  524.         captionStr,
  525.         IMG_MESSAGE_CLUB_ID,
  526.         STR_GLOBAL_OK,
  527.         IMG_GLOBAL_OK,
  528.         STR_GLOBAL_BACK,
  529.         IMG_GLOBAL_BACK,
  530.         itemNum,
  531.         itemList,
  532.         (U16*) gIndexIconsImageList,
  533.         NULL,
  534.         0,
  535.         0,
  536.         guiBuffer);
  537.     SetLeftSoftkeyFunction(mmi_msg_club_pre_entry_menu, KEY_EVENT_UP);
  538.     SetKeyHandler(mmi_msg_club_pre_entry_menu, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  539.     SetRightSoftkeyFunction(mmi_msg_club_go_back_menu, KEY_EVENT_UP);
  540.     SetKeyHandler(mmi_msg_club_go_back_menu, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  541. }
  542. /*****************************************************************************
  543.  * FUNCTION
  544.  *  EntryMsgClub
  545.  * DESCRIPTION
  546.  *  
  547.  * PARAMETERS
  548.  *  void
  549.  * RETURNS
  550.  *  void
  551.  *****************************************************************************/
  552. void EntryMsgClub(void)
  553. {
  554.     /*----------------------------------------------------------------*/
  555.     /* Local Variables                                                */
  556.     /*----------------------------------------------------------------*/
  557.     /*----------------------------------------------------------------*/
  558.     /* Code Body                                                      */
  559.     /*----------------------------------------------------------------*/
  560.     /* micha0422 */
  561.     if ((strncmp(gHomePLMNNum, "46000", 5) == 0) || (strncmp(gHomePLMNNum, "46002", 5) == 0))
  562.     {
  563.         MSGClubNetwork = MSG_CLUB_CT;
  564.     }
  565.     else if (strncmp(gHomePLMNNum, "46001", 5) == 0)
  566.     {
  567.         MSGClubNetwork = MSG_CLUB_CU;
  568.     }
  569.     else
  570.     {
  571.         MSGClubNetwork = MSG_CLUB_NETWORK_TOTAL;
  572.     }
  573.     if (MSGClubNetwork == MSG_CLUB_NETWORK_TOTAL)
  574.     {
  575.         DisplayPopup(
  576.             (PU8) GetString(STR_SMS_DOES_NOT_SUPPORT),
  577.             IMG_GLOBAL_UNFINISHED,
  578.             1,
  579.             MESSAGES_POPUP_TIME_OUT,
  580.             (U8) ERROR_TONE);
  581.     }
  582.     else
  583.     {
  584.         MSGClubCount = 0;
  585.         memset(MSGClubScreen, 0, sizeof(msg_club_entry_menu_struct) * MSG_CLUB_SCREEN_NUM);
  586.         MSGClubScreen[0].stringID = STR_MSG_CLUB;
  587.         MSGClubScreen[0].childNum = mmi_msg_club_get_item_total();
  588.         MSGClubScreen[0].childType = MSG_CLUB_MENU;
  589.         MSGClubScreen[0].childEntry = (void*)MenuMSGClub;
  590.         mmi_msg_club_entry_level_1();
  591.     }
  592. }
  593. #endif /* __MMI_MESSAGES_CLUB__ */ 
  594. #ifdef __MMI_UNIFIED_MESSAGE__
  595. /*****************************************************************************
  596.  * FUNCTION
  597.  *  mmi_msg_um_entry_msg
  598.  * DESCRIPTION
  599.  *  entry sms msg
  600.  *  void
  601.  * RETURNS
  602.  *  void
  603.  *****************************************************************************/
  604. void mmi_msg_um_entry_msg(UmMsgBoxType msg_box_type, kal_uint16 msg_index)
  605. {
  606.     /*----------------------------------------------------------------*/
  607.     /* Local Variables                                                */
  608.     /*----------------------------------------------------------------*/
  609.     UmMsgBoxType type = msg_box_type;
  610.     /*----------------------------------------------------------------*/
  611.     /* Code Body                                                      */
  612.     /*----------------------------------------------------------------*/
  613.     g_msg_cntx.currBoxIndex = msg_index;
  614.     switch (type)
  615.     {
  616.     #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  617.         case UM_MSG_BOX_TYPE_INBOX:
  618.         {
  619.             /* Update the totalinbox value in order to get the current inbox list size  */
  620.             msgbox_info.totalinbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
  621.             mmi_msg_pre_entry_list_option_req(MMI_FRM_SMS_APP_INBOX);            
  622.             break;
  623.         }
  624.         case UM_MSG_BOX_TYPE_SENT:
  625.         {            
  626.             mmi_msg_pre_entry_list_option_req(MMI_FRM_SMS_APP_OUTBOX);
  627.             break;
  628.         }
  629.         case UM_MSG_BOX_TYPE_UNSENT:
  630.         case UM_MSG_BOX_TYPE_DRAFT:
  631.         {
  632.             mmi_msg_pre_entry_list_option_req(MMI_FRM_SMS_APP_DRAFTS);
  633.             break;
  634.         }
  635.     #else /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  636.         case UM_MSG_BOX_TYPE_INBOX:
  637.         {
  638.             /* Update the totalinbox value in order to get the current inbox list size  */
  639.             msgbox_info.totalinbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
  640.             mmi_msg_get_msg_inbox();
  641.             break;
  642.         }
  643.         case UM_MSG_BOX_TYPE_SENT:
  644.         {
  645.             mmi_msg_get_msg_outbox();
  646.             break;
  647.         }
  648.         case UM_MSG_BOX_TYPE_UNSENT:
  649.         case UM_MSG_BOX_TYPE_DRAFT:
  650.         {
  651.             mmi_msg_get_msg_draftbox();
  652.             break;
  653.         }
  654.     #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */                    
  655.         default:
  656.         {
  657.             MMI_ASSERT(0);
  658.             break;
  659.         }
  660.     }
  661. }
  662. /*****************************************************************************
  663.  * FUNCTION
  664.  *  mmi_msg_um_entry_write
  665.  * DESCRIPTION
  666.  *  entry function for sms editor by Unified Message
  667.  * PARAMETERS
  668.  *  void
  669.  * RETURNS
  670.  *  void
  671.  *****************************************************************************/
  672. void mmi_msg_um_entry_write(void)
  673. {
  674.     /*----------------------------------------------------------------*/
  675.     /* Local Variables                                                */
  676.     /*----------------------------------------------------------------*/
  677.     /*----------------------------------------------------------------*/
  678.     /* Code Body                                                      */
  679.     /*----------------------------------------------------------------*/
  680.     g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY;
  681.     g_msg_cntx.PhbSmsInterfaceState = MMI_SEND_ONLY;
  682.     mmi_msg_entry_write_msg();
  683. }
  684. /*****************************************************************************
  685.  * FUNCTION
  686.  *  mmi_msg_um_entry_template
  687.  * DESCRIPTION
  688.  *  entry function for sms template
  689.  * PARAMETERS
  690.  *  void
  691.  * RETURNS
  692.  *  void
  693.  *****************************************************************************/
  694. void mmi_msg_um_entry_template(void)
  695. {
  696.     /*----------------------------------------------------------------*/
  697.     /* Local Variables                                                */
  698.     /*----------------------------------------------------------------*/
  699.     /*----------------------------------------------------------------*/
  700.     /* Code Body                                                      */
  701.     /*----------------------------------------------------------------*/
  702.     mmi_msg_entry_template_list();
  703. }
  704. /*****************************************************************************
  705.  * FUNCTION
  706.  *  mmi_msg_um_entry_setting
  707.  * DESCRIPTION
  708.  *  entry function for sms setting
  709.  * PARAMETERS
  710.  *  void
  711.  * RETURNS
  712.  *  void
  713.  *****************************************************************************/
  714. void mmi_msg_um_entry_setting(void)
  715. {
  716.     /*----------------------------------------------------------------*/
  717.     /* Local Variables                                                */
  718.     /*----------------------------------------------------------------*/
  719.     /*----------------------------------------------------------------*/
  720.     /* Code Body                                                      */
  721.     /*----------------------------------------------------------------*/
  722.     mmi_msg_pre_entry_msg_settings();
  723. }
  724. /*****************************************************************************
  725.  * FUNCTION
  726.  *  mmi_msg_set_background_process
  727.  * DESCRIPTION
  728.  *  set if SMS is in the background process
  729.  * PARAMETERS
  730.  *  flag        [IN]        
  731.  * RETURNS
  732.  *  void
  733.  *****************************************************************************/
  734. void mmi_msg_set_background_process(kal_bool flag)
  735. {
  736.     /*----------------------------------------------------------------*/
  737.     /* Local Variables                                                */
  738.     /*----------------------------------------------------------------*/
  739.     /*----------------------------------------------------------------*/
  740.     /* Code Body                                                      */
  741.     /*----------------------------------------------------------------*/
  742.     g_msg_cntx.is_background_process = (U8) flag;
  743. }
  744. /*****************************************************************************
  745.  * FUNCTION
  746.  *  mmi_msg_check_background_process
  747.  * DESCRIPTION
  748.  *  check if SMS is in the background process
  749.  * PARAMETERS
  750.  *  void
  751.  * RETURNS
  752.  *  void
  753.  *****************************************************************************/
  754. kal_bool mmi_msg_check_background_process(void)
  755. {
  756.     /*----------------------------------------------------------------*/
  757.     /* Local Variables                                                */
  758.     /*----------------------------------------------------------------*/
  759.     /*----------------------------------------------------------------*/
  760.     /* Code Body                                                      */
  761.     /*----------------------------------------------------------------*/
  762.     if (g_msg_cntx.is_background_process)
  763.     {
  764.         return KAL_TRUE;
  765.     }
  766.     else
  767.     {
  768.         return KAL_FALSE;
  769.     }
  770. }
  771. /*****************************************************************************
  772.  * FUNCTION
  773.  *  mmi_msg_set_post_send_action_type
  774.  * DESCRIPTION
  775.  *  set the type of action after send
  776.  * PARAMETERS
  777.  *  action      [IN]        
  778.  * RETURNS
  779.  *  void
  780.  *****************************************************************************/
  781. void mmi_msg_set_post_send_action_type(U8 action)
  782. {
  783.     /*----------------------------------------------------------------*/
  784.     /* Local Variables                                                */
  785.     /*----------------------------------------------------------------*/
  786.     /*----------------------------------------------------------------*/
  787.     /* Code Body                                                      */
  788.     /*----------------------------------------------------------------*/
  789.     g_msg_cntx.post_send_action = action;
  790. }
  791. /*****************************************************************************
  792.  * FUNCTION
  793.  *  mmi_msg_get_post_send_action_type
  794.  * DESCRIPTION
  795.  *  get post send action type
  796.  * PARAMETERS
  797.  *  void
  798.  * RETURNS
  799.  *  void
  800.  *****************************************************************************/
  801. U8 mmi_msg_get_post_send_action_type(void)
  802. {
  803.     /*----------------------------------------------------------------*/
  804.     /* Local Variables                                                */
  805.     /*----------------------------------------------------------------*/
  806.     /*----------------------------------------------------------------*/
  807.     /* Code Body                                                      */
  808.     /*----------------------------------------------------------------*/
  809.     return g_msg_cntx.post_send_action;
  810. }
  811. /*****************************************************************************
  812.  * FUNCTION
  813.  *  mmi_msg_get_msg_num
  814.  * DESCRIPTION
  815.  *  get sms msg number of each msg box
  816.  * PARAMETERS
  817.  *  inbox_msg_number            [?]     
  818.  *  inbox_unread_msg_number     [?]     
  819.  *  unsent_msg_number           [?]     
  820.  *  sent_msg_number             [?]     
  821.  *  draft_msg_number            [?]     
  822.  * RETURNS
  823.  *  void
  824.  *****************************************************************************/
  825. kal_bool mmi_msg_get_msg_num(
  826.             kal_uint16 *inbox_msg_number,
  827.             kal_uint16 *inbox_unread_msg_number,
  828.             kal_uint16 *unsent_msg_number,
  829.             kal_uint16 *sent_msg_number,
  830.             kal_uint16 *draft_msg_number)
  831. {
  832.     /*----------------------------------------------------------------*/
  833.     /* Local Variables                                                */
  834.     /*----------------------------------------------------------------*/
  835.     kal_uint16 i = 0;
  836.     U8 type = 0;
  837.     /*----------------------------------------------------------------*/
  838.     /* Code Body                                                      */
  839.     /*----------------------------------------------------------------*/
  840.     if (*inbox_msg_number == MMI_FRM_SMS_INVALID_INDEX)
  841.     {
  842.         return KAL_FALSE;
  843.     }
  844.     *inbox_msg_number = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_INBOX);
  845.     *sent_msg_number = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_OUTBOX);
  846.     *inbox_unread_msg_number = 0;
  847.     *unsent_msg_number = 0;
  848.     *draft_msg_number = 0;
  849.     while (i < *inbox_msg_number)
  850.     {
  851.         type = mmi_frm_sms_get_status(MMI_FRM_SMS_APP_INBOX, i) & 0x0f;
  852.         if (type == MMI_FRM_SMS_APP_UNREAD)
  853.         {
  854.             (*inbox_unread_msg_number)++;
  855.         }
  856.         i++;
  857.     }
  858.     mmi_frm_sms_get_unsent_msg_num(unsent_msg_number);
  859.     mmi_frm_sms_get_draft_msg_num(draft_msg_number);
  860.     return KAL_TRUE;
  861. }
  862. /*****************************************************************************
  863.  * FUNCTION
  864.  *  mmi_msg_get_list_info
  865.  * DESCRIPTION
  866.  *  get sms list info
  867.  * PARAMETERS
  868.  *  msg_box_type        [IN]        
  869.  *  start_entry         [IN]        
  870.  *  max_msg_number      [IN]        
  871.  *  msg_number          [?]         
  872.  *  list_info           [?]         
  873.  *  more                [?]         
  874.  * RETURNS
  875.  *  void
  876.  *****************************************************************************/
  877. kal_bool mmi_msg_get_list_info(
  878.             UmMsgBoxType msg_box_type,
  879.             kal_uint16 start_entry,
  880.             kal_uint16 max_msg_number,
  881.             kal_uint16 *msg_number,
  882.             mmi_um_list_info_struct *list_info,
  883.             kal_bool *more)
  884. {
  885.     /*----------------------------------------------------------------*/
  886.     /* Local Variables                                                */
  887.     /*----------------------------------------------------------------*/
  888.     kal_uint16 msg_list_index = start_entry;
  889.     kal_uint16 i = 0;
  890.     U8 *timestamp = NULL;
  891.     U8 sms_msg_box_type = 0;
  892.     kal_uint16 sms_msg_box_size = 0;
  893.     /*----------------------------------------------------------------*/
  894.     /* Code Body                                                      */
  895.     /*----------------------------------------------------------------*/
  896.     *msg_number = 0;
  897.     switch (msg_box_type)
  898.     {
  899.         case UM_MSG_BOX_TYPE_INBOX:
  900.         {
  901.             sms_msg_box_type = MMI_FRM_SMS_INBOX;
  902.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_INBOX);
  903.             break;
  904.         }
  905.         case UM_MSG_BOX_TYPE_UNSENT:
  906.         {
  907.             sms_msg_box_type = MMI_FRM_SMS_UNSENT;
  908.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_UNSENT);
  909.             break;
  910.         }
  911.         case UM_MSG_BOX_TYPE_SENT:
  912.         {
  913.             sms_msg_box_type = MMI_FRM_SMS_OUTBOX;
  914.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_OUTBOX);
  915.             break;
  916.         }
  917.         case UM_MSG_BOX_TYPE_DRAFT:
  918.         {
  919.             sms_msg_box_type = MMI_FRM_SMS_DRAFTS;
  920.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_DRAFTS);
  921.             break;
  922.         }
  923.         default:
  924.         {
  925.             MMI_ASSERT(0);
  926.             break;
  927.         }
  928.     }
  929.     for (; (i < max_msg_number); i++)
  930.     {
  931.         UI_time datetime;
  932.         if (msg_box_type == UM_MSG_BOX_TYPE_UNSENT)
  933.         {
  934.             if (!mmi_frm_sms_get_next_unsent_msg(&msg_list_index))
  935.             {
  936.                 *more = KAL_FALSE;
  937.                 return KAL_TRUE;
  938.             }
  939.         }
  940.         else if (msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  941.         {
  942.             if (!mmi_frm_sms_get_next_draft_msg(&msg_list_index))
  943.             {
  944.                 *more = KAL_FALSE;
  945.                 return KAL_TRUE;
  946.             }
  947.         }
  948.         /* For inbox and sent */
  949.         else
  950.         {
  951.             if (msg_list_index >= sms_msg_box_size)
  952.             {
  953.                 *more = KAL_FALSE;
  954.                 return KAL_TRUE;
  955.             }
  956.         }
  957.         timestamp = mmi_frm_sms_get_timestamp(sms_msg_box_type, msg_list_index);
  958.         if (timestamp[1] == 0)
  959.         {
  960.             list_info[i].timestamp = 0;
  961.         }
  962.         else
  963.         {
  964.             datetime.nYear = timestamp[0] + 2000;
  965.             if (datetime.nYear > 2090)
  966.             {
  967.                 datetime.nYear = datetime.nYear - 100;
  968.             }
  969.             datetime.nMonth = timestamp[1];
  970.             datetime.nDay = timestamp[2];
  971.             datetime.nHour = timestamp[3];
  972.             datetime.nMin = timestamp[4];
  973.             datetime.nSec = timestamp[5];
  974.         #ifdef MMI_ON_HARDWARE_P
  975.             list_info[i].timestamp = mmi_dt_mytime_2_utc_sec((MYTIME*) & datetime, MMI_TRUE);
  976.         #endif 
  977.         }
  978.         list_info[i].msg_index = msg_list_index;
  979.         (*msg_number)++;
  980.         msg_list_index++;
  981.     }
  982.     /* For inbox and sent */
  983.     if (msg_list_index < sms_msg_box_size)
  984.     {
  985.         *more = KAL_TRUE;
  986.     }
  987.     else
  988.     {
  989.         *more = KAL_FALSE;
  990.     }
  991.     return KAL_TRUE;
  992. }
  993. /*****************************************************************************
  994.  * FUNCTION
  995.  *  mmi_msg_get_msg_info
  996.  * DESCRIPTION
  997.  *  get sms msg info
  998.  * PARAMETERS
  999.  *  msg_box_type        [IN]        
  1000.  *  start_entry         [IN]        
  1001.  *  req_msg_number      [IN]        
  1002.  *  rsp_msg_number      [?]         
  1003.  *  msg_info            [?]         
  1004.  * RETURNS
  1005.  *  void
  1006.  *****************************************************************************/
  1007. kal_bool mmi_msg_get_msg_info(
  1008.             UmMsgBoxType msg_box_type,
  1009.             kal_uint16 start_entry,
  1010.             kal_uint16 req_msg_number,
  1011.             kal_uint16 *rsp_msg_number,
  1012.             mmi_um_msg_info_struct *msg_info)
  1013. {
  1014.     /*----------------------------------------------------------------*/
  1015.     /* Local Variables                                                */
  1016.     /*----------------------------------------------------------------*/
  1017.     kal_uint16 msg_list_index = start_entry;
  1018.     kal_uint16 i = 0;
  1019.     U8 *timestamp = NULL;
  1020.     U8 sms_msg_box_type = 0;
  1021.     kal_uint16 sms_msg_box_size = 0;
  1022.     /*----------------------------------------------------------------*/
  1023.     /* Code Body                                                      */
  1024.     /*----------------------------------------------------------------*/
  1025.     *rsp_msg_number = 0;
  1026.     switch (msg_box_type)
  1027.     {
  1028.         case UM_MSG_BOX_TYPE_INBOX:
  1029.         {
  1030.             sms_msg_box_type = MMI_FRM_SMS_INBOX;
  1031.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_INBOX);
  1032.             break;
  1033.         }
  1034.         case UM_MSG_BOX_TYPE_UNSENT:
  1035.         {
  1036.             sms_msg_box_type = MMI_FRM_SMS_UNSENT;
  1037.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_UNSENT);
  1038.             break;
  1039.         }
  1040.         case UM_MSG_BOX_TYPE_SENT:
  1041.         {
  1042.             sms_msg_box_type = MMI_FRM_SMS_OUTBOX;
  1043.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_OUTBOX);
  1044.             break;
  1045.         }
  1046.         case UM_MSG_BOX_TYPE_DRAFT:
  1047.         {
  1048.             sms_msg_box_type = MMI_FRM_SMS_DRAFTS;
  1049.             sms_msg_box_size = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_DRAFTS);
  1050.             break;
  1051.         }
  1052.         default:
  1053.         {
  1054.             MMI_ASSERT(0);
  1055.             break;
  1056.         }
  1057.     }
  1058.     for (; (i < req_msg_number); i++)
  1059.     {
  1060.         UI_time datetime;
  1061.         U8 sms_status;
  1062.         if (msg_box_type == UM_MSG_BOX_TYPE_UNSENT)
  1063.         {
  1064.             if (!mmi_frm_sms_get_next_unsent_msg(&msg_list_index))
  1065.             {
  1066.                 return KAL_TRUE;
  1067.             }
  1068.         }
  1069.         else if (msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  1070.         {
  1071.             if (!mmi_frm_sms_get_next_draft_msg(&msg_list_index))
  1072.             {
  1073.                 return KAL_TRUE;
  1074.             }
  1075.         }
  1076.         else
  1077.         {
  1078.             if (msg_list_index >= sms_msg_box_size)
  1079.             {
  1080.                 break;
  1081.             }
  1082.         }
  1083.         timestamp = mmi_frm_sms_get_timestamp(sms_msg_box_type, msg_list_index);
  1084.         if (timestamp[1] == 0)
  1085.         {
  1086.             msg_info[i].timestamp = 0;
  1087.         }
  1088.         else
  1089.         {
  1090.             datetime.nYear = timestamp[0] + 2000;
  1091.             if (datetime.nYear > 2090)
  1092.             {
  1093.                 datetime.nYear = datetime.nYear - 100;
  1094.             }
  1095.             datetime.nMonth = timestamp[1];
  1096.             datetime.nDay = timestamp[2];
  1097.             datetime.nHour = timestamp[3];
  1098.             datetime.nMin = timestamp[4];
  1099.             datetime.nSec = timestamp[5];
  1100.         #ifdef MMI_ON_HARDWARE_P
  1101.             msg_info[i].timestamp = mmi_dt_mytime_2_utc_sec((MYTIME*) & datetime, MMI_TRUE);
  1102.         #endif 
  1103.         }
  1104.         msg_info[i].msg_index = msg_list_index;
  1105.         msg_info[i].address_type = UM_ADDR_TYPE_PHONE_NUMBER;
  1106.         mmi_msg_get_address(sms_msg_box_type, msg_list_index, msg_info[i].address, MMI_UM_MAX_ADDR_LEN);
  1107.         msg_info[i].address_length = pfnUnicodeStrlen((S8*) msg_info[i].address);
  1108.         sms_status = mmi_frm_sms_get_sms_status(sms_msg_box_type, msg_list_index);
  1109.         if (!mmi_frm_sms_check_complete(sms_msg_box_type, msg_list_index))
  1110.         {
  1111.             pfnUnicodeStrncpy(
  1112.                 (S8*) msg_info[i].subject,
  1113.                 (S8*) GetString(STR_UM_INCOMPLETE_ID),
  1114.                 MMI_UM_MAX_SUBJECT_LEN);
  1115.             msg_info[i].subject_length = pfnUnicodeStrlen((S8*) GetString(STR_UM_INCOMPLETE_ID));
  1116.         }
  1117.         else if ((sms_status >> 4) == SMSAL_MTI_STATUS_REPORT)
  1118.         {
  1119.             pfnUnicodeStrncpy(
  1120.                 (S8*) msg_info[i].subject,
  1121.                 (S8*) GetString(STR_DELIVERY_REPORT_MENUENTRY),
  1122.                 MMI_UM_MAX_SUBJECT_LEN);
  1123.             msg_info[i].subject_length = pfnUnicodeStrlen((S8*) GetString(STR_DELIVERY_REPORT_MENUENTRY));
  1124.         }
  1125.         else if ((sms_status >> 4) == SMSAL_MTI_UNSPECIFIED)
  1126.         {
  1127.             pfnUnicodeStrncpy(
  1128.                 (S8*) msg_info[i].subject,
  1129.                 (S8*) GetString(STR_UM_NOT_SUPPORT_ID),
  1130.                 MMI_UM_MAX_SUBJECT_LEN);
  1131.             msg_info[i].subject_length = pfnUnicodeStrlen((S8*) GetString(STR_UM_NOT_SUPPORT_ID));
  1132.         }
  1133.         else
  1134.         {
  1135.             mmi_frm_sms_get_content(
  1136.                 sms_msg_box_type,
  1137.                 msg_list_index,
  1138.                 msg_info[i].subject,
  1139.                 (kal_uint8) mmi_msg_get_max_content_size());
  1140.             msg_info[i].subject_length = pfnUnicodeStrlen((S8*) msg_info[i].subject);
  1141.         #ifdef __MMI_MESSAGES_CHAT__
  1142.             if (CheckForInvitationMsg((U8*) msg_info[i].subject, msg_info[i].subject_length * 2, FALSE))
  1143.             {
  1144.                 S8 *chat_invitation_pattern = mmi_msg_chat_get_invitation_pattern();
  1145.                 U8 len = pfnUnicodeStrlen(chat_invitation_pattern);
  1146.                 memcpy(
  1147.                     (S8*) msg_info[i].subject,
  1148.                     (S8*) (msg_info[i].subject + len),
  1149.                     (msg_info[i].subject_length - len) * ENCODING_LENGTH);
  1150.                 memset(
  1151.                     (S8*) (msg_info[i].subject + (msg_info[i].subject_length - len) * ENCODING_LENGTH),
  1152.                     0,
  1153.                     len * ENCODING_LENGTH);
  1154.                 msg_info[i].subject_length -= len;
  1155.             }
  1156.         #endif /* __MMI_MESSAGES_CHAT__ */ 
  1157.         }
  1158.         msg_info[i].icon_id = mmi_msg_get_icon(sms_msg_box_type, msg_list_index);
  1159.         (*rsp_msg_number)++;
  1160.         msg_list_index++;
  1161.     }
  1162.     return KAL_TRUE;
  1163. }
  1164. /*****************************************************************************
  1165.  * FUNCTION
  1166.  *  mmi_msg_get_address
  1167.  * DESCRIPTION
  1168.  *  get sms address
  1169.  * PARAMETERS
  1170.  *  msg_type            [IN]        
  1171.  *  msg_index           [IN]        
  1172.  *  address             [?]         
  1173.  *  max_address_len     [IN]        
  1174.  * RETURNS
  1175.  *  void
  1176.  *****************************************************************************/
  1177. void mmi_msg_get_address(kal_uint8 msg_type, kal_uint16 msg_index, kal_wchar *address, kal_uint8 max_address_len)
  1178. {
  1179.     /*----------------------------------------------------------------*/
  1180.     /* Local Variables                                                */
  1181.     /*----------------------------------------------------------------*/
  1182.     S8 temp[(MAX_DIGITS_SMS + 1) * ENCODING_LENGTH];
  1183.     S8 *name;
  1184.     U8 type = msg_type;
  1185.     kal_uint16 index = msg_index;
  1186.     /*----------------------------------------------------------------*/
  1187.     /* Code Body                                                      */
  1188.     /*----------------------------------------------------------------*/
  1189.     if (((mmi_frm_sms_get_status(type, index) & 0xf0) >> 4) == SMSAL_MTI_STATUS_REPORT)
  1190.     {
  1191.         pfnUnicodeStrncpy((S8*) address, (S8*) GetString(STR_INBOX_REPORT_ID), max_address_len);
  1192.     }
  1193.     else
  1194.     {
  1195.         memset(temp, 0, (MAX_DIGITS_SMS + 1) * ENCODING_LENGTH);
  1196.         AnsiiToUnicodeString(temp, (S8*) mmi_frm_sms_get_address(type, index));
  1197.         if (pfnUnicodeStrlen(temp) == 0)
  1198.         {
  1199.             pfnUnicodeStrcpy((S8*) address, (S8*) GetString(STR_OUTBOX_LIST_MESSAGE));
  1200.         }
  1201.         else
  1202.         {
  1203.             name = lookUpNumber(temp);
  1204.             if (pfnUnicodeStrlen(name))
  1205.             {
  1206.                 pfnUnicodeStrcpy((S8*) address, name);
  1207.             }
  1208.             else
  1209.             {
  1210.                 pfnUnicodeStrcpy((S8*) address, temp);
  1211.             }
  1212.         }
  1213.     }
  1214. }
  1215. /*****************************************************************************
  1216.  * FUNCTION
  1217.  *  mmi_msg_get_icon
  1218.  * DESCRIPTION
  1219.  *  get sms icon id
  1220.  * PARAMETERS
  1221.  *  msg_type        [IN]        
  1222.  *  msg_index       [IN]        
  1223.  * RETURNS
  1224.  *  void
  1225.  *****************************************************************************/
  1226. kal_uint16 mmi_msg_get_icon(kal_uint8 msg_type, kal_uint16 msg_index)
  1227. {
  1228.     /*----------------------------------------------------------------*/
  1229.     /* Local Variables                                                */
  1230.     /*----------------------------------------------------------------*/
  1231.     kal_uint16 icon_id = 0;
  1232.     /*----------------------------------------------------------------*/
  1233.     /* Code Body                                                      */
  1234.     /*----------------------------------------------------------------*/
  1235.     if (msg_type == MMI_FRM_SMS_INBOX)
  1236.     {
  1237.         if ((mmi_frm_sms_get_status(msg_type, (U16) msg_index) & 0x0f) == MMI_FRM_SMS_APP_UNREAD)
  1238.         {
  1239.             icon_id = IMG_MESSAGE_UNREAD;
  1240.         }
  1241.         else
  1242.         {
  1243.             if (mmi_frm_sms_check_complete(msg_type, (U16) msg_index) == TRUE)
  1244.             {
  1245.                 icon_id = IMG_MESSAGE_READ;
  1246.             }
  1247.             else
  1248.             {
  1249.                 icon_id = IMG_MESSAGE_SS_NCOMP;
  1250.             }
  1251.         }
  1252.     }
  1253.     else
  1254.     {
  1255.         if (mmi_frm_sms_check_complete(msg_type, (U16) msg_index) == FALSE)
  1256.         {
  1257.             icon_id = IMG_MESSAGE_SS_NCOMP;
  1258.         }
  1259.         else
  1260.         {
  1261.             if (msg_type == MMI_FRM_SMS_OUTBOX)
  1262.             {
  1263.                 icon_id = IMG_MESSAGE_SENT;
  1264.             }
  1265.             else
  1266.             {
  1267.                 icon_id = IMG_MESSAGE_UNSENT;
  1268.             }
  1269.         }
  1270.     }
  1271.     return icon_id;
  1272. }
  1273. /*****************************************************************************
  1274.  * FUNCTION
  1275.  *  mmi_msg_handle_delete_folder_by_um
  1276.  * DESCRIPTION
  1277.  *  delete sms msg box
  1278.  * PARAMETERS
  1279.  *  msg_box_type        [IN]        
  1280.  * RETURNS
  1281.  *  void
  1282.  *****************************************************************************/
  1283. void mmi_msg_handle_delete_folder_by_um(UmMsgBoxType msg_box_type)
  1284. {
  1285.     /*----------------------------------------------------------------*/
  1286.     /* Local Variables                                                */
  1287.     /*----------------------------------------------------------------*/
  1288.     mmi_frm_sms_msgbox_enum sms_msg_box_type = 0;
  1289.     U16 index = MMI_FRM_SMS_INVALID_INDEX;
  1290.     U8 *bitmap = OslMalloc(sizeof(U8) * 480);
  1291.     /*----------------------------------------------------------------*/
  1292.     /* Code Body                                                      */
  1293.     /*----------------------------------------------------------------*/
  1294.     memset((S8*) bitmap, 0, sizeof(U8) * 480);
  1295.     if ((msg_box_type & UM_MSG_BOX_TYPE_INBOX))
  1296.     {
  1297.         sms_msg_box_type = MMI_FRM_SMS_INBOX;
  1298.         mmi_frm_sms_get_sms_bitmap((U8) sms_msg_box_type, index, bitmap);
  1299.     }
  1300.     if ((msg_box_type & UM_MSG_BOX_TYPE_SENT))
  1301.     {
  1302.         sms_msg_box_type = MMI_FRM_SMS_OUTBOX;
  1303.         mmi_frm_sms_get_sms_bitmap((U8) sms_msg_box_type, index, bitmap);
  1304.     }
  1305.     if ((msg_box_type & UM_MSG_BOX_TYPE_UNSENT))
  1306.     {
  1307.         U16 msg_list_index = 0;
  1308.         sms_msg_box_type = MMI_FRM_SMS_UNSENT;
  1309.         while (mmi_frm_sms_get_next_unsent_msg(&msg_list_index))
  1310.         {
  1311.             mmi_frm_sms_get_sms_bitmap((U8) sms_msg_box_type, msg_list_index, bitmap);
  1312.             msg_list_index++;
  1313.         }
  1314.     }
  1315.     if ((msg_box_type & UM_MSG_BOX_TYPE_DRAFT))
  1316.     {
  1317.         U16 msg_list_index = 0;
  1318.         sms_msg_box_type = MMI_FRM_SMS_DRAFTS;
  1319.         while (mmi_frm_sms_get_next_draft_msg(&msg_list_index))
  1320.         {
  1321.             mmi_frm_sms_get_sms_bitmap((U8) sms_msg_box_type, msg_list_index, bitmap);
  1322.             msg_list_index++;
  1323.         }
  1324.     }
  1325.     mmi_frm_sms_delete_sms_by_bitmap(mmi_msg_delete_folder_by_um_callback, MOD_MMI, bitmap);
  1326.     OslMfree(bitmap);
  1327. }
  1328. /*****************************************************************************
  1329.  * FUNCTION
  1330.  *  mmi_msg_delete_folder_by_um_callback
  1331.  * DESCRIPTION
  1332.  *  delete sms msg box
  1333.  * PARAMETERS
  1334.  *  dummy       [?]         
  1335.  *  mod         [IN]        
  1336.  *  result      [IN]        
  1337.  * RETURNS
  1338.  *  void
  1339.  *****************************************************************************/
  1340. void mmi_msg_delete_folder_by_um_callback(void *dummy, module_type mod, U16 result)
  1341. {
  1342.     /*----------------------------------------------------------------*/
  1343.     /* Local Variables                                                */
  1344.     /*----------------------------------------------------------------*/
  1345.     mmi_um_delete_folder_rsp_struct *msg =
  1346.         (mmi_um_delete_folder_rsp_struct*) OslConstructDataPtr(sizeof(mmi_um_delete_folder_rsp_struct));
  1347.     /*----------------------------------------------------------------*/
  1348.     /* Code Body                                                      */
  1349.     /*----------------------------------------------------------------*/
  1350.     if (result == MMI_FRM_SMS_OK)
  1351.     {
  1352.         msg->result = KAL_TRUE;
  1353.     }
  1354.     else
  1355.     {
  1356.         msg->result = KAL_FALSE;
  1357.     }
  1358.     if (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX) == 0)
  1359.     {
  1360.         mmi_msg_set_msg_icon(FALSE, FALSE);        
  1361.     }
  1362.     
  1363.     msg->msg_type = UM_MSG_TYPE_SMS;
  1364.     mmi_msg_send_message(MOD_MMI, MOD_MMI, 0, PRT_MSG_ID_MMI_UM_DELETE_FOLDER_RSP, (oslParaType*) msg, NULL);
  1365. }
  1366. #endif /* __MMI_UNIFIED_MESSAGE__ */
  1367. #if(!UI_DISABLE_EMS_CATEGORY_SCREENS)
  1368. #if(!EMS_USE_GSM_EXTENDED)
  1369. /* Call after EMSUnpack */
  1370. /*****************************************************************************
  1371.  * FUNCTION
  1372.  *  EMS_ConvertGSM7BitDefaultEncodingToAscii
  1373.  * DESCRIPTION
  1374.  *  
  1375.  * PARAMETERS
  1376.  *  data        [?]     
  1377.  * RETURNS
  1378.  *  void
  1379.  *****************************************************************************/
  1380. void EMS_ConvertGSM7BitDefaultEncodingToAscii(EMSData *data)
  1381. {
  1382.     /*----------------------------------------------------------------*/
  1383.     /* Local Variables                                                */
  1384.     /*----------------------------------------------------------------*/
  1385.     U16 c, OffsetToText;
  1386.     U8 *textBuffer = data->textBuffer;
  1387.     U16 textBufferLength = data->textLength;
  1388.     /*----------------------------------------------------------------*/
  1389.     /* Code Body                                                      */
  1390.     /*----------------------------------------------------------------*/
  1391.     if (textBuffer == NULL)
  1392.     {
  1393.         return;
  1394.     }
  1395.     ResetCurrentPosition(data);
  1396.     while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1397.     {
  1398.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1399.         c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1400.     #else 
  1401.         c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1402.     #endif 
  1403.         if ((c & 0xff00) != 0)
  1404.         {
  1405.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1406.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1407.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1408.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1409.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1410.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1411.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1412.         }
  1413.         else if (c == EMS_ESCAPE_CHARACTER)
  1414.         {
  1415.             c = EMS_SPACE_CHARACTER;
  1416.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1417.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1418.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1419.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1420.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1421.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1422.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1423.         }
  1424.         else
  1425.         {
  1426.             if (c == EMS_CR_CHARACTER)
  1427.             {
  1428.                 ForwardCurrentPosition(data, 1);
  1429.                 CancelCurrentPosition(data, 1);
  1430.                 BackwardCurrentPosition(data, 1);
  1431.             }
  1432.             else
  1433.             {
  1434.                 c = DefaultToAsciiArray[c];
  1435.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1436.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1437.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1438.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1439.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  1440.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1441.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1442.             }
  1443.         }
  1444.         if (ForwardCurrentPosition(data, 1) != 1)
  1445.         {
  1446.             break;
  1447.         }
  1448.     }
  1449.     ResetCurrentPosition(data);
  1450. }
  1451. /* Call before EMSPack  */
  1452. /*****************************************************************************
  1453.  * FUNCTION
  1454.  *  EMS_ConvertAsciiEncodingToGSM7BitDefault
  1455.  * DESCRIPTION
  1456.  *  
  1457.  * PARAMETERS
  1458.  *  data        [?]     
  1459.  * RETURNS
  1460.  *  void
  1461.  *****************************************************************************/
  1462. void EMS_ConvertAsciiEncodingToGSM7BitDefault(EMSData *data)
  1463. {
  1464.     /*----------------------------------------------------------------*/
  1465.     /* Local Variables                                                */
  1466.     /*----------------------------------------------------------------*/
  1467.     U16 c, OffsetToText;
  1468.     U8 *textBuffer = data->textBuffer;
  1469.     U16 textBufferLength = data->textLength;
  1470.     /*----------------------------------------------------------------*/
  1471.     /* Code Body                                                      */
  1472.     /*----------------------------------------------------------------*/
  1473.     if (textBuffer == NULL)
  1474.     {
  1475.         return;
  1476.     }
  1477.     ResetCurrentPosition(data);
  1478.     while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1479.     {
  1480.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1481.         c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1482.     #else 
  1483.         c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1484.     #endif 
  1485.         if ((c & 0xff00) == 0)
  1486.         {
  1487.             c = AsciiToDefaultArray[c];
  1488.         }
  1489.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1490.         textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1491.         textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1492.     #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1493.         textBuffer[OffsetToText] = (U8) (c & 0xff);
  1494.         textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1495.     #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1496.         if (ForwardCurrentPosition(data, 1) != 1)
  1497.         {
  1498.             break;
  1499.         }
  1500.     }
  1501.     ResetCurrentPosition(data);
  1502. }
  1503. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  1504. /* Start : JP */
  1505. /* Call after EMSUnpack */
  1506. /*****************************************************************************
  1507.  * FUNCTION
  1508.  *  EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended
  1509.  * DESCRIPTION
  1510.  *  
  1511.  * PARAMETERS
  1512.  *  data        [?]     
  1513.  * RETURNS
  1514.  *  void
  1515.  *****************************************************************************/
  1516. void EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended(EMSData *data)
  1517. {
  1518.     /*----------------------------------------------------------------*/
  1519.     /* Local Variables                                                */
  1520.     /*----------------------------------------------------------------*/
  1521.     U16 c, OffsetToText;
  1522.     U8 *textBuffer = data->textBuffer;
  1523.     U16 textBufferLength = data->textLength;
  1524.     EMSObject *object;
  1525.     /*----------------------------------------------------------------*/
  1526.     /* Code Body                                                      */
  1527.     /*----------------------------------------------------------------*/
  1528.     if (textBuffer == NULL)
  1529.     {
  1530.         return;
  1531.     }
  1532.     ResetCurrentPosition(data);
  1533.     if (data->dcs == SMSAL_DEFAULT_DCS)
  1534.     {
  1535.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1536.         {
  1537.             if (gui_EMS_input_box_get_next_object(data, &data->CurrentPosition, &c, &object) != 1)
  1538.             {
  1539.                 continue;
  1540.             }
  1541.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1542.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1543.         #else 
  1544.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1545.         #endif 
  1546.             if (c == EMS_ESCAPE_CHARACTER)
  1547.             {
  1548.                 U16 next_char = 0;
  1549.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1550.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1551.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1552.                 if (ForwardCurrentPosition(data, 1) != 1)
  1553.                 {
  1554.                     break;
  1555.                 }
  1556.                 CancelCurrentPosition(data, 1);
  1557.                 OffsetToText = data->CurrentPosition.OffsetToText;
  1558.                 c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1559.                 c = DefaultToExtendedAsciiArray[c];
  1560.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1561.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1562.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1563.                 //textBuffer[OffsetToText]=(U8)(c&0xff);
  1564.                 //textBuffer[OffsetToText+1]=(U8)(c>>8);
  1565.                 next_char =
  1566.                     (U16) (textBuffer[data->CurrentPosition.OffsetToText] |
  1567.                            (textBuffer[data->CurrentPosition.OffsetToText + 1] << 8));
  1568.                 /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1569.                 data->CurrentPosition.OffsetToText += ENCODING_LENGTH;  /* JP 20050701 */
  1570.                 CancelCurrentPosition(data, 1);
  1571.                 textBufferLength -= ENCODING_LENGTH;    /* JP */
  1572.                 /* OffsetToText=data->CurrentPosition.OffsetToText; */
  1573.                 /* c=(U16)(textBuffer[OffsetToText]|(textBuffer[OffsetToText+1]<<8)); */
  1574.                 c = next_char;
  1575.                 c = DefaultToExtendedAsciiArray[c];
  1576.                 if (c == 0x00)
  1577.                 {
  1578.                     textBuffer[OffsetToText] = (U8) (next_char & 0xff);
  1579.                     textBuffer[OffsetToText + 1] = (U8) (next_char >> 8);
  1580.                     data->CurrentPosition.OffsetToText -= 2;
  1581.                 }
  1582.                 else
  1583.                 {
  1584.                     textBuffer[OffsetToText] = (U8) (c & 0xff);
  1585.                     textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1586.                 }
  1587.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1588.             }
  1589.             else
  1590.             {
  1591.                 c = DefaultToAsciiArray[c];
  1592.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1593.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1594.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1595.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1596.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  1597.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1598.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1599.             }
  1600.             /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1601.         }
  1602.     }
  1603.     else
  1604.     {
  1605.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1606.         {
  1607.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1608.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1609.         #else 
  1610.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1611.         #endif 
  1612.             /* if(c==EMS_EURO_CHARACTER_UCS2) c=EMS_EURO_CHARACTER; */
  1613.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1614.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1615.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1616.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1617.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1618.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1619.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1620.             if (ForwardCurrentPosition(data, 1) != 1)
  1621.             {
  1622.                 break;
  1623.             }
  1624.         }
  1625.     }
  1626.     ResetCurrentPosition(data);
  1627. }
  1628. /* Call before EMSPack  */
  1629. /*****************************************************************************
  1630.  * FUNCTION
  1631.  *  EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended
  1632.  * DESCRIPTION
  1633.  *  
  1634.  * PARAMETERS
  1635.  *  data        [?]     
  1636.  * RETURNS
  1637.  *  void
  1638.  *****************************************************************************/
  1639. void EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended(EMSData *data)
  1640. {
  1641.     /*----------------------------------------------------------------*/
  1642.     /* Local Variables                                                */
  1643.     /*----------------------------------------------------------------*/
  1644.     U16 c, OffsetToText;
  1645.     U8 *textBuffer = data->textBuffer;
  1646.     U16 textBufferLength = data->textLength;
  1647.     EMSObject *object;
  1648. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1649.     U8 ESC_string[] = {0x00, 0x1B};
  1650. #else 
  1651.     U8 ESC_string[] = {0x1B, 0x00};
  1652. #endif 
  1653.     /*----------------------------------------------------------------*/
  1654.     /* Code Body                                                      */
  1655.     /*----------------------------------------------------------------*/
  1656.     if (textBuffer == NULL)
  1657.     {
  1658.         return;
  1659.     }
  1660.     ResetCurrentPosition(data);
  1661.     if (data->dcs == SMSAL_DEFAULT_DCS)
  1662.     {
  1663.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1664.         {
  1665.             if (gui_EMS_input_box_get_next_object(data, &data->CurrentPosition, &c, &object) != 1)
  1666.             {
  1667.                 continue;
  1668.             }
  1669.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1670.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1671.         #else 
  1672.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1673.         #endif 
  1674.             if (UI_TEST_GSM_EXTENDED(c))
  1675.             {
  1676.                 data->CurrentPosition.OffsetToText -= ENCODING_LENGTH;  /* JP 20050701 */
  1677.                 AddString(data, ESC_string, 1, NULL);
  1678.                 OffsetToText = data->CurrentPosition.OffsetToText;
  1679.                 /* MTK Elvis 20031126 */
  1680.                 textBufferLength += ENCODING_LENGTH;
  1681.                 /* MTK end */
  1682.                 c = ExtendedAsciiToDefaultArray[c];
  1683.                 data->CurrentPosition.OffsetToText += ENCODING_LENGTH;  /* JP 20050701 */
  1684.             }
  1685.             else
  1686.             {
  1687.                 c = AsciiToDefaultArray[c];
  1688.             }
  1689.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1690.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1691.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1692.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1693.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1694.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1695.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1696.             // if(ForwardCurrentPosition(data,1)!=1) break; /* JP */
  1697.         }
  1698.     }
  1699.     else
  1700.     {
  1701.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1702.         {
  1703.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1704.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1705.         #else 
  1706.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1707.         #endif 
  1708.             /* if(c==EMS_EURO_CHARACTER) c=EMS_EURO_CHARACTER_UCS2; */
  1709.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1710.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1711.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1712.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1713.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1714.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1715.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1716.             if (ForwardCurrentPosition(data, 1) != 1)
  1717.             {
  1718.                 break;
  1719.             }
  1720.         }
  1721.     }
  1722.     ResetCurrentPosition(data);
  1723. }
  1724. #else /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  1725. /* Call after EMSUnpack */
  1726. /*****************************************************************************
  1727.  * FUNCTION
  1728.  *  EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended
  1729.  * DESCRIPTION
  1730.  *  
  1731.  * PARAMETERS
  1732.  *  data        [?]     
  1733.  * RETURNS
  1734.  *  void
  1735.  *****************************************************************************/
  1736. void EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended(EMSData *data)
  1737. {
  1738.     /*----------------------------------------------------------------*/
  1739.     /* Local Variables                                                */
  1740.     /*----------------------------------------------------------------*/
  1741.     U16 c, OffsetToText;
  1742.     U8 *textBuffer = data->textBuffer;
  1743.     U16 textBufferLength = data->textLength;
  1744.     /*----------------------------------------------------------------*/
  1745.     /* Code Body                                                      */
  1746.     /*----------------------------------------------------------------*/
  1747.     if (textBuffer == NULL)
  1748.     {
  1749.         return;
  1750.     }
  1751.     ResetCurrentPosition(data);
  1752.     if (data->dcs == SMSAL_DEFAULT_DCS)
  1753.     {
  1754.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1755.         {
  1756.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1757.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1758.         #else 
  1759.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1760.         #endif 
  1761.             if ((c & 0xff00) != 0)
  1762.             {
  1763.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1764.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1765.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1766.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1767.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  1768.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1769.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1770.             }
  1771.             else if (c == EMS_ESCAPE_CHARACTER)
  1772.             {
  1773.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1774.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1775.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1776.                 /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1777.                 data->CurrentPosition.OffsetToText += 2;
  1778.                 if ((OffsetToText = data->CurrentPosition.OffsetToText) >= textBufferLength)
  1779.                 {
  1780.                     break;
  1781.                 }
  1782.                 OffsetToText = data->CurrentPosition.OffsetToText;
  1783.                 c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1784.                 c = DefaultToExtendedAsciiArray[c];
  1785.                 if (c == 0x00)
  1786.                 {
  1787.                     CancelCurrentPosition(data, 1);
  1788.                     data->CurrentPosition.OffsetToText -= 2;
  1789.                 }
  1790.                 else
  1791.                 {
  1792.                     textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1793.                     textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1794.                 }
  1795.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1796.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  1797.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1798.                 /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1799.                 data->CurrentPosition.OffsetToText += 2;
  1800.                 OffsetToText = data->CurrentPosition.OffsetToText;
  1801.                 c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1802.                 c = DefaultToExtendedAsciiArray[c];
  1803.                 if (c == 0x00)
  1804.                 {
  1805.                     CancelCurrentPosition(data, 1);
  1806.                     data->CurrentPosition.OffsetToText -= 2;
  1807.                 }
  1808.                 else
  1809.                 {
  1810.                     textBuffer[OffsetToText] = (U8) (c & 0xff);
  1811.                     textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1812.                 }
  1813.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1814.             }
  1815.             else
  1816.             {
  1817.                 c = DefaultToAsciiArray[c];
  1818.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1819.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1820.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1821.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1822.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  1823.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1824.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1825.             }
  1826.             /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1827.             data->CurrentPosition.OffsetToText += 2;
  1828.         }
  1829.     }
  1830.     else
  1831.     {
  1832.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1833.         {
  1834.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1835.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1836.         #else 
  1837.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1838.         #endif 
  1839.             /* if(c==EMS_EURO_CHARACTER_UCS2) c=EMS_EURO_CHARACTER; */
  1840.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1841.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1842.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1843.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1844.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1845.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1846.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1847.             /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1848.             data->CurrentPosition.OffsetToText += 2;
  1849.         }
  1850.     }
  1851.     ResetCurrentPosition(data);
  1852. }
  1853. /* Call before EMSPack  */
  1854. /*****************************************************************************
  1855.  * FUNCTION
  1856.  *  EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended
  1857.  * DESCRIPTION
  1858.  *  
  1859.  * PARAMETERS
  1860.  *  data        [?]     
  1861.  * RETURNS
  1862.  *  void
  1863.  *****************************************************************************/
  1864. void EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended(EMSData *data)
  1865. {
  1866.     /*----------------------------------------------------------------*/
  1867.     /* Local Variables                                                */
  1868.     /*----------------------------------------------------------------*/
  1869.     U16 c, OffsetToText;
  1870.     U8 *textBuffer = data->textBuffer;
  1871.     U16 textBufferLength = data->textLength;
  1872.     /*----------------------------------------------------------------*/
  1873.     /* Code Body                                                      */
  1874.     /*----------------------------------------------------------------*/
  1875.     if (textBuffer == NULL)
  1876.     {
  1877.         return;
  1878.     }
  1879.     ResetCurrentPosition(data);
  1880.     if (data->dcs == SMSAL_DEFAULT_DCS)
  1881.     {
  1882.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1883.         {
  1884.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1885.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1886.         #else 
  1887.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1888.         #endif 
  1889.             if ((c & 0xff00) == 0)
  1890.             {
  1891.                 if (c == EMS_ESCAPE_CHARACTER)
  1892.                 {
  1893.                 #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1894.                     textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1895.                     textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1896.                 #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1897.                     textBuffer[OffsetToText] = (U8) (c & 0xff);
  1898.                     textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1899.                 #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1900.                     /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1901.                     data->CurrentPosition.OffsetToText += 2;
  1902.                     if ((OffsetToText = data->CurrentPosition.OffsetToText) >= textBufferLength)
  1903.                     {
  1904.                         break;
  1905.                     }
  1906.                     OffsetToText = data->CurrentPosition.OffsetToText;
  1907.                 #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1908.                     c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1909.                 #else 
  1910.                     c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1911.                 #endif 
  1912.                     c = ExtendedAsciiToDefaultArray[c];
  1913.                 }
  1914.                 else
  1915.                 {
  1916.                     c = AsciiToDefaultArray[c];
  1917.                 }
  1918.             }
  1919.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1920.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1921.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1922.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1923.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1924.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1925.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1926.             /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1927.             data->CurrentPosition.OffsetToText += 2;
  1928.         }
  1929.     }
  1930.     else
  1931.     {
  1932.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1933.         {
  1934.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1935.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1936.         #else 
  1937.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1938.         #endif 
  1939.             /* if(c==EMS_EURO_CHARACTER) c=EMS_EURO_CHARACTER_UCS2; */
  1940.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1941.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1942.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1943.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1944.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  1945.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1946.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1947.             /* if(ForwardCurrentPosition(data,1)!=1) break; */
  1948.             data->CurrentPosition.OffsetToText += 2;
  1949.         }
  1950.     }
  1951.     ResetCurrentPosition(data);
  1952. }
  1953. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  1954. /* End : JP */
  1955. /*****************************************************************************
  1956.  * FUNCTION
  1957.  *  EMS_ConvertGSM7BitDefaultEncodingToAsciiWithoutEMSlib
  1958.  * DESCRIPTION
  1959.  *  
  1960.  * PARAMETERS
  1961.  *  data        [?]     
  1962.  * RETURNS
  1963.  *  void
  1964.  *****************************************************************************/
  1965. void EMS_ConvertGSM7BitDefaultEncodingToAsciiWithoutEMSlib(EMSData *data)
  1966. {
  1967.     /*----------------------------------------------------------------*/
  1968.     /* Local Variables                                                */
  1969.     /*----------------------------------------------------------------*/
  1970.     U16 c, OffsetToText;
  1971.     U8 *textBuffer = data->textBuffer;
  1972.     U16 textBufferLength = data->textLength;
  1973.     /*----------------------------------------------------------------*/
  1974.     /* Code Body                                                      */
  1975.     /*----------------------------------------------------------------*/
  1976.     if (textBuffer == NULL)
  1977.     {
  1978.         return;
  1979.     }
  1980.     data->CurrentPosition.OffsetToText = 0;
  1981.     if (data->dcs == SMSAL_DEFAULT_DCS)
  1982.     {
  1983.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  1984.         {
  1985.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1986.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  1987.         #else 
  1988.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  1989.         #endif 
  1990.             if ((c & 0xff00) != 0)
  1991.             {
  1992.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1993.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  1994.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  1995.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1996.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  1997.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  1998.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1999.             }
  2000.             else if (c == EMS_ESCAPE_CHARACTER)
  2001.             {
  2002.                 U16 tempOffsetToText = data->CurrentPosition.OffsetToText;
  2003.                 while ((tempOffsetToText + 2) < textBufferLength)
  2004.                 {
  2005.                     textBuffer[tempOffsetToText] = textBuffer[tempOffsetToText + 2];
  2006.                     textBuffer[tempOffsetToText + 1] = textBuffer[tempOffsetToText + 3];
  2007.                     tempOffsetToText = tempOffsetToText + 2;
  2008.                 }
  2009.                 textBuffer[tempOffsetToText] = 0;
  2010.                 textBuffer[tempOffsetToText + 1] = 0;
  2011.                 textBufferLength = textBufferLength - 2;
  2012.                 data->textLength = data->textLength - 2;
  2013.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2014.                 //textBuffer[OffsetToText+1]=(U8)(c&0xff);
  2015.                 //textBuffer[OffsetToText+0]=(U8)(c>>8);
  2016.                 if ((data->CurrentPosition.OffsetToText + 2) > textBufferLength)
  2017.                 {
  2018.                     break;
  2019.                 }
  2020.                 OffsetToText = data->CurrentPosition.OffsetToText;
  2021.                 c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2022.                 c = DefaultToExtendedAsciiArray[c];
  2023.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2024.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2025.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2026.                 //textBuffer[OffsetToText]=(U8)(c&0xff);
  2027.                 //textBuffer[OffsetToText+1]=(U8)(c>>8);
  2028.                 if ((data->CurrentPosition.OffsetToText + 2) > textBufferLength)
  2029.                 {
  2030.                     break;
  2031.                 }
  2032.                 OffsetToText = data->CurrentPosition.OffsetToText;
  2033.                 c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2034.                 c = DefaultToExtendedAsciiArray[c];
  2035.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2036.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2037.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2038.             }
  2039.             else
  2040.             {
  2041.                 c = DefaultToAsciiArray[c];
  2042.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2043.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2044.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2045.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2046.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2047.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2048.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2049.             }
  2050.             data->CurrentPosition.OffsetToText += 2;
  2051.         }
  2052.     }
  2053.     else
  2054.     {
  2055.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2056.         {
  2057.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2058.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2059.         #else 
  2060.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2061.         #endif 
  2062.             /* if(c==EMS_EURO_CHARACTER_UCS2) c=EMS_EURO_CHARACTER; */
  2063.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2064.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2065.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2066.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2067.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2068.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2069.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2070.             data->CurrentPosition.OffsetToText += 2;
  2071.         }
  2072.     }
  2073.     data->CurrentPosition.OffsetToText = 0;
  2074. }
  2075. #else /* (!EMS_USE_GSM_EXTENDED) */ 
  2076. /* Call after EMSUnpack */
  2077. /*****************************************************************************
  2078.  * FUNCTION
  2079.  *  EMS_ConvertGSM7BitDefaultEncodingToAscii
  2080.  * DESCRIPTION
  2081.  *  
  2082.  * PARAMETERS
  2083.  *  data        [?]     
  2084.  * RETURNS
  2085.  *  void
  2086.  *****************************************************************************/
  2087. void EMS_ConvertGSM7BitDefaultEncodingToAscii(EMSData *data)
  2088. {
  2089.     /*----------------------------------------------------------------*/
  2090.     /* Local Variables                                                */
  2091.     /*----------------------------------------------------------------*/
  2092.     U16 c, OffsetToText;
  2093.     U8 *textBuffer = data->textBuffer;
  2094.     U16 textBufferLength = data->textLength;
  2095.     /*----------------------------------------------------------------*/
  2096.     /* Code Body                                                      */
  2097.     /*----------------------------------------------------------------*/
  2098.     if (textBuffer == NULL)
  2099.     {
  2100.         return;
  2101.     }
  2102.     ResetCurrentPosition(data);
  2103.     if (data->dcs == SMSAL_DEFAULT_DCS)
  2104.     {
  2105.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2106.         {
  2107.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2108.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2109.         #else 
  2110.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2111.         #endif 
  2112.             if (c == EMS_ESCAPE_CHARACTER)
  2113.             {
  2114.                 c = EMS_SPACE_CHARACTER;
  2115.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2116.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2117.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2118.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2119.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2120.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2121.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2122.             }
  2123.             else
  2124.             {
  2125.                 c = DefaultToAsciiArray[c];
  2126.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2127.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2128.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2129.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2130.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2131.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2132.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2133.             }
  2134.             if (ForwardCurrentPosition(data, 1) != 1)
  2135.             {
  2136.                 break;
  2137.             }
  2138.         }
  2139.     }
  2140.     else
  2141.     {
  2142.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2143.         {
  2144.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2145.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2146.         #else 
  2147.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2148.         #endif 
  2149.             /* if(c==EMS_EURO_CHARACTER_UCS2) c=EMS_EURO_CHARACTER; */
  2150.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2151.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2152.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2153.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2154.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2155.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2156.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2157.             if (ForwardCurrentPosition(data, 1) != 1)
  2158.             {
  2159.                 break;
  2160.             }
  2161.         }
  2162.     }
  2163.     ResetCurrentPosition(data);
  2164. }
  2165. /* Call before EMSPack  */
  2166. /*****************************************************************************
  2167.  * FUNCTION
  2168.  *  EMS_ConvertAsciiEncodingToGSM7BitDefault
  2169.  * DESCRIPTION
  2170.  *  
  2171.  * PARAMETERS
  2172.  *  data        [?]     
  2173.  * RETURNS
  2174.  *  void
  2175.  *****************************************************************************/
  2176. void EMS_ConvertAsciiEncodingToGSM7BitDefault(EMSData *data)
  2177. {
  2178.     /*----------------------------------------------------------------*/
  2179.     /* Local Variables                                                */
  2180.     /*----------------------------------------------------------------*/
  2181.     U16 c, OffsetToText;
  2182.     U8 *textBuffer = data->textBuffer;
  2183.     U16 textBufferLength = data->textLength;
  2184.     /*----------------------------------------------------------------*/
  2185.     /* Code Body                                                      */
  2186.     /*----------------------------------------------------------------*/
  2187.     if (textBuffer == NULL)
  2188.     {
  2189.         return;
  2190.     }
  2191.     ResetCurrentPosition(data);
  2192.     if (data->dcs == SMSAL_DEFAULT_DCS)
  2193.     {
  2194.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2195.         {
  2196.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2197.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2198.         #else 
  2199.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2200.         #endif 
  2201.             c = AsciiToDefaultArray[c];
  2202.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2203.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2204.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2205.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2206.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2207.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2208.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2209.             if (ForwardCurrentPosition(data, 1) != 1)
  2210.             {
  2211.                 break;
  2212.             }
  2213.         }
  2214.     }
  2215.     else
  2216.     {
  2217.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2218.         {
  2219.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2220.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2221.         #else 
  2222.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2223.         #endif 
  2224.             /* if(c==EMS_EURO_CHARACTER) c=EMS_EURO_CHARACTER_UCS2; */
  2225.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2226.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2227.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2228.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2229.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2230.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2231.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2232.             if (ForwardCurrentPosition(data, 1) != 1)
  2233.             {
  2234.                 break;
  2235.             }
  2236.         }
  2237.     }
  2238.     ResetCurrentPosition(data);
  2239. }
  2240. /* Call after EMSUnpack */
  2241. /*****************************************************************************
  2242.  * FUNCTION
  2243.  *  EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended
  2244.  * DESCRIPTION
  2245.  *  
  2246.  * PARAMETERS
  2247.  *  data        [?]     
  2248.  * RETURNS
  2249.  *  void
  2250.  *****************************************************************************/
  2251. void EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended(EMSData *data)
  2252. {
  2253.     /*----------------------------------------------------------------*/
  2254.     /* Local Variables                                                */
  2255.     /*----------------------------------------------------------------*/
  2256.     U16 c, OffsetToText;
  2257.     U8 *textBuffer = data->textBuffer;
  2258.     U16 textBufferLength = data->textLength;
  2259.     EMSObject *object;
  2260.     /*----------------------------------------------------------------*/
  2261.     /* Code Body                                                      */
  2262.     /*----------------------------------------------------------------*/
  2263.     if (textBuffer == NULL)
  2264.     {
  2265.         return;
  2266.     }
  2267.     ResetCurrentPosition(data);
  2268.     if (data->dcs == SMSAL_DEFAULT_DCS)
  2269.     {
  2270.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2271.         {
  2272.             if (gui_EMS_input_box_get_next_object(data, &data->CurrentPosition, &c, &object) != 1)
  2273.             {
  2274.                 continue;
  2275.             }
  2276.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2277.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2278.         #else 
  2279.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2280.         #endif 
  2281.             if (c == EMS_ESCAPE_CHARACTER)
  2282.             {
  2283.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2284.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2285.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2286.                 if (ForwardCurrentPosition(data, 1) != 1)
  2287.                 {
  2288.                     break;
  2289.                 }
  2290.                 CancelCurrentPosition(data, 1);
  2291.                 OffsetToText = data->CurrentPosition.OffsetToText;
  2292.                 c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2293.                 c = DefaultToExtendedAsciiArray[c];
  2294.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2295.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2296.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2297.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2298.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2299.                 if (ForwardCurrentPosition(data, 1) != 1)
  2300.                 {
  2301.                     break;
  2302.                 }
  2303.                 CancelCurrentPosition(data, 1);
  2304.                 OffsetToText = data->CurrentPosition.OffsetToText;
  2305.                 c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2306.                 c = DefaultToExtendedAsciiArray[c];
  2307.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2308.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2309.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2310.             }
  2311.             else
  2312.             {
  2313.                 c = DefaultToAsciiArray[c];
  2314.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2315.                 textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2316.                 textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2317.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2318.                 textBuffer[OffsetToText] = (U8) (c & 0xff);
  2319.                 textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2320.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2321.             }
  2322.             if (ForwardCurrentPosition(data, 1) != 1)
  2323.             {
  2324.                 break;
  2325.             }
  2326.         }
  2327.     }
  2328.     else
  2329.     {
  2330.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2331.         {
  2332.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2333.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2334.         #else 
  2335.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2336.         #endif 
  2337.             /* if(c==EMS_EURO_CHARACTER_UCS2) c=EMS_EURO_CHARACTER; */
  2338.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2339.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2340.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2341.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2342.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2343.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2344.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2345.             if (ForwardCurrentPosition(data, 1) != 1)
  2346.             {
  2347.                 break;
  2348.             }
  2349.         }
  2350.     }
  2351.     ResetCurrentPosition(data);
  2352. }
  2353. /* Call before EMSPack  */
  2354. /*****************************************************************************
  2355.  * FUNCTION
  2356.  *  EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended
  2357.  * DESCRIPTION
  2358.  *  
  2359.  * PARAMETERS
  2360.  *  data        [?]     
  2361.  * RETURNS
  2362.  *  void
  2363.  *****************************************************************************/
  2364. void EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended(EMSData *data)
  2365. {
  2366.     /*----------------------------------------------------------------*/
  2367.     /* Local Variables                                                */
  2368.     /*----------------------------------------------------------------*/
  2369.     U16 c, OffsetToText;
  2370.     U8 *textBuffer = data->textBuffer;
  2371.     U16 textBufferLength = data->textLength;
  2372.     EMSObject *object;
  2373. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2374.     U8 ESC_string[] = {0x00, 0x1B};
  2375. #else 
  2376.     U8 ESC_string[] = {0x1B, 0x00};
  2377. #endif 
  2378.     /*----------------------------------------------------------------*/
  2379.     /* Code Body                                                      */
  2380.     /*----------------------------------------------------------------*/
  2381.     if (textBuffer == NULL)
  2382.     {
  2383.         return;
  2384.     }
  2385.     ResetCurrentPosition(data);
  2386.     if (data->dcs == SMSAL_DEFAULT_DCS)
  2387.     {
  2388.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2389.         {
  2390.             if (gui_EMS_input_box_get_next_object(data, &data->CurrentPosition, &c, &object) != 1)
  2391.             {
  2392.                 continue;
  2393.             }
  2394.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2395.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2396.         #else 
  2397.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2398.         #endif 
  2399.             if (UI_TEST_GSM_EXTENDED(c))
  2400.             {
  2401.                 AddString(data, ESC_string, 1, NULL);
  2402.                 OffsetToText = data->CurrentPosition.OffsetToText;
  2403.                 /* MTK Elvis 20031126 */
  2404.                 textBufferLength += ENCODING_LENGTH;
  2405.                 /* MTK end */
  2406.                 c = ExtendedAsciiToDefaultArray[c];
  2407.             }
  2408.             else
  2409.             {
  2410.                 c = AsciiToDefaultArray[c];
  2411.             }
  2412.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2413.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2414.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2415.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2416.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2417.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2418.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2419.             if (ForwardCurrentPosition(data, 1) != 1)
  2420.             {
  2421.                 break;
  2422.             }
  2423.         }
  2424.     }
  2425.     else
  2426.     {
  2427.         while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
  2428.         {
  2429.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2430.             c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
  2431.         #else 
  2432.             c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
  2433.         #endif 
  2434.             /* if(c==EMS_EURO_CHARACTER) c=EMS_EURO_CHARACTER_UCS2; */
  2435.         #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2436.             textBuffer[OffsetToText + 1] = (U8) (c & 0xff);
  2437.             textBuffer[OffsetToText + 0] = (U8) (c >> 8);
  2438.         #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2439.             textBuffer[OffsetToText] = (U8) (c & 0xff);
  2440.             textBuffer[OffsetToText + 1] = (U8) (c >> 8);
  2441.         #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2442.             if (ForwardCurrentPosition(data, 1) != 1)
  2443.             {
  2444.                 break;
  2445.             }
  2446.         }
  2447.     }
  2448.     ResetCurrentPosition(data);
  2449. }
  2450. #endif /* (!EMS_USE_GSM_EXTENDED) */
  2451. #endif /* (!UI_DISABLE_EMS_CATEGORY_SCREENS) */ 
  2452. #endif /* __MOD_SMSAL__ */