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

MTK

开发平台:

C/C++

  1.             }
  2.         }
  3.         else
  4.         {
  5.             mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  6.             mmi_frm_sms_free_savesms_data();
  7.             return;
  8.         }
  9.     }
  10.     else if (saveSMS->string != NULL && saveSMS->stringlength > 0)
  11.     {
  12.         textbufucs2 = OslMalloc((saveSMS->stringlength) * ENCODING_LENGTH);
  13.         memset((S8*) textbufucs2, 0, ((saveSMS->stringlength) * ENCODING_LENGTH));
  14.         memcpy(textbufucs2, saveSMS->string, ((saveSMS->stringlength) * ENCODING_LENGTH));
  15.     }
  16.     if (textbufucs2)
  17.     {
  18.         EMSTATUS EMSSetPortResult = EMS_OK;
  19.         EMSTATUS EMSSetClassResult = EMS_OK;
  20.         ReleaseEMSEditBuffer();
  21.         pEMS = GetEMSDataForEdit(0, 1);
  22.     #ifdef MMI_ON_HARDWARE_P
  23.         if ((saveSMS->sendrequire & MMI_FRM_SMS_SAVE_PORT) == MMI_FRM_SMS_SAVE_PORT)
  24.         {
  25.             EMSSetPortResult = EMSSetPortNum(pEMS, saveSMS->srcport, saveSMS->desport);
  26.         }
  27.         if ((saveSMS->sendrequire & MMI_FRM_SMS_SAVE_CLASS) == MMI_FRM_SMS_SAVE_CLASS)
  28.         {
  29.             EMSSetClassResult = EMSSetMsgClass(pEMS, saveSMS->dcs_class);
  30.         }
  31.         if ((EMSSetPortResult != EMS_OK) || (EMSSetClassResult != EMS_OK))
  32.         {
  33.             mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ERROR);
  34.             mmi_frm_sms_free_savesms_data();
  35.             OslMfree(textbufucs2);
  36.             return;
  37.         }
  38.     #endif /* MMI_ON_HARDWARE_P */ 
  39.         if (saveSMS->filename != NULL)
  40.         {
  41.             result = AppendEMSString(
  42.                         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  43.                         pEMS,
  44.                         (U8*) textbufucs2,
  45.                         saveSMS->dcs,
  46.                         temphistory.guiBuffer);
  47.         }
  48.         else if (saveSMS->string != NULL)
  49.         {
  50.             EMSSetDCS(pEMS, saveSMS->dcs);
  51.             result = AddString(pEMS, (U8*) textbufucs2, saveSMS->stringlength, NULL);
  52.         }
  53.         OslMfree(textbufucs2);
  54.         if ((saveSMS->filename != NULL && result == 0) || (saveSMS->string != NULL && result != EMS_OK))
  55.         {
  56.             mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
  57.             mmi_frm_sms_free_savesms_data();
  58.             return;
  59.         }
  60.     }
  61.     /* JP added to save a NSm message */
  62. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  63.     if (saveSMS->desport == 0x158A)
  64.     {
  65.         EMSData *pEMS = NULL;
  66.         ReleaseEMSEditBuffer();
  67.         pEMS = GetEMSDataForEdit(0, 0);
  68.         EMSSetPortNum(pEMS, saveSMS->srcport, saveSMS->desport);
  69.         EMSSetDCS(pEMS, saveSMS->dcs);
  70.         AddString(pEMS, (U8*) saveSMS->string, saveSMS->stringlength, NULL);
  71.     }
  72. #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  73.     result = mmi_frm_sms_pack_sms();
  74.     if (result != EMS_OK)
  75.     {
  76.         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  77.         mmi_frm_sms_free_savesms_data();
  78.     }
  79.     else
  80.     {
  81.         PendingSaveSendData.nextSegment = 0;
  82.         PendingSaveSendData.presentSegments = 0;
  83.         GetDateTime(&sms_saved_time);
  84.         if (saveSMS->sendrequire & MMI_FRM_SMS_SAVE_DISPLAY_SAVING_SCREEN)
  85.         {
  86.             mmi_frm_sms_entry_save();
  87.         }
  88.         mmi_frm_sms_save_sms_seg();
  89.     }
  90. }
  91. /* loop handle */
  92. /*****************************************************************************
  93.  * FUNCTION
  94.  *  mmi_frm_sms_read_sms_rsp
  95.  * DESCRIPTION
  96.  *  Read SMS response
  97.  * PARAMETERS
  98.  *  inMsg       [IN]        Input message
  99.  * RETURNS
  100.  *  void
  101.  *****************************************************************************/
  102. void mmi_frm_sms_read_sms_rsp(void *inMsg)
  103. {
  104.     /*----------------------------------------------------------------*/
  105.     /* Local Variables                                                */
  106.     /*----------------------------------------------------------------*/
  107.     MMI_FRM_SMS_GET_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_RSP_STRUCT*) inMsg;
  108.     U16 result = MMI_FRM_SMS_ERROR;
  109.     U8 type;
  110.     /*----------------------------------------------------------------*/
  111.     /* Code Body                                                      */
  112.     /*----------------------------------------------------------------*/
  113.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
  114.     if (msgRsp->result == TRUE)
  115.     {
  116.         memcpy(PendingSaveSendData.TPUD_p[PendingSaveSendData.presentSegments], msgRsp->msg_data, msgRsp->no_msg_data);
  117.         PendingSaveSendData.TPUDLen[PendingSaveSendData.presentSegments] = (U8) msgRsp->no_msg_data;
  118.         PendingSaveSendData.TPUD_udhi[PendingSaveSendData.presentSegments] = (U8) GetUDHIBit(msgRsp->fo);
  119.         PendingSaveSendData.mti = msgRsp->mti;
  120.         PendingSaveSendData.dcs = msgRsp->dcs;
  121.         PendingSaveSendData.st = msgRsp->st;
  122.     }
  123.     else
  124.     {
  125.         PendingSaveSendData.TPUD_p[PendingSaveSendData.presentSegments] = NULL;
  126.         PendingSaveSendData.TPUDLen[PendingSaveSendData.presentSegments] = 0;
  127.         PendingSaveSendData.TPUD_udhi[PendingSaveSendData.presentSegments] = KAL_FALSE;
  128.     }
  129.     if (PendingSaveSendData.nextSegment < PendingSaveSendData.totalSegments && mmi_frm_sms_read_sms_seg() == TRUE)
  130.     {
  131.         return;
  132.     }
  133.     else
  134.     {
  135.         result = MMI_FRM_SMS_OK;
  136.         if (msgRsp->result == TRUE)
  137.         {
  138.             switch (msgRsp->status)
  139.             {
  140.                 case SMSAL_REC_UNREAD:
  141.                     type = (msgRsp->mti << 4) | MMI_FRM_SMS_UNREAD;
  142.                     break;
  143.                 case SMSAL_REC_READ:
  144.                     type = (msgRsp->mti << 4) | MMI_FRM_SMS_INBOX;
  145.                     break;
  146.                 case SMSAL_STO_SENT:
  147.                     type = (msgRsp->mti << 4) | MMI_FRM_SMS_OUTBOX;
  148.                     break;
  149.                 case SMSAL_STO_UNSENT:
  150.                     type = (msgRsp->mti << 4) | MMI_FRM_SMS_DRAFTS;
  151.                     break;
  152.             }
  153.             mmi_frm_sms_unpack_sms(msgRsp->dcs, msgRsp->fo, msgRsp->ori_dcs);    /* change pendingsavesenddata struct */
  154.         }
  155.         else
  156.         {
  157.             PendingSaveSendData.mti = SMSAL_MTI_UNSPECIFIED;
  158.             type = (SMSAL_MTI_UNSPECIFIED << 4) | MMI_FRM_SMS_NOBOX;
  159.         }
  160.         mmi_frm_sms_callback_action(&type, result);
  161.     }
  162. }
  163. /*****************************************************************************
  164.  * FUNCTION
  165.  *  mmi_frm_sms_read_sms_seg
  166.  * DESCRIPTION
  167.  *  Read SMS segment
  168.  * PARAMETERS
  169.  *  void
  170.  * RETURNS
  171.  *  void
  172.  *****************************************************************************/
  173. U8 mmi_frm_sms_read_sms_seg(void)
  174. {
  175.     /*----------------------------------------------------------------*/
  176.     /* Local Variables                                                */
  177.     /*----------------------------------------------------------------*/
  178.     /*----------------------------------------------------------------*/
  179.     /* Code Body                                                      */
  180.     /*----------------------------------------------------------------*/
  181.     while (PendingSaveSendData.nextSegment < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size)
  182.     {
  183.         if (PendingSaveSendData.l4index[PendingSaveSendData.nextSegment] != MMI_FRM_SMS_INVALID_INDEX)
  184.         {
  185.             MMI_FRM_SMS_GET_MSG_REQ_STRUCT *msgReq;
  186.             msgReq = (MMI_FRM_SMS_GET_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  187.             msgReq->index = PendingSaveSendData.l4index[PendingSaveSendData.nextSegment];
  188.             msgReq->change_status = g_mmi_frm_sms_change_status;
  189.             SetProtocolEventHandler(mmi_frm_sms_read_sms_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
  190.             mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_REQ, (oslParaType*) msgReq, NULL);
  191.             PendingSaveSendData.presentSegments = PendingSaveSendData.nextSegment;
  192.             PendingSaveSendData.nextSegment++;
  193.             return TRUE;
  194.         }
  195.         PendingSaveSendData.nextSegment++;
  196.     }
  197.     return FALSE;
  198. }
  199. /*****************************************************************************
  200.  * FUNCTION
  201.  *  mmi_frm_sms_read_sms_req
  202.  * DESCRIPTION
  203.  *  Read SMS request
  204.  * PARAMETERS
  205.  *  inMsg       [IN]        Input message
  206.  * RETURNS
  207.  *  void
  208.  *****************************************************************************/
  209. void mmi_frm_sms_read_sms_req(void *inMsg)
  210. {
  211.     /*----------------------------------------------------------------*/
  212.     /* Local Variables                                                */
  213.     /*----------------------------------------------------------------*/
  214.     U16 *index = (U16*) inMsg;
  215.     U8 segment = 0;
  216.     /*----------------------------------------------------------------*/
  217.     /* Code Body                                                      */
  218.     /*----------------------------------------------------------------*/
  219.     for (segment = 0; segment < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size; segment++)
  220.     {
  221.         PendingSaveSendData.l4index[segment] = index[segment];
  222.         PendingSaveSendData.TPUD_udhi[segment] = 0;
  223.         PendingSaveSendData.TPUDLen[segment] = 0;
  224.         PendingSaveSendData.TPUD_p[segment] = &PendingSaveSendData.TPUD[segment * MMI_FRM_SMS_MSG_LEN];
  225.     }
  226.     PendingSaveSendData.totalSegments = (U8) index[g_frm_sms_cntx.mmi_frm_sms_msg_seg_size];
  227.     OslMfree(inMsg);
  228.     PendingSaveSendData.dcs = 0;
  229.     PendingSaveSendData.nextSegment = 0;
  230.     PendingSaveSendData.presentSegments = 0;
  231.     mmi_frm_sms_read_sms_seg();
  232. }
  233. /*****************************************************************************
  234.  * FUNCTION
  235.  *  mmi_frm_sms_get_sms_rsp
  236.  * DESCRIPTION
  237.  *  Get SMS response: update message box
  238.  * PARAMETERS
  239.  *  inMsg       [IN]        Input message
  240.  * RETURNS
  241.  *  void
  242.  *****************************************************************************/
  243. void mmi_frm_sms_get_sms_rsp(void *inMsg)
  244. {
  245.     /*----------------------------------------------------------------*/
  246.     /* Local Variables                                                */
  247.     /*----------------------------------------------------------------*/
  248.     MMI_FRM_SMS_GET_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_RSP_STRUCT*) inMsg;
  249.     mmi_frm_sms_msgbox_struct *entry;
  250.     U8 segment = 0;
  251.     /*----------------------------------------------------------------*/
  252.     /* Code Body                                                      */
  253.     /*----------------------------------------------------------------*/    
  254.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
  255.     
  256.     if (msgRsp->result == TRUE)
  257.     {
  258.         entry = OslMalloc(sizeof(mmi_frm_sms_msgbox_struct));
  259.         if (((msgRsp->concat_info.seg) % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) == 0)
  260.         {
  261.             segment = (U8) g_frm_sms_cntx.mmi_frm_sms_msg_seg_size;
  262.         }
  263.         else
  264.         {
  265.             segment = (msgRsp->concat_info.seg) % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size;
  266.         }        
  267.         mmi_frm_sms_convert_read_to_entry(msgRsp, entry, readIndex);
  268.         mmi_frm_sms_add_sms_to_msgbox(entry, readIndex, segment);
  269.         
  270.         OslMfree(entry);        
  271.         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_OK);
  272.     }
  273.     else
  274.     {
  275.         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ERROR);
  276.     }
  277.     
  278. #ifdef __MMI_UNIFIED_MESSAGE__    
  279.     mmi_msg_send_refresh_ind(UM_MSG_BOX_TYPE_INBOX | UM_MSG_BOX_TYPE_UNSENT | UM_MSG_BOX_TYPE_SENT |
  280.                              UM_MSG_BOX_TYPE_DRAFT);    
  281. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  282. }
  283. /*****************************************************************************
  284.  * FUNCTION
  285.  *  mmi_frm_sms_get_sms_req
  286.  * DESCRIPTION
  287.  *  Get SMS request for updating message box
  288.  * PARAMETERS
  289.  *  inMsg       [IN]        Input message
  290.  * RETURNS
  291.  *  void
  292.  *****************************************************************************/
  293. void mmi_frm_sms_get_sms_req(void *inMsg)
  294. {
  295.     /*----------------------------------------------------------------*/
  296.     /* Local Variables                                                */
  297.     /*----------------------------------------------------------------*/
  298.     U16 *index = (U16*) inMsg;
  299.     MMI_FRM_SMS_GET_MSG_REQ_STRUCT *msgReq;
  300.     /*----------------------------------------------------------------*/
  301.     /* Code Body                                                      */
  302.     /*----------------------------------------------------------------*/
  303.     msgReq = (MMI_FRM_SMS_GET_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  304.     readIndex = *index;
  305.     msgReq->index = *index;
  306.     msgReq->change_status = FALSE;
  307.     SetProtocolEventHandler(mmi_frm_sms_get_sms_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_RSP);
  308.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_REQ, (oslParaType*) msgReq, NULL);
  309.     OslMfree(inMsg);
  310. }
  311. /*****************************************************************************
  312.  * FUNCTION
  313.  *  mmi_frm_sms_delete_sms_rsp
  314.  * DESCRIPTION
  315.  *  Delete SMS response
  316.  * PARAMETERS
  317.  *  inMsg       [IN]        Input message
  318.  * RETURNS
  319.  *  void
  320.  *****************************************************************************/
  321. void mmi_frm_sms_delete_sms_rsp(void *inMsg)
  322. {
  323.     /*----------------------------------------------------------------*/
  324.     /* Local Variables                                                */
  325.     /*----------------------------------------------------------------*/
  326.     MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
  327.     U16 result = MMI_FRM_SMS_ERROR;
  328. //KP Jerry add on 2007-4-26 start
  329. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  330.        FIREWALL_SMSINFO* pTemp = (FIREWALL_SMSINFO*)Get_Firewall_SmsInfo();
  331. #endif
  332. //KP Jerry add on 2007-4-26 end
  333.     /*----------------------------------------------------------------*/
  334.     /* Code Body                                                      */
  335.     /*----------------------------------------------------------------*/
  336.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  337.     if (msgRsp->result == TRUE)
  338.     {
  339.         result = MMI_FRM_SMS_OK;
  340. //KP Jerry add on 2007-4-26 start
  341. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  342. if(pTemp->Firewall_SMSDeleteFlag)
  343. {
  344. mmi_frm_sms_remove_sms_entry(pTemp->Firewall_Index);
  345. }
  346. else
  347. #endif
  348. //KP Jerry add on 2007-4-26 end
  349.        mmi_frm_sms_remove_sms_from_msgbox(msgRsp->del_bitmap);
  350.     }
  351.     mmi_frm_sms_callback_action(NULL, result);
  352. }
  353. /* use index array delete at once!!! */
  354. /*****************************************************************************
  355.  * FUNCTION
  356.  *  mmi_frm_sms_delete_sms_req
  357.  * DESCRIPTION
  358.  *  Delete SMS request
  359.  * PARAMETERS
  360.  *  inMsg       [IN]        Input message
  361.  * RETURNS
  362.  *  void
  363.  *****************************************************************************/
  364. void mmi_frm_sms_delete_sms_req(void *inMsg)
  365. {
  366.     /*----------------------------------------------------------------*/
  367.     /* Local Variables                                                */
  368.     /*----------------------------------------------------------------*/
  369.     MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
  370.     U8 *index = (U8*) inMsg;
  371.     /*----------------------------------------------------------------*/
  372.     /* Code Body                                                      */
  373.     /*----------------------------------------------------------------*/
  374. //KP Jerry modify on 2007-4-26 start
  375. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  376. FIREWALL_SMSINFO* pTemp = (FIREWALL_SMSINFO*)Get_Firewall_SmsInfo();
  377. if(pTemp->Firewall_SMSDeleteFlag)
  378. {
  379. msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  380. msgReq->del_flag = SMSAL_DEL_INDEXED_MSG;
  381. msgReq->index = pTemp->Firewall_Index;
  382. SetProtocolEventHandler(mmi_frm_sms_delete_sms_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  383. mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
  384. OslMfree(inMsg);
  385. }
  386. else
  387. {
  388. msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  389. msgReq->del_flag = SMSAL_DEL_BITMAP;
  390. memcpy((S8*) msgReq->del_bitmap, (S8*) index, 480);
  391. SetProtocolEventHandler(mmi_frm_sms_delete_sms_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  392. mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
  393. OslMfree(inMsg);
  394. }
  395. #else
  396.     msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  397.     msgReq->del_flag = SMSAL_DEL_BITMAP;
  398.     memcpy((S8*) msgReq->del_bitmap, (S8*) index, 480);
  399.     SetProtocolEventHandler(mmi_frm_sms_delete_sms_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  400.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
  401.     OslMfree(inMsg);
  402. #endif
  403. //KP Jerry modify on 2007-4-26 end
  404. }
  405. /*****************************************************************************
  406.  * FUNCTION
  407.  *  mmi_frm_sms_get_profile_name_rsp
  408.  * DESCRIPTION
  409.  *  Get profile name response
  410.  * PARAMETERS
  411.  *  inMsg       [IN]        Input message
  412.  * RETURNS
  413.  *  void
  414.  *****************************************************************************/
  415. void mmi_frm_sms_get_profile_name_rsp(void *inMsg)
  416. {
  417.     /*----------------------------------------------------------------*/
  418.     /* Local Variables                                                */
  419.     /*----------------------------------------------------------------*/
  420.     MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
  421.     U16 result = MMI_FRM_SMS_ERROR;
  422.     /*----------------------------------------------------------------*/
  423.     /* Code Body                                                      */
  424.     /*----------------------------------------------------------------*/
  425.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
  426.     if (msgRsp->result == TRUE)
  427.     {
  428.         U16 tempLen = ((MAX_PROFILE_NAME_LEN * ENCODING_LENGTH) + ENCODING_LENGTH);
  429.         U8 *tempbuf = OslMalloc(tempLen);
  430.         memset((PS8) tempbuf, 0, (tempLen));
  431.         /* tempbuf = CovertStringForPlatform (msgRsp->profile_name.name, msgRsp->profile_name.name_length, msgRsp->profile_name.name_dcs, &outLen); */
  432.         if (msgRsp->profile_name.name_length > 0)
  433.         {
  434.             /* add null terminator */
  435.             if (msgRsp->profile_name.name_dcs == SMSAL_DEFAULT_DCS)
  436.             {
  437.                 if (msgRsp->profile_name.name_length < sizeof(msgRsp->profile_name.name))
  438.                 {
  439.                     msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
  440.                 }
  441.             }
  442.             else
  443.             {
  444.                 if ((msgRsp->profile_name.name_length + 1) < sizeof(msgRsp->profile_name.name))
  445.                 {
  446.                     msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
  447.                     msgRsp->profile_name.name[msgRsp->profile_name.name_length + 1] = 0;
  448.                 }
  449.             }
  450.             
  451.             InputboxConvertGSMToDeviceEncoding(
  452.                 msgRsp->profile_name.name,
  453.                 tempbuf,
  454.                 msgRsp->profile_name.name_length,
  455.                 tempLen,
  456.                 msgRsp->profile_name.name_dcs,
  457.                 0,
  458.                 1);
  459.         }
  460.         memcpy((PS8) profileList->profileName[profileList->currReqProfileNo], tempbuf, tempLen);
  461.         if (tempbuf)
  462.         {
  463.             OslMfree(tempbuf);
  464.             tempbuf = NULL;
  465.         }
  466.         profileList->currReqProfileNo++;
  467.         result = MMI_FRM_SMS_OK;
  468.     }
  469.     if ((profileList->currReqProfileNo >= profileList->currMaxPsProfiles) || (result == MMI_FRM_SMS_ERROR))
  470.     {
  471.         if (profileList->currMaxPsProfiles > 0)
  472.         {
  473.             S16 errorCode = 0;
  474.             ReadValue(NVRAM_SMS_ACTIVE_PROFILE_INDEX, &(profileList->currReqProfileNo), DS_BYTE, &errorCode);
  475.             if (profileList->currReqProfileNo >= profileList->currMaxPsProfiles)
  476.             {
  477.                 profileList->currReqProfileNo = 0;
  478.                 WriteValue(NVRAM_SMS_ACTIVE_PROFILE_INDEX, &(profileList->currReqProfileNo), DS_BYTE, &errorCode);
  479.             }
  480.         }
  481.         mmi_frm_sms_callback_action((void*)profileList, result);
  482.         OslMfree(profileList);
  483.     }
  484.     else
  485.     {
  486.         mmi_frm_sms_get_profile_name_req(&(profileList->currReqProfileNo));
  487.     }
  488. }
  489. /*****************************************************************************
  490.  * FUNCTION
  491.  *  mmi_frm_sms_get_profile_name_req
  492.  * DESCRIPTION
  493.  *  Get profile name request
  494.  * PARAMETERS
  495.  *  inMsg       [IN]        Input message
  496.  * RETURNS
  497.  *  void
  498.  *****************************************************************************/
  499. void mmi_frm_sms_get_profile_name_req(void *inMsg)
  500. {
  501.     /*----------------------------------------------------------------*/
  502.     /* Local Variables                                                */
  503.     /*----------------------------------------------------------------*/
  504.     MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
  505.     U8 index = *(U8*) inMsg;
  506.     /*----------------------------------------------------------------*/
  507.     /* Code Body                                                      */
  508.     /*----------------------------------------------------------------*/
  509.     msgReq = (MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  510.     msgReq->profile_no = index;
  511.     SetProtocolEventHandler(mmi_frm_sms_get_profile_name_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
  512.     mmi_frm_sms_send_message(
  513.         MOD_MMI,
  514.         MOD_L4C,
  515.         0,
  516.         PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_REQ,
  517.         (oslParaType*) msgReq,
  518.         NULL);
  519. }
  520. /*****************************************************************************
  521.  * FUNCTION
  522.  *  mmi_frm_sms_get_profile_num_rsp
  523.  * DESCRIPTION
  524.  *  Get profile number response
  525.  * PARAMETERS
  526.  *  inMsg       [IN]        Input message
  527.  * RETURNS
  528.  *  void
  529.  *****************************************************************************/
  530. void mmi_frm_sms_get_profile_num_rsp(void *inMsg)
  531. {
  532.     /*----------------------------------------------------------------*/
  533.     /* Local Variables                                                */
  534.     /*----------------------------------------------------------------*/
  535.     MMI_FRM_SMS_GET_PROFILE_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_NUM_RSP_STRUCT*) inMsg;
  536.     U16 result = MMI_FRM_SMS_ERROR;
  537.     /*----------------------------------------------------------------*/
  538.     /* Code Body                                                      */
  539.     /*----------------------------------------------------------------*/
  540.     profileList = OslMalloc(sizeof(msg_profile_list_struct));
  541.     profileList->currMaxPsProfiles = 0;
  542.     profileList->currReqProfileNo = 0;
  543.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_NUM_RSP);
  544.     if (msgRsp->result == TRUE)
  545.     {
  546.         profileList->currMaxPsProfiles = msgRsp->profile_no;
  547.         profileList->profileNameLength = msgRsp->name_len;
  548.         result = MMI_FRM_SMS_OK;
  549.     }
  550.     if (profileList->currMaxPsProfiles == 0)
  551.     {
  552.         mmi_frm_sms_callback_action((void*)profileList, result);
  553.         OslMfree(profileList);
  554.     }
  555.     else
  556.     {
  557.         mmi_frm_sms_get_profile_name_req(&(profileList->currReqProfileNo));
  558.     }
  559. }
  560. /*****************************************************************************
  561.  * FUNCTION
  562.  *  mmi_frm_sms_get_profile_num_req
  563.  * DESCRIPTION
  564.  *  Get profile number request
  565.  * PARAMETERS
  566.  *  dummy       [IN]        Input message
  567.  * RETURNS
  568.  *  void
  569.  *****************************************************************************/
  570. void mmi_frm_sms_get_profile_num_req(void *dummy)
  571. {
  572.     /*----------------------------------------------------------------*/
  573.     /* Local Variables                                                */
  574.     /*----------------------------------------------------------------*/
  575.     /*----------------------------------------------------------------*/
  576.     /* Code Body                                                      */
  577.     /*----------------------------------------------------------------*/
  578.     SetProtocolEventHandler(mmi_frm_sms_get_profile_num_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_NUM_RSP);
  579.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_PROFILE_NUM_REQ, NULL, NULL);
  580. }
  581. /*****************************************************************************
  582.  * FUNCTION
  583.  *  mmi_frm_sms_get_profile_detail_rsp
  584.  * DESCRIPTION
  585.  *  Get profile detail response
  586.  * PARAMETERS
  587.  *  inMsg       [IN]        Input message
  588.  * RETURNS
  589.  *  void
  590.  *****************************************************************************/
  591. void mmi_frm_sms_get_profile_detail_rsp(void *inMsg)
  592. {
  593.     /*----------------------------------------------------------------*/
  594.     /* Local Variables                                                */
  595.     /*----------------------------------------------------------------*/
  596.     MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
  597.     U16 result = MMI_FRM_SMS_ERROR;
  598.     /*----------------------------------------------------------------*/
  599.     /* Code Body                                                      */
  600.     /*----------------------------------------------------------------*/
  601.     profileDetail = OslMalloc(sizeof(msg_profile_edit_struct));
  602.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
  603.     if (msgRsp->result == TRUE)
  604.     {
  605.         U16 tempLen = ((MAX_PROFILE_NAME_LEN * ENCODING_LENGTH) + ENCODING_LENGTH);
  606.         U8 *tempbuf = OslMalloc(tempLen);
  607.         U8 type = (msgRsp->sc_addr.type == CSMCC_INTERNATIONAL_ADDR) ? 1 : 0;
  608.         memset((PS8) tempbuf, 0, (tempLen));
  609.         //tempbuff        =       CovertStringForPlatform (msgRsp->profile_name.name, msgRsp->profile_name.name_length, 
  610.         //                                msgRsp->profile_name.name_dcs, &outLen);
  611.         if (msgRsp->profile_name.name_length > 0)
  612.         {
  613.             /* add null terminator */
  614.             if (msgRsp->profile_name.name_dcs == SMSAL_DEFAULT_DCS)
  615.             {
  616.                 if (msgRsp->profile_name.name_length < sizeof(msgRsp->profile_name.name))
  617.                 {
  618.                     msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
  619.                 }
  620.             }
  621.             else
  622.             {
  623.                 if ((msgRsp->profile_name.name_length + 1) < sizeof(msgRsp->profile_name.name))
  624.                 {
  625.                     msgRsp->profile_name.name[msgRsp->profile_name.name_length] = 0;
  626.                     msgRsp->profile_name.name[msgRsp->profile_name.name_length + 1] = 0;
  627.                 }
  628.             }
  629.             
  630.             InputboxConvertGSMToDeviceEncoding(
  631.                 msgRsp->profile_name.name,
  632.                 tempbuf,
  633.                 msgRsp->profile_name.name_length,
  634.                 tempLen,
  635.                 msgRsp->profile_name.name_dcs,
  636.                 0,
  637.                 1);
  638.         }
  639.         memset((PS8) profileDetail->profileName, 0, (MAX_PROFILE_NAME_LEN * ENCODING_LENGTH) + ENCODING_LENGTH);
  640.         memcpy((PS8) profileDetail->profileName, (PS8) tempbuf, tempLen);
  641.         profileDetail->profileNameDcs = msgRsp->profile_name.name_dcs;
  642.         if (tempbuf)
  643.         {
  644.             OslMfree(tempbuf);
  645.             tempbuf = NULL;
  646.         }
  647.         profileDetail->vpIndex = (U32) msgRsp->vp;
  648.         profileDetail->msgTypeIndex = (U32) msgRsp->pid;
  649.         if (type)
  650.         {
  651.             AnsiiToUnicodeString((PS8) profileDetail->scAddress, (PS8) "+");
  652.         }
  653.         AnsiiNToUnicodeString(
  654.             (PS8) profileDetail->scAddress + (type * ENCODING_LENGTH),
  655.             (PS8) msgRsp->sc_addr.number,
  656.             msgRsp->sc_addr.length);
  657.         memset(
  658.             (void*)&profileDetail->scAddress[(msgRsp->sc_addr.length + type) * ENCODING_LENGTH],
  659.             0,
  660.             ENCODING_LENGTH);
  661.         result = MMI_FRM_SMS_OK;
  662.     }
  663.     mmi_frm_sms_callback_action((void*)profileDetail, result);
  664.     OslMfree(profileDetail);
  665. }
  666. /*****************************************************************************
  667.  * FUNCTION
  668.  *  mmi_frm_sms_get_profile_detail_req
  669.  * DESCRIPTION
  670.  *  Get profile detail request
  671.  * PARAMETERS
  672.  *  inMsg       [IN]        Input message
  673.  * RETURNS
  674.  *  void
  675.  *****************************************************************************/
  676. void mmi_frm_sms_get_profile_detail_req(void *inMsg)
  677. {
  678.     /*----------------------------------------------------------------*/
  679.     /* Local Variables                                                */
  680.     /*----------------------------------------------------------------*/
  681.     MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
  682.     U8 index = *(U8*) inMsg;
  683.     /*----------------------------------------------------------------*/
  684.     /* Code Body                                                      */
  685.     /*----------------------------------------------------------------*/
  686.     msgReq = (MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  687.     msgReq->profile_no = index;
  688.     SetProtocolEventHandler(mmi_frm_sms_get_profile_detail_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
  689.     mmi_frm_sms_send_message(
  690.         MOD_MMI,
  691.         MOD_L4C,
  692.         0,
  693.         PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_REQ,
  694.         (oslParaType*) msgReq,
  695.         NULL);
  696.     OslMfree(inMsg);
  697. }
  698. /*****************************************************************************
  699.  * FUNCTION
  700.  *  mmi_frm_sms_set_profile_detail_rsp
  701.  * DESCRIPTION
  702.  *  Set profile detail response
  703.  * PARAMETERS
  704.  *  inMsg       [IN]        Input message
  705.  * RETURNS
  706.  *  void
  707.  *****************************************************************************/
  708. void mmi_frm_sms_set_profile_detail_rsp(void *inMsg)
  709. {
  710.     /*----------------------------------------------------------------*/
  711.     /* Local Variables                                                */
  712.     /*----------------------------------------------------------------*/
  713.     MMI_FRM_SMS_SET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
  714.     U16 result = MMI_FRM_SMS_ERROR;
  715.     /*----------------------------------------------------------------*/
  716.     /* Code Body                                                      */
  717.     /*----------------------------------------------------------------*/
  718.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_RSP);
  719.     if (msgRsp->result == TRUE)
  720.     {
  721.         result = MMI_FRM_SMS_OK;
  722.     }
  723.     mmi_frm_sms_callback_action((void*)profileDetail, result);
  724.     OslMfree(profileDetail);
  725. }
  726. /*****************************************************************************
  727.  * FUNCTION
  728.  *  mmi_frm_sms_set_profile_detail_req
  729.  * DESCRIPTION
  730.  *  Set profile detail response
  731.  * PARAMETERS
  732.  *  inMsg       [IN]        Input message
  733.  * RETURNS
  734.  *  void
  735.  *****************************************************************************/
  736. void mmi_frm_sms_set_profile_detail_req(void *inMsg)
  737. {
  738.     /*----------------------------------------------------------------*/
  739.     /* Local Variables                                                */
  740.     /*----------------------------------------------------------------*/
  741.     MMI_FRM_SMS_SET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
  742.     msg_profile_edit_struct *profile = (msg_profile_edit_struct*) inMsg;
  743.     S8 scAddress[MAX_DIGITS + 1];
  744.     /*----------------------------------------------------------------*/
  745.     /* Code Body                                                      */
  746.     /*----------------------------------------------------------------*/
  747.     profileDetail = OslMalloc(sizeof(msg_profile_edit_struct));
  748.     memcpy(profileDetail, profile, sizeof(msg_profile_edit_struct));
  749.     msgReq = (MMI_FRM_SMS_SET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  750.     msgReq->para_ind = 0;
  751.     if (!IsResetCSPGroupService(CSP_TELESERVICES_SERVICE_GROUP, CSP_Validity_Period))
  752.     {
  753.         msgReq->vp = (U8) profile->vpIndex;
  754.         msgReq->para_ind |= SMSAL_PARA_VP;
  755.     }
  756.     if (!IsResetCSPGroupService(CSP_TELESERVICES_SERVICE_GROUP, CSP_Protocol_ID))
  757.     {
  758.         msgReq->pid = (U8) profile->msgTypeIndex;
  759.         msgReq->para_ind |= SMSAL_PARA_PID;
  760.     }
  761.     if (profile->profileNameDcs == PHB_UCS2)
  762.     {
  763.         msgReq->profile_name.name_dcs = MMI_PHB_UCS2;
  764.         msgReq->profile_name.name_length = ((U8) pfnUnicodeStrlen((PS8) profile->profileName)) * ENCODING_LENGTH;
  765.         InputboxConvertDeviceEncodingToGSM(
  766.             (PU8) profile->profileName,
  767.             msgReq->profile_name.name,
  768.             MAX_PROFILE_NAME_LEN,
  769.             MMI_PHB_UCS2,
  770.             0,
  771.             1);
  772.     }
  773.     else
  774.     {
  775.         msgReq->profile_name.name_dcs = MMI_PHB_ASCII;
  776.         msgReq->profile_name.name_length = InputboxConvertDeviceEncodingToGSM(
  777.                                             (PU8) profile->profileName,
  778.                                             msgReq->profile_name.name,
  779.                                             MAX_PROFILE_NAME_LEN,
  780.                                             MMI_PHB_ASCII,
  781.                                             0,
  782.                                             1) - 1;
  783.     }
  784.     memset(&msgReq->profile_name.name[msgReq->profile_name.name_length], 0, 1);
  785.     msgReq->para_ind |= SMSAL_PARA_PROFILE_NAME;
  786.     memset(&scAddress, 0, MAX_DIGITS_SMS * ENCODING_LENGTH);
  787.     UnicodeNToAnsii((PS8) scAddress, (PS8) profile->scAddress, MAX_DIGITS_SMS * ENCODING_LENGTH);
  788.     msgReq->profile_no = profile->profileIndex;
  789.     if (scAddress[0] == '+')
  790.     {
  791.         msgReq->sc_addr.type = CSMCC_INTERNATIONAL_ADDR;
  792.         msgReq->sc_addr.length = (strlen(scAddress) > MAX_DIGITS_SMS) ? (MAX_DIGITS_SMS - 1) : (strlen(scAddress) - 1);
  793.         memcpy(msgReq->sc_addr.number, scAddress + 1, msgReq->sc_addr.length);
  794.     }
  795.     else
  796.     {
  797.         msgReq->sc_addr.type = CSMCC_DEFAULT_ADDR_TYPE;
  798.         msgReq->sc_addr.length =
  799.             (strlen(scAddress) > (MAX_DIGITS_SMS - 1)) ? (MAX_DIGITS_SMS - 1) : (strlen(scAddress));
  800.         memcpy(msgReq->sc_addr.number, scAddress, msgReq->sc_addr.length);
  801.     }
  802.     memset(&msgReq->sc_addr.number[msgReq->sc_addr.length], 0, 1);
  803.     msgReq->para_ind |= SMSAL_PARA_SCA;
  804.     SetProtocolEventHandler(mmi_frm_sms_set_profile_detail_rsp, PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_RSP);
  805.     mmi_frm_sms_send_message(
  806.         MOD_MMI,
  807.         MOD_L4C,
  808.         0,
  809.         PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_REQ,
  810.         (oslParaType*) msgReq,
  811.         NULL);
  812.     OslMfree(inMsg);
  813. }
  814. /*****************************************************************************
  815.  * FUNCTION
  816.  *  mmi_frm_sms_get_common_settings_rsp
  817.  * DESCRIPTION
  818.  *  Get common settings response
  819.  * PARAMETERS
  820.  *  inMsg       [IN]        Input message
  821.  * RETURNS
  822.  *  void
  823.  *****************************************************************************/
  824. void mmi_frm_sms_get_common_settings_rsp(void *inMsg)
  825. {
  826.     /*----------------------------------------------------------------*/
  827.     /* Local Variables                                                */
  828.     /*----------------------------------------------------------------*/
  829.     MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
  830.     U16 result = MMI_FRM_SMS_ERROR;
  831.     U8 settings[2] = {0, 0};
  832.     /*----------------------------------------------------------------*/
  833.     /* Code Body                                                      */
  834.     /*----------------------------------------------------------------*/
  835.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
  836.     if (msgRsp->result == TRUE)
  837.     {
  838.         settings[0] = msgRsp->status_report;
  839.         settings[1] = msgRsp->reply_path;
  840.         result = MMI_FRM_SMS_OK;
  841.     #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
  842.         g_frm_sms_cntx.mmi_frm_sms_delivery_report_setting = msgRsp->status_report;
  843.     #endif 
  844.     }
  845.     mmi_frm_sms_callback_action((void*)settings, result);
  846. }
  847. /*****************************************************************************
  848.  * FUNCTION
  849.  *  mmi_frm_sms_get_common_settings_req
  850.  * DESCRIPTION
  851.  *  Get common settings request
  852.  * PARAMETERS
  853.  *  dummy       [IN]        Input message
  854.  * RETURNS
  855.  *  void
  856.  *****************************************************************************/
  857. void mmi_frm_sms_get_common_settings_req(void *dummy)
  858. {
  859.     /*----------------------------------------------------------------*/
  860.     /* Local Variables                                                */
  861.     /*----------------------------------------------------------------*/
  862.     /*----------------------------------------------------------------*/
  863.     /* Code Body                                                      */
  864.     /*----------------------------------------------------------------*/
  865.     SetProtocolEventHandler(mmi_frm_sms_get_common_settings_rsp, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
  866.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_REQ, NULL, NULL);
  867. }
  868. /*****************************************************************************
  869.  * FUNCTION
  870.  *  mmi_frm_sms_set_common_settings_rsp
  871.  * DESCRIPTION
  872.  *  Set common settings response
  873.  * PARAMETERS
  874.  *  inMsg       [IN]        Input message
  875.  * RETURNS
  876.  *  void
  877.  *****************************************************************************/
  878. void mmi_frm_sms_set_common_settings_rsp(void *inMsg)
  879. {
  880.     /*----------------------------------------------------------------*/
  881.     /* Local Variables                                                */
  882.     /*----------------------------------------------------------------*/
  883.     MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
  884.     U16 result = MMI_FRM_SMS_ERROR;
  885.     /*----------------------------------------------------------------*/
  886.     /* Code Body                                                      */
  887.     /*----------------------------------------------------------------*/
  888.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
  889.     if (msgRsp->result == TRUE)
  890.     {
  891.         result = MMI_FRM_SMS_OK;
  892.     #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
  893.         g_frm_sms_cntx.mmi_frm_sms_delivery_report_setting = g_frm_sms_cntx.mmi_frm_sms_delivery_report_temp_setting;
  894.     #endif 
  895.     }
  896.     mmi_frm_sms_callback_action(NULL, result);
  897. }
  898. /*****************************************************************************
  899.  * FUNCTION
  900.  *  mmi_frm_sms_set_common_settings_req
  901.  * DESCRIPTION
  902.  *  Set common settings request
  903.  * PARAMETERS
  904.  *  inMsg       [IN]        Input message
  905.  * RETURNS
  906.  *  void
  907.  *****************************************************************************/
  908. void mmi_frm_sms_set_common_settings_req(void *inMsg)
  909. {
  910.     /*----------------------------------------------------------------*/
  911.     /* Local Variables                                                */
  912.     /*----------------------------------------------------------------*/
  913.     MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT *msgReq;
  914.     U8 *DrRp = (U8*) inMsg;
  915.     /*----------------------------------------------------------------*/
  916.     /* Code Body                                                      */
  917.     /*----------------------------------------------------------------*/
  918.     msgReq = (MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  919.     if (IsResetCSPGroupService(CSP_TELESERVICES_SERVICE_GROUP, CSP_Del_Conf))
  920.     {
  921.         if (DrRp[0] == 0)
  922.         {
  923.             DrRp[0] = 0;
  924.             DrRp[1] = 0;
  925.         }
  926.         else    /* DrRp[0] == 1 */
  927.         {
  928.             DrRp[0] = 0;
  929.             DrRp[1] = 1;
  930.         }
  931.     }
  932.     msgReq->status_report = DrRp[0];
  933.     msgReq->reply_path = DrRp[1];
  934.     msgReq->para_ind = SMSAL_COM_PARA_STATUS_REP | SMSAL_COM_PARA_REPLY_PATH;
  935. #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
  936.     g_frm_sms_cntx.mmi_frm_sms_delivery_report_temp_setting = msgReq->status_report;
  937. #endif 
  938.     SetProtocolEventHandler(mmi_frm_sms_set_common_settings_rsp, PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
  939.     mmi_frm_sms_send_message(
  940.         MOD_MMI,
  941.         MOD_L4C,
  942.         0,
  943.         PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_REQ,
  944.         (oslParaType*) msgReq,
  945.         NULL);
  946.     OslMfree(inMsg);
  947. }
  948. #ifdef __MMI_MESSAGES_PREFER_STORAGE_MEMORY_STATUS__
  949. /*****************************************************************************
  950.  * FUNCTION
  951.  *  mmi_frm_sms_get_memory_status_rsp
  952.  * DESCRIPTION
  953.  *  Get memory status response
  954.  * PARAMETERS
  955.  *  inMsg       [IN]        Input message
  956.  * RETURNS
  957.  *  void
  958.  *****************************************************************************/
  959. void mmi_frm_sms_get_memory_status_rsp(void *inMsg)
  960. {
  961.     /*----------------------------------------------------------------*/
  962.     /* Local Variables                                                */
  963.     /*----------------------------------------------------------------*/
  964.     MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT*) inMsg;
  965.     U16 result = MMI_FRM_SMS_ERROR;
  966.     msg_mem_status_struct memory;
  967.     /*----------------------------------------------------------------*/
  968.     /* Code Body                                                      */
  969.     /*----------------------------------------------------------------*/
  970.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
  971.     if (msgRsp->result == TRUE)
  972.     {
  973.         memory.simTotal = msgRsp->total_sim_num;
  974.         memory.meTotal = msgRsp->total_me_num;
  975.         memory.simUsed = msgRsp->in_sim_no + msgRsp->out_sim_no;
  976.         memory.meUsed = msgRsp->in_me_no + msgRsp->out_me_no;
  977.         result = MMI_FRM_SMS_OK;
  978.     }
  979.     mmi_frm_sms_callback_action((void*)&memory, result);
  980. }
  981. /*****************************************************************************
  982.  * FUNCTION
  983.  *  mmi_frm_sms_get_memory_status_req
  984.  * DESCRIPTION
  985.  *  Get memory status request
  986.  * PARAMETERS
  987.  *  dummy       [IN]        Input message
  988.  * RETURNS
  989.  *  void
  990.  *****************************************************************************/
  991. void mmi_frm_sms_get_memory_status_req(void *dummy)
  992. {
  993.     /*----------------------------------------------------------------*/
  994.     /* Local Variables                                                */
  995.     /*----------------------------------------------------------------*/
  996.     /*----------------------------------------------------------------*/
  997.     /* Code Body                                                      */
  998.     /*----------------------------------------------------------------*/
  999.     SetProtocolEventHandler(mmi_frm_sms_get_memory_status_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
  1000.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_REQ, NULL, NULL);
  1001. }
  1002. /*****************************************************************************
  1003.  * FUNCTION
  1004.  *  mmi_frm_sms_get_preferred_storage_rsp
  1005.  * DESCRIPTION
  1006.  *  Get preferred storage response
  1007.  * PARAMETERS
  1008.  *  inMsg       [IN]        Input message
  1009.  * RETURNS
  1010.  *  void
  1011.  *****************************************************************************/
  1012. void mmi_frm_sms_get_preferred_storage_rsp(void *inMsg)
  1013. {
  1014.     /*----------------------------------------------------------------*/
  1015.     /* Local Variables                                                */
  1016.     /*----------------------------------------------------------------*/
  1017.     MMI_FRM_SMS_GET_PREFERRED_STORAGE_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PREFERRED_STORAGE_RSP_STRUCT*) inMsg;
  1018.     U16 result = MMI_FRM_SMS_ERROR;
  1019.     U8 storage = 0;
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Code Body                                                      */
  1022.     /*----------------------------------------------------------------*/
  1023.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PREFERRED_STORAGE_RSP);
  1024.     if (msgRsp->result == TRUE)
  1025.     {
  1026.         if (msgRsp->info.mem2 == SMSAL_SM || msgRsp->info.mem2 == SMSAL_SM_PREFER)
  1027.         {
  1028.             storage = SMSAL_SM;
  1029.         }
  1030.         else
  1031.         {
  1032.             storage = SMSAL_ME;
  1033.         }
  1034.         result = MMI_FRM_SMS_OK;
  1035.     }
  1036.     mmi_frm_sms_callback_action((void*)&storage, result);
  1037. }
  1038. /*****************************************************************************
  1039.  * FUNCTION
  1040.  *  mmi_frm_sms_get_preferred_storage_req
  1041.  * DESCRIPTION
  1042.  *  Get preferred storage request
  1043.  * PARAMETERS
  1044.  *  dummy       [IN]        Input message
  1045.  * RETURNS
  1046.  *  void
  1047.  *****************************************************************************/
  1048. void mmi_frm_sms_get_preferred_storage_req(void *dummy)
  1049. {
  1050.     /*----------------------------------------------------------------*/
  1051.     /* Local Variables                                                */
  1052.     /*----------------------------------------------------------------*/
  1053.     /*----------------------------------------------------------------*/
  1054.     /* Code Body                                                      */
  1055.     /*----------------------------------------------------------------*/
  1056.     SetProtocolEventHandler(mmi_frm_sms_get_preferred_storage_rsp, PRT_MSG_ID_MMI_SMS_GET_PREFERRED_STORAGE_RSP);
  1057.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_PREFERRED_STORAGE_REQ, NULL, NULL);
  1058. }
  1059. /*****************************************************************************
  1060.  * FUNCTION
  1061.  *  mmi_frm_sms_set_preferred_storage_rsp
  1062.  * DESCRIPTION
  1063.  *  Set preferred storage response
  1064.  * PARAMETERS
  1065.  *  inMsg       [IN]        Input message
  1066.  * RETURNS
  1067.  *  void
  1068.  *****************************************************************************/
  1069. void mmi_frm_sms_set_preferred_storage_rsp(void *inMsg)
  1070. {
  1071.     /*----------------------------------------------------------------*/
  1072.     /* Local Variables                                                */
  1073.     /*----------------------------------------------------------------*/
  1074.     MMI_FRM_SMS_SET_PREFERRED_STORAGE_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_PREFERRED_STORAGE_RSP_STRUCT*) inMsg;
  1075.     U16 result = MMI_FRM_SMS_ERROR;
  1076.     U8 preferStorage = 0;
  1077.     /*----------------------------------------------------------------*/
  1078.     /* Code Body                                                      */
  1079.     /*----------------------------------------------------------------*/
  1080.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_PREFERRED_STORAGE_RSP);
  1081.     if ((msgRsp->result) == TRUE)
  1082.     {
  1083.         if (msgRsp->param.mem2 == SMSAL_SM || msgRsp->param.mem2 == SMSAL_SM_PREFER)
  1084.         {
  1085.             preferStorage = SMSAL_SM;
  1086.         }
  1087.         else
  1088.         {
  1089.             preferStorage = SMSAL_ME;
  1090.         }
  1091.         result = MMI_FRM_SMS_OK;
  1092.     }
  1093.     mmi_frm_sms_callback_action((void*)&preferStorage, result);
  1094. }
  1095. /*****************************************************************************
  1096.  * FUNCTION
  1097.  *  mmi_frm_sms_set_preferred_storage_req
  1098.  * DESCRIPTION
  1099.  *  Set preferred storage request
  1100.  * PARAMETERS
  1101.  *  inMsg       [IN]        Input message
  1102.  * RETURNS
  1103.  *  void
  1104.  *****************************************************************************/
  1105. void mmi_frm_sms_set_preferred_storage_req(void *inMsg)
  1106. {
  1107.     /*----------------------------------------------------------------*/
  1108.     /* Local Variables                                                */
  1109.     /*----------------------------------------------------------------*/
  1110.     MMI_FRM_SMS_SET_PREFERRED_STORAGE_REQ_STRUCT *msgReq;
  1111.     U8 storage = *(U8*) inMsg;
  1112.     /*----------------------------------------------------------------*/
  1113.     /* Code Body                                                      */
  1114.     /*----------------------------------------------------------------*/
  1115.     msgReq = (MMI_FRM_SMS_SET_PREFERRED_STORAGE_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1116.     msgReq->mem2 = storage;
  1117.     msgReq->mem1 = SMSAL_STORAGE_UNSPECIFIED;
  1118. #ifdef __MMI_MESSAGES_PREFER_STORAGE_ONLY_FOR_MO_SMS__
  1119.     msgReq->mem3 = SMSAL_STORAGE_UNSPECIFIED;
  1120. #else 
  1121.     msgReq->mem3 = storage;
  1122. #endif 
  1123.     SetProtocolEventHandler(mmi_frm_sms_set_preferred_storage_rsp, PRT_MSG_ID_MMI_SMS_SET_PREFERRED_STORAGE_RSP);
  1124.     mmi_frm_sms_send_message(
  1125.         MOD_MMI,
  1126.         MOD_L4C,
  1127.         0,
  1128.         PRT_MSG_ID_MMI_SMS_SET_PREFERRED_STORAGE_REQ,
  1129.         (oslParaType*) msgReq,
  1130.         NULL);
  1131.     OslMfree(inMsg);
  1132. }
  1133. #endif /* __MMI_MESSAGES_PREFER_STORAGE_MEMORY_STATUS__ */ 
  1134. #ifdef __MMI_GPRS_FEATURES__
  1135. /*****************************************************************************
  1136.  * FUNCTION
  1137.  *  mmi_frm_sms_get_preferred_bearer_rsp
  1138.  * DESCRIPTION
  1139.  *  Get preferred bearer response
  1140.  * PARAMETERS
  1141.  *  inMsg       [IN]        Input message
  1142.  * RETURNS
  1143.  *  void
  1144.  *****************************************************************************/
  1145. void mmi_frm_sms_get_preferred_bearer_rsp(void *inMsg)
  1146. {
  1147.     /*----------------------------------------------------------------*/
  1148.     /* Local Variables                                                */
  1149.     /*----------------------------------------------------------------*/
  1150.     MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
  1151.     U16 result = MMI_FRM_SMS_ERROR;
  1152.     U8 bearer = 0;
  1153.     /*----------------------------------------------------------------*/
  1154.     /* Code Body                                                      */
  1155.     /*----------------------------------------------------------------*/
  1156.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
  1157.     if (msgRsp->result == TRUE)
  1158.     {
  1159.         if (msgRsp->bearer_service == SMS_PREFER_GPRS)
  1160.         {
  1161.             bearer = MMI_SMS_PREFER_GPRS;
  1162.         }
  1163.         else if (msgRsp->bearer_service == SMS_PREFER_GSM)
  1164.         {
  1165.             bearer = MMI_SMS_PREFER_GSM;
  1166.         }
  1167.         else if (msgRsp->bearer_service == SMS_GSM_ONLY)
  1168.         {
  1169.             bearer = MMI_SMS_GSM_ONLY;
  1170.         }
  1171.         result = MMI_FRM_SMS_OK;
  1172.     }
  1173.     mmi_frm_sms_callback_action((void*)&bearer, result);
  1174. }
  1175. /*****************************************************************************
  1176.  * FUNCTION
  1177.  *  mmi_frm_sms_get_preferred_bearer_req
  1178.  * DESCRIPTION
  1179.  *  Get preferred bearer request
  1180.  * PARAMETERS
  1181.  *  dummy       [IN]        Input message
  1182.  * RETURNS
  1183.  *  void
  1184.  *****************************************************************************/
  1185. void mmi_frm_sms_get_preferred_bearer_req(void *dummy)
  1186. {
  1187.     /*----------------------------------------------------------------*/
  1188.     /* Local Variables                                                */
  1189.     /*----------------------------------------------------------------*/
  1190.     /*----------------------------------------------------------------*/
  1191.     /* Code Body                                                      */
  1192.     /*----------------------------------------------------------------*/
  1193.     SetProtocolEventHandler(mmi_frm_sms_get_preferred_bearer_rsp, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
  1194.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_REQ, NULL, NULL);
  1195. }
  1196. /*****************************************************************************
  1197.  * FUNCTION
  1198.  *  mmi_frm_sms_set_preferred_bearer_rsp
  1199.  * DESCRIPTION
  1200.  *  Set preferred bearer response
  1201.  * PARAMETERS
  1202.  *  inMsg       [IN]        Input message
  1203.  * RETURNS
  1204.  *  void
  1205.  *****************************************************************************/
  1206. void mmi_frm_sms_set_preferred_bearer_rsp(void *inMsg)
  1207. {
  1208.     /*----------------------------------------------------------------*/
  1209.     /* Local Variables                                                */
  1210.     /*----------------------------------------------------------------*/
  1211.     MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_COMMON_PARAMS_RSP_STRUCT*) inMsg;
  1212.     U16 result = MMI_FRM_SMS_ERROR;
  1213.     /*----------------------------------------------------------------*/
  1214.     /* Code Body                                                      */
  1215.     /*----------------------------------------------------------------*/
  1216.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
  1217.     if ((msgRsp->result) == TRUE)
  1218.     {
  1219.         result = MMI_FRM_SMS_OK;
  1220.     }
  1221.     mmi_frm_sms_callback_action(NULL, result);
  1222. }
  1223. /*****************************************************************************
  1224.  * FUNCTION
  1225.  *  mmi_frm_sms_set_preferred_bearer_req
  1226.  * DESCRIPTION
  1227.  *  Set preferred bearer request
  1228.  * PARAMETERS
  1229.  *  inMsg       [IN]        Input message
  1230.  * RETURNS
  1231.  *  void
  1232.  *****************************************************************************/
  1233. void mmi_frm_sms_set_preferred_bearer_req(void *inMsg)
  1234. {
  1235.     /*----------------------------------------------------------------*/
  1236.     /* Local Variables                                                */
  1237.     /*----------------------------------------------------------------*/
  1238.     MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT *msgReq;
  1239.     U8 bearer = *(U8*) inMsg;
  1240.     /*----------------------------------------------------------------*/
  1241.     /* Code Body                                                      */
  1242.     /*----------------------------------------------------------------*/
  1243.     msgReq = (MMI_FRM_SMS_SET_COMMON_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1244.     switch (bearer)
  1245.     {
  1246.         case MMI_SMS_PREFER_GPRS:
  1247.             bearer = SMS_PREFER_GPRS;
  1248.             break;
  1249.         case MMI_SMS_PREFER_GSM:
  1250.             bearer = SMS_PREFER_GSM;
  1251.             break;
  1252.         case MMI_SMS_GSM_ONLY:
  1253.             bearer = SMS_GSM_ONLY;
  1254.             break;
  1255.     }
  1256.     msgReq->bearer_service = bearer;
  1257.     msgReq->para_ind = SMSAL_COM_PARA_BEARER;
  1258.     SetProtocolEventHandler(mmi_frm_sms_set_preferred_bearer_rsp, PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_RSP);
  1259.     mmi_frm_sms_send_message(
  1260.         MOD_MMI,
  1261.         MOD_L4C,
  1262.         0,
  1263.         PRT_MSG_ID_MMI_SMS_SET_COMMON_PARAMS_REQ,
  1264.         (oslParaType*) msgReq,
  1265.         NULL);
  1266.     OslMfree(inMsg);
  1267. }
  1268. #endif /* __MMI_GPRS_FEATURES__ */ 
  1269. /*****************************************************************************
  1270.  * FUNCTION
  1271.  *  mmi_frm_sms_get_mailbox_info_rsp
  1272.  * DESCRIPTION
  1273.  *  Get mailbox info response
  1274.  * PARAMETERS
  1275.  *  inMsg       [IN]        Input message
  1276.  * RETURNS
  1277.  *  void
  1278.  *****************************************************************************/
  1279. void mmi_frm_sms_get_mailbox_info_rsp(void *inMsg)
  1280. {
  1281.     /*----------------------------------------------------------------*/
  1282.     /* Local Variables                                                */
  1283.     /*----------------------------------------------------------------*/
  1284.     MMI_FRM_SMS_GET_MAILBOX_ADDRESS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MAILBOX_ADDRESS_RSP_STRUCT*) inMsg;
  1285.     mmi_frm_sms_mailbox_struct mailboxInfo;
  1286.     U16 result = MMI_FRM_SMS_ERROR;
  1287.     U8 i = 0;
  1288.     /*----------------------------------------------------------------*/
  1289.     /* Code Body                                                      */
  1290.     /*----------------------------------------------------------------*/
  1291.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_COMMON_PARAMS_RSP);
  1292.     if (msgRsp->result == TRUE)
  1293.     {
  1294.         mailboxInfo.mailboxNumber = msgRsp->mailbox_num;
  1295.         mailboxInfo.mailboxNameLength = msgRsp->alpha_length;
  1296.         for (i = 0; i < mailboxInfo.mailboxNumber; i++)
  1297.         {
  1298.             U8 type = (msgRsp->mailbox_info[i].number_info.type == CSMCC_INTERNATIONAL_ADDR) ? 1 : 0;
  1299.             U8 length = msgRsp->mailbox_info[i].number_info.length;
  1300.             U16 nameLen = (msgRsp->mailbox_info[i].name.name_length + 1) * ENCODING_LENGTH;
  1301.             mailboxInfo.mailboxNameDcs[i] = msgRsp->mailbox_info[i].name.name_dcs;
  1302.             mailboxInfo.pMailBoxName[i] = OslMalloc(nameLen);
  1303.             memset(mailboxInfo.pMailBoxName[i], 0, nameLen);
  1304.             if (msgRsp->mailbox_info[i].name.name_length > 0)
  1305.             {
  1306.                 /* add null terminator */
  1307.                 if (msgRsp->mailbox_info[i].name.name_dcs == SMSAL_DEFAULT_DCS)
  1308.                 {
  1309.                     if (msgRsp->mailbox_info[i].name.name_length < sizeof(msgRsp->mailbox_info[i].name.name))
  1310.                     {
  1311.                         msgRsp->mailbox_info[i].name.name[msgRsp->mailbox_info[i].name.name_length] = 0;
  1312.                     }
  1313.                 }
  1314.                 else
  1315.                 {
  1316.                     if ((msgRsp->mailbox_info[i].name.name_length + 1) < sizeof(msgRsp->mailbox_info[i].name.name))
  1317.                     {
  1318.                         msgRsp->mailbox_info[i].name.name[msgRsp->mailbox_info[i].name.name_length] = 0;
  1319.                         msgRsp->mailbox_info[i].name.name[msgRsp->mailbox_info[i].name.name_length + 1] = 0;
  1320.                     }
  1321.                 }
  1322.                 
  1323.                 InputboxConvertGSMToDeviceEncoding(
  1324.                     msgRsp->mailbox_info[i].name.name,
  1325.                     mailboxInfo.pMailBoxName[i],
  1326.                     msgRsp->mailbox_info[i].name.name_length,
  1327.                     nameLen,
  1328.                     msgRsp->mailbox_info[i].name.name_dcs,
  1329.                     0,
  1330.                     1);
  1331.             }
  1332.             //mailboxInfo.pMailBoxName[i] = CovertStringForPlatform (msgRsp->mailbox_info[i].name.name, 
  1333.             //msgRsp->mailbox_info[i].name.name_length, msgRsp->mailbox_info[i].name.name_dcs, &outlen);
  1334.             mailboxInfo.pMailBoxNumber[i] = OslMalloc((type + length + 1) * ENCODING_LENGTH);
  1335.             if (type)
  1336.             {
  1337.                 AnsiiToUnicodeString((PS8) mailboxInfo.pMailBoxNumber[i], (PS8) "+");
  1338.             }
  1339.             AnsiiNToUnicodeString(
  1340.                 (PS8) (mailboxInfo.pMailBoxNumber[i] + (type * ENCODING_LENGTH)),
  1341.                 (PS8) msgRsp->mailbox_info[i].number_info.number,
  1342.                 length);
  1343.             memset(mailboxInfo.pMailBoxNumber[i] + ((type + length) * ENCODING_LENGTH), 0, ENCODING_LENGTH);
  1344.         }
  1345.         result = MMI_FRM_SMS_OK;
  1346.     }
  1347.     mmi_frm_sms_callback_action((void*)&mailboxInfo, result);
  1348.     for (i = 0; i < mailboxInfo.mailboxNumber; i++)
  1349.     {
  1350.         if (mailboxInfo.pMailBoxName[i])
  1351.         {
  1352.             OslMfree(mailboxInfo.pMailBoxName[i]);
  1353.         }
  1354.         if (mailboxInfo.pMailBoxNumber[i])
  1355.         {
  1356.             OslMfree(mailboxInfo.pMailBoxNumber[i]);
  1357.         }
  1358.     }
  1359. }
  1360. /*****************************************************************************
  1361.  * FUNCTION
  1362.  *  mmi_frm_sms_get_mailbox_info_req
  1363.  * DESCRIPTION
  1364.  *  Get mailbox info request
  1365.  * PARAMETERS
  1366.  *  dummy           [?]         
  1367.  *  inMsg(?)        [IN]        Input message
  1368.  * RETURNS
  1369.  *  void
  1370.  *****************************************************************************/
  1371. void mmi_frm_sms_get_mailbox_info_req(void *dummy)
  1372. {
  1373.     /*----------------------------------------------------------------*/
  1374.     /* Local Variables                                                */
  1375.     /*----------------------------------------------------------------*/
  1376.     /*----------------------------------------------------------------*/
  1377.     /* Code Body                                                      */
  1378.     /*----------------------------------------------------------------*/
  1379.     SetProtocolEventHandler(mmi_frm_sms_get_mailbox_info_rsp, PRT_MSG_ID_MMI_SMS_GET_MAILBOX_ADDRESS_RSP);
  1380.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MAILBOX_ADDRESS_REQ, NULL, NULL);
  1381. }
  1382. /*****************************************************************************
  1383.  * FUNCTION
  1384.  *  mmi_frm_sms_set_mailbox_info_rsp
  1385.  * DESCRIPTION
  1386.  *  Set mailbox info response
  1387.  * PARAMETERS
  1388.  *  inMsg       [IN]        Input message
  1389.  * RETURNS
  1390.  *  void
  1391.  *****************************************************************************/
  1392. void mmi_frm_sms_set_mailbox_info_rsp(void *inMsg)
  1393. {
  1394.     /*----------------------------------------------------------------*/
  1395.     /* Local Variables                                                */
  1396.     /*----------------------------------------------------------------*/
  1397.     MMI_FRM_SMS_SET_MAILBOX_ADDRESS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_MAILBOX_ADDRESS_RSP_STRUCT*) inMsg;
  1398.     U16 result = MMI_FRM_SMS_ERROR;
  1399.     /*----------------------------------------------------------------*/
  1400.     /* Code Body                                                      */
  1401.     /*----------------------------------------------------------------*/
  1402.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_MAILBOX_ADDRESS_RSP);
  1403.     if ((msgRsp->result) == TRUE)
  1404.     {
  1405.         result = MMI_FRM_SMS_OK;
  1406.     }
  1407.     mmi_frm_sms_callback_action(mailboxDetail, result);
  1408.     OslMfree(mailboxDetail);
  1409. }
  1410. /*****************************************************************************
  1411.  * FUNCTION
  1412.  *  mmi_frm_sms_set_mailbox_info_req
  1413.  * DESCRIPTION
  1414.  *  Set mailbox info request
  1415.  * PARAMETERS
  1416.  *  inMsg       [IN]        Input message
  1417.  * RETURNS
  1418.  *  void
  1419.  *****************************************************************************/
  1420. void mmi_frm_sms_set_mailbox_info_req(void *inMsg)
  1421. {
  1422.     /*----------------------------------------------------------------*/
  1423.     /* Local Variables                                                */
  1424.     /*----------------------------------------------------------------*/
  1425.     MMI_FRM_SMS_SET_MAILBOX_ADDRESS_REQ_STRUCT *msgReq;
  1426.     msg_mailbox_edit_struct *mailbox = (msg_mailbox_edit_struct*) inMsg;
  1427.     S8 mailboxAddress[MAX_DIGITS + 1];
  1428.     /*----------------------------------------------------------------*/
  1429.     /* Code Body                                                      */
  1430.     /*----------------------------------------------------------------*/
  1431.     mailboxDetail = OslMalloc(sizeof(msg_mailbox_edit_struct));
  1432.     memcpy(mailboxDetail, mailbox, sizeof(msg_mailbox_edit_struct));
  1433.     msgReq = (MMI_FRM_SMS_SET_MAILBOX_ADDRESS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1434.     if (mailbox->mailboxNameDcs == PHB_UCS2)
  1435.     {
  1436.         msgReq->name.name_dcs = MMI_PHB_UCS2;
  1437.         msgReq->name.name_length = ((U8) pfnUnicodeStrlen((PS8) mailbox->mailboxName)) * ENCODING_LENGTH;
  1438.         InputboxConvertDeviceEncodingToGSM(
  1439.             (PU8) mailbox->mailboxName,
  1440.             msgReq->name.name,
  1441.             MAX_PROFILE_NAME_LEN,
  1442.             MMI_PHB_UCS2,
  1443.             0,
  1444.             1);
  1445.     }
  1446.     else
  1447.     {
  1448.         msgReq->name.name_dcs = MMI_PHB_ASCII;
  1449.         msgReq->name.name_length = InputboxConvertDeviceEncodingToGSM(
  1450.                                     (PU8) mailbox->mailboxName,
  1451.                                     msgReq->name.name,
  1452.                                     MAX_PROFILE_NAME_LEN,
  1453.                                     MMI_PHB_ASCII,
  1454.                                     0,
  1455.                                     1) - 1;
  1456.     }
  1457.     memset(&msgReq->name.name[msgReq->name.name_length], 0, 1);
  1458.     memset(mailboxAddress, 0, MAX_DIGITS_SMS * ENCODING_LENGTH);
  1459.     UnicodeNToAnsii((PS8) mailboxAddress, (PS8) mailbox->mailboxAddress, MAX_DIGITS_SMS * ENCODING_LENGTH);
  1460.     msgReq->mailbox_num = mailbox->mailboxIndex;
  1461.     if (mailboxAddress[0] == '+')
  1462.     {
  1463.         msgReq->num_addr.type = CSMCC_INTERNATIONAL_ADDR;
  1464.         msgReq->num_addr.length =
  1465.             (strlen(mailboxAddress) > MAX_DIGITS_SMS) ? (MAX_DIGITS_SMS - 1) : (strlen(mailboxAddress) - 1);
  1466.         memcpy(msgReq->num_addr.number, mailboxAddress + 1, msgReq->num_addr.length);
  1467.     }
  1468.     else
  1469.     {
  1470.         msgReq->num_addr.type = CSMCC_DEFAULT_ADDR_TYPE;
  1471.         msgReq->num_addr.length =
  1472.             (strlen(mailboxAddress) > (MAX_DIGITS_SMS - 1)) ? (MAX_DIGITS_SMS - 1) : (strlen(mailboxAddress));
  1473.         memcpy(msgReq->num_addr.number, mailboxAddress, msgReq->num_addr.length);
  1474.     }
  1475.     memset(&msgReq->num_addr.number[msgReq->num_addr.length], 0, 1);
  1476.     SetProtocolEventHandler(mmi_frm_sms_set_mailbox_info_rsp, PRT_MSG_ID_MMI_SMS_SET_MAILBOX_ADDRESS_RSP);
  1477.     mmi_frm_sms_send_message(
  1478.         MOD_MMI,
  1479.         MOD_L4C,
  1480.         0,
  1481.         PRT_MSG_ID_MMI_SMS_SET_MAILBOX_ADDRESS_REQ,
  1482.         (oslParaType*) msgReq,
  1483.         NULL);
  1484.     OslMfree(inMsg);
  1485. }
  1486. /*****************************************************************************
  1487.  * FUNCTION
  1488.  *  mmi_frm_sms_sync_msg_ind
  1489.  * DESCRIPTION
  1490.  *  Handle sync indication
  1491.  * PARAMETERS
  1492.  *  inMsg       [IN]        Input message
  1493.  * RETURNS
  1494.  *  void
  1495.  *****************************************************************************/
  1496. void mmi_frm_sms_sync_msg_ind(void *inMsg)
  1497. {
  1498.     /*----------------------------------------------------------------*/
  1499.     /* Local Variables                                                */
  1500.     /*----------------------------------------------------------------*/
  1501.     MMI_FRM_SMS_SYNC_MSG_IND_STRUCT *msgInd = (MMI_FRM_SMS_SYNC_MSG_IND_STRUCT*) inMsg;
  1502.     U8 i = 0;
  1503.     /*----------------------------------------------------------------*/
  1504.     /* Code Body                                                      */
  1505.     /*----------------------------------------------------------------*/
  1506.     switch (msgInd->action)
  1507.     {
  1508.         case L4C_AT_SMS_ADD:
  1509.             mmi_frm_sms_get_sms(NULL, MOD_MMI, msgInd->index);
  1510.             break;
  1511.         case L4C_AT_SMS_READ_CMGR:
  1512.         case L4C_AT_SMS_READ_CMGL:
  1513.         {
  1514.             U16 msgbox_index = 0;
  1515.             U8 msg_type = 0;
  1516.             mmi_frm_sms_get_sms_msgbox_index(msgInd->index, &msgbox_index);
  1517.             if (msgbox_index != MMI_FRM_SMS_INVALID_INDEX)
  1518.             {
  1519.                 msg_type = (mmi_frm_sms_msg_box[msgbox_index].msgtype & 0x0f);
  1520.                 /* From UNREAD to READ */
  1521.                 if (msg_type == MMI_FRM_SMS_UNREAD && msgInd->status == SMSAL_REC_READ)
  1522.                 {
  1523.                     mmi_frm_sms_set_sms_status(MMI_FRM_SMS_NOBOX, msgbox_index, MMI_FRM_SMS_INBOX);
  1524.                     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1525.                                          "*-------[SmsMsg.c] mmi_frm_sms_sync_msg_ind UNREAD index %d is updated-------*n",
  1526.                                          msgInd->index));
  1527.                 }
  1528.                 /* From READ to UNREAD */
  1529.                 else if (msg_type == MMI_FRM_SMS_INBOX && msgInd->status == SMSAL_REC_UNREAD)
  1530.                 {
  1531.                     mmi_frm_sms_set_sms_status(MMI_FRM_SMS_NOBOX, msgbox_index, MMI_FRM_SMS_UNREAD);
  1532.                     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1533.                                          "*-------[SmsMsg.c] mmi_frm_sms_sync_msg_ind UNREAD index %d is updated-------*n",
  1534.                                          msgInd->index));
  1535.                 }
  1536.                 /* Do nothing if from READ to READ and from UNREAD to UNREAD */
  1537.             }
  1538.             else
  1539.             {
  1540.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1541.                                      "*-------[SmsMsg.c] mmi_frm_sms_sync_msg_ind READ no MSG BOX index %d-------*n",
  1542.                                      msgInd->index));
  1543.             }
  1544.             break;
  1545.         }
  1546.         case L4C_AT_SMS_DELETE:
  1547.             mmi_frm_sms_remove_sms_from_msgbox(msgInd->del_bitmap);
  1548.             break;
  1549.         case L4C_SMS_SIM_REFRESH:
  1550.             mmi_frm_sms_ready_ind(NULL);
  1551.             break;
  1552.     }
  1553.     while (i < mmi_frm_sms_interrupt_handler_size)
  1554.     {
  1555.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_SYNC_MSG_IND)
  1556.         {
  1557.             mmi_frm_sms_interrupt_handler[i].callback(NULL, MOD_MMI, (U16) msgInd->action);
  1558.             break;
  1559.         }
  1560.         i++;
  1561.     }
  1562.     /* Design for flow control */
  1563.     if (msgInd->action == L4C_AT_SMS_READ_CMGR)
  1564.     {
  1565.         mmi_sms_sync_msg_res_req_struct *msgReq;
  1566.         msgReq = (mmi_sms_sync_msg_res_req_struct*) OslConstructDataPtr(sizeof(*msgReq));
  1567.         msgReq->result = TRUE;
  1568.         mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, MSG_ID_MMI_SMS_SYNC_MSG_RES_REQ, (oslParaType*) msgReq, NULL);
  1569.     }
  1570. }
  1571. /*****************************************************************************
  1572.  * FUNCTION
  1573.  *  mmi_frm_sms_sim_refresh_ind
  1574.  * DESCRIPTION
  1575.  *  Handle sim refresh indication from SAT
  1576.  * PARAMETERS
  1577.  *  dummy       [IN]        
  1578.  * RETURNS
  1579.  *  void
  1580.  *****************************************************************************/
  1581. void mmi_frm_sms_sim_refresh_ind(U16 dummy)
  1582. {
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Local Variables                                                */
  1585.     /*----------------------------------------------------------------*/
  1586.     U16 current_screen = GetExitScrnID();
  1587.     BOOL in_sms_screen = TRUE;
  1588.     /*----------------------------------------------------------------*/
  1589.     /* Code Body                                                      */
  1590.     /*----------------------------------------------------------------*/
  1591.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*-------[SmsMsg.c] mmi_frm_sms_sim_refresh_ind SIM Refresh -------*n"));
  1592.     g_frm_sms_cntx.mmi_frm_sms_ready = FALSE;
  1593. #ifdef __MMI_UNIFIED_MESSAGE__
  1594. #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1595.     if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION) || current_screen == SCR_ID_MSG_INBOX_LIST_OPTION)
  1596.     {
  1597.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  1598.     }
  1599.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION) || current_screen == SCR_ID_MSG_OUTBOX_LIST_OPTION)
  1600.     {
  1601.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1602.     }
  1603.     else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION) || current_screen == SCR_ID_MSG_DEFAULT_LIST_OPTION)
  1604.     {
  1605.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_LIST_OPTION);
  1606.     }
  1607.     else
  1608. #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  1609.     if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG) || current_screen == SCR_ID_MSG_INBOX_MSG)
  1610.     {
  1611.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  1612.     }
  1613.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG) || current_screen == SCR_ID_MSG_OUTBOX_MSG)
  1614.     {
  1615.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1616.     }
  1617.     else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG) || current_screen == SCR_ID_MSG_DEFAULT_MSG)
  1618.     {
  1619.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_MSG);
  1620.     }
  1621.     else if (IsScreenPresent(SCR_ID_MSG_SETTINGS) || current_screen == SCR_ID_MSG_SETTINGS)
  1622.     {
  1623.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SETTINGS);
  1624.     }
  1625.     else if (IsScreenPresent(SCR_ID_MSG_VOICE_MAIL_LIST) || current_screen == SCR_ID_MSG_VOICE_MAIL_LIST)
  1626.     {
  1627.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_VOICE_MAIL_LIST);
  1628.     }
  1629.     else if (IsScreenPresent(SCR_ID_MSG_CB_MAIN_MENU) || current_screen == SCR_ID_MSG_CB_MAIN_MENU)
  1630.     {
  1631.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_CB_MAIN_MENU);
  1632.     }
  1633.     else if (IsScreenPresent(SCR_ID_MSG_TEMPLATE_LIST) || current_screen == SCR_ID_MSG_TEMPLATE_LIST)
  1634.     {
  1635.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_TEMPLATE_LIST);
  1636.     }
  1637.     else if (IsScreenPresent(SCR_ID_MSG_WRITE) || current_screen == SCR_ID_MSG_WRITE)
  1638.     {
  1639.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  1640.     }
  1641.     else
  1642.     {
  1643.         in_sms_screen = FALSE;
  1644.     }
  1645. #else /* __MMI_UNIFIED_MESSAGE__ */ 
  1646.     if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST) || current_screen == SCR_ID_MSG_INBOX_LIST)
  1647.     {
  1648.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST);
  1649.     }
  1650.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST) || current_screen == SCR_ID_MSG_OUTBOX_LIST)
  1651.     {
  1652.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST);
  1653.     }
  1654. #ifdef __MMI_MESSAGES_DRAFT_BOX__
  1655.     else if (IsScreenPresent(SCR_ID_MSG_DRAFTBOX_LIST) || current_screen == SCR_ID_MSG_DRAFTBOX_LIST)
  1656.     {
  1657.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DRAFTBOX_LIST);
  1658.     }
  1659. #endif /* __MMI_MESSAGES_DRAFT_BOX__ */ 
  1660.     else if (IsScreenPresent(SCR_ID_MSG_SETTINGS) || current_screen == SCR_ID_MSG_SETTINGS)
  1661.     {
  1662.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SETTINGS);
  1663.     }
  1664.     else if (IsScreenPresent(SCR_ID_MSG_VOICE_MAIL_LIST) || current_screen == SCR_ID_MSG_VOICE_MAIL_LIST)
  1665.     {
  1666.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_VOICE_MAIL_LIST);
  1667.     }
  1668.     else if (IsScreenPresent(SCR_ID_MSG_CB_MAIN_MENU) || current_screen == SCR_ID_MSG_CB_MAIN_MENU)
  1669.     {
  1670.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_CB_MAIN_MENU);
  1671.     }
  1672.     else if (IsScreenPresent(SCR_ID_MSG_WRITE))
  1673.     {
  1674.         /* Only delete SMS screens if sending or saving SMS messages */
  1675.         if (mmi_frm_sms_check_action_pending())
  1676.         {
  1677.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  1678.         }
  1679.         else
  1680.         {
  1681.             in_sms_screen = FALSE;
  1682.         }
  1683.     }
  1684.     else
  1685.     {
  1686.         in_sms_screen = FALSE;
  1687.     }
  1688. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1689.     if (in_sms_screen)
  1690.     {
  1691.         DisplayPopup(
  1692.             (PU8) GetString(STR_SMS_SIM_REFRESH),
  1693.             IMG_GLOBAL_WARNING,
  1694.             1,
  1695.             MESSAGES_POPUP_TIME_OUT,
  1696.             (U8) WARNING_TONE);
  1697.     }
  1698.     mmi_frm_sms_delete_action_pending();
  1699.     if (in_sms_screen)
  1700.     {
  1701.         DeleteMessagesHistoryNodes();
  1702.     }
  1703.     mmi_frm_sms_delete_screen_history();
  1704. #ifdef __MMI_UNIFIED_MESSAGE__
  1705.     mmi_um_handle_sim_refresh(UM_MSG_TYPE_SMS, in_sms_screen);
  1706. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1707. }
  1708. #ifdef __MMI_MESSAGES_COPY__
  1709. /*****************************************************************************
  1710.  * FUNCTION
  1711.  *  mmi_frm_sms_copy_sms_callback
  1712.  * DESCRIPTION
  1713.  *  generic callback action for SMS copy
  1714.  * PARAMETERS
  1715.  *  result      [IN]        cause
  1716.  *  cause       [IN]        
  1717.  * RETURNS
  1718.  *  void
  1719.  *****************************************************************************/
  1720. void mmi_frm_sms_copy_sms_callback(U16 result, U8 cause)
  1721. {
  1722.     /*----------------------------------------------------------------*/
  1723.     /* Local Variables                                                */
  1724.     /*----------------------------------------------------------------*/
  1725.     /*----------------------------------------------------------------*/
  1726.     /* Code Body                                                      */
  1727.     /*----------------------------------------------------------------*/
  1728.     copyResult = OslMalloc(sizeof(mmi_frm_sms_copy_result_struct));
  1729.     copyResult->msg_number = g_frm_sms_copy_info.copy_msg_number;
  1730.     copyResult->cause = cause;
  1731.     mmi_frm_sms_callback_action(copyResult, result);
  1732.     OslMfree(copyResult);
  1733.     copyResult = NULL;
  1734.     return;
  1735. }
  1736. /*****************************************************************************
  1737.  * FUNCTION
  1738.  *  mmi_frm_sms_copy_sms_rollback_rsp
  1739.  * DESCRIPTION
  1740.  *  Delete SMS response for rollback
  1741.  * PARAMETERS
  1742.  *  inMsg       [IN]        Input message
  1743.  * RETURNS
  1744.  *  void
  1745.  *****************************************************************************/
  1746. void mmi_frm_sms_copy_sms_rollback_rsp(void *inMsg)
  1747. {
  1748.     /*----------------------------------------------------------------*/
  1749.     /* Local Variables                                                */
  1750.     /*----------------------------------------------------------------*/
  1751.     MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
  1752.     U8 result = MMI_FRM_SMS_ERROR;
  1753.     /*----------------------------------------------------------------*/
  1754.     /* Code Body                                                      */
  1755.     /*----------------------------------------------------------------*/
  1756.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  1757.     if (msgRsp->result == TRUE)
  1758.     {
  1759.         mmi_frm_sms_remove_sms_from_msgbox(msgRsp->del_bitmap);
  1760.     }
  1761.     mmi_frm_sms_copy_sms_callback((U16) result, result);
  1762. }
  1763. /*****************************************************************************
  1764.  * FUNCTION
  1765.  *  mmi_frm_sms_copy_sms_move_rsp
  1766.  * DESCRIPTION
  1767.  *  Delete SMS response for move action
  1768.  * PARAMETERS
  1769.  *  inMsg       [IN]        Input message
  1770.  * RETURNS
  1771.  *  void
  1772.  *****************************************************************************/
  1773. void mmi_frm_sms_copy_sms_move_rsp(void *inMsg)
  1774. {
  1775.     /*----------------------------------------------------------------*/
  1776.     /* Local Variables                                                */
  1777.     /*----------------------------------------------------------------*/
  1778.     MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
  1779.     U8 result = MMI_FRM_SMS_ERROR;
  1780.     /*----------------------------------------------------------------*/
  1781.     /* Code Body                                                      */
  1782.     /*----------------------------------------------------------------*/
  1783.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  1784.     if (msgRsp->result == TRUE)
  1785.     {
  1786.         result = MMI_FRM_SMS_OK;
  1787.         mmi_frm_sms_remove_sms_from_msgbox(msgRsp->del_bitmap);
  1788.         g_frm_sms_copy_info.copy_msg_number++;
  1789.         g_frm_sms_copy_info.present_L4_index = MMI_FRM_SMS_INVALID_INDEX;
  1790.         g_frm_sms_copy_info.dst_msg_index = MMI_FRM_SMS_INVALID_INDEX;
  1791.         g_frm_sms_copy_info.handled_msg_number++;
  1792.         /* all msgs are handled */
  1793.         if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
  1794.         {
  1795.             if (g_frm_sms_copy_info.is_memory_full)
  1796.             {
  1797.                 mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
  1798.             }
  1799.             else
  1800.             {
  1801.                 mmi_frm_sms_copy_sms_callback((U16) result, result);
  1802.             }
  1803.             return;
  1804.         }
  1805.         /* handle the next msg */
  1806.         else
  1807.         {
  1808.             /* g_frm_sms_copy_info.present_msg_index++; */
  1809.         #ifdef __MMI_UNIFIED_MESSAGE__
  1810.             if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
  1811.             {
  1812.                 MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
  1813.             }
  1814.             else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
  1815.             {
  1816.                 MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
  1817.             }
  1818.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1819.             mmi_frm_sms_pre_copy_sms_req(NULL);
  1820.             return;
  1821.         }
  1822.     }
  1823.     else
  1824.     {
  1825.         mmi_frm_sms_copy_sms_callback((U16) result, result);
  1826.     }
  1827. }
  1828. /*****************************************************************************
  1829.  * FUNCTION
  1830.  *  mmi_frm_sms_copy_sms_seg_rsp
  1831.  * DESCRIPTION
  1832.  *  copy one sms segment rsp
  1833.  * PARAMETERS
  1834.  *  inMsg       [?]     
  1835.  * RETURNS
  1836.  *  void
  1837.  *****************************************************************************/
  1838. void mmi_frm_sms_copy_sms_seg_rsp(void *inMsg)
  1839. {
  1840.     /*----------------------------------------------------------------*/
  1841.     /* Local Variables                                                */
  1842.     /*----------------------------------------------------------------*/
  1843.     MMI_FRM_SMS_COPY_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_COPY_MSG_RSP_STRUCT*) inMsg;
  1844.     /*----------------------------------------------------------------*/
  1845.     /* Code Body                                                      */
  1846.     /*----------------------------------------------------------------*/
  1847.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_COPY_MSG_RSP);
  1848.     if (msgRsp->result == TRUE)
  1849.     {
  1850.         U16 msgindex = 0;
  1851.         mmi_frm_sms_msgbox_struct *entry;
  1852.         switch (g_frm_sms_copy_info.msg_list_type)
  1853.         {
  1854.             case MMI_FRM_SMS_NOBOX:
  1855.                 msgindex = g_frm_sms_copy_info.present_msg_index;
  1856.                 break;
  1857.             case MMI_FRM_SMS_INBOX:
  1858.             case MMI_FRM_SMS_UNREAD:
  1859.                 msgindex = mmi_frm_sms_inbox_list[g_frm_sms_copy_info.present_msg_index];
  1860.                 break;
  1861.             case MMI_FRM_SMS_OUTBOX:
  1862.         #ifndef __MMI_MESSAGES_DRAFT_BOX__
  1863.             case MMI_FRM_SMS_DRAFTS:
  1864.         #endif 
  1865.                 msgindex = mmi_frm_sms_outbox_list[g_frm_sms_copy_info.present_msg_index];
  1866.                 break;
  1867.         #ifdef __MMI_MESSAGES_DRAFT_BOX__
  1868.             case MMI_FRM_SMS_DRAFTS:
  1869.         #ifdef __MMI_UNIFIED_MESSAGE__
  1870.             case MMI_FRM_SMS_UNSENT:
  1871.         #endif 
  1872.                 msgindex = mmi_frm_sms_drafts_list[g_frm_sms_copy_info.present_msg_index];
  1873.                 break;
  1874.         #endif /* __MMI_MESSAGES_DRAFT_BOX__ */ 
  1875.         }
  1876.         /* kal_uint8 result;
  1877.            //kal_uint16   cause;
  1878.            //kal_uint8 action;
  1879.            kal_uint8   dst_storage;
  1880.            kal_uint16  src_index;
  1881.            kal_uint16  dst_index; */
  1882.         entry = OslMalloc(sizeof(mmi_frm_sms_msgbox_struct));
  1883.         memcpy((S8*) entry, (S8*) & mmi_frm_sms_msg_box[msgindex], sizeof(mmi_frm_sms_msgbox_struct));
  1884.         /* if(entry->storageType != MMI_FRM_SMS_PREFER_STORAGE) */
  1885.         entry->storageType = msgRsp->dst_storage;
  1886.         entry->startindex = msgRsp->dst_index;
  1887.         /* There is not timestamp info for outbox SMS stored in SIM  */
  1888.         if (g_frm_sms_copy_info.msg_list_type != MMI_FRM_SMS_INBOX && g_frm_sms_copy_info.msg_list_type != MMI_FRM_SMS_UNREAD)
  1889.         {
  1890.             if (msgRsp->dst_storage == SMSAL_SM)
  1891.             {            
  1892.                 memset(entry->timestamp, 0, sizeof(entry->timestamp));
  1893.             }
  1894.         }
  1895.     #ifdef __MMI_UNIFIED_MESSAGE__
  1896.         /* The MMI SMS content is added in the first segment */
  1897.         if (mmi_frm_sms_index_list[msgRsp->src_index].segment != 1)
  1898.         {
  1899.             memset(entry->content,0,sizeof(entry->content));
  1900.         }
  1901.     
  1902.     #endif /* __MMI_UNIFIED_MESSAGE__ */
  1903.         g_frm_sms_copy_info.dst_msg_index = mmi_frm_sms_add_sms_to_msgbox(entry, msgRsp->dst_index, mmi_frm_sms_index_list[msgRsp->src_index].segment);
  1904.         OslMfree(entry);
  1905.         /* remaing unsent segment of this msg */
  1906.         if (mmi_frm_sms_index_list[g_frm_sms_copy_info.present_L4_index].nextindex != MMI_FRM_SMS_INVALID_INDEX)
  1907.         {
  1908.             mmi_frm_sms_copy_sms_seg_req();
  1909.             return;
  1910.         }
  1911.         /* total segments of this msg have sent */
  1912.         else
  1913.         {
  1914.             U8 type;
  1915.             U16 list_index;
  1916.             mmi_frm_sms_get_sms_list_index(&type, &list_index, g_frm_sms_copy_info.dst_msg_index);
  1917.             /* delete original msg if action == move */
  1918.             if (g_frm_sms_copy_info.action == SMSAL_MOVE_MSG)
  1919.             {
  1920.                 U8 *data = OslMalloc(sizeof(U8) * 480);
  1921.                 U16 deleteMsgIndex = 0;
  1922.                 /* Check if the new msg is added in front of the original one in the list */
  1923.                 if (list_index <= g_frm_sms_copy_info.present_msg_index)
  1924.                 {
  1925.                     g_frm_sms_copy_info.present_msg_index++;
  1926.                 }
  1927.                 deleteMsgIndex = g_frm_sms_copy_info.present_msg_index;
  1928.                 memset((S8*) data, 0, sizeof(U8) * 480);
  1929.             #if (0)
  1930. /* under construction !*/
  1931. /* under construction !*/
  1932. /* under construction !*/
  1933. /* under construction !*/
  1934. /* under construction !*/
  1935. /* under construction !*/
  1936. /* under construction !*/
  1937. /* under construction !*/
  1938. /* under construction !*/
  1939. /* under construction !*/
  1940. /* under construction !*/
  1941. /* under construction !*/
  1942. /* under construction !*/
  1943. /* under construction !*/
  1944. /* under construction !*/
  1945. /* under construction !*/
  1946. /* under construction !*/
  1947. /* under construction !*/
  1948. /* under construction !*/
  1949. /* under construction !*/
  1950. /* under construction !*/
  1951. /* under construction !*/
  1952.             #endif /* (0) */ 
  1953.                 /* swap the new added one with the original next one */
  1954.                 //mmi_frm_sms_swap_list_index(g_frm_sms_copy_info.msg_list_type, (U16)g_frm_sms_copy_info.present_msg_index , list_index);
  1955.                 //deleteMsgIndex = list_index;
  1956.                 if (mmi_frm_sms_get_sms_bitmap((U8) g_frm_sms_copy_info.msg_list_type, deleteMsgIndex, data) == FALSE)
  1957.                 {
  1958.                     OslMfree(data);
  1959.                     mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
  1960.                     return;
  1961.                 }
  1962.                 else
  1963.                 {
  1964.                     MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
  1965.                     msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1966.                     msgReq->del_flag = SMSAL_DEL_BITMAP;
  1967.                     memcpy((S8*) msgReq->del_bitmap, (S8*) data, 480);
  1968.                     OslMfree(data);
  1969.                     SetProtocolEventHandler(mmi_frm_sms_copy_sms_move_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  1970.                     mmi_frm_sms_send_message(
  1971.                         MOD_MMI,
  1972.                         MOD_L4C,
  1973.                         0,
  1974.                         PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ,
  1975.                         (oslParaType*) msgReq,
  1976.                         NULL);
  1977.                     return;
  1978.                 }
  1979.             }
  1980.             /* Check if the new msg is added in front of the original one in the list */
  1981.             if (list_index <= g_frm_sms_copy_info.present_msg_index)
  1982.             {
  1983.                 g_frm_sms_copy_info.present_msg_index++;
  1984.                 g_frm_sms_copy_info.handled_msg_number++;
  1985.             }
  1986.             /* if action == copy */
  1987.             g_frm_sms_copy_info.copy_msg_number++;
  1988.             g_frm_sms_copy_info.present_L4_index = MMI_FRM_SMS_INVALID_INDEX;
  1989.             g_frm_sms_copy_info.dst_msg_index = MMI_FRM_SMS_INVALID_INDEX;
  1990.             g_frm_sms_copy_info.handled_msg_number++;
  1991.             /* The new msg is already in list. Get new list size if copy all */
  1992.             if (g_frm_sms_copy_info.total_msg_number > 1)
  1993.             {
  1994.                 g_frm_sms_copy_info.total_msg_number = mmi_frm_sms_get_sms_list_size(g_frm_sms_copy_info.msg_list_type);
  1995.             }
  1996.             /* all msgs are handled */
  1997.             if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
  1998.             {
  1999.                 if (g_frm_sms_copy_info.is_memory_full)
  2000.                 {
  2001.                     mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
  2002.                 }
  2003.                 else
  2004.                 {
  2005.                     mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_OK, MMI_FRM_SMS_OK);
  2006.                 }
  2007.                 return;
  2008.             }
  2009.             /* handle the next msg */
  2010.             else
  2011.             {
  2012.                 g_frm_sms_copy_info.present_msg_index++;
  2013.             #ifdef __MMI_UNIFIED_MESSAGE__
  2014.                 if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
  2015.                 {
  2016.                     MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
  2017.                 }
  2018.                 else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
  2019.                 {
  2020.                     MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
  2021.                 }
  2022.             #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2023.                 mmi_frm_sms_pre_copy_sms_req(NULL);
  2024.                 return;
  2025.             }
  2026.         }
  2027.     }
  2028.     /* if(msgRsp->result == TRUE) */
  2029.     else
  2030.     {
  2031.         /* kal_uint8 result;
  2032.            kal_uint16  cause;
  2033.            kal_uint8   action;
  2034.            kal_uint8   dst_storage;
  2035.            kal_uint16  src_index;
  2036.            kal_uint16  dst_index; */
  2037.         /* first segment , no need to rollback */
  2038.         if (g_frm_sms_copy_info.dst_msg_index == MMI_FRM_SMS_INVALID_INDEX)
  2039.         {
  2040.             mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
  2041.             return;
  2042.         }
  2043.         /* rollback the last incomplete copied msg */
  2044.         else
  2045.         {
  2046.             U8 *data = OslMalloc(sizeof(U8) * 480);
  2047.             memset((S8*) data, 0, sizeof(U8) * 480);
  2048.             if (mmi_frm_sms_get_sms_bitmap
  2049.                 (MMI_FRM_SMS_AWAITS, mmi_frm_sms_msg_box[g_frm_sms_copy_info.dst_msg_index].startindex, data) == FALSE)
  2050.             {
  2051.                 OslMfree(data);
  2052.                 mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
  2053.                 return;
  2054.             }
  2055.             else
  2056.             {
  2057.                 MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
  2058.                 msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  2059.                 msgReq->del_flag = SMSAL_DEL_BITMAP;
  2060.                 memcpy((S8*) msgReq->del_bitmap, (S8*) data, 480);
  2061.                 SetProtocolEventHandler(mmi_frm_sms_copy_sms_rollback_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  2062.                 mmi_frm_sms_send_message(
  2063.                     MOD_MMI,
  2064.                     MOD_L4C,
  2065.                     0,
  2066.                     PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ,
  2067.                     (oslParaType*) msgReq,
  2068.                     NULL);
  2069.                 OslMfree(data);
  2070.                 return;
  2071.             }
  2072.         }
  2073.     }
  2074. }
  2075. /*****************************************************************************
  2076.  * FUNCTION
  2077.  *  mmi_frm_sms_copy_sms_seg_req
  2078.  * DESCRIPTION
  2079.  *  copy one sms segment req
  2080.  * PARAMETERS
  2081.  *  void
  2082.  * RETURNS
  2083.  *  void
  2084.  *****************************************************************************/
  2085. void mmi_frm_sms_copy_sms_seg_req()
  2086. {
  2087.     /*----------------------------------------------------------------*/
  2088.     /* Local Variables                                                */
  2089.     /*----------------------------------------------------------------*/
  2090.     MMI_FRM_SMS_COPY_MSG_REQ_STRUCT *msgReq;
  2091.     /*----------------------------------------------------------------*/
  2092.     /* Code Body                                                      */
  2093.     /*----------------------------------------------------------------*/
  2094.     msgReq = (MMI_FRM_SMS_COPY_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  2095.     /* first segment of message */
  2096.     if (g_frm_sms_copy_info.present_L4_index == MMI_FRM_SMS_INVALID_INDEX)
  2097.     {
  2098.         U16 msgindex = 0;
  2099.         switch (g_frm_sms_copy_info.msg_list_type)
  2100.         {
  2101.             case MMI_FRM_SMS_NOBOX:
  2102.                 msgindex = g_frm_sms_copy_info.present_msg_index;
  2103.                 break;
  2104.             case MMI_FRM_SMS_INBOX:
  2105.             case MMI_FRM_SMS_UNREAD:
  2106.                 msgindex = mmi_frm_sms_inbox_list[g_frm_sms_copy_info.present_msg_index];
  2107.                 break;
  2108.             case MMI_FRM_SMS_OUTBOX:
  2109.         #ifndef __MMI_MESSAGES_DRAFT_BOX__
  2110.             case MMI_FRM_SMS_DRAFTS:
  2111.         #endif 
  2112.                 msgindex = mmi_frm_sms_outbox_list[g_frm_sms_copy_info.present_msg_index];
  2113.                 break;
  2114.         #ifdef __MMI_MESSAGES_DRAFT_BOX__
  2115.             case MMI_FRM_SMS_DRAFTS:
  2116.         #ifdef __MMI_UNIFIED_MESSAGE__
  2117.             case MMI_FRM_SMS_UNSENT:
  2118.         #endif 
  2119.                 msgindex = mmi_frm_sms_drafts_list[g_frm_sms_copy_info.present_msg_index];
  2120.                 break;
  2121.         #endif /* __MMI_MESSAGES_DRAFT_BOX__ */ 
  2122.         }
  2123.         g_frm_sms_copy_info.present_L4_index = mmi_frm_sms_msg_box[msgindex].startindex;
  2124.     }
  2125.     /* not the first segment */
  2126.     else
  2127.     {   /* check if the nextindex == invalid index in mmi_frm_sms_copy_sms_seg_rsp, not here */
  2128.         g_frm_sms_copy_info.present_L4_index = mmi_frm_sms_index_list[g_frm_sms_copy_info.present_L4_index].nextindex;
  2129.     }
  2130.     msgReq->action = SMSAL_COPY_MSG;
  2131.     msgReq->dst_storage = g_frm_sms_copy_info.dst_storage;
  2132.     msgReq->src_index = g_frm_sms_copy_info.present_L4_index;
  2133.     SetProtocolEventHandler(mmi_frm_sms_copy_sms_seg_rsp, PRT_MSG_ID_MMI_SMS_COPY_MSG_RSP);
  2134.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_COPY_MSG_REQ, (oslParaType*) msgReq, NULL);
  2135. }
  2136. /*****************************************************************************
  2137.  * FUNCTION
  2138.  *  mmi_frm_sms_pre_copy_sms_rsp
  2139.  * DESCRIPTION
  2140.  *  Get memory status response
  2141.  * PARAMETERS
  2142.  *  inMsg       [IN]        Input message
  2143.  * RETURNS
  2144.  *  void
  2145.  *****************************************************************************/
  2146. void mmi_frm_sms_pre_copy_sms_rsp(void *inMsg)
  2147. {
  2148.     /*----------------------------------------------------------------*/
  2149.     /* Local Variables                                                */
  2150.     /*----------------------------------------------------------------*/
  2151.     MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_MSG_NUM_RSP_STRUCT*) inMsg;
  2152.     U8 segmentNumber = mmi_frm_sms_get_sms_received_size(g_frm_sms_copy_info.msg_list_type, g_frm_sms_copy_info.present_msg_index);
  2153.     U16 availableMemorySize = 0;
  2154.     /*----------------------------------------------------------------*/
  2155.     /* Code Body                                                      */
  2156.     /*----------------------------------------------------------------*/
  2157.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
  2158.     if (msgRsp->result == TRUE)
  2159.     {
  2160.         if (g_frm_sms_copy_info.dst_storage == SMSAL_SM)
  2161.         {
  2162.             availableMemorySize = msgRsp->total_sim_num - msgRsp->in_sim_no - msgRsp->out_sim_no;
  2163.         }
  2164.         else    /* SMSAL_ME */
  2165.         {
  2166.             availableMemorySize = msgRsp->total_me_num - msgRsp->in_me_no - msgRsp->out_me_no;
  2167.         }
  2168.         if (availableMemorySize == 0)   /* no more available Memory */
  2169.         {
  2170.             mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
  2171.             return;
  2172.         }
  2173.         else if (availableMemorySize < segmentNumber)   /* not enough for this msg, try the next msg */
  2174.         {
  2175.             g_frm_sms_copy_info.is_memory_full = TRUE;
  2176.             g_frm_sms_copy_info.handled_msg_number++;
  2177.             if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
  2178.             {
  2179.                 mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
  2180.                 return;
  2181.             }
  2182.             else
  2183.             {
  2184.                 g_frm_sms_copy_info.present_msg_index++;
  2185.             #ifdef __MMI_UNIFIED_MESSAGE__
  2186.                 if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
  2187.                 {
  2188.                     MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
  2189.                 }
  2190.                 else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
  2191.                 {
  2192.                     MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
  2193.                 }
  2194.             #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2195.                 mmi_frm_sms_pre_copy_sms_req(NULL);
  2196.             }
  2197.         }
  2198.         else
  2199.         {
  2200.             mmi_frm_sms_copy_sms_seg_req();
  2201.         }
  2202.     }
  2203.     else
  2204.     {
  2205.         mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ERROR, MMI_FRM_SMS_ERROR);
  2206.         return;
  2207.     }
  2208. }
  2209. /*****************************************************************************
  2210.  * FUNCTION
  2211.  *  mmi_frm_sms_pre_copy_sms_req
  2212.  * DESCRIPTION
  2213.  *  pre-copy SMS : check before copy SMS
  2214.  * PARAMETERS
  2215.  *  dummy       [?]     
  2216.  * RETURNS
  2217.  *  void
  2218.  *****************************************************************************/
  2219. void mmi_frm_sms_pre_copy_sms_req(void *dummy)
  2220. {
  2221.     /*----------------------------------------------------------------*/
  2222.     /* Local Variables                                                */
  2223.     /*----------------------------------------------------------------*/
  2224.     /*----------------------------------------------------------------*/
  2225.     /* Code Body                                                      */
  2226.     /*----------------------------------------------------------------*/
  2227.     /* check if user aborts SMS copy action */
  2228.     if (g_frm_sms_copy_info.is_aborted)
  2229.     {
  2230.         g_frm_sms_copy_info.is_aborted = FALSE;
  2231.         mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_ABORT, MMI_FRM_SMS_ABORT);
  2232.         return;
  2233.     }
  2234.     /* check msg storage */
  2235.     while (mmi_frm_sms_get_sms_storage(g_frm_sms_copy_info.msg_list_type, g_frm_sms_copy_info.present_msg_index) ==
  2236.            g_frm_sms_copy_info.dst_storage)
  2237.     {
  2238.         g_frm_sms_copy_info.handled_msg_number++;
  2239.         /*  copy one by one should not enter this loop, or will return here  */
  2240.         if (g_frm_sms_copy_info.handled_msg_number >= g_frm_sms_copy_info.total_msg_number)
  2241.         {
  2242.             if (g_frm_sms_copy_info.is_memory_full)
  2243.             {
  2244.                 mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_MEMFULL, MMI_FRM_SMS_MEMFULL);
  2245.             }
  2246.             else
  2247.             {
  2248.                 mmi_frm_sms_copy_sms_callback(MMI_FRM_SMS_OK, MMI_FRM_SMS_OK);
  2249.             }
  2250.             return;
  2251.         }
  2252.         /* only for copy all */
  2253.         g_frm_sms_copy_info.present_msg_index++;
  2254.     #ifdef __MMI_UNIFIED_MESSAGE__
  2255.         if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_UNSENT)
  2256.         {
  2257.             MMI_ASSERT(mmi_frm_sms_get_next_unsent_msg(&g_frm_sms_copy_info.present_msg_index));
  2258.         }
  2259.         else if (g_frm_sms_copy_info.msg_list_type == MMI_FRM_SMS_DRAFTS)
  2260.         {
  2261.             MMI_ASSERT(mmi_frm_sms_get_next_draft_msg(&g_frm_sms_copy_info.present_msg_index));
  2262.         }
  2263.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2264.     }
  2265.     SetProtocolEventHandler(mmi_frm_sms_pre_copy_sms_rsp, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_RSP);
  2266.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_GET_MSG_NUM_REQ, NULL, NULL);
  2267. }
  2268. #endif /* __MMI_MESSAGES_COPY__ */ 
  2269. /*****************************************************************************
  2270.  * FUNCTION
  2271.  *  mmi_frm_sms_startup_wap_browser_req
  2272.  * DESCRIPTION
  2273.  *  extract url in SMS text and link to WAP browser
  2274.  * PARAMETERS
  2275.  *  type        [IN]        
  2276.  *  URL         [?]         
  2277.  * RETURNS
  2278.  *  void
  2279.  *****************************************************************************/
  2280. #ifdef __MMI_MESSAGES_USE_URL__
  2281. void mmi_frm_sms_startup_wap_browser_req(U8 type, void *URL)
  2282. {
  2283.     /*----------------------------------------------------------------*/
  2284.     /* Local Variables                                                */
  2285.     /*----------------------------------------------------------------*/
  2286.     MMI_FRM_SMS_WAP_BROWSER_STARTUP_REQ *open_url_req;
  2287.     /*----------------------------------------------------------------*/
  2288.     /* Code Body                                                      */
  2289.     /*----------------------------------------------------------------*/
  2290.     open_url_req = (MMI_FRM_SMS_WAP_BROWSER_STARTUP_REQ*) OslConstructDataPtr(sizeof(*open_url_req));
  2291.     open_url_req->type = type;
  2292.     memset(open_url_req->url, 0, sizeof(open_url_req->url));
  2293.     strncpy((char*)open_url_req->url, (const char*) URL, (sizeof(open_url_req->url) - 1));
  2294.     mmi_frm_sms_send_message(MOD_MMI, MOD_WAP, 0, MSG_ID_WAP_BROWSER_STARTUP_REQ, (void*)open_url_req, NULL);
  2295. }
  2296. #endif /* __MMI_MESSAGES_USE_URL__ */ 
  2297. /*****************************************************************************
  2298.  * FUNCTION
  2299.  *  mmi_frm_sms_entry_write_msg_req
  2300.  * DESCRIPTION
  2301.  *  entry write msg screen with content
  2302.  * PARAMETERS
  2303.  *  entry_write_data        [?]     
  2304.  *  void*  data(?)
  2305.  * RETURNS
  2306.  *  void
  2307.  *****************************************************************************/
  2308. void mmi_frm_sms_entry_write_msg_req(void *entry_write_data)
  2309. {
  2310.     /*----------------------------------------------------------------*/
  2311.     /* Local Variables                                                */
  2312.     /*----------------------------------------------------------------*/
  2313.     mmi_frm_sms_api_entry_write_struct *data = (mmi_frm_sms_api_entry_write_struct*) entry_write_data;
  2314.     EMSData *pEMS;
  2315.     S8 *textbuf = NULL;
  2316.     S8 *textbufucs2 = NULL;
  2317.     U16 textlen = 0;
  2318.     U16 result = 0;
  2319.     history temphistory;
  2320. #ifdef __MMI_UNIFIED_COMPOSER__
  2321.     U8* addr = NULL;
  2322.     U16 type = MMI_UC_STATE_WRITE_NEW_MSG;
  2323. #endif /* __MMI_UNIFIED_COMPOSER__ */    
  2324.     /*----------------------------------------------------------------*/
  2325.     /* Code Body                                                      */
  2326.     /*----------------------------------------------------------------*/
  2327.     if (data->filename != NULL)
  2328.     {
  2329.         S32 errorCode = 0;
  2330.         FILE_HANDLE emsObjectFilePtr;
  2331.         emsObjectFilePtr = pfopen((U8*) data->filename, PFS_READ);
  2332.         /* the file exists without error */
  2333.         if (!pfOpenError(emsObjectFilePtr))
  2334.         {
  2335.             textlen = (U16) GetFSFileSize(emsObjectFilePtr);
  2336.             /* the file size is 0 */
  2337.             if (textlen == 0)
  2338.             {
  2339.                 pfclose(emsObjectFilePtr);
  2340.                 DisplayPopup(
  2341.                     (PU8) GetString(STR_SMS_FAILURE_DATA_EMPTY),
  2342.                     IMG_GLOBAL_UNFINISHED,
  2343.                     1,
  2344.                     MESSAGES_POPUP_TIME_OUT,
  2345.                     (U8) ERROR_TONE);
  2346.                 return;
  2347.             }
  2348.             if (data->dcs == SMSAL_8BIT_DCS)
  2349.             {
  2350.                 /* the file is too large. */
  2351.                 if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG / ENCODING_LENGTH) ||
  2352.                     textlen > ((MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE / ENCODING_LENGTH) - 1))
  2353.                 {
  2354.                     pfclose(emsObjectFilePtr);
  2355.                     DisplayPopup(
  2356.                         (PU8) GetString(STR_SMS_FAILURE_DATA_EXCEED),
  2357.                         IMG_GLOBAL_UNFINISHED,
  2358.                         1,
  2359.                         MESSAGES_POPUP_TIME_OUT,
  2360.                         (U8) ERROR_TONE);
  2361.                     return;
  2362.                 }
  2363.                 /* the file size is allowed */
  2364.                 textbuf = OslMalloc(textlen + 1);
  2365.                 pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
  2366.                 pfclose(emsObjectFilePtr);
  2367.                 /* the file content is corrupted */
  2368.                 if (pfError(errorCode))
  2369.                 {
  2370.                     DisplayPopup(
  2371.                         (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
  2372.                         IMG_GLOBAL_UNFINISHED,
  2373.                         1,
  2374.                         MESSAGES_POPUP_TIME_OUT,
  2375.                         (U8) ERROR_TONE);
  2376.                     OslMfree(textbuf);
  2377.                     return;
  2378.                 }
  2379.                 /* the file content is allowed */
  2380.                 textbufucs2 = OslMalloc((textlen + 1) * ENCODING_LENGTH);
  2381.                 AnsiiNToUnicodeString(textbufucs2, textbuf, textlen);
  2382.                 memset(textbufucs2 + textlen * ENCODING_LENGTH, 0, ENCODING_LENGTH);
  2383.                 OslMfree(textbuf);
  2384.             }
  2385.             /* UCS2 and  DEFAULT DCS */
  2386.             else
  2387.             {
  2388.                 /* the file is too large. */
  2389.                 if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG) ||
  2390.                     textlen > (MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE - ENCODING_LENGTH))
  2391.                 {
  2392.                     pfclose(emsObjectFilePtr);
  2393.                     DisplayPopup(
  2394.                         (PU8) GetString(STR_SMS_FAILURE_DATA_EXCEED),
  2395.                         IMG_GLOBAL_UNFINISHED,
  2396.                         1,
  2397.                         MESSAGES_POPUP_TIME_OUT,
  2398.                         (U8) ERROR_TONE);
  2399.                     return;
  2400.                 }
  2401.                 /* the file size is allowed */
  2402.                 textbuf = OslMalloc(textlen + ENCODING_LENGTH);
  2403.                 pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
  2404.                 pfclose(emsObjectFilePtr);
  2405.                 /* the file content is corrupted */
  2406.                 if (pfError(errorCode))
  2407.                 {
  2408.                     DisplayPopup(
  2409.                         (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
  2410.                         IMG_GLOBAL_UNFINISHED,
  2411.                         1,
  2412.                         MESSAGES_POPUP_TIME_OUT,
  2413.                         (U8) ERROR_TONE);
  2414.                     OslMfree(textbuf);
  2415.                     return;
  2416.                 }
  2417.                 /* the file content is allowed */
  2418.                 textbufucs2 = OslMalloc((textlen + ENCODING_LENGTH));
  2419.                 memset(textbufucs2, 0, (textlen + ENCODING_LENGTH));
  2420.                 memcpy(textbufucs2, textbuf, textlen);
  2421.                 OslMfree(textbuf);
  2422.             }
  2423.         }
  2424.         else
  2425.         {
  2426.             DisplayPopup(
  2427.                 (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
  2428.                 IMG_GLOBAL_UNFINISHED,
  2429.                 1,
  2430.                 MESSAGES_POPUP_TIME_OUT,
  2431.                 (U8) ERROR_TONE);
  2432.             return;
  2433.         }
  2434.     }
  2435.     else if (data->string != NULL && data->stringlength > 0)
  2436.     {
  2437.         textbufucs2 = OslMalloc((data->stringlength) * ENCODING_LENGTH);
  2438.         memset((S8*) textbufucs2, 0, ((data->stringlength) * ENCODING_LENGTH));
  2439.         memcpy(textbufucs2, data->string, ((data->stringlength) * ENCODING_LENGTH));
  2440.     }
  2441.     else
  2442.     {
  2443.         ReleaseEMSEditBuffer();
  2444.     }
  2445.     if (textbufucs2)
  2446.     {
  2447.         EMSTATUS EMSSetPortResult = EMS_OK;
  2448.         EMSTATUS EMSSetClassResult = EMS_OK;
  2449.         ReleaseEMSEditBuffer();
  2450.         pEMS = GetEMSDataForEdit(0, 1);
  2451.     #ifdef MMI_ON_HARDWARE_P
  2452.         if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_PORT) == MMI_FRM_SMS_ENTRY_WRITE_PORT)
  2453.         {
  2454.             EMSSetPortResult = EMSSetPortNum(pEMS, data->srcport, data->desport);
  2455.         }
  2456.         if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_CLASS) == MMI_FRM_SMS_ENTRY_WRITE_CLASS)
  2457.         {
  2458.             EMSSetClassResult = EMSSetMsgClass(pEMS, data->dcs_class);
  2459.         }
  2460.         if ((EMSSetPortResult != EMS_OK) || (EMSSetClassResult != EMS_OK))
  2461.         {
  2462.             DisplayPopup(
  2463.                 (PU8) GetString(STR_SMS_FAILURE_DATA_INVALID),
  2464.                 IMG_GLOBAL_UNFINISHED,
  2465.                 1,
  2466.                 MESSAGES_POPUP_TIME_OUT,
  2467.                 (U8) ERROR_TONE);
  2468.             OslMfree(textbufucs2);
  2469.             return;
  2470.         }
  2471.     #endif /* MMI_ON_HARDWARE_P */ 
  2472.         if (data->filename != NULL)
  2473.         {
  2474.             result = AppendEMSString(
  2475.                         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  2476.                         pEMS,
  2477.                         (U8*) textbufucs2,
  2478.                         data->dcs,
  2479.                         temphistory.guiBuffer);
  2480.         }
  2481.         else if (data->string != NULL)
  2482.         {
  2483.             EMSSetDCS(pEMS, data->dcs);
  2484.             result = AddString(pEMS, (U8*) textbufucs2, data->stringlength, NULL);
  2485.         }
  2486.         OslMfree(textbufucs2);
  2487.         if ((data->filename != NULL && result == 0) || (data->string != NULL && result != EMS_OK))
  2488.         {
  2489.             DisplayPopup(
  2490.                 (PU8) GetString(STR_SMS_FAILURE_DATA_EXCEED),
  2491.                 IMG_GLOBAL_UNFINISHED,
  2492.                 1,
  2493.                 MESSAGES_POPUP_TIME_OUT,
  2494.                 (U8) ERROR_TONE);;
  2495.             return;
  2496.         }
  2497.     }
  2498. #ifdef __MMI_UNIFIED_COMPOSER__
  2499.     if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_REPLY) == MMI_FRM_SMS_ENTRY_WRITE_REPLY)
  2500.     {
  2501.         if (data->ascii_addr && strlen((S8*)data->ascii_addr))
  2502.         {
  2503.             addr = data->ascii_addr;
  2504.             type = MMI_UC_STATE_REPLY;
  2505.         }
  2506.     }
  2507.     mmi_msg_entry_uc(addr, type, 0, MMI_UC_MSG_TYPE_SMS_ONLY);
  2508. #else /* __MMI_UNIFIED_COMPOSER__ */
  2509.     if ((data->flag & MMI_FRM_SMS_ENTRY_WRITE_REPLY) == MMI_FRM_SMS_ENTRY_WRITE_REPLY)
  2510.     {
  2511.         if (data->ascii_addr && strlen((S8*)data->ascii_addr))
  2512.         {
  2513.             strncpy((S8*)g_msg_cntx.smsPhoneNumber, (S8*)data->ascii_addr, MAX_DIGITS_SMS - 1);
  2514.             g_msg_cntx.sendMessageCase = SEND_CASE_REPLY_FROM_OTHER_APP;
  2515.         }
  2516.     }
  2517.     mmi_msg_entry_write_msg();
  2518. #endif /* __MMI_UNIFIED_COMPOSER__ */
  2519.     
  2520. }
  2521. /*****************************************************************************
  2522.  * FUNCTION
  2523.  *  mmi_frm_sms_set_protocol_event_handler
  2524.  * DESCRIPTION
  2525.  *  Set protocol event handler
  2526.  * PARAMETERS
  2527.  *  void
  2528.  * RETURNS
  2529.  *  void
  2530.  *****************************************************************************/
  2531. void mmi_frm_sms_set_protocol_event_handler(void)
  2532. {
  2533.     /*----------------------------------------------------------------*/
  2534.     /* Local Variables                                                */
  2535.     /*----------------------------------------------------------------*/
  2536.     /*----------------------------------------------------------------*/
  2537.     /* Code Body                                                      */
  2538.     /*----------------------------------------------------------------*/
  2539.     SetProtocolEventHandler(mmi_frm_sms_new_sms_ind, PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND);
  2540.     SetProtocolEventHandler(mmi_frm_sms_new_data_ind, PRT_MSG_ID_MMI_SMS_APP_DATA_IND);
  2541.     SetProtocolEventHandler(mmi_frm_sms_ready_ind, PRT_MSG_ID_MMI_SMS_READY_IND);
  2542.     SetProtocolEventHandler(mmi_frm_sms_startup_begin_ind, PRT_MSG_ID_MMI_SMS_STARTUP_BEGIN_IND);
  2543.     SetProtocolEventHandler(mmi_frm_sms_status_report_ind, PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND);
  2544.     SetProtocolEventHandler(mmi_frm_sms_mem_avai_ind, PRT_MSG_ID_MMI_SMS_MEM_AVAILABLE_IND);
  2545.     SetProtocolEventHandler(mmi_frm_sms_mem_exceed_ind, PRT_MSG_ID_MMI_SMS_MEM_EXCEED_IND);
  2546.     SetProtocolEventHandler(mmi_frm_sms_mem_full_ind, PRT_MSG_ID_MMI_SMS_MEM_FULL_IND);
  2547.     SetProtocolEventHandler(mmi_frm_sms_msg_waiting_ind, PRT_MSG_ID_MMI_SMS_MSG_WAITING_IND);
  2548.     SetProtocolEventHandler(mmi_frm_sms_sync_msg_ind, PRT_MSG_ID_MMI_SMS_SYNC_MSG_IND);
  2549. }
  2550. #endif /* __MOD_SMSAL__ */