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

MTK

开发平台:

C/C++

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