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

MTK

开发平台:

C/C++

  1.     inputBuffer = GetCurrNInputBuffer(SCR_ID_IMPS_ABOUT_ME_INLINE, &inputBufferSize);
  2.     if (inputBuffer != NULL)
  3.     {
  4.         SetCategory57Data(wgui_inline_items, IMPS_INLINE_ABOUT_ME, inputBuffer);
  5.     }
  6.     if (imps_p->about_info->is_pic_changed && GetInlineDoneFlag(guiBuffer) == 0)
  7.     {
  8.         SetInlineDoneFlag(guiBuffer);
  9.     }
  10.     ShowCategory57Screen(
  11.         STR_ID_IMPS_ABOUT_ME,
  12.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  13.         STR_GLOBAL_EDIT,
  14.         IMG_GLOBAL_BACK,
  15.         STR_GLOBAL_DONE,
  16.         IMG_GLOBAL_BACK,
  17.         IMPS_INLINE_ABOUT_ME,
  18.         (U16*) g_imps_inline_icons,
  19.         wgui_inline_items,
  20.         0,
  21.         guiBuffer);
  22.     SetCategory57RightSoftkeyFunctions(mmi_imps_about_me_save, mmi_imps_about_free_mem_and_back);
  23.     SetDelScrnIDCallbackHandler(SCR_ID_IMPS_ABOUT_ME_INLINE, (HistoryDelCBPtr) mmi_imps_about_me_del_callback);
  24. }
  25. /*****************************************************************************
  26.  * FUNCTION
  27.  *  mmi_imps_about_free_mem_and_back
  28.  * DESCRIPTION
  29.  *  Free memory and go back history
  30.  * PARAMETERS
  31.  *  void
  32.  * RETURNS
  33.  *  void
  34.  *****************************************************************************/
  35. void mmi_imps_about_free_mem_and_back(void)
  36. {
  37.     /*----------------------------------------------------------------*/
  38.     /* Local Variables                                                */
  39.     /*----------------------------------------------------------------*/
  40.     /*----------------------------------------------------------------*/
  41.     /* Code Body                                                      */
  42.     /*----------------------------------------------------------------*/
  43.     mmi_imps_free_about_me_buff();
  44.     GoBackHistory();
  45. }
  46. /*****************************************************************************
  47.  * FUNCTION
  48.  *  mmi_imps_about_me_del_callback
  49.  * DESCRIPTION
  50.  *  Callback function when About Me inline editor screen is deleted.
  51.  * PARAMETERS
  52.  *  param       [IN]        Parameter from framework
  53.  * RETURNS
  54.  *  void
  55.  *****************************************************************************/
  56. U8 mmi_imps_about_me_del_callback(void *param)
  57. {
  58.     /*----------------------------------------------------------------*/
  59.     /* Local Variables                                                */
  60.     /*----------------------------------------------------------------*/
  61.     /*----------------------------------------------------------------*/
  62.     /* Code Body                                                      */
  63.     /*----------------------------------------------------------------*/
  64.     if (param != (void*)MMI_TRUE)
  65.     {
  66.         mmi_imps_free_about_me_buff();
  67.     }
  68.     else if(imps_p->gen_info.curr_action == 0)
  69.     {
  70.         /* if it's not saving about me, free the buffer */
  71.         mmi_imps_free_about_me_buff();
  72.     }
  73.     return FALSE;
  74. }
  75. /*****************************************************************************
  76.  * FUNCTION
  77.  *  mmi_imps_free_about_me_buff
  78.  * DESCRIPTION
  79.  *  Free memory of about me screen.
  80.  * PARAMETERS
  81.  *  void
  82.  * RETURNS
  83.  *  void
  84.  *****************************************************************************/
  85. void mmi_imps_free_about_me_buff(void)
  86. {
  87.     /*----------------------------------------------------------------*/
  88.     /* Local Variables                                                */
  89.     /*----------------------------------------------------------------*/
  90.     /*----------------------------------------------------------------*/
  91.     /* Code Body                                                      */
  92.     /*----------------------------------------------------------------*/
  93.     /* about me buffer is not empty and currently is not updating */
  94.     if (imps_p->about_info != NULL && imps_p->gen_info.curr_action != MSG_ID_MMI_IMPS_UPDATE_PA_REQ)
  95.     {
  96.         OslMfree(imps_p->about_info);
  97.         imps_p->about_info = NULL;
  98.     }
  99. }
  100. /*****************************************************************************
  101.  * FUNCTION
  102.  *  mmi_imps_exit_about_me
  103.  * DESCRIPTION
  104.  *  Exit function for About Me inline editor.
  105.  * PARAMETERS
  106.  *  void
  107.  * RETURNS
  108.  *  void
  109.  *****************************************************************************/
  110. void mmi_imps_exit_about_me(void)
  111. {
  112.     /*----------------------------------------------------------------*/
  113.     /* Local Variables                                                */
  114.     /*----------------------------------------------------------------*/
  115.     /*----------------------------------------------------------------*/
  116.     /* Code Body                                                      */
  117.     /*----------------------------------------------------------------*/
  118.     GenericExitInlineScreen(SCR_ID_IMPS_ABOUT_ME_INLINE, mmi_imps_entry_about_me);
  119. }
  120. /*****************************************************************************
  121.  * FUNCTION
  122.  *  mmi_imps_about_me_fill_inline_struct
  123.  * DESCRIPTION
  124.  *  Fill inline editor structure of About Me screen.
  125.  * PARAMETERS
  126.  *  void
  127.  * RETURNS
  128.  *  void
  129.  *****************************************************************************/
  130. void mmi_imps_about_me_fill_inline_struct(void)
  131. {
  132.     /*----------------------------------------------------------------*/
  133.     /* Local Variables                                                */
  134.     /*----------------------------------------------------------------*/
  135.     S32 i;
  136.     /*----------------------------------------------------------------*/
  137.     /* Code Body                                                      */
  138.     /*----------------------------------------------------------------*/
  139.     /* status */
  140.     imps_p->about_info->status_list[0] = (U8*) GetString(STR_ID_IMPS_ONLINE);
  141.     imps_p->about_info->status_list[1] = (U8*) GetString(STR_ID_IMPS_AWAY);
  142.     imps_p->about_info->status_list[2] = (U8*) GetString(STR_ID_IMPS_OFFLINE);
  143.     /* mood */
  144.     for (i = 0; i < IMPS_NUM_MOOD; i++)
  145.     {
  146.         imps_p->about_info->mood_list[i] = (U8*) GetString((U16) (STR_ID_IMPS_HAPPY + i));
  147.     }
  148.     /* file */
  149.     imps_p->about_info->file_sel_list[0] = (U8*) GetString(STR_GLOBAL_NONE);
  150.     if (pfnUnicodeStrlen((S8*) imps_p->about_info->pic_name) == 0)
  151.     {
  152.         imps_p->about_info->file_sel_list[1] = (U8*) GetString(STR_ID_IMPS_SEL_FROM_FILE);
  153.     }
  154.     else
  155.     {
  156.         imps_p->about_info->file_sel_list[1] = (U8*) imps_p->about_info->pic_name;
  157.     }
  158.     /* My Profile */
  159.     SetInlineItemActivation(&wgui_inline_items[0], KEY_LSK, KEY_EVENT_UP);
  160.     SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_ID_IMPS_MY_PROFILE));
  161.     SetInlineItemActivation(&wgui_inline_items[1], KEY_LSK, KEY_EVENT_UP);
  162.     SetInlineItemFullScreenEdit(
  163.         &wgui_inline_items[1],
  164.         STR_ID_IMPS_MY_PROFILE,
  165.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  166.         (U8*) imps_p->about_info->my_prof,
  167.         IMPS_MAX_PA_STATUS_TEXT_LEN,
  168.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE);
  169.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[1], mmi_imps_hilite_prof_full_edit);
  170.     /* Status */
  171.     SetInlineItemActivation(&wgui_inline_items[2], KEY_LSK, KEY_EVENT_UP);
  172.     SetInlineItemCaption(&wgui_inline_items[2], (U8*) GetString(STR_ID_IMPS_STATUS));
  173.     SetInlineItemActivation(&wgui_inline_items[3], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  174.     SetInlineItemSelect(&wgui_inline_items[3], 3, imps_p->about_info->status_list, &imps_p->about_info->status);
  175.     /* Mood */
  176.     SetInlineItemActivation(&wgui_inline_items[4], KEY_LSK, KEY_EVENT_UP);
  177.     SetInlineItemCaption(&wgui_inline_items[4], (U8*) GetString(STR_ID_IMPS_MOOD));
  178.     SetInlineItemActivation(&wgui_inline_items[5], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  179.     SetInlineItemSelect(&wgui_inline_items[5], 11, imps_p->about_info->mood_list, &imps_p->about_info->mood);
  180.     /* My Picture */
  181.     SetInlineItemActivation(&wgui_inline_items[6], KEY_LSK, KEY_EVENT_UP);
  182.     SetInlineItemCaption(&wgui_inline_items[6], (U8*) GetString(STR_ID_IMPS_MY_PICTURE));
  183.     SetInlineItemActivation(&wgui_inline_items[7], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  184.     SetInlineItemSelect(&wgui_inline_items[7], 2, imps_p->about_info->file_sel_list, &imps_p->about_info->is_pic);
  185.     RegisterInlineSelectHighlightHandler(&wgui_inline_items[7], mmi_imps_hilite_about_me_inline_sel);
  186. }
  187. /*****************************************************************************
  188.  * FUNCTION
  189.  *  mmi_imps_hilite_about_me_inline_sel
  190.  * DESCRIPTION
  191.  *  Highlight handler of My Picture in About Me menu
  192.  * PARAMETERS
  193.  *  index       [IN]        Index of inline seletion item
  194.  * RETURNS
  195.  *  void
  196.  *****************************************************************************/
  197. void mmi_imps_hilite_about_me_inline_sel(S32 index)
  198. {
  199.     /*----------------------------------------------------------------*/
  200.     /* Local Variables                                                */
  201.     /*----------------------------------------------------------------*/
  202.     /*----------------------------------------------------------------*/
  203.     /* Code Body                                                      */
  204.     /*----------------------------------------------------------------*/
  205.     ChangeLeftSoftkey(0, 0);
  206.     if (index != 0)
  207.     {
  208.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, 0);
  209.         SetCategory57LeftSoftkeyFunction(mmi_imps_entry_about_me_sel_file);
  210.     }
  211. }
  212. /*****************************************************************************
  213.  * FUNCTION
  214.  *  mmi_imps_entry_about_me_sel_file
  215.  * DESCRIPTION
  216.  *  Entry About Me -> Select From File screen
  217.  * PARAMETERS
  218.  *  void
  219.  * RETURNS
  220.  *  void
  221.  *****************************************************************************/
  222. void mmi_imps_entry_about_me_sel_file(void)
  223. {
  224.     /*----------------------------------------------------------------*/
  225.     /* Local Variables                                                */
  226.     /*----------------------------------------------------------------*/
  227.     U16 numItems;
  228.     U16 nStrItemList[3];    /* only 3 options */
  229.     U8 *guiBuffer;
  230.     /*----------------------------------------------------------------*/
  231.     /* Code Body                                                      */
  232.     /*----------------------------------------------------------------*/
  233.     EntryNewScreen(SCR_ID_IMPS_ABOUT_ME_SEL_FILE, NULL, mmi_imps_entry_about_me_sel_file, NULL);
  234.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ABOUT_ME_SEL_FILE);
  235.     SetParentHandler(MENU_ID_IMPS_ABOUT_ME_FILE_OPT);
  236.     numItems = GetNumOfChild(MENU_ID_IMPS_ABOUT_ME_FILE_OPT);
  237.     GetSequenceStringIds(MENU_ID_IMPS_ABOUT_ME_FILE_OPT, nStrItemList);
  238.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  239.     if (pfnUnicodeStrlen((S8*) imps_p->about_info->file_buff) == 0)    /* no file selected */
  240.     {
  241.         numItems = 1;
  242.     }
  243.     ShowCategory52Screen(
  244.         STR_ID_IMPS_SEL_FILE,
  245.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  246.         STR_GLOBAL_OK,
  247.         IMG_GLOBAL_OK,
  248.         STR_GLOBAL_BACK,
  249.         IMG_GLOBAL_BACK,
  250.         numItems,
  251.         nStrItemList,
  252.         (U16*) gIndexIconsImageList,
  253.         NULL,
  254.         0,
  255.         0,
  256.         guiBuffer);
  257.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  258. }
  259. /*****************************************************************************
  260.  * FUNCTION
  261.  *  mmi_imps_hilite_about_pic_sel
  262.  * DESCRIPTION
  263.  *  Highlight handler of About Me -> Select From File -> Select File
  264.  * PARAMETERS
  265.  *  void
  266.  * RETURNS
  267.  *  void
  268.  *****************************************************************************/
  269. void mmi_imps_hilite_about_pic_sel(void)
  270. {
  271.     /*----------------------------------------------------------------*/
  272.     /* Local Variables                                                */
  273.     /*----------------------------------------------------------------*/
  274.     /*----------------------------------------------------------------*/
  275.     /* Code Body                                                      */
  276.     /*----------------------------------------------------------------*/
  277.     SetLeftSoftkeyFunction(mmi_imps_entry_about_pic_sel, KEY_EVENT_UP);
  278.     SetKeyHandler(mmi_imps_entry_about_pic_sel, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  279. }
  280. /*****************************************************************************
  281.  * FUNCTION
  282.  *  mmi_imps_hilite_about_pic_view
  283.  * DESCRIPTION
  284.  *  Highlight handler of About Me -> Select From File -> View
  285.  * PARAMETERS
  286.  *  void
  287.  * RETURNS
  288.  *  void
  289.  *****************************************************************************/
  290. void mmi_imps_hilite_about_pic_view(void)
  291. {
  292.     /*----------------------------------------------------------------*/
  293.     /* Local Variables                                                */
  294.     /*----------------------------------------------------------------*/
  295.     /*----------------------------------------------------------------*/
  296.     /* Code Body                                                      */
  297.     /*----------------------------------------------------------------*/
  298.     SetLeftSoftkeyFunction(mmi_imps_entry_about_pic_view, KEY_EVENT_UP);
  299.     SetKeyHandler(mmi_imps_entry_about_pic_view, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  300. }
  301. /*****************************************************************************
  302.  * FUNCTION
  303.  *  mmi_imps_hilite_about_pic_del
  304.  * DESCRIPTION
  305.  *  Highlight handler of About Me -> Select From File -> Delete
  306.  * PARAMETERS
  307.  *  void
  308.  * RETURNS
  309.  *  void
  310.  *****************************************************************************/
  311. void mmi_imps_hilite_about_pic_del(void)
  312. {
  313.     /*----------------------------------------------------------------*/
  314.     /* Local Variables                                                */
  315.     /*----------------------------------------------------------------*/
  316.     /*----------------------------------------------------------------*/
  317.     /* Code Body                                                      */
  318.     /*----------------------------------------------------------------*/
  319.     SetLeftSoftkeyFunction(mmi_imps_entry_about_pic_del, KEY_EVENT_UP);
  320. }
  321. /*****************************************************************************
  322.  * FUNCTION
  323.  *  mmi_imps_entry_about_pic_sel
  324.  * DESCRIPTION
  325.  *  Entry function of About Me -> Select From File -> Delete
  326.  * PARAMETERS
  327.  *  void
  328.  * RETURNS
  329.  *  void
  330.  *****************************************************************************/
  331. void mmi_imps_entry_about_pic_sel(void)
  332. {
  333.     /*----------------------------------------------------------------*/
  334.     /* Local Variables                                                */
  335.     /*----------------------------------------------------------------*/
  336.     FMGR_FILTER filter;
  337.     /*----------------------------------------------------------------*/
  338.     /* Code Body                                                      */
  339.     /*----------------------------------------------------------------*/
  340.     FMGR_FILTER_INIT(&filter);
  341.     FMGR_FILTER_SET(&filter, FMGR_TYPE_BMP);
  342.     FMGR_FILTER_SET(&filter, FMGR_TYPE_JPG);
  343.     #if defined(GDI_USING_PNG)
  344.         FMGR_FILTER_SET(&filter, FMGR_TYPE_PNG);
  345.     #endif
  346.     FMGR_FILTER_SET(&filter, FMGR_TYPE_GIF);
  347.     FMGR_FILTER_SET(&filter, FMGR_TYPE_WBMP);
  348.     FMGR_FILTER_SET(&filter, FMGR_TYPE_FOLDER);
  349.     mmi_fmgr_select_path_and_enter(APP_IMPS, FMGR_SELECT_FILE, filter, (S8*) L"root", mmi_imps_about_sel_pic_callback);
  350. }
  351. /*****************************************************************************
  352.  * FUNCTION
  353.  *  mmi_imps_about_sel_pic_callback
  354.  * DESCRIPTION
  355.  *  Callback function for selected image from File Manager
  356.  * PARAMETERS
  357.  *  filePath        [IN]        File path+name from File Manager
  358.  *  is_short        [IN]        
  359.  * RETURNS
  360.  *  void
  361.  *****************************************************************************/
  362. void mmi_imps_about_sel_pic_callback(void *filePath, int is_short)
  363. {
  364.     /*----------------------------------------------------------------*/
  365.     /* Local Variables                                                */
  366.     /*----------------------------------------------------------------*/
  367.     /*----------------------------------------------------------------*/
  368.     /* Code Body                                                      */
  369.     /*----------------------------------------------------------------*/
  370.     if (filePath == NULL)
  371.     {
  372.         GoBackToHistory(SCR_ID_IMPS_ABOUT_ME_SEL_FILE);
  373.     }
  374.     else
  375.     {
  376.         S32 fileLen;
  377.         S32 f_result;
  378.         mmi_imps_about_me_struct *about_info;
  379.         if ((f_result = mmi_imps_util_get_file_size(filePath, &fileLen)) == FS_NO_ERROR)
  380.         {
  381.             if (fileLen > IMPS_MAX_PIC_SIZE)
  382.             {
  383.                 mmi_imps_util_disp_err_popup(STR_ID_IMPS_SIZE_TOO_LARGE);
  384.                 DeleteUptoScrID(SCR_ID_IMPS_ABOUT_ME_SEL_FILE);
  385.                 return;
  386.             }
  387.         }
  388.         else
  389.         {
  390.             mmi_imps_util_disp_err_popup(GetFileSystemErrorString(f_result));
  391.             DeleteUptoScrID(SCR_ID_IMPS_ABOUT_ME_SEL_FILE);
  392.             return;
  393.         }
  394.         /* store file in buffer */
  395.         about_info = imps_p->about_info;
  396.         if(is_short)
  397.         {
  398.             mmi_chset_mixed_text_to_ucs2_str((kal_uint8*)about_info->pic_name, (FMGR_MAX_FILE_LEN + 1)*2, (kal_uint8 *)mmi_fmgr_extract_file_name((S8*) filePath), PhnsetGetDefEncodingType());
  399. pfnUnicodeStrcpy((S8*) about_info->file_buff, (S8*) filePath);
  400.         }
  401.         else
  402.         {
  403.             pfnUnicodeStrcpy((S8*) about_info->file_buff, (S8*) filePath);
  404.             pfnUnicodeStrcpy((S8*) about_info->pic_name, (S8*) mmi_fmgr_extract_file_name((S8*) filePath));
  405.         }
  406.         /* change RSK of signature secreen to Done */
  407.         about_info->is_pic_changed = TRUE;
  408.         about_info->is_pic = (S32) TRUE;
  409.         GoBackToHistory(SCR_ID_IMPS_ABOUT_ME_SEL_FILE);
  410.     }
  411. }
  412. /*****************************************************************************
  413.  * FUNCTION
  414.  *  mmi_imps_entry_about_pic_view
  415.  * DESCRIPTION
  416.  *  Entry function of About Me -> Select From File -> Delete
  417.  * PARAMETERS
  418.  *  void
  419.  * RETURNS
  420.  *  void
  421.  *****************************************************************************/
  422. void mmi_imps_entry_about_pic_view(void)
  423. {
  424.     /*----------------------------------------------------------------*/
  425.     /* Local Variables                                                */
  426.     /*----------------------------------------------------------------*/
  427.     /*----------------------------------------------------------------*/
  428.     /* Code Body                                                      */
  429.     /*----------------------------------------------------------------*/
  430.     EntryNewScreen(SCR_ID_IMPS_ABOUT_ME_VIEW_PIC, NULL, mmi_imps_entry_about_pic_view, NULL);
  431.     ShowCategory222Screen(
  432.         STR_GLOBAL_VIEW,
  433.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  434.         0,
  435.         0,
  436.         STR_GLOBAL_BACK,
  437.         IMG_GLOBAL_BACK,
  438.         GDI_COLOR_WHITE,
  439.         NULL,
  440.         (S8*) imps_p->about_info->file_buff,
  441.         FALSE,
  442.         NULL);
  443.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  444. }
  445. /*****************************************************************************
  446.  * FUNCTION
  447.  *  mmi_imps_entry_about_pic_del
  448.  * DESCRIPTION
  449.  *  Entry function of About Me -> Select From File -> Delete
  450.  * PARAMETERS
  451.  *  void
  452.  * RETURNS
  453.  *  void
  454.  *****************************************************************************/
  455. void mmi_imps_entry_about_pic_del(void)
  456. {
  457.     /*----------------------------------------------------------------*/
  458.     /* Local Variables                                                */
  459.     /*----------------------------------------------------------------*/
  460.     /*----------------------------------------------------------------*/
  461.     /* Code Body                                                      */
  462.     /*----------------------------------------------------------------*/
  463.     imps_p->about_info->is_pic = FALSE;
  464.     imps_p->about_info->is_pic_changed = TRUE;
  465.     imps_p->about_info->file_buff[0] = 0;
  466.     imps_p->about_info->file_buff[1] = 0;
  467.     imps_p->about_info->pic_name[0] = 0;
  468.     imps_p->about_info->pic_name[1] = 0;
  469.     mmi_imps_util_disp_popup_done();
  470.     DeleteUptoScrID(SCR_ID_IMPS_ABOUT_ME_SEL_FILE);
  471. }
  472. /*****************************************************************************
  473.  * FUNCTION
  474.  *  mmi_imps_about_me_save
  475.  * DESCRIPTION
  476.  *  LSK handler for About Me editor screen
  477.  * PARAMETERS
  478.  *  void
  479.  * RETURNS
  480.  *  void
  481.  *****************************************************************************/
  482. void mmi_imps_about_me_save(void)
  483. {
  484.     /*----------------------------------------------------------------*/
  485.     /* Local Variables                                                */
  486.     /*----------------------------------------------------------------*/
  487.     /*----------------------------------------------------------------*/
  488.     /* Code Body                                                      */
  489.     /*----------------------------------------------------------------*/
  490.     mmi_imps_entry_confirm(STR_GLOBAL_SAVE, mmi_imps_about_me_save_yes, mmi_imps_about_me_save_no);
  491. }
  492. /*****************************************************************************
  493.  * FUNCTION
  494.  *  mmi_imps_about_me_save_no
  495.  * DESCRIPTION
  496.  *  Give up saving About Me
  497.  * PARAMETERS
  498.  *  void
  499.  * RETURNS
  500.  *  void
  501.  *****************************************************************************/
  502. void mmi_imps_about_me_save_no(void)
  503. {
  504.     /*----------------------------------------------------------------*/
  505.     /* Local Variables                                                */
  506.     /*----------------------------------------------------------------*/
  507.     /*----------------------------------------------------------------*/
  508.     /* Code Body                                                      */
  509.     /*----------------------------------------------------------------*/
  510.     DeleteUptoScrID(SCR_ID_IMPS_CONT_OPT);
  511.     GoBackHistory();
  512. }
  513. /*****************************************************************************
  514.  * FUNCTION
  515.  *  mmi_imps_about_me_save_yes
  516.  * DESCRIPTION
  517.  *  Proceed saving About Me
  518.  * PARAMETERS
  519.  *  void
  520.  * RETURNS
  521.  *  void
  522.  *****************************************************************************/
  523. void mmi_imps_about_me_save_yes(void)
  524. {
  525.     /*----------------------------------------------------------------*/
  526.     /* Local Variables                                                */
  527.     /*----------------------------------------------------------------*/
  528.     mmi_imps_about_me_struct *about_info = imps_p->about_info;
  529.     /*----------------------------------------------------------------*/
  530.     /* Code Body                                                      */
  531.     /*----------------------------------------------------------------*/
  532.     mmi_imps_display_progressing();
  533.     /* check picture state */
  534.     if (about_info->is_pic && pfnUnicodeStrlen((S8*) about_info->file_buff) > 0)
  535.     {
  536.         about_info->is_pic = TRUE;
  537.         if (pfnUnicodeStrcmp((S8*) about_info->my_pic, (S8*) about_info->file_buff))
  538.         {
  539.             if (pfnUnicodeStrlen((S8*) about_info->my_pic)) /* remove previous file if exists */
  540.             {
  541.                 FS_Delete((U16*) about_info->my_pic);
  542.             }
  543.             mmi_imps_util_get_img_path((S8*) about_info->my_pic);
  544.             pfnUnicodeStrcat((S8*) about_info->my_pic, (S8*) IMPS_ABOUT_PIC_PREFIX);
  545.             pfnUnicodeStrcat(
  546.                 (S8*) about_info->my_pic,
  547.                 (S8*) mmi_fmgr_extract_ext_file_name((S8*) about_info->file_buff));
  548.             FS_Delete((U16*) about_info->my_pic);
  549.             /* special case for file copy, if the user press END key before copy finished, the state will become mismatch, 
  550.                that cause us to free about_info buffer when screen is deleted */
  551.             imps_p->gen_info.curr_action = MSG_ID_MMI_IMPS_UPDATE_PA_REQ;
  552.             mmi_fmgr_send_copy_req(
  553.                 FMGR_ACTION_COPY,
  554.                 (U8*) about_info->file_buff,
  555.                 (U8*) about_info->my_pic,
  556.                 mmi_imps_about_save_pic_callback);
  557.             return;
  558.         }
  559.         about_info->is_pic_changed = FALSE;
  560.     }
  561.     else
  562.     {
  563.         if (pfnUnicodeStrlen((S8*) about_info->my_pic)) /* remove previous file if exists */
  564.         {
  565.             FS_Delete((U16*) about_info->my_pic);
  566.             about_info->my_pic[0] = 0;
  567.         }
  568.         about_info->is_pic = FALSE;
  569.         about_info->is_pic_changed = TRUE;
  570.     }
  571.     mmi_imps_about_me_write_to_nvram();
  572. }
  573. /*****************************************************************************
  574.  * FUNCTION
  575.  *  mmi_imps_about_save_pic_callback
  576.  * DESCRIPTION
  577.  *  Callback function for copying picture of About Me
  578.  * PARAMETERS
  579.  *  info        [?]     
  580.  * RETURNS
  581.  *  void
  582.  *****************************************************************************/
  583. void mmi_imps_about_save_pic_callback(void *info)
  584. {
  585.     /*----------------------------------------------------------------*/
  586.     /* Local Variables                                                */
  587.     /*----------------------------------------------------------------*/
  588.     mmi_fmt_copy_rsp_strcut *msgPtr;
  589.     /*----------------------------------------------------------------*/
  590.     /* Code Body                                                      */
  591.     /*----------------------------------------------------------------*/
  592.     msgPtr = (mmi_fmt_copy_rsp_strcut*) info;
  593.     if (msgPtr->result >= 0)
  594.     {
  595.         mmi_imps_about_me_write_to_nvram();
  596.     }
  597.     else
  598.     {
  599.         imps_p->gen_info.curr_action = 0;
  600.         mmi_imps_util_disp_err_popup(GetFileSystemErrorString(msgPtr->result));
  601.         DeleteUptoScrID(SCR_ID_IMPS_ABOUT_ME_INLINE);
  602.     }
  603. }
  604. /*****************************************************************************
  605.  * FUNCTION
  606.  *  mmi_imps_about_me_write_to_nvram
  607.  * DESCRIPTION
  608.  *  Write About Me info to NVRAM and send request to protocol
  609.  * PARAMETERS
  610.  *  void
  611.  * RETURNS
  612.  *  void
  613.  *****************************************************************************/
  614. void mmi_imps_about_me_write_to_nvram(void)
  615. {
  616.     /*----------------------------------------------------------------*/
  617.     /* Local Variables                                                */
  618.     /*----------------------------------------------------------------*/
  619.     mmi_imps_nvram_struct *nvram_buff = (mmi_imps_nvram_struct*) OslMalloc(sizeof(mmi_imps_nvram_struct));
  620.     /*----------------------------------------------------------------*/
  621.     /* Code Body                                                      */
  622.     /*----------------------------------------------------------------*/
  623.     /* read data from NVRAM to sync */
  624.     mmi_imps_util_read_nvram((void*)nvram_buff);
  625.     /* picture */
  626.     if (imps_p->about_info->is_pic_changed)
  627.     {
  628.         nvram_buff->about_me.is_pic = (U8) imps_p->about_info->is_pic;
  629.         if (imps_p->about_info->is_pic) /* extract file extension */
  630.         {
  631.             pfnUnicodeStrcpy(
  632.                 (S8*) nvram_buff->about_me.pic_name,
  633.                 (S8*) imps_p->about_info->pic_name/*mmi_fmgr_extract_file_name((S8*) imps_p->about_info->file_buff)*/);
  634.         }
  635.     }
  636.     /* status */
  637.     nvram_buff->about_me.status = (U8) imps_p->about_info->status;
  638.     nvram_buff->about_me.mood = (U8) imps_p->about_info->mood;
  639.     /* my profile */
  640.     pfnUnicodeStrcpy((S8*) nvram_buff->about_me.my_prof, (S8*) imps_p->about_info->my_prof);
  641.     mmi_imps_util_write_nvram((void*)nvram_buff);
  642.     OslMfree(nvram_buff);
  643.     /* send request to protocol */
  644. #ifdef IMPS_TEST_CODE
  645.     mmi_imps_about_me_save_done(0);
  646. #else 
  647.     mmi_imps_ps_update_pa_req();
  648. #endif 
  649. }
  650. /*****************************************************************************
  651.  * FUNCTION
  652.  *  mmi_imps_about_me_save_done
  653.  * DESCRIPTION
  654.  *  Callback function when update presence response comes.
  655.  * PARAMETERS
  656.  *  result      [IN]        
  657.  * RETURNS
  658.  *  void
  659.  *****************************************************************************/
  660. void mmi_imps_about_me_save_done(S32 result)
  661. {
  662.     /*----------------------------------------------------------------*/
  663.     /* Local Variables                                                */
  664.     /*----------------------------------------------------------------*/
  665.     /*----------------------------------------------------------------*/
  666.     /* Code Body                                                      */
  667.     /*----------------------------------------------------------------*/
  668.     if (result == 0)
  669.     {
  670.         mmi_imps_util_disp_popup_done();
  671.         /* update contact list of myself */
  672.         imps_p->cont_info.cont_list[0].availability = (U8) imps_p->about_info->status;
  673.     }
  674.     else
  675.     {
  676.         /* display popup with error message */
  677.         mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(result));
  678.     }
  679.     if (imps_p->gen_info.is_reentry)
  680.     {
  681.         mmi_imps_re_entry_app();
  682.         /* free about me buffer */
  683.         mmi_imps_free_about_me_buff();
  684.     }
  685.     else
  686.     {
  687.         if (result == 0)
  688.         {
  689.             mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CONT);
  690.         }
  691.         else
  692.         {
  693.             mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ABOUT_ME_INLINE);
  694.         }
  695.     }
  696. }
  697. #define _ABOUT_FRIEND_IMPS
  698. /*****************************************************************************
  699.  * FUNCTION
  700.  *  mmi_imps_hilite_about_friend
  701.  * DESCRIPTION
  702.  *  Highlight handler of Contact List -> About
  703.  *  Me (Friends)
  704.  * PARAMETERS
  705.  *  void
  706.  * RETURNS
  707.  *  void
  708.  *****************************************************************************/
  709. void mmi_imps_hilite_about_friend(void)
  710. {
  711.     /*----------------------------------------------------------------*/
  712.     /* Local Variables                                                */
  713.     /*----------------------------------------------------------------*/
  714.     /*----------------------------------------------------------------*/
  715.     /* Code Body                                                      */
  716.     /*----------------------------------------------------------------*/
  717.     SetLeftSoftkeyFunction(mmi_imps_entry_about_friend, KEY_EVENT_UP);
  718.     SetKeyHandler(mmi_imps_entry_about_friend, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  719. }
  720. /*****************************************************************************
  721.  * FUNCTION
  722.  *  mmi_imps_entry_about_friend
  723.  * DESCRIPTION
  724.  *  Entry function of Contact List -> About Me (Friends)
  725.  * PARAMETERS
  726.  *  void
  727.  * RETURNS
  728.  *  void
  729.  *****************************************************************************/
  730. void mmi_imps_entry_about_friend(void)
  731. {
  732.     /*----------------------------------------------------------------*/
  733.     /* Local Variables                                                */
  734.     /*----------------------------------------------------------------*/
  735.     U8 *guiBuffer;
  736.     S32 i;
  737.     S8 *img = NULL;
  738.     U8 tmp_availability = IMPS_PA_USER_NOT_AVAILABLE;
  739.     mmi_imps_cont_struct *cont = &imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont];
  740.     /*----------------------------------------------------------------*/
  741.     /* Code Body                                                      */
  742.     /*----------------------------------------------------------------*/
  743.     if (!imps_p->gen_info.auto_update_done)
  744.     {
  745.         mmi_imps_util_disp_warning_popup(STR_ID_IMPS_ERR_CONT_NOT_READY);
  746.         return;
  747.     }
  748.     i = (S32) imps_p->cont_info.curr_cont;
  749.     /* different contact, reset data */
  750.     if (mmi_imps_util_is_id_same((S8*) imps_p->friend_info.id, (S8*) cont->id) == FALSE)
  751.     {
  752.         imps_p->friend_info.file_name[0] = 0;
  753.         strcpy((S8*) imps_p->friend_info.id, (S8*) cont->id);
  754.     }
  755.     else
  756.     {
  757.         if (pfnUnicodeStrlen((S8*) imps_p->friend_info.file_name))
  758.         {
  759.             mmi_imps_util_get_img_path((S8*) imps_p->path_buff);
  760.             pfnUnicodeStrcat((S8*) imps_p->path_buff, (S8*) imps_p->friend_info.file_name);
  761.             img = (S8*) imps_p->path_buff;
  762.         }
  763.     }
  764.     /* set to un-available when status unknown */
  765.     if (cont->availability != IMPS_PA_USER_UNKNOWN)
  766.     {
  767.         tmp_availability = cont->availability;
  768.     }
  769.     if (pfnUnicodeStrlen((S8*) cont->nick_name) == 0)
  770.     {
  771.         S8 *id_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
  772.         AnsiiToUnicodeString((S8*) id_buff, (S8*) cont->id);
  773.         mmi_imps_util_copy_with_dot((S8*) id_buff, (S8*) cont->nick_name, IMPS_MAX_NAME_LEN);
  774.         OslMfree(id_buff);
  775.     }
  776.     EntryNewScreen(SCR_ID_IMPS_ABOUT_FRIEND, NULL, mmi_imps_entry_about_friend, NULL);
  777.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ABOUT_FRIEND);
  778.     if (imps_p->cont_info.clear_gui_buff)
  779.     {
  780.         guiBuffer = NULL;
  781.     }
  782.     ShowCategory420Screen(
  783.         STR_ID_IMPS_VIEW_CONT_DETAIL,
  784.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  785.         STR_GLOBAL_OPTIONS,
  786.         IMG_GLOBAL_OK,
  787.         STR_GLOBAL_BACK,
  788.         IMG_GLOBAL_BACK,
  789.         cont->nick_name,
  790.         img,
  791.         IMG_ID_IMPS_ABOUT_DEFAULT,
  792.         STR_ID_IMPS_MOOD,
  793.         (UI_string_type) GetString((U16) (cont->mood + STR_ID_IMPS_HAPPY)),
  794.         (PU8) GetImage((U16) (cont->mood + IMG_ID_IMPS_HAPPY)),
  795.         STR_ID_IMPS_STATUS,
  796.         (UI_string_type) GetString((U16) (tmp_availability + STR_ID_IMPS_ONLINE)),
  797.         (PU8) GetImage((U16) (tmp_availability + IMG_ID_IMPS_ABOUT_ONLINE)),
  798.         (U8*) cont->prof_text,
  799.         (S32) pfnUnicodeStrlen((S8*) cont->prof_text),
  800.         guiBuffer);
  801.     SetLeftSoftkeyFunction(mmi_imps_entry_about_friend_opt, KEY_EVENT_UP);
  802.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  803. }
  804. /*****************************************************************************
  805.  * FUNCTION
  806.  *  mmi_imps_entry_about_friend_opt
  807.  * DESCRIPTION
  808.  *  Entry optino screen of Friend's Detail
  809.  * PARAMETERS
  810.  *  void
  811.  * RETURNS
  812.  *  void
  813.  *****************************************************************************/
  814. void mmi_imps_entry_about_friend_opt(void)
  815. {
  816.     /*----------------------------------------------------------------*/
  817.     /* Local Variables                                                */
  818.     /*----------------------------------------------------------------*/
  819.     U16 numItems;
  820.     U16 nStrItemList[2];
  821.     U8 *guiBuffer;
  822.     /*----------------------------------------------------------------*/
  823.     /* Code Body                                                      */
  824.     /*----------------------------------------------------------------*/
  825.     EntryNewScreen(SCR_ID_IMPS_ABOUT_FRIEND_OPT, NULL, mmi_imps_entry_about_friend_opt, NULL);
  826.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ABOUT_FRIEND_OPT);
  827.     SetParentHandler(MENU_ID_IMPS_ABOUT_FRIEND_OPT);
  828.     numItems = GetNumOfChild(MENU_ID_IMPS_ABOUT_FRIEND_OPT);
  829.     GetSequenceStringIds(MENU_ID_IMPS_ABOUT_FRIEND_OPT, nStrItemList);
  830.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  831.     ShowCategory52Screen(
  832.         STR_GLOBAL_OPTIONS,
  833.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  834.         STR_GLOBAL_OK,
  835.         IMG_GLOBAL_OK,
  836.         STR_GLOBAL_BACK,
  837.         IMG_GLOBAL_BACK,
  838.         numItems,
  839.         nStrItemList,
  840.         (U16*) gIndexIconsImageList,
  841.         NULL,
  842.         0,
  843.         0,
  844.         guiBuffer);
  845.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  846.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  847. }
  848. /*****************************************************************************
  849.  * FUNCTION
  850.  *  mmi_imps_hilite_about_friend_edit
  851.  * DESCRIPTION
  852.  *  Highlight handler of Friend's Detail -> Option -> Edit
  853.  * PARAMETERS
  854.  *  void
  855.  * RETURNS
  856.  *  void
  857.  *****************************************************************************/
  858. void mmi_imps_hilite_about_friend_edit(void)
  859. {
  860.     /*----------------------------------------------------------------*/
  861.     /* Local Variables                                                */
  862.     /*----------------------------------------------------------------*/
  863.     /*----------------------------------------------------------------*/
  864.     /* Code Body                                                      */
  865.     /*----------------------------------------------------------------*/
  866.     SetLeftSoftkeyFunction(mmi_imps_pre_entry_about_friend_edit, KEY_EVENT_UP);
  867.     SetKeyHandler(mmi_imps_pre_entry_about_friend_edit, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  868. }
  869. /*****************************************************************************
  870.  * FUNCTION
  871.  *  mmi_imps_hilite_about_friend_refresh
  872.  * DESCRIPTION
  873.  *  Highlight handler of Friend's Detail -> Option -> Refresh
  874.  * PARAMETERS
  875.  *  void
  876.  * RETURNS
  877.  *  void
  878.  *****************************************************************************/
  879. void mmi_imps_hilite_about_friend_refresh(void)
  880. {
  881.     /*----------------------------------------------------------------*/
  882.     /* Local Variables                                                */
  883.     /*----------------------------------------------------------------*/
  884.     /*----------------------------------------------------------------*/
  885.     /* Code Body                                                      */
  886.     /*----------------------------------------------------------------*/
  887.     SetLeftSoftkeyFunction(mmi_imps_about_friend_refersh, KEY_EVENT_UP);
  888. }
  889. /*****************************************************************************
  890.  * FUNCTION
  891.  *  mmi_imps_pre_entry_about_friend_edit
  892.  * DESCRIPTION
  893.  *  Pre-Entry fnuction of Friend's Detail -> Option -> Edit
  894.  * PARAMETERS
  895.  *  void
  896.  * RETURNS
  897.  *  void
  898.  *****************************************************************************/
  899. void mmi_imps_pre_entry_about_friend_edit(void)
  900. {
  901.     /*----------------------------------------------------------------*/
  902.     /* Local Variables                                                */
  903.     /*----------------------------------------------------------------*/
  904.     mmi_imps_cont_struct *cont = &imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont];
  905.     /*----------------------------------------------------------------*/
  906.     /* Code Body                                                      */
  907.     /*----------------------------------------------------------------*/
  908.     pfnUnicodeStrcpy((S8*) imps_p->file_buff, (S8*) cont->nick_name);
  909.     /* re-use input name screen */
  910.     mmi_imps_entry_cont_input_name();
  911. }
  912. /*****************************************************************************
  913.  * FUNCTION
  914.  *  mmi_imps_about_friend_edit_done
  915.  * DESCRIPTION
  916.  *  Proceed editing friend's name
  917.  * PARAMETERS
  918.  *  void
  919.  * RETURNS
  920.  *  void
  921.  *****************************************************************************/
  922. void mmi_imps_about_friend_edit_done(void)
  923. {
  924.     /*----------------------------------------------------------------*/
  925.     /* Local Variables                                                */
  926.     /*----------------------------------------------------------------*/
  927.     mmi_imps_cont_struct *cont = &imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont];
  928.     /*----------------------------------------------------------------*/
  929.     /* Code Body                                                      */
  930.     /*----------------------------------------------------------------*/
  931.     pfnUnicodeStrcpy((S8*) cont->nick_name, (S8*) imps_p->file_buff);
  932.     /* should save after response back */
  933.     /* mmi_imps_util_write_cont(); */
  934.     mmi_imps_display_progressing();
  935.     mmi_imps_edit_cont_req((U8*) cont->group_id, (U8*) cont->id, (S8*) cont->nick_name);
  936.     /* force to redraw contact list */
  937.     imps_p->cont_info.clear_gui_buff = TRUE;
  938. }
  939. /*****************************************************************************
  940.  * FUNCTION
  941.  *  mmi_imps_about_friend_edit_finish
  942.  * DESCRIPTION
  943.  *  Result of Edit
  944.  * PARAMETERS
  945.  *  result      [IN]        
  946.  * RETURNS
  947.  *  void
  948.  *****************************************************************************/
  949. void mmi_imps_about_friend_edit_finish(S32 result)
  950. {
  951.     /*----------------------------------------------------------------*/
  952.     /* Local Variables                                                */
  953.     /*----------------------------------------------------------------*/
  954.     U16 active_scr = GetActiveScreenId();
  955.     /*----------------------------------------------------------------*/
  956.     /* Code Body                                                      */
  957.     /*----------------------------------------------------------------*/
  958.     /* 
  959.      * partial success, subscribe error (server not support)
  960.      * regard it as success
  961.      */
  962.     if (result == IMPS_OK || result == IMPS_ERROR_SUBSCRIPTION_NOT_SUPPORT)
  963.     {
  964.      mmi_imps_util_write_cont();
  965.         mmi_imps_util_disp_popup_done();
  966.     }
  967.     else
  968.     {
  969.         mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(result));
  970.     }
  971.     if (imps_p->gen_info.is_reentry)
  972.     {
  973.         mmi_imps_re_entry_app();
  974.     }
  975.     else
  976.     {
  977.         if (active_scr == SCR_ID_IMPS_PROGRESS)
  978.         {
  979.             mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ABOUT_FRIEND);
  980.         }
  981.     }
  982.     /* force to redraw contact list */
  983.     imps_p->cont_info.clear_gui_buff = TRUE;
  984.     imps_p->gen_info.is_reentry = FALSE;
  985. }
  986. /*****************************************************************************
  987.  * FUNCTION
  988.  *  mmi_imps_about_friend_refersh
  989.  * DESCRIPTION
  990.  *  Refresh status of friend
  991.  * PARAMETERS
  992.  *  void
  993.  * RETURNS
  994.  *  void
  995.  *****************************************************************************/
  996. void mmi_imps_about_friend_refersh(void)
  997. {
  998.     /*----------------------------------------------------------------*/
  999.     /* Local Variables                                                */
  1000.     /*----------------------------------------------------------------*/
  1001.     /*----------------------------------------------------------------*/
  1002.     /* Code Body                                                      */
  1003.     /*----------------------------------------------------------------*/
  1004.     mmi_imps_pre_entry_progressing(
  1005.         STR_ID_IMPS,
  1006.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1007.         0,
  1008.         0,
  1009.         STR_GLOBAL_ABORT,
  1010.         0,
  1011.         (U8*) GetString(STR_ID_IMPS_PROGRESSING),
  1012.         NULL,
  1013.         IMG_GLOBAL_PROGRESS,
  1014.         NULL,
  1015.         mmi_imps_about_friend_abort,
  1016.         mmi_imps_about_friend_abort);
  1017. #ifdef IMPS_TEST_CODE
  1018.     SetKeyHandler(mmi_imps_about_friend_refresh_finish, KEY_SEND, KEY_EVENT_DOWN);
  1019. #else 
  1020.     mmi_imps_ps_get_single_pa_req((U8*) imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont].id);
  1021. #endif 
  1022. }
  1023. /*****************************************************************************
  1024.  * FUNCTION
  1025.  *  mmi_imps_about_friend_abort
  1026.  * DESCRIPTION
  1027.  *  About refresh
  1028.  * PARAMETERS
  1029.  *  void
  1030.  * RETURNS
  1031.  *  void
  1032.  *****************************************************************************/
  1033. void mmi_imps_about_friend_abort(void)
  1034. {
  1035.     /*----------------------------------------------------------------*/
  1036.     /* Local Variables                                                */
  1037.     /*----------------------------------------------------------------*/
  1038.     /*----------------------------------------------------------------*/
  1039.     /* Code Body                                                      */
  1040.     /*----------------------------------------------------------------*/
  1041.     mmi_imps_entry_abort();
  1042. #ifdef IMPS_TEST_CODE
  1043.     SetKeyHandler(mmi_imps_about_friend_refresh_finish, KEY_SEND, KEY_EVENT_DOWN);
  1044. #else 
  1045.     mmi_imps_abort_get_pa_req();
  1046. #endif 
  1047. }
  1048. /*****************************************************************************
  1049.  * FUNCTION
  1050.  *  mmi_imps_about_friend_refresh_finish
  1051.  * DESCRIPTION
  1052.  *  Finish refreshing status of friend
  1053.  * PARAMETERS
  1054.  *  void
  1055.  * RETURNS
  1056.  *  void
  1057.  *****************************************************************************/
  1058. void mmi_imps_about_friend_refresh_finish( /* S32 result */ void)
  1059. {
  1060.     /*----------------------------------------------------------------*/
  1061.     /* Local Variables                                                */
  1062.     /*----------------------------------------------------------------*/
  1063.     /*----------------------------------------------------------------*/
  1064.     /* Code Body                                                      */
  1065.     /*----------------------------------------------------------------*/
  1066.     if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
  1067.     {
  1068.         GoBackToHistory(SCR_ID_IMPS_ABOUT_FRIEND);
  1069.     }
  1070.     else
  1071.     {
  1072.         mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ABOUT_FRIEND);
  1073.     }
  1074.     /* force to redraw contact list */
  1075.     imps_p->cont_info.clear_gui_buff = TRUE;
  1076. }
  1077. #define SORT_IMPS
  1078. /*****************************************************************************
  1079.  * FUNCTION
  1080.  *  mmi_imps_sort_save
  1081.  * DESCRIPTION
  1082.  *  Save sorting type to NVRAM
  1083.  * PARAMETERS
  1084.  *  void
  1085.  * RETURNS
  1086.  *  void
  1087.  *****************************************************************************/
  1088. void mmi_imps_sort_save(void)
  1089. {
  1090.     /*----------------------------------------------------------------*/
  1091.     /* Local Variables                                                */
  1092.     /*----------------------------------------------------------------*/
  1093.     mmi_imps_nvram_struct *nvram_buff = (mmi_imps_nvram_struct*) OslMalloc(sizeof(mmi_imps_nvram_struct));
  1094.     /*----------------------------------------------------------------*/
  1095.     /* Code Body                                                      */
  1096.     /*----------------------------------------------------------------*/
  1097.     /* read data from NVRAM */
  1098.     mmi_imps_util_read_nvram((void*)nvram_buff);
  1099.     nvram_buff->sort_type = (U8) imps_p->cont_info.sort_type;
  1100.     mmi_imps_util_write_nvram((void*)nvram_buff);
  1101.     OslMfree(nvram_buff);
  1102. }
  1103. /*****************************************************************************
  1104.  * FUNCTION
  1105.  *  mmi_imps_hilite_sort
  1106.  * DESCRIPTION
  1107.  *  Highlight handler of Contact List -> Sort option
  1108.  * PARAMETERS
  1109.  *  void
  1110.  * RETURNS
  1111.  *  void
  1112.  *****************************************************************************/
  1113. void mmi_imps_hilite_sort(void)
  1114. {
  1115.     /*----------------------------------------------------------------*/
  1116.     /* Local Variables                                                */
  1117.     /*----------------------------------------------------------------*/
  1118.     /*----------------------------------------------------------------*/
  1119.     /* Code Body                                                      */
  1120.     /*----------------------------------------------------------------*/
  1121.     SetLeftSoftkeyFunction(mmi_imps_entry_sort, KEY_EVENT_UP);
  1122.     SetKeyHandler(mmi_imps_entry_sort, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1123. }
  1124. /*****************************************************************************
  1125.  * FUNCTION
  1126.  *  mmi_imps_entry_sort
  1127.  * DESCRIPTION
  1128.  *  Entry function of Contact List -> Sort option
  1129.  * PARAMETERS
  1130.  *  void
  1131.  * RETURNS
  1132.  *  void
  1133.  *****************************************************************************/
  1134. void mmi_imps_entry_sort(void)
  1135. {
  1136.     /*----------------------------------------------------------------*/
  1137.     /* Local Variables                                                */
  1138.     /*----------------------------------------------------------------*/
  1139.     U16 numItems;
  1140.     U16 nStrItemList[3];    /* only Login and Profile Setting */
  1141.     U8 *guiBuffer;
  1142.     /*----------------------------------------------------------------*/
  1143.     /* Code Body                                                      */
  1144.     /*----------------------------------------------------------------*/
  1145.     if (!imps_p->gen_info.auto_update_done)
  1146.     {
  1147.         mmi_imps_util_disp_warning_popup(STR_ID_IMPS_ERR_CONT_NOT_READY);
  1148.         return;
  1149.     }
  1150.     EntryNewScreen(SCR_ID_IMPS_SORT, NULL, mmi_imps_entry_sort, NULL);
  1151.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_SORT);
  1152.     SetParentHandler(MENU_ID_IMPS_CONT_SORT);
  1153.     numItems = GetNumOfChild(MENU_ID_IMPS_CONT_SORT);
  1154.     GetSequenceStringIds(MENU_ID_IMPS_CONT_SORT, nStrItemList);
  1155.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1156.     ShowCategory52Screen(
  1157.         STR_ID_IMPS_SORT_LIST,
  1158.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1159.         STR_GLOBAL_OK,
  1160.         IMG_GLOBAL_OK,
  1161.         STR_GLOBAL_BACK,
  1162.         IMG_GLOBAL_BACK,
  1163.         numItems,
  1164.         nStrItemList,
  1165.         (U16*) gIndexIconsImageList,
  1166.         NULL,
  1167.         0,
  1168.         0,
  1169.         guiBuffer);
  1170.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1171.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1172. }
  1173. /*****************************************************************************
  1174.  * FUNCTION
  1175.  *  mmi_imps_hilite_sort_by_name
  1176.  * DESCRIPTION
  1177.  *  Highlight handler of Contact List -> Sort -> By Name option
  1178.  * PARAMETERS
  1179.  *  void
  1180.  * RETURNS
  1181.  *  void
  1182.  *****************************************************************************/
  1183. void mmi_imps_hilite_sort_by_name(void)
  1184. {
  1185.     /*----------------------------------------------------------------*/
  1186.     /* Local Variables                                                */
  1187.     /*----------------------------------------------------------------*/
  1188.     /*----------------------------------------------------------------*/
  1189.     /* Code Body                                                      */
  1190.     /*----------------------------------------------------------------*/
  1191.     SetLeftSoftkeyFunction(mmi_imps_entry_sort_by_name, KEY_EVENT_UP);
  1192. }
  1193. /*****************************************************************************
  1194.  * FUNCTION
  1195.  *  mmi_imps_entry_sort_by_name
  1196.  * DESCRIPTION
  1197.  *  Handler of Contact List -> Sort -> By Name option
  1198.  * PARAMETERS
  1199.  *  void
  1200.  * RETURNS
  1201.  *  void
  1202.  *****************************************************************************/
  1203. void mmi_imps_entry_sort_by_name(void)
  1204. {
  1205.     /*----------------------------------------------------------------*/
  1206.     /* Local Variables                                                */
  1207.     /*----------------------------------------------------------------*/
  1208.     /*----------------------------------------------------------------*/
  1209.     /* Code Body                                                      */
  1210.     /*----------------------------------------------------------------*/
  1211.     imps_p->cont_info.sort_type = IMPS_SORT_BY_NAME;
  1212.     mmi_imps_sort_save();
  1213.     imps_p->cont_info.clear_gui_buff = TRUE;
  1214.     GoBackToHistory(SCR_ID_IMPS_CONT);
  1215. }
  1216. /*****************************************************************************
  1217.  * FUNCTION
  1218.  *  mmi_imps_hilite_sort_by_status
  1219.  * DESCRIPTION
  1220.  *  Highlight handler of Contact List -> Sort -> By Status option
  1221.  * PARAMETERS
  1222.  *  void
  1223.  * RETURNS
  1224.  *  void
  1225.  *****************************************************************************/
  1226. void mmi_imps_hilite_sort_by_status(void)
  1227. {
  1228.     /*----------------------------------------------------------------*/
  1229.     /* Local Variables                                                */
  1230.     /*----------------------------------------------------------------*/
  1231.     /*----------------------------------------------------------------*/
  1232.     /* Code Body                                                      */
  1233.     /*----------------------------------------------------------------*/
  1234.     SetLeftSoftkeyFunction(mmi_imps_entry_sort_by_status, KEY_EVENT_UP);
  1235. }
  1236. /*****************************************************************************
  1237.  * FUNCTION
  1238.  *  mmi_imps_entry_sort_by_status
  1239.  * DESCRIPTION
  1240.  *  Handler of Contact List -> Sort -> By Status option
  1241.  * PARAMETERS
  1242.  *  void
  1243.  * RETURNS
  1244.  *  void
  1245.  *****************************************************************************/
  1246. void mmi_imps_entry_sort_by_status(void)
  1247. {
  1248.     /*----------------------------------------------------------------*/
  1249.     /* Local Variables                                                */
  1250.     /*----------------------------------------------------------------*/
  1251.     /*----------------------------------------------------------------*/
  1252.     /* Code Body                                                      */
  1253.     /*----------------------------------------------------------------*/
  1254.     imps_p->cont_info.sort_type = IMPS_SORT_BY_STATUS;
  1255.     mmi_imps_sort_save();
  1256.     imps_p->cont_info.clear_gui_buff = TRUE;
  1257.     GoBackToHistory(SCR_ID_IMPS_CONT);
  1258. }
  1259. /*****************************************************************************
  1260.  * FUNCTION
  1261.  *  mmi_imps_hilite_sort_by_group
  1262.  * DESCRIPTION
  1263.  *  Highlight handler of Contact List -> Sort -> By Group option
  1264.  * PARAMETERS
  1265.  *  void
  1266.  * RETURNS
  1267.  *  void
  1268.  *****************************************************************************/
  1269. void mmi_imps_hilite_sort_by_group(void)
  1270. {
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Local Variables                                                */
  1273.     /*----------------------------------------------------------------*/
  1274.     /*----------------------------------------------------------------*/
  1275.     /* Code Body                                                      */
  1276.     /*----------------------------------------------------------------*/
  1277.     SetLeftSoftkeyFunction(mmi_imps_entry_sort_by_group, KEY_EVENT_UP);
  1278. }
  1279. /*****************************************************************************
  1280.  * FUNCTION
  1281.  *  mmi_imps_entry_sort_by_group
  1282.  * DESCRIPTION
  1283.  *  Handler of Contact List -> Sort -> By Group option
  1284.  * PARAMETERS
  1285.  *  void
  1286.  * RETURNS
  1287.  *  void
  1288.  *****************************************************************************/
  1289. void mmi_imps_entry_sort_by_group(void)
  1290. {
  1291.     /*----------------------------------------------------------------*/
  1292.     /* Local Variables                                                */
  1293.     /*----------------------------------------------------------------*/
  1294.     /*----------------------------------------------------------------*/
  1295.     /* Code Body                                                      */
  1296.     /*----------------------------------------------------------------*/
  1297.     imps_p->cont_info.sort_type = IMPS_SORT_BY_GROUP;
  1298.     mmi_imps_sort_save();
  1299.     imps_p->cont_info.clear_gui_buff = TRUE;
  1300.     GoBackToHistory(SCR_ID_IMPS_CONT);
  1301. }
  1302. /*****************************************************************************
  1303.  * FUNCTION
  1304.  *  mmi_imps_sort_list
  1305.  * DESCRIPTION
  1306.  *  Sort contact list according to selecting criterion
  1307.  * PARAMETERS
  1308.  *  void
  1309.  * RETURNS
  1310.  *  void
  1311.  *****************************************************************************/
  1312. void mmi_imps_sort_list(void)
  1313. {
  1314.     /*----------------------------------------------------------------*/
  1315.     /* Local Variables                                                */
  1316.     /*----------------------------------------------------------------*/
  1317.     /*----------------------------------------------------------------*/
  1318.     /* Code Body                                                      */
  1319.     /*----------------------------------------------------------------*/
  1320.     switch (imps_p->cont_info.sort_type)
  1321.     {
  1322.         case IMPS_SORT_BY_STATUS:
  1323.             mmi_imps_sort_by_status();
  1324.             break;
  1325.         case IMPS_SORT_BY_GROUP:
  1326.             mmi_imps_sort_by_group();
  1327.             break;
  1328.         default:    /* case IMPS_SORT_BY_NAME: */
  1329.             mmi_imps_sort_by_name();
  1330.             break;
  1331.     }
  1332. }
  1333. /*****************************************************************************
  1334.  * FUNCTION
  1335.  *  mmi_imps_sort_by_name
  1336.  * DESCRIPTION
  1337.  *  Sort list by name
  1338.  * PARAMETERS
  1339.  *  void
  1340.  * RETURNS
  1341.  *  void
  1342.  *****************************************************************************/
  1343. void mmi_imps_sort_by_name(void)
  1344. {
  1345.     /*----------------------------------------------------------------*/
  1346.     /* Local Variables                                                */
  1347.     /*----------------------------------------------------------------*/
  1348.     S32 i, j;
  1349.     S32 count = (S32) imps_p->cont_info.no_cont;
  1350.     mmi_imps_cont_struct *cont_buff = (mmi_imps_cont_struct*) OslMalloc(sizeof(mmi_imps_cont_struct));
  1351.     S8 *str1, *str2;
  1352.     S8 *str_buff1 = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
  1353.     S8 *str_buff2 = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
  1354.     /*----------------------------------------------------------------*/
  1355.     /* Code Body                                                      */
  1356.     /*----------------------------------------------------------------*/
  1357.     for (i = 1; i < count; i++)
  1358.     {
  1359.         for (j = 1; j < count; j++)
  1360.         {
  1361.             if (i >= j)
  1362.             {
  1363.                 continue;
  1364.             }
  1365.             /* compare alais first */
  1366.             if (strlen((S8*) imps_p->cont_info.cont_list[i].nick_name))
  1367.             {
  1368.                 str1 = (S8*) imps_p->cont_info.cont_list[i].nick_name;
  1369.             }
  1370.             else
  1371.             {
  1372.                 AnsiiToUnicodeString(str_buff1, (S8*) imps_p->cont_info.cont_list[i].id);
  1373.                 str1 = str_buff1;
  1374.             }
  1375.             /* compare alais first */
  1376.             if (strlen((S8*) imps_p->cont_info.cont_list[j].nick_name))
  1377.             {
  1378.                 str2 = (S8*) imps_p->cont_info.cont_list[j].nick_name;
  1379.             }
  1380.             else
  1381.             {
  1382.                 AnsiiToUnicodeString(str_buff2, (S8*) imps_p->cont_info.cont_list[j].id);
  1383.                 str2 = str_buff2;
  1384.             }
  1385.             if ((pfnUnicodeStrcmp((S8*) str1, (S8*) str2) > 0))
  1386.             {
  1387.                 memcpy(cont_buff, &imps_p->cont_info.cont_list[j], sizeof(mmi_imps_cont_struct));
  1388.                 memcpy(&imps_p->cont_info.cont_list[j], &imps_p->cont_info.cont_list[i], sizeof(mmi_imps_cont_struct));
  1389.                 memcpy(&imps_p->cont_info.cont_list[i], cont_buff, sizeof(mmi_imps_cont_struct));
  1390.             }
  1391.         }
  1392.     }
  1393.     OslMfree(cont_buff);
  1394.     OslMfree(str_buff1);
  1395.     OslMfree(str_buff2);
  1396. }
  1397. /*****************************************************************************
  1398.  * FUNCTION
  1399.  *  mmi_imps_sort_by_status
  1400.  * DESCRIPTION
  1401.  *  Sort list by status
  1402.  * PARAMETERS
  1403.  *  void
  1404.  * RETURNS
  1405.  *  void
  1406.  *****************************************************************************/
  1407. void mmi_imps_sort_by_status(void)
  1408. {
  1409.     /*----------------------------------------------------------------*/
  1410.     /* Local Variables                                                */
  1411.     /*----------------------------------------------------------------*/
  1412.     S32 i, j;
  1413.     S32 count = (S32) imps_p->cont_info.no_cont;
  1414.     mmi_imps_cont_struct *cont_buff = (mmi_imps_cont_struct*) OslMalloc(sizeof(mmi_imps_cont_struct));
  1415.     /*----------------------------------------------------------------*/
  1416.     /* Code Body                                                      */
  1417.     /*----------------------------------------------------------------*/
  1418.     for (i = 1; i < count; i++)
  1419.     {
  1420.         for (j = 1; j < count; j++)
  1421.         {
  1422.             if ((imps_p->cont_info.cont_list[i].availability > imps_p->cont_info.cont_list[j].availability) && i < j)
  1423.             {
  1424.                 memcpy(cont_buff, &imps_p->cont_info.cont_list[j], sizeof(mmi_imps_cont_struct));
  1425.                 memcpy(&imps_p->cont_info.cont_list[j], &imps_p->cont_info.cont_list[i], sizeof(mmi_imps_cont_struct));
  1426.                 memcpy(&imps_p->cont_info.cont_list[i], cont_buff, sizeof(mmi_imps_cont_struct));
  1427.             }
  1428.         }
  1429.     }
  1430.     OslMfree(cont_buff);
  1431. }
  1432. /*****************************************************************************
  1433.  * FUNCTION
  1434.  *  mmi_imps_sort_by_group
  1435.  * DESCRIPTION
  1436.  *  Sort list by group
  1437.  * PARAMETERS
  1438.  *  void
  1439.  * RETURNS
  1440.  *  void
  1441.  *****************************************************************************/
  1442. void mmi_imps_sort_by_group(void)
  1443. {
  1444.     /*----------------------------------------------------------------*/
  1445.     /* Local Variables                                                */
  1446.     /*----------------------------------------------------------------*/
  1447.     S32 i, j;
  1448.     S32 count = (S32) imps_p->cont_info.no_cont;
  1449.     mmi_imps_cont_struct *cont_buff = (mmi_imps_cont_struct*) OslMalloc(sizeof(mmi_imps_cont_struct));
  1450.     /*----------------------------------------------------------------*/
  1451.     /* Code Body                                                      */
  1452.     /*----------------------------------------------------------------*/
  1453.     for (i = 1; i < count; i++)
  1454.     {
  1455.         for (j = 1; j < count; j++)
  1456.         {
  1457.             if (strcmp((S8*) imps_p->cont_info.cont_list[i].group_id, (S8*) imps_p->cont_info.cont_list[j].group_id) >
  1458.                 0 && i < j)
  1459.             {
  1460.                 memcpy(cont_buff, &imps_p->cont_info.cont_list[j], sizeof(mmi_imps_cont_struct));
  1461.                 memcpy(&imps_p->cont_info.cont_list[j], &imps_p->cont_info.cont_list[i], sizeof(mmi_imps_cont_struct));
  1462.                 memcpy(&imps_p->cont_info.cont_list[i], cont_buff, sizeof(mmi_imps_cont_struct));
  1463.             }
  1464.         }
  1465.     }
  1466.     OslMfree(cont_buff);
  1467. }
  1468. #define ADD_CONTACT
  1469. /*****************************************************************************
  1470.  * FUNCTION
  1471.  *  mmi_imps_hilite_add_cont
  1472.  * DESCRIPTION
  1473.  *  Highlight handler of Contact List -> Add Contact option
  1474.  * PARAMETERS
  1475.  *  void
  1476.  * RETURNS
  1477.  *  void
  1478.  *****************************************************************************/
  1479. void mmi_imps_hilite_add_cont(void)
  1480. {
  1481.     /*----------------------------------------------------------------*/
  1482.     /* Local Variables                                                */
  1483.     /*----------------------------------------------------------------*/
  1484.     /*----------------------------------------------------------------*/
  1485.     /* Code Body                                                      */
  1486.     /*----------------------------------------------------------------*/
  1487.     SetLeftSoftkeyFunction(mmi_imps_entry_add_cont, KEY_EVENT_UP);
  1488.     SetKeyHandler(mmi_imps_entry_add_cont, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1489. }
  1490. /*****************************************************************************
  1491.  * FUNCTION
  1492.  *  mmi_imps_entry_add_cont
  1493.  * DESCRIPTION
  1494.  *  Display available option for Add Contact
  1495.  * PARAMETERS
  1496.  *  void
  1497.  * RETURNS
  1498.  *  void
  1499.  *****************************************************************************/
  1500. void mmi_imps_entry_add_cont(void)
  1501. {
  1502.     /*----------------------------------------------------------------*/
  1503.     /* Local Variables                                                */
  1504.     /*----------------------------------------------------------------*/
  1505.     U16 numItems;
  1506.     U16 nStrItemList[3];
  1507.     U8 *guiBuffer;
  1508.     /*----------------------------------------------------------------*/
  1509.     /* Code Body                                                      */
  1510.     /*----------------------------------------------------------------*/
  1511.     if (!imps_p->gen_info.auto_update_done)
  1512.     {
  1513.         mmi_imps_util_disp_warning_popup(STR_ID_IMPS_ERR_CONT_NOT_READY);
  1514.         return;
  1515.     }
  1516.     else if (imps_p->cont_info.no_cont == IMPS_MAX_NO_CONT)
  1517.     {
  1518.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_ERR_CONT_FULL);
  1519.         return;
  1520.     }
  1521.     else if (imps_p->group_info.no_group == 0)
  1522.     {
  1523.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_ERR_NO_GROUP);
  1524.         return;
  1525.     }
  1526.     EntryNewScreen(SCR_ID_IMPS_ADD_CONT, NULL, mmi_imps_entry_add_cont, NULL);
  1527.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ADD_CONT);
  1528.     SetParentHandler(MENU_ID_IMPS_CONT_ADD);
  1529.     numItems = GetNumOfChild(MENU_ID_IMPS_CONT_ADD);
  1530.     GetSequenceStringIds(MENU_ID_IMPS_CONT_ADD, nStrItemList);
  1531.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1532.     ShowCategory52Screen(
  1533.         STR_GLOBAL_OPTIONS,
  1534.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1535.         STR_GLOBAL_OK,
  1536.         IMG_GLOBAL_OK,
  1537.         STR_GLOBAL_BACK,
  1538.         IMG_GLOBAL_BACK,
  1539.         numItems,
  1540.         nStrItemList,
  1541.         (U16*) gIndexIconsImageList,
  1542.         NULL,
  1543.         0,
  1544.         0,
  1545.         guiBuffer);
  1546.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1547.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1548. }
  1549. /*****************************************************************************
  1550.  * FUNCTION
  1551.  *  mmi_imps_hilite_direct_search
  1552.  * DESCRIPTION
  1553.  *  Highlight handler of direct search option
  1554.  * PARAMETERS
  1555.  *  void
  1556.  * RETURNS
  1557.  *  void
  1558.  *****************************************************************************/
  1559. void mmi_imps_hilite_direct_search(void)
  1560. {
  1561.     /*----------------------------------------------------------------*/
  1562.     /* Local Variables                                                */
  1563.     /*----------------------------------------------------------------*/
  1564.     /*----------------------------------------------------------------*/
  1565.     /* Code Body                                                      */
  1566.     /*----------------------------------------------------------------*/
  1567.     SetLeftSoftkeyFunction(mmi_imps_pre_entry_cont_search, KEY_EVENT_UP);
  1568.     SetKeyHandler(mmi_imps_pre_entry_cont_search, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1569. }
  1570. /*****************************************************************************
  1571.  * FUNCTION
  1572.  *  mmi_imps_hilite_search_from_phb
  1573.  * DESCRIPTION
  1574.  *  Highlight handler of Contact List -> Add Contact -> Search From Phonebook option
  1575.  * PARAMETERS
  1576.  *  void
  1577.  * RETURNS
  1578.  *  void
  1579.  *****************************************************************************/
  1580. void mmi_imps_hilite_search_from_phb(void)
  1581. {
  1582.     /*----------------------------------------------------------------*/
  1583.     /* Local Variables                                                */
  1584.     /*----------------------------------------------------------------*/
  1585.     /*----------------------------------------------------------------*/
  1586.     /* Code Body                                                      */
  1587.     /*----------------------------------------------------------------*/
  1588.     SetLeftSoftkeyFunction(mmi_imps_entry_search_from_phb, KEY_EVENT_UP);
  1589.     SetKeyHandler(mmi_imps_entry_search_from_phb, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1590. }
  1591. /*****************************************************************************
  1592.  * FUNCTION
  1593.  *  mmi_imps_entry_search_from_phb
  1594.  * DESCRIPTION
  1595.  *  Entry function for Contact List -> Add Contact -> Search From Phonebook option
  1596.  * PARAMETERS
  1597.  *  void
  1598.  *  entity(?)
  1599.  * RETURNS
  1600.  *  void
  1601.  *****************************************************************************/
  1602. void mmi_imps_entry_search_from_phb(void)
  1603. {
  1604.     /*----------------------------------------------------------------*/
  1605.     /* Local Variables                                                */
  1606.     /*----------------------------------------------------------------*/
  1607.     /*----------------------------------------------------------------*/
  1608.     /* Code Body                                                      */
  1609.     /*----------------------------------------------------------------*/
  1610.     mmi_phb_generic_enter_list(mmi_imps_search_phb_callback);
  1611. }
  1612. /*****************************************************************************
  1613.  * FUNCTION
  1614.  *  mmi_imps_pre_entry_cont_search
  1615.  * DESCRIPTION
  1616.  *  Pre-Entry function of inline editor screen for Search Contact.
  1617.  * PARAMETERS
  1618.  *  void
  1619.  * RETURNS
  1620.  *  void
  1621.  *****************************************************************************/
  1622. void mmi_imps_pre_entry_cont_search(void)
  1623. {
  1624.     /*----------------------------------------------------------------*/
  1625.     /* Local Variables                                                */
  1626.     /*----------------------------------------------------------------*/
  1627.     /*----------------------------------------------------------------*/
  1628.     /* Code Body                                                      */
  1629.     /*----------------------------------------------------------------*/
  1630.     if (imps_p->search_data == NULL)
  1631.     {
  1632.         imps_p->search_data = (mmi_imps_search_struct*) OslMalloc(sizeof(mmi_imps_search_struct));
  1633.     }
  1634.     imps_p->search_data->username[0] = 0;
  1635.     imps_p->search_data->phone[0] = 0;
  1636.     imps_p->search_data->alias[0] = 0;
  1637.     imps_p->search_data->email[0] = 0;
  1638.     mmi_imps_entry_cont_search();
  1639. }
  1640. /*****************************************************************************
  1641.  * FUNCTION
  1642.  *  mmi_imps_search_phb_callback
  1643.  * DESCRIPTION
  1644.  *  Callback function for phone book search
  1645.  * PARAMETERS
  1646.  *  entity      [?]     
  1647.  * RETURNS
  1648.  *  void
  1649.  *****************************************************************************/
  1650. void mmi_imps_search_phb_callback(MMI_PHB_VCARD_STRUCT *entity)
  1651. {
  1652.     /*----------------------------------------------------------------*/
  1653.     /* Local Variables                                                */
  1654.     /*----------------------------------------------------------------*/
  1655.     /*----------------------------------------------------------------*/
  1656.     /* Code Body                                                      */
  1657.     /*----------------------------------------------------------------*/
  1658.     if (entity != NULL)
  1659.     {
  1660.         mmi_imps_search_struct *search_data;
  1661.         if (imps_p->search_data == NULL)
  1662.         {
  1663.             imps_p->search_data = (mmi_imps_search_struct*) OslMalloc(sizeof(mmi_imps_search_struct));
  1664.             imps_p->search_data->username[0] = 0;
  1665.             imps_p->search_data->phone[0] = 0;
  1666.             imps_p->search_data->alias[0] = 0;
  1667.             imps_p->search_data->email[0] = 0;
  1668.         }
  1669.         search_data = imps_p->search_data;
  1670.         if (strlen((S8*) entity->emailAddress))
  1671.         {
  1672.             AnsiiToUnicodeString((S8*) search_data->email, (S8*) entity->emailAddress);
  1673.         }
  1674.         if (strlen((S8*) entity->number))
  1675.         {
  1676.             AnsiiToUnicodeString((S8*) search_data->phone, (S8*) entity->number);
  1677.         }
  1678.         if (pfnUnicodeStrlen((S8*) entity->name))
  1679.         {
  1680.             pfnUnicodeStrcpy((S8*) search_data->alias, (S8*) entity->name);
  1681.         }
  1682.         mmi_imps_entry_cont_search();
  1683.     }
  1684. }
  1685. /*****************************************************************************
  1686.  * FUNCTION
  1687.  *  mmi_imps_is_search_cont_changed
  1688.  * DESCRIPTION
  1689.  *  
  1690.  * PARAMETERS
  1691.  *  void
  1692.  * RETURNS
  1693.  *  
  1694.  *****************************************************************************/
  1695. BOOL mmi_imps_is_search_cont_changed(void)
  1696. {
  1697.     /*----------------------------------------------------------------*/
  1698.     /* Local Variables                                                */
  1699.     /*----------------------------------------------------------------*/
  1700.     /*----------------------------------------------------------------*/
  1701.     /* Code Body                                                      */
  1702.     /*----------------------------------------------------------------*/
  1703.     if (pfnUnicodeStrlen((S8*) imps_p->search_data->username) ||
  1704.         pfnUnicodeStrlen((S8*) imps_p->search_data->phone) ||
  1705.         pfnUnicodeStrlen((S8*) imps_p->search_data->alias) || pfnUnicodeStrlen((S8*) imps_p->search_data->email))
  1706.     {
  1707.         return TRUE;
  1708.     }
  1709.     else
  1710.     {
  1711.         return FALSE;
  1712.     }
  1713. }
  1714. /*****************************************************************************
  1715.  * FUNCTION
  1716.  *  mmi_imps_hilite_cont_search_item
  1717.  * DESCRIPTION
  1718.  *  
  1719.  * PARAMETERS
  1720.  *  index       [IN]        
  1721.  * RETURNS
  1722.  *  void
  1723.  *****************************************************************************/
  1724. void mmi_imps_hilite_cont_search_item(S32 index)
  1725. {
  1726.     /*----------------------------------------------------------------*/
  1727.     /* Local Variables                                                */
  1728.     /*----------------------------------------------------------------*/
  1729.     /*----------------------------------------------------------------*/
  1730.     /* Code Body                                                      */
  1731.     /*----------------------------------------------------------------*/
  1732.     if (index != 2) /* phone number */
  1733.     {
  1734.         if (mmi_imps_is_search_cont_changed())
  1735.         {
  1736.             ChangeRightSoftkey(STR_GLOBAL_DONE, 0);
  1737.             SetRightSoftkeyFunction(mmi_imps_entryt_search_opt, KEY_EVENT_UP);
  1738.         }
  1739.     }
  1740. }
  1741. /*****************************************************************************
  1742.  * FUNCTION
  1743.  *  mmi_imps_entry_cont_search
  1744.  * DESCRIPTION
  1745.  *  Entry inline editor screen for Search Contact.
  1746.  * PARAMETERS
  1747.  *  void
  1748.  * RETURNS
  1749.  *  void
  1750.  *****************************************************************************/
  1751. void mmi_imps_entry_cont_search(void)
  1752. {
  1753.     /*----------------------------------------------------------------*/
  1754.     /* Local Variables                                                */
  1755.     /*----------------------------------------------------------------*/
  1756.     U8 *guiBuffer;
  1757.     U8 *inputBuffer;
  1758.     U16 inputBufferSize;
  1759.     /*----------------------------------------------------------------*/
  1760.     /* Code Body                                                      */
  1761.     /*----------------------------------------------------------------*/
  1762.     EntryNewScreen(SCR_ID_IMPS_CONT_SEARCH, mmi_imps_exit_cont_search, NULL, NULL);
  1763.     InitializeCategory57Screen();
  1764.     mmi_imps_search_fill_inline_struct();
  1765.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CONT_SEARCH);
  1766.     inputBuffer = GetCurrNInputBuffer(SCR_ID_IMPS_CONT_SEARCH, &inputBufferSize);
  1767.     RegisterHighlightHandler(mmi_imps_hilite_cont_search_item);
  1768.     if (inputBuffer != NULL)
  1769.     {
  1770.         SetCategory57Data(wgui_inline_items, IMPS_INLINE_SEARCH_CONT, inputBuffer);
  1771.     }
  1772.     ShowCategory57Screen(
  1773.         STR_ID_IMPS_SEARCH_CONTACT,
  1774.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1775.         STR_GLOBAL_EDIT,
  1776.         IMG_GLOBAL_BACK,
  1777.         STR_GLOBAL_DONE,
  1778.         IMG_GLOBAL_BACK,
  1779.         IMPS_INLINE_SEARCH_CONT,
  1780.         (U16*) g_imps_inline_icons,
  1781.         wgui_inline_items,
  1782.         0,
  1783.         guiBuffer);
  1784.     SetCategory57RightSoftkeyFunctions(mmi_imps_entryt_search_opt, mmi_imps_search_free_mem_n_back);
  1785.     SetDelScrnIDCallbackHandler(SCR_ID_IMPS_CONT_SEARCH, (HistoryDelCBPtr) mmi_imps_search_scr_del_callback);
  1786. }
  1787. /*****************************************************************************
  1788.  * FUNCTION
  1789.  *  mmi_imps_exit_cont_search
  1790.  * DESCRIPTION
  1791.  *  Exit function for Search Contact screen.
  1792.  * PARAMETERS
  1793.  *  void
  1794.  * RETURNS
  1795.  *  void
  1796.  *****************************************************************************/
  1797. void mmi_imps_exit_cont_search(void)
  1798. {
  1799.     /*----------------------------------------------------------------*/
  1800.     /* Local Variables                                                */
  1801.     /*----------------------------------------------------------------*/
  1802.     /*----------------------------------------------------------------*/
  1803.     /* Code Body                                                      */
  1804.     /*----------------------------------------------------------------*/
  1805.     GenericExitInlineScreen(SCR_ID_IMPS_CONT_SEARCH, mmi_imps_entry_cont_search);
  1806. }
  1807. /*****************************************************************************
  1808.  * FUNCTION
  1809.  *  mmi_imps_search_free_mem_n_back
  1810.  * DESCRIPTION
  1811.  *  Free memory use in Search screen and go back to previous screen
  1812.  * PARAMETERS
  1813.  *  void
  1814.  * RETURNS
  1815.  *  void
  1816.  *****************************************************************************/
  1817. void mmi_imps_search_free_mem_n_back(void)
  1818. {
  1819.     /*----------------------------------------------------------------*/
  1820.     /* Local Variables                                                */
  1821.     /*----------------------------------------------------------------*/
  1822.     /*----------------------------------------------------------------*/
  1823.     /* Code Body                                                      */
  1824.     /*----------------------------------------------------------------*/
  1825.     mmi_imps_free_search_mem();
  1826.     GoBackHistory();
  1827. }
  1828. /*****************************************************************************
  1829.  * FUNCTION
  1830.  *  mmi_imps_free_search_mem
  1831.  * DESCRIPTION
  1832.  *  Free memory of search screen
  1833.  * PARAMETERS
  1834.  *  void
  1835.  * RETURNS
  1836.  *  void
  1837.  *****************************************************************************/
  1838. void mmi_imps_free_search_mem(void)
  1839. {
  1840.     /*----------------------------------------------------------------*/
  1841.     /* Local Variables                                                */
  1842.     /*----------------------------------------------------------------*/
  1843.     /*----------------------------------------------------------------*/
  1844.     /* Code Body                                                      */
  1845.     /*----------------------------------------------------------------*/
  1846.     if (imps_p->search_data != NULL)
  1847.     {
  1848.         OslMfree(imps_p->search_data);
  1849.         imps_p->search_data = NULL;
  1850.     }
  1851. }
  1852. /*****************************************************************************
  1853.  * FUNCTION
  1854.  *  mmi_imps_search_scr_del_callback
  1855.  * DESCRIPTION
  1856.  *  Function to free memory when inline editor screen is deleted.
  1857.  * PARAMETERS
  1858.  *  param       [?]     
  1859.  * RETURNS
  1860.  *  void
  1861.  *****************************************************************************/
  1862. U8 mmi_imps_search_scr_del_callback(void *param)
  1863. {
  1864.     /*----------------------------------------------------------------*/
  1865.     /* Local Variables                                                */
  1866.     /*----------------------------------------------------------------*/
  1867.     /*----------------------------------------------------------------*/
  1868.     /* Code Body                                                      */
  1869.     /*----------------------------------------------------------------*/
  1870.     mmi_imps_free_search_mem();
  1871.     return FALSE;
  1872. }
  1873. /*****************************************************************************
  1874.  * FUNCTION
  1875.  *  mmi_imps_search_fill_inline_struct
  1876.  * DESCRIPTION
  1877.  *  Fill inline editor structure of Contact Search screen.
  1878.  * PARAMETERS
  1879.  *  void
  1880.  * RETURNS
  1881.  *  void
  1882.  *****************************************************************************/
  1883. void mmi_imps_search_fill_inline_struct(void)
  1884. {
  1885.     /*----------------------------------------------------------------*/
  1886.     /* Local Variables                                                */
  1887.     /*----------------------------------------------------------------*/
  1888.     /*----------------------------------------------------------------*/
  1889.     /* Code Body                                                      */
  1890.     /*----------------------------------------------------------------*/
  1891.     /* User name */
  1892.     SetInlineItemActivation(&wgui_inline_items[0], KEY_LSK, KEY_EVENT_UP);
  1893.     SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_ID_IMPS_USERNAME));
  1894.     SetInlineItemActivation(&wgui_inline_items[1], KEY_LSK, KEY_EVENT_UP);
  1895.     SetInlineItemFullScreenEdit(
  1896.         &wgui_inline_items[1],
  1897.         STR_ID_IMPS_USERNAME,
  1898.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1899.         (U8*) imps_p->search_data->username,
  1900.         IMPS_MAX_NAME_LEN,
  1901.         INPUT_TYPE_USE_ONLY_ENGLISH_MODES | INPUT_TYPE_ALPHANUMERIC_SENTENCECASE);
  1902.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[1], mmi_imps_hilite_prof_full_edit);
  1903.     /* Phone Number */
  1904.     SetInlineItemActivation(&wgui_inline_items[2], KEY_LSK, KEY_EVENT_UP);
  1905.     SetInlineItemCaption(&wgui_inline_items[2], (U8*) GetString(STR_ID_IMPS_PHONE_NO));
  1906.     SetInlineItemActivation(&wgui_inline_items[3], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1907.     SetInlineItemTextEdit(
  1908.         &wgui_inline_items[3],
  1909.         (U8*) imps_p->search_data->phone,
  1910.         IMPS_MAX_USER_MOBILE_PHONE_LEN,
  1911.         INPUT_TYPE_PHONE_NUMBER | INPUT_TYPE_PLUS_CHARACTER_HANDLING);
  1912.     EnableInlineItemBoundary(&wgui_inline_items[3]);
  1913.     DisableInlineItemHighlight(&wgui_inline_items[3]);
  1914.     /* Alias */
  1915.     SetInlineItemActivation(&wgui_inline_items[4], KEY_LSK, KEY_EVENT_UP);
  1916.     SetInlineItemCaption(&wgui_inline_items[4], (U8*) GetString(STR_ID_IMPS_ALIAS));
  1917.     SetInlineItemActivation(&wgui_inline_items[5], KEY_LSK, KEY_EVENT_UP);
  1918.     SetInlineItemFullScreenEdit(
  1919.         &wgui_inline_items[5],
  1920.         STR_ID_IMPS_ALIAS,
  1921.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1922.         (U8*) imps_p->search_data->alias,
  1923.         IMPS_MAX_NAME_LEN,
  1924.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE);
  1925.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[5], mmi_imps_hilite_prof_full_edit);
  1926.     /* Email Address */
  1927.     SetInlineItemActivation(&wgui_inline_items[6], KEY_LSK, KEY_EVENT_UP);
  1928.     SetInlineItemCaption(&wgui_inline_items[6], (U8*) GetString(STR_ID_IMPS_EMAIL));
  1929.     SetInlineItemActivation(&wgui_inline_items[7], KEY_LSK, KEY_EVENT_UP);
  1930.     SetInlineItemFullScreenEdit(
  1931.         &wgui_inline_items[7],
  1932.         STR_ID_IMPS_EMAIL,
  1933.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1934.         (U8*) imps_p->search_data->email,
  1935.         IMPS_MAX_USER_EMAIL_ADDRESS_LEN,
  1936.         INPUT_TYPE_USE_ONLY_ENGLISH_MODES | INPUT_TYPE_ALPHANUMERIC_SENTENCECASE);
  1937.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[7], mmi_imps_hilite_prof_full_edit);
  1938. }
  1939. /*****************************************************************************
  1940.  * FUNCTION
  1941.  *  mmi_imps_entryt_search_opt
  1942.  * DESCRIPTION
  1943.  *  "Done" key handler in Search screen
  1944.  * PARAMETERS
  1945.  *  void
  1946.  * RETURNS
  1947.  *  void
  1948.  *****************************************************************************/
  1949. void mmi_imps_entryt_search_opt(void)
  1950. {
  1951.     /*----------------------------------------------------------------*/
  1952.     /* Local Variables                                                */
  1953.     /*----------------------------------------------------------------*/
  1954.     U16 numItems;
  1955.     U16 nStrItemList[3];
  1956.     U8 *guiBuffer;
  1957.     /*----------------------------------------------------------------*/
  1958.     /* Code Body                                                      */
  1959.     /*----------------------------------------------------------------*/
  1960.     EntryNewScreen(SCR_ID_IMPS_SEARCH_OPT, NULL, mmi_imps_entryt_search_opt, NULL);
  1961.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_SEARCH_OPT);
  1962.     SetParentHandler(MENU_ID_IMPS_SEARCH_OPT);
  1963.     numItems = GetNumOfChild(MENU_ID_IMPS_SEARCH_OPT);
  1964.     GetSequenceStringIds(MENU_ID_IMPS_SEARCH_OPT, nStrItemList);
  1965.     SetHiliteHandler(MENU_ID_IMPS_SEARCH_OPT_SEARCH, mmi_imps_hilite_search_done);
  1966.     SetHiliteHandler(MENU_ID_IMPS_SEARCH_OPT_QUIT, mmi_imps_hilite_search_quit);
  1967.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1968.     ShowCategory52Screen(
  1969.         STR_GLOBAL_OPTIONS,
  1970.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  1971.         STR_GLOBAL_OK,
  1972.         IMG_GLOBAL_OK,
  1973.         STR_GLOBAL_BACK,
  1974.         IMG_GLOBAL_BACK,
  1975.         numItems,
  1976.         nStrItemList,
  1977.         (U16*) gIndexIconsImageList,
  1978.         NULL,
  1979.         0,
  1980.         0,
  1981.         guiBuffer);
  1982.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1983.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1984. }
  1985. /*****************************************************************************
  1986.  * FUNCTION
  1987.  *  mmi_imps_hilite_search_done
  1988.  * DESCRIPTION
  1989.  *  Highlight handler of Search -> Done option
  1990.  * PARAMETERS
  1991.  *  void
  1992.  * RETURNS
  1993.  *  void
  1994.  *****************************************************************************/
  1995. void mmi_imps_hilite_search_done(void)
  1996. {
  1997.     /*----------------------------------------------------------------*/
  1998.     /* Local Variables                                                */
  1999.     /*----------------------------------------------------------------*/
  2000.     /*----------------------------------------------------------------*/
  2001.     /* Code Body                                                      */
  2002.     /*----------------------------------------------------------------*/
  2003.     SetLeftSoftkeyFunction(mmi_imps_search_start, KEY_EVENT_UP);
  2004. }
  2005. /*****************************************************************************
  2006.  * FUNCTION
  2007.  *  mmi_imps_search_start
  2008.  * DESCRIPTION
  2009.  *  Start searching contact procedure
  2010.  * PARAMETERS
  2011.  *  void
  2012.  * RETURNS
  2013.  *  void
  2014.  *****************************************************************************/
  2015. void mmi_imps_search_start(void)
  2016. {
  2017.     /*----------------------------------------------------------------*/
  2018.     /* Local Variables                                                */
  2019.     /*----------------------------------------------------------------*/
  2020.     /*----------------------------------------------------------------*/
  2021.     /* Code Body                                                      */
  2022.     /*----------------------------------------------------------------*/
  2023.     /* check if all the fileds are empty */
  2024.     if (pfnUnicodeStrlen((S8*) imps_p->search_data->username) == 0
  2025.         && pfnUnicodeStrlen((S8*) imps_p->search_data->phone) == 0
  2026.         && pfnUnicodeStrlen((S8*) imps_p->search_data->alias) == 0
  2027.         && pfnUnicodeStrlen((S8*) imps_p->search_data->email) == 0)
  2028.     {
  2029.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_EMPTY_INPUT);
  2030.         return;
  2031.     }
  2032.     mmi_imps_pre_entry_progressing(
  2033.         STR_ID_IMPS,
  2034.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2035.         0,
  2036.         0,
  2037.         STR_GLOBAL_ABORT,
  2038.         0,
  2039.         (U8*) GetString(STR_GLOBAL_SEARCH),
  2040.         NULL,
  2041.         IMG_GLOBAL_PROGRESS,
  2042.         NULL,
  2043.         mmi_imps_search_abort,
  2044.         mmi_imps_search_abort);
  2045.     /* send request to search */
  2046.     imps_p->search_result.search_cause = IMPS_SEARCH_CONT;
  2047.     /* rest previous searched data */
  2048.     imps_p->search_result.count = 0;
  2049. #ifdef IMPS_TEST_CODE
  2050.     strcpy((S8*) imps_p->search_result.entity[0].id, (S8*) "TEST 1");
  2051.     AnsiiToUnicodeString((S8*) imps_p->search_result.entity[0].sname, (S8*) "TEST 1");
  2052.     strcpy((S8*) imps_p->search_result.entity[1].id, (S8*) "TEST 2");
  2053.     AnsiiToUnicodeString((S8*) imps_p->search_result.entity[1].sname, (S8*) "TEST 2");
  2054.     strcpy((S8*) imps_p->search_result.entity[2].id, (S8*) "TEST 3");
  2055.     AnsiiToUnicodeString((S8*) imps_p->search_result.entity[2].sname, (S8*) "TEST 3");
  2056.     imps_p->search_result.count = 3;
  2057.     SetKeyHandler(mmi_imps_test_search_complete, KEY_SEND, KEY_EVENT_DOWN);
  2058. #else /* IMPS_TEST_CODE */ 
  2059.     mmi_imps_ps_search_req(IMPS_SEARCH_CONT);
  2060. #endif /* IMPS_TEST_CODE */ 
  2061. }
  2062. /*****************************************************************************
  2063.  * FUNCTION
  2064.  *  mmi_imps_hilite_search_quit
  2065.  * DESCRIPTION
  2066.  *  Highlight handler of Search -> Quit option
  2067.  * PARAMETERS
  2068.  *  void
  2069.  * RETURNS
  2070.  *  void
  2071.  *****************************************************************************/
  2072. void mmi_imps_hilite_search_quit(void)
  2073. {
  2074.     /*----------------------------------------------------------------*/
  2075.     /* Local Variables                                                */
  2076.     /*----------------------------------------------------------------*/
  2077.     /*----------------------------------------------------------------*/
  2078.     /* Code Body                                                      */
  2079.     /*----------------------------------------------------------------*/
  2080.     SetLeftSoftkeyFunction(mmi_imps_search_quit, KEY_EVENT_UP);
  2081. }
  2082. /*****************************************************************************
  2083.  * FUNCTION
  2084.  *  mmi_imps_search_quit
  2085.  * DESCRIPTION
  2086.  *  Quit search procedure
  2087.  * PARAMETERS
  2088.  *  void
  2089.  * RETURNS
  2090.  *  void
  2091.  *****************************************************************************/
  2092. void mmi_imps_search_quit(void)
  2093. {
  2094.     /*----------------------------------------------------------------*/
  2095.     /* Local Variables                                                */
  2096.     /*----------------------------------------------------------------*/
  2097.     /*----------------------------------------------------------------*/
  2098.     /* Code Body                                                      */
  2099.     /*----------------------------------------------------------------*/
  2100.     GoBackToHistory(SCR_ID_IMPS_ADD_CONT);
  2101. }
  2102. /*****************************************************************************
  2103.  * FUNCTION
  2104.  *  mmi_imps_search_abort
  2105.  * DESCRIPTION
  2106.  *  Abort searching process
  2107.  * PARAMETERS
  2108.  *  void
  2109.  * RETURNS
  2110.  *  void
  2111.  *****************************************************************************/
  2112. void mmi_imps_search_abort(void)
  2113. {
  2114.     /*----------------------------------------------------------------*/
  2115.     /* Local Variables                                                */
  2116.     /*----------------------------------------------------------------*/
  2117.     /*----------------------------------------------------------------*/
  2118.     /* Code Body                                                      */
  2119.     /*----------------------------------------------------------------*/
  2120.     mmi_imps_entry_abort();
  2121. #ifdef IMPS_TEST_CODE
  2122.     SetKeyHandler(mmi_imps_abort_search_finish, KEY_SEND, KEY_EVENT_DOWN);
  2123. #else 
  2124.     mmi_imps_ps_abort_search_req();
  2125. #endif 
  2126. }
  2127. /*****************************************************************************
  2128.  * FUNCTION
  2129.  *  mmi_imps_abort_search_finish
  2130.  * DESCRIPTION
  2131.  *  Finish aborting search process.
  2132.  * PARAMETERS
  2133.  *  void
  2134.  * RETURNS
  2135.  *  void
  2136.  *****************************************************************************/
  2137. void mmi_imps_abort_search_finish(void)
  2138. {
  2139.     /*----------------------------------------------------------------*/
  2140.     /* Local Variables                                                */
  2141.     /*----------------------------------------------------------------*/
  2142.     /*----------------------------------------------------------------*/
  2143.     /* Code Body                                                      */
  2144.     /*----------------------------------------------------------------*/
  2145.     if (imps_p->gen_info.is_reentry)
  2146.     {
  2147.         mmi_imps_re_entry_app();
  2148.     }
  2149.     else
  2150.     {
  2151.         if (imps_p->search_result.count)    /* some result already came back */
  2152.         {
  2153.             mmi_imps_entry_search_result();
  2154.             mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ADD_CONT);
  2155.         }
  2156.         else
  2157.         {
  2158.             U16 end_menu;
  2159.             if (imps_p->search_result.search_cause == IMPS_SEARCH_WATCHER)
  2160.             {
  2161.                 end_menu = SCR_ID_IMPS_CONT_OPT;
  2162.             }
  2163.             else
  2164.             {
  2165.                 end_menu = SCR_ID_IMPS_SEARCH_OPT;
  2166.             }
  2167.             if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
  2168.             {
  2169.                 GoBackToHistory(end_menu);
  2170.             }
  2171.             else
  2172.             {
  2173.                 mmi_imps_util_del_scr_after_progress(end_menu);
  2174.             }
  2175.         }
  2176.     }
  2177. }
  2178. /*****************************************************************************
  2179.  * FUNCTION
  2180.  *  mmi_imps_entry_search_result
  2181.  * DESCRIPTION
  2182.  *  Display list of search result
  2183.  * PARAMETERS
  2184.  *  void
  2185.  * RETURNS
  2186.  *  void
  2187.  *****************************************************************************/
  2188. void mmi_imps_entry_search_result(void)
  2189. {
  2190.     /*----------------------------------------------------------------*/
  2191.     /* Local Variables                                                */
  2192.     /*----------------------------------------------------------------*/
  2193.     U8 *guiBuffer;
  2194.     S32 i;
  2195.     S32 count;
  2196.     /*----------------------------------------------------------------*/
  2197.     /* Code Body                                                      */
  2198.     /*----------------------------------------------------------------*/
  2199.     count = (S32) imps_p->search_result.count;
  2200.     if (count == 0)
  2201.     {
  2202.         mmi_imps_util_disp_empty_popup();
  2203.         return;
  2204.     }
  2205.     for (i = 0; i < count; i++)
  2206.     {
  2207.         mmi_imps_util_ansi_2_ucs2_menu(
  2208.             (S8*) imps_p->search_result.entity[i].id,
  2209.             (S8*) subMenuData[i],
  2210.             MAX_SUBMENU_CHARACTERS);
  2211.         mmi_imps_util_generate_name_hint((S8*) imps_p->search_result.entity[i].sname, i, MAX_SUBMENU_CHARACTERS);
  2212.         subMenuDataPtrs[i] = subMenuData[i];
  2213.     }
  2214.     EntryNewScreen(SCR_ID_IMPS_SEARCH_RESULT, NULL, mmi_imps_entry_search_result, NULL);
  2215.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_SEARCH_RESULT);
  2216.     SetParentHandler(0);
  2217.     RegisterHighlightHandler(mmi_imps_hilite_search_result);
  2218.     ShowCategory53Screen(
  2219.         STR_ID_IMPS_SEARCH_RESULT,
  2220.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2221.         STR_GLOBAL_ADD,
  2222.         IMG_GLOBAL_OPTIONS,
  2223.         STR_GLOBAL_BACK,
  2224.         IMG_GLOBAL_BACK,
  2225.         count,
  2226.         (U8 **) subMenuDataPtrs,
  2227.         (U16*) gIndexIconsImageList,
  2228.         (U8 **) hintDataPtrs,
  2229.         0,
  2230.         0,
  2231.         guiBuffer);
  2232.     if (imps_p->search_result.search_cause == IMPS_SEARCH_ROOM)
  2233.     {
  2234.         ChangeLeftSoftkey(STR_ID_IMPS_JOIN, IMG_GLOBAL_OK);
  2235.         SetLeftSoftkeyFunction(mmi_imps_pre_entry_join, KEY_EVENT_UP);
  2236.     }
  2237.     else    /* search chat room */
  2238.     {
  2239.         SetLeftSoftkeyFunction(mmi_imps_pre_entry_sel_group, KEY_EVENT_UP);
  2240.     }
  2241.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2242.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2243. }
  2244. /*****************************************************************************
  2245.  * FUNCTION
  2246.  *  mmi_imps_hilite_search_result
  2247.  * DESCRIPTION
  2248.  *  Highlight handler of result list. Store index of current selecting item.
  2249.  * PARAMETERS
  2250.  *  index       [IN]        
  2251.  * RETURNS
  2252.  *  void
  2253.  *****************************************************************************/
  2254. void mmi_imps_hilite_search_result(S32 index)
  2255. {
  2256.     /*----------------------------------------------------------------*/
  2257.     /* Local Variables                                                */
  2258.     /*----------------------------------------------------------------*/
  2259.     /*----------------------------------------------------------------*/
  2260.     /* Code Body                                                      */
  2261.     /*----------------------------------------------------------------*/
  2262.     imps_p->search_result.curr_item = (U8) index;
  2263. }
  2264. /*****************************************************************************
  2265.  * FUNCTION
  2266.  *  mmi_imps_pre_entry_sel_group
  2267.  * DESCRIPTION
  2268.  *  Pre-Entry function for selecting group when adding new contacts
  2269.  * PARAMETERS
  2270.  *  void
  2271.  * RETURNS
  2272.  *  void
  2273.  *****************************************************************************/
  2274. void mmi_imps_pre_entry_sel_group(void)
  2275. {
  2276.     /*----------------------------------------------------------------*/
  2277.     /* Local Variables                                                */
  2278.     /*----------------------------------------------------------------*/
  2279.     /*----------------------------------------------------------------*/
  2280.     /* Code Body                                                      */
  2281.     /*----------------------------------------------------------------*/
  2282.     if (mmi_imps_util_is_cont_exist((S8*) imps_p->search_result.entity[imps_p->search_result.curr_item].id))
  2283.     {
  2284.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_CONTACT_EXIST);
  2285.         return;
  2286.     }
  2287.     /* display list of groups */
  2288.     mmi_imps_entry_sel_group();
  2289. }
  2290. /*****************************************************************************
  2291.  * FUNCTION
  2292.  *  mmi_imps_entry_sel_group
  2293.  * DESCRIPTION
  2294.  *  List of group for the user to select
  2295.  * PARAMETERS
  2296.  *  void
  2297.  * RETURNS
  2298.  *  void
  2299.  *****************************************************************************/
  2300. void mmi_imps_entry_sel_group(void)
  2301. {
  2302.     /*----------------------------------------------------------------*/
  2303.     /* Local Variables                                                */
  2304.     /*----------------------------------------------------------------*/
  2305.     U8 *guiBuffer;
  2306.     S32 i;
  2307.     mmi_imps_group_struct *group;
  2308.     /*----------------------------------------------------------------*/
  2309.     /* Code Body                                                      */
  2310.     /*----------------------------------------------------------------*/
  2311.     EntryNewScreen(SCR_ID_IMPS_SELECT_GROUP, NULL, mmi_imps_entry_sel_group, NULL);
  2312.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_SELECT_GROUP);
  2313.     SetParentHandler(0);
  2314.     RegisterHighlightHandler(mmi_imps_hilite_sel_group);
  2315.     for (i = 0; i < (S32) imps_p->group_info.no_group; i++)
  2316.     {
  2317.         group = &imps_p->group_info.group_list[i];
  2318.         /* if group name is not empty */
  2319.         if (pfnUnicodeStrlen((S8*) group->group_name))
  2320.         {
  2321.             mmi_imps_util_copy_with_dot((S8*) group->group_name, (S8*) subMenuData[i], MAX_SUBMENU_CHARACTERS);
  2322.         }
  2323.         else
  2324.         {
  2325.             mmi_imps_util_ansi_2_ucs2_menu((S8*) group->group_id, (S8*) subMenuData[i], MAX_SUBMENU_CHARACTERS);
  2326.         }
  2327.         mmi_imps_util_generate_name_hint((S8*) NULL, i, MAX_SUBMENU_CHARACTERS);
  2328.         subMenuDataPtrs[i] = subMenuData[i];
  2329.     }
  2330.     ShowCategory53Screen(
  2331.         STR_ID_IMPS_SELECT_GROUP,
  2332.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2333.         STR_GLOBAL_OK,
  2334.         IMG_GLOBAL_OK,
  2335.         STR_GLOBAL_BACK,
  2336.         IMG_GLOBAL_BACK,
  2337.         (S32) imps_p->group_info.no_group,
  2338.         (U8 **) subMenuDataPtrs,
  2339.         (U16*) gIndexIconsImageList,
  2340.         (U8 **) hintDataPtrs,
  2341.         0,
  2342.         0,
  2343.         guiBuffer);
  2344.     /* entry from search contact or watcher list */
  2345.     if (IsScreenPresent(SCR_ID_IMPS_SEARCH_RESULT) || IsScreenPresent(SCR_ID_IMPS_WATCHER_LIST))
  2346.     {
  2347.         SetLeftSoftkeyFunction(mmi_imps_pre_entry_input_name, KEY_EVENT_UP);
  2348.     }
  2349.     else
  2350.     {
  2351.         SetLeftSoftkeyFunction(mmi_imps_pre_entry_add_direct, KEY_EVENT_UP);
  2352.     }
  2353.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2354.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2355. }
  2356. /*****************************************************************************
  2357.  * FUNCTION
  2358.  *  mmi_imps_hilite_sel_group
  2359.  * DESCRIPTION
  2360.  *  Highlight handler of group list for selecting item.
  2361.  * PARAMETERS
  2362.  *  index       [IN]        
  2363.  * RETURNS
  2364.  *  void
  2365.  *****************************************************************************/
  2366. void mmi_imps_hilite_sel_group(S32 index)
  2367. {
  2368.     /*----------------------------------------------------------------*/
  2369.     /* Local Variables                                                */
  2370.     /*----------------------------------------------------------------*/
  2371.     /*----------------------------------------------------------------*/
  2372.     /* Code Body                                                      */
  2373.     /*----------------------------------------------------------------*/
  2374.     imps_p->group_info.curr_item = (U8) index;
  2375. }
  2376. /*****************************************************************************
  2377.  * FUNCTION
  2378.  *  mmi_imps_pre_entry_input_name
  2379.  * DESCRIPTION
  2380.  *  Pre-entry function of input name screen when adding contact
  2381.  * PARAMETERS
  2382.  *  void
  2383.  * RETURNS
  2384.  *  void
  2385.  *****************************************************************************/
  2386. void mmi_imps_pre_entry_input_name(void)
  2387. {
  2388.     /*----------------------------------------------------------------*/
  2389.     /* Local Variables                                                */
  2390.     /*----------------------------------------------------------------*/
  2391.     /*----------------------------------------------------------------*/
  2392.     /* Code Body                                                      */
  2393.     /*----------------------------------------------------------------*/
  2394.     /* check if group full */
  2395.     if (imps_p->group_info.group_list[imps_p->group_info.curr_item].no_users == IMPS_MAX_ENTITY_NUMBER)
  2396.     {
  2397.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_ERR_CONT_LIST_FULL);
  2398.     }
  2399.     else
  2400.     {
  2401.         mmi_imps_entity_struct *sel_entity = &imps_p->search_result.entity[imps_p->search_result.curr_item];
  2402.         /* alias */
  2403.         if (pfnUnicodeStrlen((S8*) sel_entity->sname))
  2404.         {
  2405.             pfnUnicodeStrcpy((S8*) imps_p->file_buff, (S8*) sel_entity->sname);
  2406.         }
  2407.         else
  2408.         {
  2409.             imps_p->file_buff[0] = 0;
  2410.         }
  2411.         mmi_imps_entry_cont_input_name();
  2412.     }
  2413. }
  2414. /*****************************************************************************
  2415.  * FUNCTION
  2416.  *  mmi_imps_entry_cont_input_name
  2417.  * DESCRIPTION
  2418.  *  Input display name of contact
  2419.  * PARAMETERS
  2420.  *  void
  2421.  * RETURNS
  2422.  *  void
  2423.  *****************************************************************************/
  2424. void mmi_imps_entry_cont_input_name(void)
  2425. {
  2426.     /*----------------------------------------------------------------*/
  2427.     /* Local Variables                                                */
  2428.     /*----------------------------------------------------------------*/
  2429.     U8 *guiBuffer;
  2430.     /*----------------------------------------------------------------*/
  2431.     /* Code Body                                                      */
  2432.     /*----------------------------------------------------------------*/
  2433.     EntryNewScreen(SCR_ID_IMPS_ADD_CONT_INPUT_NAME, NULL, mmi_imps_entry_cont_input_name, NULL);
  2434.     SetParentHandler(0);
  2435.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ADD_CONT_INPUT_NAME);
  2436.     /* reuse file_buff */
  2437.     ShowCategory5Screen(
  2438.         STR_ID_IMPS_DISPLAY_NAME,
  2439.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2440.         STR_GLOBAL_OPTIONS,
  2441.         IMG_GLOBAL_OPTIONS,
  2442.         STR_GLOBAL_BACK,
  2443.         IMG_GLOBAL_BACK,
  2444.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  2445.         (U8*) imps_p->file_buff,
  2446.         IMPS_MAX_NAME_LEN,
  2447.         guiBuffer);
  2448.     SetLeftSoftkeyFunction(mmi_imps_entry_add_cont_input_name_opt, KEY_EVENT_UP);
  2449.     SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2450. }
  2451. /*****************************************************************************
  2452.  * FUNCTION
  2453.  *  mmi_imps_entry_add_cont_input_name_opt
  2454.  * DESCRIPTION
  2455.  *  Option screen for input name option
  2456.  * PARAMETERS
  2457.  *  void
  2458.  * RETURNS
  2459.  *  void
  2460.  *****************************************************************************/
  2461. void mmi_imps_entry_add_cont_input_name_opt(void)
  2462. {
  2463.     /*----------------------------------------------------------------*/
  2464.     /* Local Variables                                                */
  2465.     /*----------------------------------------------------------------*/
  2466.     U16 numItems;
  2467.     U16 nStrItemList[2];
  2468.     U8 *guiBuffer;
  2469.     /*----------------------------------------------------------------*/
  2470.     /* Code Body                                                      */
  2471.     /*----------------------------------------------------------------*/
  2472.     EntryNewScreen(SCR_ID_IMPS_ADD_CONT_INPUT_NAME_OPT, NULL, mmi_imps_entry_add_cont_input_name_opt, NULL);
  2473.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ADD_CONT_INPUT_NAME_OPT);
  2474.     SetParentHandler(MENU_ID_IMPS_CONT_ADD_NAME_OPT);
  2475.     numItems = GetNumOfChild(MENU_ID_IMPS_CONT_ADD_NAME_OPT);
  2476.     GetSequenceStringIds(MENU_ID_IMPS_CONT_ADD_NAME_OPT, nStrItemList);
  2477.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  2478.     ShowCategory52Screen(
  2479.         STR_GLOBAL_OPTIONS,
  2480.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2481.         STR_GLOBAL_OK,
  2482.         IMG_GLOBAL_OK,
  2483.         STR_GLOBAL_BACK,
  2484.         IMG_GLOBAL_BACK,
  2485.         numItems,
  2486.         nStrItemList,
  2487.         (U16*) gIndexIconsImageList,
  2488.         NULL,
  2489.         0,
  2490.         0,
  2491.         guiBuffer);
  2492.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2493.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2494. }
  2495. /*****************************************************************************
  2496.  * FUNCTION
  2497.  *  mmi_imps_hilite_input_name_opt_done
  2498.  * DESCRIPTION
  2499.  *  Start adding contact list
  2500.  * PARAMETERS
  2501.  *  void
  2502.  * RETURNS
  2503.  *  void
  2504.  *****************************************************************************/
  2505. void mmi_imps_hilite_input_name_opt_done(void)
  2506. {
  2507.     /*----------------------------------------------------------------*/
  2508.     /* Local Variables                                                */
  2509.     /*----------------------------------------------------------------*/
  2510.     /*----------------------------------------------------------------*/
  2511.     /* Code Body                                                      */
  2512.     /*----------------------------------------------------------------*/
  2513.     if (IsScreenPresent(SCR_ID_IMPS_ABOUT_FRIEND))  /* about friend */
  2514.     {
  2515.         SetLeftSoftkeyFunction(mmi_imps_about_friend_edit_done, KEY_EVENT_UP);
  2516.     }
  2517.     else    /* add contact list */
  2518.     {
  2519.         SetLeftSoftkeyFunction(mmi_imps_add_cont_done, KEY_EVENT_UP);
  2520.     }
  2521. }
  2522. /*****************************************************************************
  2523.  * FUNCTION
  2524.  *  mmi_imps_add_cont_done
  2525.  * DESCRIPTION
  2526.  *  Start adding contact
  2527.  * PARAMETERS
  2528.  *  void
  2529.  * RETURNS
  2530.  *  void
  2531.  *****************************************************************************/
  2532. void mmi_imps_add_cont_done(void)
  2533. {
  2534.     /*----------------------------------------------------------------*/
  2535.     /* Local Variables                                                */
  2536.     /*----------------------------------------------------------------*/
  2537.     /*----------------------------------------------------------------*/
  2538.     /* Code Body                                                      */
  2539.     /*----------------------------------------------------------------*/
  2540.     /* display progressing screen */
  2541.     mmi_imps_display_progressing();
  2542.     imps_p->cont_info.add_type = IMPS_ADD_CONT_SEARCH;
  2543. #ifdef IMPS_TEST_CODE
  2544.     mmi_imps_add_cont_finished(0);
  2545. #else /* IMPS_TEST_CODE */ 
  2546.     mmi_imps_add_cont_req(
  2547.         imps_p->group_info.group_list[imps_p->group_info.curr_item].group_id,
  2548.         imps_p->search_result.entity[imps_p->search_result.curr_item].id,
  2549.         (S8*) imps_p->file_buff);
  2550. #endif /* IMPS_TEST_CODE */ 
  2551. }
  2552. /*****************************************************************************
  2553.  * FUNCTION
  2554.  *  mmi_imps_add_cont_finished
  2555.  * DESCRIPTION
  2556.  *  Callback function when finishing adding a contact
  2557.  * PARAMETERS
  2558.  *  result      [IN]        
  2559.  * RETURNS
  2560.  *  void
  2561.  *****************************************************************************/
  2562. void mmi_imps_add_cont_finished(S32 result)
  2563. {
  2564.     /*----------------------------------------------------------------*/
  2565.     /* Local Variables                                                */
  2566.     /*----------------------------------------------------------------*/
  2567.     /*----------------------------------------------------------------*/
  2568.     /* Code Body                                                      */
  2569.     /*----------------------------------------------------------------*/
  2570.     /* 
  2571.      * partial success, subscribe error (server not support)
  2572.      * regard it as success
  2573.      */
  2574.     if (result == 0 || result == IMPS_ERROR_SUBSCRIPTION_NOT_SUPPORT)   /* IMPS_OK */
  2575.     {
  2576.         /* add contact to local-saved file */
  2577.         mmi_imps_cont_struct *cont = &imps_p->cont_info.cont_list[imps_p->cont_info.no_cont];
  2578.         mmi_imps_entity_struct *sel_entity;
  2579.         memset(cont, 0, sizeof(mmi_imps_cont_struct));
  2580.         /* contact id */
  2581.         if (imps_p->cont_info.add_type == IMPS_ADD_CONT_SEARCH)
  2582.         {
  2583.             sel_entity = &imps_p->search_result.entity[imps_p->search_result.curr_item];
  2584.             strcpy((S8*) cont->id, (S8*) sel_entity->id);
  2585.         }
  2586.         else
  2587.         {
  2588.             UnicodeToAnsii((S8*) cont->id, (S8*) imps_p->path_buff);
  2589.         }
  2590.         if (pfnUnicodeStrlen((S8*) imps_p->file_buff))
  2591.         {
  2592.             pfnUnicodeStrcpy((S8*) cont->nick_name, (S8*) imps_p->file_buff);
  2593.         }
  2594.         /* status */
  2595.         cont->availability = IMPS_PA_USER_NOT_AVAILABLE;
  2596.         strcpy((S8*) cont->group_id, (S8*) imps_p->group_info.group_list[imps_p->group_info.curr_item].group_id);
  2597.         imps_p->group_info.group_list[imps_p->group_info.curr_item].no_users++;
  2598.         MMI_ASSERT(imps_p->group_info.group_list[imps_p->group_info.curr_item].no_users <= IMPS_MAX_ENTITY_NUMBER);
  2599.         imps_p->cont_info.no_cont++;
  2600.         mmi_imps_util_write_cont();
  2601.         /* clear gui buffer when re-entry contact list */
  2602.         imps_p->cont_info.clear_gui_buff = TRUE;
  2603.         mmi_imps_util_write_group();
  2604.         mmi_imps_util_disp_popup_done();
  2605.     }
  2606.     else
  2607.     {
  2608.         mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(result));
  2609.     }
  2610.     if (imps_p->gen_info.is_reentry)
  2611.     {
  2612.         mmi_imps_re_entry_app();
  2613.     }
  2614.     else
  2615.     {
  2616.         if (imps_p->cont_info.no_cont == IMPS_MAX_NO_CONT)
  2617.         {
  2618.             mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CONT_OPT);
  2619.         }
  2620.         else
  2621.         {
  2622.             if (imps_p->cont_info.add_type == IMPS_ADD_CONT_SEARCH)
  2623.             {
  2624.                 mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_SEARCH_RESULT);
  2625.             }
  2626.             else
  2627.             {
  2628.                 mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ADD_CONT);
  2629.             }
  2630.         }
  2631.     }
  2632. }
  2633. /*****************************************************************************
  2634.  * FUNCTION
  2635.  *  mmi_imps_hilite_add_direct
  2636.  * DESCRIPTION
  2637.  *  Highlight handler of Add Contact -> Add Directly option
  2638.  * PARAMETERS
  2639.  *  void
  2640.  * RETURNS
  2641.  *  void
  2642.  *****************************************************************************/
  2643. void mmi_imps_hilite_add_direct(void)
  2644. {
  2645.     /*----------------------------------------------------------------*/
  2646.     /* Local Variables                                                */
  2647.     /*----------------------------------------------------------------*/
  2648.     /*----------------------------------------------------------------*/
  2649.     /* Code Body                                                      */
  2650.     /*----------------------------------------------------------------*/
  2651.     SetLeftSoftkeyFunction(mmi_imps_entry_sel_group, KEY_EVENT_UP);
  2652.     SetKeyHandler(mmi_imps_entry_sel_group, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2653. }
  2654. /*****************************************************************************
  2655.  * FUNCTION
  2656.  *  mmi_imps_pre_entry_add_direct
  2657.  * DESCRIPTION
  2658.  *  Pre-Entry function for Add Contact -> Add Directly option
  2659.  * PARAMETERS
  2660.  *  void
  2661.  * RETURNS
  2662.  *  void
  2663.  *****************************************************************************/
  2664. void mmi_imps_pre_entry_add_direct(void)
  2665. {
  2666.     /*----------------------------------------------------------------*/
  2667.     /* Local Variables                                                */
  2668.     /*----------------------------------------------------------------*/
  2669.     /*----------------------------------------------------------------*/
  2670.     /* Code Body                                                      */
  2671.     /*----------------------------------------------------------------*/
  2672.     /* check if group full */
  2673.     if (imps_p->group_info.group_list[imps_p->group_info.curr_item].no_users == IMPS_MAX_ENTITY_NUMBER)
  2674.     {
  2675.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_ERR_CONT_LIST_FULL);
  2676.         return;
  2677.     }
  2678.     imps_p->file_buff[0] = 0;   /* reuse path and file buffer */
  2679.     pfnUnicodeStrcpy((S8*) imps_p->path_buff, g_imps_wv);
  2680.     mmi_imps_entry_add_direct();
  2681. }
  2682. /*****************************************************************************
  2683.  * FUNCTION
  2684.  *  mmi_imps_entry_add_direct
  2685.  * DESCRIPTION
  2686.  *  Entry Add Directly option --> input name and nick name screen
  2687.  * PARAMETERS
  2688.  *  void
  2689.  * RETURNS
  2690.  *  void
  2691.  *****************************************************************************/
  2692. void mmi_imps_entry_add_direct(void)
  2693. {
  2694.     /*----------------------------------------------------------------*/
  2695.     /* Local Variables                                                */
  2696.     /*----------------------------------------------------------------*/
  2697.     U8 *guiBuffer;
  2698.     U8 *inputBuffer;
  2699.     U16 inputBufferSize;
  2700.     /*----------------------------------------------------------------*/
  2701.     /* Code Body                                                      */
  2702.     /*----------------------------------------------------------------*/
  2703.     EntryNewScreen(SCR_ID_IMPS_ADD_CONT_DIRECT, mmi_imps_exit_add_direct, NULL, NULL);
  2704.     InitializeCategory57Screen();
  2705.     mmi_imps_add_direct_fill_inline_struct();
  2706.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_ADD_CONT_DIRECT);
  2707.     inputBuffer = GetCurrNInputBuffer(SCR_ID_IMPS_ADD_CONT_DIRECT, &inputBufferSize);
  2708.     if (inputBuffer != NULL)
  2709.     {
  2710.         SetCategory57Data(wgui_inline_items, IMPS_INLINE_ADD_DIRECT, inputBuffer);
  2711.     }
  2712.     ShowCategory57Screen(
  2713.         STR_ID_IMPS_ADD_DIRECTLY,
  2714.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2715.         STR_GLOBAL_EDIT,
  2716.         IMG_GLOBAL_BACK,
  2717.         STR_GLOBAL_DONE,
  2718.         IMG_GLOBAL_BACK,
  2719.         IMPS_INLINE_ADD_DIRECT,
  2720.         (U16*) g_imps_inline_icons,
  2721.         wgui_inline_items,
  2722.         0,
  2723.         guiBuffer);
  2724.     SetCategory57RightSoftkeyFunctions(mmi_imps_add_direct_save, GoBackHistory);
  2725. }
  2726. /*****************************************************************************
  2727.  * FUNCTION
  2728.  *  mmi_imps_exit_add_direct
  2729.  * DESCRIPTION
  2730.  *  Exit function for Add Directly option --> input name and nick name screen
  2731.  * PARAMETERS
  2732.  *  void
  2733.  * RETURNS
  2734.  *  void
  2735.  *****************************************************************************/
  2736. void mmi_imps_exit_add_direct(void)
  2737. {
  2738.     /*----------------------------------------------------------------*/
  2739.     /* Local Variables                                                */
  2740.     /*----------------------------------------------------------------*/
  2741.     /*----------------------------------------------------------------*/
  2742.     /* Code Body                                                      */
  2743.     /*----------------------------------------------------------------*/
  2744.     GenericExitInlineScreen(SCR_ID_IMPS_ADD_CONT_DIRECT, mmi_imps_entry_add_direct);
  2745. }
  2746. /*****************************************************************************
  2747.  * FUNCTION
  2748.  *  mmi_imps_add_direct_fill_inline_struct
  2749.  * DESCRIPTION
  2750.  *  Fill inline structure for Direct Add contact screen
  2751.  * PARAMETERS
  2752.  *  void
  2753.  * RETURNS
  2754.  *  void
  2755.  *****************************************************************************/
  2756. void mmi_imps_add_direct_fill_inline_struct(void)
  2757. {
  2758.     /*----------------------------------------------------------------*/
  2759.     /* Local Variables                                                */
  2760.     /*----------------------------------------------------------------*/
  2761.     /*----------------------------------------------------------------*/
  2762.     /* Code Body                                                      */
  2763.     /*----------------------------------------------------------------*/
  2764.     /* User name */
  2765.     SetInlineItemActivation(&wgui_inline_items[0], KEY_LSK, KEY_EVENT_UP);
  2766.     SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(STR_ID_IMPS_USERNAME));
  2767.     SetInlineItemActivation(&wgui_inline_items[1], KEY_LSK, KEY_EVENT_UP);
  2768.     SetInlineItemFullScreenEdit(
  2769.         &wgui_inline_items[1],
  2770.         STR_ID_IMPS_USERNAME,
  2771.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2772.         (U8*) imps_p->path_buff,
  2773.         IMPS_MAX_ID_LEN,
  2774.         INPUT_TYPE_USE_ONLY_ENGLISH_MODES | INPUT_TYPE_ALPHANUMERIC_SENTENCECASE);
  2775.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[1], mmi_imps_hilite_prof_full_edit);
  2776.     /* Display Name */
  2777.     SetInlineItemActivation(&wgui_inline_items[2], KEY_LSK, KEY_EVENT_UP);
  2778.     SetInlineItemCaption(&wgui_inline_items[2], (U8*) GetString(STR_ID_IMPS_DISPLAY_NAME));
  2779.     SetInlineItemActivation(&wgui_inline_items[3], KEY_LSK, KEY_EVENT_UP);
  2780.     SetInlineItemFullScreenEdit(
  2781.         &wgui_inline_items[3],
  2782.         STR_ID_IMPS_DISPLAY_NAME,
  2783.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2784.         (U8*) imps_p->file_buff,
  2785.         IMPS_MAX_NAME_LEN,
  2786.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE);
  2787.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[3], mmi_imps_hilite_prof_full_edit);
  2788. }
  2789. /*****************************************************************************
  2790.  * FUNCTION
  2791.  *  mmi_imps_add_direct_save
  2792.  * DESCRIPTION
  2793.  *  Confirmation screen for adding contact
  2794.  * PARAMETERS
  2795.  *  void
  2796.  * RETURNS
  2797.  *  void
  2798.  *****************************************************************************/
  2799. void mmi_imps_add_direct_save(void)
  2800. {
  2801.     /*----------------------------------------------------------------*/
  2802.     /* Local Variables                                                */
  2803.     /*----------------------------------------------------------------*/
  2804.     /*----------------------------------------------------------------*/
  2805.     /* Code Body                                                      */
  2806.     /*----------------------------------------------------------------*/
  2807.     mmi_imps_entry_confirm(STR_GLOBAL_ADD, mmi_imps_add_direct_save_yes, mmi_imps_util_go_back_2_hist);
  2808. }
  2809. /*****************************************************************************
  2810.  * FUNCTION
  2811.  *  mmi_imps_add_direct_save_yes
  2812.  * DESCRIPTION
  2813.  *  Confirm to add contact
  2814.  * PARAMETERS
  2815.  *  void
  2816.  * RETURNS
  2817.  *  void
  2818.  *****************************************************************************/
  2819. void mmi_imps_add_direct_save_yes(void)
  2820. {
  2821.     /*----------------------------------------------------------------*/
  2822.     /* Local Variables                                                */
  2823.     /*----------------------------------------------------------------*/
  2824.     S8 *id = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
  2825.     /*----------------------------------------------------------------*/
  2826.     /* Code Body                                                      */
  2827.     /*----------------------------------------------------------------*/
  2828.     UnicodeToAnsii((S8*) id, (S8*) imps_p->path_buff);
  2829.     if (mmi_imps_util_is_cont_exist(id))
  2830.     {
  2831.         mmi_imps_util_disp_err_popup(STR_ID_IMPS_CONTACT_EXIST);
  2832.     }
  2833.     else
  2834.     {
  2835.         /* display progressing screen */
  2836.         mmi_imps_display_progressing();
  2837.         imps_p->cont_info.add_type = IMPS_ADD_CONT_DIRECT;
  2838.     #ifdef IMPS_TEST_CODE
  2839.         mmi_imps_add_cont_done(0);
  2840.     #else /* IMPS_TEST_CODE */ 
  2841.         mmi_imps_add_cont_req(
  2842.             imps_p->group_info.group_list[imps_p->group_info.curr_item].group_id,
  2843.             (U8*) id,
  2844.             (S8*) imps_p->file_buff);
  2845.     #endif /* IMPS_TEST_CODE */ 
  2846.     }
  2847.     OslMfree(id);
  2848. }
  2849. #define COMMON_IMPS
  2850. /*****************************************************************************
  2851.  * FUNCTION
  2852.  *  mmi_imps_display_progressing
  2853.  * DESCRIPTION
  2854.  *  Common function to display "Progressing" screen
  2855.  * PARAMETERS
  2856.  *  void
  2857.  * RETURNS
  2858.  *  void
  2859.  *****************************************************************************/
  2860. void mmi_imps_display_progressing(void)
  2861. {
  2862.     /*----------------------------------------------------------------*/
  2863.     /* Local Variables                                                */
  2864.     /*----------------------------------------------------------------*/
  2865.     /*----------------------------------------------------------------*/
  2866.     /* Code Body                                                      */
  2867.     /*----------------------------------------------------------------*/
  2868.     mmi_imps_pre_entry_progressing(
  2869.         STR_ID_IMPS,
  2870.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  2871.         0,
  2872.         0,
  2873.         0,
  2874.         0,
  2875.         (U8*) GetString(STR_ID_IMPS_PROGRESSING),
  2876.         NULL,
  2877.         IMG_GLOBAL_PROGRESS,
  2878.         NULL,
  2879.         NULL,
  2880.         NULL);
  2881. }
  2882. /*****************************************************************************
  2883.  * FUNCTION
  2884.  *  mmi_imps_pre_entry_progressing
  2885.  * DESCRIPTION
  2886.  *  Pre-entry function for progressing screen
  2887.  * PARAMETERS
  2888.  *  strCaption      [IN]        
  2889.  *  imgCaption      [IN]        
  2890.  *  strLsk          [IN]        
  2891.  *  imgLsk          [IN]        
  2892.  *  strRsk          [IN]        
  2893.  *  imgRsk          [IN]        
  2894.  *  strBody1        [?]         
  2895.  *  strBody2        [?]         
  2896.  *  imgBody         [IN]        
  2897.  *  lskFuncPtr      [IN]        
  2898.  *  rskFuncPtr      [IN]        
  2899.  *  endFuncPtr      [IN]        
  2900.  * RETURNS
  2901.  *  void
  2902.  *****************************************************************************/
  2903. void mmi_imps_pre_entry_progressing(
  2904.         U16 strCaption,
  2905.         U16 imgCaption,
  2906.         U16 strLsk,
  2907.         U16 imgLsk,
  2908.         U16 strRsk,
  2909.         U16 imgRsk,
  2910.         U8 *strBody1,
  2911.         U8 *strBody2,
  2912.         U16 imgBody,
  2913.         FuncPtr lskFuncPtr,
  2914.         FuncPtr rskFuncPtr,
  2915.         FuncPtr endFuncPtr)
  2916. {
  2917.     /*----------------------------------------------------------------*/
  2918.     /* Local Variables                                                */
  2919.     /*----------------------------------------------------------------*/
  2920.     mmi_imps_progress_scr_struct *progress_info = &imps_p->progress_info;
  2921.     /*----------------------------------------------------------------*/
  2922.     /* Code Body                                                      */
  2923.     /*----------------------------------------------------------------*/
  2924.     progress_info->strCaption = strCaption;
  2925.     progress_info->imgCaption = imgCaption;
  2926.     progress_info->strLsk = strLsk;
  2927.     progress_info->imgLsk = imgLsk;
  2928.     progress_info->strRsk = strRsk;
  2929.     progress_info->imgRsk = imgRsk;
  2930.     progress_info->strBody1 = strBody1;
  2931.     progress_info->strBody2 = strBody2;
  2932.     progress_info->imgBody = imgBody;
  2933.     progress_info->lskFuncPtr = lskFuncPtr;
  2934.     progress_info->rskFuncPtr = rskFuncPtr;
  2935.     progress_info->endFuncPtr = endFuncPtr;
  2936.     mmi_imps_entry_progressing();
  2937.     /* prevent the progressing screen being entered twice */
  2938.     DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
  2939. }
  2940. /*****************************************************************************
  2941.  * FUNCTION
  2942.  *  mmi_imps_entry_progressing
  2943.  * DESCRIPTION
  2944.  *  Common entry function for all progressing screens.
  2945.  * PARAMETERS
  2946.  *  void
  2947.  * RETURNS
  2948.  *  void
  2949.  *****************************************************************************/
  2950. void mmi_imps_entry_progressing(void)
  2951. {
  2952.     /*----------------------------------------------------------------*/
  2953.     /* Local Variables                                                */
  2954.     /*----------------------------------------------------------------*/
  2955.     U8 *guiBuffer;
  2956.     mmi_imps_progress_scr_struct *progress_info = &imps_p->progress_info;
  2957.     /*----------------------------------------------------------------*/
  2958.     /* Code Body                                                      */
  2959.     /*----------------------------------------------------------------*/
  2960.     EntryNewScreen(SCR_ID_IMPS_PROGRESS, NULL, mmi_imps_entry_progressing, NULL);
  2961.     guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_PROGRESS);
  2962.     ShowCategory154Screen(
  2963.         progress_info->strCaption,
  2964.         progress_info->imgCaption,
  2965.         progress_info->strLsk,
  2966.         progress_info->imgLsk,
  2967.         progress_info->strRsk,
  2968.         progress_info->imgRsk,
  2969.         (U8*) progress_info->strBody1,
  2970.         (U8*) progress_info->strBody2,
  2971.         progress_info->imgBody,
  2972.         guiBuffer);
  2973.     SetLeftSoftkeyFunction(progress_info->lskFuncPtr, KEY_EVENT_UP);
  2974.     SetRightSoftkeyFunction(progress_info->rskFuncPtr, KEY_EVENT_UP);
  2975.     if (progress_info->endFuncPtr)
  2976.     {
  2977.         SetKeyHandler(progress_info->endFuncPtr, KEY_END, KEY_EVENT_DOWN);
  2978.     }
  2979. }
  2980. /*****************************************************************************
  2981.  * FUNCTION
  2982.  *  mmi_imps_entry_abort
  2983.  * DESCRIPTION
  2984.  *  Common function to send abort request to PS
  2985.  * PARAMETERS
  2986.  *  void
  2987.  * RETURNS
  2988.  *  void
  2989.  *****************************************************************************/
  2990. void mmi_imps_entry_abort(void)
  2991. {
  2992.     /*----------------------------------------------------------------*/
  2993.     /* Local Variables                                                */
  2994.     /*----------------------------------------------------------------*/
  2995.     /*----------------------------------------------------------------*/
  2996.     /* Code Body                                                      */
  2997.     /*----------------------------------------------------------------*/
  2998.     mmi_imps_pre_entry_progressing(
  2999.         STR_ID_IMPS,
  3000.         GetRootTitleIcon(MENU_ID_IMPS_MAIN),
  3001.         0,
  3002.         0,
  3003.         0,
  3004.         0,
  3005.         (U8*) GetString(STR_GLOBAL_ABORTING),
  3006.         NULL,
  3007.         IMG_GLOBAL_PROGRESS,
  3008.         NULL,
  3009.         NULL,
  3010.         NULL);
  3011. }
  3012. /*****************************************************************************
  3013.  * FUNCTION
  3014.  *  mmi_imps_entry_confirm
  3015.  * DESCRIPTION
  3016.  *  Common function to display confirmation screem
  3017.  * PARAMETERS
  3018.  *  msg             [IN]        String index of message to be displayed in confirmation screen
  3019.  *  lskFuncPtr      [IN]        LSK handler of the confirmation screen
  3020.  *  rskFuncPtr      [IN]        RSK handler of the confirmation screen
  3021.  * RETURNS
  3022.  *  void
  3023.  *****************************************************************************/
  3024. void mmi_imps_entry_confirm(U16 msg, FuncPtr lskFuncPtr, FuncPtr rskFuncPtr)
  3025. {
  3026.     /*----------------------------------------------------------------*/
  3027.     /* Local Variables                                                */
  3028.     /*----------------------------------------------------------------*/
  3029.     /*----------------------------------------------------------------*/
  3030.     /* Code Body                                                      */
  3031.     /*----------------------------------------------------------------*/
  3032.     DisplayConfirm(
  3033.         STR_GLOBAL_YES,