mmi_imps_ps.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:151k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * mmi_imps_ps.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file implements all protocol related function/interface for IMPS application.
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _MMI_IMPS_PS_C
- #define _MMI_IMPS_PS_C
- #include "MMI_features.h"
- #ifdef __MMI_IMPS__
- /* Include: MMI header file */
- #include "stdC.h"
- #include "L4Dr1.h"
- #include "PixtelDataTypes.h"
- #include "GlobalDefs.h"
- #include "CommonScreens.h"
- #include "DebugInitDef.h"
- #include "GlobalConstants.h"
- #include "FrameworkStruct.h"
- #include "EventsGprot.h"
- #include "HistoryGprot.h"
- #include "wgui_categories.h"
- #include "wgui_categories_inputs.h"
- #include "wgui_inline_edit.h"
- #include "wgui_tab_bars.h"
- #include "wgui_categories_IMPS.h"
- #include "mmi_imps_enum.h"
- #include "mmi_imps_prot.h"
- #include "Mmi_imps_gprot.h"
- #include "AlarmFrameworkProt.h"
- #include "FileManagerGProt.h"
- #include "DateTimeGprot.h"
- /* ... Add More MMI header */
- /* Include: PS header file */
- /* ... Add More PS header */
- #ifdef MMI_ON_HARDWARE_P
- typedef struct
- {
- U8 ref_count;
- U16 msg_len;
- } imps_local_para_hdr;
- /*****************************************************************************
- * Define
- *****************************************************************************/
- #define IMPS_MEMSET(addr, value, structure) memset(((U8*)addr)+sizeof(imps_local_para_hdr), value, (S32)(sizeof(structure) - sizeof(imps_local_para_hdr)))
- /*****************************************************************************
- * Typedef
- *****************************************************************************/
- /*****************************************************************************
- * Local Variable
- *****************************************************************************/
- /*****************************************************************************
- * Local Function
- *****************************************************************************/
- /*****************************************************************************
- * Global Variable
- *****************************************************************************/
- /*****************************************************************************
- * Global Function
- *****************************************************************************/
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_init_ps_before_idle
- * DESCRIPTION
- * Initialize protocol event handlers when MMI power on.
- * This is to prevent ready indication comes too early
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_init_ps_before_idle(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_imps_ps_ready_ind, MSG_ID_MMI_IMPS_READY_IND);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_init_ps_hdlr
- * DESCRIPTION
- * Initialize all protocol event handlers.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_init_ps_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetProtocolEventHandler(mmi_imps_ps_login_rsp, MSG_ID_MMI_IMPS_LOGIN_RSP);
- SetProtocolEventHandler(mmi_imps_ps_abort_login_rsp, MSG_ID_MMI_IMPS_ABORT_LOGIN_RSP);
- SetProtocolEventHandler(mmi_imps_ps_logout_rsp, MSG_ID_MMI_IMPS_LOGOUT_RSP);
- SetProtocolEventHandler(mmi_imps_ps_get_contact_list_rsp, MSG_ID_MMI_IMPS_GET_CONTACT_LIST_RSP);
- SetProtocolEventHandler(mmi_imps_ps_view_contact_list_rsp, MSG_ID_MMI_IMPS_VIEW_CONTACT_LIST_RSP);
- SetProtocolEventHandler(mmi_imps_abort_get_pa_rsp, MSG_ID_MMI_IMPS_ABORT_GET_PA_RSP);
- SetProtocolEventHandler(mmi_imps_ps_pa_notify_ind, MSG_ID_MMI_IMPS_PA_NOTIFY_IND);
- SetProtocolEventHandler(mmi_imps_ps_newmsg_ind, MSG_ID_MMI_IMPS_NEWMESSAGE_IND);
- SetProtocolEventHandler(mmi_imps_ps_update_pa_rsp, MSG_ID_MMI_IMPS_UPDATE_PA_RSP);
- SetProtocolEventHandler(mmi_imps_ps_get_watch_list_rsp, MSG_ID_MMI_IMPS_GET_WATCHER_LIST_RSP);
- SetProtocolEventHandler(mmi_imps_ps_abort_get_watch_list_rsp, MSG_ID_MMI_IMPS_ABORT_GET_WATCHER_LIST_RSP);
- SetProtocolEventHandler(mmi_imps_ps_create_group_rsp, MSG_ID_MMI_IMPS_CREATE_GROUP_RSP);
- SetProtocolEventHandler(mmi_imps_ps_block_entity_rsp, MSG_ID_MMI_IMPS_BLOCK_ENTITY_RSP);
- SetProtocolEventHandler(mmi_imps_ps_join_group_rsp, MSG_ID_MMI_IMPS_JOIN_GROUP_RSP);
- SetProtocolEventHandler(mmi_imps_ps_abort_search_rsp, MSG_ID_MMI_IMPS_ABORT_SEARCH_RSP);
- SetProtocolEventHandler(mmi_imps_ps_send_msg_rsp, MSG_ID_MMI_IMPS_SEND_MESSAGE_RSP);
- SetProtocolEventHandler(mmi_imps_ps_del_group_rsp, MSG_ID_MMI_IMPS_DELETE_GROUP_RSP);
- SetProtocolEventHandler(mmi_imps_ps_del_contact_list_rsp, MSG_ID_MMI_IMPS_DEL_CONTACT_LIST_RSP);
- SetProtocolEventHandler(mmi_imps_ps_leave_group_rsp, MSG_ID_MMI_IMPS_LEAVE_GROUP_RSP);
- SetProtocolEventHandler(mmi_imps_ps_leave_group_ind, MSG_ID_MMI_IMPS_LEAVE_GROUP_IND);
- SetProtocolEventHandler(mmi_imps_ps_invite_rsp, MSG_ID_MMI_IMPS_INVITE_RSP);
- SetProtocolEventHandler(mmi_imps_ps_invite_response_ind, MSG_ID_MMI_IMPS_INVITE_RESPONSE_IND);
- SetProtocolEventHandler(mmi_imps_ps_server_disconn_ind, MSG_ID_MMI_IMPS_DISCONNECT_IND);
- SetProtocolEventHandler(mmi_imps_ps_group_change_ind, MSG_ID_MMI_IMPS_GROUP_CHANGE_NOTIFY_IND);
- SetProtocolEventHandler(mmi_imps_ps_invite_ind, MSG_ID_MMI_IMPS_INVITE_IND);
- SetProtocolEventHandler(mmi_imps_ps_get_block_list_rsp, MSG_ID_MMI_IMPS_GET_BLOCK_LIST_RSP);
- SetProtocolEventHandler(mmi_imps_ps_add_contact_list_rsp, MSG_ID_MMI_IMPS_ADD_CONTACT_LIST_RSP);
- #ifndef __MTK_TARGET__
- imps_p->gen_info.ps_ready_state |= IMPS_LOGIN_PS_READY;
- imps_p->gen_info.ps_ready_state |= IMPS_LOGIN_RAC_READY;
- #endif /* __MTK_TARGET__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_send_msg
- * DESCRIPTION
- * Wrapper function to send message to IMPS module
- * PARAMETERS
- * msg_id [IN]
- * local_param_ptr [?]
- * peer_buf_ptr [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_send_msg(U16 msg_id, void *local_param_ptr, void *peer_buf_ptr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYQUEUE Message;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* store the index of request */
- imps_p->gen_info.curr_action = msg_id;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_IMPS;
- Message.oslMsgId = msg_id;
- Message.oslDataPtr = (oslParaType*) local_param_ptr;
- Message.oslPeerBuffPtr = peer_buf_ptr;
- OslMsgSendExtQueue(&Message);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_login_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_LOGIN_REQ to PS.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_login_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* send login request to PS */
- mmi_imps_login_req_struct *req;
- mmi_imps_prof_struct *act_prof = &imps_p->act_prof;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGIN_REQ || imps_p->gen_info.is_login)
- {
- return;
- }
- req = (mmi_imps_login_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_login_req_struct));
- IMPS_MEMSET(req, 0, mmi_imps_login_req_struct);
- /* connection type, shall be set according to the enum value of PS */
- if (act_prof->conn_type == 0)
- {
- req->conn_type = IMPS_CONN_TYPE_HTTP;
- }
- else
- {
- req->conn_type = IMPS_CONN_TYPE_WSP_CO;
- }
- /* data account */
- req->net_id = act_prof->dt_acct;
- /* user proxy */
- req->use_proxy = act_prof->use_proxy;
- /* proxy info */
- if (act_prof->use_proxy)
- {
- req->prx_port = act_prof->proxy_port;
- req->prx_ip[0] = act_prof->proxy_ip[0];
- req->prx_ip[1] = act_prof->proxy_ip[1];
- req->prx_ip[2] = act_prof->proxy_ip[2];
- req->prx_ip[3] = act_prof->proxy_ip[3];
- strcpy((S8*) req->prx_usrn, (S8*) act_prof->proxy_username);
- strcpy((S8*) req->prx_pwd, (S8*) act_prof->proxy_passwd);
- }
- /* user name */
- strcpy((S8*) req->imps_usrn, (S8*) act_prof->username);
- /* password */
- strcpy((S8*) req->imps_pwd, (S8*) act_prof->passwd);
- /* server */
- strcpy((S8*) req->imps_server, (S8*) act_prof->server);
- /* currently no usage */
- req->imps_service_set = 0xff;
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_LOGIN_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_login_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_LOGIN_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_login_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_login_rsp_struct *rsp = (mmi_imps_login_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_ABORT_LOGIN_REQ)
- {
- return;
- }
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (rsp->result == IMPS_OK)
- {
- imps_p->gen_info.is_login = TRUE;
- /* reload contact list from cache */
- mmi_imps_util_init_list();
- /* update status icon */
- mmi_imps_util_update_login_icon();
- /* entry contact list screen */
- imps_p->gen_info.no_tab = 1;
- if (imps_p->gen_info.is_reentry)
- {
- mmi_imps_re_entry_app();
- }
- else
- {
- if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
- {
- mmi_imps_pre_entry_cont();
- DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
- }
- else
- {
- /* in other screen, replace progress screen by the result screen */
- HistoryReplace(SCR_ID_IMPS_PROGRESS, SCR_ID_IMPS_CONT, mmi_imps_pre_entry_cont);
- }
- DeleteScreenIfPresent(SCR_ID_IMPS_MAIN);
- }
- /* send request to get latest contact list */
- mmi_imps_ps_get_contact_list_req();
- }
- else
- {
- /* for non auto-login case */
- if (IsScreenPresent(SCR_ID_IMPS_PROGRESS) || GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
- {
- mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(rsp->result));
- /* if it's re_entry from other application */
- if (imps_p->gen_info.is_reentry)
- {
- HistoryReplace(SCR_ID_IMPS_PROGRESS, SCR_ID_IMPS_MAIN, mmi_imps_entry_main);
- }
- else
- {
- DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
- }
- }
- imps_p->gen_info.is_reentry = FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_abort_login_req
- * DESCRIPTION
- * Abort login process
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_abort_login_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_ABORT_LOGIN_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_abort_login_rsp
- * DESCRIPTION
- * Abort login process
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_abort_login_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (imps_p->gen_info.is_reentry)
- {
- mmi_imps_re_entry_app();
- }
- else
- {
- mmi_imps_login_abort_finish();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_logout_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_LOGOUT_REQ to PS.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_logout_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* send login request to PS */
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_LOGOUT_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_logout_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_LOGOUT_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_logout_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- /* because logout will be always success, no checking procedure required */
- imps_p->gen_info.is_login = FALSE;
- if (imps_p->gen_info.is_reentry)
- {
- mmi_imps_re_entry_app();
- }
- else
- {
- mmi_imps_logout_complete();
- }
- mmi_imps_util_update_login_icon();
- }
- #define CONT_PS_IMPS
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_contact_list_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_GET_CONTACT_REQ to PS.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_contact_list_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_GET_CONTACT_LIST_REQ, NULL, NULL);
- /* restore current action -- won't store state for background update */
- imps_p->gen_info.curr_action = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_contact_list_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_GET_CONTACT_LIST_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_contact_list_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_get_contact_list_rsp_struct *rsp = (mmi_imps_get_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
- {
- return;
- }
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (rsp->result == IMPS_OK && (rsp->contact_list_id_list.entity_count > 0 || rsp->default_contact_list_id_p))
- {
- S32 i = 0, j, k, l = 0;
- S32 ps_count, local_count;
- S32 new_ids[IMPS_MAX_NO_GROUP];
- memset(&new_ids, 0, sizeof(new_ids));
- /* default contact list */
- ps_count = (S32) rsp->contact_list_id_list.entity_count;
- if (ps_count > IMPS_MAX_NO_GROUP)
- {
- ps_count = IMPS_MAX_NO_GROUP;
- }
- local_count = (S32) imps_p->group_info.no_group;
- if (rsp->default_contact_list_id_p)
- {
- /* check if the default contact list is on server */
- for (i = 0; i < local_count; i++)
- {
- if (mmi_imps_util_is_id_same
- ((S8*) rsp->default_contact_list_id, (S8*) imps_p->group_info.group_list[i].group_id))
- {
- imps_p->group_info.group_list[i].is_sync = TRUE;
- break;
- }
- }
- /* default contact list presently is not in global context */
- if (i == local_count && l < IMPS_MAX_NO_GROUP)
- {
- /* store it in the new_id list, make it equal to ps_count to distinguish with others */
- new_ids[l++] = ps_count;
- }
- }
- /* sync group id with contact list Update contact list info if it's not sync */
- /* from PS to local part, find out new group ids */
- for (j = 0; j < ps_count; j++)
- {
- for (k = 0; k < local_count; k++)
- {
- /* mark is_retrieve to TRUE to mean the group is retrieved and is still stored on server */
- if (imps_p->group_info.group_list[k].is_sync == FALSE)
- {
- if (mmi_imps_util_is_id_same
- ((S8*) imps_p->group_info.group_list[k].group_id,
- (S8*) rsp->contact_list_id_list.entity[j].id))
- {
- imps_p->group_info.group_list[k].is_sync = TRUE;
- break;
- }
- }
- }
- /* only allow IMPS_MAX_NO_GROUP of groups */
- if (l < IMPS_MAX_NO_GROUP && k == local_count)
- {
- new_ids[l++] = j;
- }
- }
- /* removed dangling ids */
- for (k = (local_count - 1); k >= 0; k--)
- {
- if (imps_p->group_info.group_list[k].is_sync == FALSE)
- {
- if (k < (local_count - 1))
- {
- memcpy(
- &imps_p->group_info.group_list[k],
- &imps_p->group_info.group_list[k + 1],
- (local_count - k - 1) * sizeof(mmi_imps_group_struct));
- }
- local_count--;
- memset(&imps_p->group_info.group_list[local_count], 0, sizeof(mmi_imps_group_struct));
- }
- }
- /* fill the new id list into group list if there are still some empty slots */
- for (k = 0; (k < l && local_count < IMPS_MAX_NO_GROUP); k++, local_count++)
- {
- if (new_ids[k] == ps_count) /* it's the default contact list */
- {
- strcpy((S8*) imps_p->group_info.group_list[local_count].group_id, (S8*) rsp->default_contact_list_id);
- }
- else
- {
- strcpy(
- (S8*) imps_p->group_info.group_list[local_count].group_id,
- (S8*) rsp->contact_list_id_list.entity[new_ids[k]].id);
- }
- imps_p->group_info.group_list[local_count].is_sync = TRUE;
- }
- imps_p->group_info.no_group = (U8) local_count;
- /* send request to get detail information of each contact list */
- if (local_count)
- {
- imps_p->gen_info.curr_group = 0;
- mmi_imps_ps_view_contact_list_req(0);
- }
- else
- {
- mmi_imps_sync_cont_list();
- imps_p->gen_info.auto_update_done = TRUE;
- }
- }
- else
- {
- /* get contact list data using local-saved data if group is not empty */
- if (imps_p->group_info.no_group)
- {
- mmi_imps_ps_view_contact_list_req(0);
- }
- else
- {
- mmi_imps_ps_get_block_list_req();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_view_next_contact_list
- * DESCRIPTION
- * Send request to view the detail information of next contact list
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_view_next_contact_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- imps_p->gen_info.curr_group++;
- if (imps_p->gen_info.curr_group != imps_p->group_info.no_group)
- {
- /* still some group not retrieved */
- mmi_imps_ps_view_contact_list_req(imps_p->gen_info.curr_group);
- }
- else
- {
- mmi_imps_ps_get_about_me_req();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_view_contact_list_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_VIEW_CONTACT_REQ to PS.
- * PARAMETERS
- * index [IN] Index of group to be retrieved.
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_view_contact_list_req(U8 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_view_contact_list_req_struct *req =
- (mmi_imps_view_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_view_contact_list_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_view_contact_list_req_struct);
- strcpy((S8*) req->contact_list_id, (S8*) imps_p->group_info.group_list[index].group_id);
- /* send view contact list request to PS */
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_VIEW_CONTACT_LIST_REQ, (void*)req, NULL);
- /* restore current action -- won't store state for background update */
- imps_p->gen_info.curr_action = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_view_contact_list_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_VIEW_CONTACT_LIST_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_view_contact_list_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_view_contact_list_rsp_struct *rsp = (mmi_imps_view_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
- {
- return;
- }
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (rsp->result == IMPS_OK)
- {
- S32 i, j, count;
- S32 curr_no_cont = (S32) imps_p->cont_info.no_cont;
- mmi_imps_cont_struct *cont;
- count = (S32) rsp->user_nick_list.entity_count;
- /* update info of this contact list */
- if (rsp->display_name_p)
- {
- pfnUnicodeStrcpy(
- (S8*) imps_p->group_info.group_list[imps_p->gen_info.curr_group].group_name,
- (S8*) rsp->display_name);
- }
- /* update contacts in file buffer */
- for (i = 0; i < count; i++)
- {
- /* still compare "Myself" to prevent abnormal case */
- for (j = 0; j < curr_no_cont; j++)
- {
- cont = &imps_p->cont_info.cont_list[j];
- if (mmi_imps_util_is_id_same((S8*) rsp->user_nick_list.entity[i].id, (S8*) cont->id))
- {
- /* if j == 0, duplicated */
- if (j == 0)
- {
- break;
- }
- /* check if the user already updated */
- if ((cont->comm_state & IMPS_CONT_PA_READY) == 0)
- {
- cont->comm_state |= IMPS_CONT_PA_READY;
- strcpy(
- (S8*) cont->group_id,
- (S8*) imps_p->group_info.group_list[imps_p->gen_info.curr_group].group_id);
- /* use server-provided name if the user did not modify the nick for the contact */
- if (pfnUnicodeStrlen((S8*) rsp->user_nick_list.entity[i].sname))
- {
- pfnUnicodeStrcpy((S8*) cont->nick_name, (S8*) rsp->user_nick_list.entity[i].sname);
- }
- cont->availability = IMPS_PA_USER_UNKNOWN;
- break;
- }
- else
- {
- /* to prevent single contact belongs to multiple contact lists cases */
- break;
- }
- }
- }
- /* not in contact list -- new id */
- if ((j == curr_no_cont) && (0 < curr_no_cont < IMPS_MAX_NO_CONT))
- {
- /* to prevent abnormal case -- empty id */
- if (strlen((S8*) rsp->user_nick_list.entity[i].id))
- {
- cont = &imps_p->cont_info.cont_list[j];
- strcpy((S8*) cont->id, (S8*) rsp->user_nick_list.entity[i].id);
- pfnUnicodeStrcpy((S8*) cont->nick_name, (S8*) rsp->user_nick_list.entity[i].sname);
- cont->comm_state |= IMPS_CONT_PA_READY;
- strcpy(
- (S8*) cont->group_id,
- (S8*) imps_p->group_info.group_list[imps_p->gen_info.curr_group].group_id);
- cont->availability = IMPS_PA_USER_UNKNOWN;
- curr_no_cont++;
- imps_p->cont_info.no_cont++;
- }
- }
- }
- /* send request to retrieve PA of each friend */
- if (imps_p->act_prof.auto_update && count)
- {
- mmi_imps_ps_get_pa_req((void*)rsp);
- }
- else
- {
- mmi_imps_ps_view_next_contact_list();
- }
- }
- else
- {
- mmi_imps_ps_view_next_contact_list();
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_edit_contact_list_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_REQ to PS.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_edit_contact_list_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_req_struct *req =
- (mmi_imps_edit_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_edit_contact_list_req_struct));
- mmi_imps_group_inline_struct *grp_edit = imps_p->group_info.inline_edit_group;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_edit_contact_list_req_struct);
- strcpy((S8*) req->contact_list_id, (S8*) imps_p->group_info.group_list[imps_p->group_info.curr_item].group_id);
- req->display_name_p = TRUE;
- pfnUnicodeStrcpy((S8*) req->display_name, (S8*) grp_edit->group_name);
- if (grp_edit->open_status == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= (IMPS_PA_USER_AVAILABILITY | IMPS_PA_ONLINE_STATUS);
- }
- if (grp_edit->open_text == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= IMPS_PA_STATUS_TEXT;
- }
- if (grp_edit->open_pic == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= IMPS_PA_STATUS_CONTENT;
- }
- if (grp_edit->open_mood == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= IMPS_PA_STATUS_MOOD;
- }
- if (req->authorize_pa)
- {
- req->authorize_pa_p = TRUE;
- }
- req->subscribe_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
- req->subscribe_user_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
- req->subscribe_pa_user_p = TRUE;
- req->subscribe_pa_p = TRUE;
- req->return_content = TRUE;
- SetProtocolEventHandler(mmi_imps_ps_edit_contact_list_rsp, MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_edit_contact_list_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_edit_contact_list_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_rsp_struct *rsp = (mmi_imps_edit_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- mmi_imps_group_edit_done(rsp->result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_add_contact_list_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_ADD_CONTACT_LIST_REQ to PS.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_add_contact_list_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_add_contact_list_req_struct *req =
- (mmi_imps_add_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_add_contact_list_req_struct));
- mmi_imps_group_inline_struct *grp_edit = imps_p->group_info.inline_edit_group;
- S8 *buff = OslMalloc(IMPS_MAX_ID_LEN);
- S8 *buff2 = OslMalloc(IMPS_MAX_ID_LEN);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_add_contact_list_req_struct);
- /* generate group id */
- UnicodeToAnsii((S8*) buff2, (S8*) grp_edit->group_name);
- sprintf((S8*) buff, "%s/%s", imps_p->act_prof.username, buff2);
- strcpy((S8*) req->contact_list_id, (S8*) buff);
- OslMfree(buff);
- OslMfree(buff2);
- req->display_name_p = TRUE;
- pfnUnicodeStrcpy((S8*) req->display_name, (S8*) grp_edit->group_name);
- if (grp_edit->open_status == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= (IMPS_PA_USER_AVAILABILITY | IMPS_PA_ONLINE_STATUS);
- }
- if (grp_edit->open_text == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= IMPS_PA_STATUS_TEXT;
- }
- if (grp_edit->open_pic == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= IMPS_PA_STATUS_CONTENT;
- }
- if (grp_edit->open_mood == IMPS_STATUS_OPEN)
- {
- req->authorize_pa |= IMPS_PA_STATUS_MOOD;
- }
- req->subscribe_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
- if (req->authorize_pa)
- {
- /* authorize_pa_p = TRUE only when authorize_pa is not none */
- req->authorize_pa_p = TRUE;
- }
- req->subscribe_pa_p = TRUE;
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_ADD_CONTACT_LIST_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_add_contact_list_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_ADD_CONTACT_LIST_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_add_contact_list_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_add_contact_list_rsp_struct *rsp = (mmi_imps_add_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- mmi_imps_group_edit_done(rsp->result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_del_cont_req
- * DESCRIPTION
- * Send request to remove one contact from contact list.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_del_cont_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_req_struct *req =
- (mmi_imps_edit_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_edit_contact_list_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_edit_contact_list_req_struct);
- strcpy((S8*) req->contact_list_id, (S8*) imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont].group_id);
- req->user_nick_list.entity_count = 1;
- strcpy((S8*) req->user_nick_list.entity[0].id, (S8*) imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont].id);
- req->user_nick_list.entity[0].entity_type = IMPS_ENTITY_TYPE_USER;
- SetProtocolEventHandler(mmi_imps_ps_del_cont_rsp, MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_del_cont_rsp
- * DESCRIPTION
- * Response handler for deleting one contact
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_del_cont_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_rsp_struct *rsp = (mmi_imps_edit_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- mmi_imps_del_cont_finished((S32) rsp->result);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_del_contact_list_req
- * DESCRIPTION
- * Send request to delete a contact list
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_del_contact_list_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_del_contact_list_req_struct *req =
- (mmi_imps_del_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_del_contact_list_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_del_contact_list_req_struct);
- strcpy((S8*) req->contact_list_id, (S8*) imps_p->group_info.group_list[imps_p->group_info.curr_item].group_id);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_DEL_CONTACT_LIST_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_del_contact_list_rsp
- * DESCRIPTION
- * Response handler for deleting contact list
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_del_contact_list_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_del_contact_list_rsp_struct *rsp = (mmi_imps_del_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_group_del_done((S32) rsp->result);
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_add_cont_req
- * DESCRIPTION
- * Send request to adding new contacts to a group
- * PARAMETERS
- * group_id [IN] Groud id
- * cont_id [IN] Contact id to be added
- * nick_name [IN] Nick name of the contact
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_add_cont_req(U8 *group_id, U8 *cont_id, S8 *nick_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_req_struct *req =
- (mmi_imps_edit_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_edit_contact_list_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_edit_contact_list_req_struct);
- strcpy((S8*) req->contact_list_id, (S8*) group_id);
- req->add_user = TRUE;
- req->user_nick_list.entity_count = 1;
- req->subscribe_pa_p = TRUE;
- req->subscribe_pa |= IMPS_PA_ATTR_VALUE_NO_PIC;
- req->subscribe_pa_user_p = TRUE;
- req->subscribe_user_pa |= IMPS_PA_ATTR_VALUE_NO_PIC;
- strcpy((S8*) req->user_nick_list.entity[0].id, (S8*) cont_id);
- req->user_nick_list.entity[0].entity_type = IMPS_ENTITY_TYPE_USER;
- if (pfnUnicodeStrlen(nick_name))
- {
- pfnUnicodeStrcpy((S8*) req->user_nick_list.entity[0].sname, (S8*) nick_name);
- }
- SetProtocolEventHandler(mmi_imps_add_cont_rsp, MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_add_cont_rsp
- * DESCRIPTION
- * Response handler of adding new contact
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_add_cont_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_rsp_struct *rsp = (mmi_imps_edit_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- mmi_imps_add_cont_finished(rsp->result);
- /* to sync with block list */
- mmi_imps_ps_get_block_list_req();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_edit_cont_req
- * DESCRIPTION
- * Send request to edit nick name of a contact
- * PARAMETERS
- * group_id [?]
- * cont_id [?]
- * nick_name [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_edit_cont_req(U8 *group_id, U8 *cont_id, S8 *nick_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_req_struct *req =
- (mmi_imps_edit_contact_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_edit_contact_list_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_edit_contact_list_req_struct);
- strcpy((S8*) req->contact_list_id, (S8*) group_id);
- req->add_user = TRUE;
- req->user_nick_list.entity_count = 1;
- strcpy((S8*) req->user_nick_list.entity[0].id, (S8*) cont_id);
- req->user_nick_list.entity[0].entity_type = IMPS_ENTITY_TYPE_USER;
- if (pfnUnicodeStrlen(nick_name))
- {
- pfnUnicodeStrcpy((S8*) req->user_nick_list.entity[0].sname, (S8*) nick_name);
- }
- SetProtocolEventHandler(mmi_imps_edit_cont_rsp, MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_EDIT_CONTACT_LIST_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_edit_cont_rsp
- * DESCRIPTION
- * Response handler of editing nick name of a contact
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_edit_cont_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_edit_contact_list_rsp_struct *rsp = (mmi_imps_edit_contact_list_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_about_friend_edit_finish(rsp->result);
- imps_p->gen_info.curr_action = 0;
- }
- #define ADD_SEARCH_PS_PROT
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_search_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_SEARCH_REQ to PS.
- * PARAMETERS
- * type [IN] Flag to indicate it's to search user or group
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_search_req(U8 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_search_req_struct *req =
- (mmi_imps_search_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_search_req_struct));
- mmi_imps_search_struct *search_p = imps_p->search_data;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_search_req_struct);
- imps_p->search_result.count = 0;
- req->search_type = type;
- req->search_limit = IMPS_MAX_SEARCH_RESULT;
- req->user_onlinestatus = FALSE;
- if (type == IMPS_SEARCH_USER)
- {
- if (pfnUnicodeStrlen((S8*) search_p->username))
- {
- UnicodeToAnsii((S8*) req->user_id, (S8*) search_p->username);
- }
- if (pfnUnicodeStrlen((S8*) search_p->phone))
- {
- UnicodeToAnsii((S8*) req->user_mobile_number, (S8*) search_p->phone);
- }
- if (pfnUnicodeStrlen((S8*) search_p->alias))
- {
- pfnUnicodeStrcpy((S8*) req->user_alias, (S8*) search_p->alias);
- }
- if (pfnUnicodeStrlen((S8*) search_p->email))
- {
- UnicodeToAnsii((S8*) req->user_emailaddress, (S8*) search_p->email);
- }
- }
- else /* group */
- {
- if (pfnUnicodeStrlen((S8*) search_p->room_name))
- {
- pfnUnicodeStrcpy((S8*) req->group_name, (S8*) search_p->room_name);
- }
- if (pfnUnicodeStrlen((S8*) search_p->room_topic))
- {
- pfnUnicodeStrcpy((S8*) req->group_topic, (S8*) search_p->room_topic);
- }
- if (pfnUnicodeStrlen((S8*) search_p->room_owner))
- {
- UnicodeToAnsii((S8*) req->group_user_id_owner, (S8*) search_p->room_owner);
- }
- if (pfnUnicodeStrlen((S8*) search_p->room_joined_user))
- {
- UnicodeToAnsii((S8*) req->group_user_id_joined, (S8*) search_p->room_joined_user);
- }
- }
- SetProtocolEventHandler(mmi_imps_ps_search_rsp, MSG_ID_MMI_IMPS_SEARCH_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_SEARCH_REQ, (void*)req, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_search_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_SEARCH_RSP. This handler is for searching contacts
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_search_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_search_rsp_struct *rsp = (mmi_imps_search_rsp_struct*) msg;
- U16 active_scr = GetActiveScreenId();
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (rsp->result == IMPS_OK)
- {
- S32 i, j;
- S32 count = (S32) rsp->search_result.entity_count;
- /* copy data to local buffer */
- for (i = 0, j = (S32) imps_p->search_result.count; i < count && j < IMPS_MAX_SEARCH_RESULT; i++, j++)
- {
- mmi_imps_entity_struct *local_entity = &imps_p->search_result.entity[j];
- imps_entity_struct *ps_entity = &rsp->search_result.entity[i];
- strncpy((S8*) local_entity->id, (S8*) ps_entity->id, (IMPS_MAX_ID_LEN - 1));
- pfnUnicodeStrncpy((S8*) local_entity->sname, (S8*) ps_entity->sname, IMPS_MAX_NAME_LEN);
- }
- imps_p->search_result.count = (U8) j;
- if (rsp->completion_flag)
- {
- if (active_scr == SCR_ID_IMPS_PROGRESS)
- {
- mmi_imps_entry_search_result(); /* display list of user */
- }
- else
- {
- HistoryReplace(SCR_ID_IMPS_PROGRESS, SCR_ID_IMPS_SEARCH_RESULT, mmi_imps_entry_search_result);
- return;
- }
- }
- else
- {
- return; /* do nothing */
- }
- }
- else
- {
- if (imps_p->search_result.count == 0)
- {
- mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(rsp->result));
- if (active_scr == SCR_ID_IMPS_PROGRESS)
- {
- DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
- }
- else
- {
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_SEARCH_OPT);
- }
- return;
- }
- else
- {
- if (active_scr == SCR_ID_IMPS_PROGRESS)
- {
- mmi_imps_entry_search_result(); /* display list of user */
- }
- else
- {
- HistoryReplace(SCR_ID_IMPS_PROGRESS, SCR_ID_IMPS_SEARCH_RESULT, mmi_imps_entry_search_result);
- DeleteScreenIfPresent(SCR_ID_IMPS_SEARCH_OPT);
- if (imps_p->search_result.search_cause == IMPS_SEARCH_CONT)
- {
- DeleteScreenIfPresent(SCR_ID_IMPS_CONT_SEARCH);
- }
- else
- {
- DeleteScreenIfPresent(SCR_ID_IMPS_CHAT_ROOM_SEARCH);
- }
- return;
- }
- }
- }
- /* determine the screen to go back */
- if (imps_p->search_result.search_cause == IMPS_SEARCH_CONT)
- {
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ADD_CONT);
- }
- else
- {
- mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CHAT_ROOM);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_abort_search_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_ABORT_SEARCH_REQ to PS
- * PARAMETERS
- * void
- * msg(?) [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_abort_search_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_ABORT_SEARCH_REQ, NULL, NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_abort_search_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_ABORT_SEARCH_RSP. This handler is for searching contacts
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_abort_search_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_imps_abort_search_finish();
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- }
- #define PA_PS_IMPS
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_sync_cont_list
- * DESCRIPTION
- * Remove dangling contacts and flush data to file system
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_sync_cont_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j;
- S32 count = (S32) imps_p->cont_info.no_cont;
- S32 no_group = (S32) imps_p->group_info.no_group;
- mmi_imps_cont_info_struct *cont_info = &imps_p->cont_info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* reset number of members */
- for (j = 0; j < no_group; j++)
- {
- imps_p->group_info.group_list[j].no_users = 0;
- }
- /* sync contacts -- remove dangling contacts */
- for (i = 1; i < count; i++) /* start from 1 to neglect MySelf */
- {
- if ((cont_info->cont_list[i].comm_state & IMPS_CONT_PA_READY) == 0)
- {
- if (i < (count - 1))
- {
- memcpy(
- &cont_info->cont_list[i],
- &cont_info->cont_list[i + 1],
- (count - i - 1) * sizeof(mmi_imps_cont_struct));
- }
- count--;
- memset(&cont_info->cont_list[count], 0, sizeof(mmi_imps_cont_struct));
- }
- else
- {
- /* find out the contact list the user belongs to */
- for (j = 0; j < no_group; j++)
- if (mmi_imps_util_is_id_same
- ((S8*) cont_info->cont_list[i].group_id, (S8*) imps_p->group_info.group_list[j].group_id))
- {
- imps_p->group_info.group_list[j].no_users++;
- }
- }
- }
- imps_p->cont_info.no_cont = (U8) count;
- /* flush data to file system */
- mmi_imps_util_write_cont();
- mmi_imps_util_write_group();
- /* redraw contact list */
- mmi_imps_cont_redraw_list();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_pa_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_GET_PA_REQ to PS.
- * PARAMETERS
- * data [IN] Pointer to contact list
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_pa_req(void *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- mmi_imps_view_contact_list_rsp_struct *ids = (mmi_imps_view_contact_list_rsp_struct*) data;
- S32 count = (S32) ids->user_nick_list.entity_count;
- mmi_imps_get_pa_req_struct *req =
- (mmi_imps_get_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_get_pa_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_get_pa_req_struct);
- req->user_id_list.entity_count = (U8) ids->user_nick_list.entity_count;
- req->subscribe_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
- for (i = 0; i < count; i++)
- {
- strcpy((S8*) req->user_id_list.entity[i].id, (S8*) ids->user_nick_list.entity[i].id);
- }
- SetProtocolEventHandler(mmi_imps_ps_get_pa_rsp, MSG_ID_MMI_IMPS_GET_PA_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_GET_PA_REQ, (void*)req, NULL);
- /* restore current action -- do not have to store action for background update cases */
- imps_p->gen_info.curr_action = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_pa_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_GET_PA_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_pa_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_get_pa_rsp_struct *rsp = (mmi_imps_get_pa_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
- {
- return;
- }
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (rsp->result == IMPS_OK)
- {
- S32 i, j;
- S32 ps_count = (S32) rsp->pa_val_list_info.entity_num;
- S32 local_count = (S32) imps_p->cont_info.no_cont;
- imps_pa_value_struct *pa_value;
- mmi_imps_cont_struct *cont;
- imps_pa_value_publisher_struct *pa_value_publisher = OslMalloc(sizeof(imps_pa_value_publisher_struct));
- FS_HANDLE fileHandle = 0;
- U32 len;
- S32 result;
- fileHandle = FS_Open((const WCHAR *) rsp->pa_val_list_info.entity_list_file_path, FS_READ_ONLY);
- /* update information of users */
- for (i = 0; i < ps_count; i++)
- {
- /* keneng : read pa value from file */
- if (fileHandle > 0)
- {
- result = FS_Read(fileHandle, (void *) pa_value_publisher, sizeof(imps_pa_value_publisher_struct), &len);
- }
- else
- {
- break;
- }
- for (j = 0; j < local_count; j++)
- {
- if (result < FS_NO_ERROR)
- {
- break;
- }
- if (imps_p->cont_info.cont_list[j].comm_state & IMPS_CONT_PA_READY)
- {
- if (mmi_imps_util_is_id_same
- ((S8*) imps_p->cont_info.cont_list[j].id,
- (S8*) pa_value_publisher->publisher_user_id))
- {
- cont = &imps_p->cont_info.cont_list[j];
- pa_value = &pa_value_publisher->pa_value;
- /* default availability */
- cont->availability = IMPS_PA_USER_NOT_AVAILABLE;
- if (pa_value->online_status_qualifier) /* if user is online, the availability depends on his setting */
- {
- if (pa_value->online_status == TRUE)
- {
- if (pa_value->user_availability_qualifier)
- {
- cont->availability = pa_value->user_availability;
- }
- else
- {
- cont->availability = IMPS_PA_USER_AVAILABLE;
- }
- }
- }
- else
- {
- if (pa_value->user_availability_qualifier)
- {
- cont->availability = pa_value->user_availability;
- }
- }
- if (pa_value->status_mood_qualifier)
- {
- cont->mood = pa_value->status_mood;
- }
- if (pa_value->status_text_qualifier)
- {
- pfnUnicodeStrcpy((S8*) cont->prof_text, (S8*) pa_value->status_text);
- }
- /*
- * currently no usage
- * if(pa_value->status_content_qualifier)
- */
- }
- }
- }
- }
- FS_Close(fileHandle);
- FS_Delete((const WCHAR *) rsp->pa_val_list_info.entity_list_file_path);
- OslMfree(pa_value_publisher);
- mmi_imps_cont_redraw_list();
- }
- else
- {
- /* do nothing */
- }
- mmi_imps_ps_view_next_contact_list();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_about_me_rsp
- * DESCRIPTION
- * Response handler of MSG_ID_MMI_IMPS_GET_PA_REQ for about me
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_about_me_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_get_pa_rsp_struct *rsp = (mmi_imps_get_pa_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
- {
- return;
- }
- if (rsp->result == IMPS_OK)
- {
- mmi_imps_nvram_struct *nvram_buff = (mmi_imps_nvram_struct*) OslMalloc(sizeof(mmi_imps_nvram_struct));
- imps_pa_value_struct *pa_value;
- mmi_imps_cont_struct *cont;
- imps_pa_value_publisher_struct *pa_value_publisher = OslMalloc(sizeof(imps_pa_value_publisher_struct));
- FS_HANDLE fileHandle = 0;
- U32 len;
- fileHandle = FS_Open((const WCHAR *) rsp->pa_val_list_info.entity_list_file_path, FS_READ_ONLY);
- if (fileHandle > 0)
- {
- FS_Read(fileHandle, (void *) pa_value_publisher, sizeof(imps_pa_value_publisher_struct), &len);
- }
- /* read data from NVRAM */
- mmi_imps_util_read_nvram((void*)nvram_buff);
- cont = &imps_p->cont_info.cont_list[0];
- pa_value = &pa_value_publisher->pa_value;
- /* default regarded as online */
- cont->availability = IMPS_PA_USER_AVAILABLE;
- if (pa_value->online_status_qualifier)
- {
- if (pa_value->online_status == TRUE)
- {
- if (pa_value->user_availability_qualifier)
- {
- cont->availability = pa_value->user_availability;
- }
- }
- else
- {
- cont->availability = IMPS_PA_USER_NOT_AVAILABLE;
- }
- }
- if (pa_value->status_mood_qualifier)
- {
- cont->mood = pa_value->status_mood;
- }
- else
- {
- cont->mood = nvram_buff->about_me.mood;
- }
- if (pa_value->status_text_qualifier)
- {
- pfnUnicodeStrcpy((S8*) cont->prof_text, (S8*) pa_value->status_text);
- pfnUnicodeStrcpy((S8*) nvram_buff->about_me.my_prof, (S8*) cont->prof_text);
- }
- else
- {
- pfnUnicodeStrcpy((S8*) cont->prof_text, (S8*) nvram_buff->about_me.my_prof);
- }
- FS_Close(fileHandle);
- FS_Delete((const WCHAR *) rsp->pa_val_list_info.entity_list_file_path);
- OslMfree(pa_value_publisher);
- /* status */
- nvram_buff->about_me.status = (U8) cont->availability;
- nvram_buff->about_me.mood = (U8) cont->mood;
- mmi_imps_util_write_nvram((void*)nvram_buff);
- OslMfree(nvram_buff);
- mmi_imps_cont_redraw_list();
- }
- mmi_imps_ps_get_block_list_req();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_about_me_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_GET_PA_REQ to get detailed information of myself.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_about_me_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_get_pa_req_struct *req =
- (mmi_imps_get_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_get_pa_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- req->user_id_list.entity_count = 1;
- req->subscribe_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
- strcpy((S8*) req->user_id_list.entity[0].id, (S8*) imps_p->cont_info.cont_list[0].id);
- req->user_id_list.entity[0].entity_type = 0;
- SetProtocolEventHandler(mmi_imps_ps_get_about_me_rsp, MSG_ID_MMI_IMPS_GET_PA_RSP);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_GET_PA_REQ, (void*)req, NULL);
- /* restore current action -- do not have to store action for background update cases */
- imps_p->gen_info.curr_action = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_single_pa_req
- * DESCRIPTION
- * Send MSG_ID_MMI_IMPS_GET_PA_REQ to get detailed information of a user.
- * PARAMETERS
- * id [IN] Id of contact to get
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_single_pa_req(U8 *id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_get_pa_req_struct *req =
- (mmi_imps_get_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_get_pa_req_struct));
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- IMPS_MEMSET(req, 0, mmi_imps_get_pa_req_struct);
- req->user_id_list.entity_count = 1;
- req->user_id_list.entity[0].entity_type = IMPS_ENTITY_TYPE_USER;
- req->subscribe_pa = IMPS_PA_ATTR_VALUE;
- strcpy((S8*) req->user_id_list.entity[0].id, (S8*) id);
- mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_GET_PA_REQ, (void*)req, NULL);
- SetProtocolEventHandler(mmi_imps_ps_get_single_pa_rsp, MSG_ID_MMI_IMPS_GET_PA_RSP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_imps_ps_get_single_pa_rsp
- * DESCRIPTION
- * Handler for MSG_ID_MMI_IMPS_GET_PA_RSP.
- * PARAMETERS
- * msg [IN] Result of response
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_imps_ps_get_single_pa_rsp(void *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_imps_get_pa_rsp_struct *rsp = (mmi_imps_get_pa_rsp_struct*) msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* restore current action */
- imps_p->gen_info.curr_action = 0;
- if (rsp->result == IMPS_OK)
- {
- imps_pa_value_publisher_struct *pa_value_publisher = OslMalloc(sizeof(imps_pa_value_publisher_struct));
- FS_HANDLE fileHandle = 0;
- U32 len;
- S32 result = FS_ERROR_RESERVED;
- fileHandle = FS_Open((const WCHAR *) rsp->pa_val_list_info.entity_list_file_path, FS_READ_ONLY);
- if (fileHandle > 0)
- {
- result = FS_Read(fileHandle, (void *) pa_value_publisher, sizeof(imps_pa_value_publisher_struct), &len);