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

MTK

开发平台:

C/C++

  1.         }
  2.         
  3.         if (result == FS_NO_ERROR)
  4.         {
  5.             imps_pa_value_struct *pa_value = &pa_value_publisher->pa_value;
  6.             mmi_imps_cont_struct *cont = &imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont];
  7.             if (pa_value->online_status_qualifier)  /* if user is online, the availability depends on his setting */
  8.             {
  9.                 if (pa_value->online_status == TRUE)
  10.                 {
  11.                     if (pa_value->user_availability_qualifier)
  12.                     {
  13.                         cont->availability = pa_value->user_availability;
  14.                     }
  15.                     else
  16.                     {
  17.                         cont->availability = IMPS_PA_USER_AVAILABLE;
  18.                     }
  19.                 }
  20.                 else
  21.                 {
  22.                     cont->availability = IMPS_PA_USER_NOT_AVAILABLE;
  23.                 }
  24.             }
  25.             else
  26.             {
  27.                 if (pa_value->user_availability_qualifier)
  28.                 {
  29.                     cont->availability = pa_value->user_availability;
  30.                 }
  31.             }
  32.             if (pa_value->status_mood_qualifier)
  33.             {
  34.                 cont->mood = pa_value->status_mood;
  35.             }
  36.             else
  37.             {
  38.                 cont->mood = IMPS_PA_STATUS_MOOD_HAPPY;
  39.             }
  40.             if (pa_value->status_text_qualifier)
  41.             {
  42.                 pfnUnicodeStrcpy((S8*) cont->prof_text, (S8*) pa_value->status_text);
  43.             }
  44.             else
  45.             {
  46.                 cont->prof_text[0] = 0;
  47.             }
  48.             /* image context, temporary saved in common file buffer */
  49.             if (pa_value->status_content_qualifier)
  50.             {
  51.                 pfnUnicodeStrcpy((S8*) imps_p->friend_info.file_name, (S8*) pa_value->status_content_file_name);
  52.             }
  53.             else
  54.             {
  55.                 imps_p->friend_info.file_name[0] = 0;
  56.             }
  57.         }
  58.         FS_Close(fileHandle);
  59.         FS_Delete((const WCHAR *) rsp->pa_val_list_info.entity_list_file_path);
  60.         OslMfree(pa_value_publisher);
  61.         /* update data */
  62.         mmi_imps_about_friend_refresh_finish();
  63.     }
  64.     else
  65.     {
  66.         mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(rsp->result));
  67.         mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_ABOUT_FRIEND);
  68.     }
  69. }
  70. /*****************************************************************************
  71.  * FUNCTION
  72.  *  mmi_imps_abort_get_pa_req
  73.  * DESCRIPTION
  74.  *  Send MSG_ID_MMI_IMPS_UPDATE_PA_REQ to PS.
  75.  * PARAMETERS
  76.  *  void
  77.  * RETURNS
  78.  *  void
  79.  *****************************************************************************/
  80. void mmi_imps_abort_get_pa_req(void)
  81. {
  82.     /*----------------------------------------------------------------*/
  83.     /* Local Variables                                                */
  84.     /*----------------------------------------------------------------*/
  85.     /*----------------------------------------------------------------*/
  86.     /* Code Body                                                      */
  87.     /*----------------------------------------------------------------*/
  88.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_ABORT_GET_PA_REQ, NULL, NULL);
  89. }
  90. /*****************************************************************************
  91.  * FUNCTION
  92.  *  mmi_imps_abort_get_pa_rsp
  93.  * DESCRIPTION
  94.  *  Handler for MSG_ID_MMI_IMPS_ABORT_GET_PA_RSP.
  95.  * PARAMETERS
  96.  *  msg     [IN]        Result of response
  97.  * RETURNS
  98.  *  void
  99.  *****************************************************************************/
  100. void mmi_imps_abort_get_pa_rsp(void *msg)
  101. {
  102.     /*----------------------------------------------------------------*/
  103.     /* Local Variables                                                */
  104.     /*----------------------------------------------------------------*/
  105.     /*----------------------------------------------------------------*/
  106.     /* Code Body                                                      */
  107.     /*----------------------------------------------------------------*/
  108.     /* restore current action */
  109.     imps_p->gen_info.curr_action = 0;
  110.     if (imps_p->gen_info.is_reentry)
  111.     {
  112.         mmi_imps_re_entry_app();
  113.     }
  114.     else
  115.     {
  116.         if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
  117.         {
  118.             GoBackToHistory(SCR_ID_IMPS_ABOUT_FRIEND);
  119.         }
  120.         else
  121.         {
  122.             DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
  123.         }
  124.     }
  125. }
  126. /*****************************************************************************
  127.  * FUNCTION
  128.  *  mmi_imps_ps_update_pa_req
  129.  * DESCRIPTION
  130.  *  Send MSG_ID_MMI_IMPS_UPDATE_PA_REQ to PS.
  131.  * PARAMETERS
  132.  *  void
  133.  * RETURNS
  134.  *  void
  135.  *****************************************************************************/
  136. void mmi_imps_ps_update_pa_req(void)
  137. {
  138.     /*----------------------------------------------------------------*/
  139.     /* Local Variables                                                */
  140.     /*----------------------------------------------------------------*/
  141.     mmi_imps_update_pa_req_struct *req =
  142.         (mmi_imps_update_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_update_pa_req_struct));
  143.     imps_pa_value_struct *pa_value = &req->pa_update_list.pa_value;
  144.     mmi_imps_about_me_struct *about_info = imps_p->about_info;
  145.     /*----------------------------------------------------------------*/
  146.     /* Code Body                                                      */
  147.     /*----------------------------------------------------------------*/
  148.     IMPS_MEMSET(req, 0, mmi_imps_update_pa_req_struct);
  149.     strcpy((S8*) req->pa_update_list.publisher_user_id, (S8*) imps_p->act_prof.username);
  150.     pa_value->user_availability_qualifier = TRUE;
  151.     pa_value->user_availability = (U8) about_info->status;
  152.     pa_value->status_mood_qualifier = TRUE;
  153.     pa_value->status_mood = (U8) about_info->mood;
  154.     pa_value->status_text_qualifier = TRUE;
  155.     pfnUnicodeStrcpy((S8*) pa_value->status_text, (S8*) about_info->my_prof);
  156.     if (imps_p->about_info->is_pic_changed && pfnUnicodeStrlen((S8*) about_info->my_pic))
  157.     {
  158.         S8 *file_ext = NULL, *mine_type = NULL;
  159.         /* shall fill contect type afterwards */
  160.         pa_value->status_content_qualifier = TRUE;
  161.         pfnUnicodeStrcpy((S8*) pa_value->status_content_file_name, (S8*) IMPS_ABOUT_PIC_PREFIX);
  162.         file_ext = (S8*) mmi_fmgr_extract_ext_file_name((S8*) about_info->file_buff);
  163.         pfnUnicodeStrcat((S8*) pa_value->status_content_file_name, (S8*) file_ext);
  164.         UnicodeToAnsii((S8*) pa_value->status_content_type, (S8*) file_ext);
  165.         mine_type = mmi_imps_get_mine_type((S8*) pa_value->status_content_type);
  166.         if (mine_type)
  167.         {
  168.             strcpy((S8*) pa_value->status_content_type, mine_type);
  169.         }
  170.     }
  171.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_UPDATE_PA_REQ, (void*)req, NULL);
  172. }
  173. /*****************************************************************************
  174.  * FUNCTION
  175.  *  mmi_imps_ps_update_pa_rsp
  176.  * DESCRIPTION
  177.  *  Handler for MSG_ID_MMI_IMPS_UPDATE_PA_RSP.
  178.  * PARAMETERS
  179.  *  msg     [IN]        Result of response
  180.  * RETURNS
  181.  *  void
  182.  *****************************************************************************/
  183. void mmi_imps_ps_update_pa_rsp(void *msg)
  184. {
  185.     /*----------------------------------------------------------------*/
  186.     /* Local Variables                                                */
  187.     /*----------------------------------------------------------------*/
  188.     mmi_imps_update_pa_rsp_struct *rsp = (mmi_imps_update_pa_rsp_struct*) msg;
  189.     /*----------------------------------------------------------------*/
  190.     /* Code Body                                                      */
  191.     /*----------------------------------------------------------------*/
  192.     /* restore current action */
  193.     imps_p->gen_info.curr_action = 0;
  194.     mmi_imps_about_me_save_done(rsp->result);
  195. }
  196. /*****************************************************************************
  197.  * FUNCTION
  198.  *  mmi_imps_ps_pa_notify_ind
  199.  * DESCRIPTION
  200.  *  Handler for MSG_ID_MMI_IMPS_PA_NOTIFY_IND.
  201.  * PARAMETERS
  202.  *  msg     [IN]        Indication data
  203.  * RETURNS
  204.  *  void
  205.  *****************************************************************************/
  206. void mmi_imps_ps_pa_notify_ind(void *msg)
  207. {
  208.     /*----------------------------------------------------------------*/
  209.     /* Local Variables                                                */
  210.     /*----------------------------------------------------------------*/
  211.     mmi_imps_pa_notify_ind_struct *ind = (mmi_imps_pa_notify_ind_struct*) msg;
  212.     mmi_imps_cont_struct *cont;
  213.     S32 i, pa_count, entity_count, j;
  214.     imps_pa_value_struct *pa_value;
  215.     imps_pa_value_publisher_struct *pa_value_publisher = OslMalloc(sizeof(imps_pa_value_publisher_struct));
  216.     FS_HANDLE fileHandle = 0;
  217.     U32 len;
  218.     S32 result;
  219.     /*----------------------------------------------------------------*/
  220.     /* Code Body                                                      */
  221.     /*----------------------------------------------------------------*/
  222.     pa_count = (S32) ind->pa_val_list_info.entity_num;
  223.     entity_count = (S32) imps_p->cont_info.no_cont;
  224.     fileHandle = FS_Open((const WCHAR *) ind->pa_val_list_info.entity_list_file_path, FS_READ_ONLY);
  225.     for (i = 0; i < pa_count; i++)
  226.     {
  227.         /* keneng : read pa value from file */
  228.         if (fileHandle > 0)
  229.         {
  230.             result = FS_Read(fileHandle, (void *) pa_value_publisher, sizeof(imps_pa_value_publisher_struct), &len);
  231.         }
  232.         else
  233.         {
  234.             break;
  235.         }
  236.             
  237.         for (j = 0; j < entity_count; j++)
  238.         {
  239.             if (result < FS_NO_ERROR)
  240.             {
  241.                 break;
  242.             }
  243.             cont = &imps_p->cont_info.cont_list[j];
  244.             /* find the user in contact list, update it's data */
  245.             if (mmi_imps_util_is_id_same((S8*) cont->id, (S8*) pa_value_publisher->publisher_user_id))
  246.             {
  247.                 pa_value = &pa_value_publisher->pa_value;
  248.                 if (pa_value->online_status_qualifier)  /* if user is online, the availability depends on his setting */
  249.                 {
  250.                     if (pa_value->online_status == TRUE)
  251.                     {
  252.                         if (pa_value->user_availability_qualifier)
  253.                         {
  254.                             cont->availability = pa_value->user_availability;
  255.                         }
  256.                         else
  257.                         {
  258.                             cont->availability = IMPS_PA_USER_AVAILABLE;
  259.                         }
  260.                     }
  261.                     else
  262.                     {
  263.                         cont->availability = IMPS_PA_USER_NOT_AVAILABLE;
  264.                     }
  265.                 }
  266.                 else
  267.                 {
  268.                     if (pa_value->user_availability_qualifier)
  269.                     {
  270.                         cont->availability = pa_value->user_availability;
  271.                     }
  272.                 }
  273.                 if (pa_value->status_mood_qualifier)
  274.                 {
  275.                     cont->mood = pa_value->status_mood;
  276.                 }
  277.                 if (pa_value->status_text_qualifier)
  278.                 {
  279.                     pfnUnicodeStrcpy((S8*) cont->prof_text, (S8*) pa_value->status_text);
  280.                 }
  281.             }
  282.         }
  283.     }
  284.     FS_Close(fileHandle);
  285.     FS_Delete((const WCHAR *) ind->pa_val_list_info.entity_list_file_path);
  286.     OslMfree(pa_value_publisher);
  287.     /* update information of the contact */
  288.     /* force to redraw contact list */
  289.     mmi_imps_cont_redraw_list();
  290. }
  291. #define BLOCK_PS_IMPS
  292. /*****************************************************************************
  293.  * FUNCTION
  294.  *  mmi_imps_ps_block_entity_req
  295.  * DESCRIPTION
  296.  *  Send request to block/grant a contact
  297.  * PARAMETERS
  298.  *  type        [IN]        Type of request -- block user or grant user
  299.  * RETURNS
  300.  *  void
  301.  *****************************************************************************/
  302. void mmi_imps_ps_block_entity_req(U8 type)
  303. {
  304.     /*----------------------------------------------------------------*/
  305.     /* Local Variables                                                */
  306.     /*----------------------------------------------------------------*/
  307.     mmi_imps_block_entity_req_struct *req =
  308.         (mmi_imps_block_entity_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_block_entity_req_struct));
  309.     imps_entity_struct *entity;
  310.     /*----------------------------------------------------------------*/
  311.     /* Code Body                                                      */
  312.     /*----------------------------------------------------------------*/
  313.     IMPS_MEMSET(req, 0, mmi_imps_block_entity_req_struct);
  314.     req->block_in_use = TRUE;
  315.     req->grant_in_use = FALSE;
  316.     if (type == IMPS_BLOCK)
  317.     {
  318.         entity = &req->add_block_user;
  319.     }
  320.     else
  321.     {
  322.         entity = &req->remove_block_user;
  323.     }
  324.     strcpy((S8*) entity->id, (S8*) imps_p->cont_info.cont_list[imps_p->cont_info.curr_cont].id);
  325.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_BLOCK_ENTITY_REQ, req, NULL);
  326. }
  327. /*****************************************************************************
  328.  * FUNCTION
  329.  *  mmi_imps_ps_block_entity_rsp
  330.  * DESCRIPTION
  331.  *  Handler for MSG_ID_MMI_IMPS_BLOCK_ENTITY_RSP
  332.  * PARAMETERS
  333.  *  msg     [IN]        Indication data
  334.  * RETURNS
  335.  *  void
  336.  *****************************************************************************/
  337. void mmi_imps_ps_block_entity_rsp(void *msg)
  338. {
  339.     /*----------------------------------------------------------------*/
  340.     /* Local Variables                                                */
  341.     /*----------------------------------------------------------------*/
  342.     mmi_imps_block_entity_rsp_struct *rsp = (mmi_imps_block_entity_rsp_struct*) msg;
  343.     /*----------------------------------------------------------------*/
  344.     /* Code Body                                                      */
  345.     /*----------------------------------------------------------------*/
  346.     /* restore current action */
  347.     imps_p->gen_info.curr_action = 0;
  348.     mmi_imps_block_grant_done(rsp->result);
  349. }
  350. /*****************************************************************************
  351.  * FUNCTION
  352.  *  mmi_imps_ps_get_block_list_req
  353.  * DESCRIPTION
  354.  *  Send request to get block list
  355.  * PARAMETERS
  356.  *  void
  357.  * RETURNS
  358.  *  void
  359.  *****************************************************************************/
  360. void mmi_imps_ps_get_block_list_req(void)
  361. {
  362.     /*----------------------------------------------------------------*/
  363.     /* Local Variables                                                */
  364.     /*----------------------------------------------------------------*/
  365.     /*----------------------------------------------------------------*/
  366.     /* Code Body                                                      */
  367.     /*----------------------------------------------------------------*/
  368.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_GET_BLOCK_LIST_REQ, NULL, NULL);
  369.     /* restore current action -- won't store state for background update */
  370.     imps_p->gen_info.curr_action = 0;
  371. }
  372. /*****************************************************************************
  373.  * FUNCTION
  374.  *  mmi_imps_ps_get_block_list_rsp
  375.  * DESCRIPTION
  376.  *  Response handler of MSG_ID_MMI_IMPS_GET_BLOCK_LIST_RSP
  377.  * PARAMETERS
  378.  *  msg     [IN]        Indication data
  379.  * RETURNS
  380.  *  void
  381.  *****************************************************************************/
  382. void mmi_imps_ps_get_block_list_rsp(void *msg)
  383. {
  384.     /*----------------------------------------------------------------*/
  385.     /* Local Variables                                                */
  386.     /*----------------------------------------------------------------*/
  387.     mmi_imps_get_block_list_rsp_struct *rsp = (mmi_imps_get_block_list_rsp_struct*) msg;
  388.     S32 i;
  389.     S32 block_count;
  390.     U32 len;
  391.     S32 result;
  392.     mmi_imps_cont_struct *cont;
  393.     FS_HANDLE fileHandle;
  394.     imps_entity_struct *entity;
  395.     /*----------------------------------------------------------------*/
  396.     /* Code Body                                                      */
  397.     /*----------------------------------------------------------------*/
  398.     if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
  399.     {
  400.         return;
  401.     }
  402.     block_count = (S32) rsp->block_list.block_num;
  403.     /* block list exists */
  404.     if ( /* rsp->block_in_use && */ block_count > 0)
  405.     {
  406.         fileHandle = FS_Open((U16*) rsp->block_list.block_list_file_path, FS_READ_ONLY);
  407.         if (fileHandle > 0)
  408.         {
  409.             entity = (imps_entity_struct*) OslMalloc(sizeof(imps_entity_struct));
  410.             for (i = 0; i < block_count; i++)
  411.             {
  412.                 result = FS_Read(fileHandle, (void*)entity, sizeof(imps_entity_struct), &len);
  413.                 if (result == FS_NO_ERROR)
  414.                 {
  415.                     /* search if the user is in contact list */
  416.                     cont = mmi_imps_util_search_cont((S8*) entity->id);
  417.                     if (cont != NULL)
  418.                     {
  419.                         cont->comm_state |= IMPS_CONT_BLOCK;
  420.                     }
  421.                 }
  422.                 else
  423.                 {
  424.                     break;
  425.                 }
  426.             }
  427.             FS_Close(fileHandle);
  428.             OslMfree(entity);
  429.         }
  430.     }
  431.     /* redraw context list */
  432.     if (imps_p->gen_info.auto_update_done == FALSE)
  433.     {
  434.         mmi_imps_sync_cont_list();
  435.         imps_p->gen_info.auto_update_done = TRUE;
  436.     }
  437.     else
  438.     {
  439.         mmi_imps_cont_redraw_list();
  440.     }
  441. }
  442. #define MSG_PS_IMPS
  443. /*****************************************************************************
  444.  * FUNCTION
  445.  *  mmi_imps_ps_newmsg_ind
  446.  * DESCRIPTION
  447.  *  Handler for MSG_ID_MMI_IMPS_NEWMSG_IND
  448.  * PARAMETERS
  449.  *  msg     [IN]        Indication data
  450.  * RETURNS
  451.  *  void
  452.  *****************************************************************************/
  453. void mmi_imps_ps_newmsg_ind(void *msg)
  454. {
  455.     /*----------------------------------------------------------------*/
  456.     /* Local Variables                                                */
  457.     /*----------------------------------------------------------------*/
  458.     S32 i, count;
  459.     BOOL is_in_room = FALSE;
  460.     imps_entity_struct *entity;
  461.     mmi_imps_newmessage_ind_struct *ind = (mmi_imps_newmessage_ind_struct*) msg;
  462.     S32 unused_room = IMPS_MAX_NO_ROOM;
  463.     U16 active_scr = GetActiveScreenId();
  464.     /*----------------------------------------------------------------*/
  465.     /* Code Body                                                      */
  466.     /*----------------------------------------------------------------*/
  467.     /* logout or during logout period */
  468.     if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
  469.     {
  470.         return;
  471.     }
  472.     /* no message, to prevent abnormal cases */
  473.     if (ind->msg_len == 0)
  474.     {
  475.         return;
  476.     }
  477.     /* check if there is a chat room for the recipient */
  478.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  479.     {
  480.         mmi_imps_room_struct *room = &imps_p->room_info.room_list[i];
  481.         if (room->is_used)
  482.         {
  483.             if (room->type == IMPS_ROOM_TYPE_SINGLE && ind->recipient.entity_type == IMPS_ENTITY_TYPE_USER)
  484.             {
  485.                 /* single talk */
  486.                 entity = &ind->sender;
  487.             }
  488.             else
  489.             {
  490.                 /* chat rooms */
  491.                 entity = &ind->recipient;
  492.                 /* if the sender is the receiver himself */
  493.                 if (ind->sender.entity_type == IMPS_ENTITY_TYPE_SCREEN_NAME)    /* screen name only */
  494.                 {
  495.                     /* compare screen name */
  496.                     if (pfnUnicodeStrcmp((S8*) ind->sender.sname, (S8*) room->member[0].sname) == 0)
  497.                     {
  498.                         return;
  499.                     }
  500.                 }
  501.                 else
  502.                 {
  503.                     /* compare screen name */
  504.                     if (mmi_imps_util_is_id_same((S8*) ind->sender.id, (S8*) imps_p->cont_info.cont_list[0].id))
  505.                     {
  506.                         return;
  507.                     }
  508.                 }
  509.             }
  510.             if (mmi_imps_util_is_id_same((S8*) room->room_id, (S8*) entity->id))      /* chat room exists */
  511.             {
  512.                 mmi_imps_chat_recv_msg((U16*) ind->message_content, (U8) i, (imps_entity_struct*) & ind->sender);
  513.                 mmi_imps_tab_update_event(room, entity);
  514.                 mmi_imps_util_play_tone(IMPS_MSG_TONE);
  515.                 /* stop searching */
  516.                 is_in_room = TRUE;
  517.                 break;
  518.             }
  519.         }
  520.         else
  521.         {
  522.             unused_room = i;    /* pre-record unused room */
  523.         }
  524.     }
  525.     /* if no check room found, check if the receipient is in contact list */
  526.     if (is_in_room == FALSE && unused_room != IMPS_MAX_NO_ROOM) /* there still some chat room to store message */
  527.     {
  528.         count = (S32) imps_p->cont_info.no_cont;
  529.         entity = &ind->sender;
  530.         if (entity->entity_type == IMPS_ENTITY_TYPE_USER)
  531.         {
  532.             mmi_imps_room_struct *room = &imps_p->room_info.room_list[unused_room];
  533.             /* create a new tab */
  534.             memset(room, 0, sizeof(mmi_imps_room_struct));
  535.             room->is_used = TRUE;
  536.             room->type = IMPS_ROOM_TYPE_SINGLE;
  537.             room->no_member = 1;
  538.             room->tab_index = imps_p->gen_info.no_tab;
  539.             imps_p->gen_info.no_tab++;
  540.             strcpy((S8*) room->member[0].id, (S8*) entity->id);
  541.             strcpy((S8*) room->room_id, (S8*) entity->id);
  542.             /* display be screen name if the user's alias is not empty */
  543.             if (pfnUnicodeStrlen((S8*) entity->sname))
  544.             {
  545.                 pfnUnicodeStrcpy((S8*) room->room_name, (S8*) entity->sname);
  546.                 pfnUnicodeStrcpy((S8*) room->member[0].sname, (S8*) entity->sname);
  547.             }
  548.             else
  549.             {
  550.                 AnsiiToUnicodeString((S8*) room->room_name, (S8*) entity->id);
  551.                 room->member[0].sname[0] = 0;
  552.             }
  553.             imps_p->room_info.no_rooms++;
  554.             /* update display buffer */
  555.             mmi_imps_new_room_string((S8*) room->chat_buff, (S8*) room->room_name);
  556.             mmi_imps_chat_recv_msg(
  557.                 (U16*) ind->message_content,
  558.                 (U8) unused_room,
  559.                 (imps_entity_struct*) & ind->sender);
  560.             /* redraw tab becuase new tab created */
  561.             mmi_imps_tab_redraw(active_scr);
  562.             /* update tab when event comes event */
  563.             mmi_imps_tab_update_event(room, entity);
  564.             mmi_imps_util_play_tone(IMPS_MSG_TONE);
  565.         }
  566.     }
  567.     /*
  568.      * else
  569.      * {
  570.      * neglect the message because of buffer full
  571.      * }
  572.      */
  573. }
  574. #define WATCH_PS_IMPS
  575. /*****************************************************************************
  576.  * FUNCTION
  577.  *  mmi_imps_ps_get_watch_list_req
  578.  * DESCRIPTION
  579.  *  Send MSG_ID_MMI_IMPS_GET_WATCHER_LIST_REQ to PS
  580.  * PARAMETERS
  581.  *  void
  582.  * RETURNS
  583.  *  void
  584.  *****************************************************************************/
  585. void mmi_imps_ps_get_watch_list_req(void)
  586. {
  587.     /*----------------------------------------------------------------*/
  588.     /* Local Variables                                                */
  589.     /*----------------------------------------------------------------*/
  590.     mmi_imps_get_watcher_list_req_struct *req =
  591.         (mmi_imps_get_watcher_list_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_get_watcher_list_req_struct));
  592.     /*----------------------------------------------------------------*/
  593.     /* Code Body                                                      */
  594.     /*----------------------------------------------------------------*/
  595.     IMPS_MEMSET(req, 0, mmi_imps_get_watcher_list_req_struct);
  596.     req->max_watcher_list = IMPS_MAX_SEARCH_RESULT;
  597.     req->max_watcher_list_p = TRUE;
  598.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_GET_WATCHER_LIST_REQ, (void*)req, NULL);
  599. }
  600. /*****************************************************************************
  601.  * FUNCTION
  602.  *  mmi_imps_ps_get_watch_list_rsp
  603.  * DESCRIPTION
  604.  *  Handler for MSG_ID_MMI_IMPS_GET_WATCHER_LIST_RSP
  605.  * PARAMETERS
  606.  *  msg     [IN]        Indication data
  607.  * RETURNS
  608.  *  void
  609.  *****************************************************************************/
  610. void mmi_imps_ps_get_watch_list_rsp(void *msg)
  611. {
  612.     /*----------------------------------------------------------------*/
  613.     /* Local Variables                                                */
  614.     /*----------------------------------------------------------------*/
  615.     mmi_imps_get_watcher_list_rsp_struct *rsp = (mmi_imps_get_watcher_list_rsp_struct*) msg;
  616.     /*----------------------------------------------------------------*/
  617.     /* Code Body                                                      */
  618.     /*----------------------------------------------------------------*/
  619.     /* restore current action */
  620.     imps_p->gen_info.curr_action = 0;
  621.     if (rsp->watcher_list_p == FALSE || rsp->watcher_list.watcher_num == 0)
  622.     {
  623.         mmi_imps_util_disp_empty_popup();
  624.         mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CONT_OPT);
  625.     }
  626.     else
  627.     {
  628.         S32 result;
  629.         /* copy response to local structure */
  630.         imps_p->search_result.count = rsp->watcher_list.watcher_num;
  631.         /* display result screen */
  632.         result = mmi_imps_pre_entry_watch_list((S16*) rsp->watcher_list.watcher_list_file_path);
  633.         if (result > 0)
  634.         {
  635.             if (GetActiveScreenId() == SCR_ID_IMPS_PROGRESS)
  636.             {
  637.                 mmi_imps_entry_search_result();
  638.                 mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CONT_OPT);
  639.             }
  640.             else
  641.             {
  642.                 HistoryReplace(SCR_ID_IMPS_PROGRESS, SCR_ID_IMPS_WATCHER_LIST, mmi_imps_entry_watch_list);
  643.             }
  644.         }
  645.         else
  646.         {
  647.             mmi_imps_util_disp_err_popup(mmi_imps_util_get_err_str(result));
  648.             mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CONT_OPT);
  649.         }
  650.     }
  651. }
  652. /*****************************************************************************
  653.  * FUNCTION
  654.  *  mmi_imps_ps_abort_get_watch_list_req
  655.  * DESCRIPTION
  656.  *  Send MSG_ID_MMI_IMPS_GET_WATCHER_LIST_REQ to PS
  657.  * PARAMETERS
  658.  *  void
  659.  * RETURNS
  660.  *  void
  661.  *****************************************************************************/
  662. void mmi_imps_ps_abort_get_watch_list_req(void)
  663. {
  664.     /*----------------------------------------------------------------*/
  665.     /* Local Variables                                                */
  666.     /*----------------------------------------------------------------*/
  667.     /*----------------------------------------------------------------*/
  668.     /* Code Body                                                      */
  669.     /*----------------------------------------------------------------*/
  670.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_ABORT_GET_WATCHER_LIST_REQ, NULL, NULL);
  671. }
  672. /*****************************************************************************
  673.  * FUNCTION
  674.  *  mmi_imps_ps_abort_get_watch_list_rsp
  675.  * DESCRIPTION
  676.  *  Abort Get Watcher list process
  677.  * PARAMETERS
  678.  *  msg     [IN]        Result of response
  679.  * RETURNS
  680.  *  void
  681.  *****************************************************************************/
  682. void mmi_imps_ps_abort_get_watch_list_rsp(void *msg)
  683. {
  684.     /*----------------------------------------------------------------*/
  685.     /* Local Variables                                                */
  686.     /*----------------------------------------------------------------*/
  687.     /*----------------------------------------------------------------*/
  688.     /* Code Body                                                      */
  689.     /*----------------------------------------------------------------*/
  690.     mmi_imps_abort_search_finish();
  691.     /* restore current action */
  692.     imps_p->gen_info.curr_action = 0;
  693. }
  694. #define CHAT_IMPS
  695. /*****************************************************************************
  696.  * FUNCTION
  697.  *  mmi_imps_ps_send_msg_req
  698.  * DESCRIPTION
  699.  *  Send request to protocol
  700.  * PARAMETERS
  701.  *  msg_id          [IN]        Index of session
  702.  *  msg             [IN]        String message to be sent
  703.  *  recv_id         [IN]        Id of recipient
  704.  *  recv_type       [IN]        Type of recipient
  705.  *  screen_name     [IN]        Screen name if exists
  706.  * RETURNS
  707.  *  void
  708.  *****************************************************************************/
  709. void mmi_imps_ps_send_msg_req(S32 msg_id, S16 *msg, U8 *recv_id, U8 recv_type, S8 *screen_name)
  710. {
  711.     /*----------------------------------------------------------------*/
  712.     /* Local Variables                                                */
  713.     /*----------------------------------------------------------------*/
  714.     mmi_imps_send_message_req_struct *req =
  715.         (mmi_imps_send_message_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_send_message_req_struct));
  716.     /*----------------------------------------------------------------*/
  717.     /* Code Body                                                      */
  718.     /*----------------------------------------------------------------*/
  719.     req->message_id = msg_id;
  720.     pfnUnicodeStrcpy((S8*) req->message_content, (S8*) msg);
  721.     req->recipients.entity_count = 1;
  722.     req->recipients.entity[0].entity_type = recv_type;
  723.     strcpy((S8*) req->recipients.entity[0].id, (S8*) recv_id);
  724.     if (screen_name)
  725.     {
  726.         pfnUnicodeStrcpy((S8*) req->recipients.entity[0].sname, screen_name);
  727.     }
  728.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_SEND_MESSAGE_REQ, req, NULL);
  729.     /* restore current action */
  730.     imps_p->gen_info.curr_action = 0;
  731. }
  732. /*****************************************************************************
  733.  * FUNCTION
  734.  *  mmi_imps_ps_send_msg_rsp
  735.  * DESCRIPTION
  736.  *  handler of MSG_ID_MMI_IMPS_SEND_MESSAGE_RSP
  737.  * PARAMETERS
  738.  *  msg     [IN]        Indication data
  739.  * RETURNS
  740.  *  void
  741.  *****************************************************************************/
  742. void mmi_imps_ps_send_msg_rsp(void *msg)
  743. {
  744.     /*----------------------------------------------------------------*/
  745.     /* Local Variables                                                */
  746.     /*----------------------------------------------------------------*/
  747.     mmi_imps_send_message_rsp_struct *rsp = (mmi_imps_send_message_rsp_struct*) msg;
  748.     S32 i;
  749.     mmi_imps_chat_session_struct *session = NULL;
  750.     /*----------------------------------------------------------------*/
  751.     /* Code Body                                                      */
  752.     /*----------------------------------------------------------------*/
  753.     /* logout or during logout period */
  754.     if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
  755.     {
  756.         return;
  757.     }
  758.     /* find session index of the message */
  759.     for (i = 0; i < IMPS_MAX_CHAT_MSG_COUNT; i++)
  760.     {
  761.         if (imps_p->chat_info.chat_session[i].session_id == rsp->message_id)
  762.         {
  763.             session = &imps_p->chat_info.chat_session[i];
  764.             break;
  765.         }
  766.     }
  767.     if (session)
  768.     {
  769.         if (rsp->result != IMPS_OK)
  770.         {
  771.             S32 room_index;
  772.             imps_entity_struct *entity = OslMalloc(sizeof(imps_entity_struct));
  773.             mmi_imps_room_struct *room;
  774.             room_index = mmi_imps_util_find_room((S8*) session->room_id);
  775.             room = &imps_p->room_info.room_list[room_index];
  776.             mmi_imps_chat_display_send_failed((U8) room_index, session->input_buff);
  777.             if (room->type == IMPS_ROOM_TYPE_SINGLE)    /* only single talk required */
  778.             {
  779.                 strcpy((S8*) entity->id, (S8*) room->member[0].id);
  780.                 mmi_imps_tab_update_event(room, entity);
  781.             }
  782.             else
  783.             {
  784.                 mmi_imps_tab_update_event(room, NULL);
  785.             }
  786.             OslMfree(entity);
  787.             mmi_imps_util_play_tone(IMPS_ERR_TONE);
  788.         }
  789.         /* reset session */
  790.         session->room_id[0] = 0;
  791.         session->session_id = 0;
  792.         session->input_buff[0] = 0;
  793.     }
  794. }
  795. #define GROUP_IMPS
  796. /*****************************************************************************
  797.  * FUNCTION
  798.  *  mmi_imps_ps_create_group_req
  799.  * DESCRIPTION
  800.  *  Send MSG_ID_MMI_IMPS_CREATE_GROUP_REQ to PS
  801.  * PARAMETERS
  802.  *  void
  803.  * RETURNS
  804.  *  void
  805.  *****************************************************************************/
  806. void mmi_imps_ps_create_group_req(void)
  807. {
  808.     /*----------------------------------------------------------------*/
  809.     /* Local Variables                                                */
  810.     /*----------------------------------------------------------------*/
  811.     mmi_imps_create_group_req_struct *req =
  812.         (mmi_imps_create_group_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_create_group_req_struct));
  813.     mmi_imps_room_inline_struct *inline_open_room = imps_p->room_info.inline_open_room;
  814.     /*----------------------------------------------------------------*/
  815.     /* Code Body                                                      */
  816.     /*----------------------------------------------------------------*/
  817.     IMPS_MEMSET(req, 0, mmi_imps_create_group_req_struct);
  818.     req->join_grouop = TRUE;
  819.     /* IMPS_ACCESS_TYPE_OPEN == 0 */
  820.     /* req->group_access_type = IMPS_ACCESS_TYPE_OPEN; */
  821.     UnicodeToAnsii((S8*) req->group_id, (S8*) inline_open_room->room_name);
  822.     sprintf((S8*) inline_open_room->room_id, "%s/%s", (S8*) imps_p->act_prof.username, (S8*) req->group_id);
  823.     memcpy(req->group_id, inline_open_room->room_id, IMPS_MAX_ID_LEN);
  824.     pfnUnicodeStrcpy((S8*) req->group_name, (S8*) inline_open_room->room_name);
  825.     if (pfnUnicodeStrlen((S8*) inline_open_room->topic))
  826.     {
  827.         pfnUnicodeStrcpy((S8*) req->group_topic, (S8*) inline_open_room->topic);
  828.     }
  829.     if (pfnUnicodeStrlen((S8*) inline_open_room->welcome))
  830.     {
  831.         pfnUnicodeStrcpy((S8*) req->welcome_note, (S8*) inline_open_room->welcome);
  832.     }
  833.     if (pfnUnicodeStrlen((S8*) inline_open_room->sname))
  834.     {
  835.         pfnUnicodeStrcpy((S8*) req->sname, (S8*) inline_open_room->sname);
  836.     }
  837.     req->subscribe_notif = TRUE;
  838.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_CREATE_GROUP_REQ, (void*)req, NULL);
  839. }
  840. /*****************************************************************************
  841.  * FUNCTION
  842.  *  mmi_imps_ps_create_group_rsp
  843.  * DESCRIPTION
  844.  *  Handler for MSG_ID_MMI_IMPS_CREATE_GROUP_RSP
  845.  * PARAMETERS
  846.  *  msg     [IN]        Indication data
  847.  * RETURNS
  848.  *  void
  849.  *****************************************************************************/
  850. void mmi_imps_ps_create_group_rsp(void *msg)
  851. {
  852.     /*----------------------------------------------------------------*/
  853.     /* Local Variables                                                */
  854.     /*----------------------------------------------------------------*/
  855.     mmi_imps_create_group_rsp_struct *rsp = (mmi_imps_create_group_rsp_struct*) msg;
  856.     /*----------------------------------------------------------------*/
  857.     /* Code Body                                                      */
  858.     /*----------------------------------------------------------------*/
  859.     /* restore current action */
  860.     imps_p->gen_info.curr_action = 0;
  861.     mmi_imps_room_create_finish(rsp->result);
  862. }
  863. /*****************************************************************************
  864.  * FUNCTION
  865.  *  mmi_imps_ps_join_group_req
  866.  * DESCRIPTION
  867.  *  Send MSG_ID_MMI_IMPS_JOIN_GROUP_REQ to PS
  868.  * PARAMETERS
  869.  *  id      [?]     
  870.  * RETURNS
  871.  *  void
  872.  *****************************************************************************/
  873. void mmi_imps_ps_join_group_req(S8 *id)
  874. {
  875.     /*----------------------------------------------------------------*/
  876.     /* Local Variables                                                */
  877.     /*----------------------------------------------------------------*/
  878.     mmi_imps_join_group_req_struct *req =
  879.         (mmi_imps_join_group_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_join_group_req_struct));
  880.     mmi_imps_join_inline_struct *inline_join = imps_p->room_info.inline_join;
  881.     /*----------------------------------------------------------------*/
  882.     /* Code Body                                                      */
  883.     /*----------------------------------------------------------------*/
  884.     req->user_auto_join_group = TRUE;
  885.     pfnUnicodeStrcpy((S8*) req->sname, (S8*) inline_join->sname);
  886.     strcpy((S8*) req->group_id, id);
  887.     if (inline_join->disclose_id == 0)
  888.     {
  889.         req->user_show_id = TRUE;
  890.     }
  891.     else
  892.     {
  893.         req->user_show_id = FALSE;
  894.     }
  895.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_JOIN_GROUP_REQ, req, NULL);
  896. }
  897. /*****************************************************************************
  898.  * FUNCTION
  899.  *  mmi_imps_ps_join_group_rsp
  900.  * DESCRIPTION
  901.  *  Response handler for MSG_ID_MMI_IMPS_JOIN_GROUP_RSP
  902.  * PARAMETERS
  903.  *  msg     [IN]        Indication data
  904.  * RETURNS
  905.  *  void
  906.  *****************************************************************************/
  907. void mmi_imps_ps_join_group_rsp(void *msg)
  908. {
  909.     /*----------------------------------------------------------------*/
  910.     /* Local Variables                                                */
  911.     /*----------------------------------------------------------------*/
  912.     /*----------------------------------------------------------------*/
  913.     /* Code Body                                                      */
  914.     /*----------------------------------------------------------------*/
  915.     /* restore current action */
  916.     imps_p->gen_info.curr_action = 0;
  917.     mmi_imps_join_room_finished(msg);
  918. }
  919. /*****************************************************************************
  920.  * FUNCTION
  921.  *  mmi_imps_ps_del_group_req
  922.  * DESCRIPTION
  923.  *  Send request to delete a group
  924.  * PARAMETERS
  925.  *  room_id     [IN]        Id of the room
  926.  * RETURNS
  927.  *  void
  928.  *****************************************************************************/
  929. void mmi_imps_ps_del_group_req(U8 *room_id)
  930. {
  931.     /*----------------------------------------------------------------*/
  932.     /* Local Variables                                                */
  933.     /*----------------------------------------------------------------*/
  934.     mmi_imps_delete_group_req_struct *req =
  935.         (mmi_imps_delete_group_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_delete_group_req_struct));
  936.     /*----------------------------------------------------------------*/
  937.     /* Code Body                                                      */
  938.     /*----------------------------------------------------------------*/
  939.     strcpy((S8*) req->group_id, (S8*) room_id);
  940.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_DELETE_GROUP_REQ, req, NULL);
  941. }
  942. /*****************************************************************************
  943.  * FUNCTION
  944.  *  mmi_imps_ps_del_group_rsp
  945.  * DESCRIPTION
  946.  *  Handler of MSG_ID_MMI_IMPS_DELETE_GROUP_RSP
  947.  * PARAMETERS
  948.  *  msg     [IN]        Indication data
  949.  * RETURNS
  950.  *  void
  951.  *****************************************************************************/
  952. void mmi_imps_ps_del_group_rsp(void *msg)
  953. {
  954.     /*----------------------------------------------------------------*/
  955.     /* Local Variables                                                */
  956.     /*----------------------------------------------------------------*/
  957.     mmi_imps_delete_group_rsp_struct *rsp = (mmi_imps_delete_group_rsp_struct*) msg;
  958.     /*----------------------------------------------------------------*/
  959.     /* Code Body                                                      */
  960.     /*----------------------------------------------------------------*/
  961.     /* restore current action */
  962.     imps_p->gen_info.curr_action = 0;
  963.     mmi_imps_close_chat_room_done(rsp->result);
  964. }
  965. /*****************************************************************************
  966.  * FUNCTION
  967.  *  mmi_imps_ps_leave_group_req
  968.  * DESCRIPTION
  969.  *  Send request to leave a group
  970.  * PARAMETERS
  971.  *  room_id     [IN]        Id of the room
  972.  * RETURNS
  973.  *  void
  974.  *****************************************************************************/
  975. void mmi_imps_ps_leave_group_req(U8 *room_id)
  976. {
  977.     /*----------------------------------------------------------------*/
  978.     /* Local Variables                                                */
  979.     /*----------------------------------------------------------------*/
  980.     mmi_imps_leave_group_req_struct *req =
  981.         (mmi_imps_leave_group_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_leave_group_req_struct));
  982.     /*----------------------------------------------------------------*/
  983.     /* Code Body                                                      */
  984.     /*----------------------------------------------------------------*/
  985.     strcpy((S8*) req->group_id, (S8*) room_id);
  986.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_LEAVE_GROUP_REQ, req, NULL);
  987. }
  988. /*****************************************************************************
  989.  * FUNCTION
  990.  *  mmi_imps_ps_leave_group_rsp
  991.  * DESCRIPTION
  992.  *  Response handler for MSG_ID_MMI_IMPS_LEAVE_GROUP_RSP
  993.  * PARAMETERS
  994.  *  msg     [IN]        Indication data
  995.  * RETURNS
  996.  *  void
  997.  *****************************************************************************/
  998. void mmi_imps_ps_leave_group_rsp(void *msg)
  999. {
  1000.     /*----------------------------------------------------------------*/
  1001.     /* Local Variables                                                */
  1002.     /*----------------------------------------------------------------*/
  1003.     mmi_imps_leave_group_rsp_struct *rsp = (mmi_imps_leave_group_rsp_struct*) msg;
  1004.     /*----------------------------------------------------------------*/
  1005.     /* Code Body                                                      */
  1006.     /*----------------------------------------------------------------*/
  1007.     /* restore current action */
  1008.     imps_p->gen_info.curr_action = 0;
  1009.     mmi_imps_close_chat_room_done((S32) rsp->result);
  1010. }
  1011. /*****************************************************************************
  1012.  * FUNCTION
  1013.  *  mmi_imps_ps_leave_group_ind
  1014.  * DESCRIPTION
  1015.  *  Handler for MSG_ID_MMI_IMPS_LEAVE_GROUP_IND
  1016.  * PARAMETERS
  1017.  *  msg     [IN]        Indication data
  1018.  * RETURNS
  1019.  *  void
  1020.  *****************************************************************************/
  1021. void mmi_imps_ps_leave_group_ind(void *msg)
  1022. {
  1023.     /*----------------------------------------------------------------*/
  1024.     /* Local Variables                                                */
  1025.     /*----------------------------------------------------------------*/
  1026.     mmi_imps_leave_group_ind_struct *ind = (mmi_imps_leave_group_ind_struct*) msg;
  1027.     mmi_imps_room_struct *room;
  1028.     S32 i;
  1029.     /*----------------------------------------------------------------*/
  1030.     /* Code Body                                                      */
  1031.     /*----------------------------------------------------------------*/
  1032.     /* find the chat room */
  1033.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1034.     {
  1035.         room = &imps_p->room_info.room_list[i];
  1036.         if (room->is_used)
  1037.         {
  1038.             if (room->type == IMPS_ROOM_TYPE_GROUP_CREATE || room->type == IMPS_ROOM_TYPE_GROUP_JOIN)
  1039.             {
  1040.                 if (mmi_imps_util_is_id_same((S8*) room->room_id, (S8*) ind->group_id))       /* chat room exists */
  1041.                 {
  1042.                     break;
  1043.                 }
  1044.             }
  1045.         }
  1046.     }
  1047.     if (i < IMPS_MAX_NO_ROOM)   /* room exists */
  1048.     {
  1049.         U16 scr_id = GetActiveScreenId();
  1050.         mmi_imps_util_disp_warning_popup(STR_ID_IMPS_CHAT_ROOM_CLOSE);
  1051.         if (scr_id == SCR_ID_IMPS_CHAT) /* in chatting screen */
  1052.         {
  1053.             /* if the room is current chatting room -- go to contact list screen */
  1054.             if (room->tab_index == imps_p->gen_info.curr_tab)
  1055.             {
  1056.                 HistoryReplace(SCR_ID_IMPS_CHAT, SCR_ID_IMPS_CONT, mmi_imps_pre_entry_cont);
  1057.             }
  1058.             /* else do nothing */
  1059.         }
  1060.         else if (scr_id == SCR_ID_IMPS_CONT)
  1061.         {
  1062.             /* do nothing */
  1063.         }
  1064.         else if (IsScreenPresent(SCR_ID_IMPS_CHAT)) /* chat screen is in history */
  1065.         {
  1066.             /* if the room is current chatting room -- go to contact list screen */
  1067.             if (room->tab_index == imps_p->gen_info.curr_tab)
  1068.             {
  1069.                 HistoryReplace(SCR_ID_IMPS_CHAT, SCR_ID_IMPS_CONT, mmi_imps_pre_entry_cont);
  1070.                 mmi_imps_util_del_up_to_screen(SCR_ID_IMPS_CONT);
  1071.             }
  1072.             /* else do nothing */
  1073.         }
  1074.         /* remove the tab of the chat room */
  1075.         if (room->tab_index == imps_p->gen_info.curr_tab)
  1076.         {
  1077.             mmi_imps_tab_del(room->tab_index, 0);
  1078.         }
  1079.         else
  1080.         {
  1081.             mmi_imps_tab_del(room->tab_index, imps_p->gen_info.curr_tab);
  1082.         }
  1083.         /* clear chat room */
  1084.         mmi_imps_room_reset_cntx(room);
  1085.         imps_p->room_info.no_rooms--;
  1086.         mmi_imps_util_update_status_icon();
  1087.         mmi_imps_util_play_tone(IMPS_MSG_TONE);
  1088.     }
  1089.     else
  1090.     {
  1091.         /* do nothing */
  1092.     }
  1093. }
  1094. /*****************************************************************************
  1095.  * FUNCTION
  1096.  *  mmi_imps_ps_group_change_ind
  1097.  * DESCRIPTION
  1098.  *  Handler for MSG_ID_MMI_IMPS_GROUP_CHANGE_NOTIFY_IND
  1099.  * PARAMETERS
  1100.  *  msg     [IN]        Indication data
  1101.  * RETURNS
  1102.  *  void
  1103.  *****************************************************************************/
  1104. void mmi_imps_ps_group_change_ind(void *msg)
  1105. {
  1106.     /*----------------------------------------------------------------*/
  1107.     /* Local Variables                                                */
  1108.     /*----------------------------------------------------------------*/
  1109.     mmi_imps_group_change_notify_ind_struct *ind = (mmi_imps_group_change_notify_ind_struct*) msg;
  1110.     mmi_imps_room_struct *room;
  1111.     imps_entity_struct *entity;
  1112.     S32 i, j, k, room_id;
  1113.     S32 count;
  1114.     /*----------------------------------------------------------------*/
  1115.     /* Code Body                                                      */
  1116.     /*----------------------------------------------------------------*/
  1117.     /* finding the chat room */
  1118.     for (room_id = 0; room_id < IMPS_MAX_NO_ROOM; room_id++)
  1119.     {
  1120.         room = &imps_p->room_info.room_list[room_id];
  1121.         /* if the room is an opened group chat room */
  1122.         if (room->is_used && (room->type == IMPS_ROOM_TYPE_GROUP_CREATE || room->type == IMPS_ROOM_TYPE_GROUP_JOIN))
  1123.         {
  1124.             if (mmi_imps_util_is_id_same((S8*) room->room_id, (S8*) ind->group_id))   /* chat room exists */
  1125.             {
  1126.                 break;
  1127.             }
  1128.         }
  1129.     }
  1130.     /* the group is not in the list */
  1131.     if (room_id == IMPS_MAX_NO_ROOM)
  1132.     {
  1133.         return;
  1134.     }
  1135.     /* change of name */
  1136.     if (ind->changed_props & IMPS_GROUP_NAME_CHANGED)
  1137.     {
  1138.         pfnUnicodeStrcpy((S8*) room->room_name, (S8*) ind->group_name);
  1139.     }
  1140.     if (ind->changed_props & IMPS_GROUP_TOPIC_CHANGED)
  1141.     {
  1142.         pfnUnicodeStrcpy((S8*) room->room_topic, (S8*) ind->group_topic);
  1143.     }
  1144.     /* process left user first to make more empty slot for joined users */
  1145.     if (ind->left_user_list.entity_count != 0)
  1146.     {
  1147.         count = (S32) ind->left_user_list.entity_count;
  1148.         for (i = 0; i < IMPS_MAX_ENTITY_NUMBER; i++)
  1149.         {
  1150.             /* if the member exists */
  1151.             if (strlen((S8*) room->member[i].id) || pfnUnicodeStrlen((S8*) room->member[i].sname))
  1152.             {
  1153.                 for (j = 0; j < (S32) ind->left_user_list.entity_count; j++)
  1154.                 {
  1155.                     /* found the left user */
  1156.                     if (mmi_imps_util_is_id_same((S8*) room->member[i].id, (S8*) ind->left_user_list.entity[j].id)
  1157.                         || pfnUnicodeStrcmp(
  1158.                             (S8*) room->member[i].sname,
  1159.                             (S8*) ind->left_user_list.entity[j].sname) == 0)
  1160.                     {
  1161.                         /* display left user */
  1162.                         mmi_imps_chat_disp_user_change_msg(room_id, &room->member[i], IMPS_ROOM_MEMBER_LEFT);
  1163.                         room->member[i].id[0] = 0;
  1164.                         room->member[i].sname[0] = 0;
  1165.                         room->no_member--;
  1166.                         /* all left users found, leave whole loop */
  1167.                         count--;
  1168.                         if (count == 0)
  1169.                         {
  1170.                             i = IMPS_MAX_ENTITY_NUMBER;
  1171.                         }
  1172.                         break;
  1173.                     }
  1174.                 }
  1175.             }
  1176.         }
  1177.     }
  1178.     /* process joined users */
  1179.     if (ind->joined_user_list.entity_count != 0)
  1180.     {
  1181.         count = (S32) ind->joined_user_list.entity_count;
  1182.         j = 0;
  1183.         for (i = 0; i < count; i++)
  1184.         {
  1185.             entity = &ind->joined_user_list.entity[i];
  1186.             /* check if contact already exists */
  1187.             for (k = 0; k < (S32) room->no_member; k++)
  1188.             {
  1189.                 if (entity->entity_type == IMPS_ENTITY_TYPE_USER)
  1190.                 {
  1191.                     if (mmi_imps_util_is_id_same((S8*) room->member[k].id, (S8*) entity->id) == TRUE)
  1192.                     {
  1193.                         break;
  1194.                     }
  1195.                 }
  1196.                 else if (entity->entity_type == IMPS_ENTITY_TYPE_SCREEN_NAME)
  1197.                 {
  1198.                     if (pfnUnicodeStrcmp((S8*) room->member[k].sname, (S8*) entity->sname) == 0)
  1199.                     {
  1200.                         break;
  1201.                     }
  1202.                 }
  1203.                 else
  1204.                 {
  1205.                     k = (S32) room->no_member;
  1206.                 }
  1207.             }
  1208.             if (k < (S32) room->no_member)  /* duplicated joined */
  1209.             {
  1210.                 continue;
  1211.             }
  1212.             /* find empty slot */
  1213.             for (; j < IMPS_MAX_ENTITY_NUMBER; j++)
  1214.             {
  1215.                 if (strlen((S8*) room->member[j].id) == 0)  /* empty slot found */
  1216.                 {
  1217.                     strcpy((S8*) room->member[j].id, (S8*) entity->id);
  1218.                     pfnUnicodeStrcpy((S8*) room->member[j].sname, (S8*) entity->sname);
  1219.                     /* display joined user */
  1220.                     mmi_imps_chat_disp_user_change_msg(room_id, &room->member[j], IMPS_ROOM_MEMBER_JOINED);
  1221.                     room->no_member++;
  1222.                     break;
  1223.                 }
  1224.             }
  1225.             if (j == IMPS_MAX_ENTITY_NUMBER)    /* no empty slot to store new-joined users */
  1226.             {
  1227.                 break;
  1228.             }
  1229.         }
  1230.     }
  1231.     /* refresh screen */
  1232.     mmi_imps_tab_update_event(room, NULL);
  1233.     mmi_imps_util_play_tone(IMPS_MSG_TONE);
  1234. }
  1235. /*****************************************************************************
  1236.  * FUNCTION
  1237.  *  mmi_imps_ps_invite_req
  1238.  * DESCRIPTION
  1239.  *  Send MSG_ID_MMI_IMPS_INVITE_REQ to PS
  1240.  * PARAMETERS
  1241.  *  id      [IN]        Index of session
  1242.  * RETURNS
  1243.  *  void
  1244.  *****************************************************************************/
  1245. void mmi_imps_ps_invite_req(S32 id)
  1246. {
  1247.     /*----------------------------------------------------------------*/
  1248.     /* Local Variables                                                */
  1249.     /*----------------------------------------------------------------*/
  1250.     mmi_imps_invite_req_struct *req;
  1251.     mmi_imps_room_struct *room;
  1252.     mmi_imps_cont_struct *cont;
  1253.     /*----------------------------------------------------------------*/
  1254.     /* Code Body                                                      */
  1255.     /*----------------------------------------------------------------*/
  1256.     req = (mmi_imps_invite_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_invite_req_struct));
  1257.     IMPS_MEMSET(req, 0, mmi_imps_invite_req_struct);
  1258.     room = &imps_p->room_info.room_list[imps_p->chat_info.curr_room];
  1259.     cont = &imps_p->cont_info.cont_list[imps_p->invite_info.invite_cand_list[imps_p->invite_info.curr_sel_cont]];
  1260.     req->invite_type = IMPS_INVITE_TYPE_GROUP;
  1261.     strcpy((S8*) req->group_id, (S8*) room->room_id);
  1262.     strcpy((S8*) req->recipient_id, (S8*) cont->id);
  1263.     if (pfnUnicodeStrlen((S8*) imps_p->path_buff))
  1264.     {
  1265.         pfnUnicodeStrcpy((S8*) req->invite_note, (S8*) imps_p->path_buff);
  1266.     }
  1267.     if (pfnUnicodeStrlen((S8*) room->sname))
  1268.     {
  1269.         pfnUnicodeStrcpy((S8*) req->self_sname, (S8*) room->sname);
  1270.     }
  1271.     req->invite_id = id;
  1272.     /* use protocol default timeout */
  1273.     req->invite_timeout = 0;
  1274.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_INVITE_REQ, req, NULL);
  1275.     /* restore current action */
  1276.     imps_p->gen_info.curr_action = 0;
  1277. }
  1278. /*****************************************************************************
  1279.  * FUNCTION
  1280.  *  mmi_imps_ps_invite_rsp
  1281.  * DESCRIPTION
  1282.  *  Response handler for MSG_ID_MMI_IMPS_INVITE_RSP
  1283.  * PARAMETERS
  1284.  *  msg     [IN]        Indication data
  1285.  * RETURNS
  1286.  *  void
  1287.  *****************************************************************************/
  1288. void mmi_imps_ps_invite_rsp(void *msg)
  1289. {
  1290.     /*----------------------------------------------------------------*/
  1291.     /* Local Variables                                                */
  1292.     /*----------------------------------------------------------------*/
  1293.     mmi_imps_invite_rsp_struct *rsp = (mmi_imps_invite_rsp_struct*) msg;
  1294.     /*----------------------------------------------------------------*/
  1295.     /* Code Body                                                      */
  1296.     /*----------------------------------------------------------------*/
  1297.     mmi_imps_invite_start(rsp->result, rsp->invite_id);
  1298.     /* restore current action */
  1299.     imps_p->gen_info.curr_action = 0;
  1300. }
  1301. /*****************************************************************************
  1302.  * FUNCTION
  1303.  *  mmi_imps_ps_invite_reply_req
  1304.  * DESCRIPTION
  1305.  *  Send MSG_ID_MMI_IMPS_INVITE_RES to remote server.
  1306.  * PARAMETERS
  1307.  *  accept      [IN]        Accept or not
  1308.  * RETURNS
  1309.  *  void
  1310.  *****************************************************************************/
  1311. void mmi_imps_ps_invite_reply_req(BOOL accept)
  1312. {
  1313.     /*----------------------------------------------------------------*/
  1314.     /* Local Variables                                                */
  1315.     /*----------------------------------------------------------------*/
  1316.     mmi_imps_invite_reply_req_struct *req = OslConstructDataPtr(sizeof(mmi_imps_invite_reply_req_struct));
  1317.     mmi_imps_invite_ind_struct *invitation =
  1318.         imps_p->invite_info.invite_pending_list[imps_p->invite_info.curr_pend_invite].node;
  1319.     /*----------------------------------------------------------------*/
  1320.     /* Code Body                                                      */
  1321.     /*----------------------------------------------------------------*/
  1322.     IMPS_MEMSET(req, 0, mmi_imps_invite_reply_req_struct);
  1323.     req->invite_type = invitation->invite_type;
  1324.     strcpy((S8*) req->invite_id, (S8*) invitation->invite_id);
  1325.     req->acceptance = accept;
  1326.     req->self_sname[0] = 0; /* set to NULL first */
  1327.     req->response_note[0] = 0;
  1328.     strcpy((S8*) req->recipient.id, (S8*) invitation->sender.id);
  1329.     req->recipient.entity_type = invitation->sender.entity_type;
  1330.     pfnUnicodeStrcpy((S8*) req->recipient.sname, (S8*) invitation->sender.sname);
  1331.     strcpy((S8*) req->group_id, (S8*) invitation->group_id);
  1332.     if (accept)
  1333.     {
  1334.         mmi_imps_join_inline_struct *inline_join = imps_p->room_info.inline_join;
  1335.         pfnUnicodeStrcpy((S8*) req->self_sname, (S8*) inline_join->sname);
  1336.         req->user_auto_join_group = TRUE;
  1337.         req->user_show_id = (MMI_BOOL) inline_join->disclose_id;
  1338.         SetProtocolEventHandler(mmi_imps_ps_invite_reply_rsp, MSG_ID_MMI_IMPS_INVITE_REPLY_RSP);
  1339.     }
  1340.     else
  1341.     {
  1342.         SetProtocolEventHandler(mmi_imps_ps_reject_invite_reply_rsp, MSG_ID_MMI_IMPS_INVITE_REPLY_RSP);
  1343.     }
  1344.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_INVITE_REPLY_REQ, (void*)req, NULL);
  1345. }
  1346. /*****************************************************************************
  1347.  * FUNCTION
  1348.  *  mmi_imps_ps_invite_reply_rsp
  1349.  * DESCRIPTION
  1350.  *  Response handler for MSG_ID_MMI_IMPS_INVITE_REPLY_RSP
  1351.  * PARAMETERS
  1352.  *  msg     [IN]        Indication data
  1353.  * RETURNS
  1354.  *  void
  1355.  *****************************************************************************/
  1356. void mmi_imps_ps_invite_reply_rsp(void *msg)
  1357. {
  1358.     /*----------------------------------------------------------------*/
  1359.     /* Local Variables                                                */
  1360.     /*----------------------------------------------------------------*/
  1361.     /*----------------------------------------------------------------*/
  1362.     /* Code Body                                                      */
  1363.     /*----------------------------------------------------------------*/
  1364.     /* logout or during logout period */
  1365.     if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
  1366.     {
  1367.         return;
  1368.     }
  1369.     /* restore current action */
  1370.     imps_p->gen_info.curr_action = 0;
  1371.     mmi_imps_join_room_finished(msg);
  1372.     /* release the holding local parameter */
  1373.     mmi_imps_invite_ind_release_node();
  1374. }
  1375. /*****************************************************************************
  1376.  * FUNCTION
  1377.  *  mmi_imps_ps_reject_invite_reply_rsp
  1378.  * DESCRIPTION
  1379.  *  Response handler for MSG_ID_MMI_IMPS_INVITE_REPLY_RSP
  1380.  * PARAMETERS
  1381.  *  msg     [IN]        Indication data
  1382.  * RETURNS
  1383.  *  void
  1384.  *****************************************************************************/
  1385. void mmi_imps_ps_reject_invite_reply_rsp(void *msg)
  1386. {
  1387.     /*----------------------------------------------------------------*/
  1388.     /* Local Variables                                                */
  1389.     /*----------------------------------------------------------------*/
  1390.     /*----------------------------------------------------------------*/
  1391.     /* Code Body                                                      */
  1392.     /*----------------------------------------------------------------*/
  1393.     mmi_imps_util_disp_popup_done();
  1394.     
  1395.     /* restore current action */
  1396.     imps_p->gen_info.curr_action = 0;    
  1397.     mmi_imps_util_del_scr_after_progress(SCR_ID_IMPS_CONT);
  1398.     /* release the holding local parameter */
  1399.     mmi_imps_invite_ind_release_node();
  1400. }
  1401. /*****************************************************************************
  1402.  * FUNCTION
  1403.  *  mmi_imps_ps_invite_response_ind
  1404.  * DESCRIPTION
  1405.  *  Response handler for MSG_ID_MMI_IMPS_INVITE_RESPONSE_IND
  1406.  * PARAMETERS
  1407.  *  msg     [IN]        Indication data
  1408.  * RETURNS
  1409.  *  void
  1410.  *****************************************************************************/
  1411. void mmi_imps_ps_invite_response_ind(void *msg)
  1412. {
  1413.     /*----------------------------------------------------------------*/
  1414.     /* Local Variables                                                */
  1415.     /*----------------------------------------------------------------*/
  1416.     mmi_imps_invite_response_ind_struct *rsp = (mmi_imps_invite_response_ind_struct*) msg;
  1417.     /*----------------------------------------------------------------*/
  1418.     /* Code Body                                                      */
  1419.     /*----------------------------------------------------------------*/
  1420.     /* logout or during logout period */
  1421.     if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
  1422.     {
  1423.         return;
  1424.     }
  1425.     /* call response handler for the user */
  1426.     mmi_imps_invite_finish((BOOL) rsp->acceptance, (S32) rsp->invite_id, &rsp->sender, (U16*) rsp->response_note);
  1427. }
  1428. /*****************************************************************************
  1429.  * FUNCTION
  1430.  *  mmi_imps_ps_invite_ind
  1431.  * DESCRIPTION
  1432.  *  Handler for MSG_ID_MMI_IMPS_INVITE_IND
  1433.  * PARAMETERS
  1434.  *  msg     [IN]        Indication data
  1435.  * RETURNS
  1436.  *  void
  1437.  *****************************************************************************/
  1438. void mmi_imps_ps_invite_ind(void *msg)
  1439. {
  1440.     /*----------------------------------------------------------------*/
  1441.     /* Local Variables                                                */
  1442.     /*----------------------------------------------------------------*/
  1443.     mmi_imps_invite_info_struct *invite = &imps_p->invite_info;
  1444.     mmi_imps_invite_ind_struct *invite_ind = (mmi_imps_invite_ind_struct*) msg;
  1445.     S32 i, j;
  1446.     /*----------------------------------------------------------------*/
  1447.     /* Code Body                                                      */
  1448.     /*----------------------------------------------------------------*/
  1449.     /* logout or during logout period */
  1450.     if (imps_p->gen_info.curr_action == MSG_ID_MMI_IMPS_LOGOUT_REQ || imps_p->gen_info.is_login == FALSE)
  1451.     {
  1452.         return;
  1453.     }
  1454.     /* check if the user has joined the room of invitation */
  1455.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1456.     {
  1457.         /* if the user has already joined the chat room */
  1458.         if (mmi_imps_util_is_id_same((S8*) invite_ind->group_id, (S8*) imps_p->room_info.room_list[i].room_id))
  1459.         {
  1460.             return;
  1461.         }
  1462.     }
  1463.     i = (S32) invite->curr_pend_invite;
  1464.     /* store the invitation */
  1465.     for (j = 0; j < IMPS_MAX_PEND_INVITATION; j++, i++)
  1466.     {
  1467.         if (invite->invite_pending_list[i].node == NULL)    /* empty slot */
  1468.         {
  1469.             invite->invite_pending_list[i].node = msg;
  1470.             hold_local_para((local_para_struct*) msg);
  1471.             DTGetRTCTime(&invite->invite_pending_list[i].time_stamp);
  1472.             break;
  1473.         }
  1474.         /* to maintain circular queue */
  1475.         if (i == IMPS_MAX_PEND_INVITATION)
  1476.         {
  1477.             i = 0;
  1478.         }
  1479.     }
  1480.     if (j < IMPS_MAX_PEND_INVITATION)   /* some empty slot here */
  1481.     {
  1482.         U16 curr_scr = GetActiveScreenId();
  1483.         if (mmi_imps_util_is_in_imps() && curr_scr != SCR_ID_IMPS_INVITATION_IND)
  1484.         {
  1485.             mmi_imps_check_pending_invite();
  1486.         }
  1487.         else
  1488.         {
  1489.             invite->reminder_flag = TRUE;
  1490.             if (mmi_imps_util_is_on_idle())
  1491.             {
  1492.                 mmi_imps_entry_invite_reminder();
  1493.             }
  1494.             else if (curr_scr != SCR_ID_IMPS_INVITATION_IND)    /* to prevent unnecessary popup */
  1495.             {
  1496.                 mmi_imps_util_disp_warning_popup(STR_ID_IMPS_NEW_INVITATION);
  1497.             }
  1498.         }
  1499.     }
  1500. }
  1501. #define MISC_IMPS
  1502. /*****************************************************************************
  1503.  * FUNCTION
  1504.  *  mmi_imps_ps_server_disconn_ind
  1505.  * DESCRIPTION
  1506.  *  Handler for MSG_ID_MMI_IMPS_DISCONNECT_IND
  1507.  * PARAMETERS
  1508.  *  msg     [IN]        Indication data
  1509.  * RETURNS
  1510.  *  void
  1511.  *****************************************************************************/
  1512. void mmi_imps_ps_server_disconn_ind(void *msg)
  1513. {
  1514.     /*----------------------------------------------------------------*/
  1515.     /* Local Variables                                                */
  1516.     /*----------------------------------------------------------------*/
  1517.     BOOL cont_scr;
  1518.     BOOL chat_scr;
  1519.     /*----------------------------------------------------------------*/
  1520.     /* Code Body                                                      */
  1521.     /*----------------------------------------------------------------*/
  1522.     /* reset action_id */
  1523.     imps_p->gen_info.curr_action = 0;
  1524.     if (imps_p->gen_info.is_login == TRUE)
  1525.     {
  1526.         DisplayPopup(
  1527.             (U8*) GetString(STR_ID_IMPS_SERVER_DISCONNECT),
  1528.             IMG_GLOBAL_WARNING,
  1529.             1,
  1530.             UI_POPUP_NOTIFYDURATION_TIME,
  1531.             (U8) WARNING_TONE);
  1532.         cont_scr = IsScreenPresent(SCR_ID_IMPS_CONT);
  1533.         chat_scr = IsScreenPresent(SCR_ID_IMPS_CHAT);
  1534.         if (cont_scr)   /* contact list screen */
  1535.         {
  1536.             HistoryReplace(SCR_ID_IMPS_CONT, SCR_ID_IMPS_MAIN, mmi_imps_entry_main);
  1537.             mmi_imps_util_del_up_to_screen(SCR_ID_IMPS_MAIN);
  1538.         }
  1539.         else if (chat_scr)  /* chat screen */
  1540.         {
  1541.             HistoryReplace(SCR_ID_IMPS_CHAT, SCR_ID_IMPS_MAIN, mmi_imps_entry_main);
  1542.             mmi_imps_util_del_up_to_screen(SCR_ID_IMPS_MAIN);
  1543.         }
  1544.         else
  1545.         {
  1546.             /* not in IMPS applpication, do nothing */
  1547.         }
  1548.     }
  1549.     mmi_imps_util_free_buff_when_logout();
  1550.     mmi_imps_reset_cntx();
  1551.     mmi_imps_util_update_login_icon();
  1552. }
  1553. /*****************************************************************************
  1554.  * FUNCTION
  1555.  *  mmi_imps_ps_ready_ind
  1556.  * DESCRIPTION
  1557.  *  Handler of IMPS task ready indication
  1558.  * PARAMETERS
  1559.  *  msg     [IN]        Indication data
  1560.  * RETURNS
  1561.  *  void
  1562.  *****************************************************************************/
  1563. void mmi_imps_ps_ready_ind(void *msg)
  1564. {
  1565.     /*----------------------------------------------------------------*/
  1566.     /* Local Variables                                                */
  1567.     /*----------------------------------------------------------------*/
  1568.     /*----------------------------------------------------------------*/
  1569.     /* Code Body                                                      */
  1570.     /*----------------------------------------------------------------*/
  1571.     imps_p->gen_info.ps_ready_state |= IMPS_LOGIN_PS_READY;
  1572.     /* because WiFi does not have and indication for now, we can not prevent 
  1573.        the user to use IMPS without RAC ready, because WiFi can be used. 
  1574.        A termporary solution would be add the RAC ready when PS ready.
  1575.     */
  1576. /* #ifndef __MTK_TARGET__ */
  1577.     imps_p->gen_info.ps_ready_state |= IMPS_LOGIN_RAC_READY;
  1578. /* #endif  */
  1579.     mmi_imps_auto_login();
  1580. }
  1581. #ifdef IMPS_FOR_OMA_ONLY
  1582. /*****************************************************************************
  1583.  * FUNCTION
  1584.  *  mmi_imps_ps_broadcast_msg_req
  1585.  * DESCRIPTION
  1586.  *  Braodcast message to a group
  1587.  * PARAMETERS
  1588.  *  group_index     [IN]        Index of group
  1589.  *  msg             [?]         
  1590.  * RETURNS
  1591.  *  void
  1592.  *****************************************************************************/
  1593. void mmi_imps_ps_broadcast_msg_req(S32 group_index, S8 *msg)
  1594. {
  1595.     /*----------------------------------------------------------------*/
  1596.     /* Local Variables                                                */
  1597.     /*----------------------------------------------------------------*/
  1598.     mmi_imps_send_message_req_struct *req =
  1599.         (mmi_imps_send_message_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_send_message_req_struct));
  1600.     S32 i, count;
  1601.     S32 no_cont = (S32) imps_p->cont_info.no_cont;
  1602.     U8 *group_id = &imps_p->group_info.group_list[group_index].group_id[0];
  1603.     /*----------------------------------------------------------------*/
  1604.     /* Code Body                                                      */
  1605.     /*----------------------------------------------------------------*/
  1606.     req->message_id = 0;
  1607.     pfnUnicodeStrcpy((S8*) req->message_content, msg);
  1608.     for (i = 0, count = 0; i < no_cont; i++)
  1609.     {
  1610.         mmi_imps_cont_struct *cont = &imps_p->cont_info.cont_list[i];
  1611.         if (mmi_imps_util_is_id_same((S8*) cont->group_id, (S8*) group_id))
  1612.         {
  1613.             req->recipients.entity[count].entity_type = IMPS_ENTITY_TYPE_USER;
  1614.             strcpy((S8*) req->recipients.entity[count].id, (S8*) cont->id);
  1615.             count++;
  1616.         }
  1617.     }
  1618.     req->recipients.entity_count = (U8) count;
  1619.     SetProtocolEventHandler(mmi_imps_ps_broadcast_msg_rsp, MSG_ID_MMI_IMPS_SEND_MESSAGE_RSP);
  1620.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_SEND_MESSAGE_REQ, req, NULL);
  1621.     imps_p->gen_info.curr_action = 0;
  1622. }
  1623. /*****************************************************************************
  1624.  * FUNCTION
  1625.  *  mmi_imps_ps_broadcast_msg_rsp
  1626.  * DESCRIPTION
  1627.  *  Response handler of braodcasting message to a group
  1628.  * PARAMETERS
  1629.  *  msg     [IN]        Message of response
  1630.  * RETURNS
  1631.  *  void
  1632.  *****************************************************************************/
  1633. void mmi_imps_ps_broadcast_msg_rsp(void *msg)
  1634. {
  1635.     /*----------------------------------------------------------------*/
  1636.     /* Local Variables                                                */
  1637.     /*----------------------------------------------------------------*/
  1638.     /*----------------------------------------------------------------*/
  1639.     /* Code Body                                                      */
  1640.     /*----------------------------------------------------------------*/
  1641.     SetProtocolEventHandler(mmi_imps_ps_send_msg_rsp, MSG_ID_MMI_IMPS_SEND_MESSAGE_RSP);
  1642.     mmi_imps_group_broadcast_finished();
  1643. }
  1644. /*****************************************************************************
  1645.  * FUNCTION
  1646.  *  mmi_imps_ps_subs_pa_rsp
  1647.  * DESCRIPTION
  1648.  *  Handler for MSG_ID_MMI_IMPS_SUBS_PA_RSP
  1649.  * PARAMETERS
  1650.  *  msg     [IN]        Result of response
  1651.  * RETURNS
  1652.  *  void
  1653.  *****************************************************************************/
  1654. void mmi_imps_ps_subs_pa_rsp(void *msg)
  1655. {
  1656.     /*----------------------------------------------------------------*/
  1657.     /* Local Variables                                                */
  1658.     /*----------------------------------------------------------------*/
  1659.     mmi_imps_subs_pa_rsp_struct *rsp = (mmi_imps_subs_pa_rsp_struct*) msg;
  1660.     /*----------------------------------------------------------------*/
  1661.     /* Code Body                                                      */
  1662.     /*----------------------------------------------------------------*/
  1663.     mmi_imps_subscribe_pa_finished(rsp->result);
  1664. }
  1665. /*****************************************************************************
  1666.  * FUNCTION
  1667.  *  mmi_imps_ps_subs_pa_req
  1668.  * DESCRIPTION
  1669.  *  Send MSG_ID_MMI_IMPS_SUBS_PA_REQ to PS
  1670.  * PARAMETERS
  1671.  *  id      [IN]        Id of contact to subscribe
  1672.  * RETURNS
  1673.  *  void
  1674.  *****************************************************************************/
  1675. void mmi_imps_ps_subs_pa_req(S8 *id)
  1676. {
  1677.     /*----------------------------------------------------------------*/
  1678.     /* Local Variables                                                */
  1679.     /*----------------------------------------------------------------*/
  1680.     mmi_imps_subs_pa_req_struct *req =
  1681.         (mmi_imps_subs_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_subs_pa_req_struct));
  1682.     /*----------------------------------------------------------------*/
  1683.     /* Code Body                                                      */
  1684.     /*----------------------------------------------------------------*/
  1685.     imps_p->gen_info.curr_action = 0;
  1686.     IMPS_MEMSET(req, 0, mmi_imps_subs_pa_req_struct);
  1687.     req->subscribe_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
  1688.     req->id_list.entity_count = 1;
  1689.     req->id_list.entity[0].entity_type = IMPS_ENTITY_TYPE_USER;
  1690.     strcpy((S8*) req->id_list.entity[0].id, (S8*) id);
  1691.     SetProtocolEventHandler(mmi_imps_ps_subs_pa_rsp, MSG_ID_MMI_IMPS_SUBS_PA_RSP);
  1692.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_SUBS_PA_REQ, req, NULL);
  1693. }
  1694. /*****************************************************************************
  1695.  * FUNCTION
  1696.  *  mmi_imps_ps_unsubs_pa_req
  1697.  * DESCRIPTION
  1698.  *  Send MSG_ID_MMI_IMPS_UNSUBS_PA_REQ to PS
  1699.  * PARAMETERS
  1700.  *  id      [IN]        Id of contact to unsubscribe
  1701.  * RETURNS
  1702.  *  void
  1703.  *****************************************************************************/
  1704. void mmi_imps_ps_unsubs_pa_req(S8 *id)
  1705. {
  1706.     /*----------------------------------------------------------------*/
  1707.     /* Local Variables                                                */
  1708.     /*----------------------------------------------------------------*/
  1709.     mmi_imps_unsubs_pa_req_struct *req =
  1710.         (mmi_imps_unsubs_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_unsubs_pa_req_struct));
  1711.     /*----------------------------------------------------------------*/
  1712.     /* Code Body                                                      */
  1713.     /*----------------------------------------------------------------*/
  1714.     imps_p->gen_info.curr_action = 0;
  1715.     IMPS_MEMSET(req, 0, mmi_imps_unsubs_pa_req_struct);
  1716.     req->user_id_list.entity_count = 1;
  1717.     req->user_id_list.entity[0].entity_type = IMPS_ENTITY_TYPE_USER;
  1718.     strcpy((S8*) req->user_id_list.entity[0].id, (S8*) id);
  1719.     SetProtocolEventHandler(mmi_imps_ps_subs_pa_rsp, MSG_ID_MMI_IMPS_UNSUBS_PA_RSP);
  1720.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_UNSUBS_PA_REQ, req, NULL);
  1721. }
  1722. /*****************************************************************************
  1723.  * FUNCTION
  1724.  *  mmi_imps_ps_subs_group_pa_rsp
  1725.  * DESCRIPTION
  1726.  *  Handler for mmi_imps_ps_subs_group_pa_rsp
  1727.  * PARAMETERS
  1728.  *  msg     [IN]        Result of response
  1729.  * RETURNS
  1730.  *  void
  1731.  *****************************************************************************/
  1732. void mmi_imps_ps_subs_group_pa_rsp(void *msg)
  1733. {
  1734.     /*----------------------------------------------------------------*/
  1735.     /* Local Variables                                                */
  1736.     /*----------------------------------------------------------------*/
  1737.     mmi_imps_subs_pa_rsp_struct *rsp = (mmi_imps_subs_pa_rsp_struct*) msg;
  1738.     /*----------------------------------------------------------------*/
  1739.     /* Code Body                                                      */
  1740.     /*----------------------------------------------------------------*/
  1741.     mmi_imps_util_disp_popup_done();
  1742.     DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
  1743. }
  1744. /*****************************************************************************
  1745.  * FUNCTION
  1746.  *  mmi_imps_ps_subs_group_pa_req
  1747.  * DESCRIPTION
  1748.  *  
  1749.  * PARAMETERS
  1750.  *  id      [?]     
  1751.  * RETURNS
  1752.  *  void
  1753.  *****************************************************************************/
  1754. void mmi_imps_ps_subs_group_pa_req(U8 *id)
  1755. {
  1756.     /*----------------------------------------------------------------*/
  1757.     /* Local Variables                                                */
  1758.     /*----------------------------------------------------------------*/
  1759.     mmi_imps_subs_pa_req_struct *req =
  1760.         (mmi_imps_subs_pa_req_struct*) OslConstructDataPtr(sizeof(mmi_imps_subs_pa_req_struct));
  1761.     /*----------------------------------------------------------------*/
  1762.     /* Code Body                                                      */
  1763.     /*----------------------------------------------------------------*/
  1764.     imps_p->gen_info.curr_action = 0;
  1765.     IMPS_MEMSET(req, 0, mmi_imps_subs_pa_req_struct);
  1766.     req->subscribe_pa = IMPS_PA_ATTR_VALUE_NO_PIC;
  1767.     req->id_list.entity_count = 1;
  1768.     req->id_list.entity[0].entity_type = IMPS_ENTITY_TYPE_CONTACT_LIST;
  1769.     strcpy((S8*) req->id_list.entity[0].id, (S8*) id);
  1770.     SetProtocolEventHandler(mmi_imps_ps_subs_group_pa_rsp, MSG_ID_MMI_IMPS_SUBS_PA_RSP);
  1771.     mmi_imps_ps_send_msg(MSG_ID_MMI_IMPS_SUBS_PA_REQ, req, NULL);
  1772. }
  1773. #endif /* IMPS_FOR_OMA_ONLY */ 
  1774. #endif /* MMI_ON_HARDWARE_P */ 
  1775. #endif /* __MMI_IMPS__ */ /* #ifdef __MMI_IMPS__ */
  1776. #endif /* _MMI_IMPS_PS_C */