mmi_imps_ui.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:497k
源码类别:
MTK
开发平台:
C/C++
- IMG_GLOBAL_YES,
- STR_GLOBAL_NO,
- IMG_GLOBAL_NO,
- (UI_string_type) GetString(msg),
- IMG_GLOBAL_QUESTION,
- WARNING_TONE);
- SetLeftSoftkeyFunction(lskFuncPtr, KEY_EVENT_UP);
- SetRightSoftkeyFunction(rskFuncPtr, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_comm_input_meth
- * DESCRIPTION
- * Common highlight handler of Input Method option
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_comm_input_meth(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(EntryInputMethodScreen, KEY_EVENT_UP);
- SetKeyHandler(EntryInputMethodScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- RegisterInputMethodScreenCloseFunction(mmi_imps_util_go_back_2_hist);
- }
- #define WATCH_LIST_IMPS
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_get_watch_list
- * DESCRIPTION
- * Highlight handler of Get Watcher List option
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_get_watch_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_get_watch_list, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_get_watch_list
- * DESCRIPTION
- * Handler of Get Watcher List option
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_get_watch_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* shall not function before auto-update finished */
- if (!imps_p->gen_info.auto_update_done)
- {
- mmi_imps_util_disp_warning_popup(STR_ID_IMPS_ERR_CONT_NOT_READY);
- return;
- }
- /* display progressing screen */
- mmi_imps_pre_entry_progressing(
- STR_ID_IMPS,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- 0,
- 0,
- STR_GLOBAL_ABORT,
- 0,
- (U8*) GetString(STR_ID_IMPS_PROGRESSING),
- NULL,
- IMG_GLOBAL_PROGRESS,
- NULL,
- mmi_imps_get_watch_list_abort,
- mmi_imps_get_watch_list_abort);
- /* reset context of search */
- imps_p->search_result.count = 0;
- #ifdef IMPS_TEST_CODE
- SetKeyHandler(mmi_imps_test_get_watch_list_complete, KEY_SEND, KEY_EVENT_DOWN);
- #else /* IMPS_TEST_CODE */
- imps_p->search_result.search_cause = IMPS_SEARCH_WATCHER;
- mmi_imps_ps_get_watch_list_req();
- #endif /* IMPS_TEST_CODE */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_get_watch_list_abort
- * DESCRIPTION
- * Abort getting watch list
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_get_watch_list_abort(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_entry_abort();
- #ifdef IMPS_TEST_CODE
- SetKeyHandler(mmi_imps_get_watch_list_abort_finish, KEY_SEND, KEY_EVENT_DOWN);
- #else
- mmi_imps_ps_abort_get_watch_list_req();
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_get_watch_list_abort_finish
- * DESCRIPTION
- * Aborting getting watch list finished
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_get_watch_list_abort_finish(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->search_result.count) /* some result already came back */
- {
- mmi_imps_entry_search_result();
- DeleteUptoScrID(SCR_ID_IMPS_CONT_OPT);
- }
- else
- {
- if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
- {
- GoBackToHistory(SCR_ID_IMPS_CONT_OPT);
- }
- else
- {
- DeleteUptoScrID(SCR_ID_IMPS_CONT_OPT);
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_pre_entry_watch_list
- * DESCRIPTION
- * Pre-Entry function of watch list. Retrieve data from file.
- * PARAMETERS
- * filename [?]
- * file_path(?) [IN] File_path of search result
- * RETURNS
- * result of open file
- *****************************************************************************/
- S32 mmi_imps_pre_entry_watch_list(S16 *filename)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, count;
- FS_HANDLE fileHandle = 0;
- imps_watcher_entity_struct *buff = (imps_watcher_entity_struct*) OslMalloc(sizeof(imps_watcher_entity_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- count = (S32) imps_p->search_result.count;
- if (count)
- {
- U32 len;
- S32 result;
- fileHandle = FS_Open((U16*) filename, FS_READ_ONLY);
- if (fileHandle > 0)
- {
- for (i = 0; i < count; i++)
- {
- result = FS_Read(fileHandle, (void*)buff, sizeof(imps_watcher_entity_struct), &len);
- if (result == FS_NO_ERROR)
- {
- strcpy((S8*) imps_p->search_result.entity[i].id, (S8*) buff->watcher_user_id);
- memset(&imps_p->search_result.entity[i].sname[0], 0, sizeof(imps_p->search_result.entity[i].sname));
- }
- }
- FS_Close(fileHandle);
- }
- }
- OslMfree(buff);
- return (S32) fileHandle;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_watch_list
- * DESCRIPTION
- * Display watcher list
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_watch_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- S32 i;
- S32 num_of_items;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- num_of_items = (S32) imps_p->search_result.count;
- if (num_of_items == 0)
- {
- mmi_imps_util_disp_empty_popup();
- return;
- }
- EntryNewScreen(SCR_ID_IMPS_WATCHER_LIST, NULL, mmi_imps_entry_watch_list, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_WATCHER_LIST);
- SetParentHandler(0);
- RegisterHighlightHandler(mmi_imps_hilite_watch_list);
- num_of_items = (S32) imps_p->search_result.count;
- for (i = 0; i < num_of_items; i++)
- {
- mmi_imps_util_ansi_2_ucs2_menu(
- (S8*) imps_p->search_result.entity[i].id,
- (S8*) subMenuData[i],
- MAX_SUBMENU_CHARACTERS);
- mmi_imps_util_generate_name_hint((S8*) imps_p->search_result.entity[i].sname, i, MAX_SUBMENU_CHARACTERS);
- subMenuDataPtrs[i] = subMenuData[i];
- }
- ShowCategory53Screen(
- STR_ID_IMPS_WATCHER_LIST,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_ADD,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- num_of_items,
- (U8 **) subMenuDataPtrs,
- (U16*) gIndexIconsImageList,
- (U8 **) hintDataPtrs,
- 0,
- 0,
- guiBuffer);
- if (imps_p->cont_info.no_cont == IMPS_MAX_NO_CONT || imps_p->group_info.no_group == 0)
- {
- ChangeLeftSoftkey(0, 0);
- }
- else
- {
- SetLeftSoftkeyFunction(mmi_imps_pre_entry_sel_group, KEY_EVENT_UP);
- }
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_watch_list
- * DESCRIPTION
- * Highlight handler of watch list item
- * PARAMETERS
- * index [IN] Index of highlighting item
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_watch_list(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- imps_p->search_result.curr_item = (U8) index;
- }
- #define CHAT_IMPS
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_cont_send_msg
- * DESCRIPTION
- * Highlight handler of Send/Read Message option
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_cont_send_msg(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_pre_entry_chat, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_pre_entry_chat, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_pre_entry_chat
- * DESCRIPTION
- * Pre-Entry function of chat room
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_pre_entry_chat(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- U8 *id;
- UI_character_type *nick_name;
- U8 new_room = TRUE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- id = &imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont].id[0];
- nick_name = &imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont].nick_name[0];
- /* check if chat room for the friend already exists */
- for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
- {
- if (imps_p->room_info.room_list[i].is_used)
- {
- if (mmi_imps_util_is_id_same((S8*) id, (S8*) imps_p->room_info.room_list[i].member[0].id))
- {
- new_room = FALSE;
- break;
- }
- }
- }
- if (i == IMPS_MAX_NO_ROOM) /* all chat rooms are occupied */
- {
- i = mmi_imps_util_get_empty_room_slot();
- if (i == IMPS_MAX_NO_ROOM)
- {
- mmi_imps_util_disp_err_popup(STR_ID_IMPS_ERR_CHAT_ROOM_FULL);
- return;
- }
- }
- if (new_room)
- {
- /* reset all data */
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[i];
- memset(room, 0, sizeof(mmi_imps_room_struct));
- room->is_used = TRUE;
- room->type = IMPS_ROOM_TYPE_SINGLE;
- room->no_member = 1;
- room->tab_index = imps_p->gen_info.curr_tab = imps_p->gen_info.no_tab;
- imps_p->gen_info.no_tab++;
- strcpy((S8*) room->member[0].id, (S8*) id);
- strcpy((S8*) room->room_id, (S8*) id);
- /* display be screen name if the user's alias is not empty */
- if (pfnUnicodeStrlen((S8*) nick_name))
- {
- pfnUnicodeStrcpy((S8*) room->room_name, (S8*) nick_name);
- pfnUnicodeStrcpy((S8*) room->member[0].sname, (S8*) nick_name);
- }
- else
- {
- AnsiiToUnicodeString((S8*) room->room_name, (S8*) id);
- room->member[0].sname[0] = 0;
- }
- imps_p->room_info.no_rooms++;
- /* update display buffer */
- mmi_imps_new_room_string((S8*) room->chat_buff, (S8*) room->room_name);
- }
- else
- {
- imps_p->gen_info.curr_tab = (U8) imps_p->room_info.room_list[i].tab_index;
- }
- imps_p->chat_info.curr_room = (U8) i;
- mmi_imps_entry_chat();
- DeleteScreenIfPresent(SCR_ID_IMPS_CONT_OPT);
- DeleteScreenIfPresent(SCR_ID_IMPS_CONT);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_show_input_screen
- * DESCRIPTION
- * Show input editor in chatting screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_show_input_screen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- Category435ShowPopup(TRUE);
- imps_p->room_info.room_list[imps_p->chat_info.curr_room].edit_mode = TRUE;
- SetKeyHandler(mmi_imps_chat_send_key_hdlr, KEY_SEND, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_hide_input_screen
- * DESCRIPTION
- * Hide input editor in chatting screen
- * PARAMETERS
- * redraw [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_hide_input_screen(BOOL redraw)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- Category435HidePopup(redraw);
- imps_p->room_info.room_list[imps_p->chat_info.curr_room].edit_mode = FALSE;
- mmi_imps_chat_register_key_hdlr();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_register_key_hdlr
- * DESCRIPTION
- * Register key handlers for chatting screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_register_key_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 keyCodes[] = {KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_STAR, KEY_POUND};
- U8 nKeyCodes = (U8) 12;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetCategory435RSKFunction(GoBackHistory);
- if (imps_p->room_info.room_list[imps_p->chat_info.curr_room].edit_mode == FALSE)
- {
- SetKeyHandler(mmi_imps_tab_prev, KEY_LEFT_ARROW, KEY_EVENT_DOWN); /* move to previous tab */
- SetKeyHandler(mmi_imps_tab_next, KEY_RIGHT_ARROW, KEY_EVENT_DOWN); /* move to next tab */
- SetGroupKeyHandler(mmi_imps_chat_show_input_screen, keyCodes, nKeyCodes, KEY_EVENT_UP);
- }
- else
- {
- SetKeyHandler(mmi_imps_chat_send_key_hdlr, KEY_SEND, KEY_EVENT_DOWN);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_input_rsk_hdlr
- * DESCRIPTION
- * RSK handler of input screen. Hide input popup screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_input_rsk_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_chat_hide_input_screen(TRUE);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat
- * DESCRIPTION
- * Entry chat room of IMPS application
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_CHAT, mmi_imps_exit_chat, NULL, NULL);
- /* if GUI buffer is not NULL, shall histroy shall be reset, and room is not in edit_mode */
- if ((room->clear_gui_buff) && (room->edit_mode == FALSE))
- {
- guiBuffer = NULL;
- room->clear_gui_buff = FALSE;
- }
- else
- {
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT);
- }
- if (room->edit_mode == FALSE) /* clear buffer */
- {
- room->input_buff[0] = 0;
- }
- SetParentHandler(0);
- /* initialize tab */
- mmi_imps_tab_init();
- /* configure icons */
- wgui_config_general_multiline_icon_handler(MMI_FALSE, IMPS_NUM_MOOD, g_imps_mood_icon_list);
- ShowCategory435Screen(
- (UI_string_type) room->room_name,
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- (S8) imps_p->gen_info.no_tab,
- (S8) imps_p->gen_info.curr_tab,
- MMI_tab_bar_items,
- room->edit_mode,
- NULL,
- INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
- (U8*) room->input_buff,
- IMPS_MAX_CHAT_INPUT_LEN,
- (U8*) room->chat_buff,
- pfnUnicodeStrlen((S8*) room->chat_buff),
- wgui_general_multiline_icon_handler,
- (PU8) GetImage(IMG_ID_IMPS_HAPPY),
- guiBuffer);
- SetCategory435TabSelectCallback(mmi_imps_tab_jump);
- /* mark the unread message flag as FALSE */
- room->unread_msg = FALSE;
- mmi_imps_util_blink_tab();
- /* update status icon because it might be changed when new message read */
- mmi_imps_util_update_status_icon();
- /* reset message icon in contact list */
- mmi_imps_cont_reset_msg_icon();
- /* RSK/LSK handlers for editable mode */
- SetCategory435EditorRSKFunction(mmi_imps_chat_input_rsk_hdlr);
- SetCategory435EditorLSKFunction(mmi_imps_chat_input_opt);
- /* RSK/LSK handlers for read-only mode */
- SetCategory435RSKFunction(GoBackHistory);
- SetCategory435LSKFunction(mmi_imps_entry_chat_opt);
- mmi_imps_chat_register_key_hdlr();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_exit_chat
- * DESCRIPTION
- * Exit chat room of IMPS application (128*128/128*160)
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_exit_chat(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- wgui_reset_general_multiline_icon_handler();
- GenericExitScreen(SCR_ID_IMPS_CHAT, mmi_imps_entry_chat);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_opt
- * DESCRIPTION
- * Entry option screen of chat room
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_opt(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 numItems;
- U16 nStrItemList[5];
- U8 *guiBuffer;
- U16 menu_id;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->room_info.room_list[imps_p->chat_info.curr_room].type == IMPS_ROOM_TYPE_SINGLE)
- {
- menu_id = MENU_ID_IMPS_CHAT_OPT2;
- }
- else
- {
- menu_id = MENU_ID_IMPS_CHAT_OPT;
- }
- EntryNewScreen(SCR_ID_IMPS_CHAT_OPT, NULL, mmi_imps_entry_chat_opt, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT_OPT);
- SetParentHandler(menu_id);
- numItems = GetNumOfChild(menu_id);
- GetSequenceStringIds(menu_id, nStrItemList);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- numItems,
- nStrItemList,
- (U16*) gIndexIconsImageList,
- NULL,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_write
- * DESCRIPTION
- * Highlight handler of Chat -> Option -> Write menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_write(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_entry_chat_write, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_write
- * DESCRIPTION
- * Display popup write message screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_write(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GoBackHistory();
- mmi_imps_chat_show_input_screen();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_send
- * DESCRIPTION
- * Highlight handler of Send menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_send(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_chat_send_done, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_chat_send_done, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_send_done
- * DESCRIPTION
- * Highlight handler of Send -> Option -> Done
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_send_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_chat_send_done, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_chat_send_done, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- #ifdef IMPS_FOR_OMA_ONLY
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_private_msg
- * DESCRIPTION
- * Check if it's a private message within a chat room
- * PARAMETERS
- * session_id [IN] Id of the chat session
- * buff [IN] Buffer of input message
- * curr_room [IN] Index of current chat room
- * RETURNS
- * TRUE if it's a private message; otherwise FALSE
- *****************************************************************************/
- BOOL mmi_imps_chat_private_msg(S32 session_id, S16 *buff, U8 curr_room)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- S16 *msg = buff;
- U32 length;
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[curr_room];
- S32 count = (S32) room->no_member;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (room->type == IMPS_ROOM_TYPE_SINGLE)
- {
- return FALSE;
- }
- for (i = 0; i < count; i++)
- {
- length = pfnUnicodeStrlen((S8*) room->member[i].sname);
- if (pfnUnicodeStrncmp((S8*) room->member[i].sname, (S8*) msg, length) == 0)
- {
- break;
- }
- }
- if (i == count)
- {
- return FALSE;
- }
- msg += length;
- if (pfnUnicodeStrlen((S8*) msg))
- {
- mmi_imps_ps_send_msg_req(
- session_id,
- (S16*) msg,
- room->room_id,
- IMPS_ENTITY_TYPE_SCREEN_NAME,
- (S8*) room->member[i].sname);
- return TRUE;
- }
- return FALSE;
- }
- #endif /* IMPS_FOR_OMA_ONLY */
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_send_key_hdlr
- * DESCRIPTION
- * Send key handler of chat screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_send_key_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (pfnUnicodeStrlen((S8*) room->input_buff))
- {
- S32 session_id = mmi_imps_chat_insert_session();
- /* check if there is any empty session can be used */
- if (session_id == 0)
- {
- mmi_imps_chat_display_send_failed(imps_p->chat_info.curr_room, room->input_buff);
- mmi_imps_util_play_tone(IMPS_ERR_TONE);
- }
- else
- {
- U8 entity_type;
- mmi_imps_chat_disp_input_msg();
- #ifndef IMPS_TEST_CODE
- #ifdef IMPS_FOR_OMA_ONLY
- if (mmi_imps_chat_private_msg(session_id, (S16*) room->input_buff, imps_p->chat_info.curr_room) == FALSE)
- #endif
- {
- if (room->type == IMPS_ROOM_TYPE_SINGLE)
- {
- entity_type = IMPS_ENTITY_TYPE_USER;
- }
- else
- {
- entity_type = IMPS_ENTITY_TYPE_GROUP;
- }
- mmi_imps_ps_send_msg_req(session_id, (S16*) room->input_buff, room->room_id, (U8) entity_type, NULL);
- }
- #endif /* IMPS_TEST_CODE */
- }
- mmi_imps_chat_hide_input_screen(FALSE);
- UpdateCategory435LogText((U8*) room->chat_buff, (S32) pfnUnicodeStrlen((S8*) room->chat_buff));
- room->input_buff[0] = 0;
- }
- else
- {
- mmi_imps_chat_hide_input_screen(TRUE);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_send_done
- * DESCRIPTION
- * Highlight handler of Send -> Option -> Done
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_send_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (pfnUnicodeStrlen((S8*) room->input_buff))
- {
- S32 session_id = mmi_imps_chat_insert_session();
- /* check if there is any empty session can be used */
- if (session_id == 0)
- {
- mmi_imps_chat_display_send_failed(imps_p->chat_info.curr_room, room->input_buff);
- mmi_imps_util_play_tone(IMPS_ERR_TONE);
- }
- else
- {
- U8 entity_type;
- mmi_imps_chat_disp_input_msg();
- #ifndef IMPS_TEST_CODE
- #ifdef IMPS_FOR_OMA_ONLY
- if (mmi_imps_chat_private_msg(session_id, (S16*) room->input_buff, imps_p->chat_info.curr_room) == FALSE)
- #endif
- {
- if (room->type == IMPS_ROOM_TYPE_SINGLE)
- {
- entity_type = IMPS_ENTITY_TYPE_USER;
- }
- else
- {
- entity_type = IMPS_ENTITY_TYPE_GROUP;
- }
- mmi_imps_ps_send_msg_req(session_id, (S16*) room->input_buff, room->room_id, (U8) entity_type, NULL);
- }
- room->input_buff[0] = 0;
- #endif /* IMPS_TEST_CODE */
- }
- }
- gui_lock_double_buffer();
- GoBackToHistory(SCR_ID_IMPS_CHAT);
- gui_unlock_double_buffer();
- mmi_imps_chat_hide_input_screen(FALSE);
- UpdateCategory435LogText((U8*) room->chat_buff, (S32) pfnUnicodeStrlen((S8*) room->chat_buff));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_input_opt
- * DESCRIPTION
- * Entry option screen of chat input box
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_input_opt(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 numItems;
- U16 nStrItemList[3];
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_CHAT_OPT, NULL, mmi_imps_chat_input_opt, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT_OPT);
- SetParentHandler(MENU_ID_IMPS_CHAT_INPUT_OPT);
- numItems = GetNumOfChild(MENU_ID_IMPS_CHAT_INPUT_OPT);
- GetSequenceStringIds(MENU_ID_IMPS_CHAT_INPUT_OPT, nStrItemList);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- numItems,
- nStrItemList,
- (U16*) gIndexIconsImageList,
- NULL,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_disp_input_msg
- * DESCRIPTION
- * Insert new input message in chat room.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_disp_input_msg(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_input_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_writer_struct writer;
- BOOL result;
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- tmp_input_buff[0] = 0;
- wgui_color_buffer_create_writer(&writer, (U8*) tmp_input_buff, IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_write_char(&writer, GUI_INPUT_COLOR_04 /* colorrr++ */ );
- /* group talk */
- if ((room->type != IMPS_ROOM_TYPE_SINGLE) && pfnUnicodeStrlen((S8*) room->sname))
- {
- wgui_color_buffer_write_char(&writer, '<');
- wgui_color_buffer_write_string(&writer, (U8*) room->sname, MMI_FALSE, &result);
- wgui_color_buffer_write_char(&writer, '>');
- }
- else
- {
- U16 *tmp_chat_buff1 = OslMalloc(IMPS_MAX_CHAT_BUFF);
- U16 *tmp_chat_buff2 = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- sprintf((S8*) tmp_chat_buff1, "<%s>", (S8*) imps_p->act_prof.username);
- AnsiiToUnicodeString((S8*) tmp_chat_buff2, (S8*) tmp_chat_buff1);
- wgui_color_buffer_write_string(&writer, (U8*) tmp_chat_buff2, MMI_FALSE, &result);
- OslMfree(tmp_chat_buff1);
- OslMfree(tmp_chat_buff2);
- }
- wgui_color_buffer_write_char(&writer, GUI_INPUT_MARKER_RESET_ALL);
- wgui_color_buffer_write_string(&writer, (U8*) L"n", MMI_FALSE, &result);
- wgui_color_buffer_write_string(&writer, (U8*) room->input_buff, MMI_FALSE, &result);
- wgui_color_buffer_write_string(&writer, (U8*) L"nn", MMI_FALSE, &result);
- mmi_imps_chat_flush_msg(tmp_input_buff, (S32) imps_p->chat_info.curr_room);
- OslMfree(tmp_input_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_recv_msg
- * DESCRIPTION
- * Handler when receiving a incoming message for current chat room
- * PARAMETERS
- * msg [?]
- * room_id [IN]
- * sender [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_recv_msg(U16 *msg, U8 room_id, imps_entity_struct *sender)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_sname_buff;
- U16 *tmp_input_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_writer_struct writer;
- BOOL result;
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[room_id];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- tmp_input_buff[0] = 0;
- wgui_color_buffer_create_writer(&writer, (U8*) tmp_input_buff, IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_write_char(&writer, GUI_INPUT_COLOR_00);
- /* insert input into buffer */
- wgui_color_buffer_write_char(&writer, '<');
- if (pfnUnicodeStrlen((S8*) sender->sname) > 0)
- {
- wgui_color_buffer_write_string(&writer, (U8*) sender->sname, MMI_FALSE, &result);
- }
- else
- {
- tmp_sname_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
- AnsiiToUnicodeString((S8*) tmp_sname_buff, (S8*) sender->id);
- wgui_color_buffer_write_string(&writer, (U8*) tmp_sname_buff, MMI_FALSE, &result);
- OslMfree(tmp_sname_buff);
- }
- wgui_color_buffer_write_string(&writer, (U8*) L">n", MMI_FALSE, &result);
- wgui_color_buffer_write_char(&writer, GUI_INPUT_MARKER_RESET_ALL);
- wgui_color_buffer_write_string(&writer, (U8*) msg, MMI_FALSE, &result);
- wgui_color_buffer_write_string(&writer, (U8*) L"nn", MMI_FALSE, &result);
- mmi_imps_chat_flush_msg(tmp_input_buff, (S32) room_id);
- room->clear_gui_buff = TRUE;
- OslMfree(tmp_input_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_display_send_failed
- * DESCRIPTION
- * Display error message if a message can not be sent
- * PARAMETERS
- * room_id [IN] Index of room in room list
- * msg [IN] Text message to be display
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_display_send_failed(U8 room_id, U16 *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_input_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_writer_struct writer;
- BOOL result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- tmp_input_buff[0] = 0;
- wgui_color_buffer_create_writer(&writer, (U8*) tmp_input_buff, IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_write_char(&writer, GUI_INPUT_COLOR_00);
- wgui_color_buffer_write_string(&writer, (U8*) GetString(STR_ID_IMPS_MSG_CANNOT_SEND), MMI_FALSE, &result);
- wgui_color_buffer_write_char(&writer, GUI_INPUT_MARKER_RESET_ALL);
- wgui_color_buffer_write_char(&writer, 'n');
- wgui_color_buffer_write_string(&writer, (U8*) msg, MMI_FALSE, &result);
- wgui_color_buffer_write_string(&writer, (U8*) L"nn", MMI_FALSE, &result);
- mmi_imps_chat_flush_msg(tmp_input_buff, (S32) room_id);
- OslMfree(tmp_input_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_disp_user_change_msg
- * DESCRIPTION
- * Display member joined/left message in the chat room
- * PARAMETERS
- * room_id [IN] Index of room
- * member [IN] Left memeber
- * type [IN] Type of change
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_disp_user_change_msg(S32 room_id, mmi_imps_entity_struct *member, S32 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_sname_buff;
- U16 *tmp_input_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* insert input into buffer */
- if (pfnUnicodeStrlen((S8*) member->sname))
- {
- pfnUnicodeStrcpy((S8*) tmp_input_buff, (S8*) member->sname);
- }
- else
- {
- tmp_sname_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
- AnsiiToUnicodeString((S8*) tmp_sname_buff, (S8*) member->id);
- pfnUnicodeStrcpy((S8*) tmp_input_buff, (S8*) tmp_sname_buff);
- OslMfree(tmp_sname_buff);
- }
- pfnUnicodeStrcat((S8*) tmp_input_buff, (S8*) L" ");
- if (type == IMPS_ROOM_MEMBER_JOINED)
- {
- pfnUnicodeStrcat((S8*) tmp_input_buff, (S8*) GetString(STR_ID_IMPS_JOINED_ROOM));
- }
- else
- {
- pfnUnicodeStrcat((S8*) tmp_input_buff, (S8*) GetString(STR_ID_IMPS_LEFT_CHAT_ROOM));
- }
- pfnUnicodeStrcat((S8*) tmp_input_buff, (S8*) L"nn");
- mmi_imps_chat_flush_msg(tmp_input_buff, room_id);
- OslMfree(tmp_input_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_flush_msg
- * DESCRIPTION
- * Flush message into display buffer
- * PARAMETERS
- * data [IN] Data to be flush to display buffer
- * room_id [IN] Index of chat room
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_flush_msg(U16 *data, S32 room_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 input_len;
- S32 disp_len;
- S32 total_len;
- U16 *tmp_chat_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[room_id];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- input_len = pfnUnicodeStrlen((S8*) data);
- disp_len = pfnUnicodeStrlen((S8*) room->chat_buff);
- total_len = input_len + disp_len;
- if (total_len < IMPS_MAX_CHAT_BUFF)
- {
- pfnUnicodeStrcat((S8*) room->chat_buff, (S8*) data);
- }
- else
- {
- /* truncated previous string */
- U8 *cursor = (U8*) & room->chat_buff[0];
- U8 *end = (U8*) & room->chat_buff[(IMPS_MAX_CHAT_BUFF - 1)];
- cursor += ((total_len - IMPS_MAX_CHAT_BUFF + 1) * ENCODING_LENGTH);
- while ((cursor[0] != 0 || cursor[1] != 0) && (cursor < end))
- {
- if (cursor[0] == 'n' && cursor[1] == ' ')
- {
- cursor += 2; /* move cursor to new line */
- break;
- }
- cursor += 2;
- }
- memset(tmp_chat_buff, 0, IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- if (cursor < end)
- {
- pfnUnicodeStrncpy((S8*) tmp_chat_buff, (S8*) cursor, (end - cursor));
- }
- room->chat_buff[0] = 0;
- pfnUnicodeStrcpy((S8*) room->chat_buff, (S8*) tmp_chat_buff);
- pfnUnicodeStrcat((S8*) room->chat_buff, (S8*) data);
- }
- OslMfree(tmp_chat_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_insert_session
- * DESCRIPTION
- * Insert a chat session into queue
- * PARAMETERS
- * void
- * RETURNS
- * index of session
- *****************************************************************************/
- S32 mmi_imps_chat_insert_session(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < IMPS_MAX_CHAT_MSG_COUNT; i++)
- if (imps_p->chat_info.chat_session[i].session_id == 0)
- {
- break;
- }
- if (i == IMPS_MAX_CHAT_MSG_COUNT)
- {
- return 0;
- }
- else
- {
- mmi_imps_chat_session_struct *session = &imps_p->chat_info.chat_session[i];
- pfnUnicodeStrcpy(
- (S8*) session->input_buff,
- (S8*) imps_p->room_info.room_list[imps_p->chat_info.curr_room].input_buff);
- session->session_id = mmi_imps_util_get_seq_no();
- strcpy((S8*) session->room_id, (S8*) imps_p->room_info.room_list[imps_p->chat_info.curr_room].room_id);
- return session->session_id;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_insert_symbol
- * DESCRIPTION
- * Highlight handler of Insert Symbol menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_insert_symbol(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_entry_chat_insert_symbol, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_entry_chat_insert_symbol, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_insert_symbol
- * DESCRIPTION
- * Display list of symbols to be inserted to chatting screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_insert_symbol(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i;
- U8 *guiBuffer;
- U16 icons[IMPS_NUM_MOOD] =
- {
- IMG_ID_IMPS_HAPPY,
- IMG_ID_IMPS_SAD,
- IMG_ID_IMPS_ANGRY,
- IMG_ID_IMPS_JEALOUS,
- IMG_ID_IMPS_ASHAMED,
- IMG_ID_IMPS_INVINCIBLE,
- IMG_ID_IMPS_IN_LOVE,
- IMG_ID_IMPS_SLEEPY,
- IMG_ID_IMPS_BORED,
- IMG_ID_IMPS_EXCITED,
- IMG_ID_IMPS_ANXIOUS
- };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_INSERT_SYMBOL, NULL, mmi_imps_entry_chat_insert_symbol, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_INSERT_SYMBOL);
- SetParentHandler(0);
- RegisterHighlightHandler(mmi_imps_hilite_symbol);
- for (i = 0; i < IMPS_NUM_MOOD; i++)
- {
- memset(subMenuData[i], 0, MAX_SUB_MENU_SIZE);
- pfnUnicodeStrcpy((S8*) subMenuData[i], (S8*) GetString((U16) (STR_ID_IMPS_HAPPY + i)));
- subMenuDataPtrs[i] = subMenuData[i];
- }
- ShowCategory53Screen(
- STR_ID_IMPS_INSERT_SYMBOL,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- IMPS_NUM_MOOD,
- (U8 **) subMenuDataPtrs,
- (U16*) icons,
- (U8 **) g_imps_mood_str,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- SetLeftSoftkeyFunction(mmi_imps_sym_sel_done, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_symbol
- * DESCRIPTION
- * Highlight handler in symbol list screen
- * PARAMETERS
- * index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_symbol(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- imps_p->chat_info.sel_sym = (U8) index;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_sym_sel_done
- * DESCRIPTION
- * Handler when finish selecting a symbol
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_sym_sel_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- S32 input_len = pfnUnicodeStrlen((S8*) room->input_buff);
- S32 sym_len = pfnUnicodeStrlen((S8*) g_imps_mood_str[imps_p->chat_info.sel_sym]);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((input_len + sym_len) > (IMPS_MAX_NOTE_LEN - 1))
- {
- mmi_imps_util_disp_err_popup(STR_ID_IMPS_ERR_NO_SPACE);
- }
- else
- {
- /* lock buffer to prevent redraw */
- gui_lock_double_buffer();
- GoBackToHistory(SCR_ID_IMPS_CHAT);
- gui_unlock_double_buffer();
- Category435DirectInsertString((UI_string_type) g_imps_mood_str[imps_p->chat_info.sel_sym], TRUE);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_member
- * DESCRIPTION
- * Highlight handler of List Member menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_member(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_entry_chat_member, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_entry_chat_member, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_member
- * DESCRIPTION
- * Display list of members who is currently on that chat room
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_member(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- S32 i;
- S32 count;
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (room->no_member == 0)
- {
- mmi_imps_util_disp_empty_popup();
- return;
- }
- EntryNewScreen(SCR_ID_IMPS_CHAT_MEMBER, NULL, mmi_imps_entry_chat_member, NULL);
- /* fill member */
- for (i = 0, count = 0; i < IMPS_MAX_ENTITY_NUMBER; i++)
- {
- if (strlen((S8*) room->member[i].id) || pfnUnicodeStrlen((S8*) room->member[i].sname))
- {
- mmi_imps_util_ansi_2_ucs2_menu((S8*) room->member[i].id, (S8*) hintData[count], MAX_SUBMENU_CHARACTERS);
- if (pfnUnicodeStrlen((S8*) room->member[i].sname))
- {
- pfnUnicodeStrcpy((S8*) subMenuData[count], (S8*) room->member[i].sname);
- }
- else
- {
- pfnUnicodeStrcpy((S8*) subMenuData[count], (S8*) GetString(STR_ID_IMPS_ANONYMOUS));
- }
- subMenuDataPtrs[count] = subMenuData[count];
- if (pfnUnicodeStrlen((S8*) hintData[count]))
- {
- hintDataPtrs[count] = hintData[count];
- }
- else
- {
- hintDataPtrs[count] = NULL;
- }
- count++;
- }
- }
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT_MEMBER);
- SetParentHandler(0);
- ShowCategory53Screen(
- STR_ID_IMPS_LIST_MEMBER,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- 0,
- 0,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- (S32) count,
- (U8 **) subMenuDataPtrs,
- (U16*) gIndexIconsImageList,
- (U8 **) hintDataPtrs,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_save
- * DESCRIPTION
- * Highlight handler of Save menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_save(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_entry_chat_save, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_entry_chat_save, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_save
- * DESCRIPTION
- * Entry function of Save menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_save(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (pfnUnicodeStrlen((S8*) imps_p->room_info.room_list[imps_p->chat_info.curr_room].chat_buff) == 0)
- {
- mmi_imps_util_disp_err_popup(STR_ID_IMPS_EMPTY_INPUT);
- }
- else
- {
- FMGR_FILTER filter;
- FMGR_FILTER_INIT(&filter);
- FMGR_FILTER_SET(&filter, FMGR_TYPE_FOLDER);
- mmi_fmgr_select_path_and_enter(
- APP_IMPS,
- FMGR_SELECT_FOLDER,
- filter,
- (S8*) L"root",
- mmi_imps_chat_save_select_path_done);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_save_select_path_done
- * DESCRIPTION
- * callback function when select path to save text finished.
- * PARAMETERS
- * path [?]
- * is_short [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_save_select_path_done(void *path, int is_short)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (path)
- {
- imps_p->file_buff[0] = 0;
- pfnUnicodeStrcpy((S8*) imps_p->path_buff, (S8*) path);
- mmi_imps_entry_chat_save_filename();
- }
- else
- {
- GoBackToHistory(SCR_ID_IMPS_CHAT_OPT);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_save_filename
- * DESCRIPTION
- * Display screen for the user to enter file name for saving chat message
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_save_filename(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_CHAT_FILENAME, NULL, mmi_imps_entry_chat_save_filename, NULL);
- SetParentHandler(0);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT_FILENAME);
- ShowCategory5Screen(
- STR_GLOBAL_FILENAME,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OPTIONS,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
- (U8*) imps_p->file_buff,
- FMGR_MAX_INPUT_FILE_LEN,
- guiBuffer);
- SetLeftSoftkeyFunction(mmi_imps_entry_chat_save_opt, KEY_EVENT_UP);
- SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_save_opt
- * DESCRIPTION
- * Display option screen for saving chat message.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_save_opt(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 numItems;
- U16 nStrItemList[2];
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_CHAT_SAVE_OPT, NULL, mmi_imps_entry_chat_save_opt, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT_SAVE_OPT);
- SetParentHandler(MENU_ID_IMPS_CHAT_SAVE_OPT);
- numItems = GetNumOfChild(MENU_ID_IMPS_CHAT_SAVE_OPT);
- GetSequenceStringIds(MENU_ID_IMPS_CHAT_SAVE_OPT, nStrItemList);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- numItems,
- nStrItemList,
- (U16*) gIndexIconsImageList,
- NULL,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_save_opt_done
- * DESCRIPTION
- * Highlight handler of Chat Save -> File Name -> Option -> Done
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_save_opt_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_chat_save_done, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_save_done
- * DESCRIPTION
- * LSK handler when confirm to save chat message
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_save_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 path_len = pfnUnicodeStrlen((S8*) imps_p->path_buff);
- S32 file_len = pfnUnicodeStrlen((S8*) imps_p->file_buff) + strlen(".txt");
- S8 *file_buff;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (file_len == 0)
- {
- mmi_imps_util_disp_err_popup(STR_ID_IMPS_EMPTY_FILENAME);
- return;
- }
- if ((path_len + file_len) > FMGR_MAX_PATH_LEN)
- {
- mmi_imps_util_disp_err_popup(STR_ID_IMPS_FILENAME_TOO_LONG);
- return;
- }
- file_buff = OslMalloc((FMGR_MAX_PATH_LEN + 1)*ENCODING_LENGTH);
- pfnUnicodeStrcpy((S8*) file_buff, (S8*) imps_p->path_buff);
- pfnUnicodeStrcat((S8*) file_buff, (S8*) imps_p->file_buff);
- pfnUnicodeStrcat((S8*) file_buff, (S8*) L".txt");
- if (mmi_imps_util_check_file_exist(file_buff))
- {
- mmi_imps_util_disp_err_popup(STR_ID_IMPS_DUPLICATE_FILENAME);
- }
- else
- {
- FS_HANDLE fileHandle;
- fileHandle = FS_Open((U16*) file_buff, FS_CREATE_ALWAYS);
- if (fileHandle > 0)
- {
- S32 result;
- U32 len;
- wgui_color_buffer_reader_struct reader;
- S8 *out_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- /* create reader and strip color related markers */
- wgui_color_buffer_create_reader(
- &reader,
- (U8*) imps_p->room_info.room_list[imps_p->chat_info.curr_room].chat_buff);
- wgui_color_buffer_read_stripped_text(
- &reader,
- (U8*) out_buff,
- IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH,
- (S32*) & len);
- /* UCS2 string prefix */
- result = FS_Write(fileHandle, (void*)g_imps_ucs2_file_prefix, 2, &len);
- result = FS_Write(
- fileHandle,
- (void*)out_buff,
- (pfnUnicodeStrlen((S8*) imps_p->room_info.room_list[imps_p->chat_info.curr_room].chat_buff) * ENCODING_LENGTH),
- &len);
- FS_Close(fileHandle);
- if (result < 0)
- {
- mmi_imps_util_disp_err_popup(GetFileSystemErrorString(result));
- }
- else
- {
- mmi_imps_util_disp_popup_done();
- DeleteUptoScrID(SCR_ID_IMPS_CHAT);
- }
- OslMfree(out_buff);
- }
- else
- {
- mmi_imps_util_disp_err_popup(GetFileSystemErrorString(fileHandle));
- }
- }
- OslMfree(file_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_close
- * DESCRIPTION
- * Highlight handler of Close Chat Room menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_close(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_entry_chat_close, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_entry_chat_close, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_close
- * DESCRIPTION
- * Entry function of Close Chat Room menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_close(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_entry_confirm(STR_GLOBAL_CLOSE, mmi_imps_chat_close, GoBackHistory);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_chat_close
- * DESCRIPTION
- * Confirm to close a chat room
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_chat_close(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* if it's a group, shall send request to protocol */
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifndef IMPS_TEST_CODE
- if (room->type == IMPS_ROOM_TYPE_GROUP_CREATE)
- {
- /* send delete group request */
- mmi_imps_display_progressing();
- mmi_imps_ps_del_group_req(room->room_id);
- }
- else if (room->type == IMPS_ROOM_TYPE_GROUP_JOIN)
- {
- /* send leave group request */
- mmi_imps_display_progressing();
- mmi_imps_ps_leave_group_req(room->room_id);
- }
- else
- {
- /* single talk */
- mmi_imps_room_close_finished(room);
- mmi_imps_pre_entry_cont();
- DeleteScreenIfPresent(SCR_ID_IMPS_CHAT);
- DeleteScreenIfPresent(SCR_ID_IMPS_CHAT_OPT);
- }
- #else /* IMPS_TEST_CODE */
- mmi_imps_pre_entry_cont();
- DeleteScreenIfPresent(SCR_ID_IMPS_CHAT);
- DeleteScreenIfPresent(SCR_ID_IMPS_CHAT_OPT);
- mmi_imps_room_close_finished(room);
- #endif /* IMPS_TEST_CODE */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_room_close_finished
- * DESCRIPTION
- * Reset context of chat room when finish closing chat room
- * PARAMETERS
- * room [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_room_close_finished(mmi_imps_room_struct *room)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* reset status icon of contact list */
- if (room->type == IMPS_ROOM_TYPE_SINGLE)
- {
- /* reset status icon of contact */
- for (i = 1; i < imps_p->cont_info.no_cont; i++)
- {
- if (mmi_imps_util_is_id_same((S8*) room->member[0].id, (S8*) imps_p->cont_info.cont_list[i].id))
- {
- /* contact list found, unset new message state */
- imps_p->cont_info.cont_list[i].comm_state &= ~IMPS_CONT_NEW_MSG;
- break;
- }
- }
- }
- imps_p->chat_info.curr_room = 0;
- imps_p->room_info.curr_item = 0;
- imps_p->room_info.no_rooms--;
- mmi_imps_tab_del(room->tab_index, 0);
- mmi_imps_room_reset_cntx(room);
- mmi_imps_util_update_status_icon();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_close_chat_room_done
- * DESCRIPTION
- * Callback handler when close chat room finished
- * PARAMETERS
- * result [IN] Error cause of result
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_close_chat_room_done(S32 result)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* finished close chat room */
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- BOOL chat_present = IsScreenPresent(SCR_ID_IMPS_CHAT);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (result != IMPS_OK)
- {
- if (imps_p->gen_info.is_reentry)
- {
- mmi_imps_re_entry_app();
- mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(result));
- }
- else
- {
- mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(result));
- if (chat_present) /* entry from chat screen */
- {
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CHAT);
- }
- else /* entry from room list */
- {
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CHAT_ROOM_OPT);
- }
- }
- }
- else /* close finished */
- {
- /* update tab info, delete one tab */
- mmi_imps_room_close_finished(room);
- if (imps_p->gen_info.is_reentry)
- {
- mmi_imps_re_entry_app();
- }
- else
- {
- if (IsScreenPresent(SCR_ID_IMPS_CHAT)) /* entry from chat screen */
- {
- /* single talk */
- if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
- {
- mmi_imps_pre_entry_cont();
- DeleteScreenIfPresent(SCR_ID_IMPS_CHAT_OPT);
- DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
- }
- else
- {
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CHAT);
- HistoryReplace(SCR_ID_IMPS_CHAT, SCR_ID_IMPS_CONT, mmi_imps_pre_entry_cont);
- }
- }
- else
- {
- /* alyways regarded as success */
- mmi_imps_util_disp_popup_done();
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CHAT_ROOM);
- }
- }
- }
- }
- #define INVITE_IMPS
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_chat_invite
- * DESCRIPTION
- * Highlight handler of Invite Friend menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_chat_invite(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_pre_entry_chat_invite, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_pre_entry_chat_invite, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_pre_entry_chat_invite
- * DESCRIPTION
- * Pre-Entry function of Invite menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_pre_entry_chat_invite(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j, k, no_cont, no_member;
- mmi_imps_room_struct *room;
- mmi_imps_cont_struct *cont;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- no_cont = (S32) imps_p->cont_info.no_cont;
- room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
- no_member = (S32) room->no_member;
- k = 0;
- for (i = 1; i < no_cont; i++) /* neglect MySelf */
- {
- cont = &imps_p->cont_info.cont_list[i];
- if (cont->availability == IMPS_PA_USER_NOT_AVAILABLE || cont->availability == IMPS_PA_USER_UNKNOWN)
- {
- continue;
- }
- for (j = 0; j < IMPS_MAX_ENTITY_NUMBER; j++)
- if (mmi_imps_util_is_id_same((S8*) room->member[j].id, (S8*) cont->id))
- {
- break;
- }
- if (j == IMPS_MAX_ENTITY_NUMBER) /* user not in chat room */
- {
- mmi_imps_util_ansi_2_ucs2_menu((S8*) cont->id, (S8*) subMenuData[k], MAX_SUBMENU_CHARACTERS);
- mmi_imps_util_generate_name_hint((S8*) cont->nick_name, k, MAX_SUBMENU_CHARACTERS);
- imps_p->invite_info.invite_cand_list[k] = (U8) i;
- subMenuDataPtrs[k] = subMenuData[k];
- k++;
- }
- }
- imps_p->invite_info.invite_count = (U8) k;
- mmi_imps_entry_chat_invite();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_chat_invite
- * DESCRIPTION
- * Entry function of Invite menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_chat_invite(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- U16 icon_list[IMPS_MAX_NO_CONT];
- S32 i;
- S32 count = (S32) imps_p->invite_info.invite_count;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (count == 0)
- {
- mmi_imps_util_disp_empty_popup();
- return;
- }
- EntryNewScreen(SCR_ID_IMPS_INVITE, NULL, mmi_imps_entry_chat_invite, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_INVITE);
- SetParentHandler(0);
- RegisterHighlightHandler(mmi_imps_hilite_invite_item);
- for (i = 0; i < count; i++)
- {
- icon_list[i] = IMG_ID_IMPS_ABOUT_ONLINE;
- }
- ShowCategory53Screen(
- STR_ID_IMPS_INVITE,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- count,
- (U8 **) subMenuDataPtrs,
- (U16*) icon_list,
- (U8 **) hintDataPtrs,
- 0,
- 0,
- guiBuffer);
- SetLeftSoftkeyFunction(mmi_imps_entry_invite_note, KEY_EVENT_UP);
- SetKeyHandler(mmi_imps_entry_invite_note, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_invite_item
- * DESCRIPTION
- * Highlight handler of invite candidate list
- * PARAMETERS
- * index [IN] Index of highlighting item
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_invite_item(S32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- imps_p->invite_info.curr_sel_cont = (U8) index;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_invite_note
- * DESCRIPTION
- * Entry function to input inviting note
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_invite_note(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_INVITE_NOTE, NULL, mmi_imps_entry_invite_note, NULL);
- SetParentHandler(0);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_INVITE_NOTE);
- if (guiBuffer == NULL) /* first time entry, reset input buffer */
- {
- imps_p->path_buff[0] = 0;
- }
- ShowCategory5Screen(
- STR_ID_IMPS_INVITE_NOTE,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OPTIONS,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
- (U8*) imps_p->path_buff, /* reuse path buffer */
- IMPS_MAX_NOTE_LEN,
- guiBuffer);
- SetLeftSoftkeyFunction(mmi_imps_entry_invite_note_opt, KEY_EVENT_UP);
- SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_invite_note_opt
- * DESCRIPTION
- * Display options for inviting note
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_invite_note_opt(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 numItems;
- U16 nStrItemList[2];
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_CHAT_NOTE_OPT, NULL, mmi_imps_entry_invite_note_opt, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_CHAT_NOTE_OPT);
- SetParentHandler(MENU_ID_IMPS_ROOM_INVITE_OPT);
- numItems = GetNumOfChild(MENU_ID_IMPS_ROOM_INVITE_OPT);
- GetSequenceStringIds(MENU_ID_IMPS_ROOM_INVITE_OPT, nStrItemList);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- ShowCategory52Screen(
- STR_GLOBAL_OPTIONS,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- numItems,
- nStrItemList,
- (U16*) gIndexIconsImageList,
- NULL,
- 0,
- 0,
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_hilite_invite_note_opt_done
- * DESCRIPTION
- * Highlight handler of List Member menu.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_hilite_invite_note_opt_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetLeftSoftkeyFunction(mmi_imps_invite_done, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_done
- * DESCRIPTION
- * Finish invitation input and start inviting
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_done(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* check if all sessions are occupied */
- S32 session_id = mmi_imps_invite_insert_session();
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (session_id == 0)
- {
- mmi_imps_invite_disp_failed_msg();
- mmi_imps_util_play_tone(IMPS_ERR_TONE);
- }
- else
- {
- mmi_imps_invite_disp_msg();
- imps_p->room_info.room_list[imps_p->chat_info.curr_room].clear_gui_buff = TRUE;
- #ifndef IMPS_TEST_CODE
- mmi_imps_ps_invite_req(session_id);
- #else /* IMPS_TEST_CODE */
- SetKeyHandler(mmi_imps_test_invite_success, KEY_STAR, KEY_EVENT_DOWN);
- SetKeyHandler(mmi_imps_test_invite_failed, KEY_POUND, KEY_EVENT_DOWN);
- #endif /* IMPS_TEST_CODE */
- }
- GoBackToHistory(SCR_ID_IMPS_CHAT);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_insert_session
- * DESCRIPTION
- * insert Invitation to session list
- * PARAMETERS
- * void
- * RETURNS
- * session index
- *****************************************************************************/
- S32 mmi_imps_invite_insert_session(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < IMPS_MAX_INVITEE_SESSION; i++)
- if (imps_p->invite_info.invite_session[i].session_id == 0)
- {
- break;
- }
- if (i == IMPS_MAX_INVITEE_SESSION)
- {
- return 0;
- }
- else
- {
- mmi_imps_invite_session_struct *session = &imps_p->invite_info.invite_session[i];
- session->session_id = mmi_imps_util_get_seq_no();
- strcpy(
- (S8*) session->cont_id,
- (S8*) imps_p->cont_info.cont_list[imps_p->invite_info. invite_cand_list[imps_p->invite_info.curr_sel_cont]].id);
- strcpy((S8*) session->room_id, (S8*) imps_p->room_info.room_list[imps_p->chat_info.curr_room].room_id);
- return session->session_id;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_disp_msg
- * DESCRIPTION
- * Display invitation message in chat buffer.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_disp_msg(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_cont_buff;
- U16 *tmp_disp_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- mmi_imps_cont_struct *cont =
- &imps_p->cont_info.cont_list[imps_p->invite_info.invite_cand_list[imps_p->invite_info.curr_sel_cont]];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* insert input into buffer */
- pfnUnicodeStrcpy((S8*) tmp_disp_buff, (S8*) GetString(STR_ID_IMPS_INVITING));
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) L" ");
- if (pfnUnicodeStrlen((S8*) cont->nick_name))
- {
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) cont->nick_name);
- }
- else
- {
- tmp_cont_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
- AnsiiToUnicodeString((S8*) tmp_cont_buff, (S8*) cont->id);
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) tmp_cont_buff);
- OslMfree(tmp_cont_buff);
- }
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) L"nn");
- mmi_imps_chat_flush_msg(tmp_disp_buff, imps_p->chat_info.curr_room);
- OslMfree(tmp_disp_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_disp_failed_msg
- * DESCRIPTION
- * Display invitation failed message.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_disp_failed_msg(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_disp_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- mmi_imps_cont_struct *cont =
- &imps_p->cont_info.cont_list[imps_p->invite_info.invite_cand_list[imps_p->invite_info.curr_sel_cont]];
- wgui_color_buffer_writer_struct writer;
- BOOL result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- tmp_disp_buff[0] = 0;
- wgui_color_buffer_create_writer(&writer, (U8*) tmp_disp_buff, IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- wgui_color_buffer_write_char(&writer, GUI_INPUT_COLOR_00);
- wgui_color_buffer_write_string(&writer, (U8*) GetString(STR_ID_IMPS_INVITE_FAIL), MMI_FALSE, &result);
- /* insert input into buffer */
- wgui_color_buffer_write_char(&writer, ' ');
- if (pfnUnicodeStrlen((S8*) cont->nick_name))
- {
- wgui_color_buffer_write_string(&writer, (U8*) cont->nick_name, MMI_FALSE, &result);
- }
- else
- {
- U16 *tmp_id_buff;
- tmp_id_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
- AnsiiToUnicodeString((S8*) tmp_id_buff, (S8*) cont->id);
- wgui_color_buffer_write_string(&writer, (U8*) tmp_id_buff, MMI_FALSE, &result);
- OslMfree(tmp_id_buff);
- }
- wgui_color_buffer_write_char(&writer, GUI_INPUT_MARKER_RESET_ALL);
- wgui_color_buffer_write_string(&writer, (U8*) L"nn", MMI_FALSE, &result);
- mmi_imps_chat_flush_msg(tmp_disp_buff, imps_p->chat_info.curr_room);
- OslMfree(tmp_disp_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_rsp_success_msg
- * DESCRIPTION
- * Display invitation failed message.
- * PARAMETERS
- * session [IN] Invitation session
- * sname [IN] Screen name of the invitee
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_rsp_success_msg(mmi_imps_invite_session_struct *session, S8 *sname)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 *tmp_disp_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- S32 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* insert input into buffer */
- if (pfnUnicodeStrlen(sname))
- {
- pfnUnicodeStrcpy((S8*) tmp_disp_buff, (S8*) sname);
- }
- else /* no screen name */
- {
- AnsiiToUnicodeString((S8*) tmp_disp_buff, (S8*) session->cont_id);
- }
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) L" ");
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) GetString(STR_ID_IMPS_JOINED_ROOM));
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) L"n");
- /* find out the room index */
- for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
- {
- if (mmi_imps_util_is_id_same((S8*) session->room_id, (S8*) imps_p->room_info.room_list[i].room_id))
- {
- break;
- }
- }
- MMI_ASSERT(i < IMPS_MAX_NO_ROOM);
- mmi_imps_chat_flush_msg(tmp_disp_buff, i);
- OslMfree(tmp_disp_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_rsp_failed_msg
- * DESCRIPTION
- * Display invitation failed message.
- * PARAMETERS
- * session [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_rsp_failed_msg(mmi_imps_invite_session_struct *session)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- U16 *tmp_disp_buff = OslMalloc(IMPS_MAX_CHAT_BUFF * ENCODING_LENGTH);
- U16 *tmp_id_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
- S32 cont_index;
- mmi_imps_cont_struct *cont;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- cont_index = mmi_imps_util_find_cont((S8*) session->cont_id);
- if (cont_index == imps_p->cont_info.no_cont) /* nobody found */
- {
- AnsiiToUnicodeString((S8*) tmp_id_buff, (S8*) session->cont_id);
- }
- else
- {
- cont = &imps_p->cont_info.cont_list[cont_index];
- if (pfnUnicodeStrlen((S8*) cont->nick_name))
- {
- pfnUnicodeStrcpy((S8*) tmp_id_buff, (S8*) cont->nick_name);
- }
- else
- {
- AnsiiToUnicodeString((S8*) tmp_id_buff, (S8*) session->cont_id);
- }
- }
- /* insert input into buffer */
- pfnUnicodeStrcpy((S8*) tmp_disp_buff, (S8*) GetString(STR_ID_IMPS_INVITE_FAIL));
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) L" ");
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) tmp_id_buff);
- pfnUnicodeStrcat((S8*) tmp_disp_buff, (S8*) L"nn");
- OslMfree(tmp_id_buff);
- /* find out the room index */
- for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
- {
- if (mmi_imps_util_is_id_same((S8*) session->room_id, (S8*) imps_p->room_info.room_list[i].room_id))
- {
- break;
- }
- }
- MMI_ASSERT(i < IMPS_MAX_NO_ROOM);
- mmi_imps_chat_flush_msg(tmp_disp_buff, i);
- OslMfree(tmp_disp_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_start
- * DESCRIPTION
- * Start invitation process in PS
- * PARAMETERS
- * result [IN] Result of invitation
- * id [IN] Session index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_start(S32 result, S32 id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- mmi_imps_invite_session_struct *session = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < IMPS_MAX_INVITEE_SESSION; i++)
- {
- if (imps_p->invite_info.invite_session[i].session_id == id)
- {
- session = &imps_p->invite_info.invite_session[i];
- break;
- }
- }
- if (session == NULL)
- {
- return;
- }
- /* update display buffer and context */
- if (result != IMPS_OK)
- {
- mmi_imps_room_struct *room = &imps_p->room_info.room_list[mmi_imps_util_find_room((S8*) session->room_id)];
- mmi_imps_invite_rsp_failed_msg(session);
- mmi_imps_tab_update_event(room, NULL);
- mmi_imps_util_play_tone(IMPS_ERR_TONE);
- /* clear session */
- session->session_id = 0;
- session->cont_id[0] = 0;
- session->room_id[0] = 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_finish
- * DESCRIPTION
- * Finish invitation in PS. This function is the response handler from PS
- * PARAMETERS
- * accept [IN] If the user accept invitation or not
- * session_id [IN] Id of the invitation session
- * sender [IN] User who accepted the invitation
- * note [IN] Response note of the invitee
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_finish(BOOL accept, S32 session_id, imps_entity_struct *sender, U16 *note)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- mmi_imps_invite_session_struct *session = NULL;
- mmi_imps_room_struct *room = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* find out if a session corresponding to it */
- for (i = 0; i < IMPS_MAX_INVITEE_SESSION; i++)
- {
- if (imps_p->invite_info.invite_session[i].session_id == session_id)
- {
- session = &imps_p->invite_info.invite_session[i];
- break;
- }
- }
- if (session == NULL)
- {
- return;
- }
- /* find out the chat room it belongs to */
- for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
- {
- if (mmi_imps_util_is_id_same((S8*) session->room_id, (S8*) imps_p->room_info.room_list[i].room_id))
- {
- room = &imps_p->room_info.room_list[i];
- break;
- }
- }
- /* session exists without chat room -- clear the session */
- if (room == NULL)
- {
- session->session_id = 0;
- session->cont_id[0] = 0;
- session->room_id[0] = 0;
- return;
- }
- if (accept == FALSE)
- {
- mmi_imps_invite_rsp_failed_msg(session);
- mmi_imps_util_play_tone(IMPS_ERR_TONE);
- }
- else
- {
- S8 *tmp_disp_buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
- S32 cont_index = mmi_imps_util_find_cont((S8*) session->cont_id);
- S32 sname_len = pfnUnicodeStrlen((S8*) sender->sname);
- mmi_imps_entity_struct *member = NULL;
- /* find an empty slot of member list to fill */
- for (i = 0; i < IMPS_MAX_ENTITY_NUMBER; i++)
- {
- if (strlen((S8*) room->member[i].id) == 0)
- {
- member = &room->member[i];
- break;
- }
- }
- if (i < IMPS_MAX_ENTITY_NUMBER)
- {
- room->no_member++;
- strcpy((S8*) member->id, (S8*) session->cont_id);
- if (sname_len) /* regard as IMPS_ENTITY_TYPE_SCREEN_NAME */
- {
- pfnUnicodeStrcpy((S8*) member->sname, (S8*) sender->sname);
- mmi_imps_invite_rsp_success_msg(session, (S8*) member->sname);
- }
- else /* IMPS_ENTITY_TYPE_USER */
- {
- if ((S8) cont_index < imps_p->cont_info.no_cont)
- {
- if (pfnUnicodeStrlen((S8*) imps_p->cont_info.cont_list[cont_index].nick_name))
- {
- pfnUnicodeStrcat(
- (S8*) member->sname,
- (S8*) imps_p->cont_info.cont_list[cont_index].nick_name);
- }
- else
- {
- pfnUnicodeStrcat((S8*) member->sname, (S8*) GetString(STR_ID_IMPS_ANONYMOUS));
- }
- mmi_imps_invite_rsp_success_msg(session, (S8*) member->sname);
- }
- else
- {
- mmi_imps_invite_rsp_success_msg(session, (S8*) GetString(STR_ID_IMPS_ANONYMOUS));
- }
- }
- }
- else
- {
- if (sname_len)
- {
- mmi_imps_invite_rsp_success_msg(session, (S8*) sender->sname);
- }
- else
- {
- AnsiiToUnicodeString(tmp_disp_buff, (S8*) sender->id);
- mmi_imps_invite_rsp_success_msg(session, (S8*) tmp_disp_buff);
- }
- }
- mmi_imps_util_play_tone(IMPS_MSG_TONE);
- OslMfree(tmp_disp_buff);
- }
- /* update UI display */
- mmi_imps_tab_update_event(room, NULL);
- /* reset session */
- session->session_id = 0;
- session->cont_id[0] = 0;
- session->room_id[0] = 0;
- }
- #define INVITE_IND_IMPS
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_check_pending_invite
- * DESCRIPTION
- * Check if there is any pending invitation
- * PARAMETERS
- * void
- * msg(?) [IN] Message of invitation.
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_check_pending_invite(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* pending invitation exists */
- if (imps_p->invite_info.invite_pending_list[imps_p->invite_info.curr_pend_invite].node != NULL)
- {
- /* entry invitation screen */
- mmi_imps_entry_invite_ind();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_invite_ind
- * DESCRIPTION
- * Entry invite indication screen
- * PARAMETERS
- * void
- * msg(?) [IN] Message of invitation.
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_invite_ind(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_INVITATION_IND, NULL, mmi_imps_entry_invite_ind, NULL);
- mmi_imps_util_play_tone(IMPS_MSG_TONE);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_INVITATION_IND);
- SetParentHandler(0);
- mmi_imps_invite_ind_gen_note();
- /* configure icons */
- wgui_config_general_multiline_icon_handler(MMI_FALSE, IMPS_NUM_INVITE, g_imps_invite_icon_list);
- ShowCategory78Screen(
- STR_ID_IMPS_INVITATION,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- STR_ID_IMPS_JOIN,
- IMG_GLOBAL_OK,
- STR_GLOBAL_QUIT,
- IMG_GLOBAL_BACK,
- wgui_general_multiline_icon_handler,
- (U8*) imps_p->invite_info.invite_note,
- pfnUnicodeStrlen(imps_p->invite_info.invite_note),
- guiBuffer);
- /* re-use join screen */
- SetLeftSoftkeyFunction(mmi_imps_pre_entry_join, KEY_EVENT_UP);
- SetRightSoftkeyFunction(mmi_imps_ps_invite_reject, KEY_EVENT_UP);
- SetDelScrnIDCallbackHandler(SCR_ID_IMPS_INVITATION_IND, (HistoryDelCBPtr) mmi_imps_invite_ind_scr_del_callback);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_invite_reject
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_invite_reject(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_display_progressing();
- mmi_imps_ps_invite_reply_req(FALSE);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_ind_scr_del_callback
- * DESCRIPTION
- * Function to free memory when invitation screen deleted.
- * PARAMETERS
- * param [?]
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_imps_invite_ind_scr_del_callback(void *param)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_invite_ind_free_mem();
- mmi_imps_invite_ind_release_node();
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_reminder_del_callback
- * DESCRIPTION
- * Function to free memory when invitation reminder screen deleted.
- * PARAMETERS
- * param [?]
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_imps_invite_reminder_del_callback(void *param)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_invite_ind_free_mem();
- imps_p->invite_info.reminder_flag = FALSE;
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_ind_free_mem
- * DESCRIPTION
- * Free memory of invitation screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_ind_free_mem(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->invite_info.invite_note)
- {
- OslMfree(imps_p->invite_info.invite_note);
- imps_p->invite_info.invite_note = NULL;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_ind_free_n_back
- * DESCRIPTION
- * Free memory of invitation screen and go back to previous screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_ind_free_n_back(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* release note buffer */
- mmi_imps_invite_ind_free_mem();
- /* release the holding local parameter */
- mmi_imps_invite_ind_release_node();
- GoBackHistory();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_ind_release_node
- * DESCRIPTION
- * Release the holding local parameter
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_ind_release_node(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i = (S32) imps_p->invite_info.curr_pend_invite;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->invite_info.invite_pending_list[i].node)
- {
- free_local_para((local_para_struct*) imps_p->invite_info.invite_pending_list[i].node);
- imps_p->invite_info.invite_pending_list[i].node = NULL;
- }
- /* move index to the next node */
- i++;
- if (i == IMPS_MAX_PEND_INVITATION)
- {
- imps_p->invite_info.curr_pend_invite = 0;
- }
- else
- {
- imps_p->invite_info.curr_pend_invite = (U8) i;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_ind_gen_note
- * DESCRIPTION
- * Generate invitation note of indication screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_ind_gen_note(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *note;
- S8 *tmp_buff = OslMalloc(IMPS_MAX_NOTE_LEN * ENCODING_LENGTH); /* temporary buffer for icon */
- mmi_imps_invite_ind_struct *invite_ind =
- imps_p->invite_info.invite_pending_list[imps_p->invite_info.curr_pend_invite].node;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->invite_info.invite_note == NULL)
- {
- imps_p->invite_info.invite_note = OslMalloc(IMPS_MAX_INVITATION_NOTE);
- }
- note = imps_p->invite_info.invite_note;
- /* Owner */
- AnsiiToUnicodeString((S8*) tmp_buff, g_imps_invite_icon_list[0].string);
- pfnUnicodeStrcpy(note, (S8*) tmp_buff);
- pfnUnicodeStrcat(note, (S8*) GetString(STR_ID_IMPS_OWNER));
- pfnUnicodeStrcat(note, (S8*) L":n");
- if (invite_ind->sender.entity_type == IMPS_ENTITY_TYPE_SCREEN_NAME)
- {
- pfnUnicodeStrcat(note, (S8*) invite_ind->sender.sname);
- }
- else
- {
- AnsiiToUnicodeString((S8*) tmp_buff, (S8*) invite_ind->sender.id);
- pfnUnicodeStrcat(note, (S8*) tmp_buff);
- }
- pfnUnicodeStrcat(note, (S8*) L"nn");
- /* Group ID */
- AnsiiToUnicodeString((S8*) tmp_buff, g_imps_invite_icon_list[1].string);
- pfnUnicodeStrcat(note, (S8*) tmp_buff);
- pfnUnicodeStrcat(note, (S8*) GetString(STR_ID_IMPS_CHAT_ROOMS));
- pfnUnicodeStrcat(note, (S8*) L":n");
- AnsiiToUnicodeString(tmp_buff, (S8*) invite_ind->group_id);
- pfnUnicodeStrcat(note, tmp_buff);
- pfnUnicodeStrcat(note, (S8*) L"nn");
- /* Note */
- pfnUnicodeStrcat(note, (S8*) GetString(STR_ID_IMPS_WELCOME_TEXT));
- pfnUnicodeStrcat(note, (S8*) L":n");
- pfnUnicodeStrcat(note, (S8*) invite_ind->invite_note);
- OslMfree(tmp_buff);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_invite_accept
- * DESCRIPTION
- * Accept invitation, ask user to input screen name first
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_invite_accept(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* send request to PS */
- mmi_imps_ps_invite_reply_req(TRUE);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_invite_reminder
- * DESCRIPTION
- * Entry reminder invitation screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_invite_reminder(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_IMPS_INVITATION_IND, NULL, mmi_imps_entry_invite_reminder, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_ID_IMPS_INVITATION_IND);
- SetParentHandler(0);
- /* generate note */
- if (imps_p->invite_info.invite_note == NULL)
- {
- imps_p->invite_info.invite_note = OslMalloc(IMPS_MAX_INVITATION_NOTE);
- }
- pfnUnicodeStrcpy((S8*) imps_p->invite_info.invite_note, (S8*) GetString(STR_ID_IMPS_NEW_INVITE_REMINDER));
- /* configure icons */
- wgui_config_general_multiline_icon_handler(MMI_FALSE, IMPS_NUM_INVITE, g_imps_invite_icon_list);
- ShowCategory78Screen(
- STR_ID_IMPS_NEW_INVITATION,
- GetRootTitleIcon(MENU_ID_IMPS_MAIN),
- 0,
- 0,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- wgui_general_multiline_icon_handler,
- (U8*) imps_p->invite_info.invite_note,
- pfnUnicodeStrlen(imps_p->invite_info.invite_note),
- guiBuffer);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetDelScrnIDCallbackHandler(SCR_ID_IMPS_INVITATION_IND, (HistoryDelCBPtr) mmi_imps_invite_reminder_del_callback);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_entry_invite_key_lokced
- * DESCRIPTION
- * Entry reminder invitation screen when keypad locked
- * PARAMETERS
- * lsk_img_id [IN]
- * lsk_str_id [IN]
- * rsk_img_id [IN]
- * rsk_str_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_entry_invite_key_lokced(U16 lsk_img_id, U16 lsk_str_id, U16 rsk_img_id, U16 rsk_str_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* generate note */
- if (imps_p->invite_info.invite_note == NULL)
- {
- imps_p->invite_info.invite_note = OslMalloc(IMPS_MAX_INVITATION_NOTE);
- }
- pfnUnicodeStrcpy((S8*) imps_p->invite_info.invite_note, (S8*) GetString(STR_ID_IMPS_NEW_INVITE_REMINDER));
- ShowCategory154Screen(
- 0,
- 0,
- lsk_str_id,
- lsk_img_id,
- rsk_str_id,
- rsk_img_id,
- (U8*) imps_p->invite_info.invite_note,
- NULL,
- IMG_GLOBAL_INFO,
- NULL);
- OslMfree(imps_p->invite_info.invite_note);
- imps_p->invite_info.invite_note = NULL;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_free_invite_list
- * DESCRIPTION
- * Free all invite pending list when logout
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_free_invite_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- mmi_imps_invite_list_struct *invite;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < IMPS_MAX_PEND_INVITATION; i++)
- {
- invite = &imps_p->invite_info.invite_pending_list[i];
- if (invite->node)
- {
- free_local_para((local_para_struct*) invite->node);
- invite->node = NULL;
- }
- }
- }
- #define GROUP_IMPS