JMMSJsrHandler.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:133k
源码类别:
MTK
开发平台:
C/C++
- case JC_ERR_FILE_SYS_INIT:
- case JC_ERR_FILE_MOVE:
- case JC_ERR_FILE_INVALID_SYSTEM_HANDLE:
- return JSR_RESULT_FILE_OPERATION_ERROR;
- default:
- return JSR_RESULT_ERROR;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_add_media_object
- * DESCRIPTION
- *
- * PARAMETERS
- * msgId [IN]
- * message [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JsrResult mmi_jmms_jsr_add_media_object(U32 msgId, wap_mmc_post_appmms_msg_part_res_struct *message)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MEDIA_MIME_INFO *media_info_p = NULL;
- JC_UINT32 file_size = 0;
- JC_UINT32 read_cnt = 0;
- FS_HANDLE file_handle;
- JC_RETCODE ret_code = JC_OK;
- JC_INT8 *media_buffer_p = NULL;
- JC_INT8 *temp_buffer_p = NULL;
- JC_CHAR *path_p = NULL;
- JC_INT8 temp_file_path[40] = {0, };
- JDD_FSHANDLE vFileSysHandle = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): Enters function mmi_jmms_jsr_add_media_object() n", __FILE__, __LINE__));
- if ((message == NULL)
- || (message->filepath_len == 0)
- || (message->content_type_len == 0) || (message->content_id_len == 0 && message->content_location_len == 0))
- {
- return mmi_jmms_java_mms_error(JC_ERR_MSG_INVALID_HANDLE);
- }
- media_info_p = (MEDIA_MIME_INFO*) jdd_MemAlloc(sizeof(MEDIA_MIME_INFO), sizeof(U8));
- if (media_info_p == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- /* Initialize the File System Handle */
- ret_code = jdd_FSInitialize(&vFileSysHandle);
- if(ret_code != JC_OK)
- {
- goto ERROR_HANDLE;
- }
- jc_sprintf(temp_file_path, "@mms\temp\~jsr_temp_file%d", media_obj_index);
- media_obj_index++; /* increment index for next media object */
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s (%s) n", "JMMS JSR Add Media File Name", temp_file_path));
- jdi_UtilsCharToTchar((JC_CHAR **) &(path_p), temp_file_path);
- if(path_p == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- ret_code = jdd_FSMove(NULL, (JC_CHAR*)message->filepath, vFileSysHandle, (JC_CHAR*) path_p);
- if(ret_code != JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR Add Media File Move Failed", __FILE__, __LINE__));
- goto ERROR_HANDLE;
- }
- if(vFileSysHandle)
- {
- jdd_FSDeinitialize(vFileSysHandle);
- vFileSysHandle = NULL;
- }
- file_handle = FS_Open((U16*) path_p, FS_READ_ONLY);
- FS_GetFileSize(file_handle, &file_size);
- FS_Close(file_handle);
- if (message->content_id_len > 0)
- {
- media_info_p->MimeHeaders.pContentID = (JC_INT8*) jdd_MemAlloc(sizeof(JC_INT8), message->content_id_len + 1);
- if (media_info_p->MimeHeaders.pContentID == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- memcpy(media_info_p->MimeHeaders.pContentID, message->content_id, message->content_id_len);
- }
- if (message->content_location_len > 0)
- {
- ret_code = jdi_UtilsCharToTchar(
- (JC_CHAR **) & (media_info_p->MimeHeaders.pObjectName),
- (JC_INT8*) message->content_location);
- if (media_info_p->MimeHeaders.pObjectName == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- }
- media_info_p->MimeHeaders.bIsAttachment = 0;
- if (strstr((S8*) message->content_type, "text/plain") != NULL)
- {
- media_info_p->MimeHeaders.pContentType = jdi_UtilsStrdup((JC_INT8*) ("text/plain"));
- if (media_info_p->MimeHeaders.pContentType == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- media_info_p->ContentData.uiTotalSize = (file_size) * sizeof(JC_CHAR);
- media_info_p->ContentData.uiCurSize = (file_size) * sizeof(JC_CHAR);
- temp_buffer_p = (JC_INT8*) jdd_MemAlloc(file_size + 1, sizeof(JC_CHAR));
- if (temp_buffer_p == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- file_handle = FS_Open((U16*) path_p, FS_READ_ONLY);
- if (file_size > 0)
- {
- FS_Read(file_handle, temp_buffer_p, file_size, &read_cnt);
- }
- FS_Close(file_handle);
- if (message->encoding_scheme == MMS_US_ASCII)
- {
- ret_code = jdi_UtilsCharToTchar((JC_CHAR **) & media_buffer_p, (JC_INT8*) temp_buffer_p);
- }
- else if (message->encoding_scheme == MMS_UTF8)
- {
- ret_code = jdi_UtilsUTF8ToTchar((JC_CHAR **) & media_buffer_p, (JC_UINT8*) temp_buffer_p, (JC_UINT32) file_size);
- }
- if (ret_code != JC_OK)
- {
- goto ERROR_HANDLE;
- }
- media_info_p->ContentData.pBuffer = (JC_UINT8*) media_buffer_p;
- }
- else
- {
- if (message->content_type_len > 0)
- {
- media_info_p->MimeHeaders.pContentType =
- (JC_INT8*) jdd_MemAlloc(message->content_type_len + 1, sizeof(JC_INT8));
- if (media_info_p->MimeHeaders.pContentType == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- jc_strcpy(media_info_p->MimeHeaders.pContentType, message->content_type);
- }
- media_info_p->ContentData.bIsStream = E_TRUE;
- media_info_p->ContentData.eCopyMemory = E_FALSE;
- media_info_p->ContentData.pBuffer = NULL;
- media_info_p->ContentData.uiCurSize = 0;
- media_info_p->ContentData.uiTotalSize = file_size;
- media_info_p->ContentData.cbReadCallback = mmi_jmms_read_callback;
- media_info_p->ContentData.cbWriteCallback = NULL;
- media_info_p->ContentData.uiStartOffset = 0;
- media_info_p->ContentData.pFileName =
- (JC_CHAR*) jdd_MemAlloc((jc_tcslen((JC_CHAR*) path_p) + 1), sizeof(JC_CHAR));
- if (media_info_p->ContentData.pFileName == NULL)
- {
- ret_code = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- jc_tcscpy((UI_character_type*) media_info_p->ContentData.pFileName, (UI_character_type*) path_p);
- media_info_p->ContentData.pStream = media_info_p->ContentData.pFileName;
- /*media_info_p->MimeHeaders.bIsAttachment = 0;*/
- }
- /* add media */
- ret_code = AddMediaToMM1Handle(g_jmms_context->hMM1, media_info_p,E_TRUE);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR Media Object Added Sucessfully n", __FILE__, __LINE__));
- ERROR_HANDLE:
- if (ret_code != JC_OK)
- {
- if (media_info_p != NULL)
- {
- if (media_info_p->ContentData.pFileName != NULL)
- {
- jdd_MemFree(media_info_p->ContentData.pFileName);
- }
- if (media_info_p->MimeHeaders.pContentType != NULL)
- {
- jdd_MemFree(media_info_p->MimeHeaders.pContentType);
- }
- if (media_info_p->MimeHeaders.pContentID != NULL)
- {
- jdd_MemFree(media_info_p->MimeHeaders.pContentID);
- }
- if (media_info_p->MimeHeaders.pObjectName != NULL)
- {
- jdd_MemFree(media_info_p->MimeHeaders.pObjectName);
- }
- jdd_MemFree(media_info_p);
- }
- }
- if (temp_buffer_p != NULL)
- {
- jdd_MemFree(temp_buffer_p);
- }
- if(path_p != NULL)
- {
- jdd_MemFree(path_p);
- }
- if(vFileSysHandle)
- {
- jdd_FSDeinitialize(vFileSysHandle);
- vFileSysHandle = NULL;
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "(%d): JMMS JSR Media Object returns with RetCode(%d) n", __LINE__, ret_code));
- return (mmi_jmms_java_mms_error(ret_code));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_delete_temp_media_files
- * DESCRIPTION
- * Delete all the Temporary Media Files created while sending Java MMS
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_jsr_delete_temp_media_files(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- JC_CHAR *path_p = NULL;
- JC_INT8 temp_file_path[40] = {0, };
- JDD_FSHANDLE vFileSysHandle;
- JC_RETCODE eRet;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = jdd_FSInitialize(&vFileSysHandle);
- if (JC_OK == eRet)
- {
- for (i = 1; i < media_obj_index; i++)
- {
- jc_sprintf(temp_file_path, "@mms\temp\~jsr_temp_file%d", i);
- jdi_UtilsCharToTchar((JC_CHAR **) &(path_p), temp_file_path);
- if(path_p)
- {
- eRet = jdd_FSDelete(vFileSysHandle, path_p);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "JSR Media File(%d) Deleted with RetCode(%d):n", i, eRet));
- jdd_MemFree(path_p);
- path_p = NULL;
- }
- }
- jdd_FSDeinitialize(vFileSysHandle);
- }
- media_obj_index = 1;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_get_application_string_from_content_type
- * DESCRIPTION
- * Returns the pointer to starting position of substring in source string
- * PARAMETERS
- * contentType [IN]
- * str_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- S8* mmi_jmms_jsr_get_application_string_from_content_type(S8* contentType, jsr_string_id_enum str_id)
- {
- S8* str_pos = NULL;
- switch(str_id)
- {
- case JSR_APPLICATION_ID:
- str_pos = strstr(contentType, "application-id");
- if(str_pos == NULL)
- {
- str_pos = strstr(contentType, "Application-ID");
- }
- break;
- case JSR_REPLY_TO_APPLICATION_ID:
- str_pos = strstr(contentType, "reply-to-application-id");
- if(str_pos == NULL)
- {
- str_pos = strstr(contentType, "Reply-To-Application-ID");
- }
- break;
- }
- return str_pos;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_java_mms_set_content_type_params
- * DESCRIPTION
- *
- * PARAMETERS
- * resp [?] [?]
- * content_type [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_java_mms_set_content_type_params(wap_mmc_recv_appmms_rsp_struct *resp, JC_INT8 *content_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *str_pos = NULL;
- S8 *temp_str = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((str_pos = strstr(content_type, "start")) != NULL)
- {
- temp_str = str_pos;
- str_pos = strstr(temp_str, "=");
- temp_str = str_pos + 1;
- str_pos = strstr(temp_str, ";");
- if (str_pos == NULL)
- {
- resp->start_cnt_id_len = strlen(temp_str);
- }
- else
- {
- resp->start_cnt_id_len = strlen(temp_str) - strlen(str_pos);
- }
- if (resp->start_cnt_id_len > 99)
- {
- resp->start_cnt_id_len = 99;
- }
- memcpy(resp->start_cnt_id, temp_str, resp->start_cnt_id_len);
- }
- else
- {
- resp->start_cnt_id_len = 0;
- memset(resp->start_cnt_id, 0, 100);
- }
- //TO DO need to discuss this.
- // if((str_pos = strstr(content_type, "Reply-To-Application-ID")) != NULL)
- // if ((str_pos = strstr(content_type, "reply-to-application-id")) != NULL)
- if ((str_pos = mmi_jmms_jsr_get_application_string_from_content_type(content_type, JSR_REPLY_TO_APPLICATION_ID)) != NULL)
- {
- temp_str = str_pos;
- str_pos = strstr(temp_str, "=");
- temp_str = str_pos + 1;
- str_pos = strstr(temp_str, ";");
- if (str_pos == NULL)
- {
- resp->reply_app_id_len = strlen(temp_str);
- }
- else
- {
- resp->reply_app_id_len = strlen(temp_str) - strlen(str_pos);
- }
- if (resp->reply_app_id_len > 99)
- {
- resp->reply_app_id_len = 99;
- }
- memcpy(resp->reply_app_id, temp_str, resp->reply_app_id_len);
- }
- else
- {
- resp->reply_app_id_len = 0;
- memset(resp->reply_app_id, 0, 100);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_get_message_details
- * DESCRIPTION
- *
- * PARAMETERS
- * msgId [IN]
- * recv_callback [IN]
- * buffer(?) [IN](?)
- * resp [?](?)(?)
- * buff_size [?](?)(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_jsr_get_message_details(U32 msgId, MMI_JMMS_JSR_RETRIEVE_CALLBACK recv_callback)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- JC_UINT32 uiNumObjects = 0;
- // EMM1MessageType eMM1MsgType = 0;
- // CONTENT_DATA EncapsulatedContent = {0, };
- MESSAGE_LIST *list = NULL;
- MESSAGE_LIST *list_node = NULL;
- JC_INT32 index = 1;
- U16 result = 0;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- U8 count_msg = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_mms_get_number_of_messages(MMI_JMMS_INBOX, &count_msg);
- if (eRet != JC_OK)
- {
- result = JSR_RESULT_ERROR;
- goto END;
- }
- while (count_msg != 0)
- {
- if (count_msg <= NUM_MSGS_IN_ONE_UNIT) /* read 5 msgs at a time */
- {
- StoreRetFilter.uiNumMessage = count_msg;
- }
- else
- {
- StoreRetFilter.uiNumMessage = NUM_MSGS_IN_ONE_UNIT;
- }
- eRet = mmi_jmms_get_messages_list("Inbox", &list, &StoreRetFilter);
- if (eRet != JC_OK || list == NULL)
- {
- result = JSR_RESULT_ERROR;
- goto END;
- }
- list_node = list;
- while (list_node != NULL)
- {
- #ifdef __MMI_UNIFIED_MESSAGE__
- if ((list_node->uiExtraBytes & 0x00FFFFFF) == msgId)
- #else
- if (list_node->uiExtraBytes == msgId)
- #endif
- {
- break;
- }
- list_node = list_node->pNext;
- index++;
- }
- mmi_jmms_free_messages_list();
- list = NULL;
- StoreRetFilter.uiStartIndex = StoreRetFilter.uiStartIndex + StoreRetFilter.uiNumMessage;
- count_msg = count_msg - StoreRetFilter.uiNumMessage;
- }
- if (list_node == NULL)
- {
- result = JSR_RESULT_MESSAGE_ID_NOT_FOUND;
- goto END;
- }
- if (g_jmms_context->pParseContent != NULL)
- {
- jdd_MemFree(g_jmms_context->pParseContent);
- g_jmms_context->pParseContent = NULL;
- }
- if (g_jmms_context->pParseContent == NULL)
- {
- g_jmms_context->pParseContent = (CONTENT_DATA*) jdd_MemAlloc(sizeof(CONTENT_DATA), 1);
- }
- g_jmms_context->pParseContent->bIsStream = E_TRUE;
- /* /core itself setting the file name and read callback */
- eRet = mmi_jmms_get_message("Inbox", g_jmms_context->pParseContent, index);
- if (eRet != JC_OK || g_jmms_context->pParseContent->pFileName == NULL)
- {
- result = JSR_RESULT_ERROR;
- goto END;
- }
- if (g_jmms_context->hMM1 != NULL)
- {
- /*eRet = jdi_MM1Cleanup(g_jmms_context->hMM1, E_FALSE);*/
- /* Memory Leak Fix: jdi_MM1Cleanup is allocating memory for data chunk after freeing the context */
- eRet = jdi_MM1DeInitialize(g_jmms_context->hMM1);
- g_jmms_context->hMM1 = NULL;
- }
- eRet = jdi_MM1Initialize(&(g_jmms_context->hMM1));
- if (eRet != JC_OK)
- {
- result = JSR_RESULT_ERROR;
- goto END;
- }
- g_jmms_context->jsr_mms_receive_callback = recv_callback;
- eRet = jdi_MM1Decode(g_jmms_context->hMM1, g_jmms_context->pParseContent, E_PARSE_HEADERS_MIMEPARTS, MsgCtrl_CreateStream, &uiNumObjects); // TODO:: test it returns ok
- if (eRet == JC_ERR_MMS_PARSE_PENDING)
- {
- mmi_jmms_MM1_decode_continue_start_timer(uiNumObjects, mmi_jmms_jsr_async_get_message_details_callback);
- return;
- }
- mmi_jmms_jsr_async_get_message_details_callback(eRet);
- END:
- if (g_jmms_context->jsr_mms_receive_callback != NULL && result != 0)
- {
- wap_mmc_recv_appmms_rsp_struct *resp = NULL;
- resp = (wap_mmc_recv_appmms_rsp_struct*) jdd_MemAlloc(sizeof(wap_mmc_recv_appmms_rsp_struct), 1);
- if (resp != NULL)
- {
- resp->result = result;
- g_jmms_context->jsr_mms_receive_callback(resp, NULL, 0);
- }
- }
- if (g_jmms_context->pParseContent != NULL)
- {
- if (g_jmms_context->pParseContent->pFileName != NULL)
- {
- jdd_MemFree(g_jmms_context->pParseContent->pFileName);
- g_jmms_context->pParseContent->pFileName = NULL;
- }
- jdd_MemFree(g_jmms_context->pParseContent);
- g_jmms_context->pParseContent = NULL;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_async_get_message_details_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * eRet [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_jsr_async_get_message_details_callback(JC_RETCODE eRet)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- EMM1MessageType eMM1MsgType = 0;
- JC_UINT32 uiTempVal = 0;
- EMM1MessagePriority eMM1MessagePriority = E_MSG_PRIORITY_NORMAL;
- EMM1Charset eCharset = E_NONE;
- JC_INT8 *content_type = NULL;
- JC_CHAR *subject = NULL;
- JC_UINT32 subject_len = 0;
- MMS_ADDRESS_LIST *p_from_AddressList = NULL;
- MMS_ADDRESS_LIST *p_to_AddressList = NULL;
- MMS_ADDRESS_LIST *p_cc_AddressList = NULL;
- U32 address_len = 0;
- S8 *buf = NULL;
- U16 datalen = 0;
- U16 buf_size = 0;
- wap_mmc_recv_appmms_rsp_struct *resp = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- resp = (wap_mmc_recv_appmms_rsp_struct*) jdd_MemAlloc(sizeof(wap_mmc_recv_appmms_rsp_struct), 1);
- if (resp == NULL)
- {
- goto END;
- }
- if (eRet != JC_OK)
- {
- resp->result = JSR_RESULT_ERROR;
- goto END;
- }
- eRet = jdi_MM1GetMessageType(g_jmms_context->hMM1, &eMM1MsgType);
- if (eRet != JC_OK)
- {
- resp->result = JSR_RESULT_ERROR;
- goto END;
- }
- if (eMM1MsgType != E_MMS_RETRIEVE_CONFIRMATION_VALUE)
- {
- resp->result = JSR_RESULT_INVALID_MESSAGE;
- goto END;
- }
- uiTempVal = jdi_MM1GetDate(g_jmms_context->hMM1);
- if (uiTempVal)
- {
- resp->date = uiTempVal;
- }
- eRet = jdi_MM1GetPriority(g_jmms_context->hMM1, &eMM1MessagePriority);
- if (eRet == JC_OK)
- {
- resp->priority = eMM1MessagePriority;
- }
- else
- {
- resp->priority = 1; /* /E_MSG_PRIORITY_NORMAL */
- }
- if (g_jmms_context->jsr_total_object > 0)
- {
- U8 count = 0;
- MM1_CONTENT MM1Content = {0, };
- for (count = 0; count < g_jmms_context->jsr_total_object; count++)
- {
- jdi_MM1GetContent(g_jmms_context->hMM1, &MM1Content, count);
- if (jc_strstr(MM1Content.pszMimeType, "application/smil") != NULL)
- {
- resp->bdy_part_no = (U8) g_jmms_context->jsr_total_object - 1;
- break;
- }
- }
- if (count == g_jmms_context->jsr_total_object)
- {
- resp->bdy_part_no = (U8) g_jmms_context->jsr_total_object;
- }
- }
- else
- {
- resp->bdy_part_no = (U8) g_jmms_context->jsr_total_object;
- }
- content_type = (JC_INT8*) jdi_MM1GetContentType(g_jmms_context->hMM1);
- if (content_type == NULL)
- {
- resp->result = JSR_RESULT_ERROR;
- goto END;
- }
- mmi_jmms_java_mms_set_content_type_params(resp, content_type);
- eRet = jdi_MM1GetSubject(g_jmms_context->hMM1, &subject, &eCharset);
- /* subject */
- buf_size += 4; /* subject_data_len 4bytes; */
- if (subject)
- {
- buf_size += 4; /* subject_encode_type 4bytes */
- subject_len = mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) subject);
- buf_size += subject_len;
- }
- /* from address ///from address can be one only */
- eRet = jdi_MM1GetFromAddress(g_jmms_context->hMM1, &p_from_AddressList);
- if (eRet != JC_OK)
- {
- resp->result = JSR_RESULT_ERROR;
- goto END;
- }
- resp->from_addr_no = 0;
- if (p_from_AddressList != NULL && p_from_AddressList->pAddress != NULL)
- {
- resp->from_addr_no = 1;
- address_len = pfnUnicodeStrlen((S8*) (p_from_AddressList->pAddress));
- buf_size += (8 + address_len);
- }
- /* to address */
- eRet = jdi_MM1GetToAddress(g_jmms_context->hMM1, &p_to_AddressList);
- if (eRet != JC_OK)
- {
- resp->result = JSR_RESULT_ERROR;
- goto END;
- }
- resp->to_addr_no = 0;
- if (p_to_AddressList != NULL)
- {
- MMS_ADDRESS_LIST *to_list = p_to_AddressList;
- while (to_list)
- {
- if (to_list->pAddress)
- {
- resp->to_addr_no += 1;
- address_len = pfnUnicodeStrlen((S8*) (to_list->pAddress));
- buf_size += (8 + address_len);
- }
- to_list = to_list->pNext;
- }
- }
- /* cc address */
- eRet = jdi_MM1GetCCAddress(g_jmms_context->hMM1, &p_cc_AddressList);
- if (eRet != JC_OK)
- {
- resp->result = JSR_RESULT_ERROR;
- goto END;
- }
- resp->cc_addr_no = 0;
- if (p_cc_AddressList != NULL)
- {
- MMS_ADDRESS_LIST *cc_list = p_cc_AddressList;
- while (cc_list)
- {
- if (cc_list->pAddress)
- {
- resp->cc_addr_no += 1;
- address_len = pfnUnicodeStrlen((S8*) (cc_list->pAddress));
- buf_size += (8 + address_len);
- }
- cc_list = cc_list->pNext;
- }
- }
- buf = jdd_MemAlloc(sizeof(S8), buf_size);
- if (buf == NULL)
- {
- resp->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- goto END;
- }
- /* Pack subject */
- if (subject)
- {
- S8 *temp_subject = NULL;
- *(U32*) buf = subject_len;
- *(U32*) (buf + 4) = MMI_JMMS_JSR_SUBJECT_ENCODED_VALUE; /* /MMS_UTF8. Note::: Encoded value used is as given in mms_def.h file in Teleca. */
- /* /TODO:: may need to confirm value */
- temp_subject = jdd_MemAlloc(sizeof(S8), subject_len + 1);
- if (temp_subject == NULL)
- {
- resp->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- goto END;
- }
- mmi_chset_ucs2_to_utf8_string((U8*) temp_subject, (subject_len + 1), (U8*) subject);
- memcpy(buf + 8, temp_subject, subject_len);
- datalen += (8 + subject_len);
- if (temp_subject != NULL)
- {
- jdd_MemFree(temp_subject);
- temp_subject = NULL;
- }
- }
- else
- {
- *(U32*) buf = 0; /* subject_data_len=0 */
- datalen += 4;
- }
- /* Pack from address field */
- if (resp->from_addr_no == 1)
- {
- U32 temp_address_len = pfnUnicodeStrlen((S8*) (p_from_AddressList->pAddress));
- U32 address_type;
- S8 *temp_address = NULL;
- address_type = mmi_jmms_java_map_address_type(p_from_AddressList->eAddressType);
- memcpy((char*)(buf + datalen), &address_type, 4);
- memcpy((char*)(buf + datalen + 4), &temp_address_len, 4);
- temp_address = jdd_MemAlloc(sizeof(S8), temp_address_len + 1);
- if (temp_address == NULL)
- {
- resp->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- goto END;
- }
- UnicodeToAnsii(temp_address, (S8*) (p_from_AddressList->pAddress));
- memcpy((char*)(buf + datalen + 8), temp_address, temp_address_len);
- datalen += (8 + temp_address_len);
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- }
- /* /Pack to address field */
- if (p_to_AddressList)
- {
- MMS_ADDRESS_LIST *to_list = p_to_AddressList;
- while (to_list)
- {
- if (to_list->pAddress)
- {
- U32 temp_address_len = pfnUnicodeStrlen((S8*) (to_list->pAddress));
- U32 address_type;
- S8 *temp_address = NULL;
- address_type = mmi_jmms_java_map_address_type(to_list->eAddressType);
- memcpy((char*)(buf + datalen), &address_type, 4);
- memcpy((char*)(buf + datalen + 4), &temp_address_len, 4);
- temp_address = jdd_MemAlloc(sizeof(S8), temp_address_len + 1);
- if (temp_address == NULL)
- {
- resp->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- goto END;
- }
- UnicodeToAnsii(temp_address, (S8*) (to_list->pAddress));
- memcpy((char*)(buf + datalen + 8), temp_address, temp_address_len);
- datalen += (8 + temp_address_len);
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- }
- to_list = to_list->pNext;
- }
- }
- /* Pack cc address field */
- if (p_cc_AddressList)
- {
- MMS_ADDRESS_LIST *cc_list = p_cc_AddressList;
- while (cc_list)
- {
- if (cc_list->pAddress)
- {
- U32 temp_address_len = pfnUnicodeStrlen((S8*) (cc_list->pAddress));
- U32 address_type;
- S8 *temp_address = NULL;
- address_type = mmi_jmms_java_map_address_type(cc_list->eAddressType);
- memcpy((char*)(buf + datalen), &address_type, 4);
- memcpy((char*)(buf + datalen + 4), &temp_address_len, 4);
- temp_address = jdd_MemAlloc(sizeof(S8), temp_address_len + 1);
- if (temp_address == NULL)
- {
- resp->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- goto END;
- }
- UnicodeToAnsii(temp_address, (S8*) (cc_list->pAddress));
- memcpy((char*)(buf + datalen + 8), temp_address, temp_address_len);
- datalen += (8 + temp_address_len);
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- }
- cc_list = cc_list->pNext;
- }
- }
- resp->result = (U8) mmi_jmms_java_mms_error(JC_OK);
- END:
- if (g_jmms_context->jsr_mms_receive_callback != NULL)
- {
- if (resp != NULL)
- {
- g_jmms_context->jsr_mms_receive_callback(resp, buf, datalen);
- }
- }
- if (g_jmms_context->pParseContent != NULL)
- {
- if (g_jmms_context->pParseContent->pFileName != NULL)
- {
- jdd_MemFree(g_jmms_context->pParseContent->pFileName);
- g_jmms_context->pParseContent->pFileName = NULL;
- }
- jdd_MemFree(g_jmms_context->pParseContent);
- g_jmms_context->pParseContent = NULL;
- }
- if (p_from_AddressList != NULL)
- {
- FreeAddressList(p_from_AddressList);
- }
- if (p_to_AddressList != NULL)
- {
- FreeAddressList(p_to_AddressList);
- }
- if (p_cc_AddressList != NULL)
- {
- FreeAddressList(p_cc_AddressList);
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_java_map_address_type
- * DESCRIPTION
- *
- * PARAMETERS
- * type [IN]
- * RETURNS
- *
- *****************************************************************************/
- mmi_jmms_java_addresses_type mmi_jmms_java_map_address_type(MMSAddressTypes type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (type)
- {
- case E_PLMN:
- return MMS_PLMN;
- case E_IPV4:
- return MMS_IPV4;
- case E_MAIL:
- return MMS_EMAIL;
- case E_IPV6:
- default:
- return MMS_UNSUPPORTED;
- }
- return MMS_UNSUPPORTED;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_generate_recv_msg_body_part
- * DESCRIPTION
- *
- * PARAMETERS
- * msgId [IN]
- * bdy_part_no [?] [?]
- * total_objects [IN]
- * response [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_jmms_jsr_generate_recv_msg_body_part(
- U32 msgId,
- U8 *bdy_part_no,
- U8 total_objects,
- wap_mmc_read_appmms_msg_part_rsp_struct *response)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MM1_CONTENT MM1Content = {0, };
- MM1_HANDLE hMM1 = NULL;
- JC_RETCODE eRet = JC_OK;
- S8 *str_pos = NULL;
- S8 *temp_str = NULL;
- int read_handle = -1;
- int write_handle = -1;
- S8 *filename = NULL;
- S8 *media_buffer_p = NULL;
- int result = 0;
- U32 bytes_written = 0;
- S32 file_size = 0;
- S32 buf_size = 0;
- U8 part_no = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- part_no = (*bdy_part_no - 1);
- if (g_jmms_context->hMM1 != NULL)
- {
- hMM1 = g_jmms_context->hMM1;
- }
- else
- {
- return FALSE;
- }
- eRet = jdi_MM1GetContent(hMM1, &MM1Content, part_no);
- if (jc_strstr(MM1Content.pszMimeType, "application/smil") != NULL)
- {
- eRet = jdi_MM1GetContent(hMM1, &MM1Content, part_no + 1);
- *bdy_part_no += 1;
- }
- response->result = JSR_RESULT_OK;
- /* for content type: */
- if ((str_pos = strstr((S8*) MM1Content.pszMimeType, ";")) != NULL)
- {
- response->content_type_len = str_pos - MM1Content.pszMimeType;
- }
- if (response->content_type_len > 255)
- {
- response->content_type_len = 255;
- }
- memset(response->content_type, 0, response->content_type_len + 1);
- strncpy((S8*) response->content_type, (S8*) MM1Content.pszMimeType, (U8) response->content_type_len); /* query */
- /* For encoding scheme: */
- temp_str = str_pos + 1;
- if ((str_pos = strstr((S8*) temp_str, "Charset=utf-8")) != NULL)
- {
- response->encoding_scheme = MMS_UTF8;
- }
- else if ((str_pos = strstr((S8*) temp_str, "Charset=iso-8859-1")) != NULL)
- {
- response->encoding_scheme = MMS_ISO_8859_1;
- }
- else if ((str_pos = strstr((S8*) temp_str, "Charset=utf-16")) != NULL)
- {
- response->encoding_scheme = (U8) MMS_UTF16;
- }
- else if ((str_pos = strstr((S8*) temp_str, "Charset=us-ascii")) != NULL)
- {
- response->encoding_scheme = MMS_US_ASCII;
- }
- else
- {
- response->encoding_scheme = MMS_UNKNOWN_CHARSET;
- }
- /* for content id: */
- response->content_id_len = strlen(MM1Content.pszContentID);
- if (response->content_id_len < 100)
- {
- strcpy((S8*) response->content_id, (S8*) MM1Content.pszContentID); /* query */
- }
- else
- {
- response->content_id_len = 99;
- memset(response->content_id, 0, response->content_id_len + 1);
- strncpy((S8*) response->content_id, (S8*) MM1Content.pszContentID, response->content_id_len); /* query */
- }
- /* for content location: */
- response->content_location_len = strlen(MM1Content.pszObjectName);
- if (response->content_location_len < 100)
- {
- strcpy((S8*) response->content_location, (S8*) MM1Content.pszObjectName); /* query */
- }
- else
- {
- response->content_location_len = 99;
- memset(response->content_location, 0, response->content_location_len + 1);
- strncpy((S8*) response->content_location, (S8*) MM1Content.pszObjectName, response->content_location_len); /* query */
- }
- /* for file path: */
- if (MM1Content.MimeData.bIsStream == 1)
- {
- filename = (S8*) jdd_MemAlloc(sizeof(S8), 100);
- if (NULL == filename)
- {
- response->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR Insufficient Memory. n", __FILE__, __LINE__));
- return FALSE;
- }
- AnsiiToUnicodeString((S8*) filename, (S8*) (JSR_MEDIA_OBJECT_FILE));
- FS_Delete((U16*) filename);
- write_handle = FS_Open((U16*) (filename), FS_CREATE_ALWAYS | FS_READ_WRITE);
- if (write_handle < 0)
- {
- response->result = JSR_RESULT_FILE_OPERATION_ERROR;
- jdd_MemFree(filename);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR File Operation Error n", __FILE__, __LINE__));
- return FALSE;
- }
- read_handle = FS_Open(MM1Content.MimeData.pFileName, FS_READ_ONLY);
- if (read_handle < 0)
- {
- response->result = JSR_RESULT_FILE_OPERATION_ERROR;
- jdd_MemFree(filename);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR File Operation Error n", __FILE__, __LINE__));
- return FALSE;
- }
- media_buffer_p = (S8*) jdd_MemAlloc(sizeof(S8), (512 + 1));
- if (NULL == media_buffer_p)
- {
- response->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- jdd_MemFree(filename);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR Insufficient Memory n", __FILE__, __LINE__));
- return FALSE;
- }
- FS_Seek(read_handle, MM1Content.MimeData.uiStartOffset, FS_FILE_BEGIN);
- file_size = MM1Content.MimeData.uiTotalSize;
- while (file_size)
- {
- if (file_size > 512)
- {
- buf_size = 512;
- }
- else
- {
- buf_size = file_size;
- }
- ASSERT(FS_Read(read_handle, media_buffer_p, buf_size, &bytes_written) == 0);
- result = FS_Write(write_handle, media_buffer_p, buf_size, &bytes_written);
- if (FS_NO_ERROR != result)
- {
- response->result = JSR_RESULT_FILE_OPERATION_ERROR;
- FS_Close(read_handle);
- FS_Close(write_handle);
- jdd_MemFree(filename);
- jdd_MemFree(media_buffer_p);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR File Operation Error n", __FILE__, __LINE__));
- return FALSE;
- }
- file_size -= buf_size;
- }
- FS_Close(read_handle);
- FS_Close(write_handle);
- response->filepath_len = pfnUnicodeStrlen((S8*) filename);
- memset(response->filepath, 0, ((response->filepath_len + 1) * 2));
- pfnUnicodeStrcpy((S8*) response->filepath, (S8*) filename);
- jdd_MemFree(filename);
- jdd_MemFree(media_buffer_p);
- }
- else
- {
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- eRet = JC_ERR_FILE_SYS_INIT;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR File System Init Error n", __FILE__, __LINE__));
- return FALSE;
- }
- }
- filename = (S8*) jdd_MemAlloc(sizeof(S8), 100);
- if (NULL == filename)
- {
- response->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR Insufficient Memory n", __FILE__, __LINE__));
- return FALSE;
- }
- AnsiiToUnicodeString((S8*) filename, (S8*) (JSR_MEDIA_OBJECT_FILE));
- FS_Delete((U16*) filename);
- write_handle = FS_Open((U16*) (filename), FS_CREATE_ALWAYS | FS_READ_WRITE);
- if (write_handle < 0)
- {
- response->result = JSR_RESULT_FILE_OPERATION_ERROR;
- jdd_MemFree(filename);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR File Operation Error n", __FILE__, __LINE__));
- return FALSE;
- }
- media_buffer_p = (S8*) jdd_MemAlloc(sizeof(S8), (512 + 1));
- if (NULL == media_buffer_p)
- {
- response->result = JSR_RESULT_INSUFFICIENT_MEMORY;
- jdd_MemFree(filename);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR Insufficient Memory n", __FILE__, __LINE__));
- return FALSE;
- }
- if (MM1Content.MimeData.uiTotalSize > 0)
- {
- if ((response->encoding_scheme == MMS_US_ASCII) || (response->encoding_scheme == MMS_UTF8))
- {
- response->encoding_scheme = MMS_UTF8;
- buf_size = mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) MM1Content.MimeData.pBuffer);
- mmi_chset_ucs2_to_utf8_string(
- (U8*) media_buffer_p,
- (buf_size + 1),
- (U8*) MM1Content.MimeData.pBuffer);
- result = FS_Write(write_handle, media_buffer_p, buf_size, &bytes_written);
- }
- else
- {
- result = FS_Write(
- write_handle,
- MM1Content.MimeData.pBuffer,
- MM1Content.MimeData.uiTotalSize,
- &bytes_written);
- }
- }
- if (FS_NO_ERROR != result)
- {
- response->result = JSR_RESULT_FILE_OPERATION_ERROR;
- FS_Close(write_handle);
- jdd_MemFree(filename);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JMMS JSR File Operation Error n", __FILE__, __LINE__));
- return FALSE;
- }
- FS_Close(write_handle);
- response->filepath_len = pfnUnicodeStrlen((S8*) filename);
- memset(response->filepath, 0, ((response->filepath_len + 1) * 2));
- pfnUnicodeStrcpy((S8*) response->filepath, (S8*) filename);
- jdd_MemFree(filename);
- }
- if (total_objects == *bdy_part_no)
- {
- /* jdi_MM1Cleanup(g_jmms_context->hMM1, E_FALSE); */
- jdi_MM1DeInitialize(g_jmms_context->hMM1);
- g_jmms_context->hMM1 = NULL;
- }
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_check_msg_id
- * DESCRIPTION
- *
- * PARAMETERS
- * msgId [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_jmms_check_msg_id(U32 msgId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MESSAGE_LIST *pMessageList = NULL;
- MESSAGE_LIST *pTempMessageList = NULL;
- S8 fname[100];
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(fname, 0, 100);
- mmi_jmms_get_folder_name_from_folderId(JSR_INBOX, fname);
- /* /manish chnging here 0n 2 Feb */
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- mmi_jmms_get_messages_list((S8*) fname, &pMessageList, &StoreRetFilter);
- pTempMessageList = pMessageList;
- while (pTempMessageList)
- {
- #ifdef __MMI_UNIFIED_MESSAGE__
- if ((pTempMessageList->uiExtraBytes & 0x00FFFFFF) == msgId)
- #else
- if (pTempMessageList->uiExtraBytes == msgId)
- #endif
- {
- return TRUE;
- }
- pTempMessageList = pTempMessageList->pNext;
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_update_folder
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_update_folder(void)
- {
- #ifdef __MMI_UNIFIED_MESSAGE__
- mmi_um_jmms_refresh_ind();
- #else /* __MMI_UNIFIED_MESSAGE__ */
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 screen_id;
- S16 is_screen_update = 1;
- S8 *pFolderName = NULL;
- MESSAGE_LIST *pMessageList = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- void (*entry_folder_screen_callback_hldr) (void) = NULL;
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- screen_id = GetActiveScreenId();
- switch (screen_id)
- {
- case SCR_ID_JMMS_MAIN_MENU:
- break;
- case SCR_ID_JMMS_INBOX:
- pFolderName = (S8*) MMI_JMMS_INBOX;
- entry_folder_screen_callback_hldr = mmi_jmms_entry_inbox_screen;
- break;
- case SCR_ID_JMMS_OUTBOX:
- pFolderName = (S8*) MMI_JMMS_OUTBOX;
- entry_folder_screen_callback_hldr = mmi_jmms_entry_outbox_screen;
- break;
- case SCR_ID_JMMS_SENT:
- pFolderName = (S8*) MMI_JMMS_SENT;
- entry_folder_screen_callback_hldr = mmi_jmms_entry_sent_screen;
- break;
- case SCR_ID_JMMS_DRAFTS:
- pFolderName = (S8*) MMI_JMMS_DRAFTS;
- entry_folder_screen_callback_hldr = mmi_jmms_entry_drafts_screen;
- break;
- default:
- is_screen_update = 0;
- break;
- }
- if (is_screen_update == 0)
- {
- return;
- }
- if (pFolderName != NULL)
- {
- mmi_jmms_get_messages_list((S8*) pFolderName, &pMessageList, &StoreRetFilter);
- if (pMessageList == NULL)
- {
- GoBackToHistory(SCR_ID_JMMS_MAIN_MENU);
- return;
- }
- entry_folder_screen_callback_hldr();
- }
- else
- {
- mmi_jmms_entry_main_menu();
- DeleteNHistory(1);
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_delete_msg
- * DESCRIPTION
- *
- * PARAMETERS
- * msgId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_jsr_delete_msg(U32 msgId)
- {
- mmi_jmms_delete_message_as_per_id(msgId);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_send_mms
- * DESCRIPTION
- *
- * PARAMETERS
- * send_callback [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_jsr_send_mms(MMI_JMMS_JSR_SEND_CALLBACK send_callback)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- // CONTENT_DATA EncapsulatedContent = {0, };
- // COMM_FETCH_URL fetchUrlInfo = {0, };
- static U32 unique_value = 0;
- JC_INT8 Temp[50] = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* PMT HIMANSHU START 20060425 */
- mmi_jmms_set_mms_downloading_busy();
- mmi_jmms_update_status_icon_indicator();
- /* PMT HIMANSHU END 20060425 */
- if (g_jmms_context->hMM1 == NULL)
- {
- (*send_callback) (mmi_jmms_java_mms_error(JC_ERR_MSG_INVALID_HANDLE));
- return;
- }
- if (g_jmms_context->pSendContent != NULL)
- {
- jdd_MemFree(g_jmms_context->pSendContent);
- g_jmms_context->pSendContent = NULL;
- }
- if (g_jmms_context->pSendContent == NULL)
- {
- g_jmms_context->pSendContent = (CONTENT_DATA*) jdd_MemAlloc(sizeof(CONTENT_DATA), 1);
- }
- g_jmms_context->pSendContent->bIsStream = E_TRUE;
- g_jmms_context->pSendContent->cbWriteCallback = mmi_jmms_write_callback;
- unique_value++;
- if (unique_value > 200000)
- {
- unique_value = 0;
- }
- jc_sprintf(Temp, "%s%d", "@mms\temp\jmms_tempJSendBuff", unique_value);
- jdi_UtilsCharToTchar((JC_CHAR **) & (g_jmms_context->pSendContent->pStream), Temp);
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- /* return JC_ERR_FILE_SYS_INIT; */
- (*send_callback) (JSR_RESULT_ERROR);
- return;
- }
- }
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, g_jmms_context->pSendContent->pStream);
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- g_jmms_context->pSendContent->pFileName = g_jmms_context->pSendContent->pStream;
- g_jmms_context->jsr_mms_send_callback = send_callback;
- eRet = jdi_MM1GetEncodedStream(g_jmms_context->hMM1, g_jmms_context->pSendContent);
- if (eRet == JC_ERR_MMS_ENCODE_PENDING)
- {
- mmi_jmms_MM1_encode_continue_start_timer();
- }
- else
- {
- mmi_jmms_mm1_send_callback(eRet);
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_mm1_send_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * eRet [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_mm1_send_callback(JC_RETCODE eRet)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *temp = NULL;
- COMM_FETCH_URL fetchUrlInfo = {0, };
- JC_CHAR *fileptr = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (JC_OK != eRet)
- {
- /*jdi_MM1Cleanup(g_jmms_context->hMM1, E_FALSE);*/
- /* Memory Leak Fix: jdi_MM1Cleanup is allocating memory for data chunk after freeing the context */
- jdi_MM1DeInitialize(g_jmms_context->hMM1);
- g_jmms_context->hMM1 = NULL;
- goto END;
- }
- /*jdi_MM1Cleanup(g_jmms_context->hMM1, E_FALSE);*/
- /* Memory Leak Fix: jdi_MM1Cleanup is allocating memory for data chunk after freeing the context */
- jdi_MM1DeInitialize(g_jmms_context->hMM1);
- g_jmms_context->hMM1 = NULL;
- fetchUrlInfo.eContentMode = E_COMM_BUFFER;
- temp = mmi_jmms_get_activated_mmsc_url(g_jmms_context);
- fetchUrlInfo.pszURL = (JC_CHAR*) temp;
- fetchUrlInfo.pszContentType = "application/vnd.wap.mms-message";
- if (g_jmms_context->pSendContent->bIsStream == E_FALSE)
- {
- fetchUrlInfo.bIsFile = E_FALSE;
- fetchUrlInfo.uUserDataMode.pucPostData = g_jmms_context->pSendContent->pBuffer;
- }
- else
- {
- fetchUrlInfo.bIsFile = E_TRUE;
- fetchUrlInfo.uUserDataMode.pmFileName = g_jmms_context->pSendContent->pFileName;
- }
- fetchUrlInfo.uiPostLen = g_jmms_context->pSendContent->uiTotalSize;
- fetchUrlInfo.pHeadersInfo = NULL;
- fetchUrlInfo.eCommFetchType = E_COMM_FETCH_POST;
- g_jmms_context->uiReferenceID = 0;
- eRet = jdi_CommunicationFetchURL(g_jmms_context->hCommHandle, &fetchUrlInfo, &(g_jmms_context->uiReferenceID));
- if (eRet == JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d):n", "JMMS JSR Comm Fetch Send", g_jmms_context->uiReferenceID));
- fileptr = jdi_UtilsTcsDup(g_jmms_context->pSendContent->pFileName);
- eRet = mmi_jmms_add_comm_node(
- g_jmms_context,
- g_jmms_context->uiReferenceID,
- E_TYPE_NEW_JAVA_MMS_SEND,
- fileptr,
- 0,
- 1,
- NULL);
- if (eRet != JC_OK)
- {
- eRet = jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
- g_jmms_context->uiReferenceID = 0;
- eRet = E_JMMS_GENERAL_ERROR;
- goto END;
- }
- }
- else
- {
- goto END;
- }
- END:
- if (eRet != JC_OK)
- {
- /* PMT VIKAS START 20060401 */
- mmi_jmms_reset_mms_downloading_busy();
- mmi_jmms_update_status_icon_indicator();
- /* PMT VIKAS END 20060401 */
- if (g_jmms_context->pSendContent != NULL && g_jmms_context->pSendContent->pStream != NULL)
- {
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- /* return JC_ERR_FILE_SYS_INIT; */
- g_jmms_context->jsr_mms_send_callback(JSR_RESULT_ERROR);
- return;
- }
- }
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, g_jmms_context->pSendContent->pStream);
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- }
- if (fileptr != NULL)
- {
- jdd_MemFree(fileptr);
- }
- g_jmms_context->jsr_mms_send_callback(JSR_RESULT_ERROR);
- return;
- }
- if (g_jmms_context->pSendContent != NULL)
- {
- if (g_jmms_context->pSendContent->pStream != NULL)
- {
- jdd_MemFree(g_jmms_context->pSendContent->pStream);
- g_jmms_context->pSendContent->pStream = NULL;
- }
- jdd_MemFree(g_jmms_context->pSendContent);
- g_jmms_context->pSendContent = NULL;
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_cancel_send_mms
- * DESCRIPTION
- *
- * PARAMETERS
- * msgId [IN]
- * cancel_callback [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_jsr_cancel_send_mms(U32 msgId, MMI_JMMS_JSR_SEND_CALLBACK cancel_callback)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = jdi_CommunicationStopReq(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
- if (eRet != JC_OK)
- {
- eRet = jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
- g_jmms_context->uiReferenceID = 0;
- (*cancel_callback) (JSR_RESULT_ERROR);
- return;
- }
- eRet = jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
- g_jmms_context->uiReferenceID = 0;
- g_jmms_context->jsr_mms_send_cancel_callback = cancel_callback;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_content_type
- * DESCRIPTION
- *
- * PARAMETERS
- * pEncapsulatedContent [?] [?]
- * mms_content_type [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_get_content_type(CONTENT_DATA *pEncapsulatedContent, JC_INT8 **mms_content_type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- MM1_HANDLE hMM1 = NULL;
- CONTENT_DATA Decode;
- JC_UINT32 uiNumObjects = 0;
- EMM1MessageType eMM1MsgType = 0;
- JC_INT8 *content_type = NULL;
- U32 len = 0;
- JC_INT8 *temp_content_type = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d) Enters mmi_jmms_get_content_type", __FILE__, __LINE__));
- eRet = jdi_MM1Initialize(&hMM1);
- if (eRet != JC_OK)
- {
- goto END;
- }
- jc_memset(&Decode, 0, sizeof(CONTENT_DATA));
- /* /for file streaming */
- Decode = *pEncapsulatedContent;
- eRet = jdi_MM1Decode(hMM1, &Decode, E_PARSE_HEADERS_ONLY, MsgCtrl_CreateStream, &uiNumObjects); // TODO:: test it returns ok
- while (eRet == JC_ERR_MMS_PARSE_PENDING)
- {
- mmi_jmms_MM1_decode_continue_start_timer(uiNumObjects, NULL);
- }
- if (eRet != JC_OK)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION; /* eror type doesn't matter */
- goto END;
- }
- eRet = jdi_MM1GetMessageType(hMM1, &eMM1MsgType);
- if (eRet != JC_OK)
- {
- goto END;
- }
- if (eMM1MsgType != E_MMS_RETRIEVE_CONFIRMATION_VALUE)
- {
- eRet = E_JMMS_GENERAL_ERROR; /* eror type doesn't matter */
- goto END;
- }
- content_type = (JC_INT8*) jdi_MM1GetContentType(hMM1);
- if (content_type == NULL)
- {
- eRet = E_JMMS_GENERAL_ERROR;
- goto END;
- }
- len = strlen((const char*)content_type);
- temp_content_type = (JC_INT8*) jdd_MemAlloc(sizeof(JC_INT8), len + 1);
- if (temp_content_type == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- *mms_content_type = temp_content_type;
- strcpy((char*)temp_content_type, (const char*)content_type);
- END:
- jdi_MM1DeInitialize(hMM1);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "(%d) Exits mmi_jmms_get_content_type with retcode %d", __LINE__, eRet));
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_is_message_found
- * DESCRIPTION
- *
- * PARAMETERS
- * folderId [IN]
- * msgId [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_is_message_found(U8 folderId, U32 msgId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MESSAGE_LIST *pMessageList = NULL;
- MESSAGE_LIST *pTempMessageList = NULL;
- S8 fname[100];
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(fname, 0, 100);
- mmi_jmms_get_folder_name_from_folderId(folderId, fname);
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- mmi_jmms_get_messages_list((S8*) fname, &pMessageList, &StoreRetFilter);
- pTempMessageList = pMessageList;
- while (pTempMessageList)
- {
- #ifdef __MMI_UNIFIED_MESSAGE__
- if ((pTempMessageList->uiExtraBytes & 0x00FFFFFF) == msgId)
- #else
- if (pTempMessageList->uiExtraBytes == msgId)
- #endif
- {
- return JC_OK;
- }
- pTempMessageList = pTempMessageList->pNext;
- }
- return JC_ERR_NOT_FOUND;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_MM1_encode_continue_start_timer
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_MM1_encode_continue_start_timer(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StartTimer(JMMS_ASYNC_SEND_TIMER, JMMS_ASYNC_EVENT_TIME, mmi_jmms_mm1_encode_continue_callback);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_mm1_encode_continue_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_mm1_encode_continue_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StopTimer(JMMS_ASYNC_SEND_TIMER);
- eRet = jdi_MM1EncodeNextPart(g_jmms_context->hMM1);
- if (eRet == JC_ERR_MMS_ENCODE_PENDING)
- {
- StartTimer(JMMS_ASYNC_SEND_TIMER, JMMS_ASYNC_EVENT_TIME, mmi_jmms_mm1_encode_continue_callback);
- }
- else
- {
- mmi_jmms_mm1_send_callback(eRet);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_MM1_decode_continue_start_timer
- * DESCRIPTION
- *
- * PARAMETERS
- * total_obj [IN]
- * new_err_cb [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_MM1_decode_continue_start_timer(JC_UINT32 total_obj, error_callback new_err_cb)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_jmms_context->async_parse_context.is_re_entrant=1;
- StartTimer(JMMS_ASYNC_PARSE_TIMER, JMMS_ASYNC_EVENT_TIME, mmi_jmms_mm1_decode_continue_callback);
- g_jmms_context->jsr_total_object = total_obj;
- g_jmms_context->async_parse_context.callback = new_err_cb;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_mm1_decode_continue_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_mm1_decode_continue_callback(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StopTimer(JMMS_ASYNC_PARSE_TIMER);
- eRet = jdi_MM1DecodeNextPart(g_jmms_context->hMM1, &g_jmms_context->jsr_total_object);
- if (eRet == JC_ERR_MMS_PARSE_PENDING)
- {
- StartTimer(JMMS_ASYNC_PARSE_TIMER, JMMS_ASYNC_EVENT_TIME, mmi_jmms_mm1_decode_continue_callback);
- }
- else
- {
- mmi_jmms_parse_call_error_callback(eRet);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_attachment_filepath
- * DESCRIPTION
- * This function is written to get the virtual file path, required during the
- * installation of JAVA.
- * PARAMETERS
- * filename [IN]
- * msg [OUT]
- * RETURNS
- * void
- *
- * Date : July 19, 2006(?)
- * Written By : RAJ KUMAR GUPTA(?)
- *****************************************************************************/
- void mmi_jmms_get_attachment_filepath(S8 *filename, mms_get_attachment_rsp_struct *msg)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 media_count = 0;
- MEDIA_INFO *media_info;
- MEDIA_MIME_INFO *pMimeInfo = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msg->result = 0;
- /* Get the number of attachment with the MMS */
- mmi_jmms_jdi_get_media_count(g_jmms_context->msg_handle, 0, &media_count, E_TRUE);
- /* Atleast 2 files should be there that are .jar and .jad */
- if (media_count < 2)
- {
- return;
- }
- /* Get the MMS attachment information */
- if (mmi_jmms_compose_get_media_list(0, &media_info, &media_count, E_TRUE) == JMMS_COMP_OK)
- {
- U8 count = 0;
- for (count = 0; count < media_count; count++)
- {
- /* Check for the required file */
- if (pfnUnicodeStrcmp((S8*) filename, (S8*) media_info->pMimeInfo->MimeHeaders.pObjectName) == 0)
- {
- /* File name matched. Set the result as 1. */
- msg->result = 1;
- break;
- }
- /* Move to the next attachment information node */
- media_info = media_info->pNext;
- }
- /* If the required file not found */
- if (msg->result == 0)
- {
- return;
- }
- /* Get the information of required attachment file. */
- pMimeInfo = media_info->pMimeInfo;
- /* Get the Virtual file name of the required attachment file. */
- pfnUnicodeStrcpy((kal_char*) msg->filepath, (kal_char*) pMimeInfo->ContentData.pFileName);
- }
- }
- #endif /* MMI_JMMS_JAVA_MMS_SUPPORT */
- #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */
- #endif /* _MMI_JMMSJSRHANDLER_C */